diff --git a/desktop-tauri/ui-islands/src/islands/routing-config-panel.tsx b/desktop-tauri/ui-islands/src/islands/routing-config-panel.tsx index f8fc38c8..367746bf 100644 --- a/desktop-tauri/ui-islands/src/islands/routing-config-panel.tsx +++ b/desktop-tauri/ui-islands/src/islands/routing-config-panel.tsx @@ -188,7 +188,7 @@ export function RoutingConfigPanel({ editor, scope, now, accountControl, refresh : null} {inherited ?

{t('没有独立配置的模型沿用全局路由。')}

: null}
-
mutate(next => { next.strategy = value === '__inherit' ? undefined : value })} />
@@ -196,7 +196,7 @@ export function RoutingConfigPanel({ editor, scope, now, accountControl, refresh options={[...(scope ? [['__inherit', t('继承全局:{value}', { value: stickyLabel(workspace.globalSettings?.routingSticky) })] as [string, string]] : []), ['auto', t('自动')], ['session', t('会话内')], ['turn', t('每轮')], ['off', t('关闭')]]} onChange={value => mutate(next => { next.sticky = value === '__inherit' ? undefined : value })} />
- {!globalAccounts ?
mutate(next => { next.providerScope = value === 'all' ? 'all' : 'selected'; next.providers = allProviders; next.disabledProviders = excluded })} />
: null} diff --git a/desktop-tauri/ui-islands/src/islands/routing-page.tsx b/desktop-tauri/ui-islands/src/islands/routing-page.tsx index d4325c78..bd1a86ee 100644 --- a/desktop-tauri/ui-islands/src/islands/routing-page.tsx +++ b/desktop-tauri/ui-islands/src/islands/routing-page.tsx @@ -60,6 +60,18 @@ export function RoutingPage() { const titleEditor = useSpecialEditor(special.title, mode === 'config' && specialKey === 'title') const specialDirty = (compactEditor.dirty ? 1 : 0) + (visionEditor.dirty ? 1 : 0) + (titleEditor.dirty ? 1 : 0) const dirtyCount = editor.dirtyCount + groups.dirtyCount + specialDirty + // 页面岛跨页切换不卸载:从模型页改完映射 / 拉完模型回到路由页时,特殊请求 + // 路由的模型下拉要重新对齐一次清单。参考数据只读不写,静默失败沿用旧清单 + React.useEffect(() => { + const onPage = (event: Event) => { + if ((event as CustomEvent).detail !== 'routing') return + if (mode !== 'config' || !specialKey) return + const editors = { compact: compactEditor, vision: visionEditor, title: titleEditor } + void editors[specialKey].refreshView() + } + window.addEventListener('wb:page', onPage) + return () => window.removeEventListener('wb:page', onPage) + }, [mode, specialKey, compactEditor.refreshView, visionEditor.refreshView, titleEditor.refreshView]) const [modal, setModal] = React.useState< | { kind: 'sticky' } | { kind: 'account' | 'sort'; id: string } diff --git a/desktop-tauri/ui-islands/src/islands/routing-special-state.ts b/desktop-tauri/ui-islands/src/islands/routing-special-state.ts index e2c62e70..a5b82cc8 100644 --- a/desktop-tauri/ui-islands/src/islands/routing-special-state.ts +++ b/desktop-tauri/ui-islands/src/islands/routing-special-state.ts @@ -137,6 +137,8 @@ export type SpecialEditor = { update(mutate: (draft: T) => T): void save(): Promise reload(): Promise + /** 只刷新模型 / 客户端等参考数据,配置、修订号与未保存草稿保持不变 */ + refreshView(): Promise discard(): void } @@ -159,6 +161,10 @@ export function useSpecialEditor( const sequence = React.useRef(0) /** 服务端最新状态:保存要用它的 revision,失败回滚也回到它 */ const latest = React.useRef(null) + /** view 的镜像:参考数据合并要读当前值,避免闭包拿到旧 state */ + const viewRef = React.useRef(null) + /** 参考数据刷新自己的序号,与 reload 的 sequence 分开,互不打断对方的收尾 */ + const refreshSequence = React.useRef(0) React.useEffect(() => { alive.current = true @@ -167,11 +173,35 @@ export function useSpecialEditor( const adopt = React.useCallback((next: V) => { latest.current = next + viewRef.current = next setView(next) setDraft(structuredClone(next.config)) }, []) + /** + * 只刷新参考数据(模型 / 客户端 / 上限等),配置与修订号保持现值,草稿不动。 + * + * 模型映射与获取模型发生在模型页或路由页的其他面板,页面岛跨页切换不卸载, + * 只靠首次激活拉一次数据会让模型下拉停留在旧清单;面板重新可见时调用这里 + * 对齐一次。静默失败沿用现有清单,下次触发再试 + */ + const refreshView = React.useCallback(async () => { + if (!latest.current) return + const token = ++refreshSequence.current + try { + const next = await api.load() + if (!alive.current || token !== refreshSequence.current) return + const current = viewRef.current + const merged = current ? { ...next, config: current.config, revision: current.revision } : next + latest.current = merged + viewRef.current = merged + setView(merged) + } catch { /* 参考数据刷新失败沿用现有清单 */ } + }, [api]) + const reload = React.useCallback(async () => { + // 手动重读代表用户要求的整份最新状态,在途参考数据刷新不能再晚到覆盖 + refreshSequence.current++ const token = ++sequence.current setLoading(true); setError('') try { @@ -184,7 +214,12 @@ export function useSpecialEditor( } }, [api, adopt]) - React.useEffect(() => { if (active && !latest.current) void reload() }, [active, reload]) + React.useEffect(() => { + if (!active) return + // 已经读过配置的,激活时只对齐参考数据,不重置草稿 + if (latest.current) void refreshView() + else void reload() + }, [active, reload, refreshView]) const update = React.useCallback((mutate: (draft: T) => T) => { setError('') @@ -218,7 +253,7 @@ export function useSpecialEditor( }, []) const dirty = view !== null && draft !== null && JSON.stringify(draft) !== JSON.stringify(view.config) - return { view, draft, loading, saving, error, dirty, update, save, reload, discard } + return { view, draft, loading, saving, error, dirty, update, save, reload, refreshView, discard } } export function message(failure: unknown): string { diff --git a/desktop-tauri/ui/css/page-routing-config.css b/desktop-tauri/ui/css/page-routing-config.css index 22475721..04b8588a 100644 --- a/desktop-tauri/ui/css/page-routing-config.css +++ b/desktop-tauri/ui/css/page-routing-config.css @@ -78,7 +78,8 @@ .routing-config-search { flex: none; max-width: none; } .routing-groups-hint { flex: none; margin: 0; color: var(--text-3); font-size: 11px; line-height: 1.6; } .routing-config-listcol { flex: 1; min-width: 0; min-height: 0; padding: 1px 3px 12px; overflow: auto; scrollbar-gutter: stable; } -.routing-config-participants { display: flex; flex-direction: column; gap: 10px; } +/* 顶部留白容纳首卡上沿外 5px 的 drop-before 落点横条,避免被滚动容器裁剪 */ +.routing-config-participants { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; } .routing-config-provider { position: relative; min-width: 0; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); } .routing-config-provider.is-off { border-style: dashed; background: var(--surface-2); box-shadow: none; } .routing-config-provider > header { display: flex; align-items: center; gap: 7px; padding: 10px 8px; } diff --git a/desktop-tauri/ui/islands/ui.js b/desktop-tauri/ui/islands/ui.js index 7225c7e8..90ca0485 100644 --- a/desktop-tauri/ui/islands/ui.js +++ b/desktop-tauri/ui/islands/ui.js @@ -1,36 +1,36 @@ -var alt=Object.defineProperty;var ilt=(Td,dc,Od)=>dc in Td?alt(Td,dc,{enumerable:!0,configurable:!0,writable:!0,value:Od}):Td[dc]=Od;var Cn=(Td,dc,Od)=>ilt(Td,typeof dc!="symbol"?dc+"":dc,Od);(function(){"use strict";function Td(e,t){for(var n=0;ns[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function dc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Od={exports:{}},Sb={};var pF;function Kme(){if(pF)return Sb;pF=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,i,o){var l=null;if(o!==void 0&&(l=""+o),i.key!==void 0&&(l=""+i.key),"key"in i){o={};for(var u in i)u!=="key"&&(o[u]=i[u])}else o=i;return i=o.ref,{$$typeof:e,type:s,key:l,ref:i!==void 0?i:null,props:o}}return Sb.Fragment=t,Sb.jsx=n,Sb.jsxs=n,Sb}var gF;function qme(){return gF||(gF=1,Od.exports=Kme()),Od.exports}var r=qme(),xO={exports:{}},Ua={},vO={exports:{}},wn={};var xF;function Gme(){if(xF)return wn;xF=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.for("react.view_transition"),b=Symbol.iterator;function y(H){return H===null||typeof H!="object"?null:(H=b&&H[b]||H["@@iterator"],typeof H=="function"?H:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,S={};function N(H,G,Y){this.props=H,this.context=G,this.refs=S,this.updater=Y||k}N.prototype.isReactComponent={},N.prototype.setState=function(H,G){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,G,"setState")},N.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function C(){}C.prototype=N.prototype;function T(H,G,Y){this.props=H,this.context=G,this.refs=S,this.updater=Y||k}var P=T.prototype=new C;P.constructor=T,w(P,N.prototype),P.isPureReactComponent=!0;var O=Array.isArray;function A(){}var R={H:null,A:null,T:null,S:null},M=Object.prototype.hasOwnProperty;function _(H,G,Y){var se=Y.ref;return{$$typeof:e,type:H,key:G,ref:se!==void 0?se:null,props:Y}}function L(H,G){return _(H.type,G,H.props)}function $(H){return typeof H=="object"&&H!==null&&H.$$typeof===e}function D(H){var G={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(Y){return G[Y]})}var F=/\/+/g;function V(H,G){return typeof H=="object"&&H!==null&&H.key!=null?D(""+H.key):G.toString(36)}function q(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(A,A):(H.status="pending",H.then(function(G){H.status==="pending"&&(H.status="fulfilled",H.value=G)},function(G){H.status==="pending"&&(H.status="rejected",H.reason=G)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function Q(H,G,Y,se,re){var ne=typeof H;(ne==="undefined"||ne==="boolean")&&(H=null);var de=!1;if(H===null)de=!0;else switch(ne){case"bigint":case"string":case"number":de=!0;break;case"object":switch(H.$$typeof){case e:case t:de=!0;break;case m:return de=H._init,Q(de(H._payload),G,Y,se,re)}}if(de)return re=re(H),de=se===""?"."+V(H,0):se,O(re)?(Y="",de!=null&&(Y=de.replace(F,"$&/")+"/"),Q(re,G,Y,"",function(je){return je})):re!=null&&($(re)&&(re=L(re,Y+(re.key==null||H&&H.key===re.key?"":(""+re.key).replace(F,"$&/")+"/")+de)),G.push(re)),1;de=0;var ie=se===""?".":se+":";if(O(H))for(var oe=0;oe"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),xO.exports=Wme(),xO.exports}var xr=jF(),bO={exports:{}},Nb={},yO={exports:{}},jO={};var wF;function Yme(){return wF||(wF=1,(function(e){function t(q,Q){var X=q.length;q.push(Q);e:for(;0>>1,z=q[U];if(0>>1;Ui(ee,X))Hi(G,ee)?(q[U]=G,q[H]=X,U=H):(q[U]=ee,q[J]=X,U=J);else if(Hi(G,X))q[U]=G,q[H]=X,U=H;else break e}}return Q}function i(q,Q){var X=q.sortIndex-Q.sortIndex;return X!==0?X:q.id-Q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var d=[],f=[],m=1,g=null,v=3,b=!1,y=!1,k=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;function T(q){for(var Q=n(f);Q!==null;){if(Q.callback===null)s(f);else if(Q.startTime<=q)s(f),Q.sortIndex=Q.expirationTime,t(d,Q);else break;Q=n(f)}}function P(q){if(k=!1,T(q),!y)if(n(d)!==null)y=!0,O||(O=!0,$());else{var Q=n(f);Q!==null&&V(P,Q.startTime-q)}}var O=!1,A=-1,R=5,M=-1;function _(){return w?!0:!(e.unstable_now()-Mq&&_());){var U=g.callback;if(typeof U=="function"){g.callback=null,v=g.priorityLevel;var z=U(g.expirationTime<=q);if(q=e.unstable_now(),typeof z=="function"){g.callback=z,T(q),Q=!0;break t}g===n(d)&&s(d),T(q)}else s(d);g=n(d)}if(g!==null)Q=!0;else{var K=n(f);K!==null&&V(P,K.startTime-q),Q=!1}}break e}finally{g=null,v=X,b=!1}Q=void 0}}finally{Q?$():O=!1}}}var $;if(typeof C=="function")$=function(){C(L)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,F=D.port2;D.port1.onmessage=L,$=function(){F.postMessage(null)}}else $=function(){S(L,0)};function V(q,Q){A=S(function(){q(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(q){q.callback=null},e.unstable_forceFrameRate=function(q){0>q||125U?(q.sortIndex=X,t(f,q),n(d)===null&&q===n(f)&&(k?(N(A),A=-1):k=!0,V(P,X-U))):(q.sortIndex=z,t(d,q),y||b||(y=!0,O||(O=!0,$()))),q},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(q){var Q=v;return function(){var X=v;v=Q;try{return q.apply(this,arguments)}finally{v=X}}}})(jO)),jO}var kF;function Xme(){return kF||(kF=1,yO.exports=Yme()),yO.exports}var SF;function Qme(){if(SF)return Nb;SF=1;var e=Xme(),t=sg(),n=jF();function s(c){var h="https://react.dev/errors/"+c;if(1le||(c.current=te[le],te[le]=null,le--)}function ye(c,h){le++,te[le]=c.current,c.current=h}var fe=he(null),Le=he(null),pe=he(null),xe=he(null);function Se(c,h){switch(ye(pe,h),ye(Le,c),ye(fe,null),h.nodeType){case 9:case 11:c=(c=h.documentElement)&&(c=c.namespaceURI)?eme(c):0;break;default:if(c=h.tagName,h=h.namespaceURI)h=eme(h),c=tme(h,c);else switch(c){case"svg":c=1;break;case"math":c=2;break;default:c=0}}ce(fe),ye(fe,c)}function ge(){ce(fe),ce(Le),ce(pe)}function ue(c){var h=c.memoizedState;h!==null&&(jb._currentValue=h.memoizedState,ye(xe,c)),h=fe.current;var x=tme(h,c.type);h!==x&&(ye(Le,c),ye(fe,x))}function be(c){Le.current===c&&(ce(fe),ce(Le)),xe.current===c&&(ce(xe),jb._currentValue=je)}var ve,De;function Ie(c){if(ve===void 0)try{throw Error()}catch(x){var h=x.stack.trim().match(/\n( *(at )?)/);ve=h&&h[1]||"",De=-1dc in Td?alt(Td,dc,{enumerable:!0,configurable:!0,writable:!0,value:Od}):Td[dc]=Od;var Cn=(Td,dc,Od)=>ilt(Td,typeof dc!="symbol"?dc+"":dc,Od);(function(){"use strict";function Td(e,t){for(var n=0;ns[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function dc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Od={exports:{}},Sb={};var pF;function qme(){if(pF)return Sb;pF=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,i,o){var l=null;if(o!==void 0&&(l=""+o),i.key!==void 0&&(l=""+i.key),"key"in i){o={};for(var u in i)u!=="key"&&(o[u]=i[u])}else o=i;return i=o.ref,{$$typeof:e,type:s,key:l,ref:i!==void 0?i:null,props:o}}return Sb.Fragment=t,Sb.jsx=n,Sb.jsxs=n,Sb}var gF;function Kme(){return gF||(gF=1,Od.exports=qme()),Od.exports}var r=Kme(),xO={exports:{}},Ua={},vO={exports:{}},wn={};var xF;function Gme(){if(xF)return wn;xF=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.for("react.view_transition"),b=Symbol.iterator;function y(H){return H===null||typeof H!="object"?null:(H=b&&H[b]||H["@@iterator"],typeof H=="function"?H:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,S={};function N(H,G,Y){this.props=H,this.context=G,this.refs=S,this.updater=Y||k}N.prototype.isReactComponent={},N.prototype.setState=function(H,G){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,G,"setState")},N.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function C(){}C.prototype=N.prototype;function T(H,G,Y){this.props=H,this.context=G,this.refs=S,this.updater=Y||k}var P=T.prototype=new C;P.constructor=T,w(P,N.prototype),P.isPureReactComponent=!0;var O=Array.isArray;function A(){}var R={H:null,A:null,T:null,S:null},M=Object.prototype.hasOwnProperty;function _(H,G,Y){var se=Y.ref;return{$$typeof:e,type:H,key:G,ref:se!==void 0?se:null,props:Y}}function L(H,G){return _(H.type,G,H.props)}function $(H){return typeof H=="object"&&H!==null&&H.$$typeof===e}function D(H){var G={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(Y){return G[Y]})}var F=/\/+/g;function V(H,G){return typeof H=="object"&&H!==null&&H.key!=null?D(""+H.key):G.toString(36)}function K(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(A,A):(H.status="pending",H.then(function(G){H.status==="pending"&&(H.status="fulfilled",H.value=G)},function(G){H.status==="pending"&&(H.status="rejected",H.reason=G)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function Q(H,G,Y,se,re){var ne=typeof H;(ne==="undefined"||ne==="boolean")&&(H=null);var de=!1;if(H===null)de=!0;else switch(ne){case"bigint":case"string":case"number":de=!0;break;case"object":switch(H.$$typeof){case e:case t:de=!0;break;case m:return de=H._init,Q(de(H._payload),G,Y,se,re)}}if(de)return re=re(H),de=se===""?"."+V(H,0):se,O(re)?(Y="",de!=null&&(Y=de.replace(F,"$&/")+"/"),Q(re,G,Y,"",function(je){return je})):re!=null&&($(re)&&(re=L(re,Y+(re.key==null||H&&H.key===re.key?"":(""+re.key).replace(F,"$&/")+"/")+de)),G.push(re)),1;de=0;var ie=se===""?".":se+":";if(O(H))for(var oe=0;oe"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),xO.exports=Wme(),xO.exports}var xr=jF(),bO={exports:{}},Nb={},yO={exports:{}},jO={};var wF;function Yme(){return wF||(wF=1,(function(e){function t(K,Q){var X=K.length;K.push(Q);e:for(;0>>1,z=K[U];if(0>>1;Ui(ee,X))Hi(G,ee)?(K[U]=G,K[H]=X,U=H):(K[U]=ee,K[J]=X,U=J);else if(Hi(G,X))K[U]=G,K[H]=X,U=H;else break e}}return Q}function i(K,Q){var X=K.sortIndex-Q.sortIndex;return X!==0?X:K.id-Q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var d=[],f=[],m=1,g=null,v=3,b=!1,y=!1,k=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;function T(K){for(var Q=n(f);Q!==null;){if(Q.callback===null)s(f);else if(Q.startTime<=K)s(f),Q.sortIndex=Q.expirationTime,t(d,Q);else break;Q=n(f)}}function P(K){if(k=!1,T(K),!y)if(n(d)!==null)y=!0,O||(O=!0,$());else{var Q=n(f);Q!==null&&V(P,Q.startTime-K)}}var O=!1,A=-1,R=5,M=-1;function _(){return w?!0:!(e.unstable_now()-MK&&_());){var U=g.callback;if(typeof U=="function"){g.callback=null,v=g.priorityLevel;var z=U(g.expirationTime<=K);if(K=e.unstable_now(),typeof z=="function"){g.callback=z,T(K),Q=!0;break t}g===n(d)&&s(d),T(K)}else s(d);g=n(d)}if(g!==null)Q=!0;else{var q=n(f);q!==null&&V(P,q.startTime-K),Q=!1}}break e}finally{g=null,v=X,b=!1}Q=void 0}}finally{Q?$():O=!1}}}var $;if(typeof C=="function")$=function(){C(L)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,F=D.port2;D.port1.onmessage=L,$=function(){F.postMessage(null)}}else $=function(){S(L,0)};function V(K,Q){A=S(function(){K(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_forceFrameRate=function(K){0>K||125U?(K.sortIndex=X,t(f,K),n(d)===null&&K===n(f)&&(k?(N(A),A=-1):k=!0,V(P,X-U))):(K.sortIndex=z,t(d,K),y||b||(y=!0,O||(O=!0,$()))),K},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(K){var Q=v;return function(){var X=v;v=Q;try{return K.apply(this,arguments)}finally{v=X}}}})(jO)),jO}var kF;function Xme(){return kF||(kF=1,yO.exports=Yme()),yO.exports}var SF;function Qme(){if(SF)return Nb;SF=1;var e=Xme(),t=sg(),n=jF();function s(c){var h="https://react.dev/errors/"+c;if(1le||(c.current=te[le],te[le]=null,le--)}function ye(c,h){le++,te[le]=c.current,c.current=h}var fe=he(null),Le=he(null),pe=he(null),xe=he(null);function Se(c,h){switch(ye(pe,h),ye(Le,c),ye(fe,null),h.nodeType){case 9:case 11:c=(c=h.documentElement)&&(c=c.namespaceURI)?eme(c):0;break;default:if(c=h.tagName,h=h.namespaceURI)h=eme(h),c=tme(h,c);else switch(c){case"svg":c=1;break;case"math":c=2;break;default:c=0}}ce(fe),ye(fe,c)}function ge(){ce(fe),ce(Le),ce(pe)}function ue(c){var h=c.memoizedState;h!==null&&(jb._currentValue=h.memoizedState,ye(xe,c)),h=fe.current;var x=tme(h,c.type);h!==x&&(ye(Le,c),ye(fe,x))}function be(c){Le.current===c&&(ce(fe),ce(Le)),xe.current===c&&(ce(xe),jb._currentValue=je)}var ve,De;function Ie(c){if(ve===void 0)try{throw Error()}catch(x){var h=x.stack.trim().match(/\n( *(at )?)/);ve=h&&h[1]||"",De=-1)":-1E||me[j]!==Oe[E]){var $e=` `+me[j].replace(" at new "," at ");return c.displayName&&$e.includes("")&&($e=$e.replace("",c.displayName)),$e}while(1<=j&&0<=E);break}}}finally{We=!1,Error.prepareStackTrace=x}return(x=c?c.displayName||c.name:"")?Ie(x):""}function kt(c,h){switch(c.tag){case 26:case 27:case 5:return Ie(c.type);case 16:return Ie("Lazy");case 13:return c.child!==h&&h!==null?Ie("Suspense Fallback"):Ie("Suspense");case 19:return Ie("SuspenseList");case 0:case 15:return nt(c.type,!1);case 11:return nt(c.type.render,!1);case 1:return nt(c.type,!0);case 31:return Ie("Activity");case 30:return Ie("ViewTransition");default:return""}}function Je(c){try{var h="",x=null;do h+=kt(c,x),x=c,c=c.return;while(c);return h}catch(j){return` Error generating stack: `+j.message+` -`+j.stack}}var on=Object.prototype.hasOwnProperty,nn=e.unstable_scheduleCallback,On=e.unstable_cancelCallback,Rn=e.unstable_shouldYield,gt=e.unstable_requestPaint,sn=e.unstable_now,Ke=e.unstable_getCurrentPriorityLevel,zt=e.unstable_ImmediatePriority,ht=e.unstable_UserBlockingPriority,Tt=e.unstable_NormalPriority,Ht=e.unstable_LowPriority,jt=e.unstable_IdlePriority,an=e.log,Xt=e.unstable_setDisableYieldValue,gn=null,un=null;function lr(c){if(typeof an=="function"&&Xt(c),un&&typeof un.setStrictMode=="function")try{un.setStrictMode(gn,c)}catch{}}var yn=Math.clz32?Math.clz32:ke,xn=Math.log,jn=Math.LN2;function ke(c){return c>>>=0,c===0?32:31-(xn(c)/jn|0)|0}var Xe=256,Qe=262144,Yt=4194304;function Rt(c){var h=c&42;if(h!==0)return h;switch(c&-c){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 c&-c;case 262144:case 524288:case 1048576:case 2097152:return c&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return c&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return c}}function fn(c,h,x){var j=c.pendingLanes;if(j===0)return 0;var E=0,I=c.suspendedLanes,W=c.pingedLanes;c=c.warmLanes;var ae=j&134217727;return ae!==0?(j=ae&~I,j!==0?E=Rt(j):(W&=ae,W!==0?E=Rt(W):x||(x=ae&~c,x!==0&&(E=Rt(x))))):(ae=j&~I,ae!==0?E=Rt(ae):W!==0?E=Rt(W):x||(x=j&~c,x!==0&&(E=Rt(x)))),E===0?0:h!==0&&h!==E&&(h&I)===0&&(I=E&-E,x=h&-h,I>=x||I===32&&(x&4194048)!==0)?h:E}function At(c,h){return(c.pendingLanes&~(c.suspendedLanes&~c.pingedLanes)&h)===0}function Re(c,h){(h&8)!==0&&(h|=h&32);var x=c.entangledLanes;if(x!==0)for(c=c.entanglements,x&=h;0x;x++)h.push(c);return h}function mn(c,h){c.pendingLanes|=h,h!==268435456&&(c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0)}function vn(c,h,x,j,E,I){var W=c.pendingLanes;c.pendingLanes=x,c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0,c.expiredLanes&=x,c.entangledLanes&=x,c.errorRecoveryDisabledLanes&=x,c.shellSuspendCounter=0;var ae=c.entanglements,me=c.expirationTimes,Oe=c.hiddenUpdates;for(x=W&~x;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),rr=!1;if(bn)try{var Kr={};Object.defineProperty(Kr,"passive",{get:function(){rr=!0}}),window.addEventListener("test",Kr,Kr),window.removeEventListener("test",Kr,Kr)}catch{rr=!1}var Pr=null,qr=null,qs=null;function to(){if(qs)return qs;var c,h=qr,x=h.length,j,E="value"in Pr?Pr.value:Pr.textContent,I=E.length;for(c=0;c=M0),nde=" ",rde=!1;function sde(c,h){switch(c){case"keyup":return nit.indexOf(h.keyCode)!==-1;case"keydown":return h.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ade(c){return c=c.detail,typeof c=="object"&&"data"in c?c.data:null}var Hv=!1;function sit(c,h){switch(c){case"compositionend":return ade(h);case"keypress":return h.which!==32?null:(rde=!0,nde);case"textInput":return c=h.data,c===nde&&rde?null:c;default:return null}}function ait(c,h){if(Hv)return c==="compositionend"||!s3&&sde(c,h)?(c=to(),qs=qr=Pr=null,Hv=!1,c):null;switch(c){case"paste":return null;case"keypress":if(!(h.ctrlKey||h.altKey||h.metaKey)||h.ctrlKey&&h.altKey){if(h.char&&1"u")return null;try{return c.activeElement||c.body}catch{return c.body}}function hde(c){for(;c&&c.firstChild;)c=c.firstChild;return c}function mde(c,h){var x=hde(c);c=0;for(var j;x;){if(x.nodeType===3){if(j=c+x.textContent.length,c<=h&&j>=h)return{node:x,offset:h-c};c=j}e:{for(;x;){if(x.nextSibling){x=x.nextSibling;break e}x=x.parentNode}x=void 0}x=hde(x)}}function pde(c,h){return c&&h?c===h?!0:c&&c.nodeType===3?!1:h&&h.nodeType===3?pde(c,h.parentNode):"contains"in c?c.contains(h):c.compareDocumentPosition?!!(c.compareDocumentPosition(h)&16):!1:!1}function gde(c){c=c!=null&&c.ownerDocument!=null&&c.ownerDocument.defaultView!=null?c.ownerDocument.defaultView:window;for(var h=o3(c.document);h instanceof c.HTMLIFrameElement;){try{var x=typeof h.contentWindow.location.href=="string"}catch{x=!1}if(x)c=h.contentWindow;else break;h=o3(c.document)}return h}function l3(c){var h=c&&c.nodeName&&c.nodeName.toLowerCase();return h&&(h==="input"&&(c.type==="text"||c.type==="search"||c.type==="tel"||c.type==="url"||c.type==="password")||h==="textarea"||c.contentEditable==="true")}var hit=bn&&"documentMode"in document&&11>=document.documentMode,Vv=null,c3=null,$0=null,u3=!1;function xde(c,h,x){var j=x.window===x?x.document:x.nodeType===9?x:x.ownerDocument;u3||Vv==null||Vv!==o3(j)||(j=Vv,"selectionStart"in j&&l3(j)?j={start:j.selectionStart,end:j.selectionEnd}:(j=(j.ownerDocument&&j.ownerDocument.defaultView||window).getSelection(),j={anchorNode:j.anchorNode,anchorOffset:j.anchorOffset,focusNode:j.focusNode,focusOffset:j.focusOffset}),$0&&L0($0,j)||($0=j,j=aO(c3,"onSelect"),0>=W,E-=W,Zc=1<<32-yn(h)+E|x<hn?(ca=rn,rn=null):ca=rn.sibling;var sr=Ce(Te,rn,Me[hn],Ue);if(sr===null){rn===null&&(rn=ca);break}c&&rn&&sr.alternate===null&&h(Te,rn),we=I(sr,we,hn),Jn===null?Lt=sr:Jn.sibling=sr,Jn=sr,rn=ca}if(hn===Me.length)return x(Te,rn),Fn&&yd(Te,hn),Lt;if(rn===null){for(;hnhn?(ca=rn,rn=null):ca=rn.sibling;var bh=Ce(Te,rn,sr.value,Ue);if(bh===null){rn===null&&(rn=ca);break}c&&rn&&bh.alternate===null&&h(Te,rn),we=I(bh,we,hn),Jn===null?Lt=bh:Jn.sibling=bh,Jn=bh,rn=ca}if(sr.done)return x(Te,rn),Fn&&yd(Te,hn),Lt;if(rn===null){for(;!sr.done;hn++,sr=Me.next())sr=He(Te,sr.value,Ue),sr!==null&&(we=I(sr,we,hn),Jn===null?Lt=sr:Jn.sibling=sr,Jn=sr);return Fn&&yd(Te,hn),Lt}for(rn=j(rn);!sr.done;hn++,sr=Me.next())sr=_e(rn,Te,hn,sr.value,Ue),sr!==null&&(c&&(ca=sr.alternate,ca!==null&&rn.delete(ca.key===null?hn:ca.key)),we=I(sr,we,hn),Jn===null?Lt=sr:Jn.sibling=sr,Jn=sr);return c&&rn.forEach(function(slt){return h(Te,slt)}),Fn&&yd(Te,hn),Lt}function Mn(Te,we,Me,Ue){if(typeof Me=="object"&&Me!==null&&Me.type===L&&Me.key===null&&Me.props.ref===void 0&&(Me=Me.props.children),typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case M:e:{for(var Lt=Me.key;we!==null;){if(we.key===Lt){if(Lt=Me.type,Lt===L){if(we.tag===7){x(Te,we.sibling),Ue=E(we,Me.props.children),eh(Ue,Me),Ue.return=Te,Te=Ue;break e}}else if(we.elementType===Lt||typeof Lt=="object"&&Lt!==null&&Lt.$$typeof===z&&Wp(Lt)===we.type){x(Te,we.sibling),Ue=E(we,Me.props),eh(Ue,Me),Ue.return=Te,Te=Ue;break e}x(Te,we);break}else h(Te,we);we=we.sibling}Me.type===L?(Ue=Fp(Me.props.children,Te.mode,Ue,Me.key),eh(Ue,Me),Ue.return=Te,Te=Ue):(Ue=uT(Me.type,Me.key,Me.props,null,Te.mode,Ue),eh(Ue,Me),Ue.return=Te,Te=Ue)}return W(Te);case _:e:{for(Lt=Me.key;we!==null;){if(we.key===Lt)if(we.tag===4&&we.stateNode.containerInfo===Me.containerInfo&&we.stateNode.implementation===Me.implementation){x(Te,we.sibling),Ue=E(we,Me.children||[]),Ue.return=Te,Te=Ue;break e}else{x(Te,we);break}else h(Te,we);we=we.sibling}Ue=x3(Me,Te.mode,Ue),Ue.return=Te,Te=Ue}return W(Te);case z:return Me=Wp(Me),Mn(Te,we,Me,Ue)}if(de(Me))return bt(Te,we,Me,Ue);if(se(Me)){if(Lt=se(Me),typeof Lt!="function")throw Error(s(150));return Me=Lt.call(Me),qt(Te,we,Me,Ue)}if(typeof Me.then=="function")return Mn(Te,we,yT(Me),Ue);if(Me.$$typeof===V)return Mn(Te,we,gT(Te,Me),Ue);jT(Te,Me)}return typeof Me=="string"&&Me!==""||typeof Me=="number"||typeof Me=="bigint"?(Me=""+Me,we!==null&&we.tag===6?(x(Te,we.sibling),Ue=E(we,Me),Ue.return=Te,Te=Ue):(x(Te,we),Ue=g3(Me,Te.mode,Ue),Ue.return=Te,Te=Ue),W(Te)):x(Te,we)}return function(Te,we,Me,Ue){try{V0=0;var Lt=Mn(Te,we,Me,Ue);return Jv=null,Lt}catch(rn){if(rn===Zv||rn===vT)throw rn;var Jn=no(29,rn,null,Te.mode);return Jn.lanes=Ue,Jn.return=Te,Jn}}}var Xp=Fde(!0),Ude=Fde(!1),th=!1;function A3(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function E3(c,h){c=c.updateQueue,h.updateQueue===c&&(h.updateQueue={baseState:c.baseState,firstBaseUpdate:c.firstBaseUpdate,lastBaseUpdate:c.lastBaseUpdate,shared:c.shared,callbacks:null})}function nh(c){return{lane:c,tag:0,payload:null,callback:null,next:null}}function rh(c,h,x){var j=c.updateQueue;if(j===null)return null;if(j=j.shared,(gr&2)!==0){var E=j.pending;return E===null?h.next=h:(h.next=E.next,E.next=h),j.pending=h,h=cT(c),Nde(c,null,x),h}return lT(c,j,h,x),cT(c)}function K0(c,h,x){if(h=h.updateQueue,h!==null&&(h=h.shared,(x&4194048)!==0)){var j=h.lanes;j&=c.pendingLanes,x|=j,h.lanes=x,Ns(c,x)}}function T3(c,h){var x=c.updateQueue,j=c.alternate;if(j!==null&&(j=j.updateQueue,x===j)){var E=null,I=null;if(x=x.firstBaseUpdate,x!==null){do{var W={lane:x.lane,tag:x.tag,payload:x.payload,callback:null,next:null};I===null?E=I=W:I=I.next=W,x=x.next}while(x!==null);I===null?E=I=h:I=I.next=h}else E=I=h;x={baseState:j.baseState,firstBaseUpdate:E,lastBaseUpdate:I,shared:j.shared,callbacks:j.callbacks},c.updateQueue=x;return}c=x.lastBaseUpdate,c===null?x.firstBaseUpdate=h:c.next=h,x.lastBaseUpdate=h}var O3=!1;function q0(){if(O3){var c=Qv;if(c!==null)throw c}}function G0(c,h,x,j){O3=!1;var E=c.updateQueue;th=!1;var I=E.firstBaseUpdate,W=E.lastBaseUpdate,ae=E.shared.pending;if(ae!==null){E.shared.pending=null;var me=ae,Oe=me.next;me.next=null,W===null?I=Oe:W.next=Oe,W=me;var $e=c.alternate;$e!==null&&($e=$e.updateQueue,ae=$e.lastBaseUpdate,ae!==W&&(ae===null?$e.firstBaseUpdate=Oe:ae.next=Oe,$e.lastBaseUpdate=me))}if(I!==null){var He=E.baseState;W=0,$e=Oe=me=null,ae=I;do{var Ce=ae.lane&-536870913,_e=Ce!==ae.lane;if(_e?(Zn&Ce)===Ce:(j&Ce)===Ce){Ce!==0&&Ce===qp&&(O3=!0),$e!==null&&($e=$e.next={lane:0,tag:ae.tag,payload:ae.payload,callback:null,next:null});e:{var bt=c,qt=ae;Ce=h;var Mn=x;switch(qt.tag){case 1:if(bt=qt.payload,typeof bt=="function"){He=bt.call(Mn,He,Ce);break e}He=bt;break e;case 3:bt.flags=bt.flags&-65537|128;case 0:if(bt=qt.payload,Ce=typeof bt=="function"?bt.call(Mn,He,Ce):bt,Ce==null)break e;He=A({},He,Ce);break e;case 2:th=!0}}Ce=ae.callback,Ce!==null&&(c.flags|=64,_e&&(c.flags|=8192),_e=E.callbacks,_e===null?E.callbacks=[Ce]:_e.push(Ce))}else _e={lane:Ce,tag:ae.tag,payload:ae.payload,callback:ae.callback,next:null},$e===null?(Oe=$e=_e,me=He):$e=$e.next=_e,W|=Ce;if(ae=ae.next,ae===null){if(ae=E.shared.pending,ae===null)break;_e=ae,ae=_e.next,_e.next=null,E.lastBaseUpdate=_e,E.shared.pending=null}}while(!0);$e===null&&(me=He),E.baseState=me,E.firstBaseUpdate=Oe,E.lastBaseUpdate=$e,I===null&&(E.shared.lanes=0),uh|=W,c.lanes=W,c.memoizedState=He}}function Hde(c,h){if(typeof c!="function")throw Error(s(191,c));c.call(h)}function Vde(c,h){var x=c.callbacks;if(x!==null)for(c.callbacks=null,c=0;cI?I:8;var W=ie.T,ae={};ae.types=W!==null?W.types:null,ie.T=ae,X3(c,!1,h,x);try{var me=E(),Oe=ie.S;if(Oe!==null&&Oe(ae,me),me!==null&&typeof me=="object"&&typeof me.then=="function"){var $e=Sit(me,j);Q0(c,h,$e,zo(c))}else Q0(c,h,j,zo(c))}catch(He){Q0(c,h,{then:function(){},status:"rejected",reason:He},zo())}finally{oe.p=I,W!==null&&ae.types!==null&&(W.types=ae.types),ie.T=W}}function Oit(){}function W3(c,h,x,j){if(c.tag!==5)throw Error(s(476));var E=wfe(c).queue;jfe(c,E,h,je,x===null?Oit:function(){return kfe(c),x(j)})}function wfe(c){var h=c.memoizedState;if(h!==null)return h;h={memoizedState:je,baseState:je,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sd,lastRenderedState:je},next:null};var x={};return h.next={memoizedState:x,baseState:x,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sd,lastRenderedState:x},next:null},c.memoizedState=h,c=c.alternate,c!==null&&(c.memoizedState=h),h}function kfe(c){var h=wfe(c);h.next===null&&(h=c.alternate.memoizedState),Q0(c,h.next.queue,{},zo())}function Y3(){return ai(jb)}function Sfe(){return Gs().memoizedState}function Nfe(){return Gs().memoizedState}function Rit(c){for(var h=c.return;h!==null;){switch(h.tag){case 24:case 3:var x=zo();c=nh(x);var j=rh(h,c,x);j!==null&&(io(j,h,x),K0(j,h,x)),h={cache:k3()},c.payload=h;return}h=h.return}}function Pit(c,h,x){var j=zo();x={lane:j,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null},RT(c)?Afe(h,x):(x=m3(c,h,x,j),x!==null&&(io(x,c,j),Efe(x,h,j)))}function Cfe(c,h,x){var j=zo();Q0(c,h,x,j)}function Q0(c,h,x,j){var E={lane:j,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null};if(RT(c))Afe(h,E);else{var I=c.alternate;if(c.lanes===0&&(I===null||I.lanes===0)&&(I=h.lastRenderedReducer,I!==null))try{var W=h.lastRenderedState,ae=I(W,x);if(E.hasEagerState=!0,E.eagerState=ae,Mo(ae,W))return lT(c,h,E,0),Gr===null&&oT(),!1}catch{}if(x=m3(c,h,E,j),x!==null)return io(x,c,j),Efe(x,h,j),!0}return!1}function X3(c,h,x,j){if(j={lane:2,revertLane:B4(),gesture:null,action:j,hasEagerState:!1,eagerState:null,next:null},RT(c)){if(h)throw Error(s(479))}else h=m3(c,x,j,2),h!==null&&io(h,c,2)}function RT(c){var h=c.alternate;return c===In||h!==null&&h===In}function Afe(c,h){eb=ST=!0;var x=c.pending;x===null?h.next=h:(h.next=x.next,x.next=h),c.pending=h}function Efe(c,h,x){if((x&4194048)!==0){var j=h.lanes;j&=c.pendingLanes,x|=j,h.lanes=x,Ns(c,x)}}var PT={readContext:ai,use:AT,useCallback:Ds,useContext:Ds,useEffect:Ds,useImperativeHandle:Ds,useLayoutEffect:Ds,useInsertionEffect:Ds,useMemo:Ds,useReducer:Ds,useRef:Ds,useState:Ds,useDebugValue:Ds,useDeferredValue:Ds,useTransition:Ds,useSyncExternalStore:Ds,useId:Ds,useHostTransitionStatus:Ds,useFormState:Ds,useActionState:Ds,useOptimistic:Ds,useMemoCache:Ds,useCacheRefresh:Ds,useEffectEvent:Ds},Tfe={readContext:ai,use:AT,useCallback:function(c,h){return Mi().memoizedState=[c,h===void 0?null:h],c},useContext:ai,useEffect:ffe,useImperativeHandle:function(c,h,x){x=x!=null?x.concat([c]):null,TT(4194308,4,gfe.bind(null,h,c),x)},useLayoutEffect:function(c,h){return TT(4194308,4,c,h)},useInsertionEffect:function(c,h){TT(4,2,c,h)},useMemo:function(c,h){var x=Mi();h=h===void 0?null:h;var j=c();if(Qp){lr(!0);try{c()}finally{lr(!1)}}return x.memoizedState=[j,h],j},useReducer:function(c,h,x){var j=Mi();if(x!==void 0){var E=x(h);if(Qp){lr(!0);try{x(h)}finally{lr(!1)}}}else E=h;return j.memoizedState=j.baseState=E,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:E},j.queue=c,c=c.dispatch=Pit.bind(null,In,c),[j.memoizedState,c]},useRef:function(c){var h=Mi();return c={current:c},h.memoizedState=c},useState:function(c){c=H3(c);var h=c.queue,x=Cfe.bind(null,In,h);return h.dispatch=x,[c.memoizedState,x]},useDebugValue:q3,useDeferredValue:function(c,h){var x=Mi();return G3(x,c,h)},useTransition:function(){var c=H3(!1);return c=jfe.bind(null,In,c.queue,!0,!1),Mi().memoizedState=c,[!1,c]},useSyncExternalStore:function(c,h,x){var j=In,E=Mi();if(Fn){if(x===void 0)throw Error(s(407));x=x()}else{if(x=h(),Gr===null)throw Error(s(349));(Zn&127)!==0||Xde(j,h,x)}E.memoizedState=x;var I={value:x,getSnapshot:h};return E.queue=I,ffe(Zde.bind(null,j,I,c),[c]),j.flags|=2048,nb(9,{destroy:void 0},Qde.bind(null,j,I,x,h),null),x},useId:function(){var c=Mi(),h=Gr.identifierPrefix;if(Fn){var x=Jc,j=Zc;x=(j&~(1<<32-yn(j)-1)).toString(32)+x,h="_"+h+"R_"+x,x=NT++,0<\/script>",I=I.removeChild(I.firstChild);break;case"select":I=typeof j.is=="string"?W.createElement("select",{is:j.is}):W.createElement("select"),j.multiple?I.multiple=!0:j.size&&(I.size=j.size);break;default:I=typeof j.is=="string"?W.createElement(E,{is:j.is}):W.createElement(E)}}I[Ca]=h,I[si]=j;e:for(W=h.child;W!==null;){if(W.tag===5||W.tag===6)I.appendChild(W.stateNode);else if(W.tag!==4&&W.tag!==27&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===h)break e;for(;W.sibling===null;){if(W.return===null||W.return===h)break e;W=W.return}W.sibling.return=W.return,W=W.sibling}h.stateNode=I;e:switch(ci(I,E,j),E){case"button":case"input":case"select":case"textarea":j=!!j.autoFocus;break e;case"img":j=!0;break e;default:j=!1}j&&Cd(h)}}return Jr(h),h.subtreeFlags&=-33554433,c4(h,h.type,c===null?null:c.memoizedProps,h.pendingProps,x),null;case 6:if(c&&h.stateNode!=null)c.memoizedProps!==j&&Cd(h);else{if(typeof j!="string"&&h.stateNode===null)throw Error(s(166));if(c=pe.current,Xv(h)){if(c=h.stateNode,x=h.memoizedProps,j=null,E=za,E!==null)switch(E.tag){case 27:case 5:j=E.memoizedProps}c[Ca]=h,c=!!(c.nodeValue===x||j!==null&&j.suppressHydrationWarning===!0||Zhe(c.nodeValue,x)),c||Zf(h,!0)}else c=uk(c).createTextNode(j),c[Ca]=h,h.stateNode=c}return Jr(h),null;case 31:if(x=h.memoizedState,c===null||c.memoizedState!==null){if(j=Xv(h),x!==null){if(c===null){if(!j)throw Error(s(318));if(c=h.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(s(557));c[Ca]=h}else Up(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;Jr(h),c=!1}else x=y3(),c!==null&&c.memoizedState!==null&&(c.memoizedState.hydrationErrors=x),c=!0;if(!c)return h.flags&256?(_o(h),h):(_o(h),null);if((h.flags&128)!==0)throw Error(s(558))}return Jr(h),null;case 13:if(j=h.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(E=Xv(h),j!==null&&j.dehydrated!==null){if(c===null){if(!E)throw Error(s(318));if(E=h.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(s(317));E[Ca]=h}else Up(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;Jr(h),E=!1}else E=y3(),c!==null&&c.memoizedState!==null&&(c.memoizedState.hydrationErrors=E),E=!0;if(!E)return h.flags&256?(_o(h),h):(_o(h),null)}return _o(h),(h.flags&128)!==0?(h.lanes=x,h):(x=j!==null,c=c!==null&&c.memoizedState!==null,x&&(j=h.child,E=null,j.alternate!==null&&j.alternate.memoizedState!==null&&j.alternate.memoizedState.cachePool!==null&&(E=j.alternate.memoizedState.cachePool.pool),I=null,j.memoizedState!==null&&j.memoizedState.cachePool!==null&&(I=j.memoizedState.cachePool.pool),I!==E&&(j.flags|=2048)),x!==c&&x&&(h.child.flags|=8192),$T(h,h.updateQueue),Jr(h),null);case 4:return ge(),c===null&&V4(h.stateNode.containerInfo),h.flags|=67108864,Jr(h),null;case 10:return wd(h.type),Jr(h),null;case 19:if(M3(h),j=h.memoizedState,j===null)return Jr(h),null;if(E=(h.flags&128)!==0,I=j.rendering,I===null)if(E)J0(j,!1);else{if(Ls!==0||c!==null&&(c.flags&128)!==0)for(c=h.child;c!==null;){if(I=kT(c),I!==null){for(h.flags|=128,J0(j,!1),c=I.updateQueue,h.updateQueue=c,$T(h,c),h.subtreeFlags=0,c=x,x=h.child;x!==null;)Cde(x,c),x=x.sibling;return W0(h,oi.current&1|2),Fn&&yd(h,j.treeForkCount),h.child}c=c.sibling}j.tail!==null&&sn()>XT&&(h.flags|=128,E=!0,J0(j,!1),h.lanes=4194304)}else{if(!E)if(c=kT(I),c!==null){if(h.flags|=128,E=!0,c=c.updateQueue,h.updateQueue=c,$T(h,c),J0(j,!0),j.tail===null&&j.tailMode!=="collapsed"&&j.tailMode!=="visible"&&!I.alternate&&!Fn)return Jr(h),null}else 2*sn()-j.renderingStartTime>XT&&x!==536870912&&(h.flags|=128,E=!0,J0(j,!1),h.lanes=4194304);j.isBackwards?(I.sibling=h.child,h.child=I):(c=j.last,c!==null?c.sibling=I:h.child=I,j.last=I)}if(j.tail!==null){c=j.tail;e:{for(x=c;x!==null;){if(x.alternate!==null){x=!1;break e}x=x.sibling}x=!0}return j.rendering=c,j.tail=c.sibling,j.renderingStartTime=sn(),c.sibling=null,I=oi.current,I=E?I&1|2:I&1,j.tailMode==="visible"||j.tailMode==="collapsed"||!x||Fn?W0(h,I):(x=I,ye(ii,h),ye(oi,x),yi===null&&(yi=h)),Fn&&yd(h,j.treeForkCount),c}return Jr(h),null;case 22:case 23:return _o(h),P3(),j=h.memoizedState!==null,c!==null?c.memoizedState!==null!==j&&(h.flags|=8192):j&&(h.flags|=8192),j?(x&536870912)!==0&&(h.flags&128)===0&&(Jr(h),h.subtreeFlags&6&&(h.flags|=8192)):Jr(h),x=h.updateQueue,x!==null&&$T(h,x.retryQueue),x=null,c!==null&&c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(x=c.memoizedState.cachePool.pool),j=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(j=h.memoizedState.cachePool.pool),j!==x&&(h.flags|=2048),c!==null&&ce(Gp),null;case 24:return x=null,c!==null&&(x=c.memoizedState.cache),h.memoizedState.cache!==x&&(h.flags|=2048),wd(ia),Jr(h),null;case 25:return null;case 30:return h.flags|=33554432,Jr(h),null}throw Error(s(156,h.tag))}function zit(c,h){switch(v3(h),h.tag){case 1:return c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 3:return wd(ia),ge(),c=h.flags,(c&65536)!==0&&(c&128)===0?(h.flags=c&-65537|128,h):null;case 26:case 27:case 5:return be(h),null;case 31:if(h.memoizedState!==null){if(_o(h),h.alternate===null)throw Error(s(340));Up()}return c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 13:if(_o(h),c=h.memoizedState,c!==null&&c.dehydrated!==null){if(h.alternate===null)throw Error(s(340));Up()}return c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 19:return M3(h),c=h.flags,c&65536?(h.flags=c&-65537|128,c=h.memoizedState,c!==null&&(c.rendering=null,c.tail=null),h.flags|=4,h):null;case 4:return ge(),null;case 10:return wd(h.type),null;case 22:case 23:return _o(h),P3(),c!==null&&ce(Gp),c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 24:return wd(ia),null;case 25:return null;default:return null}}function ehe(c,h){switch(v3(h),h.tag){case 3:wd(ia),ge();break;case 26:case 27:case 5:be(h);break;case 4:ge();break;case 31:h.memoizedState!==null&&_o(h);break;case 13:_o(h);break;case 19:M3(h);break;case 10:wd(h.type);break;case 22:case 23:_o(h),P3(),c!==null&&ce(Gp);break;case 24:wd(ia)}}function ek(c,h){try{var x=h.updateQueue,j=x!==null?x.lastEffect:null;if(j!==null){var E=j.next;x=E;do{if((x.tag&c)===c){j=void 0;var I=x.create,W=x.inst;j=I(),W.destroy=j}x=x.next}while(x!==E)}}catch(ae){Mr(h,h.return,ae)}}function oh(c,h,x){try{var j=h.updateQueue,E=j!==null?j.lastEffect:null;if(E!==null){var I=E.next;j=I;do{if((j.tag&c)===c){var W=j.inst,ae=W.destroy;if(ae!==void 0){W.destroy=void 0,E=h;var me=x,Oe=ae;try{Oe()}catch($e){Mr(E,me,$e)}}}j=j.next}while(j!==I)}}catch($e){Mr(h,h.return,$e)}}function the(c){var h=c.updateQueue;if(h!==null){var x=c.stateNode;try{Vde(h,x)}catch(j){Mr(c,c.return,j)}}}function nhe(c,h,x){x.props=Zp(c.type,c.memoizedProps),x.state=c.memoizedState;try{x.componentWillUnmount()}catch(j){Mr(c,h,j)}}function eu(c,h){try{var x=c.ref;if(x!==null){switch(c.tag){case 26:case 27:case 5:var j=c.stateNode;break;case 30:var E=c.stateNode,I=xd(c.memoizedProps,E);(E.ref===null||E.ref.name!==I)&&(E.ref=cme(I)),j=E.ref;break;case 7:if(c.stateNode===null){var W=new Bo(c);g(c.child,!1,Tot,W,void 0,void 0),c.stateNode=W}j=c.stateNode;break;default:j=c.stateNode}typeof x=="function"?c.refCleanup=x(j):x.current=j}}catch(ae){Mr(c,h,ae)}}function li(c,h){var x=c.ref,j=c.refCleanup;if(x!==null)if(typeof j=="function")try{j()}catch(E){Mr(c,h,E)}finally{c.refCleanup=null,c=c.alternate,c!=null&&(c.refCleanup=null)}else if(typeof x=="function")try{x(null)}catch(E){Mr(c,h,E)}else x.current=null}function zT(c,h){if((c.tag===5||c.tag===27||c.tag===6)&&c.alternate===null&&h!==null)for(var x=0;x title"))),ci(j,h,x),j[Ca]=c,aa(j),h=j;break e;case"link":if(I=Cme("link","href",E).get(h+(x.href||""))){for(W=0;WMn&&(W=Mn,Mn=qt,qt=W);var Te=mde(ae,qt),we=mde(ae,Mn);if(Te&&we&&(_e.rangeCount!==1||_e.anchorNode!==Te.node||_e.anchorOffset!==Te.offset||_e.focusNode!==we.node||_e.focusOffset!==we.offset)){var Me=He.createRange();Me.setStart(Te.node,Te.offset),_e.removeAllRanges(),qt>Mn?(_e.addRange(Me),_e.extend(we.node,we.offset)):(Me.setEnd(we.node,we.offset),_e.addRange(Me))}}}}for(He=[],_e=ae;_e=_e.parentNode;)_e.nodeType===1&&He.push({element:_e,left:_e.scrollLeft,top:_e.scrollTop});for(typeof ae.focus=="function"&&ae.focus(),ae=0;aex?32:x,ie.T=null,x=O4,O4=null;var I=cc,W=iu;if(Cs=0,ng=cc=null,iu=0,(gr&6)!==0)throw Error(s(331));var ae=gr;if(gr|=4,Nhe(I.current),whe(I,I.current,W,x),gr=ae,ok(0,!1),un&&typeof un.onPostCommitFiberRoot=="function")try{un.onPostCommitFiberRoot(gn,I)}catch{}return!0}finally{oe.p=E,ie.T=j,Bhe(c,h)}}function Fhe(c,h,x){h=wl(x,h),h=J3(c.stateNode,h,2),c=rh(c,h,2),c!==null&&(mn(c,2),ou(c))}function Mr(c,h,x){if(c.tag===3)Fhe(c,c,x);else for(;h!==null;){if(h.tag===3){Fhe(h,c,x);break}else if(h.tag===1){var j=h.stateNode;if(typeof h.type.getDerivedStateFromError=="function"||typeof j.componentDidCatch=="function"&&(dh===null||!dh.has(j))){c=wl(x,c),x=Lfe(2),j=rh(h,x,2),j!==null&&($fe(x,j,h,c),mn(j,2),ou(j));break}}h=h.return}}function L4(c,h,x){var j=c.pingCache;if(j===null){j=c.pingCache=new Hit;var E=new Set;j.set(h,E)}else E=j.get(h),E===void 0&&(E=new Set,j.set(h,E));E.has(x)||(A4=!0,E.add(x),c=Qit.bind(null,c,h,x),h.then(c,c))}function Qit(c,h,x){var j=c.pingCache;j!==null&&j.delete(h),c.pingedLanes|=c.suspendedLanes&x,c.warmLanes&=~x,Gr===c&&(Zn&x)===x&&((Ls===4||Ls===3&&(Zn&62914560)===Zn&&300>sn()-YT)&&(gr&2)===0?hb(c,0):WT|=x,lb===Zn&&(lb=0)),ou(c)}function Uhe(c,h){h===0&&(h=Bt()),c=Bp(c,h),c!==null&&(mn(c,h),ou(c))}function Zit(c){var h=c.memoizedState,x=0;h!==null&&(x=h.retryLane),Uhe(c,x)}function Jit(c,h){var x=0;switch(c.tag){case 31:case 13:var j=c.stateNode,E=c.memoizedState;E!==null&&(x=E.retryLane);break;case 19:j=c.stateNode;break;case 22:j=c.stateNode._retryCache;break;default:throw Error(s(314))}j!==null&&j.delete(h),Uhe(c,x)}function eot(c,h){return nn(c,h)}var pb=null,gb=null,$4=!1,rO=!1,z4=!1,hh=0;function ou(c){c!==gb&&c.next===null&&(gb===null?pb=gb=c:gb=gb.next=c),rO=!0,$4||($4=!0,not())}function ok(c,h){if(!z4&&rO){z4=!0;do for(var x=!1,j=pb;j!==null;){if(c!==0){var E=j.pendingLanes;if(E===0)var I=0;else{var W=j.suspendedLanes,ae=j.pingedLanes;I=(1<<31-yn(42|c)+1)-1,I&=E&~(W&~ae),I=I&201326741?I&201326741|1:I?I|2:0}I!==0&&(x=!0,qhe(j,I))}else I=Zn,I=fn(j,j===Gr?I:0,j.cancelPendingCommit!==null||j.timeoutHandle!==-1),(I&3)===0||At(j,I)||(x=!0,qhe(j,I));j=j.next}while(x);z4=!1}}function tot(){Hhe()}function Hhe(){rO=$4=!1;var c=0;hh!==0&&hot()&&(c=hh);for(var h=sn(),x=null,j=pb;j!==null;){var E=j.next,I=Vhe(j,h);I===0?(j.next=null,x===null?pb=E:x.next=E,E===null&&(gb=x)):(x=j,(c!==0||(I&3)!==0)&&(rO=!0)),j=E}Cs!==0&&Cs!==5||ok(c),hh!==0&&(hh=0)}function Vhe(c,h){for(var x=c.suspendedLanes,j=c.pingedLanes,E=c.expirationTimes,I=c.pendingLanes&-62914561;0ae)break;var $e=me.transferSize,He=me.initiatorType;$e&&Jhe(He)&&(me=me.responseEnd,W+=$e*(melO){qt.length=bt;break}Me=new Promise(bot.bind(Me)),qt.push(Me)}}}if(0"u"?null:document;function wme(c,h,x){var j=vb;if(j&&typeof h=="string"&&h){var E=Ii(h);E='link[rel="'+c+'"][href="'+E+'"]',typeof x=="string"&&(E+='[crossorigin="'+x+'"]'),jme.has(E)||(jme.add(E),c={rel:c,crossOrigin:x,href:h},j.querySelector(E)===null&&(h=j.createElement("link"),ci(h,"link",c),aa(h),j.head.appendChild(h)))}}function $ot(c){Ed.D(c),wme("dns-prefetch",c,null)}function zot(c,h){Ed.C(c,h),wme("preconnect",c,h)}function Bot(c,h,x){Ed.L(c,h,x);var j=vb;if(j&&c&&h){var E='link[rel="preload"][as="'+Ii(h)+'"]';h==="image"&&x&&x.imageSrcSet?(E+='[imagesrcset="'+Ii(x.imageSrcSet)+'"]',typeof x.imageSizes=="string"&&(E+='[imagesizes="'+Ii(x.imageSizes)+'"]')):E+='[href="'+Ii(c)+'"]';var I=E;switch(h){case"style":I=bb(c);break;case"script":I=yb(c)}if(!(El.has(I)||(c=A({rel:"preload",href:h==="image"&&x&&x.imageSrcSet?void 0:c,as:h},x),El.set(I,c),j.querySelector(E)!==null||h==="style"&&j.querySelector(fk(I))||h==="script"&&j.querySelector(hk(I))))){var W=j.createElement("link");ci(W,"link",c),h==="style"&&(W[Aa]=!0,W.onload=W.onerror=function(){k0(W)}),aa(W),j.head.appendChild(W)}}}function Fot(c,h){Ed.m(c,h);var x=vb;if(x&&c){var j=h&&typeof h.as=="string"?h.as:"script",E='link[rel="modulepreload"][as="'+Ii(j)+'"][href="'+Ii(c)+'"]',I=E;switch(j){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":I=yb(c)}if(!El.has(I)&&(c=A({rel:"modulepreload",href:c},h),El.set(I,c),x.querySelector(E)===null)){switch(j){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(x.querySelector(hk(I)))return}j=x.createElement("link"),ci(j,"link",c),aa(j),x.head.appendChild(j)}}}function Uot(c,h,x){Ed.S(c,h,x);var j=vb;if(j&&c){var E=Gf(j).hoistableStyles,I=bb(c);h=h||"default";var W=E.get(I);if(!W){var ae={loading:0,preload:null};if(W=j.querySelector(fk(I)))ae.loading=5;else{c=A({rel:"stylesheet",href:c,"data-precedence":h},x),(x=El.get(I))&&iF(c,x);var me=W=j.createElement("link");aa(me),ci(me,"link",c),me._p=new Promise(function(Oe,$e){me.onload=Oe,me.onerror=$e}),me.addEventListener("load",function(){ae.loading|=1}),me.addEventListener("error",function(){ae.loading|=2}),ae.loading|=4,iO(W,h,j)}W={type:"stylesheet",instance:W,count:1,state:ae},E.set(I,W)}}}function Hot(c,h){Ed.X(c,h);var x=vb;if(x&&c){var j=Gf(x).hoistableScripts,E=yb(c),I=j.get(E);I||(I=x.querySelector(hk(E)),I||(c=A({src:c,async:!0},h),(h=El.get(E))&&oF(c,h),I=x.createElement("script"),aa(I),ci(I,"link",c),x.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},j.set(E,I))}}function Vot(c,h){Ed.M(c,h);var x=vb;if(x&&c){var j=Gf(x).hoistableScripts,E=yb(c),I=j.get(E);I||(I=x.querySelector(hk(E)),I||(c=A({src:c,async:!0,type:"module"},h),(h=El.get(E))&&oF(c,h),I=x.createElement("script"),aa(I),ci(I,"link",c),x.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},j.set(E,I))}}function kme(c,h,x,j){var E=(E=pe.current)?dk(E):null;if(!E)throw Error(s(446));switch(c){case"meta":case"title":return null;case"style":return typeof x.precedence=="string"&&typeof x.href=="string"?(x=bb(x.href),h=Gf(E).hoistableStyles,j=h.get(x),j||(j={type:"style",instance:null,count:0,state:null},h.set(x,j)),j):{type:"void",instance:null,count:0,state:null};case"link":if(x.rel==="stylesheet"&&typeof x.href=="string"&&typeof x.precedence=="string"){c=bb(x.href);var I=Gf(E).hoistableStyles,W=I.get(c);if(W||(E=E.ownerDocument||E,W={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},I.set(c,W),(I=E.querySelector(fk(c)))?I._p||(W.instance=I,W.state.loading=5):(I=El.get(c),I||(I={rel:"preload",as:"style",href:x.href,crossOrigin:x.crossOrigin,integrity:x.integrity,media:x.media,hrefLang:x.hrefLang,referrerPolicy:x.referrerPolicy},El.set(c,I)),Kot(E,c,I,W.state))),h&&j===null)throw Error(s(528,""));return W}if(h&&j!==null)throw Error(s(529,""));return null;case"script":return h=x.async,x=x.src,typeof x=="string"&&h&&typeof h!="function"&&typeof h!="symbol"?(x=yb(x),h=Gf(E).hoistableScripts,j=h.get(x),j||(j={type:"script",instance:null,count:0,state:null},h.set(x,j)),j):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,c))}}function bb(c){return'href="'+Ii(c)+'"'}function fk(c){return'link[rel="stylesheet"]['+c+"]"}function Sme(c){return A({},c,{"data-precedence":c.precedence,precedence:null})}function Kot(c,h,x,j){if(h=c.querySelector('link[rel="preload"][as="style"]['+h+"]")){if(h[Aa]!==!0){j.loading=1;return}}else h=c.createElement("link"),h[Aa]=!0,h.onload=h.onerror=k0.bind(null,h),ci(h,"link",x),aa(h),c.head.appendChild(h);j.preload=h,h.addEventListener("load",function(){return j.loading|=1}),h.addEventListener("error",function(){return j.loading|=2})}function yb(c){return'[src="'+Ii(c)+'"]'}function hk(c){return"script[async]"+c}function Nme(c,h,x){if(h.count++,h.instance===null)switch(h.type){case"style":var j=c.querySelector('style[data-href~="'+Ii(x.href)+'"]');if(j)return h.instance=j,aa(j),j;var E=A({},x,{"data-href":x.href,"data-precedence":x.precedence,href:null,precedence:null});return j=(c.ownerDocument||c).createElement("style"),aa(j),ci(j,"style",E),iO(j,x.precedence,c),h.instance=j;case"stylesheet":E=bb(x.href);var I=c.querySelector(fk(E));if(I)return h.state.loading|=4,h.instance=I,aa(I),I;j=Sme(x),(E=El.get(E))&&iF(j,E),I=(c.ownerDocument||c).createElement("link"),aa(I);var W=I;return W._p=new Promise(function(ae,me){W.onload=ae,W.onerror=me}),ci(I,"link",j),h.state.loading|=4,iO(I,x.precedence,c),h.instance=I;case"script":return I=yb(x.src),(E=c.querySelector(hk(I)))?(h.instance=E,aa(E),E):(j=x,(E=El.get(I))&&(j=A({},x),oF(j,E)),c=c.ownerDocument||c,E=c.createElement("script"),aa(E),ci(E,"link",j),c.head.appendChild(E),h.instance=E);case"void":return null;default:throw Error(s(443,h.type))}else h.type==="stylesheet"&&(h.state.loading&4)===0&&(j=h.instance,h.state.loading|=4,iO(j,x.precedence,c));return h.instance}function iO(c,h,x){for(var j=x.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),E=j.length?j[j.length-1]:null,I=E,W=0;W title"):null)}function qot(c,h,x){if(x===1||h.itemProp!=null)return!1;switch(c){case"meta":case"title":return!0;case"style":if(typeof h.precedence!="string"||typeof h.href!="string"||h.href==="")break;return!0;case"link":if(typeof h.rel!="string"||typeof h.href!="string"||h.href===""||h.onLoad||h.onError)break;return h.rel==="stylesheet"?(c=h.disabled,typeof h.precedence=="string"&&c==null):!0;case"script":if(h.async&&typeof h.async!="function"&&typeof h.async!="symbol"&&!h.onLoad&&!h.onError&&h.src&&typeof h.src=="string")return!0}return!1}function Ame(c,h){return c==="img"&&h.src!=null&&h.src!==""&&h.onLoad==null&&h.loading!=="lazy"}function Eme(c){return!(c.type==="stylesheet"&&(c.state.loading&3)===0)}function Tme(c){return(c.width||100)*(c.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function Ome(c,h){typeof h.decode=="function"&&(c.imgCount++,h.complete||(c.imgBytes+=Tme(h),c.suspenseyImages.push(h)),c=Yot.bind(c),h.decode().then(c,c))}function Got(c,h,x,j){if(x.type==="stylesheet"&&(typeof j.media!="string"||matchMedia(j.media).matches!==!1)&&(x.state.loading&4)===0){if(x.instance===null){var E=bb(j.href),I=h.querySelector(fk(E));if(I){h=I._p,h!==null&&typeof h=="object"&&typeof h.then=="function"&&(c.count++,c=mk.bind(c),h.then(c,c)),x.state.loading|=4,x.instance=I,aa(I);return}I=h.ownerDocument||h,j=Sme(j),(E=El.get(E))&&iF(j,E),I=I.createElement("link"),aa(I);var W=I;W._p=new Promise(function(ae,me){W.onload=ae,W.onerror=me}),ci(I,"link",j),x.instance=I}c.stylesheets===null&&(c.stylesheets=new Map),c.stylesheets.set(x,h),(h=x.state.preload)&&(x.state.loading&3)===0&&(c.count++,x=mk.bind(c),h.addEventListener("load",x),h.addEventListener("error",x))}}var lO=0;function Wot(c,h){return c.stylesheets&&c.count===0&&uO(c,c.stylesheets),0lO?50:800)+h);return c.unsuspend=x,function(){c.unsuspend=null,clearTimeout(j),clearTimeout(E)}}:null}function Rme(c){if(c.count===0&&(c.imgCount===0||!c.waitingForImages)){if(c.stylesheets)uO(c,c.stylesheets);else if(c.unsuspend){var h=c.unsuspend;c.unsuspend=null,h()}}}function mk(){this.count--,Rme(this)}function Yot(){this.imgCount--,Rme(this)}var cO=null;function uO(c,h){c.stylesheets=null,c.unsuspend!==null&&(c.count++,cO=new Map,h.forEach(Xot,c),cO=null,mk.call(c))}function Xot(c,h){if(!(h.state.loading&4)){var x=cO.get(c);if(x)var j=x.get(null);else{x=new Map,cO.set(c,x);for(var E=c.querySelectorAll("link[data-precedence],style[data-precedence]"),I=0;I"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),bO.exports=Qme(),bO.exports}var zn=Zme();const CF=Td({__proto__:null},[zn]);var p=sg();const wO=Td({__proto__:null,default:dc(p)},[p]);function bk(){return typeof window<"u"}function Ha(e){return kO(e)?(e.nodeName||"").toLowerCase():"#document"}function vr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function lu(e){var t;return(t=(kO(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function kO(e){return bk()?e instanceof Node||e instanceof vr(e).Node:!1}function Un(e){return bk()?e instanceof Element||e instanceof vr(e).Element:!1}function br(e){return bk()?e instanceof HTMLElement||e instanceof vr(e).HTMLElement:!1}function ag(e){return!bk()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof vr(e).ShadowRoot}function Cb(e){const{overflow:t,overflowX:n,overflowY:s,display:i}=Li(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&i!=="inline"&&i!=="contents"}function Jme(e){return/^(table|td|th)$/.test(Ha(e))}function yk(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const epe=/transform|translate|scale|rotate|perspective|filter/,tpe=/paint|layout|strict|content/,yh=e=>!!e&&e!=="none";let SO;function NO(e){const t=Un(e)?Li(e):e;return yh(t.transform)||yh(t.translate)||yh(t.scale)||yh(t.rotate)||yh(t.perspective)||!CO()&&(yh(t.backdropFilter)||yh(t.filter))||epe.test(t.willChange||"")||tpe.test(t.contain||"")}function npe(e){let t=Pd(e);for(;br(t)&&!Rd(t);){if(NO(t))return t;if(yk(t))return null;t=Pd(t)}return null}function CO(){return SO==null&&(SO=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),SO}function Rd(e){return/^(html|body|#document)$/.test(Ha(e))}function Li(e){return vr(e).getComputedStyle(e)}function jk(e){return Un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Pd(e){if(Ha(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ag(e)&&e.host||lu(e);return ag(t)?t.host:t}function AF(e){const t=Pd(e);return Rd(t)?(e.ownerDocument||e).body:br(t)&&Cb(t)?t:AF(t)}function ig(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=AF(e),o=i===((s=e.ownerDocument)==null?void 0:s.body),l=vr(i);if(o){const u=AO(l);return t.concat(l,l.visualViewport||[],Cb(i)?i:[],u&&n?ig(u):[])}else return t.concat(i,ig(i,[],n))}function AO(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const EO={...wO},EF={};function $s(e,t){const n=p.useRef(EF);return n.current===EF&&(n.current=e(t)),n}const TO=EO.useInsertionEffect,rpe=TO&&TO!==EO.useLayoutEffect?TO:e=>e();function qe(e){const t=$s(spe).current;return t.next=e,rpe(t.effect),t.trampoline}function spe(){const e={next:void 0,callback:ape,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function ape(){}const Ge=typeof document<"u"?p.useLayoutEffect:()=>{};function OO(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}const RO={};function oo(e,t,n,s,i){if(!n&&!s&&!i&&!e)return wk(t);let o=wk(e);return t&&(o=Ab(o,t)),n&&(o=Ab(o,n)),s&&(o=Ab(o,s)),i&&(o=Ab(o,i)),o}function ipe(e){if(e.length===0)return RO;if(e.length===1)return wk(e[0]);let t=wk(e[0]);for(let n=1;n=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function PO(e){return typeof e=="function"}function OF(e,t){return PO(e)?e(t):e??RO}function cpe(e,t){return t?e?(...n)=>{const s=n[0];if(IF(s)){const o=s;kk(o);const l=t(...n);return o.baseUIHandlerPrevented||e?.(...n),l}const i=t(...n);return e?.(...n),i}:RF(t):e}function RF(e){return e&&((...t)=>{const n=t[0];return IF(n)&&kk(n),e(...t)})}function kk(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function PF(e,t){return t?e?t+" "+e:t:e}function IF(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function upe(e,t){return function(s,...i){const o=new URL(e);return o.searchParams.set("code",s.toString()),i.forEach(l=>o.searchParams.append("args[]",l)),`${t} error #${s}; visit ${o} for the full message.`}}const Vn=upe("https://base-ui.com/production-error","Base UI"),MF=p.createContext(void 0);function _F(e=!1){const t=p.useContext(MF);if(t===void 0&&!e)throw new Error(Vn(16));return t}function dpe(e){const{focusableWhenDisabled:t,disabled:n,composite:s=!1,tabIndex:i=0,isNativeButton:o}=e,l=s&&t!==!1,u=s&&t===!1;return{props:p.useMemo(()=>{const f={onKeyDown(m){n&&t&&m.key!=="Tab"&&m.preventDefault()}};return s||(f.tabIndex=i,!o&&n&&(f.tabIndex=t?i:-1)),(o&&(t||l)||!o&&n)&&(f["aria-disabled"]=n),o&&(!t||u)&&(f.disabled=n),f},[s,n,t,l,u,o,i])}}function _n(e){return e?.ownerDocument||document}function og(e,t,{detail:n=0}={}){e.dispatchEvent(new(vr(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function $i(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:s=0,native:i=!0,composite:o}=e,l=p.useRef(null),u=_F(!0),d=o??u!==void 0,{props:f}=dpe({focusableWhenDisabled:n,disabled:t,composite:d,tabIndex:s,isNativeButton:i}),m=p.useCallback(()=>{const b=l.current;IO(b)&&d&&t&&f.disabled===void 0&&b.disabled&&(b.disabled=!1)},[t,f.disabled,d]);Ge(m,[m]);const g=p.useCallback((b={})=>{const{onClick:y,onMouseDown:k,onKeyUp:w,onKeyDown:S,onPointerDown:N,...C}=b;return oo({onClick(T){if(t){T.preventDefault();return}y?.(T)},onMouseDown(T){t||k?.(T)},onKeyDown(T){if(t||(kk(T),S?.(T),T.baseUIHandlerPrevented))return;const P=T.target===T.currentTarget,O=T.currentTarget,A=IO(O),R=!i&&fpe(O),M=P&&(i?A:!R),_=T.key==="Enter",L=T.key===" ",$=O.getAttribute("role"),D=$?.startsWith("menuitem")||$==="option"||$==="gridcell";if(P&&d&&L){if(T.defaultPrevented&&D)return;T.preventDefault(),(!i||A)&&(T.preventBaseUIHandler(),og(O,T));return}if(!M||i||!L&&!_){P&&R&&L&&T.preventDefault();return}T.defaultPrevented||(T.preventDefault(),_&&(T.preventBaseUIHandler(),og(O,T)))},onKeyUp(T){if(!t){if(kk(T),w?.(T),T.target===T.currentTarget&&i&&d&&IO(T.currentTarget)&&T.key===" "){T.preventDefault();return}T.baseUIHandlerPrevented||T.target===T.currentTarget&&!i&&!d&&!T.defaultPrevented&&T.key===" "&&(T.preventBaseUIHandler(),og(T.currentTarget,T))}},onPointerDown(T){if(t){T.preventDefault();return}N?.(T)}},i?{type:"button"}:{role:"button"},f,C)},[t,f,d,i]),v=qe(b=>{l.current=b,m()});return{getButtonProps:g,buttonRef:v}}function IO(e){return br(e)&&e.tagName==="BUTTON"}function fpe(e){return br(e)&&e.tagName==="A"&&!!e.href}function lo(e,t,n,s){const i=$s(DF).current;return mpe(i,e,t,n,s)&&LF(i,[e,t,n,s]),i.callback}function hpe(e){const t=$s(DF).current;return ppe(t,e)&&LF(t,e),t.callback}function DF(){return{callback:null,cleanup:null,refs:[]}}function mpe(e,t,n,s,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==s||e.refs[3]!==i}function ppe(e,t){return e.refs.length!==t.length||e.refs.some((n,s)=>n!==t[s])}function LF(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const s=Array(t.length).fill(null);for(let i=0;i{for(let i=0;i=e}function $F(e){if(!p.isValidElement(e))return null;const t=e,n=t.props;return(MO(19)?n?.ref:t.ref)??null}function Xn(){}const co=Object.freeze([]),yr=Object.freeze({});function xpe(e,t){const n={};for(const s in e){const i=e[s];if(t?.hasOwnProperty(s)){const o=t[s](i);o!=null&&Object.assign(n,o);continue}i===!0?n[`data-${s.toLowerCase()}`]="":i&&(n[`data-${s.toLowerCase()}`]=i.toString())}return n}function vpe(e,t){return typeof e=="function"?e(t):e}function zF(e,t){return typeof e=="function"?e(t):e}function Kt(e,t,n={}){let s=t.render;n.enabled!==!1&&(s=wpe(s));const i=bpe(t,n,s);if(n.enabled===!1)return null;const o=n.state??yr;return kpe(e,s,i,o)}function bpe(e,t,n){const{className:s,style:i}=e,{state:o=yr,ref:l,props:u,stateAttributesMapping:d,enabled:f=!0}=t,m=f?vpe(s,o):void 0,g=f?zF(i,o):void 0,v=f?xpe(o,d):yr,b=f&&u?ype(u):void 0,y=f?OO(v,b)??{}:yr;return typeof document<"u"&&(f?Array.isArray(l)?y.ref=hpe([y.ref,$F(n),...l]):y.ref=lo(y.ref,$F(n),l):lo(null,null)),f?(m!==void 0&&(y.className=PF(y.className,m)),g!==void 0&&(y.style=OO(y.style,g)),y):yr}function ype(e){return Array.isArray(e)?ipe(e):oo(void 0,e)}const jpe=Symbol.for("react.lazy");function wpe(e){if(e?.$$typeof!==jpe)return e;const t=p.Children.toArray(e)[0];return p.isValidElement(t)?t:e}function kpe(e,t,n,s){if(t){if(typeof t=="function")return t(n,s);const i=oo(n,t.props);return i.ref=n.ref,p.cloneElement(t,i)}if(e&&typeof e=="string")return Spe(e,n);throw new Error(Vn(8))}function Spe(e,t){return e==="button"?p.createElement("button",{type:"button",...t,key:t.key}):e==="img"?p.createElement("img",{alt:"",...t,key:t.key}):p.createElement(e,t)}const Npe=p.forwardRef(function(t,n){const{render:s,className:i,disabled:o=!1,focusableWhenDisabled:l=!1,nativeButton:u=!0,style:d,...f}=t,{getButtonProps:m,buttonRef:g}=$i({disabled:o,focusableWhenDisabled:l,native:u});return Kt("button",t,{state:{disabled:o},ref:[n,g],props:[f,m]})});function BF(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;ttypeof e=="boolean"?`${e}`:e===0?"0":e,HF=FF,jh=(e,t)=>n=>{var s;if(t?.variants==null)return HF(e,n?.class,n?.className);const{variants:i,defaultVariants:o}=t,l=Object.keys(i).map(f=>{const m=n?.[f],g=o?.[f];if(m===null)return null;const v=UF(m)||UF(g);return i[f][v]}),u=n&&Object.entries(n).reduce((f,m)=>{let[g,v]=m;return v===void 0||(f[g]=v),f},{}),d=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((f,m)=>{let{class:g,className:v,...b}=m;return Object.entries(b).every(y=>{let[k,w]=y;return Array.isArray(w)?w.includes({...o,...u}[k]):{...o,...u}[k]===w})?[...f,g,v]:f},[]);return HF(e,l,d,n?.class,n?.className)},Cpe=(e,t)=>{const n=new Array(e.length+t.length);for(let s=0;s({classGroupId:e,validator:t}),VF=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Sk="-",KF=[],Epe="arbitrary..",Tpe=e=>{const t=Rpe(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Ope(l);const u=l.split(Sk),d=u[0]===""&&u.length>1?1:0;return qF(u,d,t)},getConflictingClassGroupIds:(l,u)=>{if(u){const d=s[l],f=n[l];return d?f?Cpe(f,d):d:f||KF}return n[l]||KF}}},qF=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],o=n.nextPart.get(i);if(o){const f=qF(e,t+1,o);if(f)return f}const l=n.validators;if(l===null)return;const u=t===0?e.join(Sk):e.slice(t).join(Sk),d=l.length;for(let f=0;fe.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),s=t.slice(0,n);return s?Epe+s:void 0})(),Rpe=e=>{const{theme:t,classGroups:n}=e;return Ppe(n,t)},Ppe=(e,t)=>{const n=VF();for(const s in e){const i=e[s];_O(i,n,s,t)}return n},_O=(e,t,n,s)=>{const i=e.length;for(let o=0;o{if(typeof e=="string"){Mpe(e,t,n);return}if(typeof e=="function"){_pe(e,t,n,s);return}Dpe(e,t,n,s)},Mpe=(e,t,n)=>{const s=e===""?t:GF(t,e);s.classGroupId=n},_pe=(e,t,n,s)=>{if(Lpe(e)){_O(e(s),t,n,s);return}t.validators===null&&(t.validators=[]),t.validators.push(Ape(n,e))},Dpe=(e,t,n,s)=>{const i=Object.entries(e),o=i.length;for(let l=0;l{let n=e;const s=t.split(Sk),i=s.length;for(let o=0;o"isThemeGetter"in e&&e.isThemeGetter===!0,$pe=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),s=Object.create(null);const i=(o,l)=>{n[o]=l,t++,t>e&&(t=0,s=n,n=Object.create(null))};return{get(o){let l=n[o];if(l!==void 0)return l;if((l=s[o])!==void 0)return i(o,l),l},set(o,l){o in n?n[o]=l:i(o,l)}}},DO="!",WF=":",zpe=[],YF=(e,t,n,s,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:s,isExternal:i}),Bpe=e=>{const{prefix:t,experimentalParseClassName:n}=e;let s=i=>{const o=[];let l=0,u=0,d=0,f;const m=i.length;for(let k=0;kd?f-d:void 0;return YF(o,b,v,y)};if(t){const i=t+WF,o=s;s=l=>l.startsWith(i)?o(l.slice(i.length)):YF(zpe,!1,l,void 0,!0)}if(n){const i=s;s=o=>n({className:o,parseClassName:i})}return s},Fpe=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,s)=>{t.set(n,1e6+s)}),n=>{const s=[];let i=[];for(let o=0;o0&&(i.sort(),s.push(...i),i=[]),s.push(l)):i.push(l)}return i.length>0&&(i.sort(),s.push(...i)),s}},Upe=e=>({cache:$pe(e.cacheSize),parseClassName:Bpe(e),sortModifiers:Fpe(e),postfixLookupClassGroupIds:Hpe(e),...Tpe(e)}),Hpe=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let s=0;s{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:i,sortModifiers:o,postfixLookupClassGroupIds:l}=t,u=[],d=e.trim().split(Vpe);let f="";for(let m=d.length-1;m>=0;m-=1){const g=d[m],{isExternal:v,modifiers:b,hasImportantModifier:y,baseClassName:k,maybePostfixModifierPosition:w}=n(g);if(v){f=g+(f.length>0?" "+f:f);continue}let S=!!w,N;if(S){const A=k.substring(0,w);N=s(A);const R=N&&l[N]?s(k):void 0;R&&R!==N&&(N=R,S=!1)}else N=s(k);if(!N){if(!S){f=g+(f.length>0?" "+f:f);continue}if(N=s(k),!N){f=g+(f.length>0?" "+f:f);continue}S=!1}const C=b.length===0?"":b.length===1?b[0]:o(b).join(":"),T=y?C+DO:C,P=T+N;if(u.indexOf(P)>-1)continue;u.push(P);const O=i(N,S);for(let A=0;A0?" "+f:f)}return f},qpe=(...e)=>{let t=0,n,s,i="";for(;t{if(typeof e=="string")return e;let t,n="";for(let s=0;s{let n,s,i,o;const l=d=>{const f=t.reduce((m,g)=>g(m),e());return n=Upe(f),s=n.cache.get,i=n.cache.set,o=u,u(d)},u=d=>{const f=s(d);if(f)return f;const m=Kpe(d,n);return i(d,m),m};return o=l,(...d)=>o(qpe(...d))},Wpe=[],ua=e=>{const t=n=>n[e]||Wpe;return t.isThemeGetter=!0,t.themeKey=e,t},QF=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ZF=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ype=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Xpe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Qpe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Zpe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,Jpe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ege=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Id=e=>Ype.test(e),Bn=e=>!!e&&!Number.isNaN(Number(e)),fc=e=>!!e&&Number.isInteger(Number(e)),LO=e=>e.endsWith("%")&&Bn(e.slice(0,-1)),cu=e=>Xpe.test(e),JF=()=>!0,tge=e=>Qpe.test(e)&&!Zpe.test(e),$O=()=>!1,nge=e=>Jpe.test(e),rge=e=>ege.test(e),sge=e=>!$t(e)&&!Ft(e),age=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),ige=e=>Md(e,aU,$O),$t=e=>QF.test(e),wh=e=>Md(e,iU,tge),eU=e=>Md(e,mge,Bn),oge=e=>Md(e,lU,JF),lge=e=>Md(e,oU,$O),tU=e=>Md(e,rU,$O),cge=e=>Md(e,sU,rge),Nk=e=>Md(e,cU,nge),Ft=e=>ZF.test(e),Eb=e=>kh(e,iU),uge=e=>kh(e,oU),nU=e=>kh(e,rU),dge=e=>kh(e,aU),fge=e=>kh(e,sU),Ck=e=>kh(e,cU,!0),hge=e=>kh(e,lU,!0),Md=(e,t,n)=>{const s=QF.exec(e);return s?s[1]?t(s[1]):n(s[2]):!1},kh=(e,t,n=!1)=>{const s=ZF.exec(e);return s?s[1]?t(s[1]):n:!1},rU=e=>e==="position"||e==="percentage",sU=e=>e==="image"||e==="url",aU=e=>e==="length"||e==="size"||e==="bg-size",iU=e=>e==="length",mge=e=>e==="number",oU=e=>e==="family-name",lU=e=>e==="number"||e==="weight",cU=e=>e==="shadow",pge=Gpe(()=>{const e=ua("color"),t=ua("font"),n=ua("text"),s=ua("font-weight"),i=ua("tracking"),o=ua("leading"),l=ua("breakpoint"),u=ua("container"),d=ua("spacing"),f=ua("radius"),m=ua("shadow"),g=ua("inset-shadow"),v=ua("text-shadow"),b=ua("drop-shadow"),y=ua("blur"),k=ua("perspective"),w=ua("aspect"),S=ua("ease"),N=ua("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...T(),Ft,$t],O=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],R=()=>[Ft,$t,d],M=()=>[Id,"full","auto",...R()],_=()=>[fc,"none","subgrid",Ft,$t],L=()=>["auto",{span:["full",fc,Ft,$t]},fc,Ft,$t],$=()=>[fc,"auto",Ft,$t],D=()=>["auto","min","max","fr",Ft,$t],F=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],V=()=>["start","end","center","stretch","center-safe","end-safe"],q=()=>["auto",...R()],Q=()=>[Id,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],X=()=>[u,Id,"screen","full","dvw","lvw","svw","min","max","fit",...R()],U=()=>[Id,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],z=()=>[e,Ft,$t],K=()=>[...T(),nU,tU,{position:[Ft,$t]}],J=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ee=()=>["auto","cover","contain",dge,ige,{size:[Ft,$t]}],H=()=>[LO,Eb,wh],G=()=>["","none","full",f,Ft,$t],Y=()=>["",Bn,Eb,wh],se=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ne=()=>[Bn,LO,nU,tU],de=()=>["","none",y,Ft,$t],ie=()=>["none",Bn,Ft,$t],oe=()=>["none",Bn,Ft,$t],je=()=>[Bn,Ft,$t],te=()=>[Id,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[cu],breakpoint:[cu],color:[JF],container:[cu],"drop-shadow":[cu],ease:["in","out","in-out"],font:[sge],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[cu],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[cu],shadow:[cu],spacing:["px",Bn],text:[cu],"text-shadow":[cu],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Id,$t,Ft,w]}],container:["container"],"container-type":[{"@container":["","normal","size",Ft,$t]}],"container-named":[age],columns:[{columns:[Bn,"auto",$t,Ft,u]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[fc,"auto",Ft,$t]}],basis:[{basis:[Id,"full","auto",u,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Bn,Id,"auto","initial","none",$t]}],grow:[{grow:["",Bn,Ft,$t]}],shrink:[{shrink:["",Bn,Ft,$t]}],order:[{order:[fc,"first","last","none",Ft,$t]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...F(),"normal"]}],"justify-items":[{"justify-items":[...V(),"normal"]}],"justify-self":[{"justify-self":["auto",...V()]}],"align-content":[{content:["normal",...F()]}],"align-items":[{items:[...V(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...V(),{baseline:["","last"]}]}],"place-content":[{"place-content":F()}],"place-items":[{"place-items":[...V(),"baseline"]}],"place-self":[{"place-self":["auto",...V()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:q()}],mx:[{mx:q()}],my:[{my:q()}],ms:[{ms:q()}],me:[{me:q()}],mbs:[{mbs:q()}],mbe:[{mbe:q()}],mt:[{mt:q()}],mr:[{mr:q()}],mb:[{mb:q()}],ml:[{ml:q()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...X()]}],"min-inline-size":[{"min-inline":["auto",...X()]}],"max-inline-size":[{"max-inline":["none",...X()]}],"block-size":[{block:["auto",...U()]}],"min-block-size":[{"min-block":["auto",...U()]}],"max-block-size":[{"max-block":["none",...U()]}],w:[{w:[u,"screen",...Q()]}],"min-w":[{"min-w":[u,"screen","none",...Q()]}],"max-w":[{"max-w":[u,"screen","none","prose",{screen:[l]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh","none",...Q()]}],"font-size":[{text:["base",n,Eb,wh]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,hge,oge]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",LO,$t]}],"font-family":[{font:[uge,lge,t]}],"font-features":[{"font-features":[$t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Ft,$t]}],"line-clamp":[{"line-clamp":[Bn,"none",Ft,eU]}],leading:[{leading:["none",o,...R()]}],"list-image":[{"list-image":["none",Ft,$t]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ft,$t]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:z()}],"text-color":[{text:z()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...se(),"wavy"]}],"text-decoration-thickness":[{decoration:[Bn,"from-font","auto",Ft,wh]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[Bn,"auto",Ft,$t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[fc,Ft,$t]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ft,$t]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ft,$t]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:J()}],"bg-size":[{bg:ee()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},fc,Ft,$t],radial:["",Ft,$t],conic:["",fc,Ft,$t]},fge,cge]}],"bg-color":[{bg:z()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:z()}],"gradient-via":[{via:z()}],"gradient-to":[{to:z()}],rounded:[{rounded:G()}],"rounded-s":[{"rounded-s":G()}],"rounded-e":[{"rounded-e":G()}],"rounded-t":[{"rounded-t":G()}],"rounded-r":[{"rounded-r":G()}],"rounded-b":[{"rounded-b":G()}],"rounded-l":[{"rounded-l":G()}],"rounded-ss":[{"rounded-ss":G()}],"rounded-se":[{"rounded-se":G()}],"rounded-ee":[{"rounded-ee":G()}],"rounded-es":[{"rounded-es":G()}],"rounded-tl":[{"rounded-tl":G()}],"rounded-tr":[{"rounded-tr":G()}],"rounded-br":[{"rounded-br":G()}],"rounded-bl":[{"rounded-bl":G()}],"border-w":[{border:Y()}],"border-w-x":[{"border-x":Y()}],"border-w-y":[{"border-y":Y()}],"border-w-s":[{"border-s":Y()}],"border-w-e":[{"border-e":Y()}],"border-w-bs":[{"border-bs":Y()}],"border-w-be":[{"border-be":Y()}],"border-w-t":[{"border-t":Y()}],"border-w-r":[{"border-r":Y()}],"border-w-b":[{"border-b":Y()}],"border-w-l":[{"border-l":Y()}],"divide-x":[{"divide-x":Y()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Y()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...se(),"hidden","none"]}],"divide-style":[{divide:[...se(),"hidden","none"]}],"border-color":[{border:z()}],"border-color-x":[{"border-x":z()}],"border-color-y":[{"border-y":z()}],"border-color-s":[{"border-s":z()}],"border-color-e":[{"border-e":z()}],"border-color-bs":[{"border-bs":z()}],"border-color-be":[{"border-be":z()}],"border-color-t":[{"border-t":z()}],"border-color-r":[{"border-r":z()}],"border-color-b":[{"border-b":z()}],"border-color-l":[{"border-l":z()}],"divide-color":[{divide:z()}],"outline-style":[{outline:[...se(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Bn,Ft,$t]}],"outline-w":[{outline:["",Bn,Eb,wh]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","inner","none",m,Ck,Nk]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",g,Ck,Nk]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:Y()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[Bn,wh]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":Y()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",v,Ck,Nk]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[Bn,Ft,$t]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Bn]}],"mask-image-linear-from-pos":[{"mask-linear-from":ne()}],"mask-image-linear-to-pos":[{"mask-linear-to":ne()}],"mask-image-linear-from-color":[{"mask-linear-from":z()}],"mask-image-linear-to-color":[{"mask-linear-to":z()}],"mask-image-t-from-pos":[{"mask-t-from":ne()}],"mask-image-t-to-pos":[{"mask-t-to":ne()}],"mask-image-t-from-color":[{"mask-t-from":z()}],"mask-image-t-to-color":[{"mask-t-to":z()}],"mask-image-r-from-pos":[{"mask-r-from":ne()}],"mask-image-r-to-pos":[{"mask-r-to":ne()}],"mask-image-r-from-color":[{"mask-r-from":z()}],"mask-image-r-to-color":[{"mask-r-to":z()}],"mask-image-b-from-pos":[{"mask-b-from":ne()}],"mask-image-b-to-pos":[{"mask-b-to":ne()}],"mask-image-b-from-color":[{"mask-b-from":z()}],"mask-image-b-to-color":[{"mask-b-to":z()}],"mask-image-l-from-pos":[{"mask-l-from":ne()}],"mask-image-l-to-pos":[{"mask-l-to":ne()}],"mask-image-l-from-color":[{"mask-l-from":z()}],"mask-image-l-to-color":[{"mask-l-to":z()}],"mask-image-x-from-pos":[{"mask-x-from":ne()}],"mask-image-x-to-pos":[{"mask-x-to":ne()}],"mask-image-x-from-color":[{"mask-x-from":z()}],"mask-image-x-to-color":[{"mask-x-to":z()}],"mask-image-y-from-pos":[{"mask-y-from":ne()}],"mask-image-y-to-pos":[{"mask-y-to":ne()}],"mask-image-y-from-color":[{"mask-y-from":z()}],"mask-image-y-to-color":[{"mask-y-to":z()}],"mask-image-radial":[{"mask-radial":[Ft,$t]}],"mask-image-radial-from-pos":[{"mask-radial-from":ne()}],"mask-image-radial-to-pos":[{"mask-radial-to":ne()}],"mask-image-radial-from-color":[{"mask-radial-from":z()}],"mask-image-radial-to-color":[{"mask-radial-to":z()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[Bn]}],"mask-image-conic-from-pos":[{"mask-conic-from":ne()}],"mask-image-conic-to-pos":[{"mask-conic-to":ne()}],"mask-image-conic-from-color":[{"mask-conic-from":z()}],"mask-image-conic-to-color":[{"mask-conic-to":z()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:J()}],"mask-size":[{mask:ee()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ft,$t]}],filter:[{filter:["","none",Ft,$t]}],blur:[{blur:de()}],brightness:[{brightness:[Bn,Ft,$t]}],contrast:[{contrast:[Bn,Ft,$t]}],"drop-shadow":[{"drop-shadow":["","none",b,Ck,Nk]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",Bn,Ft,$t]}],"hue-rotate":[{"hue-rotate":[Bn,Ft,$t]}],invert:[{invert:["",Bn,Ft,$t]}],saturate:[{saturate:[Bn,Ft,$t]}],sepia:[{sepia:["",Bn,Ft,$t]}],"backdrop-filter":[{"backdrop-filter":["","none",Ft,$t]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[Bn,Ft,$t]}],"backdrop-contrast":[{"backdrop-contrast":[Bn,Ft,$t]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Bn,Ft,$t]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Bn,Ft,$t]}],"backdrop-invert":[{"backdrop-invert":["",Bn,Ft,$t]}],"backdrop-opacity":[{"backdrop-opacity":[Bn,Ft,$t]}],"backdrop-saturate":[{"backdrop-saturate":[Bn,Ft,$t]}],"backdrop-sepia":[{"backdrop-sepia":["",Bn,Ft,$t]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ft,$t]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Bn,"initial",Ft,$t]}],ease:[{ease:["linear","initial",S,Ft,$t]}],delay:[{delay:[Bn,Ft,$t]}],animate:[{animate:["none",N,Ft,$t]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[k,Ft,$t]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ie()}],"rotate-x":[{"rotate-x":ie()}],"rotate-y":[{"rotate-y":ie()}],"rotate-z":[{"rotate-z":ie()}],scale:[{scale:oe()}],"scale-x":[{"scale-x":oe()}],"scale-y":[{"scale-y":oe()}],"scale-z":[{"scale-z":oe()}],"scale-3d":["scale-3d"],skew:[{skew:je()}],"skew-x":[{"skew-x":je()}],"skew-y":[{"skew-y":je()}],transform:[{transform:[Ft,$t,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:te()}],"translate-x":[{"translate-x":te()}],"translate-y":[{"translate-y":te()}],"translate-z":[{"translate-z":te()}],"translate-none":["translate-none"],zoom:[{zoom:[fc,Ft,$t]}],accent:[{accent:z()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:z()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ft,$t]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":z()}],"scrollbar-track-color":[{"scrollbar-track":z()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ft,$t]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[Bn,Eb,wh,eU]}],stroke:[{stroke:["none",...z()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Ne(...e){return pge(FF(e))}const gge=jh(["group/button inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap border [font-family:inherit]","font-medium transition-[background-color,border-color,color,transform,box-shadow] duration-150 ease-out","outline-none select-none active:translate-y-[0.5px] focus-visible:shadow-focus","disabled:pointer-events-none disabled:opacity-45 disabled:shadow-none","[&_svg]:pointer-events-none [&_svg]:shrink-0"],{variants:{variant:{default:"border-primary bg-primary font-semibold text-primary-on shadow-glow hover:border-primary-hover hover:bg-primary-hover",outline:"border-control-border bg-control text-foreground shadow-1 hover:border-control-border-hover hover:bg-control-hover",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"border-transparent bg-transparent text-subtle shadow-none hover:bg-control-hover hover:text-foreground",destructive:"border-destructive-bd bg-destructive-soft text-destructive hover:bg-destructive-hover",dashed:"border-dashed border-border-strong bg-transparent text-muted-foreground shadow-none hover:border-primary hover:text-primary-fg",link:"border-transparent bg-transparent text-primary shadow-none underline-offset-4 hover:underline"},size:{default:"h-[30px] rounded-md px-3 text-[12.5px]","2xs":"h-4 rounded-pill px-1.5 text-[10px]",xs:"h-6 rounded-sm px-2 text-[11.5px]",sm:"h-[26px] rounded-sm px-2.5 text-[12px]",lg:"h-9 rounded-md px-4 text-[13px]",icon:"h-[30px] w-[30px] rounded-md p-0","icon-2xs":"size-4 rounded-pill p-0","icon-xs":"size-6 rounded-sm p-0","icon-sm":"h-[26px] w-[26px] rounded-sm p-0","icon-lg":"size-9 rounded-md p-0",touch:"h-[46px] rounded-md px-4 text-[14px]","touch-sm":"h-[34px] rounded-sm px-3 text-[12.5px]","icon-touch":"size-9 rounded-full p-0"}},defaultVariants:{variant:"default",size:"default"}});function B({className:e,variant:t,size:n,...s}){return r.jsx(Npe,{"data-slot":"button",className:Ne(gge({variant:t,size:n}),e),...s})}const xge="data-valid",vge="data-invalid",Ak={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},uU={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},bge={disabled:!1,...uU},hc={valid(e){return e===null?null:e?{[xge]:""}:{[vge]:""}}},dU={invalid:void 0,name:void 0,validityData:{state:Ak,errors:[],error:"",value:"",initialValue:null},setValidityData:Xn,disabled:void 0,setTouched:Xn,setDirty:Xn,setFilled:Xn,setFocused:Xn,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:bge,registerFieldControl:Xn,validation:{getValidationProps:(e,t=yr)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Xn,getInputControl:()=>null,commit:async()=>{},change:Xn}},zO=p.createContext(dU);function uo(e=!0){const t=p.useContext(zO);if(t.setValidityData===Xn&&!e)throw new Error(Vn(28));return t}const fU=p.createContext(void 0);function BO(e=!1){const t=p.useContext(fU);if(!t&&!e)throw new Error(Vn(86));return t}const yge=p.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Xn,validationMode:"onSubmit",submitCountRef:{current:0}});function uu(){return p.useContext(yge)}let hU=0;function jge(e,t="mui"){const[n,s]=p.useState(e),i=e||n;return p.useEffect(()=>{n==null&&(hU+=1,s(`${t}-${hU}`))},[n,t]),i}const mU=EO.useId;function lg(e,t){if(mU!==void 0){const n=mU();return e??(t?`${t}-${n}`:n)}return jge(e,t)}function Ws(e){return lg(e,"base-ui")}const pU=p.createContext({controlId:void 0,registerControlId:Xn,resetControlId:Xn,labelId:void 0,setLabelId:Xn,messageIds:[],setMessageIds:Xn,getDescriptionProps:e=>e});function zi(){return p.useContext(pU)}const wge=function(t){const n=Ws(),[s,i]=p.useState(n),[o,l]=p.useState(),[u,d]=p.useState([]),f=s===void 0?n:s,m=$s(()=>new Map),{messageIds:g}=zi(),v=qe((w,S)=>{const N=m.current;S===void 0?N.delete(w):N.set(w,S),i(C=>{if(N.size===0)return C;let T;for(const P of N.values()){if(P===C)return C;T===void 0&&(T=P)}return T})}),b=qe(()=>{m.current.size===0&&i(n)}),y=p.useCallback(w=>{const S=w["aria-describedby"]?w["aria-describedby"].split(" "):[];return S.push(...g,...u),{...w,"aria-describedby":Array.from(new Set(S)).join(" ")||void 0}},[g,u]),k=p.useMemo(()=>({controlId:f,registerControlId:v,resetControlId:b,labelId:o,setLabelId:l,messageIds:u,setMessageIds:d,getDescriptionProps:y}),[f,v,b,o,l,u,d,y]);return r.jsx(pU.Provider,{value:k,children:t.children})};function FO(e,t,n,s=!0,i){const[o,l]=p.useState(),u=Ws(i?`${i}-label`:void 0),d=e??t??o;return Ge(()=>{const f=e||t||!s?void 0:kge(n.current,u);o!==f&&l(f)}),d}function kge(e,t){const n=Sge(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function Sge(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const i=e.nextElementSibling;if(i&&i.htmlFor===n)return i}const s=e.labels;return s&&s[0]}function _d(e={}){const{id:t,enabled:n=!0}=e,{controlId:s,registerControlId:i,resetControlId:o}=zi(),l=Ws(),u=$s(()=>Symbol()),d=p.useRef(!1),f=p.useRef(!1),m=qe(()=>{!d.current||i===Xn||(d.current=!1,i(u.current,void 0))});return Ge(()=>{if(!n||i===Xn){m();return}let g;if(t!==void 0)f.current=!0,g=t;else if(f.current)g=l;else{o();return}if(g===void 0){m();return}d.current=!0,i(u.current,g)},[t,n,i,o,l,u,m]),Ge(()=>m,[m]),(n?s:void 0)??t??l}function Nge(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:Cge,platform:Age,maxTouchPoints:Ege}=Nge(),Ek=Cge.toLowerCase(),Tb=Age.toLowerCase(),Ob=/^i(os$|p)/.test(Tb)||Tb==="macintel"&&Ege>1,gU="android",Tk=Tb===gU||Ek.includes(gU),xU=!Ob&&Tb.startsWith("mac");Tb.startsWith("win");const Tge=xU||Ob,du=typeof CSS<"u"&&!!CSS.supports?.("-webkit-backdrop-filter:none"),vU=!du&&Ek.includes("firefox");!du&&Ek.includes("chrom");const Oge=Tge,UO=/jsdom|happydom/.test(Ek);function Ys(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Et(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&ag(n)){let s=t;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function Er(e){return"composedPath"in e?e.composedPath()[0]??e.target:e.target}const HO="data-base-ui-focusable",bU="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Sh="ArrowLeft",Nh="ArrowRight",VO="ArrowUp",Ok="ArrowDown",KO="data-starting-style",Rge="data-ending-style",Pge={[KO]:""},Ige={[Rge]:""},Fo={transitionStatus(e){return e==="starting"?Pge:e==="ending"?Ige:null}},Mge="data-open",_ge="data-closed",Dge="data-anchor-hidden",yU="data-popup-open",Lge="data-pressed",$ge={[yU]:""},zge={[yU]:"",[Lge]:""},Bge={[Mge]:""},Fge={[_ge]:""},Uge={[Dge]:""},Rk={open(e){return e?$ge:null}},qO={open(e){return e?zge:null}},cg={open(e){return e?Bge:Fge},anchorHidden(e){return e?Uge:null}},GO={...cg,...Fo},WO="data-trigger-disabled";function Pk(e,t){if(!Un(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute(WO);for(const[,s]of t.entries())if(Et(s,n))return!s.hasAttribute(WO);return!1}function YO(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Hge(e){return e.matches("html,body")}function Ik(e){return br(e)&&e.matches(bU)}function Vge(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${bU}`)!=null}function XO(e){return e?e.getAttribute("role")==="combobox"&&Ik(e):!1}function Mk(e){if(!e||UO)return!0;try{return e.matches(":focus-visible")}catch{return!0}}function _k(e){return e?e.hasAttribute(HO)?e:e.querySelector(`[${HO}]`)||e:null}function Dd(e,t,n=!0){return e.filter(i=>i.parentId===t).flatMap(i=>[...!n||i.context?.open?[i]:[],...Dd(e,i.id,n)])}function jU(e,t){let n=[],s=e.find(i=>i.id===t)?.parentId;for(;s;){const i=e.find(o=>o.id===s);s=i?.parentId,i&&(n=n.concat(i))}return n}function da(e){e.preventDefault(),e.stopPropagation()}function Kge(e){return"nativeEvent"in e}function Dk(e){return e.pointerType===""&&e.isTrusted?!0:Tk&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function QO(e){return UO?!1:!Tk&&e.width===0&&e.height===0||Tk&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function Ld(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function qge(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const ug=Math.min,fu=Math.max,Lk=Math.round,Ch=Math.floor,hu=e=>({x:e,y:e}),Gge={left:"right",right:"left",bottom:"top",top:"bottom"};function wU(e,t,n){return fu(e,ug(t,n))}function $d(e,t){return typeof e=="function"?e(t):e}function Uo(e){return e.split("-")[0]}function mu(e){return e.split("-")[1]}function ZO(e){return e==="x"?"y":"x"}function JO(e){return e==="y"?"height":"width"}function Ho(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function eR(e){return ZO(Ho(e))}function Wge(e,t,n){n===void 0&&(n=!1);const s=mu(e),i=eR(e),o=JO(i);let l=i==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(l=$k(l)),[l,$k(l)]}function Yge(e){const t=$k(e);return[tR(e),t,tR(t)]}function tR(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const kU=["left","right"],SU=["right","left"],Xge=["top","bottom"],Qge=["bottom","top"];function Zge(e,t,n){switch(e){case"top":case"bottom":return n?t?SU:kU:t?kU:SU;case"left":case"right":return t?Xge:Qge;default:return[]}}function Jge(e,t,n,s){const i=mu(e);let o=Zge(Uo(e),n==="start",s);return i&&(o=o.map(l=>l+"-"+i),t&&(o=o.concat(o.map(tR)))),o}function $k(e){const t=Uo(e);return Gge[t]+e.slice(t.length)}function exe(e){var t,n,s,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(s=e.bottom)!=null?s:0,left:(i=e.left)!=null?i:0}}function NU(e){return typeof e!="number"?exe(e):{top:e,right:e,bottom:e,left:e}}function Rb(e){const{x:t,y:n,width:s,height:i}=e;return{width:s,height:i,top:n,left:t,right:t+s,bottom:n+i,x:t,y:n}}function zk(e,t,n){return Math.floor(e/t)!==n}function zd(e,t){return t<0||t>=e.length}function Bk(e,t){return Ta(e.current,{disabledIndices:t})}function nR(e,t){return Ta(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Ta(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:s,amount:i=1}={}){let o=t;do o+=n?-i:i;while(o>=0&&o<=e.length-1&&Bd(e,o,s));return o}function txe(e,{event:t,orientation:n,loopFocus:s,onLoop:i,rtl:o,cols:l,disabledIndices:u,minIndex:d,maxIndex:f,prevIndex:m,stopEvent:g=!1}){let v=m,b;if(t.key===VO?b="up":t.key===Ok&&(b="down"),b){const y=[],k=[];let w=!1,S=0;{let M=null,_=-1;e.forEach((L,$)=>{if(L==null)return;S+=1;const D=L.closest('[role="row"]');D&&(w=!0),(D!==M||_===-1)&&(M=D,_+=1,y[_]=[]),y[_].push($),k[$]=_})}let N=!1,C=0;if(w)for(const M of y){const _=M.length;_>C&&(C=_),_!==l&&(N=!0)}const T=N&&S{if(!N||m===-1)return;const _=k[m];if(_==null)return;const L=y[_].indexOf(m),$=M==="up"?-1:1;for(let D=_+$,F=0;F=y.length){if(!s||T)return;if(D=D<0?y.length-1:0,i){const q=Math.min(L,y[D].length-1),Q=y[D][q]??y[D][0],X=i(t,m,Q);D=k[X]??D}}const V=y[D];for(let q=Math.min(L,V.length-1);q>=0;q-=1){const Q=V[q];if(!Bd(e,Q,u))return Q}}},A=M=>{if(!T||m===-1)return;const _=m%P,L=M==="up"?-P:P,$=f-f%P,D=Ch(f/P)+1;for(let F=m-_+L,V=0;Vf){if(!s)return;F=F<0?$:0}const q=Math.min(F+P-1,f);for(let Q=Math.min(F+_,q);Q>=F;Q-=1)if(!Bd(e,Q,u))return Q}};g&&da(t);const R=O(b)??A(b);if(R!==void 0)v=R;else if(m===-1)v=b==="up"?f:d;else if(v=Ta(e,{startingIndex:m,amount:P,decrement:b==="up",disabledIndices:u}),s){if(b==="up"&&(m-PM?L:L-P,i&&(v=i(t,m,v))}b==="down"&&m+P>f&&(v=Ta(e,{startingIndex:m%P-P,amount:P,disabledIndices:u}),i&&(v=i(t,m,v)))}zd(e,v)&&(v=m)}if(n==="both"){const y=Ch(m/l);t.key===(o?Sh:Nh)&&(g&&da(t),m%l!==l-1?(v=Ta(e,{startingIndex:m,disabledIndices:u}),s&&zk(v,l,y)&&(v=Ta(e,{startingIndex:m-m%l-1,disabledIndices:u}),i&&(v=i(t,m,v)))):s&&(v=Ta(e,{startingIndex:m-m%l-1,disabledIndices:u}),i&&(v=i(t,m,v))),zk(v,l,y)&&(v=m)),t.key===(o?Nh:Sh)&&(g&&da(t),m%l!==0?(v=Ta(e,{startingIndex:m,decrement:!0,disabledIndices:u}),s&&zk(v,l,y)&&(v=Ta(e,{startingIndex:m+(l-m%l),decrement:!0,disabledIndices:u}),i&&(v=i(t,m,v)))):s&&(v=Ta(e,{startingIndex:m+(l-m%l),decrement:!0,disabledIndices:u}),i&&(v=i(t,m,v))),zk(v,l,y)&&(v=m));const k=Ch(f/l)===y;zd(e,v)&&(s&&k?(v=t.key===(o?Nh:Sh)?f:Ta(e,{startingIndex:m-m%l-1,disabledIndices:u}),i&&(v=i(t,m,v))):v=m)}return v}function Bd(e,t,n){if(typeof n=="function"?n(t):n?.includes(t)??!1)return!0;const i=e[t];return i?!Fk(i)||i.matches(":disabled")?!0:!n&&(i.hasAttribute("disabled")||i.getAttribute("aria-disabled")==="true"):!1}function nxe(e){return e.visibility==="hidden"||e.visibility==="collapse"}function Fk(e,t=e?Li(e):null){return!e||!e.isConnected||!t||nxe(t)?!1:typeof e.checkVisibility=="function"?e.checkVisibility():t.display!=="none"&&t.display!=="contents"}const rxe='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function sxe(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return ag(n)?n.host:null}function rR(e){for(const t of Array.from(e.children))if(Ha(t)==="summary")return t;return null}function axe(e,t){const n=rR(t);return!!n&&(e===n||Et(n,e))}function CU(e){const t=e?Ha(e):"";return e!=null&&e.matches(rxe)&&(t!=="summary"||e.parentElement!=null&&Ha(e.parentElement)==="details"&&rR(e.parentElement)===e)&&(t!=="details"||rR(e)==null)&&(t!=="input"||e.type!=="hidden")}function AU(e){if(!CU(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=sxe(t)){const n=t!==e,s=Ha(t)==="slot";if(t.hasAttribute("inert")||n&&Ha(t)==="details"&&!t.open&&!axe(e,t)||t.hasAttribute("hidden")||!s&&!ixe(t,n))return!1}return!0}function ixe(e,t){const n=Li(e);return t?n.display!=="none":Fk(e,n)}function EU(e){const t=e.tabIndex;if(t<0){const n=Ha(e);if(n==="details"||n==="audio"||n==="video"||br(e)&&e.isContentEditable)return 0}return t}function sR(e){if(Ha(e)!=="input")return null;const t=e;return t.type==="radio"&&t.name!==""?t:null}function oxe(e,t){const n=sR(e);if(!n)return!0;const s=t.find(i=>{const o=sR(i);return o?.name===n.name&&o.form===n.form&&o.checked});return s?s===n:t.find(i=>{const o=sR(i);return o?.name===n.name&&o.form===n.form})===n}function TU(e){if(br(e)&&Ha(e)==="slot"){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return br(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function OU(e,t){TU(e).forEach(n=>{CU(n)&&t.push(n),OU(n,t)})}function RU(e,t,n){TU(e).forEach(s=>{br(s)&&s.matches(t)&&n.push(s),RU(s,t,n)})}function aR(e){return AU(e)&&EU(e)>=0}function PU(e){const t=[];return OU(e,t),t.filter(AU)}function Pb(e){const t=PU(e);return t.filter(n=>EU(n)>=0&&oxe(n,t))}function IU(e,t){const n=Pb(e),s=n.length;if(s===0)return;const i=Ys(_n(e)),o=n.indexOf(i),l=o===-1?t===1?0:s-1:o+t;return n[l]}function iR(e){return IU(_n(e).body,1)||e}function MU(e){return IU(_n(e).body,-1)||e}function _U(e,t){if(!e)return null;const n=Pb(_n(e).body),s=n.length;if(s===0)return null;const i=n.indexOf(e);if(i===-1)return null;const o=(i+t+s)%s;return n[o]}function lxe(e){return _U(e,1)}function cxe(e){return _U(e,-1)}function dg(e,t){const n=t||e.currentTarget,s=e.relatedTarget;return!s||!Et(n,s)}function uxe(e){Pb(e).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function DU(e){const t=[];RU(e,"[data-tabindex]",t),t.forEach(n=>{const s=n.dataset.tabindex;delete n.dataset.tabindex,s?n.setAttribute("tabindex",s):n.removeAttribute("tabindex")})}function dxe(e,t){const n=Ws(e);return Ge(()=>(t(n),()=>{t(s=>s===n?void 0:s)}),[n,t]),n}function fxe(e={}){const{id:t,fallbackControlId:n,native:s=!1,setLabelId:i,focusControl:o}=e,{controlId:l,setLabelId:u}=zi(),d=qe(b=>{u(b),i?.(b)}),f=dxe(t,d),m=l??n;function g(b){if(o){o(b,m);return}if(!m)return;const y=_n(b.currentTarget).getElementById(m);br(y)&&hxe(y)}function v(b){Er(b.nativeEvent)?.closest("button,input,select,textarea")||(!b.defaultPrevented&&b.detail>1&&b.preventDefault(),!s&&g(b))}return s?{id:f,htmlFor:m,onMouseDown:v}:{id:f,onClick:v,onPointerDown(b){b.preventDefault()}}}function hxe(e){e.focus({focusVisible:!0})}function Uk(e){p.useEffect(e,co)}const Ib=0;class Bi{constructor(){Cn(this,"currentId",Ib);Cn(this,"clear",()=>{this.currentId!==Ib&&(clearTimeout(this.currentId),this.currentId=Ib)});Cn(this,"disposeEffect",()=>this.clear)}static create(){return new Bi}start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ib,n()},t)}isStarted(){return this.currentId!==Ib}}function fa(){const e=$s(Bi.create).current;return Uk(e.disposeEffect),e}function oR(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}const lR=Object.keys(Ak);function LU(e,t){return e.matches(":disabled")?!1:!t||e.form===t?!0:e.form===null&&!e.hasAttribute("form")}function $U(e,t){let n=null;for(const s of e.keys())if(LU(s,t)){if(!s.validity.valid)return s;n??(n=s)}return n}function zU(e){return{...Ak,valid:!e,customError:e}}function cR(e){return e&&e.validationMessage?[e.validationMessage]:[]}function mxe(e){const{elementRef:t,formRef:n}=uu(),{setValidityData:s,validate:i,validityData:o,validationDebounceTime:l,invalid:u,markedDirtyRef:d,state:f,shouldValidateOnChange:m,validationMode:g,registeredFieldIdRef:v}=e,{controlId:b,getDescriptionProps:y}=zi(),k=fa(),w=p.useRef(null),S=$s(()=>new Map).current,N=p.useRef(0),C=p.useRef(null),T=p.useCallback((M,_)=>(S.set(M,_),()=>{S.delete(M)}),[S]),P=qe(()=>{const M=$U(S,t.current);return M&&S.get(M)?.controlRef.current||null}),O=qe(async(M,_=!1)=>{N.current+=1;const L=N.current;function $(H,G=u){const Y=v.current??b;if(Y==null)return;const se=n.current.fields.get(Y);if(!se)return;const re=oR(H,G);n.current.fields.set(Y,{...se,validityData:re})}function D(H,G){const Y=H.valid===!1?G:[];return{value:M,state:H,error:Y[0]??"",errors:Y,initialValue:o.initialValue}}function F(H,G){const Y=H.validity.customError?H.validationMessage:"",se=G.replace(/\r\n?/g,` -`);H.setCustomValidity(se),C.current=[H,se,Y]}function V(){const H=C.current;C.current=null,H&&(!H[0].willValidate||H[0].validationMessage===H[1])&&H[0].setCustomValidity(H[2])}function q(H,G,Y){const se=D(H,G);$(se,Y),s(se)}function Q(H){const G=lR.reduce((se,re)=>(se[re]=H.validity[re],se),{});let Y=!1;for(const se of lR)if(se!=="valid"){if(se==="valueMissing"&&G[se])Y=!0;else if(G[se])return G}return Y&&!d.current&&(G.valid=!0,G.valueMissing=!1),G}function X(){return S.size>0?$U(S,t.current):w.current}let U=X();function z(){return U=X(),U?.willValidate?Q(U):zU(!1)}if(_){if(f.valid!==!1||!U)return;if(!U.validity.valueMissing){V();const H=X(),G=H?.validity.customError?cR(H):[];q(zU(G.length>0),G,!1);return}for(const H of lR)if(H!=="valid"&&H!=="valueMissing"&&H!=="customError"&&U.validity[H])return}k.clear(),V();let K=z(),J=cR(U);const ee=m();if(J.length===0||ee){const H=Array.from(n.current.fields.values()).reduce((se,re)=>(re.name&&(se[re.name]=re.getValue()),se),{}),G=i(M,H);let Y;if(typeof G=="object"&&G!==null&&"then"in G){if(K.valid===!1?q(K,J):(g==="onSubmit"||!o.state.customError)&&(K.valid=null,q(K,J)),Y=await G,L!==N.current)return;K=z()}else Y=G;J=Y?[].concat(Y).filter(Boolean):[],J.length>0?(K.valid=!1,K.customError=!0,U?.willValidate&&F(U,J.join(` -`))):J=cR(U)}q(K,J)}),A=qe((M,_=!1)=>{if(k.clear(),N.current+=1,_)return;const L=m();L&&M!==""&&l?k.start(l,()=>{O(M)}):O(M,!L)}),R=p.useCallback((M,_={})=>oo(y(_),f.valid===!1&&!f.disabled&&!M?{"aria-invalid":!0}:yr),[y,f.disabled,f.valid]);return p.useMemo(()=>({getValidationProps:R,inputRef:w,registeredInputs:S,registerInput:T,getInputControl:P,commit:O,change:A}),[R,S,T,P,O,A])}function pxe(e){const{change:t,commit:n,invalid:s,markedDirtyRef:i,name:o,setRegisteredFieldName:l,registeredFieldIdRef:u,setValidityData:d,validityData:f}=e,{formRef:m}=uu(),g=p.useRef(null),v=p.useRef(null),b=p.useRef(!1),y=qe(()=>{const P=v.current;if(P)return P.getValue?P.getValue():P.value});function k(P){return P.value===void 0?y():P.value}const w=qe(()=>{const P=v.current;if(i.current=!0,!P){n(f.value);return}n(k(P))});function S(){const P=v.current;!P||!P.id||m.current.fields.set(P.id,{getValue:y,name:o??P.name,controlRef:P.controlRef,validityData:oR(f,s),validate:w})}function N(P=v.current?.id){P&&m.current.fields.delete(P)}function C(P){if(b.current)return;b.current=!0;const O=k(P);d(A=>A.initialValue===O?A:{...A,initialValue:O})}Ge(()=>{const P=v.current;!P||!P.id||(l(o?void 0:P.name),m.current.fields.set(P.id,{getValue:y,name:o??P.name,controlRef:P.controlRef,validityData:oR(f,s),validate:w}))},[m,y,s,o,l,w,f]),Ge(()=>{const P=m.current.fields;return()=>{const O=v.current?.id;O&&P.delete(O)}},[m]);const T=qe((P,O)=>{if(!O){g.current===P&&(g.current=null,t(void 0,!0),N(),v.current=null,l(void 0),u.current=void 0);return}const A=v.current?.id,R=g.current;R&&R!==P&&t(void 0,!0),g.current=P,v.current=O,o||l(O.name),u.current=O.id,A&&A!==O.id&&N(A),C(O),S()});return[w,T]}const gxe=p.forwardRef(function(t,n){const{errors:s,validationMode:i,submitCountRef:o}=uu(),{render:l,className:u,validate:d,validationDebounceTime:f=0,validationMode:m=i,name:g,disabled:v=!1,invalid:b,dirty:y,touched:k,actionsRef:w,style:S,...N}=t,C=BO(!0)?.disabled,T=qe(d||(()=>null)),P=C||v,[O,A]=p.useState(!1),[R,M]=p.useState(!1),[_,L]=p.useState(!1),[$,D]=p.useState(!1),F=y??R,V=k??O,q=p.useRef(F),Q=p.useRef(void 0),[X,U]=p.useState(),z=g??X;Ge(()=>{y!==void 0&&(q.current=y)},[y]);const K=qe(he=>{y===void 0&&(he&&(q.current=!0),M(he))}),J=qe(he=>{k===void 0&&A(he)}),ee=qe(()=>m==="onChange"||m==="onSubmit"&&o.current>0),H=z&&Object.hasOwn(s,z)?s[z]:null,G=!!(Array.isArray(H)?H.length:H),Y=b===!0||G,[se,re]=p.useState({state:Ak,error:"",errors:[],value:null,initialValue:null}),ne=!Y&&(P?null:se.state.valid),de=p.useMemo(()=>({disabled:P,touched:V,dirty:F,valid:ne,filled:_,focused:$}),[P,V,F,ne,_,$]),ie=mxe({setValidityData:re,validate:T,validityData:se,validationDebounceTime:f,invalid:Y,markedDirtyRef:q,state:de,shouldValidateOnChange:ee,validationMode:m,registeredFieldIdRef:Q}),[oe,je]=pxe({change:ie.change,commit:ie.commit,invalid:Y,markedDirtyRef:q,name:g,setRegisteredFieldName:U,registeredFieldIdRef:Q,setValidityData:re,validityData:se});p.useImperativeHandle(w,()=>({validate:oe}),[oe]);const te=p.useMemo(()=>({invalid:Y,name:z,validityData:se,setValidityData:re,disabled:P,setTouched:J,setDirty:K,setFilled:L,setFocused:D,validationMode:m,shouldValidateOnChange:ee,state:de,registerFieldControl:je,validation:ie}),[Y,z,se,P,J,K,L,D,m,ee,de,je,ie]),le=Kt("div",t,{ref:n,state:de,props:N,stateAttributesMapping:hc});return r.jsx(zO.Provider,{value:te,children:le})}),xxe=p.forwardRef(function(t,n){return r.jsx(wge,{children:r.jsx(gxe,{...t,ref:n})})}),vxe=p.createContext({disabled:!1});function Hk(){return p.useContext(vxe)}const bxe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,nativeLabel:u=!0,...d}=t,f=uo(!1),m=Hk(),{labelId:g}=zi(),v={...f.state,disabled:f.disabled||m.disabled},b=p.useRef(null),y=fxe({id:g??l,native:u});return Kt("label",t,{ref:[n,b],state:v,props:[y,d],stateAttributesMapping:hc})}),Vk=null;class yxe{constructor(){Cn(this,"callbacks",[]);Cn(this,"callbacksCount",0);Cn(this,"nextId",1);Cn(this,"startId",1);Cn(this,"isScheduled",!1);Cn(this,"tick",t=>{this.isScheduled=!1;const n=this.callbacks,s=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,s>0)for(let i=0;i=this.callbacks.length||this.callbacks[n]!==null&&(this.callbacks[n]=null,this.callbacksCount-=1)}}let Kk=new yxe;class Fi{constructor(){Cn(this,"currentId",Vk);Cn(this,"cancel",()=>{this.currentId!==Vk&&(Kk.cancel(this.currentId),this.currentId=Vk)});Cn(this,"disposeEffect",()=>this.cancel)}static create(){return new Fi}static request(t){return Kk.request(t)}static cancel(t){return Kk.cancel(t)}request(t){this.cancel(),this.currentId=Kk.request(()=>{this.currentId=Vk,t()})}}function fg(){const e=$s(Fi.create).current;return Uk(e.disposeEffect),e}function pu(e){return e==null?e:"current"in e?e.current:e}let qk=null;function jxe(e){if(!qk){const t=[];qk=t,queueMicrotask(()=>{qk=null,xr.flushSync(()=>{for(const n of t)n()})})}qk.push(e)}function uR(e,t=!1,n=!1){const s=fg();return qe((i,o=null)=>{s.cancel();const l=pu(e);if(l==null)return;const u=l,d=()=>{if(!n){xr.flushSync(i);return}jxe(()=>{o?.aborted||i()})};if(typeof u.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function f(){Promise.all(u.getAnimations().map(m=>m.finished)).then(()=>{o?.aborted||d()},()=>{if(o?.aborted)return;if(u.getAnimations().some(g=>g.pending||g.playState!=="finished")){f();return}d()})}if(t){const m=KO;if(!u.hasAttribute(m)){s.request(f);return}const g=new MutationObserver(()=>{u.hasAttribute(m)||(g.disconnect(),f())});g.observe(u,{attributes:!0,attributeFilter:[m]}),o?.addEventListener("abort",()=>g.disconnect(),{once:!0});return}s.request(f)})}function ji(e){const{enabled:t=!0,open:n,ref:s,batch:i=!1,onComplete:o}=e,l=qe(o),u=uR(s,n,i);p.useEffect(()=>{if(!t)return;const d=new AbortController;return u(l,d.signal),()=>{d.abort()}},[t,n,l,u])}function gu(e,t=!1,n=!1,s=!1){const[i,o]=p.useState(e&&t?"idle":void 0),[l,u]=p.useState(e&&!s);return e&&!l&&(u(!0),o("starting")),!e&&l&&i!=="ending"&&!n&&o("ending"),!e&&!l&&i==="ending"&&o(void 0),Ge(()=>{if(!e&&l&&i!=="ending"&&n){const d=Fi.request(()=>{o("ending")});return()=>{Fi.cancel(d)}}},[e,l,i,n]),Ge(()=>{if(!e||t)return;const d=Fi.request(()=>{o(void 0)});return()=>{Fi.cancel(d)}},[t,e]),Ge(()=>{if(!e||!t)return;e&&l&&i!=="idle"&&o("starting");const d=Fi.request(()=>{o("idle")});return()=>{Fi.cancel(d)}},[t,e,l,i]),{mounted:l,setMounted:u,transitionStatus:i}}const wxe=p.forwardRef(function(t,n){const{render:s,id:i,className:o,style:l,...u}=t,d=Ws(i),f=uo(!1),m=Hk(),{setMessageIds:g}=zi(),v={...f.state,disabled:f.disabled||m.disabled};return Ge(()=>{if(d)return g(y=>y.concat(d)),()=>{g(y=>y.filter(k=>k!==d))}},[d,g]),Kt("p",t,{ref:n,state:v,props:[{id:d},u],stateAttributesMapping:hc})});function Tl({controlled:e,default:t,name:n,state:s="value"}){const{current:i}=p.useRef(e!==void 0),[o,l]=p.useState(t),u=i&&e!==void 0?e:o,d=p.useCallback(f=>{i||l(f)},[]);return[u,d]}function hg(e,t,n,s,i=!0,o){const{registerFieldControl:l}=uo(),u=$s(()=>Symbol());Ge(()=>{const d=u.current;if(!i){l(d,void 0);return}l(d,{controlRef:e,getValue:s,id:t,name:o,value:n})},[e,i,s,t,o,l,u,n]),Ge(()=>{const d=u.current;return()=>{l(d,void 0)}},[l,u])}function Vo(e,t){const n=p.useRef(e),s=qe(t);Ge(()=>{n.current!==e&&s(n.current),n.current=e},[e,s])}const rs="none",xu="trigger-press",Va="trigger-hover",Gk="trigger-focus",Wk="outside-press",Mb="item-press",dR="close-press",_b="input-change",mc="input-clear",kxe="input-press",Fd="focus-out",mg="escape-key",fR="list-navigation",BU="keyboard",FU="pointer",UU="cancel-open",Sxe="disabled",hR="imperative-action",Nxe="window-resize";function Nt(e,t,n,s){let i=!1,o=!1;const l=s??yr;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){o=!0},get isCanceled(){return i},get isPropagationAllowed(){return o},trigger:n,...l}}function Cxe(e,t,n){const s=n??yr;return{reason:e,event:t??new Event("base-ui"),...s}}const Axe=p.forwardRef(function(t,n){const{render:s,className:i,id:o,name:l,value:u,disabled:d=!1,onValueChange:f,defaultValue:m,autoFocus:g=!1,style:v,...b}=t,{state:y,name:k,disabled:w,setTouched:S,setDirty:N,validityData:C,setFocused:T,setFilled:P,validationMode:O,validation:A}=uo(),{clearErrors:R,elementRef:M,submitCountRef:_}=uu(),L=w||d,$=k??l,D={...y,disabled:L},{labelId:F}=zi(),V=_d({id:o}),[q]=Tl({controlled:u,default:m,name:"FieldControl",state:"value"}),Q=u!==void 0,X=Q?q:void 0,U=X==null?void 0:String(X),z=qe(()=>A.inputRef.current?.value);hg(A.inputRef,V,U,z,!L,l),Ge(()=>{const H=U??A.inputRef.current?.value;H!==void 0&&P(H!=="")},[U,A.inputRef,P]),Vo(U,()=>{U!==void 0&&(R($),N(U!==(C.initialValue??"")),A.change(U))});const K=p.useRef(null),J=fa();return Ge(()=>{g&&K.current===Ys(_n(K.current))&&T(!0)},[g,T]),Kt("input",t,{ref:[n,K],state:D,props:[{id:V,disabled:L,name:$,ref:A.inputRef,"aria-labelledby":F,autoFocus:g,...Q?{value:X}:{defaultValue:m},onChange(H){const G=H.currentTarget.value,Y=Nt(rs,H.nativeEvent);f?.(G,Y),!Q&&(N(G!==(C.initialValue??"")),P(G!==""),!H.nativeEvent.defaultPrevented&&!Y.isCanceled&&(R($),A.change(G)))},onFocus(){T(!0)},onBlur(H){if(S(!0),T(!1),O==="onBlur"){const G=H.currentTarget.value;A.commit(G),Q&&queueMicrotask(()=>{const Y=A.inputRef.current?.value;Y!==void 0&&Y!==G&&Y!==(C.initialValue??"")&&A.commit(Y)})}},onKeyDown(H){if(H.currentTarget.tagName==="INPUT"&&H.key==="Enter"){S(!0);const G=H.currentTarget.value,Y=H.currentTarget.form;if(Y&&Y===M.current&&!H.defaultPrevented){const se=H.currentTarget,re=_.current;J.start(0,()=>{_.current===re&&A.commit(se.value)})}else A.commit(G)}}},b,H=>A.getValidationProps(L,H)],stateAttributesMapping:hc})}),Exe=p.forwardRef(function(t,n){return r.jsx(Axe,{ref:n,...t})});function ze({className:e,type:t,ref:n,...s}){return t==="file"||t==="hidden"?r.jsx("input",{ref:n,type:t,"data-slot":"input",className:Ne(e),...s}):r.jsx(Exe,{ref:n,type:t,"data-slot":"input",className:Ne("h-[30px] w-full min-w-0 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] text-foreground outline-none max-[767px]:h-10 max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out","placeholder:text-muted-foreground","hover:border-control-border-hover","focus:border-primary focus:shadow-focus","disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-surface-3 disabled:text-muted-foreground","file:inline-flex file:border-0 file:bg-transparent file:text-foreground",e),...s})}function Xs({className:e,...t}){return r.jsx("textarea",{"data-slot":"textarea",className:Ne("min-h-26 w-full resize-y rounded-md border border-control-border bg-control px-3 py-2.5","font-mono text-[12px] leading-[1.6] text-foreground outline-none max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out","placeholder:text-muted-foreground","hover:border-control-border-hover","focus:border-primary focus:shadow-focus","disabled:cursor-not-allowed disabled:bg-surface-3 disabled:text-muted-foreground",e),...t})}function zs({className:e,...t}){return r.jsx("div",{"data-slot":"input-group",role:"group",className:Ne("group/input-group relative flex h-[30px] w-full min-w-0 items-center rounded-md border border-control-border bg-control max-[767px]:h-10","transition-[border-color,box-shadow] duration-150 ease-out","outline-none","has-[[data-slot=input-group-control]:focus-visible]:border-primary","has-[[data-slot=input-group-control]:focus-visible]:shadow-focus","has-[[data-slot=input-group-control]:hover:not(:focus-visible)]:border-control-border-hover","has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>[data-slot=input-group-control]]:pl-1.5","has-[>[data-align=inline-end]]:[&>[data-slot=input-group-control]]:pr-1.5","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-start]]:[&>[data-slot=input-group-control]]:pb-1.5","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col","has-[>[data-align=block-end]]:[&>[data-slot=input-group-control]]:pt-1.5",e),...t})}const Txe=jh(["flex h-auto cursor-text items-center justify-center gap-1.5 select-none","text-[12px] font-medium text-muted-foreground","group-data-[disabled=true]/input-group:opacity-50"],{variants:{align:{"inline-start":"order-first pl-[9px] has-[>button]:-ml-1","inline-end":"order-last pr-[9px] has-[>button]:-mr-1","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-1.5","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-1.5"}},defaultVariants:{align:"inline-start"}});function As({className:e,align:t="inline-start",...n}){return r.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Ne(Txe({align:t}),e),onClick:s=>{s.target.closest("button")||s.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}const Oxe=jh("flex items-center shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-xs px-1.5",sm:"h-8 gap-1.5 rounded-sm px-2.5","icon-xs":"size-6 rounded-xs p-0","icon-sm":"size-8 rounded-sm p-0"}},defaultVariants:{size:"xs"}});function Db({className:e,type:t="button",variant:n="ghost",size:s="xs",...i}){return r.jsx(B,{type:t,"data-size":s,variant:n,className:Ne(Oxe({size:s}),e),...i})}function Bs({className:e,...t}){return r.jsx(ze,{"data-slot":"input-group-control",className:Ne("flex-1 rounded-none border-0 bg-transparent shadow-none focus:border-0 focus:shadow-none",e),...t})}function Ah(e){return Kt(e.defaultTagName??"div",e,e)}const Rxe=jh("inline-flex w-fit shrink-0 items-center justify-center gap-[5px] overflow-hidden whitespace-nowrap border font-semibold",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-destructive-bd bg-destructive-soft text-destructive",outline:"border-control-border bg-control text-subtle",ghost:"border-transparent bg-transparent text-muted-foreground",link:"border-transparent bg-transparent text-primary underline-offset-4 hover:underline",success:"border-success-bd bg-success-soft text-success",warning:"border-warning-bd bg-warning-soft text-warning",info:"border-info-bd bg-info-soft text-info",brand:"border-primary-bd bg-primary-soft text-primary-fg",cn:"border-cn-bd bg-cn-soft text-cn",intl:"border-intl-bd bg-intl-soft text-intl",sensitive:"border-sensitive-bd bg-sensitive-soft text-sensitive"},shape:{pill:"min-h-[21px] rounded-pill px-[9px] py-px text-[11.5px]",tag:"min-h-[19px] rounded-xs px-2 py-0 text-[11px]"}},defaultVariants:{variant:"default",shape:"pill"}});function Ee({className:e,variant:t,shape:n,render:s,...i}){return Ah({render:s,defaultTagName:"span",props:oo({"data-slot":"badge"},i,{className:Ne(Rxe({variant:t,shape:n}),e)})})}function Yk({className:e,...t}){return r.jsx("span",{className:Ne("size-1.5 flex-none rounded-full bg-current",e),...t})}const HU=p.createContext(void 0);function VU(){const e=p.useContext(HU);if(e===void 0)throw new Error(Vn(13));return e}const mR={imageLoadingStatus:()=>null},Pxe=p.forwardRef(function(t,n){const{className:s,render:i,style:o,...l}=t,[u,d]=p.useState("idle"),f={imageLoadingStatus:u},m=p.useMemo(()=>({imageLoadingStatus:u,setImageLoadingStatus:d}),[u,d]),g=Kt("span",t,{state:f,ref:n,props:l,stateAttributesMapping:mR});return r.jsx(HU.Provider,{value:m,children:g})});function Ixe(e,{referrerPolicy:t,crossOrigin:n,sizes:s,srcSet:i},o){const l=p.useState("idle"),u=l[1];return Ge(()=>{if(!o)return Xn;if(!e&&!i)return u("error"),Xn;let d=!0;const f=new window.Image,m=g=>()=>{d&&u(g)};return u("loading"),f.onload=m("loaded"),f.onerror=m("error"),t&&(f.referrerPolicy=t),f.crossOrigin=n??null,s&&(f.sizes=s),i&&(f.srcset=i),e&&(f.src=e),f.complete&&u(f.naturalWidth>0?"loaded":"error"),()=>{d=!1}},[o,e,i,s,n,t,u]),l}const Mxe={...mR,...Fo},_xe=p.forwardRef(function(t,n){const{className:s,render:i,onLoadingStatusChange:o,keepMounted:l=!1,style:u,sizes:d,srcSet:f,src:m,...g}=t,{setImageLoadingStatus:v}=VU(),[b,y]=Ixe(m,t,!l),k=b==="loaded",{mounted:w,transitionStatus:S,setMounted:N}=gu(k),C=p.useRef(null),T=p.useRef(!0);Ge(()=>{if(!l)return;const L=T.current;T.current=!1;const $=C.current;if(!$)return;if(!$.complete){y("loading");return}const D=$.naturalWidth>0?"loaded":"error";y(D),D==="loaded"&&L&&N(!0)},[l,m,f,d,g.crossOrigin,g.referrerPolicy,i,y,N]);const P=l?{"data-loading":b==="loading"?"":void 0,"data-error":b==="error"?"":void 0,"aria-hidden":b!=="loaded"||void 0,onLoad(){y("loaded")},onError(){y("error")}}:void 0,O=qe(L=>{o?.(L),v(L)});Ge(()=>{b!=="idle"&&O(b)},[b,O]),Ge(()=>()=>v("idle"),[v]),ji({enabled:!k,open:k,ref:C,onComplete(){k||N(!1)}});const A={imageLoadingStatus:b,transitionStatus:l&&S==="ending"?void 0:S},R=l||w,M={};d!==void 0&&(M.sizes=d),f!==void 0&&(M.srcSet=f),m!==void 0&&(M.src=m);const _=Kt("img",t,{state:A,ref:[n,C],props:[P,g,M],stateAttributesMapping:Mxe,enabled:R});return R?_:null}),Dxe=p.forwardRef(function(t,n){const{className:s,render:i,delay:o=0,style:l,...u}=t,{imageLoadingStatus:d}=VU(),[f,m]=p.useState(o===0),g=fa();return p.useEffect(()=>(o>0?g.start(o,()=>m(!0)):m(!0),g.clear),[g,o]),Kt("span",t,{state:{imageLoadingStatus:d},ref:n,props:u,stateAttributesMapping:mR,enabled:d!=="loaded"&&(o===0||f)})});function KU({className:e,...t}){return r.jsx(Pxe,{"data-slot":"avatar",className:n=>Ne("relative inline-flex size-8 shrink-0 overflow-hidden rounded-full text-foreground",typeof e=="function"?e(n):e),...t})}function qU({className:e,...t}){return r.jsx(_xe,{"data-slot":"avatar-image",className:n=>Ne("absolute inset-0 block size-full object-cover data-loading:invisible data-error:invisible",typeof e=="function"?e(n):e),...t})}function GU({className:e,...t}){return r.jsx(Dxe,{"data-slot":"avatar-fallback",className:n=>Ne("absolute inset-0 flex items-center justify-center bg-control text-[12px] font-semibold text-subtle",typeof e=="function"?e(n):e),...t})}function Z(e,t){if(typeof window>"u")return e;const n=window.wbI18n;return n?n.t(e,t)??e:e}function Qt({className:e,...t}){return r.jsx("svg",{"data-slot":"spinner",role:"status","aria-label":Z("加载中"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:Ne("size-4 animate-spin [animation-duration:0.7s]",e),...t,children:r.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function Ae({className:e,...t}){return r.jsx("label",{"data-slot":"label",className:Ne("flex items-center gap-[6px] text-[11.5px] text-muted-foreground",e),...t})}const WU={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},vu={...WU,position:"fixed",top:0,left:0},pg={...WU,position:"absolute"},YU=p.createContext(void 0);function Lxe(){const e=p.useContext(YU);if(e===void 0)throw new Error(Vn(63));return e}const $xe="data-checked",zxe="data-unchecked",XU={...hc,checked(e){return e?{[$xe]:""}:{[zxe]:""}}},Bxe=p.forwardRef(function(t,n){const{checked:s,className:i,defaultChecked:o,"aria-labelledby":l,form:u,id:d,inputRef:f,name:m,nativeButton:g=!1,onCheckedChange:v,readOnly:b=!1,required:y=!1,disabled:k=!1,render:w,uncheckedValue:S,value:N,style:C,...T}=t,{clearErrors:P}=uu(),{state:O,setTouched:A,setDirty:R,validityData:M,setFilled:_,setFocused:L,validationMode:$,disabled:D,name:F,validation:V}=uo(),{labelId:q}=zi(),Q=D||k,X=F??m,U=p.useRef(null),z=lo(U,f,V.inputRef),K=p.useRef(null),J=Ws(),ee=_d({id:d}),H=g?void 0:ee,[G,Y]=Tl({controlled:s,default:!!o,name:"Switch",state:"checked"});hg(K,J,G,void 0,!Q,m),Ge(()=>{_(G)},[G,_]),Vo(G,()=>{P(X),R(G!==M.initialValue),V.change(G)});const{getButtonProps:se,buttonRef:re}=$i({disabled:Q,native:g}),ne=FO(l,q,U,!g,H),de={id:g?ee:J,role:"switch","aria-checked":G,"aria-readonly":b||void 0,"aria-required":y||void 0,"aria-labelledby":ne,onFocus(){Q||L(!0)},onBlur(){const te=U.current;!te||Q||(A(!0),L(!1),$==="onBlur"&&V.commit(te.checked))},onClick(te){if(b||Q)return;te.preventDefault();const le=U.current;le&&og(le,te)}},ie={...V.getValidationProps(Q),checked:G,disabled:Q,form:u,id:H,name:X,required:y,style:X?pg:vu,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:z,onChange(te){if(te.nativeEvent.defaultPrevented)return;if(b){te.preventDefault();return}const le=te.currentTarget.checked,he=Nt(rs,te.nativeEvent);v?.(le,he),!he.isCanceled&&Y(le)},onClick(te){te.stopPropagation()},onFocus(){K.current?.focus()},...N!==void 0?{value:N}:yr},oe=p.useMemo(()=>({...O,checked:G,disabled:Q,readOnly:b,required:y}),[O,G,Q,b,y]),je=Kt("span",t,{state:oe,ref:[n,K,re],props:[de,T,se,te=>V.getValidationProps(Q,te)],stateAttributesMapping:XU});return r.jsxs(YU.Provider,{value:oe,children:[je,!G&&X&&S!==void 0&&r.jsx("input",{type:"hidden",form:u,name:X,value:S,disabled:Q}),r.jsx("input",{...ie,suppressHydrationWarning:!0})]})}),Fxe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=Lxe();return Kt("span",t,{state:u,ref:n,stateAttributesMapping:XU,props:l})});function St({className:e,size:t="default",variant:n="default",...s}){const i=t==="sm";return r.jsx(Bxe,{"data-slot":"switch",className:Ne("relative inline-flex flex-none cursor-pointer items-center rounded-pill border-0 bg-border-strong p-0","transition-colors duration-[180ms] ease-out",n==="success"?"data-checked:bg-success":"data-checked:bg-primary","focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:opacity-50",i?"h-[14px] w-6":t==="touch"?"h-6 w-10":"h-[21px] w-9",e),...s,children:r.jsx(Fxe,{"data-slot":"switch-thumb",className:Ne("block rounded-full bg-primary-on shadow-1","transition-transform duration-[180ms] [transition-timing-function:cubic-bezier(.3,1.4,.6,1)]",i?"size-[10px] translate-x-0.5 data-checked:translate-x-[10px]":t==="touch"?"size-5 translate-x-0.5 data-checked:translate-x-[18px]":"size-[17px] translate-x-0.5 data-checked:translate-x-[17px]")})})}function Uxe(e){if(!e)return null;for(const t of e.elements){const n=t.tagName;if(n==="BUTTON"||n==="INPUT"){const s=t;if(s.type==="submit")return s}}return null}const Hxe="data-checked",Vxe="data-unchecked";function QU(e){return{checked(t){return e.indeterminate?{}:t?{[Hxe]:""}:{[Vxe]:""}},...hc}}const Kxe=p.createContext(void 0);function qxe(){return p.useContext(Kxe)}const ZU=p.createContext(void 0);function Gxe(){const e=p.useContext(ZU);if(e===void 0)throw new Error(Vn(14));return e}const Wxe="data-parent",Yxe=p.forwardRef(function(t,n){const{checked:s,className:i,defaultChecked:o=!1,"aria-labelledby":l,disabled:u=!1,form:d,id:f,indeterminate:m=!1,inputRef:g,name:v,onCheckedChange:b,parent:y=!1,readOnly:k=!1,render:w,required:S=!1,uncheckedValue:N,value:C,nativeButton:T=!1,style:P,...O}=t,{clearErrors:A}=uu(),{disabled:R,name:M,setDirty:_,setFilled:L,setFocused:$,setTouched:D,state:F,validationMode:V,validityData:q,validation:Q}=uo(),X=Hk(),{labelId:U,registerControlId:z,getDescriptionProps:K}=zi(),J=qxe(),ee=J?.allValues===void 0?void 0:J.parent,H=ee!==void 0,G=R||X.disabled||J?.disabled||u,Y=M??v,se=C??Y,re=Ws(),ne=J?.registerControlId!==z,de=_d({id:f||void 0,enabled:ne}),ie=T?de:re;let oe={};H&&(y?oe=ee.getParentProps():se!==void 0&&(oe=ee.getChildProps(se)));const{checked:je=s,indeterminate:te=m,onCheckedChange:le,...he}=oe,ce=J?.value,ye=p.useRef(null),{getButtonProps:fe,buttonRef:Le}=$i({disabled:G,native:T}),pe=J?.validation??Q,[xe,Se]=Tl({controlled:se!==void 0&&ce!==void 0&&!y?ce.includes(se):je,default:o,name:"Checkbox",state:"checked"}),ge=H?!!je:xe,ue=H&&te||m;hg(ye,re,xe,void 0,!J&&!G,v);const be=ee?.registerChildId,ve=p.useRef(null),De=pe.registerInput,Ie=J?se:void 0,We=p.useCallback(gt=>De(gt,{controlRef:ye,value:Ie}),[De,Ie]),nt=lo(g,ve,y?void 0:We),kt=FO(l,U,ve,!T,de);Ge(()=>{ve.current&&(ve.current.indeterminate=ue),J||L(xe)},[xe,ue,J,L]),Vo(xe,()=>{J||(A(Y),_(xe!==q.initialValue),pe.change(xe))});const Je=oo({checked:xe,disabled:G,form:d,name:y?void 0:Y,id:T?void 0:de,required:S,ref:nt,style:Y?pg:vu,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(gt){if(gt.nativeEvent.defaultPrevented)return;if(k){gt.preventDefault();return}const sn=gt.currentTarget.checked,Ke=Nt(rs,gt.nativeEvent);if(b?.(sn,Ke),!Ke.isCanceled&&(le?.(sn,Ke),!Ke.isCanceled&&(Se(sn),se!==void 0&&J!==void 0&&!y&&!H))){const zt=sn?[...J.value,se]:J.value.filter(ht=>ht!==se);J.setValue(zt,Ke)}},onClick(gt){gt.stopPropagation()},onFocus(){ye.current?.focus()}},C!==void 0?{value:(J?xe&&C:C)||""}:yr,K,gt=>pe.getValidationProps(G,gt));p.useEffect(()=>{if(!ee||se===void 0)return;const gt=ee.disabledStatesRef.current;return gt.set(se,G),()=>{gt.delete(se)}},[ee,G,se]);const on=p.useMemo(()=>({...F,checked:ge,disabled:G,readOnly:k,required:S,indeterminate:ue}),[F,ge,G,k,S,ue]),nn=QU(on),On=Kt("span",t,{state:on,ref:[Le,ye,n],props:[{id:ie,role:"checkbox","aria-checked":ue?"mixed":ge,"aria-readonly":k||void 0,"aria-required":S||void 0,"aria-labelledby":kt,[Wxe]:y?"":void 0,onFocus(){G||$(!0)},onBlur(){const gt=ve.current;gt&&(D(!0),$(!1),V==="onBlur"&&pe.commit(J?ce:gt.checked))},onKeyDown(gt){if(gt.key!=="Enter"||(gt.preventBaseUIHandler(),gt.defaultPrevented))return;const sn=ve.current?.form??null,Ke=gt.currentTarget,zt=gt.nativeEvent,ht=gt.preventDefault,Tt=zt.preventDefault;let Ht=!1;gt.preventDefault=()=>{Ht=!0,ht.call(gt)},zt.preventDefault=()=>{Ht=!0,Tt.call(zt)},Tt.call(zt),vr(Ke).queueMicrotask(()=>{gt.preventDefault=ht,zt.preventDefault=Tt,Ht||Uxe(sn)?.click()})},onClick(gt){if(k||G)return;gt.preventDefault();const sn=ve.current;sn&&og(sn,gt)}},O,he,fe,K,gt=>pe.getValidationProps(G,gt)],stateAttributesMapping:nn}),Rn=On.props.id;return Ge(()=>{if(!(!be||y||se===void 0||Rn===void 0))return be(se,Rn)},[be,y,se,Rn]),r.jsxs(ZU.Provider,{value:on,children:[On,!xe&&!J&&Y&&!y&&N!==void 0&&r.jsx("input",{type:"hidden",form:d,name:Y,value:N,disabled:G}),r.jsx("input",{...Je,suppressHydrationWarning:!0})]})}),Xxe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,keepMounted:l=!1,...u}=t,d=Gxe(),f=d.checked||d.indeterminate,{mounted:m,transitionStatus:g,setMounted:v}=gu(f),b=p.useRef(null),y={...d,transitionStatus:g};ji({batch:!0,enabled:!f,open:f,ref:b,onComplete(){f||v(!1)}});const w={...QU(d),...Fo},S=l||m,N=Kt("span",t,{ref:[n,b],state:y,stateAttributesMapping:w,props:u});return S?N:null});function jr({className:e,...t}){return r.jsx(Yxe,{"data-slot":"checkbox",className:Ne("group/checkbox relative inline-flex size-3.5 shrink-0 cursor-pointer items-center justify-center rounded-[3px] border border-control-border bg-control","outline-none transition-colors duration-150 ease-out","hover:border-control-border-hover","data-checked:border-primary data-checked:bg-primary","focus-visible:shadow-focus","data-disabled:cursor-not-allowed data-disabled:opacity-45",e),...t,children:r.jsx(Xxe,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-primary-foreground data-unchecked:hidden",children:r.jsxs("svg",{viewBox:"0 0 12 12",className:"size-2.5","aria-hidden":"true",children:[r.jsx("path",{d:"M2 6h8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none",className:"hidden group-aria-[checked=indeterminate]/checkbox:block"}),r.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",className:"group-aria-[checked=indeterminate]/checkbox:hidden"})]})})})}function pR(e){return Array.isArray(e)?e.map(t=>pR(t)).join(","):e==null?"":String(e)}const JU=new Map;function Qxe(e,t){const n=JSON.stringify({locale:pR(e),options:t}),s=JU.get(n);if(s)return s;const i=new Intl.NumberFormat(e,t);return JU.set(n,i),i}function Xk(e,t,n){return e==null?"":Qxe(t,n).format(e)}function bu(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function e6(e,t,n){return(e-t)*100/(n-t)}const t6=p.createContext(void 0);function n6(){const e=p.useContext(t6);if(e===void 0)throw new Error(Vn(51));return e}const Zxe="data-complete",Jxe="data-indeterminate",eve="data-progressing",gR={status(e){return e==="progressing"?{[eve]:""}:e==="complete"?{[Zxe]:""}:e==="indeterminate"?{[Jxe]:""}:null}},tve=p.forwardRef(function(t,n){const{format:s,getAriaValueText:i,locale:o,max:l=100,min:u=0,value:d,render:f,className:m,children:g,style:v,...b}=t,[y,k]=p.useState();let w="indeterminate",S=null,N=null,C="",T="indeterminate progress";if(d!=null&&Number.isFinite(d)){const M=e6(d,u,l);S=bu(Number.isNaN(M)?0:M,0,100),N=bu(d,u,l),w=N===l?"complete":"progressing",C=s?Xk(N,o,s):Xk(S/100,o,{style:"percent"}),T=C}const P=p.useMemo(()=>({status:w}),[w]),O={"aria-labelledby":y,"aria-valuemax":l,"aria-valuemin":u,"aria-valuenow":N??void 0,"aria-valuetext":i?i(C,d):T,role:"progressbar",children:r.jsxs(p.Fragment,{children:[g,r.jsx("span",{role:"presentation",style:vu,children:"x"})]})},A=p.useMemo(()=>({formattedValue:C,percentageValue:S,setLabelId:k,state:P,value:d}),[C,S,k,P,d]),R=Kt("div",t,{state:P,ref:n,props:[O,b],stateAttributesMapping:gR});return r.jsx(t6.Provider,{value:A,children:R})}),nve=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,{state:u}=n6();return Kt("div",t,{state:u,ref:n,props:l,stateAttributesMapping:gR})}),rve=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,{percentageValue:u,state:d}=n6(),f=u==null?{}:{insetInlineStart:0,height:"inherit",width:`${u}%`};return Kt("div",t,{state:d,ref:n,props:[{style:f},l],stateAttributesMapping:gR})});function gg({className:e,children:t,value:n,...s}){return r.jsxs(tve,{value:n,"data-slot":"progress",className:Ne("flex w-full flex-wrap items-center gap-3",e),...s,children:[t,r.jsx(sve,{children:r.jsx(ave,{})})]})}function sve({className:e,...t}){return r.jsx(nve,{"data-slot":"progress-track",className:Ne("relative flex h-1.5 w-full items-center overflow-x-hidden overflow-y-hidden rounded-pill bg-surface-3",e),...t})}function ave({className:e,...t}){return r.jsx(rve,{"data-slot":"progress-indicator",className:Ne("h-full rounded-[inherit] bg-primary transition-[width] duration-300 ease-out data-[indeterminate]:w-1/3 data-[indeterminate]:animate-pulse",e),...t})}const xR=[];let vR;function ive(){return vR}function ove(e){xR.push(e)}function Qk(e){const t=(n,s)=>{const i=$s(lve).current;let o;try{vR=i;for(const l of xR)l.before(i);o=e(n,s);for(const l of xR)l.after(i);i.didInitialize=!0}finally{vR=void 0}return o};return t.displayName=e.displayName||e.name,t}function bR(e){return p.forwardRef(Qk(e))}function lve(){return{didInitialize:!1}}const r6=p.createContext(void 0);function Lb(e){const t=p.useContext(r6);if(t===void 0&&!e)throw new Error(Vn(72));return t}function cve(e,t){return t!=null&&!Ld(t)?0:typeof e=="function"?e():e}function Eh(e,t,n){const s=cve(e,n);return typeof s=="number"?s:s?.[t]}function s6(e){return typeof e=="function"?e():e}function a6(e,t){return t||e==="click"||e==="mousedown"}function uve(e){return e?.includes("mouse")&&e!=="mousedown"}const i6=p.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new Bi,currentIdRef:{current:null},currentContextRef:{current:null}});function dve(e,t){e.current=t.current}function fve(e){const{children:t,delay:n,timeoutMs:s=0}=e,i=p.useRef(n),o=p.useRef(n),l=p.useRef(null),u=p.useRef(null),d=fa();return Ge(()=>{if(o.current=n,!l.current){i.current=n;return}i.current={open:Eh(i.current,"open"),close:Eh(n,"close")}},[n,l,i,o]),r.jsx(i6.Provider,{value:p.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:o,currentIdRef:l,timeoutMs:s,currentContextRef:u,timeout:d}),[s,d]),children:t})}function hve(e,t={open:!1}){const{open:n}=t,s="rootStore"in e?e.rootStore:e,i=s.useState("floatingId"),o=p.useContext(i6),{currentIdRef:l,delayRef:u,timeoutMs:d,initialDelayRef:f,currentContextRef:m,hasProvider:g,timeout:v}=o,[b,y]=p.useState(!1),k=p.useRef(n);return Ge(()=>{k.current=n},[n]),Ge(()=>{function w(){m.current?.setIsInstantPhase(!1),l.current=null,m.current=null,u.current=f.current,v.clear()}if(l.current&&!n&&l.current===i){if(y(!1),d){const S=i;return v.start(d,()=>{s.select("open")||l.current&&l.current!==S||w()}),()=>{(k.current||l.current!==S)&&v.clear()}}w()}},[n,i,l,u,d,f,m,v,s]),Ge(()=>{if(!n)return;const w=m.current,S=l.current;v.clear(),m.current={onOpenChange:s.setOpen,setIsInstantPhase:y},l.current=i,u.current={open:0,close:Eh(f.current,"close")},S!==null&&S!==i?(y(!0),w?.setIsInstantPhase(!0),w?.onOpenChange(!1,Nt(rs))):(y(!1),w?.setIsInstantPhase(!1))},[n,i,s,l,u,f,m,v]),Ge(()=>()=>{if(l.current===i){if(m.current=null,!k.current)return;l.current=null,dve(u,f),v.clear()}},[m,l,u,i,f,v]),p.useMemo(()=>({activeIdRef:l,hasProvider:g,delayRef:u,isInstantPhase:b}),[l,g,u,b])}function kn(e,t,n,s){return e.addEventListener(t,n,s),()=>{e.removeEventListener(t,n,s)}}function Ol(...e){return()=>{for(let t=0;t{t.current=t.next}};return t}const Th=p.forwardRef(function(t,n){const[s,i]=p.useState();Ge(()=>{Oge&&du&&i("button")},[]);const o={tabIndex:0,role:s};return r.jsx("span",{...t,ref:n,style:vu,"aria-hidden":s?void 0:!0,...o,"data-base-ui-focus-guard":""})});function $b(e){return`data-base-ui-${e}`}let Zk=0;function Jk(e,t={}){const{preventScroll:n=!1,sync:s=!1,shouldFocus:i}=t;cancelAnimationFrame(Zk);function o(){i&&!i()||e?.focus({preventScroll:n})}if(s)return o(),Xn;const l=requestAnimationFrame(o);return Zk=l,()=>{Zk===l&&(cancelAnimationFrame(l),Zk=0)}}const yR={inert:new WeakMap,"aria-hidden":new WeakMap},o6="data-base-ui-inert",jR={inert:new WeakSet,"aria-hidden":new WeakSet};let zb=new WeakMap,wR=0;function pve(e){return jR[e]}function l6(e){return e?ag(e)?e.host:l6(e.parentNode):null}const c6=(e,t)=>t.map(n=>{if(e.contains(n))return n;const s=l6(n);return e.contains(s)?s:null}).filter(n=>n!=null),u6=e=>{const t=new Set;return e.forEach(n=>{let s=n;for(;s&&!t.has(s);)t.add(s),s=s.parentNode}),t},d6=(e,t,n)=>{const s=[],i=o=>{!o||n.has(o)||Array.from(o.children).forEach(l=>{Ha(l)!=="script"&&(t.has(l)?i(l):s.push(l))})};return i(e),s};function gve(e,t,n,s,{mark:i=!0}){let o=null;s?o="inert":n&&(o="aria-hidden");let l=null,u=null;const d=c6(t,e),f=i?d6(t,u6(d),new Set(d)):[],m=[],g=[];if(o){const v=yR[o],b=pve(o);u=b,l=v;const y=c6(t,Array.from(t.querySelectorAll("[aria-live]"))),k=d.concat(y);d6(t,u6(k),new Set(k)).forEach(S=>{const N=S.getAttribute(o),C=N!==null&&N!=="false",T=(v.get(S)||0)+1;v.set(S,T),m.push(S),T===1&&C&&b.add(S),C||S.setAttribute(o,o==="inert"?"":"true")})}return i&&f.forEach(v=>{const b=(zb.get(v)||0)+1;zb.set(v,b),g.push(v),b===1&&v.setAttribute(o6,"")}),wR+=1,()=>{l&&m.forEach(v=>{const y=(l.get(v)||0)-1;l.set(v,y),y||(!u?.has(v)&&o&&v.removeAttribute(o),u?.delete(v))}),i&&g.forEach(v=>{const b=(zb.get(v)||0)-1;zb.set(v,b),b||v.removeAttribute(o6)}),wR-=1,wR||(yR.inert=new WeakMap,yR["aria-hidden"]=new WeakMap,jR.inert=new WeakSet,jR["aria-hidden"]=new WeakSet,zb=new WeakMap)}}function f6(e,t={}){const{ariaHidden:n=!1,inert:s=!1,mark:i=!0}=t,o=_n(e[0]).body;return gve(e,o,n,s,{mark:i})}const xve=500,vve={style:{transition:"none"}},kR="data-base-ui-click-trigger",bve="data-base-ui-swipe-ignore",yve="data-swipe-ignore",jve=`[${bve}]`,wve=`[${yve}]`,h6={fallbackAxisSide:"none"},m6={fallbackAxisSide:"end"},kve={clipPath:"inset(50%)",position:"fixed",top:0,left:0},p6=p.createContext(null),g6=()=>p.useContext(p6),Sve=$b("portal");function x6(e={}){const{ref:t,container:n,componentProps:s=yr,elementProps:i}=e,o=lg(),u=g6()?.portalNode,[d,f]=p.useState(null),[m,g]=p.useState(null),v=qe(w=>{w!==null&&g(w)}),b=p.useRef(null);Ge(()=>{if(n===null){b.current&&(b.current=null,g(null),f(null));return}const w=(n&&(kO(n)?n:n.current))??u??document.body;if(w==null){b.current&&(b.current=null,g(null),f(null));return}b.current!==w&&(b.current=w,g(null),f(w))},[n,u]);const y=Kt("div",s,{ref:[t,v],props:[{id:o,[Sve]:""},i]}),k=d&&y?xr.createPortal(y,d):null;return{node:m,nodeId:p.isValidElement(y)?y.props.id:void 0,subtree:k}}const eS=p.forwardRef(function(t,n){const{render:s,className:i,style:o,children:l,container:u,portalOwnerRole:d,...f}=t,{node:m,nodeId:g,subtree:v}=x6({container:u,ref:n,componentProps:t,elementProps:f}),b=p.useRef(null),y=p.useRef(null),k=p.useRef(null),w=p.useRef(null),[S,N]=p.useState(null),C=p.useRef(!1),T=S?.modal,P=S?.open,O=!!S&&!S.modal&&S.open&&!!m;p.useEffect(()=>{if(!m||T)return;function R(M){m&&M.relatedTarget&&dg(M)&&(M.type==="focusin"?C.current&&(DU(m),C.current=!1):(uxe(m),C.current=!0))}return Ol(kn(m,"focusin",R,!0),kn(m,"focusout",R,!0))},[m,T]),Ge(()=>{!m||P!==!0||!C.current||(DU(m),C.current=!1)},[P,m]);const A=p.useMemo(()=>({beforeOutsideRef:b,afterOutsideRef:y,beforeInsideRef:k,afterInsideRef:w,portalNode:m,setFocusManagerState:N}),[m]);return r.jsxs(p.Fragment,{children:[v,r.jsxs(p6.Provider,{value:A,children:[O&&m&&r.jsx(Th,{"data-type":"outside",ref:b,onFocus:R=>{if(dg(R,m))k.current?.focus();else{const M=S?S.domReference:null;MU(M)?.focus()}}}),O&&m&&r.jsx("span",{role:d,"aria-owns":g,style:kve}),m&&xr.createPortal(l,m),O&&m&&r.jsx(Th,{"data-type":"outside",ref:y,onFocus:R=>{if(dg(R,m))w.current?.focus();else{const M=S?S.domReference:null;iR(M)?.focus(),S?.closeOnFocusOut&&S?.onOpenChange(!1,Nt(Fd,R.nativeEvent))}}})]})]})});function v6(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(s=>s(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class Nve{constructor(){Cn(this,"nodesRef",{current:[]});Cn(this,"events",v6())}addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(s=>s===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const b6=p.createContext(null),y6=p.createContext(null),xg=()=>p.useContext(b6)?.id||null,Oh=e=>{const t=p.useContext(y6);return e??t};function Cve(e){const t=lg(),n=Oh(e),s=xg();return Ge(()=>{if(!t)return;const i={id:t,parentId:s};return n?.addNode(i),()=>{n?.removeNode(i)}},[n,t,s]),t}function Ave(e){const{children:t,id:n}=e,s=xg();return r.jsx(b6.Provider,{value:p.useMemo(()=>({id:n,parentId:s}),[n,s]),children:t})}function Eve(e){const{children:t,externalTree:n}=e,s=$s(()=>n??new Nve).current;return r.jsx(y6.Provider,{value:s,children:t})}function Tve(e,t){const n=vr(Er(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const j6=20;let Ud=[];function SR(){Ud=Ud.filter(e=>e.deref()?.isConnected)}function w6(e){SR(),e&&Ha(e)!=="body"&&(Ud.push(new WeakRef(e)),Ud.length>j6&&(Ud=Ud.slice(-j6)))}function k6(){return SR(),Ud[Ud.length-1]?.deref()}function Ove(e){return e?aR(e)?e:Pb(e)[0]||e:null}function S6(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!e.getAttribute("role")?.includes("dialog"))return;const n=PU(e).filter(i=>{const o=i.getAttribute("data-tabindex")||"";return aR(i)||i.hasAttribute("data-tabindex")&&!o.startsWith("-")}),s=e.getAttribute("tabindex");n.length===0?s!=="0"&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):(s!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function tS(e){const{context:t,children:n,disabled:s=!1,initialFocus:i=!0,returnFocus:o=!0,restoreFocus:l=!1,modal:u=!0,closeOnFocusOut:d=!0,openInteractionType:f="",nextFocusableElement:m,previousFocusableElement:g,beforeContentFocusGuardRef:v,externalTree:b,getInsideElements:y}=e,k="rootStore"in t?t.rootStore:t,w=k.useState("open"),S=k.useState("domReferenceElement"),N=k.useState("floatingElement"),{events:C,dataRef:T}=k.context,P=qe(()=>T.current.floatingContext?.nodeId),O=i===!1,A=XO(S)&&O,R=ss(i),M=ss(o),_=ss(f),L=ss(w),$=Oh(b),D=g6(),F=p.useRef(!1),V=p.useRef(!1),q=p.useRef(!1),Q=p.useRef(null),X=p.useRef(""),U=p.useRef(""),z=p.useRef(null),K=p.useRef(null),J=lo(z,v,D?.beforeInsideRef),ee=lo(K,D?.afterInsideRef),H=fa(),G=fa(),Y=fg(),se=D!=null,re=_k(N),ne=qe((oe=re)=>oe?Pb(oe):[]),de=qe(()=>y?.().filter(oe=>oe!=null)??[]);p.useEffect(()=>{if(s||!u)return;function oe(te){te.key==="Tab"&&Et(re,Ys(_n(re)))&&ne().length===0&&!A&&da(te)}const je=_n(re);return kn(je,"keydown",oe)},[s,re,u,A,ne]),p.useEffect(()=>{if(s||!w)return;const oe=_n(re);function je(){q.current=!1}function te(he){const ce=Er(he),ye=de(),fe=Et(N,ce)||Et(S,ce)||Et(D?.portalNode,ce)||ye.some(Le=>Le===ce||Et(Le,ce));q.current=!fe,U.current=he.pointerType||"keyboard",ce?.closest(`[${kR}]`)&&(V.current=!0,G.start(0,()=>{V.current=!1}))}function le(){U.current="keyboard"}return Ol(kn(oe,"pointerdown",te,!0),kn(oe,"pointerup",je,!0),kn(oe,"pointercancel",je,!0),kn(oe,"keydown",le,!0),je)},[s,N,S,re,w,D,G,de]),p.useEffect(()=>{if(s||!d)return;const oe=_n(re);function je(){V.current=!0,G.start(0,()=>{V.current=!1})}function te(ye){const fe=Er(ye);aR(fe)&&(Q.current=fe)}function le(ye){const fe=ye.relatedTarget,Le=ye.currentTarget,pe=Er(ye);u&&fe==null&&pe!=null&&Et(N,pe)&&w6(pe),queueMicrotask(()=>{const xe=P(),Se=k.context.triggerElements,ge=de(),ue=fe?.hasAttribute($b("focus-guard"))&&[z.current,K.current,D?.beforeInsideRef.current,D?.afterInsideRef.current,D?.beforeOutsideRef.current,D?.afterOutsideRef.current,pu(g),pu(m)].includes(fe),be=!(Et(S,fe)||Et(N,fe)||Et(fe,N)||Et(D?.portalNode,fe)||ge.some(ve=>ve===fe||Et(ve,fe))||Se.hasMatchingElement(ve=>Et(ve,fe))||ue||$&&(Dd($.nodesRef.current,xe).find(ve=>Et(ve.context?.elements.floating,fe)||Et(ve.context?.elements.domReference,fe))||jU($.nodesRef.current,xe).find(ve=>[ve.context?.elements.floating,_k(ve.context?.elements.floating)].includes(fe)||ve.context?.elements.domReference===fe)));if(Le===S&&re&&S6(re),l&&Le!==S&&!Fk(pe)&&Ys(oe)===oe.body){if(br(re)&&(re.focus(),l==="popup")){Y.request(()=>{re.focus()});return}const ve=ne(),De=Q.current,Ie=(De&&ve.includes(De)?De:null)||ve[ve.length-1]||re;br(Ie)&&Ie.focus()}if(T.current.insideReactTree){T.current.insideReactTree=!1;return}(A||!u)&&fe&&be&&!V.current&&(A||fe!==k6())&&(F.current=!0,k.setOpen(!1,Nt(Fd,ye)))})}function he(){q.current||(T.current.insideReactTree=!0,H.start(0,()=>{T.current.insideReactTree=!1}))}const ce=br(S)?S:null;if(!(!N&&!ce))return Ol(ce&&kn(ce,"focusout",le),ce&&kn(ce,"pointerdown",je),N&&kn(N,"focusin",te),N&&kn(N,"focusout",le),N&&D&&kn(N,"focusout",he,!0))},[s,S,N,re,u,$,D,k,d,l,ne,A,P,T,H,G,Y,m,g,de]),p.useEffect(()=>{if(s||!N||!w)return;const oe=Array.from(D?.portalNode?.querySelectorAll(`[${$b("portal")}]`)||[]),te=($?jU($.nodesRef.current,P()):[]).find(Le=>XO(Le.context?.elements.domReference||null))?.context?.elements.domReference,he=[...[N,...oe,z.current,K.current,D?.beforeOutsideRef.current,D?.afterOutsideRef.current,...de()],te,pu(g),pu(m),A?S:null].filter(Le=>Le!=null),ce=f6(he,{ariaHidden:u||A,mark:!1}),ye=[N,...oe].filter(Le=>Le!=null),fe=f6(ye);return()=>{fe(),ce()}},[w,s,S,N,u,D,A,$,P,m,g,de]),Ge(()=>{if(!w||s||!br(re))return;X.current="",U.current="";const oe=_n(re),je=Ys(oe);queueMicrotask(()=>{const te=R.current,le=typeof te=="function"?te(_.current||""):te;if(le===void 0||le===!1||Et(re,je))return;let ce=null;const ye=()=>(ce==null&&(ce=ne(re)),ce[0]||re);let fe;le===!0||le===null?fe=ye():fe=pu(le),fe=fe||ye();const Le=Et(re,Ys(oe));Jk(fe,{preventScroll:fe===re,shouldFocus(){if(!L.current)return!1;if(Le)return!0;const pe=Ys(oe);return!(pe!==fe&&Et(re,pe))}})})},[s,w,re,ne,R,_,L]),Ge(()=>{if(s||!re)return;const oe=_n(re),je=Ys(oe),te=_.current==null;w6(je);function le(ce){if(ce.open||(X.current=Tve(ce.nativeEvent,U.current)),ce.reason===Va&&ce.nativeEvent.type==="mouseleave"&&(F.current=!0),ce.reason===Wk)if(ce.nested)F.current=!1;else if(Dk(ce.nativeEvent)||QO(ce.nativeEvent))F.current=!1;else{let ye=!1;_n(re).createElement("div").focus({get preventScroll(){return ye=!0,!1}}),ye?F.current=!1:F.current=!0}}C.on("openchange",le);function he(ce){const ye=M.current;let fe=typeof ye=="function"?ye(ce):ye;if(fe===void 0||fe===!1)return null;fe===null&&(fe=!0);const Le=S?.isConnected?S:null,pe=je?.isConnected&&Ha(je)!=="body"?je:null;let xe=te?pe||Le:Le||pe;return xe||(xe=k6()||null),typeof fe=="boolean"?xe:pu(fe)||xe||null}return()=>{C.off("openchange",le);const ce=Ys(oe),ye=de(),fe=Et(N,ce)||ye.some(Se=>Se===ce||Et(Se,ce))||$&&Dd($.nodesRef.current,P(),!1).some(Se=>Et(Se.context?.elements.floating,ce)),Le=M.current,pe=X.current,xe=he(pe);queueMicrotask(()=>{const Se=Ove(xe),ge=typeof Le!="boolean";if(Le&&!F.current&&br(Se)&&(!(!ge&&Se!==ce&&ce!==oe.body)||fe)){const ue={preventScroll:!0};pe==="keyboard"&&(ue.focusVisible=!0),Se.focus(ue)}F.current=!1})}},[s,N,re,M,_,C,$,S,P,de]),Ge(()=>{if(!du||w||!N)return;const oe=Ys(_n(N));!br(oe)||!Ik(oe)||Et(N,oe)&&oe.blur()},[w,N]),Ge(()=>{if(!(s||!D))return D.setFocusManagerState({modal:u,closeOnFocusOut:d,open:w,onOpenChange:k.setOpen,domReference:S}),()=>{D.setFocusManagerState(null)}},[s,D,u,w,k,d,S]),Ge(()=>{if(!(s||!re))return S6(re),()=>{queueMicrotask(SR)}},[s,re]);const ie=!s&&(u?!A:!0)&&(se||u);return r.jsxs(p.Fragment,{children:[ie&&r.jsx(Th,{"data-type":"inside",ref:J,onFocus:oe=>{if(u){const je=ne();Jk(je[je.length-1])}else D?.portalNode&&(F.current=!1,dg(oe,D.portalNode)?iR(S)?.focus():pu(g??D.beforeOutsideRef)?.focus())}}),n,ie&&r.jsx(Th,{"data-type":"inside",ref:ee,onFocus:oe=>{u?Jk(ne()[0]):D?.portalNode&&(d&&(F.current=!0),dg(oe,D.portalNode)?MU(S)?.focus():pu(m??D.afterOutsideRef)?.focus())}})]})}function Bb(e,t={}){const{enabled:n=!0,event:s="click",toggle:i=!0,ignoreMouse:o=!1,stickIfOpen:l=!0,touchOpenDelay:u=0,reason:d=xu}=t,f="rootStore"in e?e.rootStore:e,m=f.context.dataRef,g=p.useRef(void 0),v=fg(),b=fa(),y=p.useMemo(()=>{function k(S,N,C,T){const P=Nt(d,N,C);S&&T==="touch"&&u>0?b.start(u,()=>{f.setOpen(!0,P)}):f.setOpen(S,P)}function w(S,N,C){const T=m.current.openEvent,P=f.select("domReferenceElement")!==N;return S&&P||!S||!i?!0:T&&l?!C(T.type):!1}return{onPointerDown(S){g.current=Ld(S.pointerType,!0)&&QO(S.nativeEvent)?"virtual":S.pointerType},onMouseDown(S){const N=g.current,C=S.nativeEvent,T=f.select("open");if(S.button!==0||s==="click"||Ld(N,!0)&&o)return;const P=w(T,S.currentTarget,R=>R==="click"||R==="mousedown"),O=Er(C);if(Ik(O)){k(P,C,O,N);return}const A=S.currentTarget;v.request(()=>{k(P,C,A,N)})},onClick(S){if(s==="mousedown-only")return;const N=g.current;if(s==="mousedown"&&N){g.current=void 0;return}if(Ld(N,!0)&&o)return;const C=f.select("open"),T=w(C,S.currentTarget,P=>P==="click"||P==="mousedown"||P==="keydown"||P==="keyup");k(T,S.nativeEvent,S.currentTarget,N)},onKeyDown(){g.current=void 0}}},[m,s,o,d,f,l,i,v,b,u]);return p.useMemo(()=>n?{reference:y}:yr,[n,y])}function Rve(e,t){let n=null,s=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){const o=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},l=t.axis==="x"||t.axis==="both",u=t.axis==="y"||t.axis==="both",d=["mouseenter","mousemove"].includes(t.dataRef.current.openEvent?.type||"")&&t.pointerType!=="touch";let f=o.width,m=o.height,g=o.x,v=o.y;return n==null&&t.x&&l&&(n=o.x-t.x),s==null&&t.y&&u&&(s=o.y-t.y),g-=n||0,v-=s||0,f=0,m=0,!i||d?(f=t.axis==="y"?o.width:0,m=t.axis==="x"?o.height:0,g=l&&t.x!=null?t.x:g,v=u&&t.y!=null?t.y:v):i&&!d&&(m=t.axis==="x"?o.height:m,f=t.axis==="y"?o.width:f),i=!0,{width:f,height:m,x:g,y:v,top:v,right:g+f,bottom:v+m,left:g}}}}function N6(e){return e!=null&&e.clientX!=null}function Pve(e,t={}){const{enabled:n=!0,axis:s="both"}=t,i="rootStore"in e?e.rootStore:e,o=i.useState("open"),l=i.useState("floatingElement"),u=i.useState("domReferenceElement"),d=i.context.dataRef,f=p.useRef(!1),m=p.useRef(null),[g,v]=p.useState(),[b,y]=p.useState([]),k=qe(T=>{i.set("positionReference",T)}),w=qe((T,P,O)=>{f.current||d.current.openEvent&&!N6(d.current.openEvent)||i.set("positionReference",Rve(O??u,{x:T,y:P,axis:s,dataRef:d,pointerType:g}))}),S=qe(T=>{o?m.current||(w(T.clientX,T.clientY,T.currentTarget),y([])):w(T.clientX,T.clientY,T.currentTarget)}),N=Ld(g)?l:o;p.useEffect(()=>{if(!n){k(u);return}if(!N)return;function T(){m.current?.(),m.current=null}const P=vr(l);function O(A){const R=Er(A);Et(l,R)?T():w(A.clientX,A.clientY)}return!d.current.openEvent||N6(d.current.openEvent)?m.current=kn(P,"mousemove",O):k(u),T},[N,n,l,d,u,i,w,k,b]),p.useEffect(()=>()=>{i.set("positionReference",null)},[i]),p.useEffect(()=>{n&&!l&&(f.current=!1)},[n,l]),p.useEffect(()=>{!n&&o&&(f.current=!0)},[n,o]);const C=p.useMemo(()=>{function T(P){v(P.pointerType)}return{onPointerDown:T,onPointerEnter:T,onMouseMove:S,onMouseEnter:S}},[S]);return p.useMemo(()=>n?{reference:C,trigger:C}:{},[n,C])}function Ive(){return!1}function Mve(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function Fb(e,t={}){const{enabled:n=!0,escapeKey:s=!0,outsidePress:i=!0,outsidePressEvent:o="sloppy",referencePress:l=Ive,bubbles:u,externalTree:d}=t,f="rootStore"in e?e.rootStore:e,m=f.useState("open"),g=f.useState("floatingElement"),{dataRef:v,events:b}=f.context,y=Oh(d),k=qe(typeof i=="function"?i:()=>!1),w=typeof i=="function"?k:i,S=w!==!1,N=qe(()=>o),{escapeKey:C,outsidePress:T}=Mve(u),P=p.useRef(!1),O=p.useRef(!1),A=p.useRef(!1),R=p.useRef(!1),M=p.useRef(!1),_=p.useRef(""),L=p.useRef(null),$=fa(),D=fa(),F=qe(()=>{D.clear(),v.current.insideReactTree=!1}),V=qe(H=>{const G=v.current.floatingContext?.nodeId;return(y?Dd(y.nodesRef.current,G):[]).some(se=>se.context?.open&&!se.context.dataRef.current[H])}),q=qe(H=>YO(H,f.select("floatingElement"))||YO(H,f.select("domReferenceElement"))),Q=qe(H=>{l()&&f.setOpen(!1,Nt(xu,H.nativeEvent))}),X=qe(H=>{if(!m||!n||!s||H.key!=="Escape"||M.current||!C&&V("__escapeKeyBubbles"))return;const G=Kge(H)?H.nativeEvent:H,Y=Nt(mg,G);f.setOpen(!1,Y),Y.isCanceled||H.preventDefault(),!C&&!Y.isPropagationAllowed&&H.stopPropagation()}),U=qe(()=>{v.current.insideReactTree=!0,D.start(0,F)}),z=qe(H=>{if(!m||!n||H.button!==0)return;const G=Er(H.nativeEvent);Et(f.select("floatingElement"),G)&&(P.current||(P.current=!0,O.current=!1))}),K=qe(H=>{!m||!n||(H.defaultPrevented||H.nativeEvent.defaultPrevented)&&P.current&&(O.current=!0)});p.useEffect(()=>{function H(G){G.open||(R.current=!1)}return b.on("openchange",H),()=>{b.off("openchange",H)}},[b]),p.useEffect(()=>{if(!m||!n)return m||(R.current=!1),F;v.current.__escapeKeyBubbles=C,v.current.__outsidePressBubbles=T;const H=new Bi,G=new Bi,Y=_n(g);function se(){H.clear(),M.current=!0}function re(){H.start(du?5:0,()=>{M.current=!1})}function ne(){A.current=!0,G.start(0,()=>{A.current=!1})}function de(){P.current=!1,O.current=!1}function ie(){const be=_.current,ve=be==="pen"||!be?"mouse":be,De=N(),Ie=typeof De=="function"?De():De;return typeof Ie=="string"?Ie:Ie[ve]}function oe(be){const ve=ie();return ve==="intentional"&&be.type!=="click"||ve==="sloppy"&&be.type==="click"}function je(be){const ve=v.current.floatingContext?.nodeId,De=y&&Dd(y.nodesRef.current,ve).some(Ie=>YO(be,Ie.context?.elements.floating));return q(be)||De}function te(be){if(oe(be)){be.type!=="click"&&!q(be)&&(G.clear(),A.current=!1),F();return}if(v.current.insideReactTree){F();return}const ve=Er(be),De=`[${$b("inert")}]`,Ie=Un(ve)?ve.getRootNode():null,We=Array.from((ag(Ie)?Ie:_n(f.select("floatingElement"))).querySelectorAll(De)),nt=f.context.triggerElements;if(ve&&(nt.hasElement(ve)||nt.hasMatchingElement(Je=>Et(Je,ve))))return;let kt=Un(ve)?ve:null;for(;kt&&!Rd(kt);){const Je=Pd(kt);if(Rd(Je)||!Un(Je))break;kt=Je}if(!(We.length&&Un(ve)&&!Hge(ve)&&!Et(ve,f.select("floatingElement"))&&We.every(Je=>!Et(kt,Je)))){if(br(ve)&&!("touches"in be)){const Je=Rd(ve),on=Li(ve),nn=/auto|scroll/,On=Je||nn.test(on.overflowX),Rn=Je||nn.test(on.overflowY),gt=On&&ve.clientWidth>0&&ve.scrollWidth>ve.clientWidth,sn=Rn&&ve.clientHeight>0&&ve.scrollHeight>ve.clientHeight,Ke=on.direction==="rtl",zt=sn&&(Ke?be.offsetX<=ve.offsetWidth-ve.clientWidth:be.offsetX>ve.clientWidth),ht=gt&&be.offsetY>ve.clientHeight;if(zt||ht)return}if(!je(be)){if(ie()==="intentional"){if(be.detail!==0&&!Dk(be)&&!R.current)return;if(A.current){G.clear(),A.current=!1;return}}typeof w=="function"&&!w(be)||V("__outsidePressBubbles")||(f.setOpen(!1,Nt(Wk,be)),F())}}}function le(be){ie()!=="sloppy"||be.pointerType==="touch"||!f.select("open")||!n||q(be)||te(be)}function he(be){if(ie()!=="sloppy"||!f.select("open")||!n||q(be))return;const ve=be.touches[0];ve&&(L.current={startTime:Date.now(),startX:ve.clientX,startY:ve.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},$.start(1e3,()=>{L.current&&(L.current.dismissOnTouchEnd=!1,L.current.dismissOnMouseDown=!1)}))}function ce(be,ve){const De=Er(be);if(!De)return;const Ie=kn(De,be.type,()=>{ve(be),Ie()})}function ye(be){_.current="touch",ce(be,he)}function fe(be){$.clear(),be.type==="pointerdown"&&(be.button===0&&(R.current=!0),_.current=be.pointerType),!(be.type==="mousedown"&&L.current&&!L.current.dismissOnMouseDown)&&ce(be,ve=>{ve.type==="pointerdown"?le(ve):te(ve)})}function Le(be){if(be.type==="pointercancel"&&(R.current=!1),!P.current)return;const ve=O.current;if(de(),ie()==="intentional"){if(be.type==="pointercancel"){ve&&ne();return}if(!je(be)){if(ve){ne();return}typeof w=="function"&&!w(be)||(G.clear(),A.current=!0,F())}}}function pe(be){if(ie()!=="sloppy"||!L.current||q(be))return;const ve=be.touches[0];if(!ve)return;const De=Math.abs(ve.clientX-L.current.startX),Ie=Math.abs(ve.clientY-L.current.startY),We=Math.sqrt(De*De+Ie*Ie);We>5&&(L.current.dismissOnTouchEnd=!0),We>10&&(te(be),$.clear(),L.current=null)}function xe(be){ce(be,pe)}function Se(be){ie()!=="sloppy"||!L.current||q(be)||(L.current.dismissOnTouchEnd&&te(be),$.clear(),L.current=null)}function ge(be){ce(be,Se)}const ue=Ol(s&&Ol(kn(Y,"keydown",X),kn(Y,"compositionstart",se),kn(Y,"compositionend",re)),S&&Ol(kn(Y,"click",fe,!0),kn(Y,"pointerdown",fe,!0),kn(Y,"pointerup",Le,!0),kn(Y,"pointercancel",Le,!0),kn(Y,"mousedown",fe,!0),kn(Y,"mouseup",Le,!0),kn(Y,"touchstart",ye,{capture:!0,passive:!0}),kn(Y,"touchmove",xe,{capture:!0,passive:!0}),kn(Y,"touchend",ge,{capture:!0,passive:!0})));return()=>{ue(),H.clear(),G.clear(),de(),A.current=!1,F()}},[v,g,s,S,w,m,n,C,T,X,F,N,V,q,y,f,$]);const J=p.useMemo(()=>({onKeyDown:X,onPointerDown:Q,onClick:Q}),[X,Q]),ee=p.useMemo(()=>({onKeyDown:X,onPointerDown:K,onMouseDown:K,onClickCapture:U,onMouseDownCapture(H){U(),z(H)},onPointerDownCapture(H){U(),z(H)},onMouseUpCapture:U,onTouchEndCapture:U,onTouchMoveCapture:U}),[X,U,z,K]);return p.useMemo(()=>n?{reference:J,floating:ee,trigger:J}:{},[n,J,ee])}function C6(e,t,n){let{reference:s,floating:i}=e;const o=Ho(t),l=eR(t),u=JO(l),d=Uo(t),f=o==="y",m=s.x+s.width/2-i.width/2,g=s.y+s.height/2-i.height/2,v=s[u]/2-i[u]/2;let b;switch(d){case"top":b={x:m,y:s.y-i.height};break;case"bottom":b={x:m,y:s.y+s.height};break;case"right":b={x:s.x+s.width,y:g};break;case"left":b={x:s.x-i.width,y:g};break;default:b={x:s.x,y:s.y}}const y=mu(t);return y&&(b[l]+=v*(y==="end"?1:-1)*(n&&f?-1:1)),b}async function _ve(e,t){var n;t===void 0&&(t={});const{x:s,y:i,platform:o,rects:l,elements:u,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:m="viewport",elementContext:g="floating",altBoundary:v=!1,padding:b=0}=$d(t,e),y=NU(b),w=u[v?g==="floating"?"reference":"floating":g],S=Rb(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(w)))==null||n?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(u.floating)),boundary:f,rootBoundary:m,strategy:d})),N=g==="floating"?{x:s,y:i,width:l.floating.width,height:l.floating.height}:l.reference,C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u.floating)),T=await(o.isElement==null?void 0:o.isElement(C))&&await(o.getScale==null?void 0:o.getScale(C))||{x:1,y:1},P=Rb(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:N,offsetParent:C,strategy:d}):N);return{top:(S.top-P.top+y.top)/T.y,bottom:(P.bottom-S.bottom+y.bottom)/T.y,left:(S.left-P.left+y.left)/T.x,right:(P.right-S.right+y.right)/T.x}}const Dve=50,Lve=async(e,t,n)=>{const{placement:s="bottom",strategy:i="absolute",middleware:o=[],platform:l}=n,u=l.detectOverflow?l:{...l,detectOverflow:_ve},d=await(l.isRTL==null?void 0:l.isRTL(t));let f=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:m,y:g}=C6(f,s,d),v=s,b=0;const y={};for(let k=0;kF<=0)){var L,$;const F=(((L=o.flip)==null?void 0:L.index)||0)+1,V=A[F];if(V&&(!(g==="alignment"?N!==Ho(V):!1)||_.every(X=>Ho(X.placement)===N?X.overflows[0]>0:!0)))return{data:{index:F,overflows:_},reset:{placement:V}};let q=($=_.filter(Q=>Q.overflows[0]<=0).sort((Q,X)=>Q.overflows[1]-X.overflows[1])[0])==null?void 0:$.placement;if(!q)switch(b){case"bestFit":{var D;const Q=(D=_.filter(X=>{if(O){const U=Ho(X.placement);return U===N||U==="y"}return!0}).map(X=>[X.placement,X.overflows.filter(U=>U>0).reduce((U,z)=>U+z,0)]).sort((X,U)=>X[1]-U[1])[0])==null?void 0:D[0];Q&&(q=Q);break}case"initialPlacement":q=u;break}if(i!==q)return{reset:{placement:q}}}return{}}}},A6=new Set(["left","top"]);async function zve(e,t){const{placement:n,platform:s,elements:i}=e,o=await(s.isRTL==null?void 0:s.isRTL(i.floating)),l=Uo(n),u=mu(n),d=Ho(n)==="y",f=A6.has(l)?-1:1,m=o&&d?-1:1,g=$d(t,e);let{mainAxis:v,crossAxis:b,alignmentAxis:y}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof y=="number"&&(b=u==="end"?y*-1:y),d?{x:b*m,y:v*f}:{x:v*f,y:b*m}}const Bve=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:i,y:o,placement:l,middlewareData:u}=t,d=await zve(t,e);return l===((n=u.offset)==null?void 0:n.placement)&&(s=u.arrow)!=null&&s.alignmentOffset?{}:{x:i+d.x,y:o+d.y,data:{...d,placement:l}}}}},Fve=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:i,platform:o}=t,{mainAxis:l=!0,crossAxis:u=!1,limiter:d={fn:N=>{let{x:C,y:T}=N;return{x:C,y:T}}},...f}=$d(e,t),m={x:n,y:s},g=await o.detectOverflow(t,f),v=Ho(i),b=ZO(v);let y=m[b],k=m[v];const w=(N,C)=>wU(C+g[N==="y"?"top":"left"],C,C-g[N==="y"?"bottom":"right"]);l&&(y=w(b,y)),u&&(k=w(v,k));const S=d.fn({...t,[b]:y,[v]:k});return{...S,data:{x:S.x-n,y:S.y-s,enabled:{[b]:l,[v]:u}}}}}},Uve=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,s;const{x:i,y:o,placement:l,rects:u,middlewareData:d}=t,{offset:f=0,mainAxis:m=!0,crossAxis:g=!0}=$d(e,t),v={x:i,y:o},b=Ho(l),y=ZO(b);let k=v[y],w=v[b];const S=$d(f,t),N=typeof S=="number"?{mainAxis:S,crossAxis:0}:{mainAxis:(n=S.mainAxis)!=null?n:0,crossAxis:(s=S.crossAxis)!=null?s:0};if(m){const P=y==="y"?"height":"width",O=u.reference[y]-u.floating[P]+N.mainAxis,A=u.reference[y]+u.reference[P]-N.mainAxis;kA&&(k=A)}if(g){var C,T;const P=y==="y"?"width":"height",O=A6.has(Uo(l)),A=u.reference[b]-u.floating[P]+(O&&((C=d.offset)==null?void 0:C[b])||0)+(O?0:N.crossAxis),R=u.reference[b]+u.reference[P]+(O?0:((T=d.offset)==null?void 0:T[b])||0)-(O?N.crossAxis:0);wR&&(w=R)}return{[y]:k,[b]:w}}}},Hve=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:s,platform:i,elements:o}=t,{apply:l=()=>{},...u}=$d(e,t),d=await i.detectOverflow(t,u),f=Uo(n),m=mu(n),g=Ho(n)==="y",{width:v,height:b}=s.floating;let y,k;f==="top"||f==="bottom"?(y=f,k=m===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(k=f,y=m==="end"?"top":"bottom");const w=b-d.top-d.bottom,S=v-d.left-d.right,N=ug(b-d[y],w),C=ug(v-d[k],S),T=t.middlewareData.shift,P=!T;let O=N,A=C;T!=null&&T.enabled.x&&(A=S),T!=null&&T.enabled.y&&(O=w),P&&!m&&(g?A=v-2*fu(d.left,d.right):O=b-2*fu(d.top,d.bottom)),await l({...t,availableWidth:A,availableHeight:O});const R=await i.getDimensions(o.floating);return v!==R.width||b!==R.height?{reset:{rects:!0}}:{}}}};function E6(e){const t=Li(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const i=br(e),o=i?e.offsetWidth:n,l=i?e.offsetHeight:s,u=Lk(n)!==o||Lk(s)!==l;return u&&(n=o,s=l),{width:n,height:s,$:u}}function NR(e){return Un(e)?e:e.contextElement}function vg(e){const t=NR(e);if(!br(t))return hu(1);const n=t.getBoundingClientRect(),{width:s,height:i,$:o}=E6(t);let l=(o?Lk(n.width):n.width)/s,u=(o?Lk(n.height):n.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!u||!Number.isFinite(u))&&(u=1),{x:l,y:u}}const Vve=hu(0);function T6(e){const t=vr(e);return!CO()||!t.visualViewport?Vve:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Kve(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===vr(e)}function Rh(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=NR(e);let l=hu(1);t&&(s?Un(s)&&(l=vg(s)):l=vg(e));const u=Kve(o,n,s)?T6(o):hu(0);let d=(i.left+u.x)/l.x,f=(i.top+u.y)/l.y,m=i.width/l.x,g=i.height/l.y;if(o&&s){const v=vr(o),b=Un(s)?vr(s):s;let y=v,k=AO(y);for(;k&&b!==y;){const w=vg(k),S=k.getBoundingClientRect(),N=Li(k),C=S.left+(k.clientLeft+parseFloat(N.paddingLeft))*w.x,T=S.top+(k.clientTop+parseFloat(N.paddingTop))*w.y;d*=w.x,f*=w.y,m*=w.x,g*=w.y,d+=C,f+=T,y=vr(k),k=AO(y)}}return Rb({width:m,height:g,x:d,y:f})}function nS(e,t){const n=jk(e).scrollLeft;return t?t.left+n:Rh(lu(e)).left+n}function O6(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-nS(e,n),i=n.top+t.scrollTop;return{x:s,y:i}}function qve(e){let{elements:t,rect:n,offsetParent:s,strategy:i}=e;const o=i==="fixed",l=lu(s),u=t?yk(t.floating):!1;if(s===l||u&&o)return n;let d={scrollLeft:0,scrollTop:0},f=hu(1);const m=hu(0),g=br(s);if((g||!o)&&((Ha(s)!=="body"||Cb(l))&&(d=jk(s)),g)){const b=Rh(s);f=vg(s),m.x=b.x+s.clientLeft,m.y=b.y+s.clientTop}const v=l&&!g&&!o?O6(l,d):hu(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+m.x+v.x,y:n.y*f.y-d.scrollTop*f.y+m.y+v.y}}function Gve(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Wve(e){const t=jk(e),n=e.ownerDocument.body,s=fu(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=fu(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+nS(e);const l=-t.scrollTop;return Li(n).direction==="rtl"&&(o+=fu(e.clientWidth,n.clientWidth)-s),{width:s,height:i,x:o,y:l}}const Yve=25;function Xve(e,t,n){n===void 0&&(n="viewport");const s=n==="layoutViewport",i=vr(e),o=lu(e),l=i.visualViewport;let u=o.clientWidth,d=o.clientHeight,f=0,m=0;if(l){const v=!CO()||t==="fixed";s?v||(f=-l.offsetLeft,m=-l.offsetTop):(u=l.width,d=l.height,v&&(f=l.offsetLeft,m=l.offsetTop))}if(nS(o)<=0){const v=o.ownerDocument,b=v.body,y=getComputedStyle(b),k=v.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,w=Math.abs(o.clientWidth-b.clientWidth-k),S=getComputedStyle(o).scrollbarGutter==="stable both-edges"?w/2:w;S<=Yve&&(u-=S)}return{width:u,height:d,x:f,y:m}}function Qve(e,t){const n=Rh(e,!0,t==="fixed"),s=n.top+e.clientTop,i=n.left+e.clientLeft,o=vg(e),l=e.clientWidth*o.x,u=e.clientHeight*o.y,d=i*o.x,f=s*o.y;return{width:l,height:u,x:d,y:f}}function R6(e,t,n){let s;if(t==="viewport"||t==="layoutViewport")s=Xve(e,n,t);else if(t==="document")s=Wve(lu(e));else if(Un(t))s=Qve(t,n);else{const i=T6(e);s={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Rb(s)}function Zve(e,t){const n=t.get(e);if(n)return n;let s=ig(e,[],!1).filter(u=>Un(u)&&Ha(u)!=="body"),i=null;const o=Li(e).position==="fixed";let l=o?Pd(e):e;for(;Un(l)&&!Rd(l);){const u=Li(l),d=NO(l),f=i?i.position:o?"fixed":"";!d&&(f==="fixed"||f==="absolute"&&u.position==="static")?s=s.filter(g=>g!==l):i=u,l=Pd(l)}return t.set(e,s),s}function Jve(e){let{element:t,boundary:n,rootBoundary:s,strategy:i}=e;const l=[...n==="clippingAncestors"?yk(t)?[]:Zve(t,this._c):[].concat(n),s],u=R6(t,l[0],i);let d=u.top,f=u.right,m=u.bottom,g=u.left;for(let v=1;v{u(!1,1e-7)},1e3)}A=!1}try{s=new IntersectionObserver(R,{...O,root:o.ownerDocument})}catch{s=new IntersectionObserver(R,O)}s.observe(e)}const d=vr(e),f=()=>u(n);return d.addEventListener("resize",f),u(!0),()=>{d.removeEventListener("resize",f),l()}}function D6(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,f=NR(e),m=i||o?[...f?ig(f):[],...t?ig(t):[]]:[];m.forEach(S=>{i&&S.addEventListener("scroll",n),o&&S.addEventListener("resize",n)});const g=f&&u?sbe(f,n,o):null;let v=-1,b=null;l&&(b=new ResizeObserver(S=>{let[N]=S;N&&N.target===f&&b&&t&&(b.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var C;(C=b)==null||C.observe(t)})),n()}),f&&!d&&b.observe(f),t&&b.observe(t));let y,k=d?Rh(e):null;d&&w();function w(){const S=Rh(e);k&&!_6(k,S)&&n(),k=S,y=requestAnimationFrame(w)}return n(),()=>{var S;m.forEach(N=>{i&&N.removeEventListener("scroll",n),o&&N.removeEventListener("resize",n)}),g?.(),(S=b)==null||S.disconnect(),b=null,d&&cancelAnimationFrame(y)}}const abe=Bve,ibe=Fve,obe=$ve,lbe=Hve,cbe=Uve,ube=(e,t,n)=>{const s=new Map,i=n??{},o={...M6,...i.platform,_c:s};return Lve(e,t,{...i,platform:o})};var dbe=typeof document<"u",fbe=function(){},rS=dbe?p.useLayoutEffect:fbe;function sS(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!sS(e[s],t[s]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,i[s]))return!1;for(s=n;s--!==0;){const o=i[s];if(!(o==="_owner"&&e.$$typeof)&&!sS(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function L6(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $6(e,t){const n=L6(e);return Math.round(t*n)/n}function AR(e){const t=p.useRef(e);return rS(()=>{t.current=e}),t}function hbe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:i,elements:{reference:o,floating:l}={},transform:u=!0,whileElementsMounted:d,open:f}=e,[m,g]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[v,b]=p.useState(s);sS(v,s)||b(s);const[y,k]=p.useState(null),[w,S]=p.useState(null),N=p.useCallback(X=>{X!==O.current&&(O.current=X,k(X))},[]),C=p.useCallback(X=>{X!==A.current&&(A.current=X,S(X))},[]),T=o||y,P=l||w,O=p.useRef(null),A=p.useRef(null),R=p.useRef(m),M=d!=null,_=AR(d),L=AR(i),$=AR(f),D=p.useCallback(()=>{if(!O.current||!A.current)return;const X={placement:t,strategy:n,middleware:v};L.current&&(X.platform=L.current),ube(O.current,A.current,X).then(U=>{const z={...U,isPositioned:$.current!==!1};F.current&&!sS(R.current,z)&&(R.current=z,xr.flushSync(()=>{g(z)}))})},[v,t,n,L,$]);rS(()=>{f===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,g(X=>({...X,isPositioned:!1})))},[f]);const F=p.useRef(!1);rS(()=>(F.current=!0,()=>{F.current=!1}),[]),rS(()=>{if(T&&(O.current=T),P&&(A.current=P),T&&P){if(_.current)return _.current(T,P,D);D()}},[T,P,D,_,M]);const V=p.useMemo(()=>({reference:O,floating:A,setReference:N,setFloating:C}),[N,C]),q=p.useMemo(()=>({reference:T,floating:P}),[T,P]),Q=p.useMemo(()=>{const X={position:n,left:0,top:0};if(!q.floating)return X;const U=$6(q.floating,m.x),z=$6(q.floating,m.y);return u?{...X,transform:"translate("+U+"px, "+z+"px)",...L6(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:z}},[n,u,q.floating,m.x,m.y]);return p.useMemo(()=>({...m,update:D,refs:V,elements:q,floatingStyles:Q}),[m,D,V,q,Q])}const mbe=(e,t)=>{const n=abe(e);return{name:n.name,fn:n.fn,options:[e,t]}},pbe=(e,t)=>{const n=ibe(e);return{name:n.name,fn:n.fn,options:[e,t]}},gbe=(e,t)=>({fn:cbe(e).fn,options:[e,t]}),xbe=(e,t)=>{const n=obe(e);return{name:n.name,fn:n.fn,options:[e,t]}},vbe=(e,t)=>{const n=lbe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var ER={exports:{}},TR={};var z6;function bbe(){if(z6)return TR;z6=1;var e=sg();function t(g,v){return g===v&&(g!==0||1/g===1/v)||g!==g&&v!==v}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,i=e.useEffect,o=e.useLayoutEffect,l=e.useDebugValue;function u(g,v){var b=v(),y=s({inst:{value:b,getSnapshot:v}}),k=y[0].inst,w=y[1];return o(function(){k.value=b,k.getSnapshot=v,d(k)&&w({inst:k})},[g,b,v]),i(function(){return d(k)&&w({inst:k}),g(function(){d(k)&&w({inst:k})})},[g]),l(b),b}function d(g){var v=g.getSnapshot;g=g.value;try{var b=v();return!n(g,b)}catch{return!0}}function f(g,v){return v()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return TR.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,TR}var B6;function F6(){return B6||(B6=1,ER.exports=bbe()),ER.exports}var OR=F6(),RR={exports:{}},PR={};var U6;function ybe(){if(U6)return PR;U6=1;var e=sg(),t=F6();function n(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var s=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,l=e.useEffect,u=e.useMemo,d=e.useDebugValue;return PR.useSyncExternalStoreWithSelector=function(f,m,g,v,b){var y=o(null);if(y.current===null){var k={hasValue:!1,value:null};y.current=k}else k=y.current;y=u(function(){function S(O){if(!N){if(N=!0,C=O,O=v(O),b!==void 0&&k.hasValue){var A=k.value;if(b(A,O))return T=A}return T=O}if(A=T,s(C,O))return A;var R=v(O);return b!==void 0&&b(A,R)?(C=O,A):(C=O,T=R)}var N=!1,C,T,P=g===void 0?null:g;return[function(){return S(m())},P===null?void 0:function(){return S(P())}]},[m,g,v,b]);var w=i(f,y[0],y[1]);return l(function(){k.hasValue=!0,k.value=w},[w]),d(w),w},PR}var H6;function jbe(){return H6||(H6=1,RR.exports=ybe()),RR.exports}var V6=jbe();const wbe=MO(19)?Sbe:Nbe;function K6(e,t,n,s,i){return wbe(e,t,n,s,i)}function kbe(e,t,n,s,i){const o=p.useCallback(()=>t(e.getSnapshot(),n,s,i),[e,t,n,s,i]);return OR.useSyncExternalStore(e.subscribe,o,o)}ove({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=new Set;for(const i of e.syncHooks)n.add(i.store);const s=[];for(const i of n)s.push(i.subscribe(t));return()=>{for(const i of s)i()}}),OR.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Sbe(e,t,n,s,i){const o=ive();if(!o)return kbe(e,t,n,s,i);const l=o.syncIndex;o.syncIndex+=1;let u;return o.didInitialize?(u=o.syncHooks[l],(u.store!==e||u.selector!==t||!Object.is(u.a1,n)||!Object.is(u.a2,s)||!Object.is(u.a3,i))&&(u.store!==e&&(o.didChangeStore=!0),u.store=e,u.selector=t,u.a1=n,u.a2=s,u.a3=i,u.value=t(e.getSnapshot(),n,s,i))):(u={store:e,selector:t,a1:n,a2:s,a3:i,value:t(e.getSnapshot(),n,s,i)},o.syncHooks.push(u)),u.value}function Nbe(e,t,n,s,i){return V6.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,o=>t(o,n,s,i))}class Cbe{constructor(t){Cn(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));Cn(this,"getSnapshot",()=>this.state);this.state=t,this.listeners=new Set,this.updateTick=0}static create(t){return new this(t)}setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const s of this.listeners){if(n!==this.updateTick)return;s(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){const t={...this.state};this.setState(t)}use(t,n,s,i){return K6(this,t,n,s,i)}}class Ph extends Cbe{constructor(t,n={},s){super(t),this.context=n,this.selectors=s}useSyncedValue(t,n){p.useDebugValue(t);const s=this;Ge(()=>{s.state[t]!==n&&s.set(t,n)},[s,t,n])}useSyncedValueWithCleanup(t,n){const s=this;Ge(()=>(s.state[t]!==n&&s.set(t,n),()=>{s.set(t,void 0)}),[s,t,n])}useSyncedValues(t){const n=this,s=Object.values(t);Ge(()=>{n.update(t)},[n,...s])}useControlledProp(t,n){p.useDebugValue(t);const s=this,i=n!==void 0;Ge(()=>{i&&!Object.is(s.state[t],n)&&s.setState({...s.state,[t]:n})},[s,t,n,i])}select(t,n,s,i){const o=this.selectors[t];return o(this.state,n,s,i)}useState(t,n,s,i){return p.useDebugValue(t),K6(this,this.selectors[t],n,s,i)}useContextCallback(t,n){p.useDebugValue(t);const s=qe(n??Xn);this.context[t]=s}useStateSetter(t){const n=p.useRef(void 0);return n.current===void 0&&(n.current=s=>{this.set(t,s)}),n.current}observe(t,n){let s;typeof t=="function"?s=t:s=this.selectors[t];let i=s(this.state);return n(i,i,this),this.subscribe(o=>{const l=s(o);if(!Object.is(i,l)){const u=i;i=l,n(l,u,this)}})}}const Abe={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};class IR extends Ph{constructor(n){const{syncOnly:s,nested:i,onOpenChange:o,triggerElements:l,...u}=n;super({...u,positionReference:u.referenceElement,domReferenceElement:u.referenceElement},{onOpenChange:o,dataRef:{current:{}},events:v6(),nested:i,triggerElements:l},Abe);Cn(this,"syncOpenEvent",(n,s)=>{(!n||!this.state.open||s!=null&&qge(s))&&(this.context.dataRef.current.openEvent=n?s:void 0)});Cn(this,"dispatchOpenChange",(n,s)=>{this.syncOpenEvent(n,s.event);const i={open:n,reason:s.reason,nativeEvent:s.event,nested:this.context.nested,triggerElement:s.trigger};this.context.events.emit("openchange",i)});Cn(this,"setOpen",(n,s)=>{if(this.syncOnly){this.context.onOpenChange?.(n,s);return}this.dispatchOpenChange(n,s),this.context.onOpenChange?.(n,s)});this.syncOnly=s}}function Ebe(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:s,floatingId:i,nested:o,onOpenChange:l}=e,u=t.useState("open"),d=t.useState("activeTriggerElement"),f=t.useState(n?"popupElement":"positionerElement"),m=t.context.triggerElements,g=l,v=p.useRef(null);s===void 0&&v.current===null&&(v.current=new IR({open:u,transitionStatus:void 0,referenceElement:d,floatingElement:f,triggerElements:m,onOpenChange:g,floatingId:i,syncOnly:!0,nested:o}));const b=s??v.current;return t.useSyncedValue("floatingId",i),Ge(()=>{const y={open:u,floatingId:i,referenceElement:d,floatingElement:f};Un(d)&&(y.domReferenceElement=d),b.state.positionReference===b.state.referenceElement&&(y.positionReference=d),b.update(y)},[u,i,d,f,b]),b.context.onOpenChange=g,b.context.nested=o,b}const Ub={tabIndex:-1,[HO]:""};function q6(e){return t=>t==="touch"?e.current:!0}function MR(e,t=!1){const n=lg(),s=xg()!=null,i=$s(()=>e(n,s)).current;return Ebe({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:s,onOpenChange:i.setOpen}),i}function _R({handle:e,store:t}){return Ge(()=>e.attachStore(t),[e,t]),null}function G6(e){const t=e.context.triggerElements.size;e.select("open")&&e.state.triggerCount!==t&&e.set("triggerCount",t)}function Tbe(e,t){const n=p.useRef(null);return qe(s=>{const i=n.current;if(i!==null){if(i.element===s&&i.store===t&&i.id===e)return;n.current=null;const o=i.store;o.context.triggerElements.getById(i.id)===i.element&&(o.context.triggerElements.delete(i.id),G6(o))}s!==null&&e!==void 0&&(n.current={store:t,id:e,element:s},t.context.triggerElements.add(e,s),G6(t))})}function DR(e,t,n,s=!1){let i=e.preventUnmountingOnClose;t?i=!1:s&&(i=!0);const o=n?.id??null;let l=e.activeTriggerId,u=e.activeTriggerElement;return(o||t)&&(l=o,u=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:l,activeTriggerElement:u}}function W6(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Obe(e,t,n,s={}){const i=n.reason,o=i===Va,l=t&&i===Gk,u=!t&&(i===xu||i===mg),d=W6(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;s.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);const f=()=>{const m=DR(e.state,t,n.trigger,d()),g={...s.extraState,...m};l?g.instantType="focus":u?g.instantType="dismiss":o&&(g.instantType=void 0),e.update(g)};o?xr.flushSync(f):f()}function LR(e,t,n,s){const i=n.useState("isMountedByTrigger",e),o=Tbe(e,n),l=qe(d=>{const f=n.select("open"),m=n.select("activeTriggerId");if(m===e){const g={activeTriggerElement:d,...f?s:null};n.update(g);return}if(m==null&&f){const g={activeTriggerId:e??null,activeTriggerElement:d,...s};n.update(g)}}),u=qe(d=>{o(d),d&&l(d)});return Ge(()=>(u(t.current),()=>u(null)),[u,t,n,e]),Ge(()=>{if(i){const d={activeTriggerElement:t.current,...s};n.update(d)}},[i,n,t,...Object.values(s)]),{registerTrigger:u,isMountedByThisTrigger:i}}function $R(e,t={}){const{closeOnActiveTriggerUnmount:n=!1}=t,s=p.useRef(null),i=e.useState("open"),o=e.useState("triggerCount"),l=e.useState("activeTriggerId"),u=e.useState("activeTriggerElement");Ge(()=>{if(!i){s.current=null,e.state.triggerCount!==0&&e.set("triggerCount",0);return}const d=e.context.triggerElements.size,f={};e.state.triggerCount!==d&&(f.triggerCount=d);const m=e.select("activeTriggerId");let g=null;if(m){const v=e.context.triggerElements.getById(m);if(v)s.current=m,v!==e.state.activeTriggerElement&&(f.activeTriggerElement=v);else{for(const[b,y]of e.context.triggerElements.entries())if(y===e.state.activeTriggerElement){f.activeTriggerId=b,f.activeTriggerElement=y,s.current=b;break}f.activeTriggerId===void 0&&(s.current===m?g=m:s.current=null)}}else s.current=null;if(!g&&!m&&d===1){const v=e.context.triggerElements.entries().next();if(!v.done){const[b,y]=v.value;f.activeTriggerId=b,f.activeTriggerElement=y,s.current=b}}(f.triggerCount!==void 0||f.activeTriggerId!==void 0||f.activeTriggerElement!==void 0)&&e.update(f),g&&n&&queueMicrotask(()=>{if(e.select("open")&&e.select("activeTriggerId")===g&&!e.context.triggerElements.getById(g)){const v=Nt(rs);e.setOpen(!1,v),v.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,o,l,u,n])}function zR(e,t,n,s){const{mounted:i,setMounted:o,transitionStatus:l}=gu(e,!1,!1,s),u=t.useState("preventUnmountingOnClose"),d=e?!1:u;t.useSyncedValues({mounted:i,transitionStatus:l,preventUnmountingOnClose:d});const f=qe(()=>{o(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return ji({enabled:i&&!e&&!d,open:e,ref:t.context.popupRef,onComplete(){e||f()}}),{forceUnmount:f,transitionStatus:l}}function BR(e,t){e.useSyncedValues(t),Ge(()=>()=>{e.update({activeTriggerProps:yr,inactiveTriggerProps:yr,popupProps:yr})},[e])}function Y6(e,t){Ge(()=>{!t&&e.state.openMethod!==null&&e.set("openMethod",null)},[t,e]),Ge(()=>()=>{e.state.openMethod!==null&&e.set("openMethod",null)},[e])}class aS{constructor(){this.idMap=new Map}add(t,n){this.idMap.set(t,n)}delete(t){this.idMap.delete(t)}hasElement(t){for(const n of this.idMap.values())if(n===t)return!0;return!1}hasMatchingElement(t){for(const n of this.idMap.values())if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}}function FR(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new IR({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:yr,inactiveTriggerProps:yr,popupProps:yr}}const Hb=e=>e.triggerIdProp??e.activeTriggerId,UR=e=>e.openProp??e.open,X6=e=>(e.popupElement?.id??e.floatingId)||void 0;function Q6(e,t){return t!==void 0&&UR(e)&&Hb(e)===t}function Rbe(e,t){return Q6(e,t)?!0:t!==void 0&&UR(e)&&Hb(e)==null&&e.triggerCount===1}const HR={open:UR,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Hb,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:X6,isTriggerActive:(e,t)=>t!==void 0&&Hb(e)===t,isOpenedByTrigger:(e,t)=>Q6(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Hb(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Rbe(e,t)?X6(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function VR(e){const t=p.useCallback(s=>e===void 0?Xn:e.subscribeStore(s),[e]),n=p.useCallback(()=>e===void 0?void 0:e.store,[e]);return OR.useSyncExternalStore(t,n,()=>e?.serverStore)}function Z6(e){const{open:t=!1,onOpenChange:n,elements:s={}}=e,i=lg(),o=xg()!=null,l=$s(()=>new IR({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:s.reference??null,floatingElement:s.floating??null,triggerElements:new aS,floatingId:i,syncOnly:!1,nested:o})).current;return Ge(()=>{const u={open:t,floatingId:i};s.reference!==void 0&&(u.referenceElement=s.reference,u.domReferenceElement=Un(s.reference)?s.reference:null),s.floating!==void 0&&(u.floatingElement=s.floating),l.update(u)},[t,i,s.reference,s.floating,l]),l.context.onOpenChange=n,l.context.nested=o,l}function Pbe(e){return Ibe(e,e.rootContext)}function Ibe(e,t){const{nodeId:n,externalTree:s}=e,i=t.useState("referenceElement"),o=t.useState("floatingElement"),l=t.useState("domReferenceElement"),u=t.useState("open"),d=t.useState("floatingId"),[f,m]=p.useState(null),[g,v]=p.useState(void 0),[b,y]=p.useState(void 0),k=p.useRef(null),w=Oh(s),S=p.useMemo(()=>({reference:i,floating:o,domReference:l}),[i,o,l]),N=hbe({...e,elements:{...S,...f&&{reference:f}}}),C=Un(g)?g:null,T=b===void 0?t.state.floatingElement:b;t.useSyncedValue("referenceElement",g??null),t.useSyncedValue("domReferenceElement",g===void 0?l:C),t.useSyncedValue("floatingElement",T);const P=p.useCallback(L=>{const $=Un(L)?{getBoundingClientRect:()=>L.getBoundingClientRect(),getClientRects:()=>L.getClientRects(),contextElement:L}:L;m($),N.refs.setReference($)},[N.refs]),O=p.useCallback(L=>{(Un(L)||L===null)&&(k.current=L,v(L)),(Un(N.refs.reference.current)||N.refs.reference.current===null||L!==null&&!Un(L))&&N.refs.setReference(L)},[N.refs,v]),A=p.useCallback(L=>{y(L),N.refs.setFloating(L)},[N.refs]),R=p.useMemo(()=>({...N.refs,setReference:O,setFloating:A,setPositionReference:P,domReference:k}),[N.refs,O,A,P]),M=p.useMemo(()=>({...N.elements,domReference:l}),[N.elements,l]),_=p.useMemo(()=>({...N,dataRef:t.context.dataRef,open:u,onOpenChange:t.setOpen,events:t.context.events,floatingId:d,refs:R,elements:M,nodeId:n,rootStore:t}),[N,R,M,n,t,u,d]);return Ge(()=>{l&&(k.current=l)},[l]),Ge(()=>{t.context.dataRef.current.floatingContext=_;const L=w?.nodesRef.current.find($=>$.id===n);L&&(L.context=_)}),p.useMemo(()=>({...N,context:_,refs:R,elements:M,rootStore:t}),[N,R,M,_,t])}const KR=xU&&du;function Mbe(e,t={}){const{enabled:n=!0,delay:s}=t,i="rootStore"in e?e.rootStore:e,{events:o,dataRef:l}=i.context,u=p.useRef(!1),d=p.useRef(null),f=p.useRef(!0),m=fa();p.useEffect(()=>{const v=i.select("domReferenceElement");if(!n)return;const b=vr(v);function y(){const S=i.select("domReferenceElement");!i.select("open")&&br(S)&&S===Ys(_n(S))&&(u.current=!0,d.current=S)}function k(){f.current=!0}function w(){f.current=!1}return Ol(kn(b,"blur",y),KR&&kn(b,"keydown",k,!0),KR&&kn(b,"pointerdown",w,!0))},[i,n]),p.useEffect(()=>{if(!n)return;function v(b){if(b.reason===xu||b.reason===mg){const y=i.select("domReferenceElement");Un(y)&&(d.current=y,u.current=!0)}}return o.on("openchange",v),()=>{o.off("openchange",v)}},[o,n,i]);const g=p.useMemo(()=>{function v(){u.current=!1,d.current=null}return{onMouseLeave(){v()},onFocus(b){const y=b.currentTarget;if(u.current){if(d.current===y)return;v()}const k=Er(b.nativeEvent);if(Un(k)){if(KR&&!b.relatedTarget){if(!f.current&&!Ik(k))return}else if(!Mk(k))return}const w=Pk(b.relatedTarget,i.context.triggerElements),{nativeEvent:S,currentTarget:N}=b,C=typeof s=="function"?s():s;if(i.select("open")&&w||C===0||C===void 0){i.setOpen(!0,Nt(Gk,S,N));return}m.start(C,()=>{u.current||i.setOpen(!0,Nt(Gk,S,N))})},onBlur(b){v();const y=b.relatedTarget,k=b.nativeEvent,w=Un(y)&&y.hasAttribute($b("focus-guard"))&&y.getAttribute("data-type")==="outside";m.start(0,()=>{const S=i.select("domReferenceElement"),N=Ys(_n(S));!y&&N===S||Et(l.current.floatingContext?.refs.floating.current,N)||Et(S,N)||w||Pk(y??N,i.context.triggerElements)||i.setOpen(!1,Nt(Gk,k))})}}},[l,s,i,m]);return p.useMemo(()=>n?{reference:g,trigger:g}:{},[n,g])}class qR{constructor(){Cn(this,"dispose",()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()});Cn(this,"disposeEffect",()=>this.dispose);this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new Bi,this.restTimeout=new Bi,this.handleCloseOptions=void 0}static create(){return new qR}}const iS=new WeakMap;function oS(e){if(!e.performedPointerEventsMutation)return;const t=e.pointerEventsScopeElement;t&&iS.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),iS.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function J6(e,t){const{scopeElement:n,referenceElement:s,floatingElement:i}=t,o=iS.get(n);o&&o!==e&&oS(o),oS(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=s,e.pointerEventsFloatingElement=i,iS.set(n,e),n.style.pointerEvents="none",s.style.pointerEvents="auto",i.style.pointerEvents="auto"}function GR(e){const t=e.context.dataRef.current,n=$s(()=>t.hoverInteractionState??qR.create()).current;return t.hoverInteractionState||(t.hoverInteractionState=n),Uk(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function eH(e,t={}){const{enabled:n=!0,closeDelay:s=0,nodeId:i}=t,o="rootStore"in e?e.rootStore:e,l=o.useState("open"),u=o.useState("floatingElement"),d=o.useState("domReferenceElement"),{dataRef:f}=o.context,m=Oh(),g=xg(),v=GR(o),b=fa(),y=qe(()=>a6(f.current.openEvent?.type,v.interactedInside)),k=qe(()=>uve(f.current.openEvent?.type)),w=qe(()=>{oS(v)});Ge(()=>{l||(v.pointerType=void 0,v.restTimeoutPending=!1,v.interactedInside=!1,w())},[l,v,w]),p.useEffect(()=>w,[w]),Ge(()=>{if(n&&l&&v.handleCloseOptions?.blockPointerEvents&&k()&&Un(d)&&u){const S=d,N=u,C=_n(u),T=m?.nodesRef.current.find(R=>R.id===g)?.context?.elements.floating;T&&(T.style.pointerEvents="");const P=v.pointerEventsScopeElement!==N?v.pointerEventsScopeElement:null,O=T!==N?T:null,A=v.handleCloseOptions?.getScope?.()??P??O??S.closest("[data-rootownerid]")??C.body;return J6(v,{scopeElement:A,referenceElement:S,floatingElement:N}),()=>{w()}}},[n,l,d,u,v,k,m,g,w]),p.useEffect(()=>{if(!n)return;function S(){return!!(m&&g&&Dd(m.nodesRef.current,g).length>0)}function N(R){const M=Eh(s,"close",v.pointerType),_=()=>{o.setOpen(!1,Nt(Va,R)),m?.events.emit("floating.closed",R)};M?v.openChangeTimeout.start(M,_):(v.openChangeTimeout.clear(),_())}function C(R){const M=Er(R);if(!Vge(M)){v.interactedInside=!1;return}v.interactedInside=M?.closest("[aria-haspopup]")!=null}function T(){v.openChangeTimeout.clear(),b.clear(),m?.events.off("floating.closed",O),w()}function P(R){if(S()&&m){m.events.on("floating.closed",O);return}if(Pk(R.relatedTarget,o.context.triggerElements))return;const M=f.current.floatingContext?.nodeId??i,_=R.relatedTarget;if(!(m&&M&&Un(_)&&Dd(m.nodesRef.current,M,!1).some($=>Et($.context?.elements.floating,_)))){if(v.handler){v.handler(R);return}w(),k()&&!y()&&N(R)}}function O(R){!m||!g||S()||b.start(0,()=>{m.events.off("floating.closed",O),o.setOpen(!1,Nt(Va,R)),m.events.emit("floating.closed",R)})}const A=u;return Ol(A&&kn(A,"mouseenter",T),A&&kn(A,"mouseleave",P),A&&kn(A,"pointerdown",C,!0),()=>{m?.events.off("floating.closed",O)})},[n,u,o,f,s,i,k,y,w,v,m,g,b])}const _be={current:null};function tH(e,t={}){const{enabled:n=!0,delay:s=0,handleClose:i=null,mouseOnly:o=!1,restMs:l=0,move:u=!0,triggerElementRef:d=_be,externalTree:f,isActiveTrigger:m=!0,getHandleCloseContext:g,isClosing:v,shouldOpen:b,guardStaleOpen:y=!1}=t,k="rootStore"in e?e.rootStore:e,{dataRef:w,events:S}=k.context,N=Oh(f),C=GR(k),T=p.useRef(!1),P=ss(i),O=ss(s),A=ss(l),R=ss(n),M=ss(b),_=ss(v),L=qe(()=>a6(w.current.openEvent?.type,C.interactedInside)),$=qe(()=>M.current?.()!==!1),D=qe((q,Q,X)=>{const U=k.context.triggerElements;if(U.hasElement(Q))return!q||!Et(q,Q);if(!Un(X))return!1;const z=X;return U.hasMatchingElement(K=>Et(K,z))&&(!q||!Et(q,z))}),F=qe(()=>{if(!C.handler)return;_n(k.select("domReferenceElement")).removeEventListener("mousemove",C.handler),C.handler=void 0}),V=qe(()=>{oS(C)});return m&&(C.handleCloseOptions=i?.__options),p.useEffect(()=>F,[F]),p.useEffect(()=>{if(!n)return;function q(Q){Q.open?T.current=!1:(T.current=Q.reason===Va,F(),C.openChangeTimeout.clear(),C.restTimeout.clear(),C.blockMouseMove=!0,C.restTimeoutPending=!1)}return S.on("openchange",q),()=>{S.off("openchange",q)}},[n,S,C,F]),p.useEffect(()=>{if(!n)return;function q(J,ee=!0){const H=Eh(O.current,"close",C.pointerType);H?C.openChangeTimeout.start(H,()=>{k.setOpen(!1,Nt(Va,J)),N?.events.emit("floating.closed",J)}):ee&&(C.openChangeTimeout.clear(),k.setOpen(!1,Nt(Va,J)),N?.events.emit("floating.closed",J))}const Q=d.current??(m?k.select("domReferenceElement"):null);if(!Un(Q))return;function X(J){if(C.openChangeTimeout.clear(),C.blockMouseMove=!1,o&&!Ld(C.pointerType))return;const ee=s6(A.current),H=Eh(O.current,"open",C.pointerType),G=Er(J),Y=J.currentTarget??null,se=k.select("domReferenceElement");let re=Y;if(Un(G)&&!k.context.triggerElements.hasElement(G)){for(const ce of k.context.triggerElements.elements())if(Et(ce,G)){re=ce;break}}Un(Y)&&Un(se)&&!k.context.triggerElements.hasElement(Y)&&Et(Y,se)&&(re=se);const ne=re==null?!1:D(se,re,G),de=k.select("open"),ie=_.current?.()??k.select("transitionStatus")==="ending",oe=!de&&ie&&T.current,je=!ne&&Un(re)&&Un(se)&&Et(se,re)&&oe,te=ee>0&&!H,le=ne&&(de||oe)||je,he=!de||ne;if(le){$()&&k.setOpen(!0,Nt(Va,J,re));return}te||(H?C.openChangeTimeout.start(H,()=>{he&&$()&&k.setOpen(!0,Nt(Va,J,re))}):he&&$()&&k.setOpen(!0,Nt(Va,J,re)))}function U(J){if(L()){V();return}F();const ee=k.select("domReferenceElement"),H=_n(ee);C.restTimeout.clear(),C.restTimeoutPending=!1;const G=w.current.floatingContext??g?.();if(Pk(J.relatedTarget,k.context.triggerElements))return;if(P.current&&G){k.select("open")||C.openChangeTimeout.clear();const se=d.current;C.handler=P.current({...G,tree:N,x:J.clientX,y:J.clientY,onClose(){V(),F(),R.current&&!L()&&se===k.select("domReferenceElement")&&q(J,!0)}}),H.addEventListener("mousemove",C.handler),C.handler(J);return}(C.pointerType!=="touch"||!Et(k.select("floatingElement"),J.relatedTarget))&&q(J)}function z(J){Et(Q,J.relatedTarget)||(C.openChangeTimeout.clear(),C.restTimeout.clear(),C.restTimeoutPending=!1)}const K=y?kn(Q,"mouseout",z):void 0;return u?Ol(kn(Q,"mousemove",X,{once:!0}),kn(Q,"mouseenter",X),kn(Q,"mouseleave",U),K):Ol(kn(Q,"mouseenter",X),kn(Q,"mouseleave",U),K)},[F,V,w,O,k,n,P,C,m,D,L,o,u,A,d,N,R,g,_,$,y]),p.useMemo(()=>{if(!n)return;function q(Q){C.pointerType=Q.pointerType}return{onPointerDown:q,onPointerEnter:q,onMouseMove(Q){const{nativeEvent:X}=Q,U=Q.currentTarget,z=k.select("domReferenceElement"),K=k.select("open"),J=D(z,U,Q.target);if(o&&!Ld(C.pointerType))return;if(K&&J&&C.handleCloseOptions?.blockPointerEvents){const G=k.select("floatingElement");if(G){const Y=C.handleCloseOptions?.getScope?.()??U.ownerDocument.body;J6(C,{scopeElement:Y,referenceElement:U,floatingElement:G})}}const ee=s6(A.current);if(K&&!J||ee===0||!J&&C.restTimeoutPending&&Q.movementX**2+Q.movementY**2<2)return;C.restTimeout.clear();function H(){if(C.restTimeoutPending=!1,L())return;const G=k.select("open");!C.blockMouseMove&&(!G||J)&&$()&&k.setOpen(!0,Nt(Va,X,U))}C.pointerType==="touch"?xr.flushSync(()=>{H()}):J&&K?H():(C.restTimeoutPending=!0,C.restTimeout.start(ee,H))}}},[n,C,L,D,o,k,A,$])}const Dbe="Escape";function nH(e){return du&&e.movementX===0&&e.movementY===0}function lS(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function cS(e,t){return lS(t,e===VO||e===Ok,e===Sh||e===Nh)}function WR(e,t,n){return lS(t,e===Ok,n?e===Sh:e===Nh)||e==="Enter"||e===" "||e===""}function Lbe(e,t,n){return lS(t,n?e===Sh:e===Nh,e===Ok)}function $be(e,t,n,s){const i=n?e===Nh:e===Sh,o=e===VO;return t==="both"||t==="horizontal"&&s?e===Dbe:lS(t,i,o)}function rH(e,t){const{listRef:n,activeIndex:s,onNavigate:i=()=>{},enabled:o=!0,selectedIndex:l=null,allowEscape:u=!1,loopFocus:d=!1,nested:f=!1,rtl:m=!1,virtual:g=!1,focusItemOnOpen:v="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:y=!0,disabledIndices:k=void 0,orientation:w="vertical",parentOrientation:S,id:N,resetOnPointerLeave:C=!0,externalTree:T,grid:P}=t,O=P!=null,A="rootStore"in e?e.rootStore:e,R=A.useState("open"),M=A.useState("floatingElement"),_=A.useState("domReferenceElement"),L=A.context.dataRef,$=_k(M),D=XO(_),F=ss($),V=xg(),q=Oh(T),Q=p.useRef(v),X=p.useRef(l??-1),U=p.useRef(null),z=p.useRef(!0),K=qe(ge=>{i(X.current===-1?null:X.current,ge)}),J=p.useRef(!!M),ee=p.useRef(R),H=p.useRef(!1),G=p.useRef(!1),Y=p.useRef(null),se=ss(k),re=ss(R),ne=ss(l),de=ss(C),ie=fg(),oe=fg(),je=qe(()=>{function ge(De){g?q?.events.emit("virtualfocus",De):Y.current=Jk(De,{sync:H.current,preventScroll:!0})}const ue=n.current[X.current],be=G.current;ue&&ge(ue),(H.current?De=>De():De=>ie.request(De))(()=>{const De=n.current[X.current]||ue;if(!De)return;ue||ge(De),fe&&(be||!z.current)&&De.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Ge(()=>{L.current.orientation=w},[L,w]),Ge(()=>{o&&(R&&M?(X.current=l??-1,Q.current&&l!=null&&(G.current=!0,K())):J.current&&(X.current=-1,K()))},[o,R,M,l,K]),Ge(()=>{if(o){if(!R){H.current=!1;return}if(M)if(s==null){if(H.current=!1,ne.current!=null)return;if(J.current&&(X.current=-1,je()),(!ee.current||!J.current)&&Q.current&&(U.current!=null||Q.current===!0&&U.current==null)){let ge=0;const ue=()=>{n.current[0]==null?(ge<2&&(ge?ve=>oe.request(ve):queueMicrotask)(ue),ge+=1):(X.current=U.current==null||WR(U.current,w,m)||f?Bk(n):nR(n),U.current=null,K())};ue()}}else zd(n.current,s)||(X.current=s,je(),G.current=!1)}},[o,R,M,s,ne,f,n,w,m,K,je,oe]),Ge(()=>{if(!o||M||!q||g||!J.current)return;const ge=q.nodesRef.current,ue=ge.find(De=>De.id===V)?.context?.elements.floating,be=Ys(_n(_??ue??null)),ve=ge.some(De=>De.context&&Et(De.context.elements.floating,be));ue&&!ve&&z.current&&ue.focus({preventScroll:!0})},[o,M,_,q,V,g]),Ge(()=>{ee.current=R,J.current=!!M}),Ge(()=>{R||(U.current=null,Q.current=v)},[R,v]);const te=s!=null,le=qe(ge=>{if(!re.current)return;const ue=n.current.indexOf(ge.currentTarget);ue!==-1&&(X.current!==ue||s!==ue)&&(X.current=ue,K(ge))}),he=qe(()=>S??q?.nodesRef.current.find(ge=>ge.id===V)?.context?.dataRef?.current.orientation),ce=qe(()=>Bk(n,se.current)),ye=qe(ge=>{if(z.current=!1,H.current=!0,ge.which===229||!re.current&&ge.currentTarget===F.current)return;if(f&&$be(ge.key,w,m,O)){cS(ge.key,he())||da(ge),A.setOpen(!1,Nt(fR,ge.nativeEvent)),br(_)&&(g?q?.events.emit("virtualfocus",_):_.focus());return}const ue=X.current,be=Bk(n,k),ve=nR(n,k);if(D||(ge.key==="Home"&&(da(ge),X.current=be,K(ge)),ge.key==="End"&&(da(ge),X.current=ve,K(ge))),P!=null){const De=P(ge,X.current,n,w,d,m,k,be,ve);if(De!=null&&(X.current=De,K(ge)),w==="both")return}if(cS(ge.key,w)){if(da(ge),R&&!g&&Ys(ge.currentTarget.ownerDocument)===ge.currentTarget){X.current=WR(ge.key,w,m)?be:ve,K(ge);return}WR(ge.key,w,m)?d?ue>=ve?u&&ue!==n.current.length?X.current=-1:(H.current=!1,X.current=be):X.current=Ta(n.current,{startingIndex:ue,disabledIndices:k}):X.current=Math.min(ve,Ta(n.current,{startingIndex:ue,disabledIndices:k})):d?ue<=be?u&&ue!==-1?X.current=n.current.length:(H.current=!1,X.current=ve):X.current=Ta(n.current,{startingIndex:ue,decrement:!0,disabledIndices:k}):X.current=Math.max(be,Ta(n.current,{startingIndex:ue,decrement:!0,disabledIndices:k})),zd(n.current,X.current)&&(X.current=-1),K(ge)}}),fe=p.useMemo(()=>({onFocus(ue){H.current=!0,le(ue)},onClick:({currentTarget:ue})=>ue.focus({preventScroll:!0}),onMouseMove(ue){nH(ue)||(H.current=!0,G.current=!1,b&&le(ue))},onPointerLeave(ue){if(!re.current||!z.current||ue.pointerType==="touch")return;H.current=!0;const be=ue.relatedTarget;if(!(!b||n.current.includes(be))&&de.current&&(Y.current?.(),Y.current=null,X.current=-1,K(ue),!g)){const ve=F.current,De=Ys(_n(ve));ve&&Et(ve,De)&&ve.focus({preventScroll:!0})}}}),[le,re,F,b,n,K,de,g]),Le=p.useMemo(()=>g&&R&&te&&{"aria-activedescendant":`${N}-${s}`},[g,R,te,N,s]),pe=p.useMemo(()=>({...D?{}:Le,onKeyDown(ge){if(ge.key==="Tab"&&ge.shiftKey&&R&&!g){const ue=Er(ge.nativeEvent);if(ue&&!Et(F.current,ue))return;da(ge),A.setOpen(!1,Nt(Fd,ge.nativeEvent)),br(_)&&_.focus();return}ye(ge)},onPointerMove(ge){nH(ge)||(z.current=!0)}}),[Le,ye,F,D,A,R,g,_]),xe=p.useMemo(()=>{function ge(ve){A.setOpen(!0,Nt(fR,ve.nativeEvent,ve.currentTarget))}function ue(ve){v==="auto"&&Dk(ve.nativeEvent)&&(Q.current=!g)}function be(ve){Q.current=v,v==="auto"&&QO(ve.nativeEvent)&&(Q.current=!0)}return{onKeyDown(ve){const De=A.select("open");z.current=!1;const Ie=ve.key.startsWith("Arrow"),We=Lbe(ve.key,he(),m),nt=cS(ve.key,w),kt=(f?We:nt)||ve.key==="Enter"||ve.key.trim()==="";if(g&&De)return ye(ve);if(!(!De&&!y&&Ie)){if(kt){const Je=cS(ve.key,he());U.current=f&&Je?null:ve.key}if(f){We&&(da(ve),De?(X.current=ce(),K(ve)):ge(ve));return}nt&&(ne.current!=null&&(X.current=ne.current),da(ve),!De&&y?ge(ve):ye(ve),De&&K(ve))}},onFocus(ve){A.select("open")&&!g&&(X.current=-1,K(ve))},onPointerDown:be,onPointerEnter:be,onMouseDown:ue,onClick:ue}},[ye,v,ce,f,K,A,y,w,he,m,ne,g]),Se=p.useMemo(()=>({...Le,...xe}),[Le,xe]);return p.useMemo(()=>o?{reference:Se,floating:pe,item:fe,trigger:xe}:{},[o,Se,pe,xe,fe])}function sH(e,t){const{listRef:n,elementsRef:s,activeIndex:i,onMatch:o,disabledIndices:l,onTyping:u,enabled:d=!0,resetMs:f=750,selectedIndex:m=null}=t,g="rootStore"in e?e.rootStore:e,v=g.useState("open"),b=fa(),y=p.useRef(""),k=p.useRef(m??i??-1),w=p.useRef(null),S=qe(T=>{function P(F){return s?.current[F]}function O(F){const V=P(F);return V&&!Fk(V)||V?.matches(":disabled")?!1:l==null||!Bd(co,F,l)}function A(F,V,q=0){if(F.length===0)return-1;const Q=(q%F.length+F.length)%F.length,X=V.toLowerCase();for(let U=0;U0&&T.key===" "&&(da(T),u?.(!0)),y.current.length>0&&y.current[0]!==" "&&A(R,y.current)===-1&&T.key!==" "&&u?.(!1),R==null||T.key.length!==1||T.ctrlKey||T.metaKey||T.altKey)return;v&&T.key!==" "&&(da(T),u?.(!0));const M=y.current==="";M&&(k.current=m??i??-1),R.every((F,V)=>F&&O(V)?F[0]?.toLowerCase()!==F[1]?.toLowerCase():!0)&&y.current===T.key&&(y.current="",k.current=w.current),y.current+=T.key,b.start(f,()=>{y.current="",k.current=w.current,u?.(!1)});const $=((M?m??i??-1:k.current)??0)+1,D=A(R,y.current,$);D!==-1?(o?.(D),w.current=D):T.key!==" "&&(y.current="",u?.(!1))}),N=qe(T=>{const P=T.relatedTarget,O=g.select("domReferenceElement"),A=g.select("floatingElement");Et(O,P)||Et(A,P)||(b.clear(),y.current="",k.current=w.current,u?.(!1))});Ge(()=>{!v&&m!==null||(b.clear(),w.current=null,y.current!==""&&(y.current=""))},[v,m,b]);const C=p.useMemo(()=>({onKeyDown:S,onBlur:N}),[S,N]);return p.useMemo(()=>d?{reference:C,floating:C}:{},[d,C])}const aH=.1,zbe=aH*aH,Dr=.5;function uS(e,t,n,s,i,o){return s>=t!=o>=t&&e<=(i-n)*(t-s)/(o-s)+n}function dS(e,t,n,s,i,o,l,u,d,f){let m=!1;return uS(e,t,n,s,i,o)&&(m=!m),uS(e,t,i,o,l,u)&&(m=!m),uS(e,t,l,u,d,f)&&(m=!m),uS(e,t,d,f,n,s)&&(m=!m),m}function Bbe(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function fS(e,t,n,s,i,o){const l=Math.min(n,i),u=Math.max(n,i),d=Math.min(s,o),f=Math.max(s,o);return e>=l&&e<=u&&t>=d&&t<=f}function iH(e={}){const{blockPointerEvents:t=!1}=e,n=new Bi,s=({x:i,y:o,placement:l,elements:u,onClose:d,nodeId:f,tree:m})=>{const g=l?.split("-")[0];let v=!1,b=null,y=null,k=typeof performance<"u"?performance.now():0;function w(N,C){const T=performance.now(),P=T-k;if(b===null||y===null||P===0)return b=N,y=C,k=T,!1;const O=N-b,A=C-y,R=O*O+A*A,M=P*P*zbe;return b=N,y=C,k=T,R0)}function D(){$()||S()}if($())return;const F=T.getBoundingClientRect(),V=P.getBoundingClientRect(),q=i>V.right-V.width/2,Q=o>V.bottom-V.height/2,X=V.width>F.width,U=V.height>F.height,z=(X?F:V).left,K=(X?F:V).right,J=(U?F:V).top,ee=(U?F:V).bottom;if(g==="top"&&o>=F.bottom-1||g==="bottom"&&o<=F.top+1||g==="left"&&i>=F.right-1||g==="right"&&i<=F.left+1){D();return}let H=!1;switch(g){case"top":H=fS(O,A,z,F.top+1,K,V.bottom-1);break;case"bottom":H=fS(O,A,z,V.top+1,K,F.bottom-1);break;case"left":H=fS(O,A,V.right-1,ee,F.left+1,J);break;case"right":H=fS(O,A,F.right-1,ee,V.left+1,J);break}if(H)return;if(v&&!Bbe(O,A,F)){D();return}if(!M&&w(O,A)){D();return}let G=!1;switch(g){case"top":{const Y=X?Dr/2:Dr*4,se=X||q?i+Y:i-Y,re=X?i-Y:q?i+Y:i-Y,ne=o+Dr+1,de=q||X?V.bottom-Dr:V.top,ie=q?X?V.bottom-Dr:V.top:V.bottom-Dr;G=dS(O,A,se,ne,re,ne,V.left,de,V.right,ie);break}case"bottom":{const Y=X?Dr/2:Dr*4,se=X||q?i+Y:i-Y,re=X?i-Y:q?i+Y:i-Y,ne=o-Dr,de=q||X?V.top+Dr:V.bottom,ie=q?X?V.top+Dr:V.bottom:V.top+Dr;G=dS(O,A,se,ne,re,ne,V.left,de,V.right,ie);break}case"left":{const Y=U?Dr/2:Dr*4,se=U||Q?o+Y:o-Y,re=U?o-Y:Q?o+Y:o-Y,ne=i+Dr+1,de=Q||U?V.right-Dr:V.left,ie=Q?U?V.right-Dr:V.left:V.right-Dr;G=dS(O,A,de,V.top,ie,V.bottom,ne,se,ne,re);break}case"right":{const Y=U?Dr/2:Dr*4,se=U||Q?o+Y:o-Y,re=U?o-Y:Q?o+Y:o-Y,ne=i-Dr,de=Q||U?V.left+Dr:V.right,ie=Q?U?V.left+Dr:V.right:V.left+Dr;G=dS(O,A,ne,se,ne,re,de,V.top,ie,V.bottom);break}}G?v||n.start(40,D):D()}};return s.__options={...e,blockPointerEvents:t},s}const Fbe={...HR,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class Ube extends Ph{constructor(n,s,i){const o=new aS;super(Hbe(n,o,s,i),Vbe(o),Fbe);Cn(this,"setOpen",(n,s)=>{Obe(this,n,s,{extraState:{openChangeReason:s.reason}})})}cancelPendingOpen(n){this.state.floatingRootContext.dispatchOpenChange(!1,Nt(xu,n))}}function Hbe(e,t,n,s=!1){return{...FR(t,n,s),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function Vbe(e){return{popupRef:p.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}const Kbe=Qk(function(t){const{disabled:n=!1,defaultOpen:s=!1,open:i,disableHoverablePopup:o=!1,trackCursorAxis:l="none",actionsRef:u,onOpenChange:d,onOpenChangeComplete:f,handle:m,triggerId:g,defaultTriggerId:v=null,children:b}=t,y=MR((L,$)=>new Ube({open:s,openProp:i,activeTriggerId:v,triggerIdProp:g},L,$));y.useControlledProp("openProp",i),y.useControlledProp("triggerIdProp",g),y.useContextCallback("onOpenChange",d),y.useContextCallback("onOpenChangeComplete",f);const k=y.useState("open"),w=!n&&k,S=y.useState("activeTriggerId"),N=y.useState("mounted"),C=y.useState("payload");y.useSyncedValues({trackCursorAxis:l,disableHoverablePopup:o,disabled:n}),$R(y,{closeOnActiveTriggerUnmount:!0});const{forceUnmount:T,transitionStatus:P}=zR(w,y),O=y.useState("isInstantPhase"),A=y.useState("instantType"),R=y.useState("lastOpenChangeReason"),M=p.useRef(null);Ge(()=>{k&&n&&y.setOpen(!1,Nt(Sxe))},[k,n,y]),Ge(()=>{P==="ending"&&R===rs||P!=="ending"&&O?(A!=="delay"&&(M.current=A),y.set("instantType","delay")):M.current!==null&&(y.set("instantType",M.current),M.current=null)},[P,O,R,A,y]),Ge(()=>{w&&S==null&&y.set("payload",void 0)},[y,S,w]),p.useImperativeHandle(u,()=>({unmount:T,close:()=>y.setOpen(!1,Nt(hR))}),[T,y]);const _=w||N||!n&&l!=="none";return r.jsxs(r6.Provider,{value:y,children:[m&&r.jsx(_R,{handle:m,store:y}),_&&r.jsx(qbe,{store:y,disabled:n,trackCursorAxis:l}),typeof b=="function"?b({payload:C}):b]})});function qbe({store:e,disabled:t,trackCursorAxis:n}){const s=e.useState("floatingRootContext"),i=Fb(s,{enabled:!t,referencePress:()=>e.select("closeOnClick")}),o=Pve(s,{enabled:!t&&n!=="none",axis:n==="none"?void 0:n}),l=p.useMemo(()=>oo(o.reference,i.reference),[o.reference,i.reference]);return BR(e,{activeTriggerProps:l,inactiveTriggerProps:l,popupProps:i.floating??yr}),null}const oH=p.createContext(void 0);function Gbe(){return p.useContext(oH)}const Wbe=600,lH="data-base-ui-tooltip-trigger";function cH(e){if("composedPath"in e){const n=e.composedPath();for(let s=0;sw.select("transitionStatus")==="ending",shouldOpen(){return!z.current}}),se=Mbe(T,{enabled:!q}).reference,re=je=>{const te=z.current,le=cH(je),he=G(le),ce=P.current,ye=ce&&le&&Et(ce,le);if(he&&w.select("open")&&w.select("lastOpenChangeReason")===Va){w.setOpen(!1,Nt(Va,je));return}if(te&&!he&&ye&&!Q.current&&!w.select("open")&&ce&&Ld(J.current)){const fe=()=>{!z.current&&!Q.current&&!w.select("open")&&w.setOpen(!0,Nt(Va,je,ce))},Le=ee();Le===0?(K.clear(),fe()):K.start(Le,fe)}},ne=w.useState("triggerProps",R);return Kt("button",t,{state:{open:C},ref:[n,A,P],props:[Y,se,R||X!=="none"?ne:void 0,{onMouseOver(je){re(je.nativeEvent)},onFocus(je){H(cH(je.nativeEvent))&&je.preventBaseUIHandler()},onMouseLeave(){z.current=!1,K.clear(),J.current=void 0},onPointerEnter(je){J.current=je.pointerType},onPointerDown(je){J.current=je.pointerType,w.set("closeOnClick",m),m&&!w.select("open")&&w.cancelPendingOpen(je.nativeEvent)},onClick(je){m&&!w.select("open")&&w.cancelPendingOpen(je.nativeEvent)},id:S,[WO]:q?"":void 0,[lH]:q?void 0:""},b],stateAttributesMapping:Rk})}),uH=p.createContext(void 0);function Qbe(){const e=p.useContext(uH);if(e===void 0)throw new Error(Vn(70));return e}const dH=p.forwardRef(function(t,n){const{children:s,container:i,className:o,render:l,style:u,...d}=t,{node:f,subtree:m}=x6({container:i,ref:n,componentProps:t,elementProps:d});return!m&&!f?null:r.jsxs(p.Fragment,{children:[m,f&&xr.createPortal(s,f)]})}),Zbe=p.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t;return Lb().useState("mounted")||s?r.jsx(uH.Provider,{value:s,children:r.jsx(dH,{ref:n,...i})}):null}),fH=p.createContext(void 0);function hH(){const e=p.useContext(fH);if(e===void 0)throw new Error(Vn(71));return e}const Jbe=p.createContext(void 0);function Vb(){return p.useContext(Jbe)?.direction??"ltr"}const eye=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:i,rects:o,platform:l,elements:u,middlewareData:d}=t,{element:f,padding:m=0,offsetParent:g="real"}=$d(e,t)||{};if(f==null)return{};const v=NU(m),b={x:n,y:s},y=eR(i),k=JO(y),w=await l.getDimensions(f),S=y==="y",N=S?"top":"left",C=S?"bottom":"right",T=S?"clientHeight":"clientWidth",P=o.reference[k]+o.reference[y]-b[y]-o.floating[k],O=b[y]-o.reference[y],A=g==="real"?await l.getOffsetParent?.(f):u.floating;let R=u.floating[T]||o.floating[k];(!R||!await l.isElement?.(A))&&(R=u.floating[T]||o.floating[k]);const M=P/2-O/2,_=R/2-w[k]/2-1,L=Math.min(v[N],_),$=Math.min(v[C],_),D=L,F=R-w[k]-$,V=R/2-w[k]/2+M,q=wU(D,V,F),Q=!d.arrow&&mu(i)!=null&&V!==q&&o.reference[k]/2-(V{const{name:n,fn:s}=eye(e);return{name:n,fn:s,options:[e,t]}},nye={name:"hide",async fn(e){const{width:t,height:n,x:s,y:i}=e.rects.reference,o=t===0&&n===0&&s===0&&i===0,l=await e.platform.detectOverflow(e,{elementContext:"reference"});return{data:{referenceHidden:l.top-n>=0||l.right-t>=0||l.bottom-n>=0||l.left-t>=0||o}}}},rye={sideX:"left",sideY:"top"},sye="--available-width",aye="--available-height",iye="--anchor-width",oye="--anchor-height",lye="--transform-origin",mH=sye,pH=aye;function gH(e,t,n){const s=e==="inline-start"||e==="inline-end";return{top:"top",right:s?n?"inline-start":"inline-end":"right",bottom:"bottom",left:s?n?"inline-end":"inline-start":"left"}[t]}function xH(e,t,n){const{rects:s,placement:i}=e;return{side:gH(t,Uo(i),n),align:mu(i)||"center",anchor:{width:s.reference.width,height:s.reference.height},positioner:{width:s.floating.width,height:s.floating.height}}}function hS(e){return cye(e,Pbe)}function cye(e,t){const{anchor:n,positionMethod:s="absolute",side:i="bottom",sideOffset:o=0,align:l="center",alignOffset:u=0,collisionBoundary:d,collisionPadding:f=5,sticky:m=!1,arrowPadding:g=5,disableAnchorTracking:v=!1,inline:b,keepMounted:y=!1,floatingRootContext:k,mounted:w,collisionAvoidance:S,shift:N,nodeId:C,adaptiveOrigin:T,lazyFlip:P=!1,externalTree:O}=e,[A,R]=p.useState(null);!w&&A!==null&&R(null);const M=S.side||"flip",_=S.align||"flip",L=S.fallbackAxisSide||"end",$=N?.crossAxis??!1,D=N?.rootBoundary,F=typeof n=="function"?n:void 0,V=qe(F),q=F?V:n,Q=ss(n),X=ss(w),z=Vb()==="rtl",K=A||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":z?"left":"right","inline-start":z?"right":"left"}[i],J=l==="center"?K:`${K}-${l}`;let ee=f;typeof ee=="number"?ee={top:ee,right:ee,bottom:ee,left:ee}:ee&&(ee={top:ee.top||0,right:ee.right||0,bottom:ee.bottom||0,left:ee.left||0});const H=1,G=i==="bottom"?H:0,Y=i==="top"?H:0,se=i==="right"?H:0,re=i==="left"?H:0,ne={boundary:d==="clipping-ancestors"?"clippingAncestors":d,padding:ee},de=p.useRef(null),ie=ss(o),oe=ss(u),je=typeof o!="function"?o:0,te=typeof u!="function"?u:0,le=[];b&&le.push(b),le.push(mbe(ht=>{const Tt=xH(ht,i,z),Ht=typeof ie.current=="function"?ie.current(Tt):ie.current,jt=typeof oe.current=="function"?oe.current(Tt):oe.current;return{mainAxis:Ht,crossAxis:jt,alignmentAxis:jt}},[je,te,z,i]));const he=_==="none"&&M!=="shift",ce=!he&&(m||$||M==="shift"),ye=M==="none"?null:xbe({...ne,padding:{top:ee.top+H+G,right:ee.right+H+re,bottom:ee.bottom+H+Y,left:ee.left+H+se},mainAxis:!$&&M==="flip",crossAxis:_==="flip"?"alignment":!1,fallbackAxisSideDirection:L}),fe=he?null:pbe({...ne,rootBoundary:D,mainAxis:_!=="none",crossAxis:ce,limiter:m||$?void 0:gbe(ht=>{if(!de.current)return{};const{width:Tt,height:Ht}=de.current.getBoundingClientRect(),jt=Ho(Uo(ht.placement)),an=jt==="y"?Tt:Ht,Xt=jt==="y"?ee.left+ee.right:ee.top+ee.bottom;return{offset:an/2+Xt/2}})},[ne,m,$,D,ee,_]);M==="shift"||_==="shift"||l==="center"?le.push(fe,ye):le.push(ye,fe),le.push(vbe({...ne,apply({elements:{floating:ht},availableWidth:Tt,availableHeight:Ht,rects:jt}){if(!X.current)return;const an=ht.style;an.setProperty(mH,`${Tt}px`),an.setProperty(pH,`${Ht}px`);const Xt=vr(ht).devicePixelRatio||1,{x:gn,y:un,width:lr,height:yn}=jt.reference,xn=(Math.round((gn+lr)*Xt)-Math.round(gn*Xt))/Xt,jn=(Math.round((un+yn)*Xt)-Math.round(un*Xt))/Xt;an.setProperty(iye,`${xn}px`),an.setProperty(oye,`${jn}px`)}}),tye(ht=>({element:de.current||_n(ht.elements.floating).createElement("div"),padding:de.current?g:0,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(ht){const{elements:{floating:Tt},middlewareData:Ht,placement:jt,platform:an,rects:Xt,y:gn}=ht,un=Uo(jt),lr=mu(jt),yn=Ho(un)==="y",xn=de.current,jn=typeof o=="function"?o(xH(ht,i,z)):o;let ke;if(!xn&&lr&&Math.abs(yn?Ht.shift?.x||0:Ht.shift?.y||0)<=1)ke=lr==="start"===(yn&&an.isRTL?.(Tt)===!0)?"100%":"0%";else{const Qe=yn?Ht.arrow?.x||0:Ht.arrow?.y||0,Yt=yn?xn?.clientWidth||0:xn?.clientHeight||0;ke=`${Qe+Yt/2}px`}let Xe=un==="top"||un==="left"?`calc(100% + ${jn}px)`:`${-jn}px`;return ce&&yn&&Math.abs(Ht.shift?.y||0)>jn&&(Xe=`${Xt.reference.y+Xt.reference.height/2-gn}px`),Tt.style.setProperty(lye,yn?`${ke} ${Xe}`:`${Xe} ${ke}`),{}}},nye,T),Ge(()=>{!w&&k&&k.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[w,k]);const Le=p.useMemo(()=>({ancestorScroll:!v,elementResize:!v&&typeof ResizeObserver<"u",layoutShift:!v&&typeof IntersectionObserver<"u"}),[v]),{refs:pe,elements:xe,x:Se,y:ge,middlewareData:ue,update:be,placement:ve,context:De,isPositioned:Ie,floatingStyles:We}=t({rootContext:k,open:y?w:void 0,placement:J,middleware:le,strategy:s,whileElementsMounted:y?void 0:(...ht)=>D6(...ht,Le),nodeId:C,externalTree:O}),{sideX:nt,sideY:kt}=ue.adaptiveOrigin||rye,Je=Ie?s:"fixed",on=p.useMemo(()=>{let ht;return Ie?T?ht={position:Je,[nt]:Se,[kt]:ge}:ht={...We,position:Je}:ht={position:Je,top:0,left:0},ht[mH]="100vw",ht[pH]="100vh",Ie||(ht.opacity=0),ht},[T,Je,nt,Se,kt,ge,We,Ie]),nn=p.useRef(null);Ge(()=>{if(!w)return;const ht=Q.current,Tt=typeof ht=="function"?ht():ht,jt=(vH(Tt)?Tt.current:Tt)||null||null;jt!==nn.current&&(pe.setPositionReference(jt),nn.current=jt)},[w,pe,q,Q]),p.useEffect(()=>{if(!w)return;const ht=Q.current;typeof ht!="function"&&vH(ht)&&ht.current!==nn.current&&(pe.setPositionReference(ht.current),nn.current=ht.current)},[w,pe,q,Q]),p.useEffect(()=>{if(y&&w&&xe.reference&&xe.floating)return D6(xe.reference,xe.floating,be,Le)},[y,w,xe,be,Le]);const On=Uo(ve),Rn=gH(i,On,z),gt=mu(ve)||"center",sn=!!ue.hide?.referenceHidden;Ge(()=>{P&&w&&Ie&&On!==K&&R(On)},[P,w,Ie,On,K]);const Ke=p.useMemo(()=>({position:"absolute",top:ue.arrow?.y,left:ue.arrow?.x}),[ue.arrow]),zt=ue.arrow?.centerOffset!==0;return p.useMemo(()=>({positionerStyles:on,arrowStyles:Ke,arrowRef:de,arrowUncentered:zt,side:Rn,align:gt,physicalSide:On,anchorHidden:sn,refs:pe,context:De,isPositioned:Ie,update:be}),[on,Ke,de,zt,Rn,gt,On,sn,pe,De,Ie,be])}function vH(e){return e!=null&&"current"in e}function Kb(e){return e==="starting"?vve:yr}function mS(e,t,{styles:n,transitionStatus:s,props:i,refs:o,hidden:l,inert:u=!1}){const d={...n};return u&&(d.pointerEvents="none"),Kt("div",e,{state:t,ref:o,props:[{role:"presentation",hidden:l,style:d},Kb(s),i],stateAttributesMapping:cg})}const uye=p.forwardRef(function(t,n){const{render:s,className:i,anchor:o,positionMethod:l="absolute",side:u="top",align:d="center",sideOffset:f=0,alignOffset:m=0,collisionBoundary:g="clipping-ancestors",collisionPadding:v=5,arrowPadding:b=5,sticky:y=!1,disableAnchorTracking:k=!1,collisionAvoidance:w=m6,style:S,...N}=t,C=Lb(),T=Qbe(),P=C.useState("open"),O=C.useState("mounted"),A=C.useState("trackCursorAxis"),R=C.useState("disableHoverablePopup"),M=C.useState("floatingRootContext"),_=C.useState("instantType"),L=C.useState("transitionStatus"),$=C.useState("adaptiveOrigin"),D=hS({anchor:o,positionMethod:l,floatingRootContext:M,mounted:O,side:u,sideOffset:f,align:d,alignOffset:m,collisionBoundary:g,collisionPadding:v,sticky:y,arrowPadding:b,disableAnchorTracking:k,keepMounted:T,collisionAvoidance:w,adaptiveOrigin:$}),F=p.useMemo(()=>({open:P,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:A!=="none"?"tracking-cursor":_}),[P,D.side,D.align,D.anchorHidden,A,_]),V=mS(t,F,{styles:D.positionerStyles,transitionStatus:L,props:N,refs:[n,C.useStateSetter("positionerElement")],hidden:!O,inert:!P||A==="both"||R});return r.jsx(fH.Provider,{value:D,children:V})}),dye=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=Lb(),{side:d,align:f}=hH(),m=u.useState("open"),g=u.useState("instantType"),v=u.useState("transitionStatus"),b=u.useState("popupProps"),y=u.useState("floatingRootContext"),k=u.useState("disabled"),w=u.useState("closeDelay");ji({open:m,ref:u.context.popupRef,onComplete(){m&&u.context.onOpenChangeComplete?.(!0)}}),eH(y,{enabled:!k,closeDelay:w});const S=u.useStateSetter("popupElement");return Kt("div",t,{state:{open:m,side:d,align:f,instant:g,transitionStatus:v},ref:[n,u.context.popupRef,S],props:[Ub,b,Kb(v),l],stateAttributesMapping:GO})}),fye=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=Lb(),{arrowRef:d,side:f,align:m,arrowUncentered:g,arrowStyles:v}=hH(),b=u.useState("open"),y=u.useState("instantType");return Kt("div",t,{state:{open:b,side:f,align:m,uncentered:g,instant:y},ref:[n,d],props:[{style:v,"aria-hidden":!0},l],stateAttributesMapping:cg})}),hye=function(t){const{delay:n,closeDelay:s,timeout:i=400}=t,o=p.useMemo(()=>({open:n,close:s}),[n,s]);return r.jsx(oH.Provider,{value:n,children:r.jsx(fve,{delay:o,timeoutMs:i,children:t.children})})};function qb(e){return MO(19)?e:e?"true":void 0}function mye(e){const[t,n]=p.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function pS(e){return r.jsx(hye,{"data-slot":"tooltip-provider",...e})}function pc(e){return r.jsx(Kbe,{"data-slot":"tooltip",...e})}function Ih(e){return r.jsx(Xbe,{"data-slot":"tooltip-trigger",...e})}function gc({className:e,sideOffset:t=8,side:n="top",anchor:s,variant:i="default",children:o,...l}){return r.jsx(Zbe,{children:r.jsx(uye,{anchor:s,positionMethod:"fixed",collisionPadding:8,sideOffset:t,side:n,className:"z-[90] data-anchor-hidden:hidden",children:r.jsx(dye,{"data-slot":"tooltip-content",className:Ne("max-w-[min(320px,calc(100vw-16px))] rounded-md px-2.5 py-2 text-[11.5px] leading-[1.55] shadow-3",i==="plain"?"border border-border bg-raised text-foreground":"bg-primary text-primary-on","break-words outline-none","transition-[opacity,transform] duration-150 ease-out","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95","data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...l,children:o})})})}function pye({className:e,...t}){return r.jsx(fye,{className:Ne("size-2 rotate-45 rounded-[1px] bg-primary","data-[side=top]:-bottom-1 data-[side=bottom]:-top-1",e),...t})}const bH=p.createContext(void 0);function Hd(e){const t=p.useContext(bH);if(!e&&t===void 0)throw new Error(Vn(27));return t}const YR=p.forwardRef(function(t,n){const{render:s,className:i,style:o,forceRender:l=!1,...u}=t,d=Hd(),f=d.useState("open"),m=d.useState("nested"),g=d.useState("mounted"),v=d.useState("transitionStatus");return Kt("div",t,{state:{open:f,transitionStatus:v},ref:[d.context.backdropRef,n],stateAttributesMapping:GO,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},u],enabled:l||!m})}),Gb=p.forwardRef(function(t,n){const{render:s,className:i,style:o,disabled:l=!1,nativeButton:u=!0,...d}=t,f=Hd(),m=f.useState("open"),{getButtonProps:g,buttonRef:v}=$i({disabled:l,native:u}),b={disabled:l};function y(k){m&&f.setOpen(!1,Nt(dR,k.nativeEvent))}return Kt("button",t,{state:b,ref:[n,v],props:[{onClick:y},d,g]})}),yH=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,...u}=t,d=Hd(),f=Ws(l);return d.useSyncedValueWithCleanup("descriptionElementId",f),Kt("p",t,{ref:n,props:[{id:f},u]})}),jH=p.createContext(void 0);function gye(){const e=p.useContext(jH);if(e===void 0)throw new Error(Vn(26));return e}const XR="ArrowUp",QR="ArrowDown",ZR="ArrowLeft",JR="ArrowRight",eP="Home",tP="End",gS=new Set([XR,QR,ZR,JR,eP,tP]),wH="Shift",xye=[wH,"Control","Alt","Meta"];function vye(e){return br(e)&&e.tagName==="INPUT"}function kH(e){return!!(vye(e)&&e.selectionStart!=null||br(e)&&e.tagName==="TEXTAREA")}function SH(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,o=e.scrollTop;const l=e.clientWidthe.scrollLeft+e.clientWidth-f.scrollPaddingRight?i=d+t.offsetWidth+m.scrollMarginRight-e.clientWidth+f.scrollPaddingRight:d-m.scrollMarginLefte.scrollLeft+e.clientWidth-f.scrollPaddingRight&&(i=d+t.offsetWidth+m.scrollMarginRight-e.clientWidth+f.scrollPaddingRight))}if(u&&s!=="horizontal"){const d=NH(e,t,"top"),f=xS(e),m=xS(t);d-m.scrollMarginTope.scrollTop+e.clientHeight-f.scrollPaddingBottom&&(o=d+t.offsetHeight+m.scrollMarginBottom-e.clientHeight+f.scrollPaddingBottom)}e.scrollTo({left:i,top:o,behavior:"auto"})}function NH(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[s],t.offsetParent!==e);)t=t.offsetParent;return i}function xS(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const bye="--nested-dialogs",yye="data-nested-dialog-open",jye={...cg,...Fo,nestedDialogOpen(e){return e?{[yye]:""}:null}},nP=p.forwardRef(function(t,n){const{render:s,className:i,style:o,finalFocus:l,initialFocus:u,...d}=t,f=Hd(),m=f.useState("descriptionElementId"),g=f.useState("disablePointerDismissal"),v=f.useState("floatingRootContext"),b=f.useState("popupProps"),y=f.useState("modal"),k=f.useState("mounted"),w=f.useState("nested"),S=f.useState("nestedOpenDialogCount"),N=f.useState("open"),C=f.useState("openMethod"),T=f.useState("titleElementId"),P=f.useState("transitionStatus"),O=f.useState("role"),A=v.useState("floatingId");gye(),ji({open:N,ref:f.context.popupRef,onComplete(){N&&f.context.onOpenChangeComplete?.(!0)}});const R=u===void 0?q6(f.context.popupRef):u,M=S>0,_=f.useStateSetter("popupElement"),$=Kt("div",t,{state:{open:N,nested:w,transitionStatus:P,nestedDialogOpen:M},props:[b,{id:A,"aria-labelledby":T,"aria-describedby":m,role:O,...Ub,hidden:!k,onKeyDown(D){gS.has(D.key)&&D.stopPropagation()},style:{[bye]:S}},d],ref:[n,f.context.popupRef,_],stateAttributesMapping:jye});return r.jsx(tS,{context:v,openInteractionType:C,disabled:!k,closeOnFocusOut:!g,initialFocus:R,returnFocus:l,modal:y!==!1,restoreFocus:"popup",children:$})}),vS=p.forwardRef(function(t,n){const{cutout:s,...i}=t;let o;if(s){const l=s.getBoundingClientRect();o=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${l.left}px ${l.top}px,${l.left}px ${l.bottom}px,${l.right}px ${l.bottom}px,${l.right}px ${l.top}px,${l.left}px ${l.top}px)`}return r.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})}),rP=p.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,o=Hd(),l=o.useState("mounted"),u=o.useState("modal"),d=o.useState("open");return l||s?r.jsx(jH.Provider,{value:s,children:r.jsxs(eS,{ref:n,...i,children:[l&&u===!0&&r.jsx(vS,{ref:o.context.internalBackdropRef,inert:qb(!d)}),t.children]})}):null});let CH={},AH={},EH="";function bS(e,t){return Cb(e)?e:t}function TH(e,t,n){return/hidden|clip/.test(e.getComputedStyle(bS(t,n)).overflowY)}function wye(e){if(typeof document>"u")return!1;const t=_n(e);return vr(t).innerWidth-t.documentElement.clientWidth>0}function kye(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=_n(e),s=n.documentElement,i=n.body,o=bS(s,i),l=o.style.overflowY,u=s.style.scrollbarGutter;s.style.scrollbarGutter="stable",o.style.overflowY="scroll";const d=o.offsetWidth;o.style.overflowY="hidden";const f=o.offsetWidth;return o.style.overflowY=l,s.style.scrollbarGutter=u,d===f}function Sye(e){const t=_n(e),n=t.documentElement,s=t.body,i=bS(n,s),o={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(i.style,o)}}function Nye(e){const t=_n(e),n=t.documentElement,s=t.body,i=vr(n);let o=0,l=0,u=!1;const d=Fi.create();if(du&&(i.visualViewport?.scale??1)!==1)return()=>{};function f(){const b=i.getComputedStyle(n),y=i.getComputedStyle(s),S=(b.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,l=n.scrollLeft,CH={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},EH=n.style.scrollBehavior,AH={position:s.style.position,height:s.style.height,width:s.style.width,boxSizing:s.style.boxSizing,overflowY:s.style.overflowY,overflowX:s.style.overflowX,scrollBehavior:s.style.scrollBehavior};const N=n.scrollHeight>n.clientHeight,C=n.scrollWidth>n.clientWidth,T=b.overflowY==="scroll"||y.overflowY==="scroll",P=b.overflowX==="scroll"||y.overflowX==="scroll",O=Math.max(0,i.innerWidth-s.clientWidth),A=Math.max(0,i.innerHeight-s.clientHeight),R=parseFloat(y.marginTop)+parseFloat(y.marginBottom),M=parseFloat(y.marginLeft)+parseFloat(y.marginRight),_=bS(n,s);if(u=kye(e),u){n.style.scrollbarGutter=S,_.style.overflowY="hidden",_.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:S,overflowY:"hidden",overflowX:"hidden"}),(N||T)&&(n.style.overflowY="scroll"),(C||P)&&(n.style.overflowX="scroll"),Object.assign(s.style,{position:"relative",height:R||A?`calc(100dvh - ${R+A}px)`:"100dvh",width:M||O?`calc(100vw - ${M+O}px)`:"100vw",boxSizing:"border-box",overflowY:"hidden",overflowX:"hidden",scrollBehavior:"unset"}),s.scrollTop=o,s.scrollLeft=l,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function m(){Object.assign(n.style,CH),Object.assign(s.style,AH),u||(n.scrollTop=o,n.scrollLeft=l,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=EH)}function g(){m(),d.request(f)}f();const v=kn(i,"resize",g);return()=>{d.cancel(),m(),typeof i.removeEventListener=="function"&&v()}}class Cye{constructor(){Cn(this,"lockCount",0);Cn(this,"restore",null);Cn(this,"timeoutLock",Bi.create());Cn(this,"timeoutUnlock",Bi.create());Cn(this,"release",()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)});Cn(this,"unlock",()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)})}acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}lock(t){if(this.lockCount===0||this.restore!==null)return;const n=_n(t),s=n.documentElement,i=n.body,o=vr(s);if(TH(o,s,i)){const u=new o.MutationObserver(()=>{TH(o,s,i)||(u.disconnect(),this.restore=null,this.lock(t))}),d={attributes:!0};u.observe(s,d),u.observe(i,d),this.restore=()=>u.disconnect();return}const l=Ob||!wye(t);this.restore=l?Sye(t):Nye(t)}}const Aye=new Cye;function OH(e=!0,t=null){Ge(()=>{if(e)return Aye.acquire(t)},[e,t])}function Eye({store:e,parentContext:t,isDrawer:n}){const s=e.useState("open"),i=e.useState("disablePointerDismissal"),o=e.useState("modal"),l=e.useState("popupElement"),u=e.useState("floatingRootContext"),[d,f]=p.useState(0),[m,g]=p.useState(0),v=d===0,b=Fb(u,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(y){if(!e.context.outsidePressEnabledRef.current||"button"in y&&y.button!==0)return!1;if("touches"in y){if(y.type==="touchend"){if(y.changedTouches.length!==1||y.touches.length!==0)return!1}else if(y.touches.length!==1)return!1}const k=Er(y);if(v&&!i){if(o){const w=e.context.internalBackdropRef.current,S=e.context.backdropRef.current;return w||S?w===k||S===k||Et(k,l)&&!k?.hasAttribute("data-base-ui-portal"):!0}return!0}return!1},escapeKey:v});return OH(s&&o===!0,l),e.useContextCallback("onNestedDialogOpen",(y,k)=>{f(y),g(k)}),Ge(()=>(t?.onNestedDialogOpen&&(s?t.onNestedDialogOpen(d+1,m+(n?1:0)):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&s&&t.onNestedDialogOpen(0,0)}),[n,s,d,m,t]),BR(e,{activeTriggerProps:b.reference,inactiveTriggerProps:b.trigger,popupProps:b.floating,nestedOpenDialogCount:d,nestedOpenDrawerCount:m}),null}const Tye={...HR,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role};class Oye extends Ph{constructor(n,s,i){const o=new aS,l=Rye(n,o,s,i);super(l,Pye(o),Tye);Cn(this,"setOpen",(n,s)=>{s.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!n&&s.trigger==null&&this.state.activeTriggerId!=null&&(s.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(n,s),!s.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(n,s),this.update(DR(this.state,n,s.trigger)))})}}function Rye(e,t,n,s=!1){return{...FR(t,n,s),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function Pye(e){return{popupRef:p.createRef(),backdropRef:p.createRef(),internalBackdropRef:p.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function RH(e,t){const{children:n,open:s,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:l,disablePointerDismissal:u=!1,modal:d=!0,actionsRef:f,handle:m,triggerId:g,defaultTriggerId:v=null}=t,b=e==="drawer",y=e==="alert-dialog",k=y?!0:d,w=y||u,S=y?"alertdialog":"dialog",N=Hd(!0),C=N!=null,T={modal:k,disablePointerDismissal:w,nested:C,role:S},P=MR((L,$)=>new Oye({open:i,openProp:s,activeTriggerId:v,triggerIdProp:g,...T},L,$),!0);P.useControlledProp("openProp",s),P.useControlledProp("triggerIdProp",g),P.useSyncedValues(T),P.useContextCallback("onOpenChange",o),P.useContextCallback("onOpenChangeComplete",l);const O=P.useState("open"),A=P.useState("mounted"),R=P.useState("payload");Y6(P,O),$R(P);const{forceUnmount:M}=zR(O,P);p.useImperativeHandle(f,()=>({unmount:M,close:()=>P.setOpen(!1,Nt(hR))}),[M,P]);const _=O||A;return r.jsxs(bH.Provider,{value:P,children:[m&&r.jsx(_R,{handle:m,store:P}),_&&r.jsx(Eye,{store:P,parentContext:N?.context,isDrawer:b}),typeof n=="function"?n({payload:R}):n]})}const PH=Qk(function(t){return RH("dialog",t)}),sP=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,...u}=t,d=Hd(),f=Ws(l);return d.useSyncedValueWithCleanup("titleElementId",f),Kt("h2",t,{ref:n,props:[{id:f},u]})});function Iye(e){const t=p.useRef(""),n=p.useCallback(i=>{i.defaultPrevented||(t.current=i.pointerType,e(i,i.pointerType))},[e]);return{onClick:p.useCallback(i=>{if(i.detail===0){e(i,"keyboard");return}"pointerType"in i?e(i,i.pointerType):e(i,t.current),t.current=""},[e]),onPointerDown:n}}function aP(e,t){const n=qe((o,l)=>{(typeof e=="function"?e():e)||t(l||(Ob?"touch":""))}),{onClick:s,onPointerDown:i}=Iye(n);return p.useMemo(()=>({onClick:s,onPointerDown:i}),[s,i])}function IH(e){const[t,n]=p.useState(null),s=aP(e,n);return Vo(e,i=>{i&&!e&&n(null)}),p.useMemo(()=>({openMethod:t,triggerProps:s}),[t,s])}const MH=bR(function(t,n){const{render:s,className:i,style:o,disabled:l=!1,nativeButton:u=!0,id:d,payload:f,handle:m,...g}=t,v=Hd(!0),y=VR(m)??v;if(!y)throw new Error(Vn(79));const k=Ws(d),w=y.useState("floatingRootContext"),S=y.useState("isOpenedByTrigger",k),N=y.useState("triggerPopupId",k),C=p.useRef(null),{registerTrigger:T,isMountedByThisTrigger:P}=LR(k,C,y,{payload:f}),{getButtonProps:O,buttonRef:A}=$i({disabled:l,native:u}),R=Bb(w),M=aP(()=>y.select("open"),$=>{y.set("openMethod",$)}),_={disabled:l,open:S},L=y.useState("triggerProps",P);return Kt("button",t,{state:_,ref:[A,n,T,C],props:[R.reference,L,M,{[kR]:"",id:k,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":N},g,O],stateAttributesMapping:Rk})});function at(e){return r.jsx(PH,{"data-slot":"dialog",...e})}function _H(e){return r.jsx(MH,{"data-slot":"dialog-trigger",...e})}function Mye(e){return r.jsx(rP,{"data-slot":"dialog-portal",...e})}function DH(e){return r.jsx(Gb,{"data-slot":"dialog-close",...e})}const st=e=>r.jsx(sP,{"data-slot":"dialog-title",...e}),fo=e=>r.jsx(yH,{"data-slot":"dialog-description",...e});function _ye({className:e,...t}){return r.jsx(YR,{"data-slot":"dialog-overlay",className:Ne("fixed inset-0 isolate z-30 bg-mask backdrop-blur-[3px]","transition-opacity duration-150","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...t})}function it({className:e,children:t,showCloseButton:n=!0,keepMounted:s=!1,overlayForceRender:i=!1,...o}){return r.jsxs(Mye,{keepMounted:s,children:[r.jsx(_ye,{forceRender:i}),r.jsxs(nP,{"data-slot":"dialog-content",className:Ne("fixed top-1/2 left-1/2 z-30 flex max-h-[calc(100vh-48px)] w-[min(620px,calc(100vw-48px))] -translate-x-1/2 -translate-y-1/2 flex-col","overflow-hidden rounded-lg border border-border bg-surface shadow-3 outline-none","transition-[opacity,transform] duration-200 [transition-timing-function:cubic-bezier(.2,.9,.3,1)]","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[.985] data-open:slide-in-from-bottom-2.5","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...o,children:[t,n&&r.jsxs(Gb,{"data-slot":"dialog-close",render:r.jsx(B,{variant:"ghost",size:"icon-sm",className:"absolute top-3 right-3"}),children:[r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 2.5l7 7M9.5 2.5l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),r.jsx("span",{className:"sr-only",children:Z("关闭")})]})]})]})}function ot({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-header",className:Ne("flex items-center gap-2.5 border-b border-hairline px-5 py-[15px] pr-10","[&_h2]:flex-1 [&_h2]:text-[14.5px] [&_h2]:font-semibold",e),...t})}function lt({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-body",className:Ne("flex flex-col gap-4 overflow-y-auto px-5 py-[18px]",e),...t})}function xt({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-footer",className:Ne("flex items-center justify-end gap-2 border-t border-hairline bg-surface-2 px-5 py-[13px]",e),...t})}function as({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-section",className:Ne("flex flex-col gap-2.5 rounded-md border border-border bg-surface-inset p-3.5","[&_h3]:text-[12.5px] [&_h3]:font-semibold","[&_p]:text-xs [&_p]:leading-[1.65] [&_p]:text-subtle",e),...t})}function Dye(e){return RH("alert-dialog",e)}const LH=Dye,Lye=rP,$H=e=>r.jsx(sP,{"data-slot":"alert-dialog-title",...e});function $ye({className:e,...t}){return r.jsx(YR,{"data-slot":"alert-dialog-overlay",className:Ne("fixed inset-0 isolate z-[38] bg-mask backdrop-blur-[3px]","transition-opacity duration-150","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...t})}function zH({className:e,children:t,showCloseButton:n=!1,...s}){return r.jsxs(Lye,{children:[r.jsx($ye,{}),r.jsxs(nP,{"data-slot":"alert-dialog-content",className:Ne("fixed top-1/2 left-1/2 z-[38] flex max-h-[calc(100vh-48px)] w-[min(440px,calc(100vw-48px))] -translate-x-1/2 -translate-y-1/2 flex-col","overflow-hidden rounded-lg border border-border bg-surface shadow-3 outline-none","transition-[opacity,transform] duration-200 [transition-timing-function:cubic-bezier(.2,.9,.3,1)]","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[.985] data-open:slide-in-from-bottom-2.5","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...s,children:[t,n&&r.jsxs(Gb,{"data-slot":"alert-dialog-close",render:r.jsx(B,{variant:"ghost",size:"icon-sm",className:"absolute top-3 right-3"}),children:[r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 2.5l7 7M9.5 2.5l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),r.jsx("span",{className:"sr-only",children:Z("关闭")})]})]})]})}function BH({className:e,...t}){return r.jsx("div",{"data-slot":"alert-dialog-header",className:Ne("flex items-center gap-2.5 border-b border-hairline px-5 py-[15px]","[&_h2]:flex-1 [&_h2]:text-[14.5px] [&_h2]:font-semibold",e),...t})}function FH({className:e,...t}){return r.jsx("div",{"data-slot":"alert-dialog-body",className:Ne("flex flex-col gap-4 overflow-y-auto px-5 py-[18px]",e),...t})}function UH({className:e,...t}){return r.jsx("div",{"data-slot":"alert-dialog-footer",className:Ne("flex items-center justify-end gap-2 border-t border-hairline bg-surface-2 px-5 py-[13px]",e),...t})}function zye({className:e,tone:t="danger",...n}){return r.jsx("div",{"data-slot":"alert-dialog-banner","data-tone":t,className:Ne("rounded-md border px-3.5 py-3 text-xs leading-[1.65] text-subtle","[&_strong]:font-semibold",t==="danger"?"border-destructive-bd bg-destructive-soft [&_strong]:text-destructive":"border-border bg-surface-inset [&_strong]:text-foreground",e),...n})}function ps({className:e,containerClassName:t,container:n=!0,...s}){const i=r.jsx("table",{"data-slot":"table",className:Ne("w-full caption-bottom border-collapse text-[12.5px]",e),...s});return n?r.jsx("div",{"data-slot":"table-container",className:Ne("relative w-full overflow-auto",t),children:i}):i}function Qs({className:e,...t}){return r.jsx("thead",{"data-slot":"table-header",className:Ne(e),...t})}function Es({className:e,...t}){return r.jsx("tbody",{"data-slot":"table-body",className:Ne(e),...t})}function Bye({className:e,...t}){return r.jsx("tfoot",{"data-slot":"table-footer",className:Ne("border-t border-border bg-surface-2 font-medium",e),...t})}function Jt({className:e,...t}){return r.jsx("tr",{"data-slot":"table-row",className:Ne("transition-colors duration-100 hover:[&>td]:bg-control-hover",e),...t})}function tt({className:e,children:t,sortDirection:n=!1,onSortChange:s,sortLabel:i,...o}){return r.jsx("th",{"data-slot":"table-head",className:Ne("sticky top-0 z-[2] whitespace-nowrap border-b border-border bg-[var(--ui-table-head-bg)] px-2 py-2","text-left text-[10.5px] font-semibold tracking-[.05em] text-muted-foreground",e),...o,"aria-sort":s?n==="asc"?"ascending":n==="desc"?"descending":"none":o["aria-sort"],children:s?r.jsxs(B,{type:"button",variant:"ghost",size:"xs","data-table-sort":"",className:"h-auto max-w-full gap-1 border-0 px-0 py-0 align-middle [font-size:inherit] font-semibold tracking-[inherit] text-inherit hover:bg-transparent active:translate-y-0","aria-label":i,title:[i,o.title].filter(Boolean).join(` -`)||void 0,onClick:()=>s(n==="asc"?"desc":"asc"),children:[r.jsx("span",{className:"min-w-0 truncate",children:t}),r.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"m8 9 4-4 4 4",className:n==="asc"?"text-primary-fg":"opacity-35"}),r.jsx("path",{d:"m8 15 4 4 4-4",className:n==="desc"?"text-primary-fg":"opacity-35"})]})]}):t})}function Ve({className:e,...t}){return r.jsx("td",{"data-slot":"table-cell",className:Ne("border-b border-hairline px-2 py-2 align-middle",e),...t})}function Fye({className:e,...t}){return r.jsx("caption",{"data-slot":"table-caption",className:Ne("mt-4 text-xs text-muted-foreground",e),...t})}const Uye="data-checked",Hye="data-unchecked",iP={checked(e){return e?{[Uye]:""}:{[Hye]:""}},...Fo,...hc},oP="data-composite-item-active",HH=p.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Vye(){return p.useContext(HH)}function lP(e={}){const{guess:t,label:n,metadata:s,textRef:i,index:o}=e,{register:l,unregister:u,subscribeMapChange:d,nextIndexRef:f}=Vye(),m=p.useRef(-1),[g,v]=p.useState(o==null&&t?()=>{if(m.current===-1){const w=f.current;f.current+=1,m.current=w}return m.current}:-1),b=o??g,y=p.useRef(null),k=p.useCallback(w=>{const S=y.current;S&&u(S),y.current=w,w&&l(w,{metadata:s??null,index:o??null,label:n,textRef:i})},[o,l,u,s,n,i]);return Ge(()=>{if(o==null)return d(w=>{const S=y.current?w.get(y.current)?.index:null;S!=null&&v(S)})},[o,d]),{ref:k,index:b}}function Kye(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=_F(),{ref:i,index:o}=lP(e),l=n===o,u=p.useRef(null),d=lo(i,u);return{compositeProps:{tabIndex:l?0:-1,onFocus(){s(o)},onMouseMove(){const m=u.current;if(!t||!m)return;const g=m.hasAttribute("disabled")||m.ariaDisabled==="true";!l&&!g&&m.focus()}},compositeRef:d,index:o}}function VH(e){const{render:t,className:n,style:s,state:i=yr,props:o=co,refs:l=co,metadata:u,stateAttributesMapping:d,tag:f="div",...m}=e,{compositeProps:g,compositeRef:v}=Kye({metadata:u});return Kt(f,e,{state:i,ref:[v,...l],props:[g,...o,m],stateAttributesMapping:d})}const KH=p.createContext(void 0);function qye(){return p.useContext(KH)}function yS(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}const qH=p.createContext(void 0);function Gye(){const e=p.useContext(qH);if(e===void 0)throw new Error(Vn(52));return e}const GH=p.forwardRef(function(t,n){const{render:s,className:i,disabled:o=!1,readOnly:l=!1,required:u=!1,"aria-labelledby":d,value:f,inputRef:m,nativeButton:g=!1,id:v,style:b,...y}=t,k=qye(),{disabled:w,readOnly:S,required:N,form:C,checkedValue:T,touched:P=!1,validation:O,name:A,setCheckedValue:R=Xn,setTouched:M=Xn,registerInputRef:_=Xn}=k??{},{setTouched:L,setFilled:$,state:D,disabled:F}=uo(),V=Hk(),{labelId:q,getDescriptionProps:Q}=zi(),X=F||V.disabled||w||o,U=S||l,z=N||u,K=C,J=k?T===f:f==="",ee=p.useRef(null),H=p.useRef(null),G=O?.registerInput,Y=p.useCallback(xe=>G?.(xe,{controlRef:ee,value:void 0}),[G]),se=lo(m,H,_,Y);Ge(()=>{H.current?.checked&&$(!0)},[$]),Ge(()=>{if(H.current){if(X&&J){_(null);return}_(H.current)}},[J,X,_]);const re=Ws(),ne=_d({id:v}),de=g?void 0:ne,ie=FO(d,q,H,!g,de),oe={role:"radio","aria-checked":J,"aria-labelledby":ie,[oP]:J?"":void 0,id:g?ne:re,onKeyDown(xe){xe.key==="Enter"&&xe.preventDefault()},onClick(xe){if(xe.defaultPrevented||X||U)return;xe.preventDefault();const Se=H.current;Se&&og(Se,xe)},onFocus(xe){xe.defaultPrevented||X||U||!P||(H.current?.click(),M(!1))}},{getButtonProps:je,buttonRef:te}=$i({disabled:X,native:g,composite:!1}),le={type:"radio",ref:se,form:K,id:de,name:A,tabIndex:-1,style:A?pg:vu,"aria-hidden":!0,...f!==void 0?{value:yS(f)}:yr,disabled:X,checked:J,required:z,readOnly:U,onChange(xe){if(xe.nativeEvent.defaultPrevented||X||U||f===void 0)return;const Se=Nt(rs,xe.nativeEvent);R(f,Se),!Se.isCanceled&&L(!0)},onClick(xe){xe.stopPropagation()},onFocus(){ee.current?.focus()}},he=p.useMemo(()=>({...D,required:z,disabled:X,readOnly:U,checked:J}),[D,X,U,J,z]),ce=he,ye=k!==void 0,fe=[n,ee,te],Le=[oe,y,je,Q,O?xe=>O.getValidationProps(X,xe):yr],pe=Kt("span",t,{enabled:!ye,state:he,ref:fe,props:Le,stateAttributesMapping:iP});return r.jsxs(qH.Provider,{value:ce,children:[ye?r.jsx(VH,{tag:"span",render:s,className:i,style:b,state:he,refs:fe,props:Le,stateAttributesMapping:iP}):pe,r.jsx("input",{...le,suppressHydrationWarning:!0})]})}),Wye=p.forwardRef(function(t,n){const{render:s,className:i,style:o,keepMounted:l=!1,...u}=t,d=Gye(),f=d.checked,{mounted:m,transitionStatus:g,setMounted:v}=gu(f),b={...d,transitionStatus:g},y=p.useRef(null),k=l||m,w=Kt("span",t,{ref:[n,y],state:b,props:u,stateAttributesMapping:iP});return ji({batch:!0,enabled:!f,open:f,ref:y,onComplete(){f||v(!1)}}),k?w:null});function cP(e){const{children:t,elementsRef:n,labelsRef:s,onMapChange:i}=e,o=qe(i),[,l]=p.useState(!1),u=$s(Xye).current,d=$s(Yye).current,f=p.useRef(0),m=p.useRef(!0),g=p.useRef(null),v=p.useRef(null),b=qe(()=>{m.current||(m.current=!0,l(P=>!P))}),y=qe((P,O)=>{d.set(P,O),b()}),k=qe(P=>{d.delete(P),b()}),w=qe(P=>{const O=new Map;return n.current.length=0,s&&(s.current.length=0),P.forEach(A=>{O.set(A.element,{...A.registration.metadata??{},index:A.index}),n.current[A.index]=A.element,s&&(s.current[A.index]=A.registration.label!==void 0?A.registration.label:A.registration.textRef?.current?.textContent??A.element.textContent)}),f.current=n.current.length,O});function S(P){if(v.current?.disconnect(),v.current=null,typeof MutationObserver!="function"||P.length<2)return;const O=new MutationObserver(R=>{if(!Jye(R))return;let M=null;for(const _ of P)if(_.isConnected){if(M&&WH(M,_)>0){O.disconnect(),b();return}M=_}});v.current=O;const A=new Set;for(let R=1;RO.observe(R,{childList:!0}))}const N=qe(()=>{const[P,O]=Qye(d),A=w(P),R=g.current,M=!R||R.length!==P.length||P.some((_,L)=>{const $=R[L];return _.index!==$.index||_.element!==$.element||_.registration.index!==$.registration.index||_.registration.metadata!==$.registration.metadata});S(O),g.current=P,m.current=!1,M&&(u.forEach(_=>_(A)),o(A))});Ge(()=>(!m.current&&g.current&&w(g.current),()=>{n.current=[],s&&(s.current=[])}),[n,s,w]),Ge(()=>{m.current&&N()}),Ge(()=>()=>{v.current?.disconnect(),m.current=!0},[]);const C=qe(P=>(u.add(P),()=>{u.delete(P)})),T=p.useMemo(()=>({register:y,unregister:k,subscribeMapChange:C,nextIndexRef:f}),[y,k,C,f]);return r.jsx(HH.Provider,{value:T,children:t})}function Yye(){return new Map}function Xye(){return new Set}function Qye(e){const t=new Set,n=[],s=[];e.forEach((o,l)=>{if(!l.isConnected)return;const u=o.index,d={index:u??-1,element:l,registration:o};u===null?s.push(d):u>=0&&(t.add(u),n.push(d))});let i=0;return s.sort((o,l)=>WH(o.element,l.element)),s.forEach(o=>{for(;t.has(i);)i+=1;o.index=i,n.push(o),i+=1}),t.size>0&&n.sort((o,l)=>o.index-l.index),[n,s.map(o=>o.element)]}function Zye(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Jye(e){for(const t of e)for(let n=0;n{if(T.current=N.current[L]??null,(u??y)(L),$){const D=N.current[L];SH(w.current,D,o,n)}}),A=qe(L=>{if(L.size===0)return;if(C.current){const V=N.current,q=V.indexOf(T.current);if(q===-1){const Q=V[P];!Q||Bd(V,P,g)?O(tje(V,g)):T.current=Q}else q!==P&&O(q);return}C.current=!0;const $=Array.from(L.keys()),D=$.find(V=>V?.hasAttribute(oP))??null,F=D?L.get(D)?.index??-1:-1;if(F!==-1)O(F);else if(Bd($,P,g)){const V=Ta($,{disabledIndices:g});zd($,V)||O(V)}SH(w.current,D,o,n)});Ge(()=>{if(g==null||l!=null||!C.current)return;const L=N.current;if(Bd(L,P,g)){const $=Ta(L,{disabledIndices:g});zd(L,$)||O($)}},[g,l,P,N,O]);const R=qe((L,$,D)=>i?i(L,$,D,N):D),M=qe(L=>{const $=L.key===eP||L.key===tP;if(!gS.has(L.key)||!f&&$||nje(L,v)||!w.current)return;const F=o==="rtl",V=F?ZR:JR,q=F?JR:ZR,Q=n==="vertical"?QR:V,X=n==="vertical"?XR:q,U=Er(L.nativeEvent);if(U!=null&&kH(U)&&!YH(U)){const G=U.selectionStart,Y=U.selectionEnd,se=U.value;if(G==null||L.shiftKey||G!==Y||L.key!==X&&G0)return}let z=P;const K=Bk(N,g),J=nR(N,g);s!=null&&(z=s({disabledIndices:g,elementsRef:N,event:L,highlightedIndex:P,loopFocus:t,maxIndex:J,minIndex:K,onLoop:R,orientation:n,rtl:F}));const ee=n!=="vertical"&&L.key===V||n!=="horizontal"&&L.key===QR,H=n!=="vertical"&&L.key===q||n!=="horizontal"&&L.key===XR;f&&(L.key===eP?z=K:L.key===tP&&(z=J)),z===P&&(ee||H)&&(t&&z===J&&ee?(z=K,i&&(z=i(L,P,z,N))):t&&z===K&&H?(z=J,i&&(z=i(L,P,z,N))):z=Ta(N.current,{startingIndex:z,decrement:H,disabledIndices:g})),z!==P&&!zd(N.current,z)&&(m&&L.stopPropagation(),(k||$||ee||H)&&L.preventDefault(),O(z,!0),queueMicrotask(()=>{N.current[z]?.focus()}))});return{props:{ref:S,onFocus(L){const $=w.current,D=Er(L.nativeEvent);!$||D==null||!kH(D)||D.setSelectionRange(0,D.value.length)},onKeyDown:M},highlightedIndex:P,onHighlightedIndexChange:O,elementsRef:N,onMapChange:A,relayKeyboardEvent:M}}function tje(e,t){let n=-1;for(let s=0;s({highlightedIndex:M,onHighlightedIndexChange:_,highlightItemOnHover:T,relayKeyboardEvent:D}),[M,_,T,D]);return r.jsx(MF.Provider,{value:V,children:r.jsx(cP,{elementsRef:L,onMapChange:q=>{k?.(q),$(q)},children:F})})}const sje=[wH],XH=p.forwardRef(function(t,n){const{render:s,className:i,disabled:o,readOnly:l,required:u,onValueChange:d,value:f,defaultValue:m,form:g,name:v,inputRef:b,id:y,style:k,...w}=t,{setTouched:S,setFocused:N,validationMode:C,name:T,disabled:P,state:O,validation:A,setDirty:R,setFilled:M,validityData:_}=uo(),{labelId:L}=zi(),{clearErrors:$,elementRef:D}=uu(),F=BO(!0),V=P||o,q=T??v,Q=Ws(y),[X,U]=Tl({controlled:f,default:m,name:"RadioGroup",state:"value"}),[z,K]=p.useState(!1),J=qe((te,le)=>{d?.(te,le),!le.isCanceled&&U(te)}),ee=A.getInputControl,H=p.useMemo(()=>({get current(){return ee()}}),[ee]),G=p.useRef(null),Y=p.useRef(null);function se(te){let le;return b&&(typeof b=="function"?le=b(te):b.current=te),G.current=te,le}const re=qe(te=>{if(!te||te.disabled)return;Y.current||(Y.current=te);const le=G.current,he=te.checked||le==null||le.disabled?se(te):void 0;return()=>{Y.current===te&&(Y.current=null),G.current===te?he?(he(),G.current=null):se(null):he?.()}}),ne=qe(()=>{const te=D.current;if(!te)return X??null;for(const le of A.registeredInputs.keys())if(le.checked&&LU(le,te))return X??null;return null});hg(H,Q,X??null,ne,!V,v),Vo(X,()=>{$(q),R(X!==_.initialValue),M(X!=null),A.change(X);const te=Y.current;X==null&&te&&!te.disabled&&se(te)});const de=L??F?.legendId,ie={...O,disabled:V??!1,required:u??!1,readOnly:l??!1},oe=p.useMemo(()=>({checkedValue:X,disabled:V,form:g,validation:A,name:q,readOnly:l,registerInputRef:re,required:u,setCheckedValue:J,setTouched:K,touched:z}),[X,V,g,A,q,l,re,u,J,K,z]),je={id:y,role:"radiogroup","aria-required":u||void 0,"aria-disabled":V||void 0,"aria-readonly":l||void 0,"aria-labelledby":de,onFocus(){N(!0)},onBlur(te){Et(te.currentTarget,te.relatedTarget)||(S(!0),N(!1),C==="onBlur"&&A.commit(X))},onKeyDownCapture(te){te.key.startsWith("Arrow")&&(K(!0),N(!0))}};return r.jsx(KH.Provider,{value:oe,children:r.jsx(rje,{render:s,className:i,style:k,state:ie,props:[je,w,te=>A.getValidationProps(V??!1,te)],refs:[n],stateAttributesMapping:hc,enableHomeAndEndKeys:!1,modifierKeys:sje})})});function bg({className:e,...t}){return r.jsx(XH,{"data-slot":"radio-group",className:Ne("flex flex-col gap-2",e),...t})}function Mh({className:e,children:t,...n}){return r.jsxs(GH,{"data-slot":"radio-group-item",className:Ne("relative inline-flex size-3.5 flex-none cursor-pointer items-center justify-center rounded-full border border-control-border bg-control","outline-none transition-colors duration-150 ease-out","hover:border-control-border-hover","data-checked:border-primary data-checked:bg-primary","focus-visible:shadow-focus","data-disabled:cursor-not-allowed data-disabled:opacity-45",e),...n,children:[t,r.jsx(Wye,{"data-slot":"radio-group-indicator",className:"grid place-content-center data-unchecked:hidden",children:r.jsx("span",{className:"block size-[5px] rounded-full bg-primary-foreground"})})]})}function QH(e){const t=p.useRef(!0);t.current&&(t.current=!1,e())}const ZH=p.createContext(void 0),JH=p.createContext(void 0),eV=p.createContext(void 0);function Vd(){const e=p.useContext(ZH);if(e===void 0)throw new Error(Vn(60));return e}function uP(){const e=p.useContext(JH);if(e===void 0)throw new Error(Vn(101));return e}function tV(){const e=p.useContext(eV);if(e===void 0)throw new Error(Vn(61));return e}function aje(e,t,n=Object.is){const{length:s}=e;if(s!==t.length)return!1;for(let i=0;iObject.is(e,t);function Ko(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function nV(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!aje(e,t,(s,i)=>Ko(s,i,n)):e!==t}function wS(e,t,n){return e?e.some(s=>s===void 0?!1:Ko(t,s,n)):!1}function yg(e,t,n){return e?e.findIndex(s=>s===void 0?!1:Ko(s,t,n)):-1}function ije(e,t){if(t!==jS)return s=>wS(e,s,t);const n=new Set(e);return n.delete(void 0),s=>n.has(s)&&(s!==0||e.some(i=>Object.is(s,i)))}function Wb(e,t,n,s){const i=s&&Array.isArray(t)?e.findIndex(ije(t,n)):yg(e,t,n);return i===-1?null:i}function rV(e,t,n,s,i,o){return wS(s,t,i)?o!=null&&e>o&&wS(s,n[o],i)?o:e:e===o?Wb(n,s,i,!0):o}function sV(e,t,n){return e.filter(s=>!Ko(t,s,n))}function oje(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function dP(e){return oje(e?.[0])}function kS(e){return dP(e)?e.flatMap(t=>t.items):e}function aV(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(dP(t)){for(const n of t)for(const s of n.items)if(s&&s.value==null&&s.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function Kd(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return yS(e)}function Rl(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?yS(e.value):yS(e)}function fP(e,t,n){function s(){return Kd(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??s();if(Array.isArray(t)){const o=kS(t);if(e==null||typeof e!="object"){const l=o.find(u=>u.value===e);return l&&l.label!=null?l.label:s()}if("value"in e){const l=o.find(u=>u&&u.value===e.value);if(l&&l.label!=null)return l.label}}return s()}function iV(e,t,n){return e.reduce((s,i,o)=>(o>0&&s.push(", "),s.push(r.jsx(p.Fragment,{children:fP(i,t,n)},o)),s),[])}const lje={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:s}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Rl(t,s)!==""},hasNullItemLabel:(e,t)=>t?aV(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,s=e.value;return e.multiple?Array.isArray(s)&&s.some(i=>Ko(t,i,n)):Ko(t,s,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},yu=1;function oV(e,t){return Math.max(0,e-t)}function cje(e,t){if(t<=0)return 0;const n=bu(e,0,t),s=n,i=t-n,o=s<=yu,l=i<=yu;return o&&l?s<=i?0:t:o?0:l?t:n}function uje(e){const{id:t,value:n,defaultValue:s=null,onValueChange:i,open:o,defaultOpen:l=!1,onOpenChange:u,name:d,form:f,autoComplete:m,disabled:g=!1,readOnly:v=!1,required:b=!1,modal:y=!0,actionsRef:k,inputRef:w,onOpenChangeComplete:S,items:N,multiple:C=!1,itemToStringLabel:T,itemToStringValue:P,isItemEqualToValue:O=jS,highlightItemOnHover:A=!0,children:R}=e,{clearErrors:M}=uu(),{setDirty:_,setTouched:L,setFocused:$,validityData:D,setFilled:F,name:V,disabled:q,validation:Q,validationMode:X}=uo(),U=_d({id:t}),z=q||g,K=V??d,[J,ee]=Tl({controlled:n,default:C?s??co:s,name:"Select",state:"value"}),[H,G]=Tl({controlled:o,default:l,name:"Select",state:"open"}),Y=p.useRef([]),se=p.useRef([]),re=p.useRef(null),ne=p.useRef(null),de=p.useRef(0),ie=p.useRef(null),oe=p.useRef([]),je=p.useRef(!1),te=p.useRef(null),le=p.useRef(null),he=p.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ce=p.useRef(!1),ye=p.useRef(J),{mounted:fe,setMounted:Le,transitionStatus:pe}=gu(H),{openMethod:xe,triggerProps:Se}=IH(H),ge=$s(()=>new Ph({id:U,labelId:void 0,modal:y,multiple:C,itemToStringLabel:T,itemToStringValue:P,isItemEqualToValue:O,value:J,open:H,mounted:fe,transitionStatus:pe,items:N,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:yr,triggerProps:yr,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Xn,setOpen:Xn,handleScrollArrowVisibility:Xn,onOpenChangeComplete:Xn,listRef:Y,popupRef:re,scrollHandlerRef:ne,scrollArrowsMountedCountRef:de,valueRef:ie,valuesRef:oe,labelsRef:se,typingRef:je,selectionRef:he,firstItemTextRef:te,selectedItemTextRef:le,alignItemWithTriggerActiveRef:ce,initialValueRef:ye},lje)).current,ue=ge.useState("activeIndex"),be=ge.useState("selectedIndex"),ve=ge.useState("triggerElement"),De=ge.useState("positionerElement"),Ie=mye(xe),We=xe??Ie,nt=p.useMemo(()=>C?"":Rl(J,P),[C,J,P]),kt=p.useMemo(()=>C&&Array.isArray(J)?J.map(xn=>Rl(xn,P)):Rl(J,P),[C,J,P]),Je=ss(ve),on=qe(()=>kt);hg(Je,U,J,on,!z,d);const nn=C?Array.isArray(J)&&J.length>0:J!=null&&nt!=="";Ge(()=>{F(nn)},[nn,F]),Ge(function(){const jn=Wb(oe.current,J,O,C);jn===null&&(le.current=null),!H&&ge.set("selectedIndex",jn)},[C,H,J,O,ge]),Vo(J,()=>{M(K),_(nV(J,D.initialValue,O)),Q.change(J)});const On=qe((xn,jn)=>{u?.(xn,jn),!jn.isCanceled&&(G(xn),!xn&&(jn.reason===Fd||jn.reason===Wk)&&(L(!0),$(!1),X==="onBlur"&&Q.commit(J)))}),Rn=qe(()=>{Le(!1),ge.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),S?.(!1)});ji({enabled:!k,open:H,ref:re,onComplete(){H||Rn()}}),p.useImperativeHandle(k,()=>({unmount:Rn}),[Rn]);const gt=qe((xn,jn)=>{i?.(xn,jn),!jn.isCanceled&&ee(xn)}),sn=qe(xn=>{const jn=oV(xn.scrollHeight,xn.clientHeight),ke=cje(xn.scrollTop,jn),Xe=ke>0,Qe=keYH(Y.current[xn]),onMatch(xn){H?ge.set("activeIndex",xn):gt(oe.current[xn],Nt(rs))},onTyping(xn){je.current=xn}}),jt=p.useMemo(()=>oo(Ht.reference,Tt.reference,ht.reference,zt.reference,Se),[zt.reference,Ht.reference,Tt.reference,ht.reference,Se]),an=p.useMemo(()=>oo(Ub,Ht.floating,Tt.floating,ht.floating),[Ht.floating,Tt.floating,ht.floating]),Xt=Tt.item??yr;ge.useContextCallback("setValue",gt),ge.useContextCallback("setOpen",On),ge.useContextCallback("handleScrollArrowVisibility",sn),ge.useContextCallback("onOpenChangeComplete",S),QH(()=>{ge.update({popupProps:an,triggerProps:jt})}),ge.useSyncedValues({id:U,modal:y,multiple:C,value:J,open:H,mounted:fe,transitionStatus:pe,popupProps:an,triggerProps:jt,items:N,itemToStringLabel:T,itemToStringValue:P,isItemEqualToValue:O,openMethod:We});const gn=p.useMemo(()=>({disabled:z,readOnly:v,required:b,multiple:C,highlightItemOnHover:A,itemProps:Xt}),[z,v,b,C,A,Xt]),un=lo(w,Q.inputRef),lr=C?void 0:K,yn=p.useMemo(()=>!C||!Array.isArray(J)||!K?null:J.map(xn=>{const jn=Rl(xn,P);return r.jsx("input",{type:"hidden",form:f,name:K,value:jn,disabled:z},jn)}),[C,J,f,K,P,z]);return r.jsxs(ZH.Provider,{value:ge,children:[r.jsx(JH.Provider,{value:gn,children:r.jsx(eV.Provider,{value:Ke,children:R})}),r.jsx("input",{...Q.getValidationProps(z,{onFocus(){ge.state.triggerElement?.focus({focusVisible:!0})},onChange(xn){if(xn.nativeEvent.defaultPrevented||z||v)return;const jn=xn.currentTarget.value,ke=Nt(rs,xn.nativeEvent);function Xe(){if(C)return;const Qe=jn.toLowerCase();let Yt=oe.current.findIndex(fn=>Rl(fn,P).toLowerCase()===Qe||Kd(fn,T).toLowerCase()===Qe);Yt===-1&&(Yt=oe.current.findIndex((fn,At)=>{const Re=se.current[At];return Re!=null&&Re.toLowerCase()===Qe}));const Rt=oe.current[Yt];Rt!=null&>(Rt,ke)}ge.set("forceMount",!0),queueMicrotask(Xe)}}),id:U&&lr==null?`${U}-hidden-input`:void 0,form:f,name:lr,autoComplete:m,value:nt,disabled:z,required:b&&!(C&&nn),readOnly:v,ref:un,style:K?pg:vu,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),yn]})}function lV(e,t){return e??t}const SS=5;function cV(e,t){const n=dje(t);return e.clientX>=n.left-SS&&e.clientX<=n.right+SS&&e.clientY>=n.top-SS&&e.clientY<=n.bottom+SS}function dje(e){const t=e.getBoundingClientRect(),n=vr(e);if(UO)return t;const s=n.getComputedStyle(e,"::before"),i=n.getComputedStyle(e,"::after");if(!(s.content!=="none"||i.content!=="none"))return t;const l=parseFloat(s.width)||0,u=parseFloat(s.height)||0,d=parseFloat(i.width)||0,f=parseFloat(i.height)||0,m=Math.max(t.width,l,d),g=Math.max(t.height,u,f),v=m-t.width,b=g-t.height;return{left:t.left-v/2,right:t.right+v/2,top:t.top-b/2,bottom:t.bottom+b/2}}const fje="data-popup-side",hje=400,mje={...qO,...hc,popupSide:e=>e?{[fje]:e}:null,value:()=>null},pje=p.forwardRef(function(t,n){const{render:s,className:i,id:o,disabled:l=!1,nativeButton:u=!0,style:d,...f}=t,{setTouched:m,setFocused:g,validationMode:v,validation:b,state:y,disabled:k}=uo(),{labelId:w}=zi(),S=Vd(),{readOnly:N,required:C,disabled:T}=uP(),P=k||T||l,O=S.useState("open"),A=S.useState("mounted"),R=S.useState("value"),M=S.useState("triggerProps"),_=S.useState("positionerElement"),L=S.useState("listElement"),$=S.useState("popupSide"),D=S.useState("id"),F=S.useState("labelId"),V=S.useState("hasSelectedValue"),q=A&&_?$:null,Q=o??D,X=lV(w,F);_d({id:o});const U=ss(_),z=p.useRef(null),{getButtonProps:K,buttonRef:J}=$i({disabled:P,native:u}),ee=S.useStateSetter("triggerElement"),H=fa(),G=fa(),Y=fa();p.useEffect(()=>{if(O)return Y.start(hje,()=>{S.context.selectionRef.current.allowUnselectedMouseUp=!0,S.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{Y.clear()};S.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},G.clear()},[O,S,G,Y]);const se=oo(M,{id:Q,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?L?.id??_k(_)?.id:void 0,"aria-labelledby":X,"aria-readonly":N||void 0,"aria-required":C||void 0,tabIndex:P?-1:0,onFocus(de){g(!0),O&&S.context.alignItemWithTriggerActiveRef.current&&S.context.setOpen(!1,Nt(rs,de.nativeEvent)),H.start(0,()=>{S.set("forceMount",!0)})},onBlur(de){Et(_,de.relatedTarget)||(m(!0),g(!1),v==="onBlur"&&b.commit(R))},onMouseDown(de){if(O)return;const ie=_n(de.currentTarget);function oe(je){if(!z.current)return;const te=je.target;Et(z.current,te)||Et(U.current,te)||cV(je,z.current)||S.context.setOpen(!1,Nt(UU,je))}G.start(0,()=>{ie.addEventListener("mouseup",oe,{once:!0})})}},f,K),re=b.getValidationProps(P,se);re.role="combobox";const ne={...y,open:O,disabled:P,value:R,readOnly:N,popupSide:q,placeholder:!V};return Kt("button",t,{ref:[n,z,J,ee],state:ne,stateAttributesMapping:mje,props:re})}),gje={value:()=>null},xje=p.forwardRef(function(t,n){const{className:s,render:i,children:o,placeholder:l,style:u,...d}=t,f=Vd(),m=f.useState("value"),g=f.useState("items"),v=f.useState("itemToStringLabel"),b=f.useState("hasSelectedValue"),y=!b&&l!=null&&o==null,k=f.useState("hasNullItemLabel",y),w={value:m,placeholder:!b};let S=null;return typeof o=="function"?S=o(m):o!=null?S=o:y&&!k?S=l:Array.isArray(m)?S=iV(m,g,v):S=fP(m,g,v),Kt("span",t,{state:w,ref:[n,f.context.valueRef],props:[{children:S},d],stateAttributesMapping:gje})}),vje=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,f={open:Vd().useState("open")};return Kt("span",t,{state:f,ref:n,props:[{"aria-hidden":!0,children:"▼"},l],stateAttributesMapping:Rk})}),bje=p.forwardRef(function(t,n){const s=Vd(),i=s.useState("mounted"),o=s.useState("forceMount");return i||o?r.jsx(eS,{ref:n,...t}):null}),uV=p.createContext(void 0);function yje(){const e=p.useContext(uV);if(!e)throw new Error(Vn(59));return e}function NS(e,t){e&&Object.assign(e.style,t)}const jje={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},wje=20;function hP(e,t,n,s){const[i,o]=p.useState(!1);Ge(()=>{if(!e||!t||n==null){o(!1);return}const l=_n(n).documentElement.clientWidth,u=n.offsetWidth;o(l>0&&u>0&&u>=l-wje)},[e,t,n]),OH(e&&(!t||i),s)}const kje={position:"fixed"},Sje=p.forwardRef(function(t,n){const{anchor:s,className:i,render:o,positionMethod:l,side:u,align:d,sideOffset:f,alignOffset:m,collisionBoundary:g="clipping-ancestors",collisionPadding:v,arrowPadding:b,sticky:y,disableAnchorTracking:k,alignItemWithTrigger:w=!0,collisionAvoidance:S=h6,style:N,...C}=t,T=Vd(),P=tV(),O=T.useState("open"),A=T.useState("mounted"),R=T.useState("modal"),M=T.useState("value"),_=T.useState("openMethod"),L=T.useState("positionerElement"),$=T.useState("triggerElement"),D=T.useState("isItemEqualToValue"),F=T.useState("transitionStatus"),V=p.useRef(null),q=p.useRef(null),[Q,X]=p.useState(w),U=A&&Q&&_!=="touch";!A&&Q!==w&&X(w),p.useImperativeHandle(T.context.alignItemWithTriggerActiveRef,()=>U),hP((U||R)&&O,_==="touch",L,$);const z=hS({anchor:s,floatingRootContext:P,positionMethod:l,mounted:A,side:u,sideOffset:f,align:d,alignOffset:m,arrowPadding:b,collisionBoundary:g,collisionPadding:v,sticky:y,disableAnchorTracking:k??U,collisionAvoidance:S,keepMounted:!0}),K=U?"none":z.side,J=U?kje:z.positionerStyles,ee={open:O,side:K,align:z.align,anchorHidden:z.anchorHidden};Ge(()=>{T.set("popupSide",z.side)},[T,z.side]);const H=T.useStateSetter("positionerElement"),G=mS(t,ee,{styles:J,transitionStatus:F,props:C,refs:[n,H],hidden:!A,inert:!O}),Y=p.useRef(0),se=qe(ne=>{if(T.context.valuesRef.current.length===0)return;const de=Y.current;Y.current=ne.size;const ie=Nt(rs);if(de!==0&&!T.state.multiple&&M!==null&&yg(T.context.valuesRef.current,M,D)===-1){const je=T.context.initialValueRef.current,le=je!=null&&yg(T.context.valuesRef.current,je,D)!==-1?je:null;T.context.setValue(le,ie),le===null&&(T.set("selectedIndex",null),T.context.selectedItemTextRef.current=null)}if(de!==0&&T.state.multiple&&Array.isArray(M)){const oe=M.filter(je=>yg(T.context.valuesRef.current,je,D)!==-1);oe.length!==M.length&&(T.context.setValue(oe,ie),oe.length===0&&(T.set("selectedIndex",null),T.context.selectedItemTextRef.current=null))}if(O&&U){T.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const oe={height:""};NS(L,oe),NS(T.context.popupRef.current,oe)}}),re=p.useMemo(()=>({...z,side:K,alignItemWithTriggerActive:U,setControlledAlignItemWithTrigger:X,scrollUpArrowRef:V,scrollDownArrowRef:q}),[z,K,U,X]);return r.jsx(cP,{elementsRef:T.context.listRef,labelsRef:T.context.labelsRef,onMapChange:se,children:r.jsxs(uV.Provider,{value:re,children:[A&&R&&r.jsx(vS,{inert:qb(!O),cutout:$}),G]})})}),CS="base-ui-disable-scrollbar",dV={className:CS,getElement(e){return r.jsx("style",{nonce:e,href:CS,precedence:"base-ui:low",children:`.${CS}{scrollbar-width:none}.${CS}::-webkit-scrollbar{display:none}`})}},Nje=p.createContext(void 0);function fV(e){return p.useContext(Nje)}const Cje=p.createContext(void 0),Aje={disableStyleElements:!1};function Eje(){return p.useContext(Cje)??Aje}const hV="--transform-origin",Tje={...cg,...Fo},Oje=p.forwardRef(function(t,n){const{render:s,className:i,style:o,finalFocus:l,...u}=t,d=Vd(),{multiple:f,readOnly:m,highlightItemOnHover:g}=uP(),v=tV(),{side:b,align:y,alignItemWithTriggerActive:k,isPositioned:w,setControlledAlignItemWithTrigger:S}=yje(),N=fV()!=null,C=Vb(),{nonce:T,disableStyleElements:P}=Eje(),O=d.useState("id"),A=d.useState("open"),R=d.useState("openMethod"),M=d.useState("mounted"),_=d.useState("popupProps"),L=d.useState("transitionStatus"),$=d.useState("triggerElement"),D=d.useState("positionerElement"),F=d.useState("listElement"),V=p.useRef(!1),q=p.useRef(!1),Q=p.useRef({}),X=fg(),U=qe(ee=>{if(!D||!d.context.popupRef.current||!q.current)return;const H=D.style.top==="0px",G=D.style.bottom==="0px";if(V.current||!k||!H&&!G){d.context.handleScrollArrowVisibility(ee);return}const Y=pV(D),se=Yb(D.getBoundingClientRect().height,"y",Y),re=_n(D),ne=vr(D),de=ne.getComputedStyle(D),ie=parseFloat(de.marginTop),oe=parseFloat(de.marginBottom),je=mV(ne.getComputedStyle(d.context.popupRef.current)),te=Math.min(re.documentElement.clientHeight-ie-oe,je),le=ee.scrollTop,he=AS(ee);let ce=null;const ye=xe=>{D.style.height=`${xe}px`},fe=H?he-le:le,Le=Math.min(se+fe,te);if(fe<=yu){const xe=bu(fe,0,te-se);xe>0&&ye(se+xe),ee.scrollTop=H?he:0,te-(se+xe)<=yu&&(V.current=!0),d.context.handleScrollArrowVisibility(ee);return}if(te-Le>yu)ce=H?1/0:0;else if(G&&leyu&&(ee.scrollTop=xe)}pe>=te-yu&&(V.current=!0),d.context.handleScrollArrowVisibility(ee)});p.useImperativeHandle(d.context.scrollHandlerRef,()=>U,[U]),ji({open:A,ref:d.context.popupRef,onComplete(){A&&d.context.onOpenChangeComplete(!0)}});const z={open:A,transitionStatus:L,side:b,align:y};Ge(()=>{!D||!d.context.popupRef.current||Object.keys(Q.current).length||(Q.current={top:D.style.top||"0",left:D.style.left||"0",right:D.style.right,height:D.style.height,bottom:D.style.bottom,minHeight:D.style.minHeight,maxHeight:D.style.maxHeight,marginTop:D.style.marginTop,marginBottom:D.style.marginBottom})},[d,D]),Ge(()=>{A||k||(q.current=!1,V.current=!1,NS(D,Q.current))},[A,k,D]),Ge(()=>{const ee=d.context.popupRef.current;if(!A||!$||!D||!ee||k&&!w||d.state.transitionStatus==="ending")return;if(q.current=!0,ee.style.removeProperty(hV),!k){X.request(()=>d.context.handleScrollArrowVisibility(F||ee));return}const H=Rje(ee);try{let G=d.context.selectedItemTextRef.current;G?.isConnected||(G=!d.select("hasSelectedValue")&&d.context.firstItemTextRef.current?.isConnected?d.context.firstItemTextRef.current:null);const Y=d.context.valueRef.current,se=vr(D),re=se.getComputedStyle(D),ne=se.getComputedStyle(ee),de=_n($),ie=pV($),oe=ES($.getBoundingClientRect(),ie),je=ES(D.getBoundingClientRect(),ie),te=oe.height,le=F||ee,he=le.scrollHeight,ce=parseFloat(ne.borderBottomWidth),ye=parseFloat(re.marginTop)||10,fe=parseFloat(re.marginBottom)||10,Le=parseFloat(re.minHeight)||100,pe=mV(ne),xe=5,Se=5,ge=20,ue=de.documentElement.clientHeight-ye-fe,be=de.documentElement.clientWidth,ve=ue-oe.bottom+te;let De,Ie=C==="rtl"?oe.right-je.width:oe.left,We=0;if(G&&Y){const zt=ES(Y.getBoundingClientRect(),ie);De=ES(G.getBoundingClientRect(),ie),Ie=je.left+(C==="rtl"?zt.right-De.right:zt.left-De.left);const ht=zt.top-oe.top+zt.height/2;We=De.top-je.top+De.height/2-ht}const nt=ve+We+fe+ce;let kt=Math.min(ue,nt);const Je=ue-ye-fe,on=nt-kt,nn=be-Se;D.style.left=`${bu(Ie,xe,nn-je.width)}px`,D.style.height=`${kt}px`,D.style.maxHeight="none",D.style.marginTop=`${ye}px`,D.style.marginBottom=`${fe}px`,ee.style.height="100%";const On=AS(le),Rn=on>=On-yu;Rn&&(kt=Math.min(ue,je.height)-(on-On));const gt=oe.topue-ge||Math.ceil(kt)+yu=Je?"0":`${zt}px`,D.style.height=`${kt}px`,le.scrollTop=AS(le)}else D.style.bottom="0",le.scrollTop=on;if(De){const zt=je.top,ht=je.height,Tt=De.top+De.height/2,Ht=bu(ht>0?(Tt-zt)/ht*100:50,0,100);ee.style.setProperty(hV,`50% ${Ht}%`)}(Ke===ue||kt>=pe)&&(V.current=!0),d.context.handleScrollArrowVisibility(le),g&&d.state.selectedIndex===null&&d.state.activeIndex===null&&d.context.listRef.current[0]!=null&&d.set("activeIndex",0)}finally{H()}},[d,A,D,$,k,S,X,F,g,C,w]),p.useEffect(()=>{if(!k||!D||!A)return;const ee=vr(D);function H(G){d.context.setOpen(!1,Nt(Nxe,G))}return kn(ee,"resize",H)},[d,k,D,A]);const K={...F?{role:"presentation"}:{role:"listbox","aria-multiselectable":f||void 0,"aria-readonly":m||void 0,id:`${O}-list`},onKeyDown(ee){N&&gS.has(ee.key)&&ee.stopPropagation()},onScroll(ee){F||U(ee.currentTarget)},...k&&{style:F?{height:"100%"}:jje},className:!F&&k?dV.className:void 0},J=Kt("div",t,{ref:[n,d.context.popupRef],state:z,stateAttributesMapping:Tje,props:[_,K,Kb(L),u]});return r.jsxs(p.Fragment,{children:[!P&&dV.getElement(T),r.jsx(tS,{context:v,modal:!1,disabled:!M,openInteractionType:R,returnFocus:l,restoreFocus:!0,children:J})]})});function mV(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function AS(e){return oV(e.scrollHeight,e.clientHeight)}function pV(e){return M6.getScale(e)}function Yb(e,t,n){return e/n[t]}function ES(e,t){return Rb({x:Yb(e.x,"x",t),y:Yb(e.y,"y",t),width:Yb(e.width,"x",t),height:Yb(e.height,"y",t)})}const gV=[["transform","none"],["scale","1"],["translate","0 0"]];function Rje(e){const{style:t}=e,n={};for(const[s,i]of gV)n[s]=t.getPropertyValue(s),t.setProperty(s,i,"important");return()=>{for(const[s]of gV){const i=n[s];i?t.setProperty(s,i):t.removeProperty(s)}}}const xV=p.createContext(void 0);function mP(){const e=p.useContext(xV);if(!e)throw new Error(Vn(57));return e}const Pje=p.memo(p.forwardRef(function(t,n){const{render:s,className:i,style:o,value:l=null,label:u,disabled:d=!1,nativeButton:f=!1,...m}=t,g=p.useRef(null),v=lP({guess:!0,label:u,textRef:g}),b=Vd(),{itemProps:y,multiple:k,disabled:w,readOnly:S}=uP(),N=w||d,C=b.useState("isActive",v.index),T=b.useState("open"),P=b.useState("isSelected",l),O=b.useState("isSelectedByFocus",v.index),A=b.useState("isItemEqualToValue"),R=v.index,M=p.useRef(null);Ge(()=>{const z=b.context.valuesRef.current;return z[R]=l,()=>{delete z[R]}},[R,l,b]),Ge(()=>{const z=b.state.value,K=b.state.selectedIndex;let J=K,ee;k&&Array.isArray(z)?(J=rV(R,l,b.context.valuesRef.current,z,A,K),ee=J===R,R===K&&!ee&&(b.context.selectedItemTextRef.current=null)):(ee=z!==void 0&&Ko(l,z,A),ee&&(J=R)),b.set("selectedIndex",J),ee&&g.current&&(b.context.selectedItemTextRef.current=g.current)},[R,k,A,b,l]);const _=p.useRef("mouse"),L=p.useRef(!1),{getButtonProps:$,buttonRef:D}=$i({disabled:N,focusableWhenDisabled:!0,native:f,composite:!0}),F={disabled:N,selected:P,highlighted:C};function V(z){if(w||S)return;const K=b.state.value;if(k){const J=Array.isArray(K)?K:[],ee=P?sV(J,l,A):[...J,l];b.context.setValue(ee,Nt(Mb,z))}else b.context.setValue(l,Nt(Mb,z)),b.context.setOpen(!1,Nt(Mb,z))}function q(){b.context.selectionRef.current.dragY=0}const Q={role:"option","aria-selected":P,tabIndex:T&&C?0:-1,onKeyDown(z){b.set("activeIndex",R),z.key===" "&&b.context.typingRef.current&&z.preventDefault()},onClick(z){const K=_.current!=="touch",J=z.nativeEvent.pointerType,ee=K&&Dk(z.nativeEvent)&&(J!==void 0||C),H=K&&!ee&&!L.current;L.current=!1,!(N||H)&&V(z.nativeEvent)},onPointerEnter(z){_.current=z.pointerType},onPointerMove(z){if(z.pointerType==="mouse"&&z.buttons===1){const K=b.context.selectionRef.current;K.dragY+=z.movementY,K.dragY**2>=64&&(K.allowUnselectedMouseUp=!0)}},onPointerDown(z){_.current=z.pointerType,L.current=!0,q()},onMouseUp(){if(q(),N||_.current==="touch"||L.current)return;const z=!b.context.selectionRef.current.allowSelectedMouseUp&&P,K=!b.context.selectionRef.current.allowUnselectedMouseUp&&!P;z||K||(L.current=!0,M.current?.click(),L.current=!1)}},X=Kt("div",t,{ref:[D,n,v.ref,M],state:F,props:[y,Q,m,$]}),U=p.useMemo(()=>({selected:P,index:R,textRef:g,selectedByFocus:O}),[P,R,g,O]);return r.jsx(xV.Provider,{value:U,children:X})})),Ije=p.forwardRef(function(t,n){const{selected:s}=mP();return t.keepMounted||s?r.jsx(Mje,{...t,ref:n}):null}),Mje=p.memo(p.forwardRef((e,t)=>{const{render:n,className:s,style:i,keepMounted:o,...l}=e,{selected:u}=mP(),d=p.useRef(null),{transitionStatus:f,setMounted:m}=gu(u),v=Kt("span",e,{ref:[t,d],state:{selected:u,transitionStatus:f},props:[{"aria-hidden":!0,children:"✔️"},l],stateAttributesMapping:Fo});return ji({batch:!0,enabled:!u,open:u,ref:d,onComplete(){u||m(!1)}}),v})),_je=p.memo(p.forwardRef(function(t,n){const{index:s,textRef:i,selectedByFocus:o}=mP(),l=Vd(),{render:u,className:d,style:f,...m}=t,g=p.useCallback(b=>{b&&(s===0&&(l.context.firstItemTextRef.current=b),o&&(l.context.selectedItemTextRef.current=b))},[l,s,o]);return Kt("div",t,{ref:[g,n,i],props:m})})),vV=p.createContext(void 0);function Dje(){const e=p.useContext(vV);if(e===void 0)throw new Error(Vn(56));return e}const Lje=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,[u,d]=p.useState(),f=p.useMemo(()=>({labelId:u,setLabelId:d}),[u,d]),m=Kt("div",t,{ref:n,props:[{role:"group","aria-labelledby":u},l]});return r.jsx(vV.Provider,{value:f,children:m})}),$je=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,...u}=t,{setLabelId:d}=Dje(),f=Ws(l);return Ge(()=>(d(f),()=>{d(g=>g===f?void 0:g)}),[f,d]),Kt("div",t,{ref:n,props:[{id:f,"aria-hidden":!0},u]})}),zje=p.forwardRef(function(t,n){const{className:s,render:i,orientation:o="horizontal",style:l,...u}=t;return Kt("div",t,{state:{orientation:o},ref:n,props:[{role:"presentation"},u]})});function bV(e,t){const[n,s]=p.useState();return p.useLayoutEffect(()=>{if(!t)return;const i=e?.closest('[role="dialog"], [role="alertdialog"]'),o=e?.ownerDocument.defaultView;if(!e||!i||!o){s(void 0);return}const l=[i];for(let u=e.parentElement;u&&u!==i;u=u.parentElement){const d=o.getComputedStyle(u);(/(auto|scroll)/.test(`${d.overflowX} ${d.overflowY}`)||u.matches('[data-slot="dialog-body"], [data-slot="sheet-body"], [data-slot="alert-dialog-body"]'))&&l.push(u)}s(l)},[e,t]),n}const TS=p.createContext(null);function Pt({open:e,defaultOpen:t=!1,onOpenChange:n,children:s,...i}){const[o,l]=p.useState(t),[u,d]=p.useState(null),[f,m]=p.useState(!1),g=e??o;p.useLayoutEffect(()=>{g&&m(!1)},[g]);const v=p.useCallback((k,w)=>{n?.(k,w),!w.isCanceled&&(k&&m(!1),l(k))},[n]),b=p.useCallback(()=>{if(!g||f)return;const k=Nt("none",void 0,u??void 0);v(!1,k),k.isCanceled||m(!0)},[g,f,u,v]),y=p.useMemo(()=>({open:g,trigger:u,setTrigger:d,closeOnAnchorHidden:b,closedOnAnchorHidden:f}),[g,u,b,f]);return r.jsx(TS.Provider,{value:y,children:r.jsx(uje,{...i,open:g,onOpenChange:v,children:s})})}function Bje({anchorHidden:e,open:t,...n}){const i=p.useContext(TS)?.closeOnAnchorHidden;return p.useLayoutEffect(()=>{t&&e&&i?.()},[t,e,i]),r.jsx("div",{...n})}const It=xje,Fje=Lje,Uje=$je,Hje=zje;function Mt({className:e,children:t,ref:n,...s}){const i=p.useContext(TS);return Ah({render:r.jsx(pje,{}),ref:[n??null,i?.setTrigger??null],props:{...s,"data-slot":"select-trigger",className:Ne("inline-flex h-[30px] min-w-0 cursor-pointer items-center justify-between gap-1.5 rounded-md border border-control-border bg-control px-2.5","[&>span]:min-w-0 [&>span]:truncate","text-[12.5px] font-normal text-foreground max-[767px]:h-10 max-[767px]:text-base","transition-colors duration-150 ease-out","hover:border-control-border-hover hover:bg-control-hover","focus-visible:border-primary focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:bg-control data-disabled:text-muted-foreground data-disabled:opacity-60",e),children:r.jsxs(r.Fragment,{children:[t,r.jsx(vje,{className:"flex flex-none text-muted-foreground transition-transform duration-[180ms] data-popup-open:rotate-180",children:r.jsx("svg",{viewBox:"0 0 10 6",className:"size-2.5","aria-hidden":"true",children:r.jsx("path",{d:"M1 1l4 4 4-4",stroke:"currentColor",strokeWidth:"1.4",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}})}function _t({className:e,sideOffset:t=4,children:n,finalFocus:s,...i}){const o=p.useContext(TS),l=bV(o?.trigger??null,o?.open??!1);return r.jsx(bje,{children:r.jsx(Sje,{sideOffset:t,alignItemWithTrigger:!1,collisionBoundary:l,className:"z-[35] data-anchor-hidden:invisible data-anchor-hidden:pointer-events-none",render:(u,d)=>r.jsx(Bje,{...u,anchorHidden:d.anchorHidden,open:d.open}),children:r.jsx(Oje,{"data-slot":"select-content",className:Ne("max-h-[min(260px,var(--available-height))] min-w-[min(var(--anchor-width),var(--available-width))] max-w-[var(--available-width)] overflow-y-auto overscroll-contain rounded-lg border border-border-strong bg-raised p-[5px] shadow-3","outline-none","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0",e),finalFocus:o?.closedOnAnchorHidden?!1:s,...i,children:n})})})}function Ze({className:e,children:t,...n}){return r.jsxs(Pje,{"data-slot":"select-item",className:Ne("flex min-h-7 cursor-pointer items-center gap-2 rounded-sm px-[9px] text-[12.5px] leading-[1.4] text-foreground select-none","transition-colors duration-[120ms] ease-out","data-[highlighted]:bg-nav-hover","data-[selected]:bg-primary-soft data-[selected]:font-semibold data-[selected]:text-primary-fg","data-[highlighted]:data-[selected]:bg-primary-tint","data-disabled:pointer-events-none data-disabled:font-normal data-disabled:text-muted-foreground",e),...n,children:[r.jsx(_je,{className:"min-w-0 flex-1 truncate",children:t}),r.jsx(Ije,{className:"flex flex-none text-primary",children:r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}function Vje(e,t,n,s,i,o,l,u,d,f=2){const m=txe(n.current,{event:e,orientation:s,loopFocus:i,rtl:o,cols:f,disabledIndices:l,minIndex:u,maxIndex:d,prevIndex:t>d?u:t,stopEvent:!0});return zd(n.current,m)?void 0:m}const yV=p.createContext(void 0),jV=p.createContext(void 0),wV=p.createContext(void 0),kV=p.createContext(!1),SV=p.createContext("");function qo(){const e=p.useContext(yV);if(!e)throw new Error(Vn(22));return e}function OS(){const e=p.useContext(jV);if(!e)throw new Error(Vn(23));return e}function Xb(){const e=p.useContext(wV);if(!e)throw new Error(Vn(24));return e}function NV(){return p.useContext(SV)}function Kje(){return p.useContext(kV)}const qje={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{const t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{const{selectedValue:t,selectionMode:n}=e;return t==null?!1:n==="multiple"&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?aV(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,s=e.selectedValue;return Array.isArray(s)?s.some(i=>Ko(t,i,n)):Ko(t,s,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemProps:e=>e.itemProps,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight};function CV(e){return e==null?void 0:`${e}-popup`}function Gje(e,t){return(n,s)=>n==null?!1:e.contains(n,s,t)}const AV=new Map;function Wje(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${pR(e.locale)}|${JSON.stringify(t)}`,s=AV.get(n);if(s)return s;const i=new Intl.Collator(e.locale,t),o={contains(l,u,d){if(!u)return!0;const f=Kd(l,d);for(let m=0;m<=f.length-u.length;m+=1)if(i.compare(f.slice(m,m+u.length),u)===0)return!0;return!1},startsWith(l,u,d){if(!u)return!0;const f=Kd(l,d);return i.compare(f.slice(0,u.length),u)===0},endsWith(l,u,d){if(!u)return!0;const f=Kd(l,d),m=u.length;return f.length>=m&&i.compare(f.slice(f.length-m),u)===0}};return AV.set(n,o),o}const Yje=Wje;function Xje(e,t=!1){const{overflowY:n}=Li(e);return n!=="auto"&&n!=="scroll"?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}const EV=Symbol("none"),pP={value:EV,index:-1};function Qje(e,t,n){const s=e.get(t);if(s!==void 0||n===jS)return s;for(const[i,o]of e)if(Ko(i,t,n))return o}function Zje(e){const{id:t,onOpenChangeComplete:n,defaultSelectedValue:s=null,selectedValue:i,onSelectedValueChange:o,defaultInputValue:l,inputValue:u,open:d,defaultOpen:f=!1,selectionMode:m,onItemHighlighted:g,name:v,form:b,disabled:y=!1,readOnly:k=!1,required:w=!1,inputRef:S,grid:N=!1,items:C,filteredItems:T,filter:P,filterQuery:O,openOnInputClick:A=!0,autoHighlight:R=!1,keepHighlight:M=!1,highlightItemOnHover:_=!0,loopFocus:L=!0,itemToStringLabel:$,itemToStringValue:D,isItemEqualToValue:F=jS,virtualized:V=!1,inline:q=!1,fillInputOnItemPress:Q=!0,modal:X=!1,limit:U=-1,autoComplete:z="list",formAutoComplete:K,locale:J,submitOnItemClick:ee=!1}=e,{clearErrors:H}=uu(),{setDirty:G,validityData:Y,setFilled:se,name:re,disabled:ne,setTouched:de,setFocused:ie,validationMode:oe,validation:je}=uo(),te=Vb(),le=_d({id:t}),he=Yje({locale:J}),ce=Array.isArray(C)?null:C;if(ce&&typeof ce.label!="function")throw new Error(Vn(100));const ye=ce?ce.data:C,fe=ce?.value,Le=fe?void 0:ye,pe=p.useMemo(()=>{if(!T||!fe)return;const rt=kS(T),vt=rt.map(fe);let bn;return{values:vt,findItem(rr,Kr){if(!bn){bn=new Map;for(let Pr=0;Prce?rt=>ce.label(rt,F,vt=>{const bn=pe?.findItem(vt,F);return bn!=null?ce.itemLabel(bn):Kd(vt,$)}):$,[ce,$,pe,F]),Se=p.useMemo(()=>ce?Object.assign(rt=>ce.itemLabel(rt),{selected:rt=>Kd(rt,xe)}):$,[ce,xe,$]);function ge(rt){return Kd(rt,xe)}const[ue,be]=p.useState(!1),[ve,De]=p.useState(null),Ie=p.useRef(ve),We=p.useRef([]),nt=p.useRef([]),kt=p.useRef(null),Je=p.useRef(null),on=p.useRef(null),nn=p.useRef(null),On=p.useRef(null),Rn=p.useRef(!0),gt=p.useRef(!1),sn=p.useRef(null),Ke=p.useRef(null),zt=p.useRef(null),ht=p.useRef(pP),Tt=p.useRef(null),Ht=p.useRef([]),jt=p.useRef(null),an=ne||y,Xt=re??v,gn=m==="multiple",un=m==="single",lr=u!==void 0||l!==void 0,yn=ye!==void 0,xn=T!==void 0;let jn;R==="always"?jn="always":jn=R?"input-change":!1;const[ke,Xe]=Tl({controlled:i,default:gn?s??co:s,name:"Combobox",state:"selectedValue"}),Qe=p.useMemo(()=>P===null?()=>!0:P!==void 0?P:Gje(he,Se),[P,he,Se]),Yt=$s(()=>lr?l??"":un?ge(ke):"").current,[Rt,fn]=Tl({controlled:u,default:Yt,name:"Combobox",state:"inputValue"}),[At,Re]=Tl({controlled:d,default:f,name:"Combobox",state:"open"}),mt=dP(ye),Bt=!At&&ve!==null?ve:String(Rt).trim(),Pn=un?ge(ke):"",mn=un&&!ue&&Bt!==""&&Pn.length===Bt.length&&he.contains(Pn,Bt),vn=mn?"":O??Bt,Qn=yn&&xn&&mn&&(!ce||ce.hasValue(ke,F)),Ns=p.useMemo(()=>ye?kS(ye):co,[ye]),Cr=p.useMemo(()=>{if(T&&!Qn)return T;if(!ye)return co;if(mt){const vt=ye,bn=[];let rr=0;for(const Kr of vt){if(U>-1&&rr>=U)break;const Pr=U>-1?U-rr:1/0,qr=vn===""?Kr.items.slice(0,Pr):[];if(vn!=="")for(const qs of Kr.items){if(qr.length>=Pr)break;Qe(qs,vn,Se)&&qr.push(qs)}if(qr.length>0){const qs={...Kr,items:qr};bn.push(qs),rr+=qr.length}}return bn}if(vn==="")return U>-1?Ns.slice(0,U):Ns;const rt=[];for(const vt of Ns){if(U>-1&&rt.length>=U)break;Qe(vt,vn,Se)&&rt.push(vt)}return rt},[T,Qn,ye,mt,vn,U,Qe,Se,Ns]),Qr=p.useMemo(()=>{if(pe&&Cr===T)return pe.values;const rt=kS(Cr);return fe?rt.map(vt=>fe(vt)):rt},[Cr,T,pe,fe]),Vt=$s(()=>{let rt=null;return q&&At&&yn&&m!=="none"&&(rt=Wb(Qr,ke,F,gn)),new Ph({id:le,labelId:void 0,selectedValue:ke,open:At,items:Le,selectionMode:m,name:Xt,form:b,disabled:an,readOnly:k,required:w,grid:N,virtualized:V,openOnInputClick:A,itemToStringLabel:xe,isItemEqualToValue:F,modal:X,autoHighlight:jn,submitOnItemClick:ee,hasInputValue:lr,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:q,activeIndex:null,selectedIndex:rt,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:yr,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:m==="none"},{onOpenChangeComplete:Xn,setOpen:Xn,setInputValue:Xn,setSelectedValue:Xn,setIndices:Xn,handleSelection:Xn,forceMount:Xn,requestSubmit:Xn,listRef:We,labelsRef:nt,popupRef:kt,emptyRef:On,inputRef:Je,startDismissRef:on,endDismissRef:nn,keyboardActiveRef:Rn,chipsContainerRef:sn,clearRef:Ke,valuesRef:Ht,pointerDownItemRef:jt,selectionEventRef:zt},qje)}).current,eo=m==="none"?Rt:ke,Kf=p.useMemo(()=>m==="none"?eo:Array.isArray(ke)?ke.map(rt=>Rl(rt,D)):Rl(ke,D),[eo,D,m,ke]),nc=qe(g),Ca=qe(n),si=Vt.useState("activeIndex"),qf=Vt.useState("selectedIndex"),Tp=Vt.useState("positionerElement"),XE=Vt.useState("listElement"),Op=Vt.useState("triggerElement"),Rp=Vt.useState("inputElement"),Pp=Vt.useState("inputGroupElement"),Aa=Vt.useState("inline"),bi=Vt.useState("inputInsidePopup"),dd=Vt.useState("inputOwnsFormValue"),fd=un&&!bi&&Rt===Pn,Ip=ss(Op),{mounted:Gf,setMounted:aa,transitionStatus:k0}=gu(At),{openMethod:QE,triggerProps:S0}=IH(At),hd=qe(()=>Kf);hg(bi?Ip:Je,le,eo,hd,!an,v);const md=qe(()=>{ye?nt.current=Qr.map(ge):Vt.set("forceMounted",!0)}),Wf=qe((rt,vt,bn)=>{if(vt===-1){if(ht.current===pP)return;ht.current=pP}else ht.current={value:rt,index:vt};nc(rt,Cxe(bn,void 0,{index:vt}))}),Oo=qe(rt=>{const vt={};rt.activeIndex!==void 0&&(vt.activeIndex=rt.activeIndex),rt.selectedIndex!==void 0&&(vt.selectedIndex=rt.selectedIndex),Vt.update(vt);const bn=rt.activeIndex;if(bn===void 0)return;const rr=rt.type||rs;bn===null?Wf(void 0,-1,rr):Wf(Ht.current[bn],bn,rr)}),Ro=qe((rt,vt)=>{if(e.onInputValueChange?.(rt,vt),!vt.isCanceled){if(gt.current=vt.reason===mc,vt.reason===_b){At&&ve!==null&&De(null);const bn=vt.event,rr=bn.inputType;if(bn.type==="compositionend"||rr!=null&&rr!==""&&rr!=="insertReplacementText"){const Pr=rt.trim()!=="";Pr&&be(!0),Tt.current={hasQuery:Pr};const qr=Vt.state.listElement;if(!Vt.state.virtualized&&qr){const qs=kt.current;for(const to of ig(qr.firstElementChild??qr)){if(!br(to)||(qs?!Et(qs,to):to.getAttribute("role")==="dialog"))break;if(Xje(to)){to.scrollTop=0;break}}}Pr&&jn&&Vt.state.activeIndex==null&&(At||Aa)&&Vt.set("activeIndex",0)}}else vt.reason===mc&&rt===""&&Vt.state.inputInsidePopup&&(Tt.current={hasQuery:!1,selection:!0});fn(rt)}}),ZE=qe(rt=>{const vt=!rt&&bi&&!Aa&&Rt!==""&&(String(Rt).trim()===ve||Rt===Pn);!rt&&(vt||Rt===""||fd)&&be(!1),De(null),vt&&Ro("",Nt(mc))}),Hn=qe((rt,vt)=>{if(At!==rt&&(vt.reason===mg&&yn&&Qr.length===0&&!On.current&&vt.allowPropagation(),e.onOpenChange?.(rt,vt),!vt.isCanceled&&(rt&&ve!==null&&ZE(vt.reason===_b),!rt&&ue&&(un?(Aa||De(Bt),Bt===""&&be(!1)):gn&&(Aa||De(Bt),bi&&Oo({activeIndex:null}),(!bi||Aa)&&Ro("",Nt(mc,vt.event,void 0,{isItemPress:vt.reason===Mb})))),Re(rt),!rt&&bi&&(vt.reason===Fd||vt.reason===Wk)&&(de(!0),ie(!1),oe==="onBlur")))){const bn=m==="none"?Rt:ke;je.commit(bn)}}),Mp=qe((rt,vt)=>{if(o?.(rt,vt),vt.isCanceled)return;Xe(rt),(m==="none"&&kt.current&&Q||un&&!Vt.state.inputInsidePopup)&&Ro(ge(rt),Nt(vt.reason,vt.event))}),Lv=qe((rt,vt)=>{const bn=Er(rt),rr=zt.current??rt;zt.current=null;const Kr=Nt(Mb,rr),Pr=bn?.closest("a")?.getAttribute("href");if(Pr){Pr.startsWith("#")&&Hn(!1,Kr);return}if(gn){const qr=Array.isArray(ke)?ke:[],qs=wS(qr,vt,F),to=qs?sV(qr,vt,F):[...qr,vt];if(Mp(to,Kr),Kr.isCanceled||!(Je.current?Je.current.value.trim()!=="":!1))return;if(Vt.state.inputInsidePopup){Ro("",Nt(mc,Kr.event,void 0,{isItemPress:!0}));const Io=Tt.current;Io&&!qs&&(Io.toggledValue=vt)}else Hn(!1,Kr)}else{if(Mp(vt,Kr),Kr.isCanceled)return;Hn(!1,Kr)}}),$v=qe(()=>{const rt=je.inputRef.current?.form??Vt.state.inputElement?.form;rt&&typeof rt.requestSubmit=="function"&&rt.requestSubmit()}),Po=qe(()=>{if(aa(!1),Ca?.(!1),be(!1),De(null),Oo(m==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),gn&&Je.current&&Je.current.value!==""&&!gt.current&&Ro("",Nt(mc)),un)if(Vt.state.inputInsidePopup)Je.current&&Je.current.value!==""&&Ro("",Nt(mc));else{const rt=ge(ke);Je.current&&Je.current.value!==rt&&Ro(rt,Nt(rt===""?mc:rs))}}),Pi=p.useMemo(()=>Aa&&Tp?{current:Tp.closest('[role="dialog"]')}:kt,[Aa,Tp]);ji({enabled:!e.actionsRef,open:At,ref:Pi,onComplete(){At||Po()}}),p.useImperativeHandle(e.actionsRef,()=>({unmount:Po}),[Po]),Ge(function(){const vt=Ie.current!==null&&ve===null;if(Ie.current=ve,At&&(!vt||!yn)||(At||(jt.current=null),m==="none"))return;const bn=yn?Qr:Ht.current;Oo({selectedIndex:Wb(bn,ke,F,gn)})},[At,ve,ke,m,gn,yn,Qr,F,Oo]),Ge(()=>{ye&&(Ht.current=Qr,We.current.length=Qr.length)},[ye,Qr]),Ge(()=>{const rt=Tt.current;if(rt){const qs=At||Aa||Vt.state.positionerElement?.hidden===!1;if(rt.hasQuery)jn&&qs&&Vt.set("activeIndex",0),Tt.current=null;else if(String(Rt).trim()===""&&(Tt.current=null,qs)){const to=rt.selection;jn==="always"&&!to&&Vt.state.selectionMode==="none"&&Vt.set("activeIndex",0),queueMicrotask(()=>{if(!Vt.state.open&&!Vt.state.inline||Je.current&&Je.current.value.trim()!=="")return;const yl=Vt.state.selectedValue,Io=Vt.state.selectionMode==="multiple";if(Io&&Array.isArray(yl)?yl.length>0:Vt.state.selectionMode!=="none"&&yl!=null){const $a=yn||xn?Qr:Ht.current,sc=yg($a,rt.toggledValue,Vt.state.isItemEqualToValue);Vt.set("activeIndex",sc!==-1?sc:Wb($a,yl,Vt.state.isItemEqualToValue,Io))}else to?Vt.set("activeIndex",null):jn==="always"&&Vt.set("activeIndex",0)})}}if(!At&&!Aa)return;const bn=yn||xn?Qr:Ht.current,rr=Vt.state.activeIndex;if(rr==null){if(jn==="always"&&bn.length>0){Vt.set("activeIndex",0);return}Wf(void 0,-1,rs);return}if(rr>=bn.length){Wf(void 0,-1,rs),Vt.set("activeIndex",null);return}const Kr=bn[rr],Pr=ht.current.value,qr=Pr!==EV&&Ko(Kr,Pr,Vt.state.isItemEqualToValue);(ht.current.index!==rr||!qr)&&Wf(Kr,rr,rs)},[si,jn,Wf,xn,yn,Qr,Aa,At,Vt,Rt]),Ge(()=>{if(m==="none"){se(String(Rt)!=="");return}se(gn?Array.isArray(ke)&&ke.length>0:ke!=null)},[se,m,Rt,ke,gn]),p.useEffect(()=>{yn&&jn&&Qr.length===0&&Oo({activeIndex:null})},[yn,jn,Qr.length,Oo]);function JE(){At&&Bt!==""&&Bt!==String(Yt)&&!fd&&be(!0)}function QB(){At&&ve!==null&&ZE(!1)}let zv=!1;function N0(){!zv&&Rt!==Pn&&(zv=!0,Ro(Pn,Nt(rs)))}function ZB(){m!=="none"&&(H(Xt),G(nV(ke,Y.initialValue,F)),je.change(ke),un&&!lr&&!bi&&N0())}function Ii(){un&&!lr&&!bi&&!ue&&N0()}function C0(){m==="none"&&(H(Xt),G(Rt!==Y.initialValue),je.change(Rt))}Vo(Bt,JE),Vo(At,QB),Vo(ke,ZB),Vo(Pn,Ii),Vo(ye,Ii),Vo(Rt,C0);const _p=Z6({open:Aa?!0:At,onOpenChange:Hn,elements:{reference:bi?Op:Rp,floating:Tp}}),Bv=N?"grid":"listbox",rc=At||Aa,A0=rc?"true":"false",Dp=p.useMemo(()=>{const rt=Rp?.tagName==="INPUT",vt=Rp==null||rt,bn=vt||rc,rr=vt?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return bn&&(rr.role="combobox",rr["aria-expanded"]=A0,rr["aria-haspopup"]=Bv,rr["aria-controls"]=rc?XE?.id:void 0,rr["aria-autocomplete"]=k?"none":z),{reference:rr,floating:{role:"presentation"}}},[Rp,rc,A0,Bv,XE?.id,z,k]),pd=Bb(_p,{enabled:!an&&A,event:"mousedown-only",toggle:!1,touchOpenDelay:bi?0:100,reason:kxe}),Fv=Fb(_p,{enabled:!an&&!Aa,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:Aa?!0:void 0,outsidePress(rt){const vt=Er(rt);return!Et(Op,vt)&&!Et(Ke.current,vt)&&!Et(sn.current,vt)&&!Et(Pp,vt)}}),gd=rH(_p,{enabled:!an,id:le,listRef:We,activeIndex:si,selectedIndex:qf,virtual:!0,loopFocus:L,allowEscape:L&&!jn,focusItemOnOpen:ue||m==="none"&&!jn?!1:"auto",focusItemOnHover:_,resetOnPointerLeave:!M,orientation:N?"horizontal":void 0,rtl:te==="rtl",disabledIndices:co,grid:N?Vje:void 0,onNavigate(rt,vt){!vt&&!At||k0==="ending"||Oo(vt?{activeIndex:rt,type:Rn.current?BU:FU}:{activeIndex:rt})}}),E0=p.useMemo(()=>oo(gd.reference,{onKeyDown(rt){N&&Vt.state.activeIndex==null&&(rt.key==="ArrowLeft"||rt.key==="ArrowRight")&&rt.preventBaseUIHandler()}},Fv.reference,pd.reference,Dp.reference),[gd.reference,Fv.reference,pd.reference,Dp.reference,N,Vt]),Uv=p.useMemo(()=>oo(Ub,Fv.floating),[Fv.floating]),eT=p.useMemo(()=>oo(gd.floating,Dp.floating),[gd.floating,Dp.floating]),tT=p.useMemo(()=>{const rt=gd.item;return rt?{...rt,onFocus:void 0}:yr},[gd.item]);Vt.useContextCallback("setOpen",Hn),Vt.useContextCallback("setInputValue",Ro),Vt.useContextCallback("setSelectedValue",Mp),Vt.useContextCallback("setIndices",Oo),Vt.useContextCallback("handleSelection",Lv),Vt.useContextCallback("forceMount",md),Vt.useContextCallback("requestSubmit",$v),Vt.useContextCallback("onOpenChangeComplete",n),QH(()=>{Vt.update({inline:q,popupProps:Uv,listProps:eT,inputProps:E0,triggerProps:S0,itemProps:tT})});const Lp={id:le,selectedValue:ke,open:At,mounted:Gf,transitionStatus:k0,items:Le,inline:q,popupProps:Uv,listProps:eT,inputProps:E0,triggerProps:S0,itemProps:tT,openMethod:QE,selectionMode:m,name:Xt,form:b,disabled:an,readOnly:k,required:w,grid:N,virtualized:V,openOnInputClick:A,itemToStringLabel:xe,modal:X,autoHighlight:jn,isItemEqualToValue:F,submitOnItemClick:ee,hasInputValue:lr};Ge(()=>{Vt.update({...Lp,inputOwnsFormValue:m==="none"&&(q||!Vt.state.inputInsidePopup)})},[Vt,...Object.values(Lp)]);const bl=lo(S,je.inputRef),T0=p.useMemo(()=>({query:Bt,hasItems:yn,filteredItems:Cr,flatFilteredValues:Qr}),[Bt,yn,Cr,Qr]),O0=p.useMemo(()=>Array.isArray(eo)?"":Rl(eo,D),[eo,D]),Yf=gn&&Array.isArray(ke)&&ke.length>0,Qc=gn||m==="none"&&dd?void 0:Xt,nT=p.useMemo(()=>!gn||!Array.isArray(ke)||!Xt?null:ke.map(rt=>{const vt=Rl(rt,D);return r.jsx("input",{type:"hidden",form:b,name:Xt,value:vt,disabled:an},vt)}),[gn,ke,b,Xt,D,an]),R0=r.jsxs(p.Fragment,{children:[e.children,r.jsx("input",{...je.getValidationProps(an,{onFocus(){if(bi){Op?.focus();return}(Je.current||Op)?.focus()},onChange(rt){if(rt.nativeEvent.defaultPrevented||an||k)return;const vt=rt.currentTarget.value,bn=vt.toLowerCase(),rr=Nt(rs,rt.nativeEvent),Kr=()=>Ht.current.findIndex(qr=>Rl(qr,D).toLowerCase()===bn||ge(qr).toLowerCase()===bn);function Pr(){if(gn)return;if(m==="none"){Ro(vt,rr);return}let qr=Kr();qr===-1&&(qr=Ht.current.findIndex((to,yl)=>{const Io=nt.current[yl];return Io!=null&&Io.toLowerCase()===bn}));const qs=qr===-1?void 0:Ht.current[qr];qs!=null&&Mp?.(qs,rr)}un&&(md(),ye&&Kr()===-1&&Vt.set("forceMounted",!0)),queueMicrotask(Pr)}}),id:le&&Qc==null?`${le}-hidden-input`:void 0,form:b,name:Qc,autoComplete:K,disabled:an,required:w&&!Yf,readOnly:k,value:O0,ref:bl,style:Qc?pg:vu,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),nT]});return r.jsx(yV.Provider,{value:Vt,children:r.jsx(jV.Provider,{value:_p,children:r.jsx(kV.Provider,{value:yn,children:r.jsx(wV.Provider,{value:T0,children:r.jsx(SV.Provider,{value:Rt,children:R0})})})})})}function TV(e){const{multiple:t=!1,defaultValue:n,value:s,onValueChange:i,autoComplete:o,...l}=e;return r.jsx(Zje,{...l,selectionMode:t?"multiple":"single",selectedValue:s,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:o})}function Jje(e){const{children:t,placeholder:n}=e,s=qo(),i=s.useState("itemToStringLabel"),o=s.useState("selectedValue"),l=s.useState("items"),u=s.useState("selectionMode")==="multiple",d=s.useState("hasSelectedValue"),f=!d&&n!=null&&t==null,m=s.useState("hasNullItemLabel",f);let g=null;return typeof t=="function"?g=t(o):t!=null?g=t:!d&&n!=null&&!m?g=n:u&&Array.isArray(o)?g=iV(o,l,i):g=fP(o,l,i),r.jsx(p.Fragment,{children:g})}const ewe="data-popup-side",twe="data-list-empty",OV={...qO,...hc,popupSide:e=>e?{[ewe]:e}:null,listEmpty:e=>e?{[twe]:""}:null},nwe=p.createContext(void 0);function rwe(){return p.useContext(nwe)}const RV=p.createContext(void 0);function gP(e){const t=p.useContext(RV);if(t===void 0&&!e)throw new Error(Vn(21));return t}const PV=p.forwardRef(function(t,n){const s=qo(),{buttonRef:i,getButtonProps:o}=$i({native:!1}),l=lo(n,i);function u(f){s.context.setOpen(!1,Nt(dR,f.nativeEvent,f.currentTarget))}const d=o({onClick:u});return r.jsx("span",{ref:l,...d,"aria-label":"Dismiss",tabIndex:void 0,style:pg})});function IV(e){const t=e.useState("mounted"),n=e.useState("popupSide"),s=e.useState("positionerElement");return t&&s?n:null}function RS(){return Xb().filteredItems.length===0}function swe(e){return e==="rtl"?["ArrowRight","ArrowLeft"]:["ArrowLeft","ArrowRight"]}function awe(e,t){const n=e>=t-1?t-2:e;return n>=0?n:void 0}function MV(e,t,n){const s=e.context.listRef.current[t];s&&(e.context.selectionEventRef.current=n,s.click(),e.context.selectionEventRef.current=null)}const _V=p.forwardRef(function(t,n){const{render:s,className:i,disabled:o=!1,id:l,style:u,...d}=t,{state:f,disabled:m,setTouched:g,setFocused:v,validationMode:b,validation:y}=uo(),{labelId:k}=zi(),w=rwe(),N=!!gP(!0),C=qo(),T=NV(),P=Vb(),O=C.useState("required"),A=C.useState("disabled"),R=C.useState("readOnly"),M=C.useState("name"),_=C.useState("form"),L=C.useState("selectionMode"),$=C.useState("autoHighlight"),D=C.useState("inputProps"),F=C.useState("triggerProps"),V=C.useState("open"),q=C.useState("mounted"),Q=C.useState("selectedValue"),X=C.useState("id"),U=C.useState("inline"),z=C.useState("modal"),K=!!$,J=IV(C),ee=m||A||o,H=RS(),G=N||U,Y=!G||z,se=Ws(l??(G?void 0:X)),re=N?uU:f,[ne,de]=p.useState(null),ie=p.useRef(!1),oe=p.useRef(null),je=p.useRef(!1),te=L==="none"&&!N,le=qe(Se=>{const ge=N||C.state.inline;ge&&!C.state.hasInputValue&&C.context.setInputValue("",Nt(rs)),C.update({inputElement:Se,inputInsidePopup:ge,inputOwnsFormValue:te})}),he=N?d:y.getValidationProps(ee,d);function ce(){C.context.setIndices({activeIndex:null,selectedIndex:null,type:C.context.keyboardActiveRef.current?BU:FU})}function ye(){C.context.keyboardActiveRef.current=!1}const fe={...re,open:V,disabled:ee,readOnly:R,popupSide:J,listEmpty:H};function Le(Se){if(!w)return;let ge;const{highlightedChipIndex:ue}=w,be=w.chipsRef.current.length,[ve,De]=swe(P);return ue!==void 0?(Se.key===ve?(Se.preventDefault(),ue>0?ge=ue-1:ge=void 0):Se.key===De?(Se.preventDefault(),ue0&&(Se.preventDefault(),ge=be>0?be-1:void 0),ge)}const pe=Kt("input",t,{state:fe,ref:[n,C.context.inputRef,le],props:[D,F,{value:ne??T,"aria-readonly":R||void 0,"aria-required":O||void 0,"aria-labelledby":k,disabled:ee,readOnly:R,required:L==="none"?O:void 0,form:_,...te&&M&&{name:M},id:se,onFocus(){if(v(!0),!U||!je.current)return;je.current=!1;const Se=oe.current;Se==null||!Object.hasOwn(C.context.valuesRef.current,Se)||C.context.setIndices({activeIndex:Se})},onBlur(){g(!0),v(!1);const Se=C.state.activeIndex;if(U&&Se!==null&&$!=="always"&&(oe.current=Se,je.current=!0,C.context.setIndices({activeIndex:null})),b==="onBlur"){const ge=L==="none"?T:Q;y.commit(ge)}},onCompositionStart(Se){Tk||(ie.current=!0,de(Se.currentTarget.value))},onCompositionEnd(Se){ie.current=!1;const ge=Se.currentTarget.value;de(null),C.context.setInputValue(ge,Nt(_b,Se.nativeEvent))},onChange(Se){const ge=Se.nativeEvent,ue=ge.inputType,be=!ue||ue==="insertReplacementText",ve=ie.current||!be;function De(kt){R||ee||!kt||!ve||(C.context.setOpen(!0,Nt(_b,ge)),K||ce())}if(ie.current){const kt=Se.currentTarget.value;de(kt),kt===""&&!C.state.openOnInputClick&&!C.state.inputInsidePopup&&C.context.setOpen(!1,Nt(mc,ge));const Je=kt.trim(),on=K&&Je!=="";De(Je),V&&C.state.activeIndex!==null&&!on&&ce();return}const Ie=Nt(_b,ge);if(C.context.setInputValue(Se.currentTarget.value,Ie),Ie.isCanceled)return;const We=Se.currentTarget.value==="",nt=Nt(mc,ge);We&&!C.state.inputInsidePopup&&(L==="single"&&C.context.setSelectedValue(null,nt),C.state.openOnInputClick||C.context.setOpen(!1,nt)),De(Se.currentTarget.value.trim()),V&&C.state.activeIndex!==null&&!K&&ce()},onKeyDown(Se){if(Se.ctrlKey||Se.shiftKey||Se.altKey||Se.metaKey)return;if(C.context.keyboardActiveRef.current=!0,ee||R){R&&Se.key==="Enter"&&V&&C.state.activeIndex!==null&&da(Se);return}const ge=Se.currentTarget,ue=ge.scrollWidth-ge.clientWidth,be=P==="rtl";if(Se.key==="Home"){da(Se);const Ie=vU&&be?ge.value.length:0;ge.setSelectionRange(Ie,Ie),ge.scrollLeft=0;return}if(Se.key==="End"){da(Se);const Ie=vU&&be?0:ge.value.length;ge.setSelectionRange(Ie,Ie),ge.scrollLeft=be?-ue:ue;return}if(!q&&Se.key==="Escape"){const Ie=L==="multiple"&&Array.isArray(Q)?Q.length===0:Q===null,We=Nt(mg,Se.nativeEvent),nt=L==="multiple"?[]:null;C.context.setInputValue("",We),C.context.setSelectedValue(nt,We),!Ie&&!C.state.inline&&!We.isPropagationAllowed&&Se.stopPropagation();return}if(w&&Se.key==="Backspace"&&ge.value===""&&w.highlightedChipIndex===void 0&&Array.isArray(Q)&&Q.length>0){const Ie=w.chipsRef.current.length,We=Ie>0?Ie-1:Q.length-1,nt=Q.filter((kt,Je)=>Je!==We);ce(),C.context.setSelectedValue(nt,Nt(rs,Se.nativeEvent));return}const ve=w?.highlightedChipIndex!==void 0,De=Le(Se);if(w?.setHighlightedChipIndex(De),De!==void 0?w?.chipsRef.current[De]?.focus():ve&&C.context.inputRef.current?.focus(),Se.which!==229&&Se.key==="Enter"&&V){const Ie=C.state.activeIndex,We=Se.nativeEvent;if(Ie===null){if(U)return;C.context.setOpen(!1,Nt(rs,We));return}da(Se),MV(C,Ie,We)}},onPointerMove:ye,onPointerDown:ye},he],stateAttributesMapping:OV}),xe=N?r.jsx(zO.Provider,{value:dU,children:pe}):pe;return r.jsxs(p.Fragment,{children:[V&&Y&&r.jsx(PV,{ref:C.context.startDismissRef}),xe]})}),DV=p.forwardRef(function(t,n){const{render:s,className:i,nativeButton:o=!0,disabled:l=!1,id:u,style:d,...f}=t,{state:m,disabled:g,setTouched:v,setFocused:b,validationMode:y,validation:k}=uo(),{labelId:w}=zi(),S=qo(),N=S.useState("selectionMode"),C=S.useState("disabled"),T=S.useState("readOnly"),P=S.useState("required"),O=S.useState("positionerElement"),A=S.useState("listElement"),R=S.useState("popupId"),M=S.useState("triggerProps"),_=S.useState("inputInsidePopup"),L=S.useState("id"),$=S.useState("labelId"),D=S.useState("open"),F=S.useState("selectedValue"),V=S.useState("activeIndex"),q=S.useState("selectedIndex"),Q=S.useState("hasSelectedValue"),X=OS(),U=NV(),z=fa(),K=g||C||l,J=RS(),ee=IV(S);_d({id:_?u:void 0});const H=_?u??L:u,G=lV(w,$);let Y;D&&_?Y=R??CV(L):D&&(Y=A?.id);const se=p.useRef("");function re(he){se.current=he.pointerType}const{reference:ne}=sH(X,{enabled:!D&&!T&&!C&&N==="single",listRef:S.context.labelsRef,activeIndex:V,selectedIndex:q,onMatch(he){const ce=S.context.valuesRef.current[he];ce!==void 0&&S.context.setSelectedValue(ce,Nt(rs))}}),{reference:de}=Bb(X,{enabled:!C,event:"mousedown"}),{buttonRef:ie,getButtonProps:oe}=$i({native:o,disabled:K}),je={...m,readOnly:T,open:D,disabled:K,popupSide:ee,listEmpty:J,placeholder:N==="none"?!1:!Q},te=qe(he=>{S.set("triggerElement",he)});return Kt("button",t,{ref:[n,ie,te],state:je,props:[M,de,ne,{id:H,tabIndex:_?0:-1,role:_?"combobox":void 0,"aria-expanded":D,"aria-haspopup":_?"dialog":"listbox","aria-controls":Y,"aria-required":_&&P||void 0,"aria-readonly":_&&T||void 0,"aria-labelledby":G,onPointerDown:re,onPointerEnter:re,onFocus(){b(!0),!K&&z.start(0,S.context.forceMount)},onBlur(he){if(!Et(O,he.relatedTarget)&&(v(!0),b(!1),y==="onBlur")){const ce=N==="none"?U:F;k.commit(ce)}},onMouseDown(he){if(K||(_||X.set("domReferenceElement",he.currentTarget),S.context.forceMount(),se.current!=="touch"&&(S.context.inputRef.current?.focus(),_||he.preventDefault()),D))return;const ce=_n(he.currentTarget);function ye(fe){const Le=S.state.triggerElement;if(!Le)return;const pe=Er(fe),xe=S.state.positionerElement,Se=S.state.listElement;Et(Le,pe)||Et(xe,pe)||Et(Se,pe)||cV(fe,Le)||S.context.setOpen(!1,Nt(UU,fe))}_&&ce.addEventListener("mouseup",ye,{once:!0})},onKeyDown(he){(he.key==="ArrowDown"||he.key==="ArrowUp")&&(da(he),S.context.setOpen(!0,Nt(fR,he.nativeEvent)),S.context.inputRef.current?.focus())}},k.getValidationProps(K,f),oe],stateAttributesMapping:OV})}),iwe=p.createContext(null);function owe(){return p.useContext(iwe)}function lwe(e){const{children:t}=e,{filteredItems:n}=Xb(),s=owe(),i=s?s.items:n;return r.jsx(p.Fragment,{children:i.map(t)})}const LV=p.forwardRef(function(t,n){var s;const{render:i,className:o,style:l,children:u,...d}=t,f=qo(),m=OS(),g=!!gP(!0),{filteredItems:v,hasItems:b}=Xb(),y=f.useState("selectionMode"),k=f.useState("grid"),w=f.useState("readOnly"),S=f.useState("listProps"),N=f.useState("virtualized"),C=f.useState("forceMounted"),T=y==="multiple",P=v.length===0,O=qe(D=>{f.set("positionerElement",D)}),A=qe(D=>{f.set("listElement",D)}),R=p.useMemo(()=>typeof u=="function"?s||(s=r.jsx(lwe,{children:u})):u,[u]),M={empty:P},_=m.useState("floatingId"),L=Kt("div",t,{state:M,ref:[n,A,g?null:O],props:[S,{children:R,tabIndex:-1,id:_,role:k?"grid":"listbox","aria-multiselectable":T?"true":void 0,"aria-readonly":!k&&w?!0:void 0,onKeyDown(D){if(!(f.state.disabled||f.state.readOnly)&&D.key==="Enter"){const F=f.state.activeIndex;if(F==null)return;da(D),MV(f,F,D.nativeEvent)}},onKeyDownCapture(){f.context.keyboardActiveRef.current=!0},onPointerMoveCapture(){f.context.keyboardActiveRef.current=!1}},d]});if(N)return L;const $=b&&!C?void 0:f.context.labelsRef;return r.jsx(cP,{elementsRef:f.context.listRef,labelsRef:$,children:L})}),cwe="⁠",uwe=200;function dwe(e){const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let n=null;for(;t.nextNode();){const s=t.currentNode;s.nodeValue!==""&&(n=s)}return n}function fwe(){const e=fa(),t=p.useRef(null);return p.useEffect(()=>{if(Ob)return;const n=t.current;if(n==null)return;const s=dwe(n);if(s==null)return;const i=s.data,o=`${i}${cwe}`;return s.nodeValue=o,e.start(uwe,()=>{s.nodeValue===o&&(s.nodeValue=i)}),()=>{e.clear(),s.nodeValue===o&&(s.nodeValue=i)}},[t,e]),t}const $V=p.createContext(void 0);function hwe(){const e=p.useContext($V);if(e===void 0)throw new Error(Vn(20));return e}const zV=p.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,o=qo(),l=o.useState("mounted"),u=o.useState("forceMounted");return l||s||u?r.jsx($V.Provider,{value:s,children:r.jsx(eS,{ref:n,...i})}):null}),BV=p.forwardRef(function(t,n){const{render:s,className:i,anchor:o,positionMethod:l,side:u,align:d,sideOffset:f,alignOffset:m,collisionBoundary:g="clipping-ancestors",collisionPadding:v,arrowPadding:b,sticky:y,disableAnchorTracking:k=!1,collisionAvoidance:w=h6,style:S,...N}=t,C=qo(),T=OS(),P=hwe(),O=C.useState("modal"),A=C.useState("open"),R=C.useState("mounted"),M=C.useState("openMethod"),_=C.useState("positionerElement"),L=C.useState("triggerElement"),$=C.useState("inputElement"),D=C.useState("inputGroupElement"),F=C.useState("inputInsidePopup"),V=C.useState("transitionStatus"),q=RS(),X=hS({anchor:o??(F?L:D??$),floatingRootContext:T,positionMethod:l,mounted:R,side:u,sideOffset:f,align:d,alignOffset:m,arrowPadding:b,collisionBoundary:g,collisionPadding:v,sticky:y,disableAnchorTracking:k,keepMounted:P,collisionAvoidance:w,lazyFlip:!0});hP(A&&O,M==="touch",_,L);const U={open:A,side:X.side,align:X.align,anchorHidden:X.anchorHidden,empty:q};Ge(()=>{C.set("popupSide",X.side)},[C,X.side]);const z=qe(J=>{C.set("positionerElement",J)}),K=mS(t,U,{styles:X.positionerStyles,transitionStatus:V,props:N,refs:[n,z],hidden:!R,inert:!A});return r.jsxs(RV.Provider,{value:X,children:[R&&O&&r.jsx(vS,{inert:qb(!A),cutout:D??$??L}),K]})}),mwe={...cg,...Fo},FV=p.forwardRef(function(t,n){const{render:s,className:i,style:o,initialFocus:l,finalFocus:u,...d}=t,f=qo(),m=gP(),g=OS(),v=f.useState("mounted"),b=f.useState("open"),y=f.useState("openMethod"),k=f.useState("popupProps"),w=f.useState("transitionStatus"),S=f.useState("inputInsidePopup"),N=f.useState("inputElement"),C=f.useState("modal"),T=f.useState("id"),P=RS(),O=d.id??(S?CV(T):void 0);Ge(()=>(f.set("popupId",f.context.popupRef.current?.id||O),()=>{f.set("popupId",void 0)}),[f,O]),ji({open:b,ref:f.context.popupRef,onComplete(){b&&f.context.onOpenChangeComplete(!0)}});const A={open:b,side:m.side,align:m.align,anchorHidden:m.anchorHidden,transitionStatus:w,empty:P},R=Kt("div",t,{state:A,ref:[n,f.context.popupRef],props:[k,{id:O,role:S?"dialog":"presentation",onFocus(D){const F=Er(D.nativeEvent);y!=="touch"&&(Et(f.state.listElement,F)||F===D.currentTarget)&&f.context.inputRef.current?.focus()}},Kb(w),d],stateAttributesMapping:mwe}),_=l===void 0?S?D=>D==="touch"?f.context.popupRef.current:N:!1:l;let L;u!=null?L=u:L=S?void 0:!1;const $=!S||C;return r.jsx(tS,{context:g,disabled:!v,modal:$,openInteractionType:y,initialFocus:_,returnFocus:L,getInsideElements:()=>[f.context.startDismissRef.current,f.context.endDismissRef.current],children:r.jsxs(p.Fragment,{children:[R,$&&r.jsx(PV,{ref:f.context.endDismissRef})]})})}),UV=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t;return Kt("span",t,{ref:n,props:[{"aria-hidden":!0,children:"▼"},l]})}),HV=p.createContext(void 0);function VV(){const e=p.useContext(HV);if(!e)throw new Error(Vn(19));return e}const pwe=p.createContext(!1);function gwe(){return p.useContext(pwe)}function KV(e){const{componentProps:t,forwardedRef:n,virtualized:s,indexFromFilter:i}=e,{render:o,className:l,style:u,value:d=null,index:f,disabled:m=!1,nativeButton:g=!1,...v}=t,b=p.useRef(null),y=lP({guess:!0,index:f,textRef:b}),k=qo(),w=gwe(),S=Kje(),N=k.useState("selectionMode"),C=k.useState("disabled"),T=k.useState("readOnly"),P=k.useState("isItemEqualToValue"),O=C||m,A=N!=="none",R=f??i??y.index,M=R!==-1,_=k.useState("id"),L=k.useState("isActive",R),$=k.useState("isSelected",d),D=k.useState("itemProps"),F=p.useRef(null),V=_!=null&&M?`${_}-${R}`:void 0,q=$&&A;Ge(()=>{if(!(M&&(s||f!=null)))return;const G=k.context.listRef.current;return G[R]=F.current,()=>{delete G[R]}},[M,s,R,f,k]),Ge(()=>{if(!M||S)return;const H=k.context.valuesRef.current;return H[R]=d,()=>{delete H[R]}},[M,S,R,d,k]),Ge(()=>{if(!M||S)return;const H=k.state.selectedValue;let G=k.state.selectedIndex;k.state.selectionMode==="multiple"&&Array.isArray(H)?G=rV(R,d,k.context.valuesRef.current,H,P,G):Ko(d,H,P)&&(G=R),k.set("selectedIndex",G)},[M,S,k,R,d,P]);const{getButtonProps:Q,buttonRef:X}=$i({disabled:O,focusableWhenDisabled:!0,native:g,composite:!0}),U={disabled:O,selected:q,highlighted:L};function z(H){function G(){k.context.handleSelection(H,d)}k.state.submitOnItemClick?(xr.flushSync(G),k.context.requestSubmit()):G()}const K={id:V,role:w?"gridcell":"option","aria-selected":A?q:void 0,tabIndex:void 0,onPointerDownCapture(H){H.isPrimary&&(k.context.pointerDownItemRef.current=H.currentTarget),H.preventDefault()},onMouseDown(H){H.preventDefault()},onClick(H){O||T||z(H.nativeEvent)},onMouseUp(H){const G=k.context.pointerDownItemRef.current===H.currentTarget;k.context.pointerDownItemRef.current=null,!(O||T||H.button!==0||G||!L)&&z(H.nativeEvent)}},J=Kt("div",t,{ref:[X,n,y.ref,F],state:U,props:[D,K,v,Q]}),ee=p.useMemo(()=>({selected:q,textRef:b}),[q,b]);return r.jsx(HV.Provider,{value:ee,children:J})}function xwe(e){const{componentProps:t,forwardedRef:n}=e,i=qo().useState("isItemEqualToValue"),{flatFilteredValues:o}=Xb(),l=t.value??null,u=yg(o,l,i);return r.jsx(KV,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:u})}const qV=p.memo(p.forwardRef(function(t,n){const i=qo().useState("virtualized");return i&&t.index==null?r.jsx(xwe,{componentProps:t,forwardedRef:n}):r.jsx(KV,{componentProps:t,forwardedRef:n,virtualized:i,indexFromFilter:void 0})})),GV=p.forwardRef(function(t,n){const{selected:s}=VV();return t.keepMounted||s?r.jsx(vwe,{...t,ref:n}):null}),vwe=p.memo(p.forwardRef((e,t)=>{const{render:n,className:s,style:i,keepMounted:o,...l}=e,{selected:u}=VV(),d=p.useRef(null),{transitionStatus:f,setMounted:m}=gu(u),v=Kt("span",e,{ref:[t,d],state:{selected:u,transitionStatus:f},props:[{"aria-hidden":!0,children:"✔️"},l],stateAttributesMapping:Fo});return ji({batch:!0,enabled:!u,open:u,ref:d,onComplete(){u||m(!1)}}),v})),WV=p.forwardRef(function(t,n){const{render:s,className:i,style:o,children:l,...u}=t,{filteredItems:d}=Xb(),f=qo(),m=fwe(),g=d.length===0?l:null;return Kt("div",t,{ref:[n,f.context.emptyRef,m],props:[{children:g,role:"status","aria-live":"polite","aria-atomic":!0},u]})}),PS=p.createContext(null);function YV({open:e,defaultOpen:t=!1,onOpenChange:n,children:s,...i}){const[o,l]=p.useState(t),[u,d]=p.useState(null),[f,m]=p.useState(!1),g=e??o;p.useLayoutEffect(()=>{g&&m(!1)},[g]);const v=p.useCallback((k,w)=>{n?.(k,w),!w.isCanceled&&(k&&m(!1),l(k))},[n]),b=p.useCallback(()=>{if(!g||f)return;const k=Nt("none",void 0,u??void 0);v(!1,k),k.isCanceled||m(!0)},[g,f,u,v]),y=p.useMemo(()=>({open:g,trigger:u,setTrigger:d,closeOnAnchorHidden:b,closedOnAnchorHidden:f}),[g,u,b,f]);return r.jsx(PS.Provider,{value:y,children:r.jsx(TV,{...i,open:g,onOpenChange:v,children:s})})}function bwe({anchorHidden:e,open:t,...n}){const i=p.useContext(PS)?.closeOnAnchorHidden;return p.useLayoutEffect(()=>{t&&e&&i?.()},[t,e,i]),r.jsx("div",{...n})}const XV=Jje;function QV({className:e,children:t,ref:n,...s}){const i=p.useContext(PS);return Ah({render:r.jsx(DV,{}),ref:[n??null,i?.setTrigger??null],props:{...s,"data-slot":"combobox-trigger",className:Ne("inline-flex h-[30px] min-w-0 cursor-pointer items-center justify-between gap-1.5 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] font-normal text-foreground max-[767px]:h-10 max-[767px]:text-base","transition-colors duration-150 ease-out","hover:border-control-border-hover hover:bg-control-hover","focus-visible:border-primary focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:bg-control data-disabled:text-muted-foreground data-disabled:opacity-60",e),children:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t}),r.jsx(UV,{className:"flex flex-none text-muted-foreground transition-transform duration-[180ms] data-popup-open:rotate-180",children:r.jsx("svg",{viewBox:"0 0 10 6",className:"size-2.5","aria-hidden":"true",children:r.jsx("path",{d:"M1 1l4 4 4-4",stroke:"currentColor",strokeWidth:"1.4",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}})}function ZV({className:e,sideOffset:t=4,children:n,finalFocus:s,...i}){const o=p.useContext(PS),l=bV(o?.trigger??null,o?.open??!1);return r.jsx(zV,{children:r.jsx(BV,{sideOffset:t,align:"start",collisionBoundary:l,className:"z-[35] data-anchor-hidden:invisible data-anchor-hidden:pointer-events-none",render:(u,d)=>r.jsx(bwe,{...u,anchorHidden:d.anchorHidden,open:d.open}),children:r.jsx(FV,{"data-slot":"combobox-content",className:Ne("flex max-h-[min(300px,var(--available-height))] w-[max(var(--anchor-width),220px)] max-w-[var(--available-width)] flex-col overflow-hidden","rounded-lg border border-border-strong bg-raised shadow-3 outline-none","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0",e),finalFocus:o?.closedOnAnchorHidden?!1:s,...i,children:n})})})}function JV({className:e,...t}){return r.jsx(_V,{"data-slot":"combobox-input",className:Ne("h-[30px] w-full min-w-0 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] text-foreground outline-none max-[767px]:h-10 max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out placeholder:text-muted-foreground","hover:border-control-border-hover focus:border-primary focus:shadow-focus","disabled:pointer-events-none disabled:cursor-not-allowed disabled:text-muted-foreground",e),...t})}function eK({className:e,...t}){return r.jsx(LV,{"data-slot":"combobox-list",className:Ne("min-h-0 flex-1 overflow-y-auto overscroll-contain p-[5px]",e),...t})}function tK({className:e,children:t,...n}){return r.jsxs(qV,{"data-slot":"combobox-item",className:Ne("flex min-h-7 cursor-pointer items-center gap-2 rounded-sm px-[9px] py-[5px] text-[12.5px] leading-[1.4] text-foreground select-none outline-none","max-[767px]:min-h-10 max-[767px]:text-sm transition-colors duration-[120ms] ease-out","data-[highlighted]:bg-nav-hover","data-[selected]:bg-primary-soft data-[selected]:font-semibold data-[selected]:text-primary-fg","data-[highlighted]:data-[selected]:bg-primary-tint","data-disabled:pointer-events-none data-disabled:font-normal data-disabled:text-muted-foreground",e),...n,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),r.jsx(GV,{className:"flex flex-none text-primary",children:r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}function nK({className:e,children:t,...n}){return r.jsx(WV,{"data-slot":"combobox-empty",...n,children:r.jsx("div",{className:Ne("px-2.5 py-3 text-[11.5px] leading-[1.5] text-muted-foreground",e),children:t})})}const ywe={left:0,top:0,width:0,height:0,ready:!1};function rK(e,t){const n=p.useRef(null),[s,i]=p.useState(ywe),[o,l]=p.useState(!1),u=p.useRef(!1),d=p.useRef(null),f=p.useCallback(()=>{const g=n.current,v=g?.querySelector(t);if(!g||!v||!g.offsetWidth||!g.offsetHeight||!v.getClientRects().length){u.current=!1,l(!1),i(N=>N.ready?{...N,ready:!1}:N);return}const b=g.getBoundingClientRect(),y=v.getBoundingClientRect();if(!b.width||!b.height||!y.width||!y.height)return;const k=b.width/g.offsetWidth,w=b.height/g.offsetHeight,S={left:(y.left-b.left)/k-g.clientLeft+g.scrollLeft,top:(y.top-b.top)/w-g.clientTop+g.scrollTop,width:y.width/k,height:y.height/w,ready:!0};u.current=!0,i(N=>N.ready&&Math.abs(N.left-S.left)<.1&&Math.abs(N.top-S.top)<.1&&Math.abs(N.width-S.width)<.1&&Math.abs(N.height-S.height)<.1?N:S)},[t]),m=p.useCallback(()=>{if(!u.current){f();return}d.current===null&&(d.current=requestAnimationFrame(()=>{d.current=null,f()}))},[f]);return p.useLayoutEffect(()=>{m()}),p.useLayoutEffect(()=>{const g=n.current;if(!g)return;const v=typeof ResizeObserver>"u"?null:new ResizeObserver(m),b=()=>{v?.disconnect(),v?.observe(g),g.querySelectorAll(e).forEach(k=>v?.observe(k))};b();const y=new MutationObserver(k=>{const w=k.filter(S=>!(S.target instanceof Element&&S.target.hasAttribute("data-selection-indicator")));w.length&&(w.some(S=>S.type==="childList")&&b(),m())});return y.observe(g,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["data-active","data-checked","class","hidden","style"]}),window.addEventListener("resize",m),document.fonts?.addEventListener("loadingdone",m),()=>{v?.disconnect(),y.disconnect(),d.current!==null&&cancelAnimationFrame(d.current),d.current=null,window.removeEventListener("resize",m),document.fonts?.removeEventListener("loadingdone",m)}},[e,m]),p.useEffect(()=>{if(!s.ready||o)return;let g=0;const v=requestAnimationFrame(()=>{g=requestAnimationFrame(()=>{u.current&&l(!0)})});return()=>{cancelAnimationFrame(v),cancelAnimationFrame(g)}},[s.ready,o]),{containerRef:n,indicator:{"data-selection-indicator":"","data-ready":s.ready?"true":"false","data-animate":o?"true":"false",style:{transform:`translate3d(${s.left}px, ${s.top}px, 0)`,width:s.width,height:s.height}}}}function en({options:e,value:t,onValueChange:n,disabled:s=!1,className:i,...o}){const{containerRef:l,indicator:u}=rK('[data-slot="segmented-item"]','[data-slot="segmented-item"][data-checked]');return r.jsxs(XH,{ref:l,"data-slot":"segmented-control",className:Ne("relative inline-flex gap-0.5 rounded-md border border-hairline bg-control p-0.5 shadow-none",i),value:t,disabled:s,onValueChange:d=>n(d),...o,children:[r.jsx("span",{"aria-hidden":"true","data-slot":"segmented-thumb",...u}),e.map(d=>r.jsxs(GH,{value:d.value,"data-slot":"segmented-item",title:d.title,disabled:d.disabled,"data-zero":d.count===0?"true":void 0,className:Ne("group/seg relative z-[1] inline-flex h-6 items-center gap-[5px] rounded-sm border-0 bg-transparent px-2.5","text-xs font-normal whitespace-nowrap text-subtle select-none","transition-[background-color,color] duration-150 ease-out","hover:bg-nav-hover hover:text-foreground focus-visible:outline-none focus-visible:shadow-focus","data-checked:bg-transparent data-checked:text-foreground data-checked:hover:bg-transparent","data-disabled:cursor-not-allowed data-disabled:opacity-40","data-[zero=true]:data-unchecked:opacity-45"),children:[d.label,d.count!==void 0&&r.jsx("span",{className:Ne("min-w-4 rounded-pill bg-surface-3 px-[5px] text-center text-[10.5px] font-semibold tabular-nums text-muted-foreground","group-data-checked/seg:bg-surface-2 group-data-checked/seg:text-foreground"),children:d.count})]},d.value))]})}const jwe=p.createContext(void 0);function wwe(){return p.useContext(jwe)}const kwe=p.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:o=!1,form:l,onPressedChange:u,pressed:d,render:f,type:m,value:g,nativeButton:v=!0,style:b,...y}=t,k=Ws(g||void 0),w=wwe(),S=w?.value??[],N=(o||w?.disabled)??!1,[C,T]=Tl({controlled:w?k!==void 0&&S.indexOf(k)>-1:d,default:i,name:"Toggle",state:"pressed"}),{getButtonProps:P,buttonRef:O}=$i({disabled:N,native:v}),A={disabled:N,pressed:C},R=[O,n],M=[{"aria-pressed":C,onClick($){const D=!C,F=Nt(rs,$.nativeEvent);u?.(D,F),!F.isCanceled&&(k&&w?.setGroupValue?.(k,D,F),!F.isCanceled&&T(D))}},y,P],_=Kt("button",t,{enabled:!w,state:A,ref:R,props:M}),L=p.useMemo(()=>({disabled:N,focusableWhenDisabled:!1}),[N]);return w?r.jsx(VH,{tag:"button",render:f,className:s,style:b,metadata:L,state:A,refs:R,props:M}):_}),Swe=jh(["inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border","font-medium transition-[background-color,border-color,color] duration-150 ease-out","outline-none select-none disabled:pointer-events-none disabled:opacity-45","[&_svg]:pointer-events-none [&_svg]:shrink-0","data-pressed:border-primary-bd data-pressed:bg-primary-soft data-pressed:font-semibold data-pressed:text-primary-fg","data-pressed:hover:bg-primary-tint"],{variants:{variant:{default:"border-transparent bg-transparent text-subtle hover:bg-nav-hover hover:text-foreground",outline:"border-control-border bg-control text-foreground shadow-1 hover:border-control-border-hover hover:bg-control-hover"},size:{default:"h-[30px] rounded-md px-3 text-[12.5px]",xs:"h-6 rounded-sm px-2 text-[11.5px]",sm:"h-[26px] rounded-sm px-2.5 text-[12px]",lg:"h-9 rounded-md px-4 text-[13px]"}},defaultVariants:{variant:"default",size:"default"}});function Nwe({className:e,variant:t,size:n,...s}){return r.jsx(kwe,{"data-slot":"toggle",className:Ne(Swe({variant:t,size:n}),e),...s})}const Cwe="、";function xc({value:e,onValueChange:t,options:n,placeholder:s="",emptyHint:i=Z("没有匹配的选项"),searchPlaceholder:o=Z("搜索…"),disabled:l=!1,className:u,id:d,title:f,...m}){const g=p.useMemo(()=>n.filter(b=>e.includes(b.value)),[n,e]),v=g.length?g.map(b=>b.label).join(Cwe):s;return r.jsxs(TV,{items:n,multiple:!0,value:g,onValueChange:b=>t(b.map(y=>y.value)),isItemEqualToValue:(b,y)=>b?.value===y?.value,disabled:l,children:[r.jsxs(DV,{"data-slot":"multi-select-trigger",id:d,title:f,"aria-label":m["aria-label"],className:Ne("inline-flex h-[30px] min-w-0 cursor-pointer items-center justify-between gap-1.5 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] font-normal text-foreground","transition-colors duration-150 ease-out","hover:border-control-border-hover hover:bg-control-hover","focus-visible:border-primary focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:bg-control data-disabled:text-muted-foreground data-disabled:opacity-60",u),children:[r.jsx("span",{"data-slot":"multi-select-value",className:"min-w-0 flex-1 truncate text-left data-[placeholder]:text-muted-foreground","data-placeholder":g.length?void 0:"",title:v,children:v}),r.jsx(UV,{className:"flex flex-none text-muted-foreground transition-transform duration-[180ms] data-popup-open:rotate-180",children:r.jsx("svg",{viewBox:"0 0 10 6",className:"size-2.5","aria-hidden":"true",children:r.jsx("path",{d:"M1 1l4 4 4-4",stroke:"currentColor",strokeWidth:"1.4",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),r.jsx(zV,{children:r.jsx(BV,{sideOffset:4,className:"z-[35]",children:r.jsxs(FV,{"data-slot":"multi-select-content",className:Ne("flex max-h-[280px] w-[max(var(--anchor-width),220px)] flex-col overflow-hidden","rounded-lg border border-border-strong bg-raised shadow-3 outline-none","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0"),children:[r.jsxs("div",{className:"flex flex-none items-center gap-1.5 border-b border-hairline px-2.5 py-1.5",children:[r.jsxs("svg",{viewBox:"0 0 12 12",className:"size-3 flex-none text-muted-foreground","aria-hidden":"true",children:[r.jsx("circle",{cx:"5",cy:"5",r:"3.4",stroke:"currentColor",strokeWidth:"1.3",fill:"none"}),r.jsx("path",{d:"M7.6 7.6 10.5 10.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),r.jsx(_V,{placeholder:o,className:"min-w-0 flex-1 border-0 bg-transparent p-0 text-[12.5px] text-foreground outline-none placeholder:text-muted-foreground"})]}),r.jsx(WV,{children:r.jsx("div",{className:"px-2.5 py-3 text-[11.5px] leading-[1.5] text-muted-foreground",children:i})}),r.jsx(LV,{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-[5px]",children:b=>r.jsxs(qV,{value:b,disabled:b.disabled===!0,className:Ne("grid cursor-pointer grid-cols-[14px_minmax(0,1fr)] items-center gap-2 rounded-sm px-[9px] py-[5px]","text-[12.5px] leading-[1.4] text-foreground select-none outline-none","transition-colors duration-[120ms] ease-out","data-[highlighted]:bg-nav-hover","data-[selected]:bg-primary-soft data-[selected]:font-semibold data-[selected]:text-primary-fg","data-[highlighted]:data-[selected]:bg-primary-tint","data-disabled:pointer-events-none data-disabled:text-muted-foreground"),children:[r.jsx(GV,{className:"col-start-1 flex text-primary",children:r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("span",{className:"col-start-2 min-w-0 truncate",children:b.label})]},b.value)})]})})})]})}const sK=p.createContext(void 0);function _h(e){const t=p.useContext(sK);if(t===void 0&&!e)throw new Error(Vn(47));return t}const Awe={...HR,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class Ewe extends Ph{constructor(n,s,i){const o=new aS;super(Twe(n,o,s,i),Owe(o),Awe);Cn(this,"setOpen",(n,s)=>{const i=s.reason===Va,o=s.reason===xu&&s.event.detail===0,l=!n&&(s.reason===mg||s.reason==null),u=W6(s),d=this.select("activeTriggerId");if(!n&&s.reason===dR&&s.trigger==null&&d!=null&&(s.trigger=this.context.triggerElements.getById(d)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(n,s),s.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(n,s);const f=()=>{const g=DR(this.state,n,s.trigger,u());g.openChangeReason=s.reason,this.update(g)};i?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(xve,()=>{this.set("stickIfOpen",!1)}),xr.flushSync(f)):f();let m;o?m="click":l?m="dismiss":s.reason===Fd&&(m="focus"),this.set("instantType",m)})}}function Twe(e,t,n,s=!1){const i={...FR(t,n,s),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function Owe(e){return{popupRef:p.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:p.createRef(),beforeContentFocusGuardRef:p.createRef(),stickIfOpenTimeout:new Bi,triggerElements:e}}const aK=Qk(function({props:t}){const{children:n,open:s,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:l,modal:u=!1,handle:d,triggerId:f,defaultTriggerId:m=null}=t,g=Pwe(d,{modal:u,open:i,openProp:s,activeTriggerId:m,triggerIdProp:f});g.useControlledProp("openProp",s),g.useControlledProp("triggerIdProp",f);const v=g.useState("open"),b=g.useState("mounted"),y=g.useState("payload");g.useContextCallback("onOpenChange",o),g.useContextCallback("onOpenChangeComplete",l),Y6(g,v),$R(g);const{forceUnmount:k}=zR(v,g,()=>{g.update({stickIfOpen:!0,openChangeReason:null})});g.useSyncedValues({modal:u}),p.useEffect(()=>{v||g.context.stickIfOpenTimeout.clear()},[g,v]),p.useImperativeHandle(t.actionsRef,()=>({unmount:k,close:()=>g.setOpen(!1,Nt(hR))}),[k,g]);const w=v||b;return r.jsxs(sK.Provider,{value:g,children:[d&&r.jsx(_R,{handle:d,store:g}),w&&r.jsx(Iwe,{store:g,modal:u}),typeof n=="function"?n({payload:y}):n]})});function Rwe(e){return _h(!0)?r.jsx(aK,{props:e}):r.jsx(Eve,{children:r.jsx(aK,{props:e})})}function Pwe(e,t){const n=MR((s,i)=>new Ewe(t,s,i));return p.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function Iwe({store:e,modal:t}){const n=e.useState("floatingRootContext"),s=Fb(n,{outsidePressEvent:{mouse:t==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),i=s.reference,o=s.floating;return BR(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:o}),null}const Mwe=300;function _we(e,t){const n=p.useRef(null);function s(o){xr.flushSync(()=>{e.setOpen(!1,Nt(Fd,o.nativeEvent,o.currentTarget))}),cxe(n.current)?.focus()}function i(o){const l=e.select("positionerElement");if(l&&dg(o,l))e.context.beforeContentFocusGuardRef.current?.focus();else{xr.flushSync(()=>{e.setOpen(!1,Nt(Fd,o.nativeEvent,o.currentTarget))});let u=lxe(e.context.triggerFocusTargetRef.current||t.current);for(;u!==null&&Et(l,u);){const d=u;if(u=iR(u),u===d)break}u?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:s,handleFocusTargetFocus:i}}const Dwe=bR(function(t,n){const{render:s,className:i,style:o,disabled:l=!1,nativeButton:u=!0,handle:d,payload:f,openOnHover:m=!1,delay:g=Mwe,closeDelay:v=0,id:b,...y}=t,k=_h(!0),S=VR(d)??k;if(!S)throw new Error(Vn(74));const N=Ws(b),C=S.useState("isTriggerActive",N),T=S.useState("floatingRootContext"),P=S.useState("isOpenedByTrigger",N),O=S.useState("triggerPopupId",N),A=p.useRef(null),{registerTrigger:R,isMountedByThisTrigger:M}=LR(N,A,S,{payload:f,disabled:l,openOnHover:m,closeDelay:v}),_=S.useState("openChangeReason"),L=S.useState("stickIfOpen"),$=S.useState("openMethod"),D=S.useState("focusManagerModal"),F=tH(T,{enabled:!l&&m&&($!=="touch"||_!==xu),mouseOnly:!0,move:!1,handleClose:iH(),restMs:g,delay:{close:v},triggerElementRef:A,isActiveTrigger:C,isClosing:()=>S.select("transitionStatus")==="ending"}),V=Bb(T,{stickIfOpen:L}),q=aP(()=>S.select("open"),se=>{S.set("openMethod",se)}),Q=S.useState("triggerProps",M),{getButtonProps:X,buttonRef:U}=$i({disabled:l,native:u}),z={open(se){return se&&_===xu?qO.open(se):Rk.open(se)}},{preFocusGuardRef:K,handlePreFocusGuardFocus:J,handleFocusTargetFocus:ee}=_we(S,A),G=Kt("button",t,{state:{disabled:l,open:P},ref:[U,n,R,A],props:[V.reference,F,Q,q,{[kR]:"",id:N,"aria-haspopup":"dialog","aria-expanded":P,"aria-controls":O},y,X],stateAttributesMapping:z}),Y=r.jsx(p.Fragment,{children:G},N);return M&&!D?r.jsxs(p.Fragment,{children:[r.jsx(Th,{ref:K,onFocus:J}),Y,r.jsx(Th,{ref:S.context.triggerFocusTargetRef,onFocus:ee})]}):Y}),iK=p.createContext(void 0);function Lwe(){const e=p.useContext(iK);if(e===void 0)throw new Error(Vn(45));return e}const $we=p.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t;return _h().useState("mounted")||s?r.jsx(iK.Provider,{value:s,children:r.jsx(eS,{ref:n,...i})}):null}),oK=p.createContext(void 0);function zwe(){const e=p.useContext(oK);if(!e)throw new Error(Vn(46));return e}const Bwe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,anchor:l,positionMethod:u,side:d,align:f,sideOffset:m,alignOffset:g,collisionBoundary:v="clipping-ancestors",collisionPadding:b,arrowPadding:y,sticky:k,disableAnchorTracking:w=!1,collisionAvoidance:S=m6,...N}=t,C=_h(),T=Lwe(),P=Cve(),O=C.useState("floatingRootContext"),A=C.useState("mounted"),R=C.useState("open"),M=C.useState("openChangeReason"),_=C.useState("activeTriggerElement"),L=C.useState("modal"),$=C.useState("openMethod"),D=C.useState("positionerElement"),F=C.useState("instantType"),V=C.useState("transitionStatus"),q=C.useState("adaptiveOrigin"),Q=p.useRef(null),X=uR(D),U=hS({anchor:l,floatingRootContext:O,positionMethod:u,mounted:A,side:d,sideOffset:m,align:f,alignOffset:g,arrowPadding:y,collisionBoundary:v,collisionPadding:b,sticky:k,disableAnchorTracking:w,keepMounted:T,nodeId:P,collisionAvoidance:S,adaptiveOrigin:q}),z=O.useState("domReferenceElement");Ge(()=>{const G=z,Y=Q.current;if(G&&(Q.current=G),Y&&G&&G!==Y){C.set("instantType",void 0);const se=new AbortController;return X(()=>{C.set("instantType","trigger-change")},se.signal),()=>{se.abort()}}},[z,X,C]);const K=L===!0&&M!==Va;hP(R&&K,$==="touch",D,_);const J=C.useStateSetter("positionerElement"),ee={open:R,side:U.side,align:U.align,anchorHidden:U.anchorHidden,instant:F},H=mS(t,ee,{styles:U.positionerStyles,transitionStatus:V,props:N,refs:[n,J],hidden:!A,inert:!R});return r.jsxs(oK.Provider,{value:U,children:[A&&K&&r.jsx(vS,{inert:qb(!R),cutout:_}),r.jsx(Ave,{id:P,children:H})]})}),Fwe=p.createContext(void 0);function Uwe(){const[e,t]=p.useState(0),n=qe(()=>(t(i=>i+1),()=>{t(i=>Math.max(0,i-1))}));return{context:p.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}const Hwe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,initialFocus:l,finalFocus:u,...d}=t,f=_h(),m=zwe(),g=fV()!=null,{context:v,hasClosePart:b}=Uwe(),y=f.useState("open"),k=f.useState("openMethod"),w=f.useState("instantType"),S=f.useState("transitionStatus"),N=f.useState("popupProps"),C=f.useState("titleElementId"),T=f.useState("descriptionElementId"),P=f.useState("modal"),O=f.useState("mounted"),A=f.useState("openChangeReason"),R=f.useState("activeTriggerElement"),M=f.useState("floatingRootContext"),_=M.useState("floatingId"),L=f.useState("disabled"),$=f.useState("openOnHover"),D=f.useState("closeDelay");ji({open:y,ref:f.context.popupRef,onComplete(){y&&f.context.onOpenChangeComplete?.(!0)}}),eH(M,{enabled:$&&!L,closeDelay:D});const F=l===void 0?q6(f.context.popupRef):l,V=P!==!1&&b;f.useSyncedValue("focusManagerModal",V);const q=f.useStateSetter("popupElement"),Q={open:y,side:m.side,align:m.align,instant:w,transitionStatus:S},X=Kt("div",t,{state:Q,ref:[n,f.context.popupRef,q],props:[N,{id:_,role:"dialog",...Ub,"aria-labelledby":C,"aria-describedby":T,onKeyDown(U){g&&gS.has(U.key)&&U.stopPropagation()}},Kb(S),d],stateAttributesMapping:GO});return r.jsx(tS,{context:M,openInteractionType:k,modal:V,disabled:!O||A===Va,initialFocus:F,returnFocus:u,restoreFocus:"popup",previousFocusableElement:br(R)?R:void 0,nextFocusableElement:f.context.triggerFocusTargetRef,beforeContentFocusGuardRef:f.context.beforeContentFocusGuardRef,children:r.jsx(Fwe.Provider,{value:v,children:X})})}),Vwe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=_h(),d=Ws(l.id);return u.useSyncedValueWithCleanup("titleElementId",d),Kt("h2",t,{ref:n,props:[{id:d},l]})}),Kwe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=_h(),d=Ws(l.id);return u.useSyncedValueWithCleanup("descriptionElementId",d),Kt("p",t,{ref:n,props:[{id:d},l]})});function ui(e){return r.jsx(Rwe,{"data-slot":"popover",...e})}function wi(e){return r.jsx(Dwe,{"data-slot":"popover-trigger",...e})}function di({className:e,sideOffset:t=6,align:n="start",side:s,alignOffset:i,collisionPadding:o=8,anchor:l,children:u,...d}){return r.jsx($we,{children:r.jsx(Bwe,{className:"z-[35] outline-none",sideOffset:t,align:n,side:s,alignOffset:i,collisionPadding:o,anchor:l,children:r.jsx(Hwe,{"data-slot":"popover-content",className:Ne("flex max-h-[min(70vh,560px)] flex-col overflow-hidden rounded-lg border border-border-strong bg-raised text-foreground shadow-3","outline-none","data-open:animate-in data-open:fade-in-0 data-open:slide-in-from-top-1","data-closed:animate-out data-closed:fade-out-0",e),...d,children:u})})})}function qwe({className:e,...t}){return r.jsx("div",{"data-slot":"popover-header",className:Ne("flex items-center gap-2 border-b border-hairline px-3 py-2",e),...t})}function lK({className:e,...t}){return r.jsx(Vwe,{"data-slot":"popover-title",className:Ne("text-[12.5px] font-semibold text-foreground",e),...t})}function Gwe({className:e,...t}){return r.jsx(Kwe,{"data-slot":"popover-description",className:Ne("text-[11.5px] leading-[1.55] text-muted-foreground",e),...t})}function xP({page:e,pageCount:t,onPageChange:n,disabled:s=!1,className:i,infoFirst:o=!1}){const l=Math.max(1,Number(t)||1),u=Math.min(Math.max(1,Number(e)||1),l),d=r.jsx("span",{"data-slot":"pager-info",className:"text-[11.5px] text-subtle [font-variant-numeric:tabular-nums]",children:Z("第 {current} / {total} 页",{current:u,total:l})});return r.jsxs("div",{"data-slot":"pager",className:Ne("flex items-center gap-2",i),children:[o&&d,r.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:s||u<=1,onClick:()=>n(u-1),children:Z("上一页")}),r.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:s||u>=l,onClick:()=>n(u+1),children:Z("下一页")}),!o&&d]})}const cK=p.createContext(!1);function Go({className:e,render:t,children:n,...s}){const{containerRef:i,indicator:o}=rK('[data-slot="nav-item"]','[data-slot="nav-item"][data-active]'),l=Ah({defaultTagName:"div",render:t,ref:i,props:{...s,"data-slot":"nav-list",className:Ne("relative isolate flex min-h-0 flex-col gap-0.5",e),children:r.jsxs(r.Fragment,{children:[r.jsx("span",{"data-slot":"nav-list-indicator","aria-hidden":"true",...o}),n]})}});return r.jsx(cK.Provider,{value:!0,children:l})}const Wwe=jh(["relative flex h-auto w-full items-center justify-start gap-2.5 whitespace-normal text-left active:translate-y-0","border border-transparent rounded-md","shadow-none","transition-[background-color,border-color,color] duration-150 ease-out","outline-none focus-visible:shadow-focus","disabled:pointer-events-none disabled:opacity-45","[&_svg]:pointer-events-none [&_svg]:shrink-0"],{variants:{variant:{default:["cursor-pointer px-2.5 py-2","text-[12.5px] font-medium text-sidebar-fg","hover:bg-nav-hover hover:text-foreground","data-[active]:border-nav-selected-border data-[active]:bg-nav-selected-bg data-[active]:font-medium data-[active]:text-nav-selected-fg"],add:["cursor-pointer justify-center px-2 py-1.5","border-dashed border-border-strong bg-transparent","text-[11.5px] text-muted-foreground","hover:border-primary hover:text-primary-fg"]}},defaultVariants:{variant:"default"}});function Ts({className:e,variant:t,active:n=!1,count:s,icon:i,trailing:o,children:l,...u}){const d=p.useContext(cK);return r.jsxs(B,{type:"button",variant:"ghost","data-slot":"nav-item","data-active":n?"":void 0,"data-sliding":d?"":void 0,"aria-current":n?"true":void 0,className:Ne(Wwe({variant:t}),d&&"data-[active]:border-transparent data-[active]:bg-transparent data-[active]:hover:bg-transparent",e),...u,children:[i,r.jsx("span",{"data-slot":"nav-item-label",className:"min-w-0 flex-1 truncate",children:l}),o,s!=null&&r.jsx("span",{"data-slot":"nav-item-count",className:Ne("flex-none text-[10.5px] text-sidebar-muted [font-variant-numeric:tabular-nums]",n&&"text-inherit"),children:s})]})}function Qb(e){return r.jsx(PH,{"data-slot":"sheet",...e})}function Ywe(e){return r.jsx(MH,{"data-slot":"sheet-trigger",...e})}function uK(e){return r.jsx(Gb,{"data-slot":"sheet-close",...e})}function Xwe(e){return r.jsx(rP,{"data-slot":"sheet-portal",...e})}const IS=e=>r.jsx(sP,{"data-slot":"sheet-title",...e}),Qwe=e=>r.jsx(yH,{"data-slot":"sheet-description",...e});function Zwe({className:e,...t}){return r.jsx(YR,{"data-slot":"sheet-overlay",className:Ne("fixed inset-0 isolate z-30 bg-mask backdrop-blur-[3px]","transition-opacity duration-200","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...t})}function Zb({className:e,children:t,showCloseButton:n=!0,showHandle:s=!0,side:i="bottom",keepMounted:o=!1,...l}){const u=i==="center",d=i==="right",f=i==="left";return r.jsxs(Xwe,{keepMounted:o,children:[r.jsx(Zwe,{}),r.jsxs(nP,{"data-slot":"sheet-content",className:Ne("fixed z-30 flex flex-col overflow-hidden border border-border bg-surface shadow-3 outline-none","transition-[opacity,transform] duration-200 [transition-timing-function:cubic-bezier(.32,.9,.3,1)]",u?["top-1/2 left-1/2 max-h-[calc(100vh-48px)] w-[min(560px,calc(100vw-48px))]","-translate-x-1/2 -translate-y-1/2 rounded-lg","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[.985]","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards"]:d?["top-0 right-0 bottom-0 h-full w-[min(340px,86vw)] rounded-l-xl","data-open:animate-in data-open:slide-in-from-right data-open:fade-in-0","data-closed:animate-out data-closed:slide-out-to-right data-closed:fade-out-0 data-closed:fill-mode-forwards"]:f?["top-0 left-0 bottom-0 h-full w-[min(340px,86vw)] rounded-r-xl","data-open:animate-in data-open:slide-in-from-left data-open:fade-in-0","data-closed:animate-out data-closed:slide-out-to-left data-closed:fade-out-0 data-closed:fill-mode-forwards"]:["inset-x-0 bottom-0 max-h-[85svh] rounded-t-xl","data-open:animate-in data-open:slide-in-from-bottom data-open:fade-in-0","data-closed:animate-out data-closed:slide-out-to-bottom data-closed:fade-out-0 data-closed:fill-mode-forwards"],e),...l,children:[s&&!u&&!d&&!f&&r.jsx("div",{"aria-hidden":"true",className:"mx-auto mt-2 mb-1 h-1 w-9.5 shrink-0 rounded-pill bg-border-strong"}),t,n&&r.jsxs(Gb,{"data-slot":"sheet-close",render:r.jsx(B,{variant:"ghost",size:"icon-sm",className:"absolute top-3 right-3"}),children:[r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 2.5l7 7M9.5 2.5l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),r.jsx("span",{className:"sr-only",children:Z("关闭")})]})]})]})}function MS({className:e,...t}){return r.jsx("div",{"data-slot":"sheet-header",className:Ne("flex shrink-0 items-center gap-2.5 border-b border-hairline px-5 py-3 pr-10","[&_h2]:flex-1 [&_h2]:text-[15px] [&_h2]:font-semibold",e),...t})}function _S({className:e,...t}){return r.jsx("div",{"data-slot":"sheet-body",className:Ne("flex min-h-0 flex-1 flex-col gap-3.5 overflow-y-auto px-5 py-4",e),...t})}function vP({className:e,...t}){return r.jsx("div",{"data-slot":"sheet-footer",className:Ne("flex shrink-0 items-center gap-2 border-t border-hairline bg-surface-2 px-5 py-3 pb-[max(12px,env(safe-area-inset-bottom))]",e),...t})}function bP(e){const t=p.useMemo(()=>typeof window>"u"?null:window.matchMedia(e),[e]);return p.useSyncExternalStore(p.useCallback(n=>(t?.addEventListener("change",n),()=>t?.removeEventListener("change",n)),[t]),()=>t?.matches??!1,()=>!1)}function DS({open:e,onOpenChange:t,title:n,actions:s,children:i,breakpoint:o=767,side:l="right",inlineClassName:u,inlineAs:d="div",contentClassName:f,bodyClassName:m}){const g=bP(`(max-width: ${o}px)`);return p.useEffect(()=>{!g&&e&&t(!1)},[g,e,t]),p.useEffect(()=>{const v=()=>t(!1);return window.addEventListener("wb:navigation-close",v),()=>window.removeEventListener("wb:navigation-close",v)},[t]),g?r.jsx(Qb,{open:e,onOpenChange:t,children:r.jsxs(Zb,{side:l,keepMounted:!0,showHandle:!1,className:f,children:[r.jsxs(MS,{children:[r.jsx(IS,{children:n}),s]}),r.jsx(_S,{className:Ne("gap-4 [&>*]:w-full [&>*]:min-w-0 [&>*]:max-w-none",m),children:i})]})}):r.jsx(d,{"data-slot":"responsive-sheet-inline",className:u,children:i})}function Jwe(e){const{open:t,defaultOpen:n=!1,onOpenChange:s,disabled:i}=e,[o,l]=Tl({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:u,setMounted:d,transitionStatus:f}=gu(o,!0,!0),m=Ws(),[g,v]=p.useState(),b=g===null?void 0:g??m,y=qe(k=>{const w=!o,S=Nt(xu,k.nativeEvent);s(w,S),!S.isCanceled&&l(w)});return p.useMemo(()=>({defaultPanelId:m,disabled:i,handleTrigger:y,mounted:u,open:o,panelId:b,setMounted:d,setOpen:l,setPanelIdState:v,transitionStatus:f}),[m,i,y,u,o,b,d,l,v,f])}const dK=p.createContext(void 0);function fK(){const e=p.useContext(dK);if(e===void 0)throw new Error(Vn(15));return e}const e0e="data-open",t0e="data-closed",n0e=KO,r0e="data-panel-open",s0e={[e0e]:""},a0e={[t0e]:""},i0e={open(e){return e?{[r0e]:""}:null}},hK={...{open(e){return e?s0e:a0e}},...Fo},o0e=p.forwardRef(function(t,n){const{render:s,className:i,defaultOpen:o=!1,disabled:l=!1,onOpenChange:u,open:d,style:f,...m}=t,g=qe(u),v=Jwe({open:d,defaultOpen:o,onOpenChange:g,disabled:l}),b=p.useMemo(()=>({open:v.open,disabled:v.disabled,transitionStatus:v.transitionStatus}),[v.open,v.disabled,v.transitionStatus]),y=p.useMemo(()=>({...v,onOpenChange:g,state:b}),[v,g,b]),k=Kt("div",t,{state:b,ref:n,props:m,stateAttributesMapping:hK});return r.jsx(dK.Provider,{value:y,children:k})}),l0e={...i0e,...Fo},c0e=p.forwardRef(function(t,n){const{panelId:s,open:i,handleTrigger:o,state:l,disabled:u}=fK(),{className:d,disabled:f=u,render:m,nativeButton:g=!0,style:v,...b}=t,{getButtonProps:y,buttonRef:k}=$i({disabled:f,focusableWhenDisabled:!0,native:g});return Kt("button",t,{state:l,ref:[n,k],props:[{"aria-controls":i?s:void 0,"aria-expanded":i,onClick:o},b,y],stateAttributesMapping:l0e})}),Jb={height:void 0,width:void 0};function u0e(e){const{externalRef:t,hiddenUntilFound:n,id:s,keepMounted:i,mounted:o,onOpenChange:l,open:u,setMounted:d,setOpen:f,transitionStatus:m}=e,g=p.useRef(null),v=p.useRef(null),[b,y]=p.useState(Jb),k=p.useRef(Jb),w=p.useRef(!1),S=p.useRef(u),N=p.useRef(!1),[C,T]=p.useState(!1),P=p.useRef(null),O=lo(t,g),A=ss(u),R=uR(g),M=!u&&!o,_=C?"idle":m,L=u&&(S.current||N.current),$=!u&&o&&v.current==="css-animation"&&b.height===void 0&&b.width===void 0?k.current:b,D=n&&M&&v.current!=="css-animation",F=qe((U,z=!0)=>{z&&(k.current=U),y(U)}),V=qe(()=>{P.current?.(),P.current=null}),q=qe(U=>{V(),P.current=()=>{P.current=null,U()}}),Q=qe(()=>{u&&o&&v.current==="css-animation"&&(N.current=!0)});Ge(()=>{!C||m==="starting"||T(!1)},[C,m]),p.useEffect(()=>()=>{Q(),V()},[Q,V]),Ge(()=>{const U=g.current;if(!U)return;!u&&P.current&&V();const z=d0e(U,L);if(v.current=z,u&&m==="idle"&&S.current&&z==="css-animation"){k.current=jg(U);return}if(u&&m==="starting"){const ee=w.current;if(w.current=!1,z==="none"){F(jg(U)),T(!0);return}if(z==="css-transition"){const Y=f0e(U);if(F(jg(U)),!ee)return Y;const se=LS(U,"transition-duration","0s");return q(se),T(!0),Y}F(jg(U));const H=LS(U,"animation-name","none");if(!ee){H();return}const G=LS(U,"animation-duration","0s");H(),q(G),T(!0);return}if(!u&&o&&(m==="idle"||m==="starting")){if(S.current=!1,N.current=!1,z==="none"){F(Jb,!1),d(!1);return}F(jg(U));return}if(m!=="ending")return;if(z==="none"){d(!1);return}const K=jg(U);if(!(K.height>0||K.width>0)){d(!1);return}F(K),z==="css-animation"&&LS(U,"animation-name","none")()},[o,u,V,F,d,q,L,m]),ji({enabled:u&&o&&_==="idle",open:!0,ref:g,onComplete(){u&&F(Jb,!1)}}),p.useEffect(()=>{if(u||!o||_!=="ending"||!g.current)return;const z=new AbortController;let K=-1;function J(){A.current||(d(!1),F(Jb,!1))}return K=Fi.request(()=>{R(J,z.signal)}),()=>{Fi.cancel(K),z.abort()}},[A,o,u,_,R,F,d]),Ge(()=>{const U=g.current;!U||!n||!M||U.setAttribute("hidden","until-found")},[M,n]),p.useEffect(function(){const z=g.current;if(!z)return;function K(J){const ee=Nt(rs,J);l(!0,ee),!ee.isCanceled&&(w.current=!0,f(!0))}return kn(z,"beforematch",K)},[l,f]);const X=i||n||o||u;return{height:$.height,props:{...D?{[n0e]:""}:void 0,hidden:M,id:s},ref:O,shouldPreventOpenAnimation:L,shouldRender:X,transitionStatus:_,width:$.width}}function jg(e){return{height:e.scrollHeight,width:e.scrollWidth}}function d0e(e,t){const n=vr(e).getComputedStyle(e),s=(n.animationName.split(",").map(o=>o.trim()).some(o=>o!==""&&o!=="none")||t)&&mK(n.animationDuration),i=mK(n.transitionDuration);return s&&i||i?"css-transition":s?"css-animation":"none"}function mK(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function LS(e,t,n){const s=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(s===""){e.style.removeProperty(t);return}e.style.setProperty(t,s,i)}}function f0e(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(i=>{e.style.setProperty(i,"initial","important")});function n(){Object.entries(t).forEach(([i,o])=>{if(o===""){e.style.removeProperty(i);return}e.style.setProperty(i,o)})}const s=Fi.request(n);return()=>{Fi.cancel(s),n()}}const h0e="--collapsible-panel-height",m0e="--collapsible-panel-width",p0e=p.forwardRef(function(t,n){const{className:s,hiddenUntilFound:i,keepMounted:o,render:l,id:u,style:d,...f}=t,{defaultPanelId:m,mounted:g,onOpenChange:v,open:b,setMounted:y,setPanelIdState:k,setOpen:w,state:S,transitionStatus:N}=fK(),C=i??!1,T=o??!1,P=u||void 0,O=P??m;Ge(()=>(k(Q=>P??(Q===null?void 0:Q)),()=>{k(Q=>Q===P?null:Q)}),[P,k]);const{height:A,props:R,ref:M,shouldPreventOpenAnimation:_,shouldRender:L,transitionStatus:$,width:D}=u0e({externalRef:n,hiddenUntilFound:C,id:O,keepMounted:T,mounted:g,onOpenChange:v,open:b,setMounted:y,setOpen:w,transitionStatus:N}),F={...S,transitionStatus:$},V=zF(d,F),q=Kt("div",{...t,style:void 0},{state:F,ref:M,props:[R,{style:{[h0e]:A===void 0?"auto":`${A}px`,[m0e]:D===void 0?"auto":`${D}px`}},f,V?{style:V}:void 0,_?{style:{animationName:"none"}}:void 0],stateAttributesMapping:hK});return L?q:null});function gs(e){return r.jsx(o0e,{"data-slot":"collapsible",...e})}function xs({className:e,render:t,...n}){return r.jsx(c0e,{"data-slot":"collapsible-trigger",render:t??r.jsx(B,{variant:"ghost"}),className:e,...n})}function vs({className:e,...t}){return r.jsx(p0e,{"data-slot":"collapsible-content",className:Ne("min-w-0",typeof e=="string"&&e),...t})}function Fe({className:e,variant:t="default",...n}){return r.jsx("div",{"data-slot":"alert",role:"alert",className:Ne("rounded-md border px-3 py-2.5 text-[12.5px] leading-relaxed",t==="default"&&"border-border bg-surface-2 text-subtle",t==="destructive"&&"border-destructive-bd bg-destructive-soft text-destructive",t==="warning"&&"border-warning-bd bg-warning-soft text-warning",t==="success"&&"border-success-bd bg-success-soft text-success",e),...n})}function wg({className:e,...t}){return r.jsx("div",{"data-slot":"alert-title",className:Ne("font-semibold",e),...t})}function ho({className:e,...t}){return r.jsx("div",{"data-slot":"alert-description",className:Ne("text-[12px] leading-relaxed",e),...t})}function pt({className:e,...t}){return r.jsx("div",{"data-slot":"empty",className:Ne("flex flex-col items-center justify-center gap-2 px-4 py-8 text-center text-[12.5px] leading-relaxed text-muted-foreground",e),...t})}function yP({className:e,...t}){return r.jsx("div",{"data-slot":"empty-title",className:Ne("text-[13px] font-semibold text-foreground",e),...t})}function jP({className:e,...t}){return r.jsx("div",{"data-slot":"empty-description",className:Ne("text-[12px] leading-relaxed text-muted-foreground",e),...t})}function Ka({className:e,variant:t="success",pulse:n,...s}){return r.jsx("span",{"data-slot":"status-dot","aria-hidden":"true",className:Ne("inline-block size-[7px] shrink-0 rounded-full",t==="success"&&"bg-success",t==="warning"&&"bg-warning",t==="destructive"&&"bg-destructive",t==="muted"&&"bg-muted-foreground",n&&"animate-pulse motion-reduce:animate-none",e),...s})}const g0e=new Set(["a","article","b","blockquote","br","code","del","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","kbd","li","ol","p","pre","s","section","small","span","strong","sub","sup","ul","col","colgroup"]),pK={button:B,input:ze,label:Ae,textarea:Xs,table:ps,thead:Qs,tbody:Es,tfoot:Bye,tr:Jt,th:tt,td:Ve,caption:Fye},x0e=new Set(["text-align","white-space","word-break","overflow-wrap","font-weight","font-style","font-size","line-height","color","background-color","width","max-width","min-width","height","padding","margin","display","gap","flex","grid-column"]);function gK(e,t=!1){if(t&&/^data:image\/(?:png|jpe?g|gif|webp|avif);base64,/i.test(e)||/^(?:https?:\/\/|\/[^/]|\.\.?\/|#)/i.test(e))return e}function v0e(e){const t={};for(const n of e.attributes)n.name==="class"?t.className=n.value:n.name==="colspan"?t.colSpan=Number(n.value)||1:n.name==="rowspan"?t.rowSpan=Number(n.value)||1:n.name==="target"&&["_blank","_self"].includes(n.value)?t.target=n.value:n.name==="loading"&&["lazy","eager"].includes(n.value)?t.loading=n.value:["title","id","role","alt","scope","type","placeholder"].includes(n.name)||/^(aria-|data-)/.test(n.name)?t[n.name]=n.value:n.name==="href"?t.href=gK(n.value):n.name==="src"&&(t.src=gK(n.value,!0));if(e.tagName==="A"&&(t.rel="noopener noreferrer"),e instanceof HTMLElement){const n={};for(const s of e.style){if(!x0e.has(s))continue;const i=e.style.getPropertyValue(s);/url\(|expression\(/i.test(i)||(n[s.replace(/-([a-z])/g,(o,l)=>l.toUpperCase())]=i)}Object.keys(n).length&&(t.style=n)}return t}function $S(e,t=""){return Array.from(e).map((n,s)=>{const i=`${t}${s}`;if(n.nodeType===Node.TEXT_NODE)return n.textContent;if(!(n instanceof Element))return null;const o=n.tagName.toLowerCase();if(["script","style","iframe","object","embed"].includes(o))return null;const l=v0e(n),u=$S(n.childNodes,`${i}-`);if(o==="details"){const d=Array.from(n.children).find(f=>f.tagName==="SUMMARY");return r.jsxs(gs,{defaultOpen:n.hasAttribute("open"),...l,children:[r.jsxs(xs,{className:Ne("h-auto w-full justify-start whitespace-normal px-0 text-left",d?.className),children:[r.jsx("span",{className:"shrink-0 transition-transform in-data-panel-open:rotate-90","aria-hidden":"true",children:"▸"}),d?$S(d.childNodes,`${i}-summary-`):"…"]}),r.jsx(vs,{keepMounted:!0,children:$S(Array.from(n.childNodes).filter(f=>f!==d),`${i}-body-`)})]},i)}if(o==="span"&&n.classList.contains("badge")){const d=n.classList.contains("ok")||n.classList.contains("phase-streaming")?"success":n.classList.contains("bad")?"destructive":n.classList.contains("warn")?"warning":n.classList.contains("brand")?"brand":"outline";return r.jsx(Ee,{variant:d,shape:n.classList.contains("tag")?"tag":"pill",...l,children:u},i)}return o==="span"&&n.classList.contains("req-live-dot")?r.jsx(Ka,{pulse:!0,className:"size-[5px] bg-current"},i):o==="div"&&n.classList.contains("empty")?r.jsx(pt,{...l,children:u},i):o==="input"&&n.getAttribute("type")==="checkbox"?r.jsx(jr,{checked:n.hasAttribute("checked"),readOnly:!0},i):o==="table"?r.jsx(ps,{container:!1,...l,children:u},i):pK[o]?p.createElement(pK[o],{key:i,...l},o==="input"?void 0:u):g0e.has(o)?["br","hr","img","col"].includes(o)?p.createElement(o,{key:i,...l}):p.createElement(o,{key:i,...l},u):r.jsx(p.Fragment,{children:u},i)})}function Wo({html:e,className:t,render:n,...s}){const i=p.useMemo(()=>{if(!e)return[];const o=new DOMParser().parseFromString(e,"text/html");return $S(o.body.childNodes)},[e]);return Ah({defaultTagName:"div",render:n,props:{...s,"data-slot":"html-content",className:Ne(t),children:i}})}const xK=p.createContext(void 0);function b0e(){const e=p.useContext(xK);if(e===void 0)throw new Error(Vn(38));return e}const y0e=p.forwardRef(function(t,n){const{format:s,getAriaValueText:i,locale:o,max:l=100,min:u=0,value:d,render:f,className:m,children:g,style:v,...b}=t,[y,k]=p.useState(),w=e6(d,u,l),S=bu(Number.isNaN(w)?0:w,0,100),N=bu(Number.isNaN(d)?u:d,u,l),C=s?Xk(N,o,s):Xk(S/100,o,{style:"percent"});let T=C;i&&(T=i(C,d));const P={"aria-labelledby":y,"aria-valuemax":l,"aria-valuemin":u,"aria-valuenow":N,"aria-valuetext":T,role:"meter",children:r.jsxs(p.Fragment,{children:[g,r.jsx("span",{role:"presentation",style:vu,children:"x"})]})},O=p.useMemo(()=>({formattedValue:C,percentageValue:S,setLabelId:k,value:d}),[C,S,k,d]),A=Kt("div",t,{ref:n,props:[P,b]});return r.jsx(xK.Provider,{value:O,children:A})}),j0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t;return Kt("div",t,{ref:n,props:l})}),w0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,{percentageValue:u}=b0e();return Kt("div",t,{ref:n,props:[{style:{insetInlineStart:0,height:"inherit",width:`${u}%`}},l]})});function kg({value:e,variant:t="default",className:n,trackClassName:s,indicatorClassName:i,...o}){const l=Ne("block h-1 w-full overflow-hidden rounded-pill bg-hairline",s);return e===null?r.jsx("span",{"data-slot":"meter","aria-hidden":"true",className:Ne("block w-full",n),children:r.jsx("span",{"data-slot":"meter-track",className:l})}):r.jsx(y0e,{render:r.jsx("span",{}),value:e,"data-slot":"meter",className:Ne("block w-full",n),...o,children:r.jsx(j0e,{render:r.jsx("span",{}),"data-slot":"meter-track",className:l,children:r.jsx(w0e,{render:r.jsx("span",{}),"data-slot":"meter-indicator",className:Ne("block h-full rounded-[inherit] transition-[width] duration-300 motion-reduce:transition-none",t==="default"&&"bg-primary",t==="success"&&"bg-success",t==="warning"&&"bg-warning",t==="destructive"&&"bg-destructive",t==="muted"&&"bg-muted-foreground",i)})})})}function et({className:e,size:t="default",render:n,...s}){return Ah({defaultTagName:"div",render:n,props:{...s,"data-slot":"card","data-size":t,className:Ne("group/card min-w-0 overflow-hidden rounded-lg border border-border bg-surface text-foreground shadow-1",e)}})}function pn({className:e,...t}){return r.jsx("div",{"data-slot":"card-header",className:Ne("flex flex-wrap items-center gap-2.5 border-b border-border px-4 py-3 group-data-[size=sm]/card:px-3 group-data-[size=sm]/card:py-2",e),...t})}function Fs({className:e,...t}){return r.jsx("h3",{"data-slot":"card-title",className:Ne("m-0 text-[14px] font-semibold leading-snug",e),...t})}function k0e({className:e,...t}){return r.jsx("p",{"data-slot":"card-description",className:Ne("m-0 text-[12px] leading-relaxed text-subtle",e),...t})}function vK({className:e,...t}){return r.jsx("div",{"data-slot":"card-action",className:Ne("ml-auto flex shrink-0 flex-wrap items-center gap-2",e),...t})}function Gt({className:e,...t}){return r.jsx("div",{"data-slot":"card-content",className:Ne("min-w-0 p-4 group-data-[size=sm]/card:p-3",e),...t})}function ju({className:e,...t}){return r.jsx("div",{"data-slot":"card-footer",className:Ne("flex flex-wrap items-center gap-2 border-t border-border px-4 py-2.5 text-[11.5px] leading-relaxed text-muted-foreground",e),...t})}function wP({className:e,...t}){return r.jsx(et,{"data-slot":"metric-card",className:Ne("rounded-md bg-surface-inset px-3.5 py-3",e),...t})}function bK({className:e,...t}){return r.jsx("div",{"data-slot":"metric-label",className:Ne("mb-1 text-[11.5px] text-muted-foreground",e),...t})}function yK({className:e,...t}){return r.jsx("div",{"data-slot":"metric-value",className:Ne("break-all text-[13px] font-semibold leading-normal tabular-nums",e),...t})}function jK({className:e,...t}){return r.jsx("div",{"data-slot":"metric-grid",className:Ne("grid grid-cols-[repeat(auto-fit,minmax(min(178px,100%),1fr))] gap-2.5",e),...t})}function qa(e,t={}){return new Promise(n=>{const s=document.createElement("div");document.body.append(s);const i=zn.createRoot(s),o=p.createRef();let l=!1;const u=d=>{l||(l=!0,queueMicrotask(()=>{i.unmount(),s.remove()}),n(d))};i.render(r.jsx(LH,{open:!0,onOpenChange:d=>{d||u(!1)},children:r.jsxs(zH,{initialFocus:o,children:[r.jsx(BH,{children:r.jsx($H,{children:t.title||Z("请确认")})}),r.jsx(FH,{children:r.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-relaxed",children:e})}),r.jsxs(UH,{children:[r.jsx(B,{ref:o,variant:"outline",onClick:()=>u(!1),children:Z("取消")}),r.jsx(B,{variant:t.destructive===!1?"default":"destructive",onClick:()=>u(!0),children:t.confirmText||Z("确定")})]})]})}))})}function Dh({className:e,render:t,variant:n="default",size:s="default",...i}){return Ah({defaultTagName:"div",render:t,props:{...i,"data-slot":"item","data-size":s,className:Ne("flex w-full min-w-0 items-center gap-2.5 rounded-md text-left text-foreground transition-colors",s==="sm"?"px-3 py-2 text-[12.5px]":"px-3.5 py-3 text-[13px]",n==="outline"&&"border border-border",n==="muted"&&"bg-surface-2","has-[[data-slot=item-content]]:justify-start",e)}})}function wK({className:e,...t}){return r.jsx("div",{"data-slot":"item-group",role:"list",className:Ne("flex flex-col",e),...t})}function kK({className:e,...t}){return r.jsx("div",{"data-slot":"item-content",className:Ne("min-w-0 flex-1",e),...t})}function SK({className:e,...t}){return r.jsx("div",{"data-slot":"item-title",className:Ne("text-[13px] font-medium",e),...t})}function NK({className:e,...t}){return r.jsx("p",{"data-slot":"item-description",className:Ne("m-0 mt-0.5 text-[12px] leading-relaxed text-muted-foreground",e),...t})}function S0e({className:e,...t}){return r.jsx("div",{"data-slot":"item-media",className:Ne("flex shrink-0 items-center justify-center",e),...t})}function CK({className:e,...t}){return r.jsx("div",{"data-slot":"item-actions",className:Ne("ml-auto flex shrink-0 items-center gap-2",e),...t})}const N0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,disabled:l=!1,...u}=t,[d,f]=p.useState(void 0),g=BO(!0)?.disabled||l,b=Kt("fieldset",t,{ref:n,state:{disabled:g},props:[{"aria-labelledby":d,disabled:g},u]}),y=p.useMemo(()=>({legendId:d,setLegendId:f,disabled:g}),[d,f,g]);return r.jsx(fU.Provider,{value:y,children:b})}),AK=jh("min-w-0",{variants:{orientation:{vertical:"flex flex-col gap-1.5",horizontal:"flex flex-wrap items-center gap-2.5",responsive:"flex flex-col gap-1.5 min-[768px]:flex-row min-[768px]:items-center min-[768px]:gap-2.5"}},defaultVariants:{orientation:"vertical"}});function ct({className:e,orientation:t,...n}){return r.jsx(xxe,{"data-slot":"field",className:s=>Ne(AK({orientation:t}),typeof e=="function"?e(s):e),...n})}function Lh({className:e,orientation:t,...n}){return r.jsx("div",{"data-slot":"field-group",className:Ne(t?AK({orientation:t}):"flex flex-col gap-3",e),...n})}function C0e({className:e,...t}){return r.jsx(N0e,{"data-slot":"field-set",className:n=>Ne("m-0 min-w-0 border-0 p-0",typeof e=="function"?e(n):e),...t})}function ut({className:e,...t}){return r.jsx(bxe,{"data-slot":"field-label",className:n=>Ne("flex items-center gap-[6px] text-[11.5px] text-muted-foreground",typeof e=="function"?e(n):e),...t})}function kP({className:e,...t}){return r.jsx("div",{"data-slot":"field-content",className:Ne("min-w-0 flex-1",e),...t})}function wr({className:e,...t}){return r.jsx(wxe,{"data-slot":"field-description",className:n=>Ne("m-0 text-[11.5px] leading-relaxed text-subtle",typeof e=="function"?e(n):e),...t})}const EK=p.createContext(void 0);function SP(){const e=p.useContext(EK);if(!e)throw new Error(Vn(73));return e}let TK=0;function OK(e){return TK+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${TK}`}function NP(e,t){if(typeof e=="string")return{description:e};if(typeof e=="function"){const n=e(t);return typeof n=="string"?{description:n}:n}return e}function CP(e){const t=new Map;let n=0,s=0;return e.forEach((i,o)=>{const l=i.transitionStatus==="ending";t.set(i.id,{value:i,domIndex:o,visibleIndex:l?-1:n,offsetY:s}),s+=i.height||0,l||(n+=1)}),t}function AP(e,t){let n=0;return e.map(s=>{if(s.transitionStatus==="ending")return s;const i=n>=t;return n+=1,s.limited===i?s:{...s,limited:i}})}const Pl={toasts:e=>e.toasts,isEmpty:e=>e.toasts.length===0,toast:(e,t)=>e.toastMetadata.get(t)?.value,toastIndex:(e,t)=>e.toastMetadata.get(t)?.domIndex??-1,toastOffsetY:(e,t)=>e.toastMetadata.get(t)?.offsetY??0,toastVisibleIndex:(e,t)=>e.toastMetadata.get(t)?.visibleIndex??-1,focused:e=>e.focused,expanded:e=>e.hovering||e.focused,expandedOrOutOfFocus:e=>e.hovering||e.focused||!e.isWindowFocused,prevFocusElement:e=>e.prevFocusElement};class A0e extends Ph{constructor(n){super({...n,toastMetadata:CP(n.toasts)},{},Pl);Cn(this,"timers",new Map);Cn(this,"areTimersPaused",!1);Cn(this,"setViewport",n=>{this.set("viewport",n)});Cn(this,"disposeEffect",()=>()=>{this.timers.forEach(n=>{n.timeout?.clear()}),this.timers.clear()});Cn(this,"addToast",n=>{const{timeout:s,limit:i}=this.state,o=n.id||OK("toast");if(n.id){const f=Pl.toast(this.state,n.id);if(f)if(f.transitionStatus==="ending")this.removeToast(n.id,!0);else{const{id:m,transitionStatus:g,...v}=n;return this.updateToastInternal(n.id,v,!0,!0),n.id}}const l={...n,id:o,updateKey:0,transitionStatus:"starting"},u=[l,...this.state.toasts];this.setToasts(AP(u,i));const d=l.timeout??s;return l.type!=="loading"&&d>0&&this.scheduleTimer(o,d,()=>this.closeToast(o)),Pl.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),o});Cn(this,"updateToast",(n,s)=>{const i=Pl.toast(this.state,n);!i||i.transitionStatus==="ending"||this.updateToastInternal(n,typeof s=="function"?s(i):s,!1,!0)});Cn(this,"updateToastInternal",(n,s,i=!1,o=!1)=>{const{timeout:l,toasts:u}=this.state,d=Pl.toast(this.state,n);if(!d||d.transitionStatus==="ending")return;const f={...d,...s,...o&&{updateKey:d.updateKey+1}};this.setToasts(u.map(S=>S.id===n?f:S));const m=f.timeout??l,g=d.timeout??l,v=Object.hasOwn(s,"timeout"),b=f.transitionStatus!=="ending"&&f.type!=="loading"&&m>0,y=this.timers.has(n),k=g!==m,w=d.type==="loading";if(!b&&y){this.clearTimer(n);return}b&&(!y||k||v||w||i)&&(this.clearTimer(n),this.scheduleTimer(n,m,()=>this.closeToast(n)),Pl.expandedOrOutOfFocus(this.state)&&this.pauseTimers())});Cn(this,"closeToast",n=>{const s=n===void 0,{limit:i,toasts:o}=this.state;let l;if(s)l=o,this.clearTimers();else{const f=Pl.toast(this.state,n);if(!f)return;l=[f],this.clearTimer(n)}const u=o.map(f=>s||f.id===n?{...f,transitionStatus:"ending",height:0}:f),d=AP(u,i);this.setToasts(d,!d.some(f=>f.transitionStatus!=="ending")),l.forEach(f=>{f.transitionStatus!=="ending"&&f.onClose?.()}),this.handleFocusManagement(n)});Cn(this,"promiseToast",(n,s)=>{const i=NP(s.loading),o=this.addToast({...i,type:"loading"}),l=n.then(u=>{const d=NP(s.success,u);return this.updateToast(o,{...d,type:"success",timeout:d.timeout}),u}).catch(u=>{const d=NP(s.error,u);return this.updateToast(o,{...d,type:"error",timeout:d.timeout}),Promise.reject(u)});return{}.hasOwnProperty.call(s,"setPromise")&&s.setPromise(l),l});Cn(this,"handleDocumentPointerDown",n=>{if(n.pointerType!=="touch")return;const s=Er(n);Et(this.state.viewport,s)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))})}syncProviderProps(n,s){const i=this.state.limit!==s;if(this.state.timeout===n&&!i)return;const o={timeout:n,limit:s};if(i){const l=AP(this.state.toasts,s);o.toasts=l,o.toastMetadata=CP(l)}this.update(o)}removeToast(n,s=!1){const i=Pl.toastIndex(this.state,n);if(i===-1)return;const o=this.state.toasts[i];s||o?.onRemove?.();const l=[...this.state.toasts];l.splice(i,1),this.setToasts(l)}pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(n=>{n.timeout&&(n.timeout.clear(),n.remaining=Math.max(n.remaining-(Date.now()-n.start),0))}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((n,s)=>{n.remaining=n.remaining>0?n.remaining:n.delay,n.timeout??(n.timeout=Bi.create()),n.timeout.start(n.remaining,()=>{this.handleTimerFired(s),n.callback()}),n.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}scheduleTimer(n,s,i){const o=Date.now(),u=!Pl.expandedOrOutOfFocus(this.state)?Bi.create():void 0;u?.start(s,()=>{this.handleTimerFired(n),i()}),this.timers.set(n,{timeout:u,start:o,delay:s,remaining:s,callback:i})}clearTimers(){this.timers.forEach(n=>{n.timeout?.clear()}),this.timers.clear(),this.areTimersPaused=!1}clearTimer(n){this.timers.get(n)?.timeout?.clear(),this.timers.delete(n),this.resetPausedStateIfNoTimersRemain()}handleTimerFired(n){this.timers.delete(n),this.resetPausedStateIfNoTimersRemain()}resetPausedStateIfNoTimersRemain(){this.timers.size===0&&(this.areTimersPaused=!1)}setToasts(n,s=n.length===0){const i={toasts:n,toastMetadata:CP(n)};s&&(i.hovering=!1,i.focused=!1),this.update(i)}handleFocusManagement(n){const s=Ys(_n(this.state.viewport));if(!this.state.viewport||!Et(this.state.viewport,s)||!Mk(s))return;if(n===void 0){this.restoreFocusToPrevElement();return}const i=Pl.toasts(this.state),o=Pl.toastIndex(this.state,n),l=(d,f)=>{for(let m=d;m>=0&&mnew A0e({timeout:s,limit:i,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return Uk(l.disposeEffect),p.useEffect(function(){return o?o[" subscribe"](({action:f,options:m})=>{const g=m.id;f==="promise"&&m.promise?l.promiseToast(m.promise,m):f==="update"&&g?l.updateToast(g,m.updates):f==="close"?l.closeToast(g):l.addToast(m)}):void 0},[l,o]),r.jsxs(EK.Provider,{value:l,children:[r.jsx(T0e,{store:l,timeout:s,limit:i}),n]})};function T0e(e){const{store:t,timeout:n,limit:s}=e;return Ge(()=>{t.syncProviderProps(n,s)},[t,n,s]),null}const O0e="--toast-frontmost-height",R0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,children:l,...u}=t,d=SP(),f=fa(),m=p.useRef(!1),g=p.useRef(!1),v=p.useRef(!1),b=d.useState("isEmpty"),y=d.useState("toasts"),k=d.useState("focused"),w=d.useState("expanded"),S=d.useState("prevFocusElement"),N=y[0]?.height,C=y.some(U=>U.transitionStatus==="ending"),T=y.filter(U=>U.priority==="high");p.useEffect(()=>{const U=d.state.viewport;if(!U||b)return;const z=vr(U),K=_n(U);function J(G){G.key==="F6"&&Er(G)!==U&&(G.preventDefault(),d.set("prevFocusElement",Ys(K)),U?.focus({preventScroll:!0}),d.pauseTimers(),d.set("focused",!0))}function ee(G){Er(G)===z&&(d.set("isWindowFocused",!1),d.pauseTimers())}function H(G){if(G.relatedTarget)return;const Y=Er(G),se=Ys(_n(U));(Y===z||!Et(U,Y)||!Mk(se))&&d.resumeTimers(),f.start(0,()=>d.set("isWindowFocused",!0))}return Ol(kn(z,"keydown",J),kn(z,"blur",ee,!0),kn(z,"focus",H,!0),kn(K,"pointerdown",d.handleDocumentPointerDown,!0))},[d,f,b]);function P(U){m.current=!0;const z=U.relatedTarget===d.state.viewport?y.find(K=>K.transitionStatus!=="ending"&&!K.limited):void 0;z?z.ref?.current?.focus():d.restoreFocusToPrevElement()}function O(U){U.key==="Tab"&&U.shiftKey&&Er(U.nativeEvent)===d.state.viewport&&(U.preventDefault(),d.restoreFocusToPrevElement())}function A(){d.state.toasts.some(z=>z.transitionStatus==="ending")||v.current||!g.current||(d.state.isWindowFocused&&d.resumeTimers(),d.set("hovering",!1),g.current=!1)}p.useEffect(A,[C,d]);function R(){d.pauseTimers(),d.set("hovering",!0),g.current=!1}function M(){d.state.isWindowFocused&&d.resumeTimers()}function _(){g.current=!0,A()}function L(U){U.pointerType==="touch"&&(v.current=!0)}function $(U){U.pointerType==="touch"&&(v.current=!1,A())}function D(){if(m.current){m.current=!1;return}k||Mk(Ys(_n(d.state.viewport)))&&(d.set("focused",!0),d.pauseTimers())}function F(U){!k||Et(d.state.viewport,U.relatedTarget)||(d.set("focused",!1),M())}const V={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:R,onMouseMove:R,onMouseLeave:_,onFocus:D,onBlur:F,onKeyDown:O,onClick:D,onPointerDown:L,onPointerUp:$,onPointerCancel:$,style:{[O0e]:N?`${N}px`:void 0}},q={expanded:w},Q=!b&&S&&r.jsx(Th,{onFocus:P}),X=Kt("div",t,{ref:[n,d.setViewport],state:q,props:[V,u,{children:r.jsxs(p.Fragment,{children:[Q,l,Q]})}]});return r.jsxs(p.Fragment,{children:[Q,X,!k&&T.length>0&&r.jsx("div",{style:vu,children:T.map(U=>r.jsxs("div",{role:"alert","aria-atomic":!0,children:[r.jsx("div",{children:U.title}),r.jsx("div",{children:U.description})]},U.id))})]})}),RK=p.createContext(void 0);function P0e(){const e=p.useContext(RK);if(!e)throw new Error(Vn(66));return e}function I0e(e,t){const n=vr(e).getComputedStyle(e).transform;let s=0,i=0,o=1;if(n&&n!=="none"){const l=n.match(/matrix(?:3d)?\(([^)]+)\)/);if(l){const u=l[1].split(", ").map(parseFloat);u.length===6?(s=u[4],i=u[5],o=Math.sqrt(u[0]*u[0]+u[1]*u[1])):u.length===16&&(s=u[12],i=u[13],o=u[0])}}return{x:s,y:i,scale:o}}function EP(e,t,n){switch(e){case"up":return-n;case"down":return n;case"left":return-t;case"right":return t;default:return 0}}const M0e="--toast-index",_0e="--toast-offset-y",D0e="--toast-height",L0e="--toast-swipe-movement-x",$0e="--toast-swipe-movement-y",z0e="data-swipe-direction",B0e={...Fo,swipeDirection(e){return e?{[z0e]:e}:null}},PK=40,F0e=10,IK=.5,U0e=1,H0e=`${jve},${wve}`,V0e=p.forwardRef(function(t,n){const{toast:s,render:i,className:o,swipeDirection:l=["down","right"],style:u,...d}=t,f=s.positionerProps?.anchor!==void 0;let m=[];f||(m=Array.isArray(l)?l:[l]);const g=m.length>0,v=SP(),[b,y]=p.useState(void 0),[k,w]=p.useState(!1),[S,N]=p.useState(!1),[C,T]=p.useState({x:0,y:0}),[P,O]=p.useState({x:0,y:0,scale:1}),[A,R]=p.useState(),[M,_]=p.useState(),[L,$]=p.useState(null),D=p.useRef(null),F=p.useRef(void 0),V=p.useRef({x:0,y:0}),q=p.useRef({x:0,y:0,scale:1}),Q=p.useRef(void 0),X=p.useRef(0),U=p.useRef(!1),z=p.useRef({x:0,y:0}),K=p.useRef(!1),J=p.useRef({x:0,y:0}),ee=p.useRef(null),H=p.useRef(null),G=v.useState("toastIndex",s.id),Y=v.useState("toastVisibleIndex",s.id),se=v.useState("toastOffsetY",s.id),re=v.useState("focused"),ne=v.useState("expanded");ji({open:s.transitionStatus!=="ending",ref:D,onComplete(){s.transitionStatus==="ending"&&v.removeToast(s.id)}});const de=qe((Se=!1)=>{const ge=D.current;if(!ge)return;const ue=ge.style.height;ge.style.height="auto";const be=ge.offsetHeight;ge.style.height=ue;function ve(){v.updateToastInternal(s.id,{ref:D,height:be,transitionStatus:void 0})}Se?xr.flushSync(ve):ve()});Ge(()=>{const Se=F.current;s.transitionStatus!=="starting"&&Se===s.id||(Se!==void 0&&(y(void 0),O({x:0,y:0,scale:1}),ie({x:0,y:0})),F.current=s.id,de())},[de,s.id,s.transitionStatus]);function ie(Se){J.current=Se,T(Se)}Ge(()=>()=>{H.current?.abort()},[]);function oe(Se,ge){const ue=De=>De>0?De**IK:-(Math.abs(De)**IK),be=Se>0&&!m.includes("right")||Se<0&&!m.includes("left"),ve=ge>0&&!m.includes("down")||ge<0&&!m.includes("up");return{x:be?ue(Se):Se,y:ve?ue(ge):ge}}const je=qe(Se=>{if(Se.pointerId!==ee.current)return;ee.current=null,H.current?.abort(),H.current=null,w(!1),N(!1),$(null);const ge=q.current;if(Se.type==="pointercancel"||U.current){ie({x:ge.x,y:ge.y}),y(void 0);return}const ue=J.current,be=ue.x-ge.x,ve=ue.y-ge.y;let De;for(const Ie of m)if(EP(Ie,be,ve)>PK){De=Ie;break}De?(y(De),v.closeToast(s.id)):(ie({x:ge.x,y:ge.y}),y(void 0))});function te(Se){if(Se.button!==0||(Se.pointerType==="touch"&&v.pauseTimers(),Er(Se.nativeEvent)?.closest(`button,a,input,textarea,[role="button"],${H0e}`)))return;U.current=!1,Q.current=void 0,X.current=0,ee.current=Se.pointerId,V.current={x:Se.clientX,y:Se.clientY},z.current=V.current;const be=Se.currentTarget,ve=I0e(be);q.current=ve,O(ve),ie({x:ve.x,y:ve.y}),v.set("hovering",!0),w(!0),N(!1),$(null),K.current=!0,H.current?.abort();const De=new AbortController;H.current=De;const Ie=_n(be);Ie.addEventListener("pointerup",je,{signal:De.signal}),Ie.addEventListener("pointercancel",je,{signal:De.signal}),be.setPointerCapture?.(Se.pointerId)}function le(Se){if(Se.pointerId!==ee.current)return;Se.preventDefault(),K.current&&(V.current={x:Se.clientX,y:Se.clientY},K.current=!1);const{clientY:ge,clientX:ue,movementX:be,movementY:ve}=Se;(ve<0&&ge>z.current.y||ve>0&&gez.current.x||be>0&&ue=U0e){N(!0);const Ke=m.includes("left")||m.includes("right"),zt=m.includes("up")||m.includes("down");if(Ke&&zt){const ht=Math.abs(De),Tt=Math.abs(Ie);kt=ht>Tt?"horizontal":"vertical",$(kt)}}let Je;if(!Q.current)kt==="vertical"?Ie>0?Je="down":Ie<0&&(Je="up"):kt==="horizontal"?De>0?Je="right":De<0&&(Je="left"):Math.abs(De)>=Math.abs(Ie)?Je=De>0?"right":"left":Je=Ie>0?"down":"up",Je&&m.includes(Je)&&(Q.current=Je,X.current=EP(Je,De,Ie),y(Je));else{const sn=Q.current,Ke=EP(sn,nt,We);Ke>PK?(U.current=!1,y(sn)):!(m.includes("left")&&m.includes("right"))&&!(m.includes("up")&&m.includes("down"))&&X.current-Ke>=F0e&&(U.current=!0)}const on=oe(De,Ie);let nn=q.current.x,On=q.current.y;const Rn=m.includes("left")||m.includes("right"),gt=m.includes("up")||m.includes("down");kt!=="vertical"&&Rn&&(nn+=on.x),kt!=="horizontal"&>&&(On+=on.y),ie({x:nn,y:On})}function he(Se){if(Se.key==="Escape"){if(!D.current||!Et(D.current,Ys(_n(D.current))))return;v.closeToast(s.id)}}p.useEffect(()=>{const Se=D.current;if(!g||!Se)return;function ge(ue){ee.current===null||!Et(Se,Er(ue))||ue.preventDefault()}return kn(Se,"touchmove",ge,{passive:!1})},[g]);function ce(){const Se=C.x-P.x,ge=C.y-P.y;return{transition:k?"none":void 0,transform:k?`translateX(${C.x}px) translateY(${C.y}px) scale(${P.scale})`:void 0,[L0e]:`${Se}px`,[$0e]:`${ge}px`}}const ye=s.priority==="high",fe={role:ye?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":A,"aria-describedby":M,"aria-hidden":ye&&!re?!0:void 0,onPointerDown:g?te:void 0,onPointerMove:g?le:void 0,onPointerUp:g?je:void 0,onPointerCancel:g?je:void 0,onKeyDown:he,inert:qb(s.limited),style:{...ce(),[M0e]:s.transitionStatus==="ending"?G:Y,[_0e]:`${se}px`,[D0e]:s.height?`${s.height}px`:void 0}},Le=p.useMemo(()=>({toast:s,setTitleId:R,setDescriptionId:_,recalculateHeight:de,visibleIndex:Y,expanded:ne}),[s,R,_,de,Y,ne]),pe={transitionStatus:s.transitionStatus,expanded:ne,limited:s.limited||!1,type:s.type,swiping:k,swipeDirection:b},xe=Kt("div",t,{ref:[n,D],state:pe,stateAttributesMapping:B0e,props:[fe,d]});return r.jsx(RK.Provider,{value:Le,children:xe})});function MK(e){return e==null||typeof e=="boolean"||e===""?!1:Array.isArray(e)?e.some(MK):!0}function K0e(e){return p.isValidElement(e)&&MK(e.props.children)}function _K(e,t,n){const{toast:s,setTitleId:i,setDescriptionId:o}=P0e(),l=n==="title"?i:o,u=t??(n==="title"?s.title:s.description);return{id:lg(e),children:u,type:s.type,setId:l}}function DK(e,t,n){const s=K0e(e);return Ge(()=>{if(s)return n(t),()=>{n(i=>i===t?void 0:i)}},[s,t,n]),s?e:null}const q0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,children:u,...d}=t,{id:f,children:m,type:g,setId:v}=_K(l,u,"description"),y=Kt("p",t,{ref:n,state:{type:g},props:{...d,id:f,children:m}});return DK(y,f,v)}),G0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,children:u,...d}=t,{id:f,children:m,type:g,setId:v}=_K(l,u,"title"),y=Kt("h2",t,{ref:n,state:{type:g},props:{...d,id:f,children:m}});return DK(y,f,v)}),W0e=p.forwardRef(function(t,n){return r.jsx(dH,{ref:n,...t})});function Y0e(){const e=SP(),t=e.useState("toasts");return p.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function X0e(){const e=new Set;function t(n){e.forEach(s=>s(n))}return{" subscribe":function(s){return e.add(s),()=>{e.delete(s)}},add(n){const s=n.id||OK("toast"),i={...n,id:s,transitionStatus:"starting"};return t({action:"add",options:i}),s},close(n){t({action:"close",options:{id:n}})},update(n,s){t({action:"update",options:{id:n,updates:s}})},promise(n,s){let i=n;return t({action:"promise",options:{...s,promise:n,setPromise(o){i=o}}}),i}}}const TP=X0e(),Q0e=E0e;function Z0e({className:e,...t}){return r.jsx(G0e,{"data-slot":"toast-title",className:n=>Ne("m-0 text-[12.5px] font-semibold leading-relaxed [overflow-wrap:anywhere]",typeof e=="function"?e(n):e),...t})}function J0e({className:e,...t}){return r.jsx(q0e,{"data-slot":"toast-description",className:n=>Ne("m-0 text-[12px] leading-relaxed text-subtle [overflow-wrap:anywhere]",typeof e=="function"?e(n):e),...t})}function eke({className:e,...t}){return r.jsx(V0e,{"data-slot":"toast",className:Ne("pointer-events-auto max-w-full rounded-lg border border-border bg-raised px-4 py-2.5 text-[12.5px] text-foreground shadow-3 outline-none","data-[type=success]:border-success-bd data-[type=success]:text-success","data-[type=error]:border-destructive-bd data-[type=error]:text-destructive","data-[type=warning]:border-warning-bd data-[type=warning]:text-warning","data-limited:hidden data-ending-style:opacity-0 transition-opacity duration-150",typeof e=="string"&&e),...t})}function tke(){const{toasts:e}=Y0e();return e.map(t=>r.jsxs(eke,{toast:t,children:[r.jsx(Z0e,{children:t.title}),t.description&&r.jsx(J0e,{className:"mt-1",children:t.description})]},t.id))}function LK({manager:e=TP,position:t="top-center",className:n}){return r.jsx(Q0e,{toastManager:e,timeout:3500,limit:1,children:r.jsx(W0e,{children:r.jsx(R0e,{"data-slot":"toast-viewport",className:Ne("pointer-events-none fixed left-1/2 z-[100] flex w-max max-w-[84vw] -translate-x-1/2 flex-col items-center gap-2 outline-none",t==="top-center"?"top-4":"bottom-[calc(78px+env(safe-area-inset-bottom,0px))]",n),children:r.jsx(tke,{})})})})}function nke({className:e,...t}){return r.jsx("div",{"data-slot":"app-frame",className:Ne("min-h-0 bg-background text-foreground",e),...t})}function $h({className:e,...t}){return r.jsx("aside",{"data-slot":"sidebar",className:Ne("flex min-h-0 flex-col gap-3 border-r border-sidebar-border bg-sidebar p-3 text-sidebar-foreground",e),...t})}function $K({className:e,...t}){return r.jsx("div",{"data-slot":"sidebar-header",className:Ne("shrink-0",e),...t})}function zK({className:e,...t}){return r.jsx("nav",{"data-slot":"sidebar-content",className:Ne("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",e),...t})}function BK({className:e,...t}){return r.jsx("div",{"data-slot":"sidebar-footer",className:Ne("flex shrink-0 flex-col gap-2 border-t border-sidebar-border pt-2.5",e),...t})}function Sg({className:e,...t}){return r.jsx("div",{"data-slot":"sidebar-group-label",className:Ne("px-2 pb-1 pt-2 text-[10.5px] font-semibold uppercase tracking-[.09em] text-sidebar-muted",e),...t})}function zS({className:e,...t}){return r.jsx("header",{"data-slot":"page-header",className:Ne("flex shrink-0 items-center justify-between gap-3",e),...t})}function FK({className:e,...t}){return r.jsx("h1",{"data-slot":"page-title",className:Ne("m-0 text-[20px] font-semibold tracking-tight",e),...t})}function UK({className:e,...t}){return r.jsx("p",{"data-slot":"page-description",className:Ne("m-0 text-[12.5px] text-muted-foreground",e),...t})}function rke({className:e,...t}){return r.jsx("header",{"data-slot":"window-titlebar","data-tauri-drag-region":"",className:Ne("flex h-8 shrink-0 items-center gap-2.5 overflow-hidden border-b border-sidebar-border bg-sidebar pl-3 text-sidebar-fg select-none",e),...t})}function OP({className:e,action:t,...n}){return r.jsx(B,{"data-slot":"window-control",variant:"ghost",className:Ne("h-8 w-11 rounded-none p-0 shadow-none active:translate-y-0",t==="close"&&"hover:bg-destructive hover:text-white",e),...n})}const HK="w-auto flex-auto";function VK({onInput:e,domRef:t,icon:n,className:s,inputClassName:i,...o}){const l=d=>{t.current=d},u=d=>{e?.(d.currentTarget.value)};return n?r.jsxs(zs,{className:Ne(HK,s),children:[r.jsx(Bs,{ref:l,className:i,onInput:u,...o}),r.jsx(As,{"aria-hidden":"true",children:n})]}):r.jsx(ze,{ref:l,className:Ne(HK,i),onInput:u,...o})}function ske(e,t){const n=zn.createRoot(e),s={current:null};return n.render(r.jsx(VK,{domRef:s,defaultValue:t.value,placeholder:t.placeholder,type:t.type??"search",icon:t.icon,"aria-label":t.ariaLabel,onInput:t.onInput})),{setValue(i){const o=s.current;o&&o.value!==i&&(o.value=i)},getValue(){return s.current?.value??""},focus(){s.current?.focus()},unmount(){n.unmount()}}}const ake=[["id","id"],["type","type"],["name","name"],["title","title"],["placeholder","placeholder"],["min","min"],["max","max"],["step","step"],["autocomplete","autoComplete"]];function ike(e){const t={defaultValue:e.value||void 0,inputClassName:e.className||void 0};for(const[l,u]of ake){const d=e.getAttribute(l);d!=null&&(t[u]=d)}const n=e.getAttribute("maxlength");n!=null&&(t.maxLength=Number(n));const s=e.getAttribute("inputmode");s!=null&&(t.inputMode=s),e.hasAttribute("spellcheck")&&(t.spellCheck=e.spellcheck),e.disabled&&(t.disabled=!0),e.readOnly&&(t.readOnly=!0),e.hidden&&(t.hidden=!0);const i=e.getAttribute("aria-label");i!=null&&(t["aria-label"]=i);for(const l of e.getAttributeNames())!l.startsWith("data-")||l.startsWith("data-island-")||(t[l]=e.getAttribute(l)??"");const o=e.getAttribute("data-island-icon");return o!=null&&(t.icon=o),t}function KK(e){if(e.dataset.islandUpgraded)return;e.dataset.islandUpgraded="1";const t=ike(e),n=e.parentElement?.classList.contains("input-affix")?e.parentElement:null;let s;n?(n.className=n.className.replace(/\binput-affix\b/,"").trim(),n.style.display="flex",n.style.alignItems="center",s=n):(s=document.createElement("span"),s.style.display="contents",e.replaceWith(s));const i={current:null},o=zn.createRoot(s);xr.flushSync(()=>{o.render(r.jsx(VK,{...t,domRef:i}))})}function qK(e=document){if(e instanceof HTMLInputElement&&e.matches("[data-island-input]")){KK(e);return}e.querySelectorAll("input[data-island-input]").forEach(KK)}function oke(){qK();const e=new MutationObserver(t=>{for(const n of t)for(const s of n.addedNodes)s instanceof Element&&qK(s)});return e.observe(document.body,{childList:!0,subtree:!0}),e}function lke(e,t){const n=zn.createRoot(e);let s={options:t.options,value:t.value,ariaLabel:t.ariaLabel,className:t.className};const i=()=>{n.render(r.jsx(en,{options:s.options,value:s.value,onValueChange:t.onChange,"aria-label":s.ariaLabel,className:s.className}))};return i(),{setValue(o){o!==s.value&&(s={...s,value:o},i())},setOptions(o){s={...s,options:o},i()},unmount(){n.unmount()}}}window.wbUiKit={React:wO,createRoot:zn.createRoot,flushSync:xr.flushSync,Badge:Ee,Button:B,Checkbox:jr,Input:ze,Label:Ae,Progress:gg,SegmentedControl:en,Spinner:Qt,Switch:St,Card:et,CardHeader:pn,CardContent:Gt,CardFooter:ju,Collapsible:gs,CollapsibleTrigger:xs,CollapsibleContent:vs,HtmlContent:Wo,Toaster:LK,toastManager:TP,Select:{Root:Pt,Trigger:Mt,Value:It,Content:_t,Item:Ze,Group:Fje,Label:Uje,Separator:Hje}};function a(e,t){const n=typeof window<"u"?window.wbI18n:void 0;return n&&typeof n.t=="function"?n.t(e,t):e}const ey=Object.freeze({displayName:"Agent2API",logoUrl:null}),cke=2*1024*1024;function GK(e,t){if(!e||typeof e!="object")throw new Error("品牌设置格式无效");const n=e;if(typeof n.displayName!="string"||!n.displayName.trim()||Array.from(n.displayName).length>64)throw new Error("品牌设置格式无效");let s=null;if(n.logoUrl!==null&&n.logoUrl!==void 0){if(typeof n.logoUrl!="string"||!/^\/api\/panel\/branding\/logo\?v=[a-f0-9]{64}$/.test(n.logoUrl))throw new Error("品牌 Logo 地址无效");s=new URL(n.logoUrl,t).href}return{displayName:n.displayName,logoUrl:s}}function uke(e,t){let n="",s=ey,i=0,o=null;const l=new Set,u=()=>{for(const g of l)g()},d=()=>n===e()?s:ey,f=g=>(i+=1,n=e(),(s.displayName!==g.displayName||s.logoUrl!==g.logoUrl)&&(s=g,u()),g);return{snapshot:d,refresh:()=>{const g=e();if(o?.scope===g)return o.request;n!==g&&(n=g,s=ey,u());const v=++i,b=t().then(y=>(v===i&&e()===g&&f(y),y)).finally(()=>{o?.request===b&&(o=null)});return o={scope:g,request:b},b},accept:f,subscribe(g){return l.add(g),()=>{l.delete(g)}},useValue(){return p.useSyncExternalStore(this.subscribe,d)}}}function dke(e,t,n=!0){p.useEffect(()=>{if(!n)return;const s=()=>{document.hidden||e.refresh().catch(()=>{})};s();const i=window.setInterval(s,6e4);return window.addEventListener("focus",s),document.addEventListener("visibilitychange",s),()=>{window.clearInterval(i),window.removeEventListener("focus",s),document.removeEventListener("visibilitychange",s)}},[e,t,n])}let BS=null,wu=null;function fke(e,t){document.querySelector("title")?.removeAttribute("data-i18n"),document.title=t,BS||(BS=[...document.querySelectorAll('link[rel="icon"]')].map(n=>({element:n,href:n.href,type:n.type,sizes:n.sizes.value})));for(const n of BS)n.element.href=e.logoUrl||n.href,n.element.type=e.logoUrl?"image/png":n.type,n.element.sizes.value=e.logoUrl?"any":n.sizes;!BS.length&&e.logoUrl?(wu||(wu=document.createElement("link"),wu.rel="icon",document.head.appendChild(wu)),wu.type="image/png",wu.href=e.logoUrl):wu&&(wu.remove(),wu=null)}const RP=()=>window.workbuddyDesktop;async function WK(){const e=RP();if(e?.platform&&e.platform!=="web"){const t=await e.waitForBackend?.();if(!t?.port||!Number.isInteger(t.port)||t.port<1||t.port>65535)throw new Error(a("网关尚未就绪"));return`http://127.0.0.1:${t.port}`}return window.location.origin}const Ng=uke(()=>"local",async()=>{const e=await WK(),t=await fetch(new URL("/api/panel/branding",e),{cache:"no-store"});if(!t.ok)throw new Error(a("无法读取品牌设置"));const n=await t.json();return GK(n.data,e)});async function hke(e){const t=RP();if(!t?.saveBranding)throw new Error(a("当前版本不支持品牌设置"));const n=await t.saveBranding(e),s=GK(n,await WK());return Ng.accept(s),t.syncBrandingTitle?.().catch(()=>{}),s}function mke(e){const t=Ng.useValue();return dke(Ng,"local"),p.useEffect(()=>{const n=RP(),s=n?.title?.startsWith("[Dev]")?"[Dev] ":"",i=t.displayName==="Agent2API"?n?.title||a("Agent2API · 多提供商本地网关"):`${s}${t.displayName}`;fke(t,i),n?.syncBrandingTitle?.().catch(()=>{})},[t,e]),t}function PP({branding:e,size:t=32,className:n=""}){const[s,i]=p.useState(null);return e.logoUrl&&e.logoUrl!==s?r.jsx("img",{src:e.logoUrl,alt:"","aria-hidden":"true",width:t,height:t,className:`block shrink-0 object-contain ${n}`,style:{width:t,height:t},onError:()=>i(e.logoUrl)}):r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24","aria-hidden":"true",className:`block shrink-0 ${n}`,children:[r.jsx("rect",{width:"24",height:"24",rx:"5.4",fill:"#007AFF"}),r.jsxs("g",{fill:"none",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M5.23 9.24h10.71"}),r.jsx("path",{d:"M15.94 6.72 18.77 9.24 15.94 11.76"}),r.jsx("path",{d:"M18.77 14.76H8.06"}),r.jsx("path",{d:"M8.06 12.24 5.23 14.76 8.06 17.28"})]})]})}function pke(){const e=()=>window.wbZcodeClaimVerification,[t,n]=p.useState(()=>e()?.status()||null);if(p.useEffect(()=>{const i=()=>n(e()?.status()||null);return window.addEventListener("zcode-claim-verification",i),i(),()=>window.removeEventListener("zcode-claim-verification",i)},[]),!t)return null;const s=t.phase==="submitting";return r.jsxs(et,{className:"fixed bottom-5 right-5 z-[2147482900] w-[min(380px,calc(100vw-40px))] space-y-2 p-4 shadow-lg",role:"status","aria-live":"polite",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[r.jsx(Qt,{className:"size-4 shrink-0"}),a("ZCode 自动领取验证")]}),r.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:[t.accountName," · ",t.planName]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:a(s?"验证凭据正在提交,领取结果请查看签到记录":"正在为本次领取验证;若出现滑块,请手动完成")}),r.jsx(B,{variant:"outline",size:"xs",disabled:s,onClick:()=>e()?.cancel(),children:a("取消验证")})]})}const qd=()=>window;let FS=[],ty="overview",YK=a("报表"),XK=localStorage.getItem("workbuddy-desktop-theme")||"system",QK=[],ZK="";const ku=new Set;let ny=0;const US=()=>{ny+=1;for(const e of ku)e()};function gke({name:e,size:t=17}){return r.jsx("span",{className:"ico shrink-0","aria-hidden":"true",dangerouslySetInnerHTML:{__html:qd().wbIcons?.icon(e,t)||qd().wbIcons?.icon("plugins",t)||""}})}function xke(){return p.useSyncExternalStore(e=>(ku.add(e),()=>ku.delete(e)),()=>ny),r.jsx(r.Fragment,{children:FS.length?FS.map((e,t)=>r.jsxs(p.Fragment,{children:[r.jsx(Sg,{className:"nav-group-label",children:qd().wbSidebarLayout?.groupLabel(e.label)||e.label}),e.items.map(n=>{const s=n.key==="requests"?"nav-count-requests":n.key==="logs"?"nav-count-logs":n.key==="settings"?"nav-count-update":"";return r.jsx(Ts,{className:`nav-item ${ty===n.key?"active":""}`,active:ty===n.key,"data-page":n.key,"data-icon":n.icon,icon:r.jsx(gke,{name:n.icon}),trailing:s?r.jsx(Ee,{id:s,variant:"destructive",shape:"tag",className:"count min-w-5 px-1.5 py-0 text-[10.5px]",style:{display:"none"},children:n.key==="settings"?a("新"):"0"}):void 0,children:r.jsx("span",{className:"label",children:a(n.label)})},n.key)})]},`${e.label}-${t}`)):r.jsx(pt,{className:"nav-empty px-2 py-3 text-[11px]",children:a("侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。")})})}function vke(){return p.useSyncExternalStore(e=>(ku.add(e),()=>ku.delete(e)),()=>ny),r.jsx(en,{className:"w-full",value:XK,"aria-label":a("显示模式"),options:[{value:"system",label:a("跟随系统")},{value:"light",label:a("浅色")},{value:"dark",label:a("深色")}],onValueChange:e=>qd().wbApp?.applyTheme(e)})}function bke(){p.useSyncExternalStore(t=>(ku.add(t),()=>ku.delete(t)),()=>ny);const e={ok:"success",warn:"warning",bad:"destructive",brand:"brand"};return r.jsx(r.Fragment,{children:QK.map((t,n)=>r.jsxs(Ee,{variant:e[t.kind]||"outline",className:t.optional?"badge optional":"badge",children:[t.dot&&r.jsx(Yk,{}),t.text]},n))})}function yke(){p.useSyncExternalStore(o=>(ku.add(o),()=>ku.delete(o)),()=>ny);const e=mke(),[t,n]=p.useState(!1),s=bP("(max-width: 767px)");p.useEffect(()=>{s||n(!1),window.dispatchEvent(new Event("wb:shell-layout")),qd().wbApp?.syncNavBadges()},[s]),p.useEffect(()=>{const o=()=>n(!1);return window.addEventListener("wb:navigation-close",o),()=>window.removeEventListener("wb:navigation-close",o)},[]);const i=r.jsxs($h,{className:"sidebar",children:[r.jsxs($K,{className:"brand",children:[r.jsx("div",{className:"brand-logo",children:r.jsx(PP,{branding:e,size:32})}),r.jsx("div",{className:"brand-text min-w-0",children:r.jsx("h1",{className:"truncate",title:e.displayName,children:e.displayName})})]}),r.jsx(Go,{render:r.jsx(zK,{}),className:"nav",id:"nav","aria-label":a("主导航"),onClick:o=>{const l=o.target.closest(".nav-item[data-page]");l?.dataset.page&&qd().wbApp?.showPage(l.dataset.page)},children:r.jsx(xke,{})}),r.jsxs(BK,{className:"sidebar-foot",children:[r.jsx("div",{className:"sidebar-status",id:"sidebar-status",title:a("本地网关监听状态")}),r.jsx("div",{id:"theme-switch",children:r.jsx(vke,{})})]})]});return r.jsxs(nke,{className:"shell","data-navigation-open":t?"true":void 0,children:[s?r.jsx(Qb,{open:t,onOpenChange:n,children:r.jsxs(Zb,{side:"left",keepMounted:!0,showHandle:!1,showCloseButton:!1,"aria-label":a("主导航"),className:"w-[min(280px,86vw)] rounded-none border-0 p-0",children:[r.jsx(uK,{render:r.jsx(B,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 z-10"}),"aria-label":a("关闭菜单"),children:"✕"}),i]})}):i,r.jsxs("main",{className:"main",children:[r.jsxs(zS,{className:"topbar",children:[r.jsx(B,{variant:"ghost",size:"icon",className:"mobile-menu-btn","aria-label":a("切换菜单"),onClick:()=>n(!t),children:"☰"}),r.jsxs("div",{className:"crumb min-w-0",children:[r.jsx("span",{className:"max-w-[200px] truncate",title:e.displayName,children:e.displayName}),r.jsx("span",{className:"sep",children:"/"}),r.jsx("span",{className:"cur",id:"crumb-page",children:YK})]}),r.jsx("div",{className:"spacer"}),r.jsx("div",{className:"topbar-actions",id:"topbar-status",title:ZK,children:r.jsx(bke,{})}),r.jsx("div",{id:"page-refresh-actions"})]}),r.jsx("div",{className:"content",children:r.jsxs("div",{className:"content-inner",children:[["assistant","overview","accounts","checkin","routing","gateway","agent","tools","proxies","keys","docs","logs","tasks","requests","plugins","settings"].map(o=>r.jsx("section",{className:`page${ty===o?" active":""}`,"data-page":o},o)),r.jsx("section",{className:`page${ty.startsWith("plugin:")?" active":""}`,"data-page":"__plugin__",id:"plugin-page-host"})]})})]}),r.jsx(pke,{})]})}function jke(){const e=document.getElementById("desktop-app");if(!e)return;const t=qd().wbSidebarLayout;t&&(FS=t.renderGroups(t.readLayout())),qd().wbShell={sidebar(s){FS=s,xr.flushSync(US)},page(s,i){ty=s,YK=i,US()},status(s,i=""){QK=s,ZK=i,US()},theme(s){XK=s,US()},closeNavigation(){window.dispatchEvent(new Event("wb:navigation-close"))},toast(s,i="ok"){TP.add({id:"desktop-feedback",title:s,type:i==="err"?"error":i==="warn"?"warning":"success",timeout:3500})}},xr.flushSync(()=>zn.createRoot(e).render(r.jsx(yke,{})));const n=document.createElement("div");document.body.append(n),xr.flushSync(()=>zn.createRoot(n).render(r.jsx(LK,{})))}jke();const JK="wb-tip-bubble",IP=new WeakSet;let es=null,Cg=!1,ry=0,HS=0,eq=0;const MP=new Set,_P=()=>{eq+=1;for(const e of MP)e()},DP=e=>({text:e.getAttribute("data-tip")?.trim()||"",variant:e.getAttribute("data-tip-variant")});let VS=null;function KS(e){const t=e.getBoundingClientRect();return e.isConnected&&t.width>0&&t.height>0&&t.bottom>0&&t.top{es&&!KS(es)&&Il()})),VS?.observe(e),es.classList.add("active"),es.setAttribute("aria-describedby",JK),_P())}function wke(){p.useSyncExternalStore(t=>(MP.add(t),()=>MP.delete(t)),()=>eq);const e=es?DP(es):null;return r.jsx(pS,{children:r.jsx(pc,{open:!!es,disableHoverablePopup:!0,onOpenChange:t=>{!t&&!Cg&&Il()},children:r.jsx(gc,{id:JK,anchor:es,side:"bottom",variant:e?.variant==="plain"?"plain":"default",className:"pointer-events-none",children:e?.text.split(` -`).map((t,n)=>{const s=/^\[(#[0-9a-fA-F]{3}|#[0-9a-fA-F]{6})\]/.exec(t);return r.jsxs("span",{className:"flex items-start gap-1.5",children:[s&&r.jsx("span",{className:"mt-1 size-1.5 shrink-0 rounded-full",style:{background:s[1]}}),r.jsx("span",{children:s?t.slice(s[0].length):t})]},n)})})})})}function LP(e){IP.has(e)||!DP(e).text||(IP.add(e),e.classList.contains("tip-q")&&!e.textContent?.trim()&&(e.textContent="?"),e.matches("a[href], button, input, select, textarea, [tabindex]")||e.setAttribute("tabindex","0"))}function tq(){const e=document.createElement("div");document.body.append(e),xr.flushSync(()=>zn.createRoot(e).render(r.jsx(wke,{})));const t=o=>{o.matches("[data-tip]")&&LP(o),o.querySelectorAll("[data-tip]").forEach(LP)};t(document.body),new MutationObserver(o=>{es&&!KS(es)&&Il();for(const l of o){l.type==="attributes"&&l.target instanceof Element&&(LP(l.target),l.target===es&&_P());for(const u of l.addedNodes)u instanceof Element&&t(u)}}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tip","data-tip-variant"]});const s=o=>o.target instanceof Element?o.target.closest("[data-tip]"):null;document.addEventListener("pointerover",o=>{if(!window.matchMedia("(hover: hover)").matches)return;const l=s(o);!l||o.relatedTarget instanceof Node&&l.contains(o.relatedTarget)||(window.clearTimeout(HS),window.clearTimeout(ry),ry=window.setTimeout(()=>qS(l),es?0:150))}),document.addEventListener("pointerout",o=>{const l=s(o);!l||o.relatedTarget instanceof Node&&l.contains(o.relatedTarget)||Cg||(window.clearTimeout(ry),HS=window.setTimeout(()=>{es===l&&!Cg&&Il()},80))}),document.addEventListener("focusin",o=>{const l=s(o);l?.matches(":focus-visible")&&qS(l)}),document.addEventListener("focusout",o=>{s(o)===es&&Il()}),document.addEventListener("click",o=>{const l=s(o);if(!l){es&&Il();return}es===l&&Cg?Il():(qS(l),Cg=!0)},!0),document.addEventListener("keydown",o=>{o.key==="Escape"&&es&&Il()});const i=()=>{es&&!KS(es)&&Il()};window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),window.wbTooltip={open:qS,close:Il,enhanced:o=>IP.has(o)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",tq,{once:!0}):tq();const Gd=window.workbuddyDesktop;function $P({action:e,maximized:t=!1}){return r.jsx("svg",{viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="minimize"?r.jsx("path",{d:"M5 12h14"}):e==="close"?r.jsx("path",{d:"M6 6l12 12M18 6 6 18"}):t?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:8.5,y:4.5,width:11,height:11,rx:1.5}),r.jsx("rect",{x:4.5,y:8.5,width:11,height:11,rx:1.5,className:"fill-sidebar"})]}):r.jsx("rect",{x:5.5,y:5.5,width:13,height:13,rx:1.5})})}function kke({api:e}){const t=Ng.useValue(),[n,s]=p.useState(!1),i=p.useCallback(async()=>{try{e.windowIsMaximized&&s(await e.windowIsMaximized())}catch{}},[e]);p.useEffect(()=>{i();const u=e.onWindowResize?.(()=>{i()});return typeof u=="function"?u:void 0},[e,i]);const o=e.platform==="macos",l=t.displayName==="Agent2API"?e.title||a("Agent2API · 多提供商本地网关"):`${e.title?.startsWith("[Dev]")?"[Dev] ":""}${t.displayName}`;return r.jsxs(rke,{className:o?"titlebar is-macos pl-[84px] pr-3.5":"titlebar",children:[r.jsxs("div",{className:"titlebar-brand pointer-events-none flex min-w-0 items-center gap-2 text-[12.5px] font-semibold [&_*]:pointer-events-none",children:[r.jsx(PP,{branding:t,size:16}),r.jsx("span",{className:"txt truncate",children:l})]}),!o&&r.jsxs("div",{className:"ml-auto flex h-full shrink-0",children:[r.jsx(OP,{action:"minimize",title:a("最小化"),"aria-label":a("最小化"),onClick:()=>{e.windowMinimize?.().catch(()=>{})},children:r.jsx($P,{action:"minimize"})}),r.jsx(OP,{action:"maximize",title:a(n?"还原":"最大化"),"aria-label":a(n?"还原":"最大化"),onClick:async()=>{try{await e.windowToggleMaximize?.(),await i()}catch(u){console.warn("切换窗口大小失败:",u)}},children:r.jsx($P,{action:"maximize",maximized:n})}),r.jsx(OP,{action:"close",title:a("关闭"),"aria-label":a("关闭"),onClick:()=>{e.windowClose?.().catch(()=>{})},children:r.jsx($P,{action:"close"})})]})]})}function Ske(){if(!document.getElementById("desktop-app")||!Gd?.platform||Gd.platform==="web"||Gd.platform!=="macos"&&(!Gd.windowMinimize||!Gd.windowToggleMaximize||!Gd.windowClose))return;const e=document.createElement("div");document.body.prepend(e),document.body.classList.add("has-titlebar"),document.title=Gd.title||a("Agent2API · 多提供商本地网关"),zn.createRoot(e).render(r.jsx(kke,{api:Gd}))}Ske();const Su=999;function zP(e){const t=e.resolved||e;if(t.protocol&&t.host&&t.port){const n=t.host.includes(":")&&!t.host.startsWith("[")?`[${t.host}]`:t.host;return`${String(t.protocol).toLowerCase()}://${n}:${t.port}`}return e.resolved?.label||""}function Ag(e){const t=e.name||e.id,n=[e.source==="clash"?"Clash Verge":"",e.resolveError?a("解析失败"):zP(e),e.enabled===!1?a("已禁用"):""].filter(Boolean);return n.length?a("{name}({parts})",{name:t,parts:n.join(" · ")}):t}const vc="pool:";function ft(){return window}function Ct(e,t){ft().wbApp?.toast?.(e,t)}function Yo(e){const t=ft().wbApp?.esc;return t?t(e):String(e??"").replace(/[&<>"']/g,n=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[n]||n)}function ki(e){const t=ft().wbApp?.formatTime;if(t)return t(e);const n=Number(e);return!Number.isFinite(n)||n<=0?"":new Date(n).toLocaleString("zh-CN")}function dn(e){return e instanceof Error?e.message:String(e)}function Ln(e){if(e==null||e==="")return"—";const t=Number(e);return Number.isFinite(t)?String(Number(t.toFixed(2))):String(e)}const Nke={workbuddy:{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!0,identifier:["uid"],expiry:["expiresAt"]},"workbuddy-intl":{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!1,identifier:["uid"],expiry:["expiresAt"]},raccoon:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"]},catpaw:{usage:!0,edition:!1,identifier:["uid"],expiry:["tokenExpiresAt"]},autoclaw:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"]},"autoclaw-intl":{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"],emailAsName:!0},qoder:{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"qoder-intl":{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},qwenwork:{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"qwenwork-intl":{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"cline-free":{usage:!0,edition:!1,identifier:["account"],expiry:["expiresAt"]},"cline-pass":{usage:!0,edition:!1,identifier:["account"],expiry:["expiresAt"]},accio:{usage:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"accio-cn":{usage:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},zcode:{usage:!0,creditDetail:!0,claim:!0,planChannel:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"]},"zcode-intl":{usage:!0,creditDetail:!0,claim:!0,planChannel:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"]},codearts:{usage:!0,usageDetail:!0,edition:!1,identifier:["userId"],expiry:["expiresAt"],concurrencyDefault:3},trae:{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!1,identifier:["uid"],expiry:["expiresAt"]},loomy:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:[""]},kuku:{usage:!0,edition:!1,identifier:["uid"],expiry:[""]},officeace:{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!1,identifier:["id"],expiry:["expiresAt"]},antigravity:{usage:!0,edition:!1,identifier:["userId"],expiry:[""],longLived:!0},chatglm:{usage:!0,creditDetail:!0,edition:!1,identifier:["uid"],expiry:[""],longLived:!0},modelscope:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:[""],longLived:!0},"modelscope-intl":{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:[""],longLived:!0},atomcode:{usage:!0,edition:!1,identifier:["userId"],expiry:["expiresAt"]},commandcode:{usage:!1,edition:!1,identifier:["id"],expiry:[""],longLived:!0},lobsterai:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["expiresAt"]},monkeycode:{usage:!1,edition:!1,identifier:["userId"],expiry:["expiresAt"]},"monkeycode-intl":{usage:!1,edition:!1,identifier:["userId"],expiry:["expiresAt"]},orcaterm:{usage:!0,edition:!1,identifier:["uid"],expiry:["tokenExpireAt"]}},GS={usage:!1,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"],emailAsName:!1};let nq=new Map,rq=null;function Cke(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=new Map;for(const[n,s]of Object.entries(e))!n||!s||typeof s!="object"||Array.isArray(s)||t.set(n,Eke(s));nq=t}function Ake(){const e=ft().wbApp?.getState?.()?.accountFeatures;return e!==rq&&(rq=e,Cke(e)),nq}function Eke(e){return{usage:e.usage===!0,edition:e.edition===!0,identifier:sq(e.identifier,GS.identifier),expiry:sq(e.expiry,GS.expiry),longLived:e.long_lived===!0,emailAsName:e.email_as_name===!0,claim:e.claim===!0,planChannel:e.plan_channel===!0,usageDetail:e.usage_detail===!0,creditDetail:e.credit_detail===!0,creditExpiry:e.credit_expiry===!0,concurrencyDefault:Number(e.concurrency_default)>0?Number(e.concurrency_default):void 0,defaultLimiters:Tke(e.default_limiters)}}function sq(e,t){if(typeof e=="string")return e?[e]:[];if(!Array.isArray(e))return t;const n=e.filter(s=>typeof s=="string"&&s.length>0);return n.length?n:[]}function Tke(e){if(!Array.isArray(e))return;const t=[];for(const n of e){if(!n||typeof n!="object"||Array.isArray(n))continue;const s=n,i=Number(s.threshold);if(!Number.isFinite(i)||i<=0)continue;const o=s.kind==="token"?"token":s.kind==="balance"?"balance":null;if(!o)continue;const l=s.action==="disable"?"disable":"skip",u=Number(s.period_seconds),d=o==="token"&&Number.isFinite(u)&&u>0;t.push({type:o,action:l,threshold:i,enabled:!0,...d?{period:u,reset:"fixed"}:{},...o==="token"&&!d?{reset:"daily"}:{}})}return t}function Ga(e){if(!e)return GS;const t=Ake().get(e);return t||Nke[e]||GS}function Oke(e,t){const n=Ui(e);if(!n)return null;const s=Object.prototype.hasOwnProperty.call(n,"totalLeft"),o=(Array.isArray(n.quotaSources)?n.quotaSources:[]).map(Ui).find(f=>f?.id==="account"),l=String(n.unit||o?.unit||(s?"积分":"")).trim(),u=Os(s?n.totalLeft:n.available),d=n.unlimited===!0;return u===null&&!d?null:{label:zh(l)?t("总积分"):t("可用合计"),unit:mo(l,t),remaining:u,unlimited:d}}function Ui(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function aq(e,t){const n=Ui(e);if(n?.empty!==!0||n.error)return null;const s=n.emptyText==="暂无可用积分信息"?t("暂无可用积分信息"):typeof n.emptyText=="string"?t(n.emptyText.trim()):"";return{text:t("暂无额度信息"),detail:[s,t("查询已成功,但上游未提供额度数据,不代表余额为零。")].filter(Boolean).join(" · ")}}function Os(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;const t=Number(e);return Number.isFinite(t)?t:null}function iq(e){const t=Ui(e);return t?.snapshot===!0||t?.type==="magicubes"}function BP(e){const t=Ui(e);if(!t)return[];const n=Array.isArray(t.credits)?t.credits.filter(i=>Ui(i)):[];return Array.isArray(t.wallets)&&t.wallets.some(i=>Ui(i)?.type==="magicubes")?n.map(i=>{if(i.snapshot===!0||i.record===!0)return i;const{remain:o,...l}=i;switch(i.name){case"可用魔粒":return{...l,key:"available",name:"可用余额",balance:o,unit:"魔粒",snapshot:!0};case"冻结魔粒":return{...l,key:"frozen",name:"冻结余额",balance:o,unit:"魔粒",snapshot:!0};case"今日已用(次)":return{...l,key:"used-today",name:"今日已用",used:i.used??o,unit:"次",daily:!0,snapshot:!0};default:return i}}):n}function zh(e){return e.trim()==="积分"||e.trim().toLowerCase()==="credits"}function mo(e,t){if(zh(e))return t("积分");switch(e){case"额度":return t("额度");case"魔粒":return t("魔粒");case"次":return t("次");case"copilot_quota_units":return t("Copilot 额度单位");default:return e}}function oq(e,t){switch(e){case"Premium requests":return t("高级请求");case"Chat requests":return t("对话请求");case"Completions":return t("补全请求");default:return typeof e=="string"?t(e):""}}function lq(e,t,n){const s=typeof e.view=="string"?e.view.trim():"",i=Os(e.remaining),o=Os(e.limit),l=Os(e.remainingPercent),u=typeof e.unit=="string"?mo(e.unit,t):"";return e.unlimited===!0&&(!s||s==="不限")?t("不限"):i!==null&&(!s||/^剩余 [-+\d.eE]+(?: \/ [-+\d.eE]+)?(?: .+)?$/.test(s))?[o===null?t("剩 {remaining}",{remaining:n(i)}):t("剩 {remaining} / {total}",{remaining:n(i),total:n(o)}),u].filter(Boolean).join(" "):l!==null&&(!s||/^剩余 [-+\d.]+%$/.test(s))?t("剩余 {percent}%",{percent:Math.round(Math.max(0,Math.min(100,l)))}):s?t(s):"—"}function cq(e,t,n){if(e.snapshot!==!0)return null;const s=Os(e.used),i=s??Os(e.balance)??Os(e.remain),o=String(e.unit||"").trim(),l=String(e.name||"").trim(),u=l==="可用余额"?t("可用余额"):l==="冻结余额"?t("冻结余额"):l==="今日已用"?t("今日已用"):l==="今日发放"?t("今日发放"):l||t("明细"),d=i===null?"—":o==="次"?t("{count} 次",{count:n(i)}):o?`${n(i)} ${mo(o,t)}`:n(i);return{name:u,view:d,tone:s!==null||e.key==="frozen"||i===null||i<=0?"muted":"ok",daily:e.daily===!0}}function Rke(e,t,n){return BP(e).map(s=>cq(s,t,n)).filter(s=>s!==null)}function uq(e){const t=Ui(e);return!Array.isArray(t?.wallets)||!t.wallets.some(n=>String(Ui(n)?.type||"").startsWith("meter:"))?null:t.wallets.map(Ui).filter(n=>n!==null&&(n.creditRemaining!=null||n.creditTotal!=null||n.creditUsed!=null))}function FP(e,t,n){const s=Ui(e);if(!s)return[];const i=[],o=Ui(s.subscription);typeof o?.planName=="string"&&o.planName.trim()&&i.push(t("套餐 {name}",{name:o.planName})),typeof s.balanceView=="string"&&s.balanceView.trim()&&i.push(t(s.balanceView));for(const l of uq(s)??(Array.isArray(s.wallets)?s.wallets:[])){const u=Ui(l);if(!u)continue;const d=typeof u.balanceView=="string"&&u.balanceView.trim()?t(u.balanceView):Os(u.balance)===null?"":n(Os(u.balance));if(!d)continue;const f=typeof u.displayName=="string"?t(u.displayName):typeof u.type=="string"?u.type:t("明细");i.push([f,d].filter(Boolean).join(" "))}return[...new Set(i)]}function WS(e){const t=Ui(e);return Array.isArray(t?.warnings)?t.warnings.filter(n=>typeof n=="string"&&!!n.trim()):[]}let Bh={};function Pke(e){if(!e?.limiterStates)return!1;const t=JSON.stringify([Bh.limiterStates,Bh.quotaSources,Bh.limiterModels])!==JSON.stringify([e.limiterStates,e.quotaSources,e.limiterModels]);return Bh={tokenAt:e.tokenAt,limiterStates:e.limiterStates,quotaSources:e.quotaSources,limiterModels:e.limiterModels},t}function sy(e,t=[]){return Array.isArray(e?.limiterGroups)?e.limiterGroups:t.map(n=>({enabled:n.enabled!==!1,action:n.action,target:"account",conditions:[{join:"or",sourceId:"",models:[],threshold:n.threshold,metric:n.type==="balance"?"remaining":"tokens",comparison:n.type==="balance"?"lt":"gte",...n.type==="token"?{window:{reset:n.reset==="daily"?"daily":"fixed",seconds:n.period||0}}:{}}]}))}function UP(e){const t=e?Bh.quotaSources?.[e.id]:void 0;return Array.isArray(t)?t.slice():[{id:"account",label:a("账号主额度"),provider:String(e?.provider||"")},{id:"local",label:a("本地用量保护"),provider:String(e?.provider||""),localOnly:!0}]}function Ike(e){const t=String(e?.provider||"");return(Bh.limiterModels?.[t]||[]).map(s=>({value:s.id,label:s.name&&s.name!==s.id?`${s.name}(${s.id})`:s.id}))}function HP(e){return e?Bh.limiterStates?.[e.id]||[]:[]}function ay(e,t,n="skip"){if(!e)return!1;const s=sy(e),i=HP(e);return s.some((o,l)=>o.enabled&&o.action===n&&i[l]?.hit&&(!t||o.conditions.some(u=>t==="token"?u.metric==="tokens"||u.metric==="requests":u.metric!=="tokens"&&u.metric!=="requests")))}function VP(e,t=e?.id||"account"){return t==="local"?a("本地用量保护"):t==="account"||!t?zh(e?.unit||"")?a("总积分"):a("账号主额度"):e?.label?a(e.label):a("账号主额度")}function dq(e){const{remaining:t,total:n,used:s,remainingPercent:i,resetsAt:o,...l}=e;return l}function fq(e,t){const n=e.sourceId||(e.metric==="tokens"||e.metric==="requests"?"local":"account"),s=UP(t).find(m=>m.id===n),i=VP(s||e.source,n),o=e.models.length?e.models.join("、"):a("全部模型"),l=KP(e.metric),u=e.comparison==="lt"?"<":e.comparison==="lte"?"≤":"≥",d=e.metric.endsWith("percent")?"%":e.metric==="tokens"?"Token":e.metric==="requests"?a("次"):mo(s?.unit||e.source?.unit||"",a),f=e.metric==="tokens"?hq(e.threshold):String(e.threshold);return`${i} · ${o} · ${l} ${u} ${f} ${d}`.trim()}function KP(e){switch(e){case"remaining":return a("剩余额度");case"remaining_percent":return a("剩余比例");case"used":return a("已用额度");case"used_percent":return a("已用比例");case"tokens":return a("本地 Token 消耗");case"requests":return a("本地请求次数")}}function hq(e){return window.wbUnits?.formatTokens?.(e)||e.toLocaleString()}function Mke(e,t,n){if(!e?.known||e.value===null)return _ke(e?.reason);const s=UP(n).find(u=>u.id===(t.sourceId||"account")),i=mo(s?.unit||t.source?.unit||"",a),o=u=>t.metric==="tokens"?`${hq(u)} Token`:t.metric.endsWith("percent")?`${Number(u.toFixed(2))}%`:`${Number(u.toFixed(2))} ${t.metric==="requests"?a("次"):i}`.trim(),l=Object.entries(e.modelValues||{});return l.length?l.map(([u,d])=>`${u}:${o(d)}`).join(" · "):o(e.value)}function _ke(e){switch(e){case"此额度不属于账号当前使用的通道":return a("此额度不属于账号当前使用的通道");case"套餐尚未生效或已经到期":return a("套餐尚未生效或已经到期");case"上游额度无上限":return a("上游额度无上限");case"统计周期尚未开始或已经结束":return a("统计周期尚未开始或已经结束");default:return a("暂无读数")}}function Dke(e,t){const n=[];return e.forEach((s,i)=>{(i===0||s.join==="or")&&n.push([]),n[n.length-1].push(fq(s,t))}),n.map(s=>s.length>1?`(${s.join(` ${a("与")} `)})`:s[0]).join(` ${a("或")} `)}function mq(e){return e.desktop!==!0&&(e.canRefresh===!0||e.hasRefreshToken===!0)}function qP(e){return e.desktop===!0?a("桌面端实时登录态请在原客户端更新"):e.needsRelogin===!0?iy(e):mq(e)?"":a("该账号不支持刷新 Token 或未提供刷新凭证")}function iy(e){return e.needsReloginReason?.trim()||a("登录授权已失效,请重新登录;自动续期无法恢复已过期或已撤销的刷新令牌。")}function pq(e,t=Date.now()){const n=Number(e?.upstreamCooldownUntil);return!Number.isFinite(n)||n<=t||n>864e13?null:{resetAt:n,message:String(e?.upstreamBlockedReason||"").trim()}}function gq(e){return e?.enabled===!1?String(e.upstreamBlockedReason||"").trim():""}function GP(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function xq(e){return typeof e=="string"?e.trim():""}function vq(e){const t=GP(e);if(t?.stale)return{remaining:null,unit:"",unlimited:!1};const n=t?.error?GP(t.lastUsage):t,s=!!(n&&Object.prototype.hasOwnProperty.call(n,"totalLeft")),o=(Array.isArray(n?.quotaSources)?n.quotaSources:[]).map(GP).find(g=>g?.id==="account"),l=xq(n?.unit)||xq(o?.unit)||(s?"积分":""),u=/^(credits?|积分)$/i.test(l)?"积分":l,d=s?n?.totalLeft:n?.available,f=!!n?.unlimited;return{remaining:!f&&typeof d=="number"&&Number.isFinite(d)?d:null,unit:u,unlimited:f}}function WP(e){return!e||e.unlimited||!e.unit||e.unit==="%"?null:typeof e.remaining=="number"&&Number.isFinite(e.remaining)?e.remaining:null}function bq(e){const t=new Set(e.filter(n=>WP(n)!==null).map(n=>n.unit));return t.size>1?"mixedUnits":t.size?"ready":"noData"}const YP=30,yq=86400,Lke=60,$ke=3,YS=10,XS=60,XP=180;function jq(e){const t=e?.usageQuery,n=t?.enabled===void 0?!0:t.enabled===!0,s=Number(t?.interval)||0,i=s>=YP&&s<=yq,o=t?.retries;return{enabled:n,interval:n&&!i?Lke:s,retries:typeof o=="number"&&Number.isInteger(o)&&o>=0&&o<=YS?o:$ke,timeoutSeconds:typeof t?.timeoutSeconds=="number"&&Number.isInteger(t.timeoutSeconds)&&t.timeoutSeconds>=15&&t.timeoutSeconds<=XP?t.timeoutSeconds:XS}}const QP="workbuddy",zke="raccoon";function tn(e){const t=e?.provider;return typeof t=="string"&&t?t:QP}const Bke="opencode",Fke="https://opencode.ai/zen/go/v1";function wq(e,t){if(!e||e.clientEmulation!==Bke)return!1;const s=((typeof t=="string"?t.trim():"")||String(e.baseUrl||"")).trim().replace(/\/+$/,"").toLowerCase();return s?s!==Fke:!1}function Uke(e){const t=e?tn(e):"";return t.startsWith("custom-")&&(ft().wbProviders?.customList?.()||[]).find(s=>s?.id===t)||null}function Hke(e){return e?wq(Uke(e),e.baseUrl):!1}function kq(e){const t=Array.isArray(e?.providers)?e.providers:[],n=Array.isArray(e?.accounts)?e.accounts:[],s=new Map;n.forEach(o=>{const l=tn(o);s.set(l,(s.get(l)||0)+1)});const i=new Map;return t.forEach(o=>{o?.id&&i.set(String(o.id),{id:String(o.id),label:String(o.label||o.id),count:Number(o.count)||0})}),s.forEach((o,l)=>{i.has(l)||i.set(l,{id:l,label:ft().wbProviders?.labelOf?.(l)||l,count:o})}),[...i.values()]}function QS(e){return Kke(e,Ga(tn(e)).identifier)}function Vke(e){for(const t of Ga(tn(e)).identifier){const n=e?.[t];if(!(n==null||n===""))return t}return""}function Kke(e,t){for(const n of t){const s=e?.[n];if(!(s==null||s===""))return String(s)}return""}function Sq(e){const t=Number(e)||0;return t<=0?0:t<1e11?t*1e3:t}function Nq(e){const t=Ga(tn(e)).expiry;for(const n of t){const s=Sq(e?.[n]);if(s>0)return s}return 0}function Si(e){if(e?.isGuest===!0)return!1;const t=tn(e);return t.startsWith("custom-")?!!e?.balanceQuery?.scheme:Ga(t).usage}const qke=1800,Gke=86400,Cq=1;function Wke(e){const t=e?Ga(e).defaultLimiters:void 0;return t&&(e!=="codearts"||t.every(n=>n.type==="balance"))?t.slice():e==="cline-free"?[]:[{type:"balance",action:"skip",threshold:Cq,enabled:!0}]}function Yke(e){if(!e||typeof e!="object")return!1;const t=e;if(t.type!=="balance"&&t.type!=="token"||t.action!=="skip"&&t.action!=="disable")return!1;const n=Number(t.threshold);if(!Number.isFinite(n)||n<=0)return!1;if(t.type==="token"&&t.reset!=="daily"){const s=Number(t.period);if(!Number.isInteger(s)||sGke)return!1}return!0}function Xke(e){const t=e?.lowBalance;if(!t||typeof t!="object"||!t.mode)return Wke(tn(e));const n=Number(t.threshold),s=Number.isFinite(n)&&n>0?n:Cq;return t.mode!=="skip"&&t.mode!=="disable"?[]:[{type:"balance",action:t.mode,threshold:s,enabled:!0}]}function Fh(e){const t=e?.limiters;return Array.isArray(t)?t.filter(Yke):Xke(e)}function Qke(e){return Fh(e).filter(t=>t.type==="token")}function Zke(e,t){const n=t*1e3;return e-e%n}function Aq(e){return e.reset==="daily"?0:e.period??0}function ZP(e,t=Date.now()){if(e===0){const n=new Date(t);return n.setHours(0,0,0,0),n.getTime()}return Zke(t,e)}function JP(e,t,n=Date.now()){if(e.type!=="token")return null;const s=Aq(e),i=(t||[]).find(o=>Number(o.kind)===s);return i&&Number(i.windowStart)===ZP(s,n)?i:null}function eI(e,t){if(t&&typeof t=="object"&&t.stale)return!1;if(Array.isArray(e?.limiterGroups))return ay(e,"balance");const n=Fh(e).filter(l=>l.type==="balance"&&l.action==="skip"&&l.enabled!==!1&&l.threshold>0);if(!n.length||!t||typeof t!="object")return!1;const s=t;if(s.unlimited)return!1;const i=s.totalLeft??s.available;if(i==null||i==="")return!1;const o=Number(i);return Number.isFinite(o)&&n.some(l=>oi.type==="token"&&i.action==="skip"&&i.enabled!==!1);if(!n.length||!t?.length)return!1;const s=Date.now();return n.some(i=>{const o=JP(i,t,s);return o!==null&&Number(o.used)>=i.threshold})}function Jke(e,t){return Array.isArray(e?.limiterGroups)?ay(e,"token","disable"):Fh(e).some(n=>{if(n.type!=="token"||n.action!=="disable"||n.enabled===!1)return!1;const s=JP(n,t);return s!==null&&Number(s.used)>=n.threshold})}function eSe(e,t=Date.now()){const n=Aq(e),s=ZP(n,t),i=n===0?Math.max(0,ZP(0,s+864e5+36e5)-t):Math.max(0,s+n*1e3-t);return{kind:n,startMs:s,remainingMs:i,daily:n===0}}function Eq(e,t){if(e<=0)return"";const n=Math.ceil(e/6e4);if(t){const s=Math.ceil(e/36e5);return s>=1?a("今日剩 {n} 小时",{n:s}):a("今日剩 {n} 分钟",{n})}return n>=1?a("剩 {n} 分钟",{n}):a("剩不到 1 分钟")}function Tq(e){const t=Number(e);if(!Number.isFinite(t))return"—";const n=window.wbUnits;return n?.formatTokens?n.formatTokens(t):String(Math.round(t))}function tSe(e){return e>0&&e%3600===0?a("{n} 小时",{n:e/3600}):e>0&&e%60===0?a("{n} 分钟",{n:e/60}):a("{n} 秒",{n:e})}function oy(e){return e?.desktop===!0}function Oq(e){return e?.chatSupported!==!1}function nSe(e){return typeof e=="string"&&e.startsWith("custom-")}function rSe(e){return a(e==="enterprise"?"企业":e==="ultimate"?"旗舰":"个人")}function ZS(e,t){const n=Number(e?.priority??100)-Number(t?.priority??100);return n!==0?n:(Number(e?.addedAt)||0)-(Number(t?.addedAt)||0)}function Ni(e){return e?.enabled!==!1}function ly(e,t=""){if(pq(e))return!0;const n=e?.rateLimits||{},s=Date.now();return t?Number(n[t]?.resetAt)>s:Object.values(n).some(i=>Number(i?.resetAt)>s)}function Rq(e){return e?.edition==="intl"?"intl":"cn"}const Pq="coding-plan",Uh="start-plan";function JS(e){return!!Ga(tn(e)).planChannel}function nI(e){return JS(e)?String(e?.zcodePlan||"").trim()===Uh?Uh:Pq:""}function sSe(e){return a(e===Uh?"套餐池(Start Plan)":"编码套餐(Coding Plan)")}function rI(e){switch(String(e??"").trim()){case"pending":return a("待生效");case"active":return a("生效中");case"expired":return a("已过期");case"unknown":return a("状态未知");default:return String(e??"")}}function aSe(e){const t=e?.claimPlans;if(!t||typeof t!="object"||Array.isArray(t))return[];const n=_q();return Object.entries(t).filter(([,s])=>Number(s)>0&&_q(Number(s))===n).map(([s])=>s)}function iSe(e){return!!Ga(tn(e)).usageDetail}function sI(e){return!!Ga(tn(e)).creditDetail}function Iq(e,t=Date.now()){if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e,s=Array.isArray(n.credits)?n.credits:[];let i=null;for(const o of s){if(!o||typeof o!="object"||o.snapshot===!0||o.record===!0||o.daily===!0||o.unlimited===!0)continue;const l=Number(o.expireAt);if(!Number.isFinite(l)||l<=0||l<=t)continue;const u=o.remain;u!=null&&u!==""&&Number(u)<=0||(i===null||lString(i||"").toLowerCase().includes(n)):!0}function Lq(e,t){return t.provider==="all"||tn(e)===t.provider}function iI(e,t){return t.enabled==="all"?!0:t.enabled==="enabled"?Ni(e):!Ni(e)}function $q(e,t,n,s){if(t.limit==="all")return!0;if(!Ni(e))return!1;const i=cy(e,n?.(e),s?.(e));return t.limit==="limited"?i:!i}function zq(e,t,n,s){return Lq(e,t)&&iI(e,t)&&$q(e,t,n,s)&&Dq(e,t)}function oSe(e,t,n,s){return(e||[]).filter(i=>zq(i,t,n,s))}function Bq(e,t,n,s){const i=e||[],o=d=>i.filter(f=>Lq(f,t)&&(d==="enabled"||iI(f,t))&&Dq(f,t)),l=o("enabled"),u=o("limit");return{enabledAll:l.length,enabled:l.filter(Ni).length,disabled:l.filter(d=>!Ni(d)).length,limitAll:u.length,normal:u.filter(d=>Ni(d)&&!cy(d,n?.(d),s?.(d))).length,limited:u.filter(d=>Ni(d)&&cy(d,n?.(d),s?.(d))).length}}function oI(e){const t=e?.rateLimits;if(!t||typeof t!="object")return[];const n=Date.now();return Object.entries(t).map(([s,i])=>({model:s,...i&&typeof i=="object"?i:{}})).filter(s=>Number(s.resetAt)>n).sort((s,i)=>Number(s.resetAt)-Number(i.resetAt))}function lI(e,t){const n=new Map((t?.providerOrder||[]).flatMap(o=>t?.accountOrder[o]||[]).map((o,l)=>[o,l])),s=(e||[]).slice().sort(n.size?(o,l)=>(n.get(o.id)??1/0)-(n.get(l.id)??1/0):ZS),i=new Map;return s.forEach((o,l)=>i.set(o.id,{position:l+1,total:s.length})),i}function Fq(e){return[{key:"credit",on:Eg(e),dir:"soon"},{key:"balance",on:!1,dir:"high"},{key:"added",on:!1,dir:"new"}]}function lSe(e,t,n,s=Date.now()){const i=(t||[]).filter(f=>f.on);if(!i.length)return e.slice();const o=e.map((f,m)=>({account:f,index:m})),l=new Map,u=new Map(e.map(f=>[f.id,vq(n?.(f))])),d=bq([...u.values()])==="ready";for(const{account:f}of o)l.set(f.id,Iq(n?.(f),s));return o.sort((f,m)=>{for(const g of i){let v=0;if(g.key==="added"?v=cSe(g.dir,f.account,m.account):g.key==="credit"?v=Uq(g.dir,l.get(f.account.id)??null,l.get(m.account.id)??null):g.key==="balance"&&d&&(v=Uq(g.dir==="high"?"late":"soon",WP(u.get(f.account.id)),WP(u.get(m.account.id)))),v!==0)return v}return f.index-m.index}),o.map(f=>f.account)}function cSe(e,t,n){const s=Number(t.addedAt)||0,i=Number(n.addedAt)||0;return e==="new"?i-s:s-i}function Uq(e,t,n){return t===null&&n===null?0:t===null?1:n===null?-1:e==="soon"?t-n:n-t}function uSe(e,t,n,s,i,o){const l=(e||[]).slice().sort(ZS),u=[],d=new Map;for(const f of l){const m=tn(f);d.has(m)||(d.set(m,[]),u.push(m)),d.get(m).push(f)}if(o){const f=new Map(o.providerOrder.map((m,g)=>[m,g]));u.sort((m,g)=>(f.get(m)??1/0)-(f.get(g)??1/0))}return u.map((f,m)=>{const g=d.get(f)||[],v=o?.accountOrder[f],b=new Map((v||[]).map((k,w)=>[k,w])),y=v?g.slice().sort((k,w)=>(b.get(k.id)??1/0)-(b.get(w.id)??1/0)):i?lSe(g,i(f),n):g;return{provider:f,label:ft().wbProviders?.labelOf?.(f)||f,rank:o?.providerOrder.includes(f)?o.providerOrder.indexOf(f)+1:m+1,members:y,queueMembers:g,accounts:t?y.filter(t):y,enabled:y.filter(Ni).length,disabled:y.filter(k=>!Ni(k)).length,limited:y.filter(k=>Ni(k)&&cy(k,n?.(k),s?.(k))).length}})}function Ci(e){if(!e)return"";const t=String(e.name||"").trim();if(e.nameCustom===!0&&t)return t;const n=String(e.email||"").trim();return Ga(tn(e)).emailAsName&&n?n:e?.nickname||t||QS(e)||e?.id||""}const cI="已限流",Hq=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function uI(e){const t=Number(e);if(!Number.isFinite(t)||t<=0||t<=Date.now())return cI;const n=new Date(t),s=n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}),i=Math.round((Hq(n)-Hq(new Date))/864e5);return i===0?a("今天 {clock}",{clock:s}):i===1?a("明天 {clock}",{clock:s}):a("{month}月{day}日 {clock}",{month:n.getMonth()+1,day:n.getDate(),clock:s})}function dSe(e){const t=tn(e);if(!Ga(t).edition)return"";const n=Rq(e),s=e?.editionLabel,i=s||(n==="intl"?"国际版":"国内版");return(ft().wbProviders?.labelOf?.(t)||"").includes(i)?"":s||a(n==="intl"?"国际版":"国内版")}function fSe(e){const t=gq(e);return[t?{text:a("上游限制 · 已禁用"),kind:"bad",title:t}:null,e.needsRelogin?{text:a("需要重新登录"),kind:"bad",title:iy(e)}:null,Oq(e)?null:{text:a("仅账号管理"),kind:"plain",title:a("该提供商的推理转发尚未接入,账号不参与转发")},nSe(tn(e))&&e.hasCredentials===!1?{text:a("未配置凭证"),kind:"bad",title:a("这条自定义账号既没有 API Key,也没有勾选「无需鉴权」:转发时会被跳过,该提供商下的模型也不会出现在模型列表里。去账号「设置」里补上 Key,或勾选「该上游无需鉴权」")}:null,e.proxy?.error?{text:a("代理异常"),kind:"bad",title:a("{error}(不会自动改为直连)",{error:e.proxy.error})}:null,nI(e)===Uh?{text:a("套餐池"),kind:"plain",title:a("转发走套餐池(Start Plan)通道(zcode.z.ai 的 Anthropic 端点,用账号里的体验额度 / 活动领取额度);在账号设置里可切回编码套餐")}:null].filter(n=>n!==null)}const Vq="workbuddy-desktop-accounts-filters",Kq="workbuddy-desktop-accounts-collapsed",dI="workbuddy-desktop-accounts-names-hidden",fI="workbuddy-desktop-accounts-group-total-filtered",hSe="workbuddy-desktop-accounts-group-sort";function mSe(){try{const e=JSON.parse(localStorage.getItem(hSe)||"{}");if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e)){if(!Array.isArray(s))continue;const i=[];for(const o of s){if(!o||typeof o!="object")continue;const l=o;l.key==="credit"?i.push({key:"credit",on:l.on!==!1,dir:l.dir==="late"?"late":"soon"}):l.key==="balance"?i.push({key:"balance",on:l.on!==!1,dir:l.dir==="low"?"low":"high"}):l.key==="added"&&i.push({key:"added",on:l.on!==!1,dir:l.dir==="old"?"old":"new"})}i.length&&(t[n]=i)}return t}catch{return{}}}function pSe(){const e={provider:"all",enabled:"all",limit:"all",q:""},t=ft().wbFilterMemory?.load(Vq,e)||e;return{provider:String(t.provider||"all"),enabled:String(t.enabled||"all"),limit:String(t.limit||"all"),q:""}}function gSe(){try{const e=JSON.parse(localStorage.getItem(Kq)||"[]");return new Set(Array.isArray(e)?e.map(t=>String(t)).filter(Boolean):[])}catch{return new Set}}function qq(){return Wq()}function Gq(){return hI()}function Wq(){try{return localStorage.getItem(dI)==="1"}catch{return!1}}function hI(){try{return localStorage.getItem(fI)==="1"}catch{return!1}}let ar={version:0,listBusy:!1,listError:"",filter:pSe(),collapsed:gSe(),selected:new Set,connections:new Map,dialog:null,namesHidden:Wq(),usageBusy:!1,usageInflight:new Set,usageTasks:new Map,usageStarting:new Set,groupTotalFiltered:hI(),groupSort:mSe(),sorting:null,sortBusy:!1};const mI=new Set;function Hh(e){return mI.add(e),()=>{mI.delete(e)}}function Sn(){return ar}function Tr(e){ar={...ar,...e,version:ar.version+1},mI.forEach(t=>t())}function eN(){Tr({})}function Wd(){return ft().wbApp?.getState?.()?.accounts}function Ml(){const e=Wd()?.accounts;return Array.isArray(e)?e:[]}function xSe(){const e=Wd()?.hiddenAccounts,t=e?.byProvider,n={};if(t&&typeof t=="object"&&!Array.isArray(t))for(const[l,u]of Object.entries(t)){const d=Number(u);Number.isFinite(d)&&d>0&&(n[l]=d)}const s=new Map;for(const l of Array.isArray(e?.providers)?e.providers:[]){if(!l||typeof l.id!="string"||!l.id)continue;const u=l.reason==="not_installed"||l.reason==="pack_disabled"||l.reason==="provider_disabled"||l.reason==="loading"||l.reason==="load_failed"||l.reason==="load_timeout"?l.reason:"not_loaded";s.set(l.id,{id:l.id,label:typeof l.label=="string"&&l.label?l.label:l.id,count:Number(l.count)||0,reason:u,packId:l.packId,startup:l.startup})}const i=Object.entries(n).map(([l,u])=>{const d=s.get(l);return{id:l,count:u,label:d?.label||ft().wbProviders?.labelOf?.(l)||l,reason:d?.reason||"not_loaded",packId:d?.packId,startup:d?.startup}}).sort((l,u)=>u.count-l.count),o=Number(e?.total);return{total:Number.isFinite(o)&&o>0?o:0,byProvider:n,providers:i}}function _l(e){return Ml().find(t=>t.id===e)||null}function vSe(e,t){const n=uSe(Ml(),i=>zq(i,ar.filter,e,t),e,t,Nu,ar.sorting||Wd()?.sorting);return{groups:n.filter(i=>i.accounts.length>0),allGroups:n}}function Nu(e){const n=ar.sorting?.rules[e]||Wd()?.sorting?.rules[e]||ar.groupSort[e];if(n){const s=n.map(i=>({...i}));return[...s,...Fq(e).filter(i=>!s.some(o=>o.key===i.key)).map(i=>({...i,on:!1}))]}return Fq(e)}function bSe(e){return Object.prototype.hasOwnProperty.call(ar.sorting?.configured||ar.groupSort,e)}function Yq(){return kq(Wd())}function ySe(e,t){return Bq(Ml(),ar.filter,e,t)}function jSe(){return lI(Ml(),ar.sorting||Wd()?.sorting)}function tN(){ft().wbFilterMemory?.save(Vq,{provider:ar.filter.provider,enabled:ar.filter.enabled,limit:ar.filter.limit})}function wSe(e){ar.filter.q!==e&&Tr({filter:{...ar.filter,q:e}})}function kSe(e){const t=e||"all";ar.filter.provider!==t&&(Tr({filter:{...ar.filter,provider:t}}),tN())}function Xq(e,t){const n={...ar.filter,[e]:t};n.enabled==="disabled"&&n.limit!=="all"&&(n.limit="all"),Tr({filter:n}),tN()}function Qq(){return ar.filter.provider!=="all"||ar.filter.enabled!=="all"||ar.filter.limit!=="all"||ar.filter.q.trim()!==""}function pI(){Tr({filter:{provider:"all",enabled:"all",limit:"all",q:""}}),tN()}function SSe(){const e=ar.filter.provider;e!=="all"&&(Yq().some(t=>t.id===e)||(Tr({filter:{...ar.filter,provider:"all"}}),tN()))}function Zq(e){try{localStorage.setItem(Kq,JSON.stringify([...e]))}catch{}}function Jq(e){const t=new Set(ar.collapsed);t.has(e)?t.delete(e):t.add(e),Zq(t),Tr({collapsed:t})}function NSe(e,t){const n=new Set(ar.collapsed);for(const s of e)t?n.add(s):n.delete(s);Zq(n),Tr({collapsed:n})}function CSe(e){return ar.selected.has(e)}function ASe(e,t){const n=new Set(ar.selected);t?n.add(e):n.delete(e),Tr({selected:n})}function e8(e,t){const n=new Set(ar.selected);for(const s of e)t?n.add(s):n.delete(s);Tr({selected:n})}function ESe(){const e=!ar.namesHidden;try{localStorage.setItem(dI,e?"1":"0")}catch{}Tr({namesHidden:e})}function TSe(e){try{localStorage.setItem(dI,e?"1":"0")}catch{}Tr({namesHidden:e})}function OSe(){const e=hI();e!==ar.groupTotalFiltered&&Tr({groupTotalFiltered:e})}function RSe(e){try{localStorage.setItem(fI,e?"1":"0")}catch{}Tr({groupTotalFiltered:e})}function t8(e){return"*".repeat(Math.min(Math.max(e.length,4),12))}const n8="usage_not_configured";function gI(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Vh(e){const t=Number(e);return Number.isFinite(t)&&t>0&&t<=864e13?t:0}function PSe(e,t){if(!e.error)return{...e,lastUsage:null,lastSuccessAt:Vh(e.lastSuccessAt)||Vh(e.at)};const n=Object.prototype.hasOwnProperty.call(e,"lastUsage"),s=gI(n?e.lastUsage:t?.error?t.lastUsage:t?.usage),i=n?Vh(e.lastSuccessAt):Vh(e.lastSuccessAt)||Vh(t?.lastSuccessAt)||(t?.error?0:Vh(t?.at));return{...e,usage:null,lastUsage:s,lastSuccessAt:s?i:0}}function r8(e,t,n){const s=Math.max(0,n-e);return s<1e4?t("刚刚更新"):s<6e4?t("{n} 秒前更新",{n:Math.floor(s/1e3)}):s<36e5?t("{n} 分钟前更新",{n:Math.floor(s/6e4)}):s<864e5?t("{n} 小时前更新",{n:Math.floor(s/36e5)}):t("{n} 天前更新",{n:Math.floor(s/864e5)})}function ISe(e,t,n,s=Date.now()){if(!e.error||e.code===n8)return null;const i=gI(e.lastUsage)?Vh(e.lastSuccessAt):0,o=i?`${t("更新失败")} · ${r8(i,t,s)}`:t("查询失败"),l=i?n(i):"";return{text:o,detail:[t(e.error),l?t("上次成功查询:{time}",{time:l}):""].filter(Boolean).join(` -`)}}const MSe=n8,uy=new Map,Kh=new Map,_Se=()=>uy,Tg=e=>Kh.get(e);function DSe(e){const t=Kh.get(e);t&&a8({...t,stale:!0})}function Og(e){return e==null?null:typeof e=="string"?{message:e,notConfigured:!1}:e.error?{message:String(e.error),notConfigured:e.code===MSe}:null}function s8(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function a8(e){Kh.set(e.id,e),uy.set(e.id,e.error?{error:e.error,code:e.code,lastUsage:e.lastUsage,lastSuccessAt:e.lastSuccessAt,stale:e.stale,requestId:e.requestId}:e.usage?{...e.usage,stale:e.stale}:void 0)}function LSe(e,t){const n=String(e.id||"");if(!n)return!1;const s=Sn().usageTasks.get(n);if(s&&e.requestId===s.requestId&&s.status==="config_changed")return!1;const i={id:n,usage:s8(e.usage),error:e.error?String(e.error):e.usage?null:a("余额响应为空"),code:typeof e.code=="string"||typeof e.code=="number"?e.code:null,at:Number(e.at)||t,stale:e.stale===!0,requestId:typeof e.requestId=="string"?e.requestId:void 0};Object.prototype.hasOwnProperty.call(e,"lastSuccessAt")&&(i.lastSuccessAt=Number(e.lastSuccessAt)||0),Object.prototype.hasOwnProperty.call(e,"lastUsage")&&(i.lastUsage=s8(e.lastUsage));const o=Kh.get(n);if(o&&Number(o.at)>Number(i.at))return!1;const l=PSe(i,o);return o&&JSON.stringify(o)===JSON.stringify(l)?!1:(a8(l),!0)}function po(e){if(e.isGuest!==!0)return uy.get(e.id)}function $Se(e){const n=Kh.get(e.id)?.lastSuccessAt??0;return Number.isFinite(n)&&n>0&&n<=864e13?n:0}function zSe(e){const t=Og(po(e));if(!t||t.notConfigured)return null;const n=Kh.get(e.id);return n?ISe(n,a,ki):null}function BSe(e){let t=!1;for(const n of uy.keys())e.has(n)||(uy.delete(n),Kh.delete(n),t=!0);return t}const FSe=800;function USe(e,t){switch(e?.status){case"running":return t("查询中…");case"cancelled":return t("已取消查询");case"config_changed":return t("配置已变更,请重新查询");case"failed":return e.error?t(e.error):t("查询失败");case"timeout":return t("查询超时,可重新查询");default:return""}}function nN(e,t=15e3){return new Promise((n,s)=>{const i=setTimeout(()=>s(new Error("等待余额查询响应超时,请重新查询")),t);e.then(o=>{clearTimeout(i),n(o)},o=>{clearTimeout(i),s(o)})})}let bc,xI,vI=!1,dy=null,HSe=0,fy=0;const i8=()=>fy,Cu=new Map,rN=new Map;function VSe(e){bc=e}function o8(){xI||vI||!bc||!Sn().usageInflight.size||(xI=setTimeout(async()=>{xI=void 0,vI=!0;try{await nN(bc(),5e3)}catch{}const e=new Map(Sn().usageTasks);let t=!1;for(const[n,s]of e)s.status==="running"&&Date.now()>s.deadlineAt+15e3&&(e.set(n,{...s,status:"timeout"}),t=!0,ft().workbuddyDesktop?.cancelBalanceQuery?.(n,s.requestId).catch(()=>{}));t&&(fy++,sN(e)),vI=!1,o8()},FSe))}function hy(e,t){const n=rN.get(e);if(n){rN.delete(e);for(const s of n)clearTimeout(s.timer),s.resolve(t)}}function sN(e){const t=Sn().usageTasks;for(const[i,o]of e){const l=t.get(i);if(l&&l.requestId!==o.requestId&&hy(l.requestId,null),o.status!=="running"){const u=Tg(i);hy(o.requestId,u?.requestId===o.requestId?u:null)}}const n=new Set([...e].filter(([,i])=>i.status==="running").map(([i])=>i)),s=!!(dy&&[...dy].some(([i,o])=>{const l=e.get(i);return l?.requestId===o&&l.status==="running"}));Tr({usageTasks:e,usageInflight:n,usageBusy:s}),o8()}function bI(e){if(!Array.isArray(e))return;const t=new Map(Sn().usageTasks);let n=!1;for(const s of e){if(!s?.id||!s.requestId||!Number.isFinite(s.startedAt)||!Number.isFinite(s.deadlineAt))continue;const i=t.get(s.id);if(!(i&&(i.startedAt>s.startedAt||i.requestId===s.requestId&&i.status!=="running"&&s.status==="running"||i.requestId===s.requestId&&i.status==="config_changed"))){if(i?.requestId===s.requestId&&i.status===s.status){if(s.status!=="running"){const o=Tg(s.id);hy(s.requestId,o?.requestId===s.requestId?o:null)}continue}t.set(s.id,s),n=!0}}n&&sN(t)}async function yI(e,t=!0){const n=e||"*";if(Cu.has(n))return null;const s=ft().workbuddyDesktop;if(!s?.startBalanceQuery)throw new Error(a("余额查询接口不可用,请更新网关后重试"));const i=++HSe;Cu.set(n,i),Tr({usageStarting:new Set(Cu.keys())});try{const o=await nN(s.startBalanceQuery(e,t));if(Cu.get(n)!==i)return null;if(!Array.isArray(o?.queries)||e&&!o.queries.some(l=>l.id===e))throw new Error(a("余额查询接口返回异常"));return fy++,e||(dy=new Map(o.queries.map(l=>[l.id,l.requestId]))),bI(o.queries),e||sN(new Map(Sn().usageTasks)),bc&&bc(),o}finally{Cu.get(n)===i&&Cu.delete(n),Tr({usageStarting:new Set(Cu.keys())})}}function KSe(e){const t=Sn().usageTasks.get(e.id);if(!t||t.requestId!==e.requestId)return Promise.resolve(null);if(t.status!=="running"){const n=Tg(e.id);return n?.requestId===e.requestId?Promise.resolve(n):!["success","failed","timeout"].includes(t.status)||!bc?Promise.resolve(null):bc().then(async()=>{Tg(e.id)?.requestId!==e.requestId&&await bc();const s=Tg(e.id);return Sn().usageTasks.get(e.id)?.requestId===e.requestId&&s?.requestId===e.requestId?s:null})}return new Promise(n=>{const s=Math.max(1e3,Math.min(195e3,e.deadlineAt-Date.now()+15e3)),i=setTimeout(()=>hy(e.requestId,null),s);rN.set(e.requestId,[...rN.get(e.requestId)||[],{resolve:n,timer:i}])})}async function l8(e){const t=Sn().usageTasks.get(e);if(!(!t||t.status!=="running"))try{const n=await nN(ft().workbuddyDesktop.cancelBalanceQuery(e,t.requestId));if(Sn().usageTasks.get(e)?.requestId!==t.requestId)return;n.cancelled?(fy++,bI([{...t,status:"cancelled"}])):bc&&bc()}catch(n){Ct(a("取消查询失败:{message}",{message:dn(n)}),"err")}}async function qSe(){dy&&await Promise.all([...dy].map(([e,t])=>Sn().usageTasks.get(e)?.requestId===t?l8(e):Promise.resolve()))}function jI(e){fy++;const t=new Map(Sn().usageTasks);for(const n of e){DSe(n),Cu.delete(n);const s=t.get(n);s&&(hy(s.requestId,null),t.set(n,{...s,status:"config_changed"}),s.status==="running"&&ft().workbuddyDesktop?.cancelBalanceQuery?.(n,s.requestId).catch(()=>{}))}Tr({usageStarting:new Set(Cu.keys())}),sN(t)}let Dl=null,aN=null,wI=0,my=null,Rg=0,c8=!1,iN=null;function u8(e){return e.map(t=>[t.id,t.name||"",t.enabled===!1?0:1,t.protocol||"",t.host||"",t.resolved?.protocol||"",t.resolved?.host||"",t.resolved?.port??"",t.port??"",t.resolveError??"",t.usedBy?.length??0,t.usedByServices?.join(",")??""].join(":")).join("|")}function d8(e){return iN!==null&&u8(e)===iN}function f8(e){iN=u8(e)}const kI=new Set;function GSe(e){return kI.add(e),()=>{kI.delete(e)}}function oN(){kI.forEach(e=>e())}function h8(){return Dl}function WSe(){return my}function YSe(){Dl=null,iN=null}function m8(e){Array.isArray(e)&&(Dl=e,wI+=1,my=null,Rg=0,!d8(e)&&(f8(e),oN()))}async function SI(e={}){if(!e.force&&Dl)return Dl;const t=wI;aN||(aN=(async()=>{try{const o=await ft().workbuddyDesktop?.getProxyPool?.();if(!o||typeof o!="object"||!Array.isArray(o.items))throw new Error(a("代理池响应异常({type})",{type:typeof o}));return{items:o.items}}finally{aN=null}})());const s=(await aN).items,i=wI===t||Dl===null;return my=null,!i&&Dl||(Dl=s,d8(s)||(f8(s),oN())),Dl}function XSe(){if(!(Dl||Date.now(){Rg=0}).catch(e=>{my=e instanceof Error?e.message:String(e),oN()})}}async function QSe(){Rg=0;try{await SI({force:!0})}catch(e){my=e instanceof Error?e.message:String(e),oN()}}let p8=!1;function g8(){if(p8)return;const e=ft().wbApp;if(!e?.getRefreshStatus||!e.subscribeRefresh)return;p8=!0;const t=e.getRefreshStatus,n=()=>{const s=t(),i=Sn();i.listBusy===s.pending&&i.listError===s.error||Tr({listBusy:s.pending,listError:s.error})};e.subscribeRefresh(n),n()}async function x8(e={}){g8();try{const t=ft().wbApp?.refresh;if(!t)throw new Error(a("账号列表刷新不可用,请重新打开页面"));const n=await t();return n&&ft().wbProviders?.refreshCustom?.(),e.feedback&&(n?Ct(a("账号列表已刷新")):Ct(a("刷新账号列表失败:{message}",{message:Sn().listError||a("请求失败")}),"err")),n}catch(t){const n=dn(t);return Tr({listBusy:!1,listError:n}),e.feedback&&Ct(a("刷新账号列表失败:{message}",{message:n}),"err"),!1}}const NI="workbuddy-desktop-accounts-group-sort";let lN=null,CI="",v8=0,b8,y8=0,j8="";function Xo(e){if(!e?.rules||!e.configured||!e.accountOrder||!Array.isArray(e.providerOrder)||e.updatedAtf&&typeof f.on=="boolean"&&(f.key==="credit"&&(f.dir==="soon"||f.dir==="late")||f.key==="balance"&&(f.dir==="high"||f.dir==="low")||f.key==="added"&&(f.dir==="new"||f.dir==="old"))).length!==u.length)){if(!Sn().sorting?.rules[l]){i[l]=u;continue}Xo(await e.saveAccountSorting({provider:l,rules:u,onlyIfUnset:!0}))}const o=Object.keys(i).length===0;return o?localStorage.removeItem(NI):localStorage.setItem(NI,JSON.stringify(i)),o}function w8(){const e=Wd()?.sorting;e&&e!==b8&&!Sn().sortBusy&&(b8=e,Xo(e));const t=JSON.stringify(Sn().sorting?.providerOrder||[]);Sn().sortBusy||!lN&&Sn().sorting&&CI!==t&&Date.now()>=v8&&(CI=t,lN=ZSe().then(n=>{n||(lN=null)}).catch(n=>{lN=null,CI="",v8=Date.now()+6e4,Ct(a("排序设置迁移失败:{message}",{message:dn(n)}),"err")}))}async function JSe(){const e=ft().workbuddyDesktop;if(!(!e?.getAccountSorting||Sn().sortBusy))try{Xo(await e.getAccountSorting())}catch(t){Ct(a("读取消耗排序失败:{message}",{message:dn(t)}),"err")}}async function AI(e,t){if(!e||Sn().sortBusy)return;const n=ft().workbuddyDesktop;if(!n?.saveAccountSorting){Ct(a("账号排序接口不可用,请确认网关与界面已更新"),"err");return}const s=Sn().sorting?.balanceSortStates!==void 0;if(!s&&t?.some(o=>o.key==="balance"&&o.on)){Ct(a("当前网关不支持余额排序,请先更新网关"),"err");return}const i=s?t:t?.filter(o=>o.key!=="balance")??null;Tr({sortBusy:!0});try{const o=await n.saveAccountSorting({provider:e,rules:i});if(!o?.rules||!o.accountOrder||!Array.isArray(o.providerOrder))throw new Error(a("保存响应不完整,请刷新当前配置确认结果"));Xo(o),window.dispatchEvent(new CustomEvent("wb:account-sorting",{detail:o}));try{await ft().wbApp?.refresh?.()}catch(l){Ct(a("排序已保存,但列表刷新失败:{message}",{message:dn(l)}),"err")}}catch(o){Ct(a("排序未保存:{message}",{message:dn(o)}),"err")}finally{Tr({sortBusy:!1})}}function qh(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Yd(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((i,o)=>Yd(i,t[o]));const n=qh(e),s=qh(t);return!!(n&&s&&Object.keys(n).length===Object.keys(s).length&&Object.entries(n).every(([i,o])=>Object.hasOwn(s,i)&&Yd(o,s[i])))}function k8(e){return e?{reset:e.reset||"fixed",seconds:e.seconds||0,startsAt:e.startsAt||0,endsAt:e.endsAt||0,utcOffsetMinutes:e.utcOffsetMinutes??null}:null}function eNe(e){return e?{id:e.id,label:e.label,provider:e.provider||"",channel:e.channel||"",planId:e.planId||"",planName:e.planName||"",models:e.models||[],unit:e.unit||"",remaining:null,total:null,used:null,remainingPercent:null,startsAt:e.startsAt||0,endsAt:e.endsAt||0,resetsAt:0,window:k8(e.window),unlimited:e.unlimited===!0,localEstimate:e.localEstimate===!0,localOnly:e.localOnly===!0}:null}function Pg(e){return e.map(t=>({enabled:t.enabled!==!1,action:t.action||"skip",target:t.target||"models",conditions:t.conditions.map((n,s)=>({join:s===0?"or":n.join||"or",sourceId:n.sourceId.trim(),source:eNe(n.source),models:[...new Set(n.models.map(i=>i.trim()).filter(Boolean))].sort(),metric:n.metric,comparison:n.comparison,threshold:n.threshold,window:k8(n.window)}))}))}function cN(e,t){return Object.entries(t).every(([n,s])=>{if(n==="proxy"){const i=e.proxy?.config||e.proxy;if(s===null)return!i||i.source==="direct";const o=qh(s),l=qh(i);return!!(o&&l&&Object.entries(o).every(([u,d])=>Yd(d,l[u])))}if(n==="maxConcurrent"){const i=Number(s),o=e.provider==="codearts"?i===0?3:Math.min(i,64):i;return e.maxConcurrent===o}if(n==="limiterGroups")return Array.isArray(s)&&Array.isArray(e.limiterGroups)&&Yd(Pg(e.limiterGroups),Pg(s));if(n==="balanceToken")return e.hasBalanceToken===(s!==null&&s!=="");if(n==="apiKey")return e.hasApiKey===(s!==null&&s!=="");if(n==="baseUrl"){const i=typeof s=="string"?s.trim().replace(/\/+$/,""):"";return i?String(e.baseUrl||"").replace(/\/+$/,"")===i:!e.baseUrl}if(n==="balanceQuery"){const i=qh(s),o=qh(e.balanceQuery);return!!(i&&o&&Object.entries(i).every(([l,u])=>{const f={accessToken:"hasAccessToken",password:"hasPassword",token:"hasToken"}[l];return f?o[f]===(u!==null&&u!==""):Yd(o[l],u)}))}return Yd(e[n],s)})}async function Gh(e,t){const n=ft().workbuddyDesktop;if(!n?.updateAccount)throw new Error(a("账号更新接口不可用,请重新打开页面"));const s=ft().wbApp?.getState?.()?.accounts?.accounts?.find(u=>u.id===e),i=await n.updateAccount(e,t);i?.changes?.length&&["proxy","baseUrl","balanceToken","apiKey","noAuth","balanceQuery","zcodePlan","userAgent"].some(u=>{if(!Object.prototype.hasOwnProperty.call(t,u))return!1;if(u==="balanceQuery"&&s){const d=qh(t.balanceQuery);return!!(d&&["accessToken","password","token"].some(m=>Object.prototype.hasOwnProperty.call(d,m))||!cN(s,{balanceQuery:t.balanceQuery}))}return s&&!["balanceToken","apiKey"].includes(u)?!cN(s,{[u]:t[u]}):!0})&&jI([e]);const l=i?.account;if(!l||l.id!==e||s&&l.provider!==s.provider||!cN(l,t))throw new Error(a("账号更新结果未确认,请刷新后核对设置"));return l}function tNe(e){switch(e.action){case"enable":return{enabled:!0};case"disable":return{enabled:!1};case"proxy":return{proxy:e.proxy};case"concurrency":return{maxConcurrent:e.maxConcurrent};case"usageQuery":return{usageQuery:e.usageQuery};default:return{}}}function EI(e,t){if(!e||!Array.isArray(t.action==="remove"?e.removed:e.ok))throw new Error(a("批量操作未返回结果,请刷新后确认状态"));const n=t.action==="remove"?e.removed||[]:e.ok||[],s=new Set(t.ids),i=new Set;if([...n,...e.failed||[],...e.skipped||[]].some(d=>!d.id||!s.has(d.id)||i.has(d.id)?!0:(i.add(d.id),!1))||i.size!==s.size)throw new Error(a("批量操作结果不完整,请刷新后核对所选账号"));const l=e.list?.accounts;if(!Array.isArray(l))throw new Error(a("批量操作结果不完整,请刷新后核对所选账号"));const u=tNe(t);if(n.some(d=>{const f=l.find(g=>g.id===d.id);if(t.action==="remove")return!!f;if(!f||!cN(f,u))return!0;if(t.action!=="limiters")return!1;const m=f.limiterGroups;if(!Array.isArray(m))return!0;switch(t.limiterMode){case"append":return Pg(t.limiterGroups||[]).some(g=>!Pg(m).some(v=>Yd(v,g)));case"replace":return!Yd(Pg(m),Pg(t.limiterGroups||[]));case"enable":return m.some(g=>g.enabled!==!0);case"disable":return m.some(g=>g.enabled!==!1);case"clear":return m.length!==0;default:return!0}}))throw new Error(a("批量操作结果未确认,请刷新后核对设置"));if(t.action==="proxy"||t.action==="remove"){const d=t.action==="remove"?e.removed||[]:(e.ok||[]).filter(f=>f.changes?.length);jI(d.map(f=>f.id).filter(Boolean))}return e}async function Qo(){const e=ft().wbApp;if(!e?.refresh)throw new Error(a("账号列表刷新接口不可用,请重新打开页面"));if(await e.refresh()!==!0)throw new Error(e.getRefreshStatus?.().error||a("账号列表刷新失败"))}const py=new Map;let S8=0,N8=!1,uN;VSe(Ig);function Wh(e){return e?py.get(e.id)||[]:[]}function nNe(e){const t=Number(e?.tokenAt)||0;if(!t||t===S8)return!1;const n=e?.tokenUsage;if(!n||typeof n!="object")return!1;S8=t;const s=new Map;for(const[o,l]of Object.entries(n)){if(!Array.isArray(l))continue;const u=[];for(const d of l){if(!d||typeof d!="object")continue;const f=Number(d.kind),m=Number(d.windowStart),g=Number(d.used);!Number.isFinite(f)||f<0||!Number.isFinite(m)||m<=0||!Number.isFinite(g)||g<0||u.push({kind:f,windowStart:m,used:g})}s.set(o,u)}const i=s.size!==py.size||[...s].some(([o,l])=>{const u=py.get(o);return!u||u.length!==l.length||l.some((d,f)=>d.used!==u[f]?.used||d.windowStart!==u[f]?.windowStart)});py.clear();for(const[o,l]of s)py.set(o,l);return i}function rNe(){return Ml().filter(e=>Si(e)&&e.available!==!1)}function C8(e){const t=Array.isArray(e?.results)?e.results:[],n=Number(e?.at)||Date.now();let s=0;for(const i of t)i&&LSe(i,n)&&(s++,i.code==="refresh_token_expired"&&ft().wbApp?.refresh?.());return s&&(eN(),ft().wbApp?.renderTopbarStatus?.()),s}function sNe(e){if(!sI(e)||e.needsRelogin)return!1;const t=po(e);return!t||typeof t!="object"||Array.isArray(t)||Og(t)?!1:!Array.isArray(t.credits)}async function aNe(){if(!N8){N8=!0;for(const e of Ml().filter(sNe))try{await TI(e.id,!1)}catch{}}}function Ig(){return uN||(uN=iNe().finally(()=>{uN=void 0})),uN}async function iNe(){try{const e=i8(),t=await nN(Promise.resolve(ft().workbuddyDesktop?.getBalancesSnapshot?.()),5e3);if(e!==i8())return!1;const n=Pke(t),s=!Sn().sortBusy&&Xo(t?.sorting),i=nNe(t)||n||s;i&&(eN(),ft().wbApp?.renderTopbarStatus?.());const o=C8(t);return bI(t?.queries),o?(aNe(),!0):i}catch{return!1}}async function TI(e,t=!0){const n=await yI(e||void 0,t);if(!n)return{results:[]};const s=await Promise.all(n.queries.map(KSe));return JSe(),{results:s.filter(i=>i!==null)}}async function A8(){if(!Sn().usageStarting.has("*")){if(!rNe().length){Ct(a("暂无可查询余额的账号"),"err");return}try{await yI(void 0,!0)}catch(e){Ct(a("余额查询失败:{message}",{message:dn(e)}),"err")}}}async function oNe(e){try{if(!(await TI(e)).results.length)return;const n=_Se().get(e),s=Og(n),i=aq(n,a);s?.notConfigured?Ct(s.message,"ok"):s?Ct(a("余额查询失败:{message}",{message:s.message}),"err"):i?Ct(i.detail,"ok"):Ct(a("✅ 已更新余额"))}catch(t){Ct(a("余额查询失败:{message}",{message:dn(t)}),"err")}}async function gy(e){const t=e?_l(e):null;if(!(e&&(!t||!Si(t)||t.needsRelogin)))try{await yI(e,!1)}catch{}}function Mg(e){if(!_l(e)){Ct(a("账号不存在,请刷新后重试"),"err");return}Tr({dialog:{kind:"settings",id:e}})}function xy(){Tr({dialog:null})}function OI(e,t="enable"){const n=(Array.isArray(e)?e:[]).filter(s=>_l(s));if(!n.length){Ct(a("请先勾选要操作的账号"),"err");return}Tr({dialog:{kind:"batch",ids:n,action:t}})}function E8(e){e&&Tr({dialog:{kind:"group",provider:e}})}function lNe(e){let t=BSe(e);const n=new Map(Sn().connections);for(const o of[...n.keys()])e.has(o)||(n.delete(o),t=!0);const s=new Set(Sn().usageInflight);for(const o of[...s])e.has(o)||(s.delete(o),t=!0);const i=new Set(Sn().selected);for(const o of[...i])e.has(o)||(i.delete(o),t=!0);t&&Tr({connections:n,usageInflight:s,selected:i})}const cNe=2e3;function T8(e){return Sn().connections.get(e)||0}async function O8(){try{const e=await ft().workbuddyDesktop?.getAccountConnections?.(),t=e?.counts&&typeof e.counts=="object"?e.counts:{},n=new Map;for(const[s,i]of Object.entries(t)){const o=Number(i)||0;o>0&&n.set(s,o)}return uNe(n,Sn().connections)||Tr({connections:n}),!0}catch{return!1}}function uNe(e,t){if(e.size!==t.size)return!1;for(const[n,s]of e)if(t.get(n)!==s)return!1;return!0}let R8=null;function dNe(){R8||(R8=setInterval(()=>{document.hidden||ft().wbApp?.currentPage!=="accounts"||O8()},cNe))}async function P8(e,t){try{await Gh(e,{enabled:t}),Ct(a(t?"✅ 已启用":"✅ 已禁用"));try{await Qo()}catch(n){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(n)}),"err")}}catch(n){Ct(a("操作失败:{message}",{message:dn(n)}),"err"),ft().wbApp?.refresh?.()}}async function I8(e,t){if(!e.length)return!1;try{return await ft().workbuddyDesktop?.reorderAccounts?.(e),Ct(t?a("✅ 已保存:{note}",{note:t}):a("✅ 顺序已保存")),await ft().wbApp?.refresh?.(),!0}catch(n){return Ct(a("顺序未保存:{message}",{message:dn(n)}),"err"),ft().wbApp?.refresh?.(),!1}}async function M8(e,t){if(e.length)try{const n=ft().workbuddyDesktop;if(!n?.batchAccounts)throw new Error(a("批量操作接口不可用,请重新打开页面"));const s={action:t?"enable":"disable",ids:e},i=EI(await n.batchAccounts(s),s),o=i.ok?.length||0,l=i.ok?.filter(d=>d.changes?.length).length||0,u=i.failed?.length||0;u||i.skipped?.length?Ct(a("{verb}完成:成功 {ok} 个,未变更 {unchanged} 个,跳过 {skip} 个,失败 {fail} 个",{verb:a(t?"启用":"禁用"),ok:l,unchanged:o-l,skip:i.skipped?.length||0,fail:u}),u?"err":"ok"):Ct(t?a("✅ 已启用 {n} 个账号",{n:o}):a("✅ 已禁用 {n} 个账号",{n:o}));try{await Qo()}catch(d){Ct(a("批量操作已保存,但列表刷新失败:{error}",{error:dn(d)}),"err")}}catch(n){Ct(a("操作失败:{message}",{message:dn(n)}),"err"),ft().wbApp?.refresh?.()}}async function fNe(e,t){try{await ft().workbuddyDesktop?.clearRateLimits?.(e,t||null),Ct(t?a("✅ 已清除 {model} 的限流标记",{model:t}):a("✅ 已清除该账号全部限流标记")),await ft().wbApp?.refresh?.()}catch(n){Ct(a("清除失败:{message}",{message:dn(n)}),"err")}}async function hNe(e,t,n){if(typeof t!="string")return;if(t===_8){Mg(e);return}if(t===dN||t===n)return;const s=t.startsWith(vc)?t.slice(vc.length).trim():"";if(!(t!==""&&!s)){if(s){const i=(h8()||[]).find(o=>o.id===s);if(i&&i.enabled===!1){Ct(a("「{name}」已在「网络代理」页禁用,请先启用它或换一条",{name:i.name||s}),"err");return}}try{await Gh(e,{proxy:s?{source:"pool",proxyId:s}:null}),Ct(`✅ ${a("代理已更新")}`)}catch(i){Ct(a("保存失败:{message}",{message:dn(i)}),"err")}finally{try{await Qo()}catch(i){Ct(a("刷新账号列表失败:{message}",{message:dn(i)}),"err")}}}}const dN="__proxy_custom__",_8="__proxy_custom_edit__";function mNe(e,t,n=1){return{seat:t.get(e.id)||{position:1,total:1},rank:n,picked:CSe(e.id),usageEntry:po(e),connections:T8(e.id)}}const pNe={DEFAULT_PROVIDER_ID:QP,RACCOON_PROVIDER_ID:zke,providerOf:tn,providerFeatures:Ga,providerSummaries:kq,identifierOf:QS,tokenExpiryOf:Nq,supportsUsage:Si,isDesktopAccount:oy,supportsChat:Oq,byPriorityOrder:ZS,typeLabel:rSe,isEnabled:Ni,isRateLimited:ly,isLimited:e=>cy(e,e?po(e):void 0,Wh(e)),accountEdition:Rq,matchEnabled:iI,matchLimit:$q,visibleAccounts:oSe,filterCounts:Bq,positionMap:lI,activeLimits:oI,editionSuffix:dSe,formatResetText:uI};function gNe(){g8(),window.wbAccountsView={render:()=>{w8(),eN()},refreshList:x8,refreshCaches:lNe,invalidateUsageTasks:jI,syncConnections:O8,refreshProxyPool:QSe,applyBalances:C8,syncBalancesSnapshot:Ig,queryUsageFor:TI,queryAllUsage:A8,refreshUsageAfterCheckin:gy,supportsUsage:Si,isDesktopAccount:oy,isEnabled:Ni,isRateLimited:ly},window.wbAccountsModel=pNe,window.wbAccountPanel={open:Mg,close:xy,openBatch:OI,closeBatch:xy,syncAddProvider:()=>ft().wbAccountAddForms?.syncAddProvider?.(),invalidate:()=>{YSe()}}}async function xNe(e,t){const n=ft().workbuddyDesktop;if(!n?.refreshAccountToken)throw new Error(a("Token 刷新接口不可用,请重新打开页面"));const s=[...new Set(e)],i=[],o=[],l=[];for(const[u,d]of s.entries()){const f=_l(d),m=Ci(f)||d;t({completed:u,total:s.length,name:m});try{if(!f)throw new Error(a("账号不存在,请刷新后重试"));const g=qP(f);if(g)l.push({id:d,name:m,reason:g});else{const v=await n.refreshAccountToken(d),b=v?.list?.accounts?.find(y=>y.id===d);if(v?.refreshedId!==d||!b||b.needsRelogin===!0||tn(b)!==tn(f))throw new Error(a("Token 刷新结果未确认,请刷新后核对账号状态"));i.push({id:d,name:m})}}catch(g){o.push({id:d,error:dn(g)})}t({completed:u+1,total:s.length,name:m})}return{ok:i,failed:o,skipped:l}}const D8=[{value:"fixed",label:()=>a("固定周期")},{value:"rolling",label:()=>a("滚动窗口")},{value:"daily",label:()=>a("自然日")},{value:"weekly",label:()=>a("自然周")},{value:"monthly",label:()=>a("自然月")},{value:"total",label:()=>a("生效至到期累计(不自动回满)")}];function vNe(){return{join:"or",sourceId:"local",models:[],metric:"tokens",comparison:"gte",threshold:5e5,window:{reset:"daily",utcOffsetMinutes:null}}}function L8(e){if(!e||!Number.isFinite(e))return"";const t=new Date(e);return new Date(e-t.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function $8(e){const t=e.metric==="tokens"&&e.threshold%1e8===0?"yi":e.metric==="tokens"&&e.threshold%1e4===0?"wan":"unit";return{condition:{...structuredClone(e),window:e.window||e.source?.window,sourceId:e.sourceId||(e.metric==="tokens"||e.metric==="requests"?"local":"account")},unit:t,threshold:String(e.threshold/(t==="yi"?1e8:t==="wan"?1e4:1)),period:String(((e.window||e.source?.window)?.seconds||3600)/3600),anchor:L8((e.window||e.source?.window)?.startsAt),end:L8((e.window||e.source?.window)?.endsAt)}}function z8(e){if(!e||e.id==="local"||e.localOnly)return["tokens","requests"];if(e.id==="account")return["remaining"];const t=[];return e.unlimited||(e.remaining!==null&&e.remaining!==void 0&&t.push("remaining"),e.used!==null&&e.used!==void 0&&t.push("used"),(e.remainingPercent!==null&&e.remainingPercent!==void 0||(e.total||0)>0)&&t.push("remaining_percent","used_percent")),e.window&&t.push("tokens","requests"),t.length?t:["tokens","requests"]}function bNe({account:e,value:t,allowBalance:n=!0,onSave:s,onClose:i}){const[o,l]=p.useState(()=>$8(t)),[u,d]=p.useState(""),f=o.condition,m=UP(e).filter(M=>(n||M.id==="local")&&(tn(e)!=="codearts"||M.id==="account"||zh(M.unit||"")));f.source&&!m.some(M=>M.id===f.sourceId)&&m.push(f.source);const g=m.find(M=>M.id===f.sourceId),v=m.find(M=>M.id==="account"&&zh(M.unit||"")),b=[...new Map(m.filter(M=>M.planId).map(M=>[M.planId,M.planName||M.planId])).entries()],y=g?.planId||"",k=m.filter(M=>M.id==="account"||(y?M.planId===y:!M.planId)),w=f.metric==="tokens"||f.metric==="requests",S=Number(o.threshold)*(o.unit==="yi"?1e8:o.unit==="wan"?1e4:1),N=f.metric==="tokens"&&o.unit!=="unit"&&o.threshold.trim()&&Number.isSafeInteger(S)&&S>0?S.toLocaleString("en-US"):"",C=v?.unlimited?a("不限"):v?.remaining==null?a("暂无读数"):`${Ln(v.remaining)} ${a("积分")}`,T=g?.models?.length?g.models.map(M=>({value:M,label:M})):Ike(e);for(const M of f.models)T.some(_=>_.value===M)||T.push({value:M,label:M});const P=[...new Set([...z8(g),f.metric])].filter(M=>tn(e)!=="codearts"||M!=="tokens"&&M!=="requests"),O=M=>{d(""),l(_=>({..._,condition:{..._.condition,...M}}))},A=M=>{const _=m.find(D=>D.id===M);if(!_)return;const L=_.localOnly||_.localEstimate?"tokens":z8(_)[0],$=L==="tokens"?_.total||5e5:L.endsWith("percent")?5:1;l($8({...f,sourceId:M,source:dq(_),models:_.models?.length===1?_.models.slice():[],metric:L,comparison:L.startsWith("remaining")?"lte":"gte",threshold:$,window:_.window||{reset:"daily",utcOffsetMinutes:null}})),d("")},R=()=>{const M=Number(o.threshold),_=f.metric==="tokens"?Math.round(M*(o.unit==="yi"?1e8:o.unit==="wan"?1e4:1)):M;if(!o.threshold.trim()||!Number.isFinite(_)||_<0){d(a("限制阈值必须是非负有限数字"));return}if(w&&(!Number.isSafeInteger(_)||_<=0)){d(a("本地消耗上限必须是大于 0 的安全整数"));return}if(f.metric.endsWith("percent")&&_>100){d(a("百分比阈值必须在 0~100 之间"));return}let L=f.window;if(w){if(L={...L,reset:L?.reset||"daily"},L.reset==="fixed"||L.reset==="rolling"){const $=Math.round(Number(o.period)*3600);if(!Number.isFinite($)||$<60||$>2678400){d(a("统计窗口必须是 1 分钟~31 天"));return}L.seconds=$}if((L.reset==="total"||L.reset==="fixed")&&(L.startsAt=o.anchor?new Date(o.anchor).getTime():0,L.endsAt=o.end?new Date(o.end).getTime():0,!Number.isFinite(L.startsAt)||!Number.isFinite(L.endsAt)||L.endsAt>0&&L.endsAt<=L.startsAt)){d(a("统计结束时间必须晚于开始时间"));return}}s({...f,threshold:_,window:L,source:g&&g.id!=="account"&&g.id!=="local"?dq(g):null})};return r.jsx(at,{open:!0,onOpenChange:M=>{M||i()},children:r.jsxs(it,{className:"w-[min(680px,calc(100vw-48px))]",showCloseButton:!0,overlayForceRender:!0,children:[r.jsx(ot,{children:r.jsx(st,{children:a("编辑限制条件")})}),r.jsxs(lt,{className:"space-y-3",children:[b.length?r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("套餐")}),r.jsxs(Pt,{value:y,onValueChange:M=>{const _=m.find(L=>M?L.planId===M:!L.planId);_&&A(_.id)},children:[r.jsx(Mt,{className:"min-w-0 flex-1",children:r.jsx(It,{children:b.find(([M])=>M===y)?.[1]||a("通用额度/本地保护")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"",children:a("通用额度/本地保护")}),b.map(([M,_])=>r.jsx(Ze,{value:M,children:_},M))]})]})]}):null,r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("额度来源")}),r.jsxs(Pt,{value:f.sourceId||"account",onValueChange:M=>{M&&A(M)},children:[r.jsx(Mt,{className:"min-w-0 flex-1",children:r.jsx(It,{children:VP(g,f.sourceId||"account")})}),r.jsx(_t,{children:k.map(M=>r.jsx(Ze,{value:M.id,children:VP(M)},M.id))})]})]}),v?r.jsxs(wP,{className:"space-y-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("span",{className:"text-xs text-subtle",children:a("总积分")}),r.jsx("span",{className:"text-[13px] font-semibold tabular-nums",children:C}),r.jsx(B,{variant:"outline",size:"sm",className:"ml-auto",disabled:g?.id===v.id&&f.metric==="remaining",onClick:()=>A(v.id),children:a("按总积分设置限制")})]}),r.jsx("p",{className:"detail",children:a("总积分是当前可用积分的汇总,与余额列一致;不重复累加汇总行,不包含 Token、次数或其他单位的额度。")})]}):null,r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("模型范围")}),r.jsx(xc,{value:f.models,options:T,onValueChange:M=>O({models:M}),placeholder:g?.models?.length?a("该额度中的全部模型"):a("全部模型"),className:"min-w-0 flex-1","aria-label":a("模型范围")})]}),r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("限制指标")}),r.jsxs(Pt,{value:f.metric,onValueChange:M=>{M&&(O({metric:M,comparison:M.startsWith("remaining")?"lte":"gte"}),l(_=>({..._,threshold:"",unit:"unit"})))},children:[r.jsx(Mt,{className:"min-w-[190px]",children:r.jsx(It,{children:KP(f.metric)})}),r.jsx(_t,{children:P.map(M=>r.jsx(Ze,{value:M,children:KP(M)},M))})]})]}),r.jsxs(Lh,{orientation:"horizontal",className:"field-row",children:[r.jsx("span",{className:"text-[12.5px] text-subtle",children:a("触发条件")}),r.jsxs(Pt,{value:f.comparison,onValueChange:M=>O({comparison:M}),children:[r.jsx(Mt,{className:"w-[92px]","aria-label":a("触发条件"),children:r.jsx(It,{children:f.comparison==="lt"?"<":f.comparison==="lte"?"≤":"≥"})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"lt",children:"<"}),r.jsx(Ze,{value:"lte",children:"≤"}),r.jsx(Ze,{value:"gte",children:"≥"})]})]}),r.jsx(ze,{type:"number",min:0,className:"max-w-[160px]",value:o.threshold,onChange:M=>l({...o,threshold:M.currentTarget.value}),placeholder:a("阈值"),"aria-label":a("阈值")}),f.metric==="tokens"?r.jsxs(Pt,{value:o.unit,onValueChange:M=>l({...o,unit:M}),children:[r.jsx(Mt,{className:"w-[84px]","aria-label":a("Token 单位"),children:r.jsx(It,{children:o.unit==="yi"?a("亿"):o.unit==="wan"?a("万"):a("个")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"yi",children:a("亿")}),r.jsx(Ze,{value:"wan",children:a("万")}),r.jsx(Ze,{value:"unit",children:a("个")})]})]}):r.jsx("span",{className:"detail",children:f.metric.endsWith("percent")?"%":f.metric==="requests"?a("次"):mo(g?.unit||"",a)})]}),N?r.jsx("p",{className:"detail",children:a("实际阈值:{value} Token",{value:N})}):null,w?r.jsxs(r.Fragment,{children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("统计周期")}),r.jsxs(Pt,{value:f.window?.reset||"daily",onValueChange:M=>O({window:{...f.window,reset:M}}),children:[r.jsx(Mt,{className:"min-w-0 flex-1",children:r.jsx(It,{children:D8.find(M=>M.value===(f.window?.reset||"daily")).label()})}),r.jsx(_t,{children:D8.map(M=>r.jsx(Ze,{value:M.value,children:M.label()},M.value))})]})]}),f.window?.reset==="fixed"||f.window?.reset==="rolling"?r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("窗口长度")}),r.jsx(ze,{type:"number",min:1/60,max:744,step:"any",value:o.period,className:"max-w-[130px]",onChange:M=>l({...o,period:M.currentTarget.value})}),r.jsx("span",{className:"detail",children:a("小时")})]}):null,f.window?.reset==="total"||f.window?.reset==="fixed"?r.jsxs(r.Fragment,{children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("累计起点")}),r.jsx(ze,{type:"datetime-local",value:o.anchor,onChange:M=>l({...o,anchor:M.currentTarget.value}),className:"min-w-0 flex-1"})]}),r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("到期时间")}),r.jsx(ze,{type:"datetime-local",value:o.end,onChange:M=>l({...o,end:M.currentTarget.value}),className:"min-w-0 flex-1"})]})]}):null,["daily","weekly","monthly"].includes(f.window?.reset||"daily")?r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("重置时区")}),r.jsxs(Pt,{value:f.window?.utcOffsetMinutes===480?"beijing":f.window?.utcOffsetMinutes===0?"utc":"local",onValueChange:M=>O({window:{...f.window,reset:f.window?.reset||"daily",utcOffsetMinutes:M==="beijing"?480:M==="utc"?0:null}}),children:[r.jsx(Mt,{className:"min-w-[190px]",children:r.jsx(It,{children:f.window?.utcOffsetMinutes===480?a("北京时间(UTC+8)"):f.window?.utcOffsetMinutes===0?"UTC":a("服务器本地时区")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"local",children:a("服务器本地时区")}),r.jsx(Ze,{value:"beijing",children:a("北京时间(UTC+8)")}),r.jsx(Ze,{value:"utc",children:"UTC"})]})]})]}):null]}):null,r.jsx("p",{className:"detail",children:a(w?"本地统计只包含经过本网关的请求,不等于上游账单;清理请求日志不会清零。套餐选择用于限定保护范围,不会强制上游扣指定套餐。":"按上游额度查询的读数判定;模型共用同一个额度池时,选择模型不会拆分该池余额。")}),w&&T.length>0?r.jsx("p",{className:"detail",children:a("选中多个模型时,每个模型单独累计、单独比较阈值;不合并用量。")}):null,g?.localEstimate?r.jsx("p",{className:"detail text-warning",children:a("上游没有提供此额度的分桶用量,当前使用本地估算保护;在其他客户端产生的消耗不会计入。")}):null,g?.channel&&g.channel!==String(e?.quotaChannel||e?.zcodePlan||"")?r.jsx("p",{className:"detail text-warning",children:a("此额度不属于账号当前使用的通道,切换到对应通道后才参与判定。")}):null,u?r.jsx("p",{className:"detail text-destructive",children:u}):null]}),r.jsxs(xt,{children:[r.jsx(B,{variant:"outline",onClick:i,children:a("取消")}),r.jsx(B,{onClick:R,children:a("保存条件")})]})]})})}function B8({account:e,draft:t,onChange:n,allowBalance:s=!0}){const[i,o]=p.useState(null),[l,u]=p.useState(!1);p.useEffect(()=>{Ig()},[e?.id]);const d=(k,w)=>{n(t.map((S,N)=>N===k?{...S,...w}:S))},f=()=>tn(e)==="codearts"?{join:"or",sourceId:"account",models:[],metric:"remaining",comparison:"lt",threshold:1}:vNe(),m=()=>o({group:-1,condition:-1,value:f()}),g=k=>{if(i){if(i.group<0)n([...t,{enabled:!0,action:"skip",target:"models",conditions:[k]}]);else{const S=t[i.group].conditions.slice();i.condition<0?S.push(k):S[i.condition]=k,d(i.group,{conditions:S})}o(null)}},v=async()=>{if(!(!e||l)){u(!0);try{await gy(e.id),await Ig()}finally{u(!1)}}},b=HP(e),y=e?sy(e,Fh(e)):[];return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"acct-limiter-toolbar flex flex-wrap items-center gap-2",children:[r.jsx(B,{variant:"outline",onClick:m,children:a("+ 添加限制")}),e&&s?r.jsx(B,{variant:"ghost",disabled:l,onClick:()=>{v()},children:a(l?"查询中…":"刷新套餐与额度")}):null]}),r.jsx("p",{className:"detail acct-limiter-lead",children:a("每组共用一个触发动作;第二条条件起可选择「与/或」。与优先于或,下面会显示明确分组。各条件组独立生效。")}),t.length?null:r.jsx("p",{className:"detail acct-limiter-lead",children:a("还没有条件组:账号照常参与转发,不设置额度保护。")}),t.map((k,w)=>{const S=JSON.stringify(k)===JSON.stringify(y[w])?b[w]:void 0;return r.jsxs("div",{className:"acct-limiter-group rounded-lg border border-hairline p-3 space-y-2",children:[r.jsxs("div",{className:"acct-limiter-head flex flex-wrap items-center gap-2",children:[r.jsx(St,{checked:k.enabled,onCheckedChange:N=>d(w,{enabled:N}),"aria-label":a("启用该规则")}),r.jsx("span",{className:"text-[13px] font-medium",children:a("条件组 {n}",{n:w+1})}),S?r.jsx(Ee,{shape:"tag",variant:k.enabled?S.hit?"warning":"success":"secondary",children:k.enabled?S.hit?a("已触发"):a("未触发"):a("已停用")}):null,r.jsx("div",{className:"flex-1"}),r.jsx(B,{variant:"ghost",size:"sm",onClick:()=>n(t.filter((N,C)=>C!==w)),children:a("删除组")})]}),k.conditions.map((N,C)=>r.jsxs("div",{className:"acct-limiter-condition flex flex-wrap items-center gap-2 rounded-md bg-control p-2",children:[C>0?r.jsxs(Pt,{value:N.join,onValueChange:T=>d(w,{conditions:k.conditions.map((P,O)=>O===C?{...P,join:T}:P)}),children:[r.jsx(Mt,{className:"w-[78px]",children:r.jsx(It,{children:N.join==="and"?a("与"):a("或")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"and",children:a("与")}),r.jsx(Ze,{value:"or",children:a("或")})]})]}):r.jsx("span",{className:"text-xs text-muted-foreground",children:a("当")}),r.jsxs("div",{className:"min-w-0 flex-1 text-xs",children:[r.jsx("div",{className:"break-words",children:fq(N,e)}),S?r.jsx("div",{className:"text-muted-foreground mt-1",children:a("当前:{value}",{value:Mke(S.conditions[C],N,e)})}):null]}),r.jsx(B,{variant:"ghost",size:"xs",onClick:()=>o({group:w,condition:C,value:N}),children:a("编辑")}),r.jsx(B,{variant:"ghost",size:"xs",disabled:k.conditions.length===1,onClick:()=>d(w,{conditions:k.conditions.filter((T,P)=>P!==C).map((T,P)=>P===0?{...T,join:"or"}:T)}),children:a("删除")})]},C)),r.jsx(B,{variant:"ghost",size:"sm",onClick:()=>o({group:w,condition:-1,value:f()}),children:a("+ 添加条件")}),r.jsxs(Lh,{orientation:"horizontal",className:"field-row acct-limiter-actions",children:[r.jsx(Ae,{children:a("触发动作")}),r.jsxs(Pt,{value:k.action,onValueChange:N=>d(w,{action:N}),children:[r.jsx(Mt,{className:"min-w-[190px]","aria-label":a("触发动作"),children:r.jsx(It,{children:k.action==="disable"?a("禁用整个账号(手动恢复)"):a("跳过(自动恢复)")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"skip",children:a("跳过(自动恢复)")}),r.jsx(Ze,{value:"disable",children:a("禁用整个账号(手动恢复)")})]})]}),k.action==="skip"?r.jsxs(Pt,{value:k.target,onValueChange:N=>d(w,{target:N}),children:[r.jsx(Mt,{className:"min-w-[170px]","aria-label":a("模型范围"),children:r.jsx(It,{children:k.target==="account"?a("整个账号"):a("命中条件的模型")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"models",children:a("命中条件的模型")}),r.jsx(Ze,{value:"account",children:a("整个账号")})]})]}):null]}),r.jsx("p",{className:"detail break-words acct-limiter-expression",children:Dke(k.conditions,e)})]},w)}),e?null:r.jsx("p",{className:"detail",children:a("跨账号批量配置仅支持通用条件;套餐实例不能直接复制到其他账号。")}),i?r.jsx(bNe,{account:e,value:i.value,allowBalance:s,onSave:g,onClose:()=>o(null)},`${i.group}:${i.condition}`):null]})}function yNe(e,t){const n=sy(e,Fh(e));return JSON.stringify(t)===JSON.stringify(n)?null:{patch:{limiterGroups:t}}}function F8(e){return structuredClone(sy(e,Fh(e)))}const jNe={seconds:1,minutes:60,hours:3600};function wNe(e){return e>0&&e%3600===0?{value:String(e/3600),unit:"hours"}:e>0&&e%60===0?{value:String(e/60),unit:"minutes"}:e>0?{value:String(e),unit:"seconds"}:{value:"5",unit:"minutes"}}function RI(e){const{enabled:t,interval:n,retries:s,timeoutSeconds:i}=jq(e),o=wNe(t?n:0);return{enabled:t,intervalInput:o.value,unit:o.unit,retriesInput:String(s),timeoutInput:String(i||XS)}}function U8(e){const t=Number(e.retriesInput);if(!e.retriesInput.trim()||!Number.isInteger(t)||t<0||t>YS)return{error:a("失败重试次数必须是 0~{max} 的整数",{max:YS})};const n=Number(e.timeoutInput??XS);if(!Number.isInteger(n)||n<15||n>XP)return{error:a("整轮查询时限必须是 15~180 秒的整数")};if(!e.enabled)return{value:{enabled:!1,interval:0,retries:t,timeoutSeconds:n}};const s=Number(e.intervalInput),i=Math.round(s*jNe[e.unit]);return!Number.isFinite(s)||s<=0?{error:a("请填写查询间隔")}:iyq?{error:a("查询间隔必须是 {min} 秒 ~ 24 小时",{min:YP})}:{value:{enabled:!0,interval:i,retries:t,timeoutSeconds:n}}}function kNe(e,t){const n=U8(t);if("error"in n)return n;const{enabled:s,interval:i,retries:o,timeoutSeconds:l}=n.value,u=jq(e);return s===u.enabled&&(!s||i===u.interval)&&o===u.retries&&l===u.timeoutSeconds?null:{patch:{usageQuery:{enabled:s,interval:s?i:u.interval,retries:o,timeoutSeconds:l}}}}function H8({draft:e,onChange:t,idPrefix:n="account-usage"}){const s=i=>t({...e,...i});return r.jsxs(r.Fragment,{children:[r.jsx(ct,{orientation:"horizontal",className:"field-row mt-2.5 acct-usage-toggle",children:r.jsxs(ut,{className:"inline-flex cursor-pointer items-center gap-2.5 font-normal",children:[r.jsx(St,{checked:e.enabled,onCheckedChange:i=>s({enabled:i===!0}),"aria-label":a("自动查询余额")}),r.jsx("span",{className:"text-xs text-subtle",children:a("自动查询余额(按下面的间隔自动刷新余额列的读数)")})]})}),e.enabled?r.jsxs(Lh,{orientation:"horizontal",className:"field-row mt-2.5 acct-usage-interval",children:[r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-interval`,children:a("查询间隔")}),r.jsx(ze,{id:`${n}-interval`,type:"number",min:1,step:1,className:"max-w-[110px]",value:e.intervalInput,onChange:i=>s({intervalInput:i.currentTarget.value})})]}),r.jsxs(Pt,{value:e.unit,onValueChange:i=>s({unit:i}),children:[r.jsx(Mt,{className:"w-[92px]","aria-label":a("间隔单位"),children:r.jsx(It,{children:e.unit==="hours"?a("小时"):e.unit==="minutes"?a("分钟"):a("秒")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"seconds",children:a("秒")}),r.jsx(Ze,{value:"minutes",children:a("分钟")}),r.jsx(Ze,{value:"hours",children:a("小时")})]})]}),r.jsx("span",{className:"detail",children:a("30 秒 ~ 24 小时;手动查询会顺延下一轮")})]}):null,r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5 acct-usage-interval",children:[r.jsx(ut,{htmlFor:`${n}-timeout`,children:a("整轮查询时限")}),r.jsx(ze,{id:`${n}-timeout`,type:"number",min:15,max:XP,step:1,className:"max-w-[110px]",value:e.timeoutInput??String(XS),onChange:i=>s({timeoutInput:i.currentTarget.value})}),r.jsx("span",{className:"detail",children:a("秒;默认 60 秒,包含重试等待,多步骤查询可适当延长。")})]}),r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5 acct-usage-interval",children:[r.jsx(ut,{htmlFor:`${n}-retries`,children:a("失败重试次数")}),r.jsx(ze,{id:`${n}-retries`,type:"number",min:0,max:YS,step:1,className:"max-w-[110px]",value:e.retriesInput,"aria-describedby":`${n}-retries-hint`,onChange:i=>s({retriesInput:i.currentTarget.value})}),r.jsx("span",{id:`${n}-retries-hint`,className:"detail",children:a("只重试临时故障;次数与整轮时间上限任一用尽即停止,凭证错误不重试。")})]})]})}const Xd="max-w-full flex-wrap [&_[data-slot=segmented-item]]:h-7 [&_[data-slot=segmented-item]]:px-3 [&_[data-slot=segmented-item]]:text-[12.5px]";function SNe(e,t){const n=e&&typeof e=="object"?e.proxy:void 0;if(n==null)throw new Error(t("网关电脑未检测到可导入的系统代理;请手动填写,或选择已保存的代理。"));if(typeof n!="object"||Array.isArray(n))throw new Error(t("系统代理信息无效,请手动填写。"));const s=n;if(s.source!=="custom"||!["http","socks5"].includes(String(s.protocol))||typeof s.host!="string"||!s.host.trim()||typeof s.port!="number"||!Number.isInteger(s.port)||s.port<1||s.port>65535||typeof s.username!="string"||typeof s.password!="string")throw new Error(t("系统代理信息无效,请手动填写。"));return{source:"custom",protocol:s.protocol,host:s.host,port:s.port,username:s.username,password:s.password}}const NNe=new Set(["qwenwork-intl","qwenwork-enterprise","claude-subscription","codex-subscription","chatgpt-subscription","copilot-subscription","gemini-subscription"]);function PI(e){return NNe.has(e)}function CNe(e){return PI(e)}function fN(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n=typeof t.warning=="string"?t.warning.trim():"",s=typeof t.importNotice=="string"?t.importNotice.trim():"";if(!(!s&&!n))return{text:s||n,warning:!!n}}function Wt(){return window}function cr(e,t){Wt().wbApp?.toast?.(e,t)}function II(e,t=0){if(typeof e=="string")return e.trim();if(e instanceof Error)return e.message.trim();if(!e||typeof e!="object"||t>3)return"";const n=e;for(const s of["message","error","msg","reason"]){const i=II(n[s],t+1);if(i)return i}return""}function Oa(e){const t=II(e);return a(t||"未知错误")}function V8(e,t=0){if(e&&typeof e=="object"&&t<4){const s=e;for(const i of["status","statusCode","status_code","httpStatus"]){const o=s[i];if((typeof o=="number"||typeof o=="string")&&Number(o)===501)return!0}if(s.code==="not_implemented"||s.code==="auth_methods_unavailable"||s.error&&s.error!==e&&V8(s.error,t+1))return!0}const n=II(e);return n==="该提供商尚未申报动态登录方式,请使用既有登录入口"||/\b501\b|auth\.methods[^\n]*(?:not implemented|no method|未实现|不支持)/i.test(n)}function go(e){if(PI(e))return;const t=Wt().wbApp?.getState?.()?.accounts?.providers;return(Array.isArray(t)?t:Wt().wbProviders?.all?.()||[]).find(s=>s.id===e)}function ANe(e){return(Wt().wbApp?.getState?.()?.accounts?.accounts||[]).filter(n=>(n?.provider||"workbuddy")===e).length}async function _g(e,t,n){const s=Wt().__TAURI_INTERNALS__;if(!s||typeof s.invoke!="function")throw new Error(a("桌面运行时不可用(Tauri 未初始化)"));const i=await s.invoke("api_request",{request:{method:e,path:t,body:n===void 0?null:n}});if(i&&typeof i=="object"){const o=i;if(o.success===!1)throw i;if(o.success===!0&&Object.hasOwn(o,"data"))return o.data}return i}function Qd(e){return _g("POST","/api/accounts",e)}function Zd(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function ENe(e){const t=Zd(e);if(!t)return;const n={};for(const s of["id","name","uid","userId","provider"])typeof t[s]=="string"&&(n[s]=t[s]);return n.id||n.uid||n.userId?n:void 0}function hN(e){let t=Zd(e);if(t?.success===!1)throw e;t?.success===!0&&Object.hasOwn(t,"data")&&(t=Zd(t.data));const n=Zd(t?.payload),s=Zd(t?.session)||Zd(n?.session),i=[t,n,s].filter(f=>!!f);if(i.some(f=>f.canceled===!0||f.state==="canceled"||f.status==="canceled"))return{ok:!1,canceled:!0,silent:i.some(f=>f.silent===!0)};for(const f of i){if(f.error||f.ok===!1||f.success===!1||f.state==="failed"||f.status==="failed"||f.type==="error")throw new Error(Oa(f.error||f));if(f.pending===!0||Zd(f.pending)||f.accepted===!0||f.done===!1||f.state==="pending"||f.status==="pending")throw new Error(a("登录尚未完成,请继续通过共享登录桥等待结果"))}const o=i.map(f=>ENe(f.account)).find(Boolean),l=i.find(f=>typeof f.accountUid=="string"&&!!f.accountUid||typeof f.accountId=="string"&&!!f.accountId||typeof f.nickname=="string"&&!!f.nickname);if(!o&&!l&&i.some(f=>(f.flow||f.authUrl)&&f.done!==!0))throw new Error(a("登录尚未完成,请继续通过共享登录桥等待结果"));if(!o&&!l&&t?.ok!==!0)throw new Error(s&&!Object.keys(s).length?a("登录桥返回了空会话,无法确认账号已添加"):a("登录桥未返回已完成的账号或会话,请重试"));const u=f=>{const m=i.map(g=>g[f]).find(g=>typeof g=="string"&&g.trim());return typeof m=="string"?m:void 0},d=i.map(f=>f.proxySaved).find(f=>typeof f=="boolean");return{ok:!0,canceled:!1,account:o,warning:u("warning"),instructions:u("instructions"),...typeof d=="boolean"?{proxySaved:d}:{},session:l?Object.fromEntries(["accountUid","accountId","nickname","edition","provider"].filter(f=>typeof l[f]=="string").map(f=>[f,l[f]])):void 0}}async function K8(e,t){if(e.canceled||e.proxySaved===!0)return e;const n=e.account?.id||e.session?.accountUid||e.session?.accountId;let s=a("旧网关未确认代理同次保存,已使用兼容接口保存;请在账号设置中确认代理选择。");try{if(typeof n!="string"||!n)throw new Error("Missing account ID");await _g("PATCH",`/api/accounts/${encodeURIComponent(n)}`,{proxy:t??{source:"direct"}})}catch{s=a("账号已添加,但代理选择未确认保存;请在账号设置中重新检查。")}return{...e,warning:[e.warning,s].filter(Boolean).join(` -`)}}async function mN(e,t="cn",n="embedded",s,i){const o=i!==void 0&&i.methodIndex!==void 0;if(PI(e)||o&&!go(e))throw new Error(a("该提供商已不在运行时目录中,请返回列表重新选择"));try{const l=Wt().workbuddyDesktop;let u;if(o&&l?.platform!=="web"){const f=Wt().__TAURI_INTERNALS__;if(!f?.invoke)throw new Error(a("桌面运行时不可用(Tauri 未初始化)"));u=await f.invoke("start_login",{provider:e,edition:t,mode:n,socialRestore:s===!0,options:i})}else{if(!l?.startLogin)throw new Error(a("共享登录桥不可用,请重新打开面板"));u=await l.startLogin(t,n,e,s,i)}const d=hN(u);if(o&&!d.canceled){const f=d.account?.id||d.session?.accountUid||d.session?.accountId,m=d.account?.provider||d.session?.provider;if(!f||m&&m!==e)throw new Error(a("登录桥返回了空会话,无法确认账号已添加"))}return i&&Object.hasOwn(i,"proxy")&&!d.canceled?await K8(d,i.proxy):d}catch(l){const u=Zd(l);if(u?.canceled===!0)return{ok:!1,canceled:!0,silent:u.silent===!0};throw new Error(Oa(l))}}function Jd(e){return e?.name||e?.uid||e?.userId||""}function MI(){Wt().wbAddAccountModal?.close?.()}async function Ll(e,t,n){MI(),await Wt().wbApp?.refresh?.();const s=a("✅ {label}账号已添加{name}",{label:t,name:e?`:${e}`:""}),i=fN(n);cr(i?`${s} -${a(i.text)}`:s,i?.warning?"warn":"ok")}const Dg=new Map;function xo(e){return{defaultValue:Dg.get(e)??"",onChange:t=>{const n=t.currentTarget.value;n?Dg.set(e,n):Dg.delete(e)}}}function ef(e,t){t?Dg.set(e,t):Dg.delete(e);const n=document.getElementById(e);(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&(n.value=t)}function Zo(e){const t=document.getElementById(e);return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t.value.trim():(Dg.get(e)??"").trim()}function _I(e){for(const t of e)ef(t,"")}const Yh={edition:"cn",loginMode:"embedded",socialRestore:!1},q8=8;function DI(e){return e?.success?e.status===void 0||e.status===""||Number(e.status)>=200&&Number(e.status)<300:!1}function LI(e){return e?.error||(e?.status?`HTTP ${String(e.status)}`:a("连接失败"))}function Lg(e){const t=e?.config?.source||e?.source,n=e?.config||null,s=t==="rotate";return{mode:t==="pool"?"pool":s?"rotate":t==="clash"?"clash":t==="custom"?"custom":t==="subscription"?"retired":"none",listenerUid:t==="clash"?String(n?.listenerUid||""):"",proxyId:t==="pool"?String(n?.proxyId||""):"",rotateAll:s?n?.all!==!1:!0,rotateIds:s&&Array.isArray(n?.proxyIds)?n.proxyIds.map(String):[],protocol:n?.protocol==="socks5"?"socks5":"http",host:n?.host||"",port:n?.port===void 0||n?.port===null?"":String(n.port),username:n?.username||"",password:n?.password||"",nonDirect:n?.nonDirect===!0}}function yc(e){if(e.mode==="none")return null;if(e.mode==="retired")throw new Error(a("原代理来源已下线,请选择已保存的代理、自定义地址或直连"));if(e.mode==="clash"){if(!e.listenerUid)throw new Error(a("请先选择 Clash Verge 出口"));return{source:"clash",listenerUid:e.listenerUid}}if(e.mode==="pool"){if(!e.proxyId)throw new Error(a("请先选择已保存的代理"));return{source:"pool",proxyId:e.proxyId}}if(e.mode==="rotate"){if(e.rotateAll)return{source:"rotate",all:!0};if(!e.rotateIds.length)throw new Error(a("轮询至少要选择一条代理(或改选「全部」)"));return{source:"rotate",all:!1,proxyIds:[...e.rotateIds]}}const t=e.host.trim(),n=Number(e.port);if(!t)throw new Error(a("请填写代理主机地址"));if(!Number.isInteger(n)||n<1||n>65535)throw new Error(a("代理端口必须是 1-65535 的整数"));return{source:"custom",protocol:e.protocol==="socks5"?"socks5":"http",host:t,port:n,username:e.username.trim(),password:e.password,nonDirect:e.nonDirect===!0}}function G8(e){return`${e.name||e.uid} :${e.port}${e.profileActive===!1?a("(其他订阅,可能未生效)"):""}${e.enabled===!1?a("(已在 Clash 中禁用)"):""}`}function pN({draft:e,onChange:t,idPrefix:n,allowRotate:s=!1,allowSystemImport:i=!1,onSystemImportBusy:o}){const[l,u]=p.useState(!1),[d,f]=p.useState(!1),[m,g]=p.useState(""),v=p.useRef({draft:e,onChange:t,onSystemImportBusy:o});v.current={draft:e,onChange:t,onSystemImportBusy:o};const b=p.useRef(0),y=p.useRef(!1);p.useEffect(()=>()=>{b.current+=1,y.current&&(y.current=!1,v.current.onSystemImportBusy?.(!1))},[]);const[k,w]=p.useState(null),[S,N]=p.useState(null),[C,T]=p.useState(""),[P,O]=p.useState(null),[A,R]=p.useState(""),M=P?.options||[],_=JSON.stringify(e),[L,$]=p.useState(""),D=U=>t({...e,...U}),F=p.useCallback(()=>{R(""),Promise.resolve(ft().workbuddyDesktop?.getProxies?.()).then(U=>{if(!U?.clash||!Array.isArray(U.clash.options))throw new Error(a("代理列表响应异常"));O(U.clash)}).catch(U=>{O({available:!1,options:[]}),R(dn(U))})},[]);p.useEffect(()=>{e.mode==="clash"&&P===null&&F()},[e.mode,P,F]);const V=p.useCallback((U=!1)=>{T(""),SI({force:U}).then(z=>N(z)).catch(z=>{N([]),T(dn(z))})},[]);p.useEffect(()=>{(e.mode==="pool"||e.mode==="rotate")&&S===null&&V()},[e.mode,S,V]);function q(){return e.rotateAll?(S??[]).filter(U=>U.enabled!==!1).map(U=>U.id):[...e.rotateIds]}async function Q(){if(y.current)return;y.current=!0;const U=++b.current,z=JSON.stringify(v.current.draft);f(!0),g(""),v.current.onSystemImportBusy?.(!0);try{const K=SNe(await _g("GET","/api/proxies/system"),a);if(U!==b.current||JSON.stringify(v.current.draft)!==z)return;v.current.onChange({...v.current.draft,mode:"custom",protocol:K.protocol,host:K.host,port:String(K.port),username:K.username,password:K.password,nonDirect:!1})}catch(K){U===b.current&&g(dn(K))}finally{U===b.current&&(y.current=!1,f(!1),v.current.onSystemImportBusy?.(!1))}}async function X(){if(l)return;if($(_),w(null),e.mode==="rotate"){const z=q();if(!z.length){Ct(a("轮询至少要选择一条代理(或改选「全部」)"),"err");return}const K=z.slice(0,q8);u(!0),w(a("正在连接上游…"));let J=0;const ee=[];for(const Y of K){const se=S?.find(re=>re.id===Y)?.name||Y;try{const re=await ft().workbuddyDesktop?.testProxyPoolItem?.(Y);DI(re)?J+=1:ee.push(`${se}(${LI(re)})`)}catch(re){ee.push(`${se}(${dn(re)})`)}}const H=z.length-K.length,G=a("✅ {ok}/{total} 个出口可用",{ok:J,total:K.length})+(H>0?a("(只测了前 {limit} 个,还有 {rest} 个未测)",{limit:q8,rest:H}):"");w(r.jsxs("span",{className:ee.length?"text-destructive":"text-success",children:[G,ee.length?` ${Yo(ee.join(a(";")))}`:""]})),u(!1);return}if(e.mode==="pool"){if(!e.proxyId){Ct(a("请先选择已保存的代理"),"err");return}u(!0),w(a("正在连接上游…"));try{const z=await ft().workbuddyDesktop?.testProxyPoolItem?.(e.proxyId);w(DI(z)?r.jsxs("span",{className:"text-success",children:[a("✅ 出口可用"),z.ip?a(" 出口 IP {ip}",{ip:Yo(z.ip)}):"",z.durationMs!==void 0&&z.durationMs!==""?` ${Yo(String(z.durationMs))}ms`:""]}):r.jsxs("span",{className:"text-destructive",children:["❌ ",Yo(LI(z))]}))}catch(z){w(r.jsxs("span",{className:"text-destructive",children:["❌ ",Yo(dn(z))]}))}finally{u(!1)}return}let U;try{U=yc(e)}catch(z){Ct(dn(z),"err");return}u(!0),w(a("正在连接上游…"));try{const z=await ft().workbuddyDesktop?.testProxy?.({proxy:U});DI(z)?w(r.jsxs("span",{className:"text-success",children:[a("✅ 出口可用"),z.status!==void 0&&z.status!==""?` HTTP ${Yo(String(z.status))}`:"",z.ip?a(" 出口 IP {ip}",{ip:Yo(z.ip)}):"",z.durationMs!==void 0&&z.durationMs!==""?` ${Yo(String(z.durationMs))}ms`:""]})):w(r.jsxs("span",{className:"text-destructive",children:["❌ ",Yo(LI(z))]}))}catch(z){w(r.jsxs("span",{className:"text-destructive",children:["❌ ",Yo(dn(z))]}))}finally{u(!1)}}return r.jsxs("div",{className:"acct-proxy-form flex flex-col",children:[e.mode==="retired"?r.jsx("p",{className:"mb-3 text-xs text-destructive",children:a("原代理来源已下线,请选择已保存的代理、自定义地址或直连")}):null,r.jsx(en,{"aria-label":a("代理方式"),className:Xd,value:e.mode,onValueChange:U=>D({mode:U}),options:[{value:"none",label:a("无代理(直连)")},{value:"pool",label:a("已保存的代理")},...s?[{value:"rotate",label:a("轮询(换 IP)"),title:a("逐请求轮换出口(换 IP):OpenCode Zen 免费档按 IP 限流,单个 IP 的额度用完会对它一律 429")}]:[],...e.mode==="clash"?[{value:"clash",label:"Clash Verge"}]:[],{value:"custom",label:a("自定义")}]}),i?r.jsxs("div",{className:"mt-3 flex flex-col items-start gap-1.5",children:[r.jsx(B,{variant:"outline",size:"sm",disabled:d,onClick:()=>{Q()},children:a(d?"正在读取…":"填入系统代理")}),r.jsx("p",{className:"detail",children:a("读取网关电脑当前的 HTTPS 系统代理,填入自定义地址;后续系统设置变化不会自动同步。")}),m?r.jsx("p",{className:"text-xs text-destructive",role:"alert",children:m}):null]}):null,e.mode==="pool"?r.jsxs("div",{className:"mt-3",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:`${n}-pool-exit`,children:a("代理")}),r.jsxs(Pt,{value:e.proxyId,disabled:!S?.length,onValueChange:U=>D({proxyId:String(U)}),children:[r.jsx(Mt,{id:`${n}-pool-exit`,className:"min-w-[220px]",children:r.jsx(It,{children:S?.find(U=>U.id===e.proxyId)?Ag(S.find(U=>U.id===e.proxyId)):e.proxyId?a("当前代理不可用,请重新选择"):S===null?a("正在读取…"):S.length?a("请选择代理"):a("还没有保存的代理")})}),r.jsx(_t,{children:(S??[]).map(U=>r.jsx(Ze,{value:U.id,disabled:U.enabled===!1,children:Ag(U)},U.id))})]}),r.jsx(B,{variant:"outline",size:"sm",onClick:()=>V(!0),children:a("重新读取")})]}),r.jsx("div",{className:"detail mt-1.5",children:C?a("读取失败:{error}",{error:C}):S===null?a("正在读取代理列表…"):S.length?a("地址与端口由「网络代理」页管理:那边改一次、测一次,所有引用它的账号一起生效"):a("「网络代理」页还没有出口 —— 去那里添加手动地址或同步 Clash Verge 的端点")})]}):null,e.mode==="rotate"?r.jsxs("div",{className:"mt-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1",children:[r.jsx(jr,{id:`${n}-rotate-all`,checked:e.rotateAll,"aria-label":a("轮询全部代理节点"),onCheckedChange:U=>D({rotateAll:U===!0})}),r.jsx(Ae,{htmlFor:`${n}-rotate-all`,className:"cursor-pointer text-xs text-subtle",children:a("全部代理节点(推荐)")}),r.jsx("span",{className:"detail",children:a("「网络代理」页里每个启用的出口轮流使用;之后新加的出口自动加入")})]}),e.rotateAll?null:r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5",children:[r.jsx(ut,{htmlFor:`${n}-rotate-exits`,children:a("轮询的代理")}),r.jsx(xc,{id:`${n}-rotate-exits`,value:e.rotateIds,onValueChange:U=>D({rotateIds:U.map(String)}),options:(S??[]).map(U=>({value:U.id,label:Ag(U),disabled:U.enabled===!1})),placeholder:a("选择要轮询的代理(可多选)"),"aria-label":a("轮询的代理")}),r.jsx(B,{variant:"outline",size:"sm",onClick:()=>V(!0),children:a("重新读取")})]}),r.jsx("div",{className:"detail mt-1.5",children:C?a("读取失败:{error}",{error:C}):S===null?a("正在读取代理列表…"):S.length?a("每条请求换一个出口(按顺序轮流),上游看到的 IP 因此是变化的;出口的地址与端口由「网络代理」页管理"):a("「网络代理」页还没有出口 —— 去那里添加手动地址或同步 Clash Verge 的端点")})]}):null,e.mode==="clash"?r.jsxs("div",{className:"mt-3",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:`${n}-clash-exit`,children:a("出口")}),r.jsxs(Pt,{value:e.listenerUid,disabled:!M.length,onValueChange:U=>D({listenerUid:String(U)}),children:[r.jsx(Mt,{id:`${n}-clash-exit`,className:"min-w-[220px]",children:r.jsx(It,{children:M.find(U=>U.uid===e.listenerUid)?G8(M.find(U=>U.uid===e.listenerUid)):e.listenerUid?a("当前代理不可用,请重新选择"):a("请选择出口")})}),r.jsx(_t,{children:M.filter(U=>U.uid).map(U=>r.jsx(Ze,{value:String(U.uid),disabled:U.enabled===!1,children:G8(U)},U.uid))})]}),r.jsx(B,{variant:"outline",size:"sm",onClick:F,children:a("重新读取")})]}),r.jsx("p",{className:"detail mt-1.5",children:A?a("读取失败:{error}",{error:A}):P===null?a("正在读取 Clash Verge 配置…"):P.available===!1?a("不可用:{error}",{error:P.error||a("未检测到 Clash Verge 配置")}):a("读取自 {dir};端口由 Clash Verge 管理,这里实时同步",{dir:P.dir||"Clash Verge"})}),r.jsx("p",{className:"detail mt-1.5",children:a("既有 Clash Verge 直接引用继续可用;也可在「网络代理」页同步端点,再改选「已保存的代理」。")})]}):null,e.mode==="custom"?r.jsxs("div",{className:"mt-3",children:[r.jsxs(Lh,{orientation:"horizontal",className:"field-row",children:[r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-protocol`,children:a("协议")}),r.jsxs(Pt,{value:e.protocol,onValueChange:U=>D({protocol:U}),children:[r.jsx(Mt,{id:`${n}-protocol`,className:"min-w-[110px]",children:r.jsx(It,{children:e.protocol==="socks5"?"SOCKS5":"HTTP"})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"http",children:"HTTP"}),r.jsx(Ze,{value:"socks5",children:"SOCKS5"})]})]})]}),r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-host`,className:"ml-2",children:a("主机")}),r.jsx(ze,{id:`${n}-host`,className:"min-w-[140px]",placeholder:"127.0.0.1",value:e.host,onChange:U=>D({host:U.currentTarget.value})})]}),r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-port`,children:a("端口")}),r.jsx(ze,{id:`${n}-port`,type:"number",min:1,max:65535,className:"max-w-[110px]",placeholder:"7890",value:e.port,onChange:U=>D({port:U.currentTarget.value})})]})]}),r.jsxs(Lh,{orientation:"horizontal",className:"field-row mt-2.5",children:[r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-user`,children:a("用户名")}),r.jsx(ze,{id:`${n}-user`,placeholder:a("可选"),autoComplete:"off",value:e.username,onChange:U=>D({username:U.currentTarget.value})})]}),r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-pass`,children:a("密码")}),r.jsx(ze,{id:`${n}-pass`,type:"password",placeholder:a("可选"),autoComplete:"new-password",value:e.password,onChange:U=>D({password:U.currentTarget.value})})]})]}),r.jsxs(Ae,{className:"mt-3 flex cursor-pointer items-center gap-2 text-xs font-normal",children:[r.jsx(jr,{checked:e.nonDirect===!0,onCheckedChange:U=>D({nonDirect:U})}),a("非直连代理")]}),r.jsx("p",{className:"detail mt-1.5",children:a("非直连会先经过网关所在设备的系统代理,再连接到此代理;系统代理不可用时不会改走直连。")})]}):null,r.jsxs(Lh,{orientation:"horizontal",className:"field-row mt-3",children:[r.jsx(B,{variant:"outline",size:"sm",disabled:l,onClick:()=>{X()},children:a(l?"测试中…":"测试出口")}),r.jsx("span",{className:"detail",children:L===_?k:null})]})]})}const $I=[{value:"enable",label:()=>a("启用")},{value:"disable",label:()=>a("禁用")},{value:"refresh",label:()=>a("刷新 Token")},{value:"proxy",label:()=>a("修改代理")},{value:"concurrency",label:()=>a("设置并发上限")},{value:"usageQuery",label:()=>a("查询设置")},{value:"limiters",label:()=>a("限制器")},{value:"remove",label:()=>a("删除")}],zI=[{value:"append",label:()=>a("追加规则(保留原有)")},{value:"replace",label:()=>a("替换全部规则")},{value:"enable",label:()=>a("启用全部规则")},{value:"disable",label:()=>a("停用全部规则")},{value:"clear",label:()=>a("清空全部规则")}];function tf(e){return Ci(e)||e?.id||""}function TNe({ids:e,action:t,onClose:n}){const[s,i]=p.useState($I.some(ee=>ee.value===t)?t:"enable"),[o,l]=p.useState(()=>Lg(null)),[u,d]=p.useState(""),[f,m]=p.useState(()=>({...RI(null),intervalInput:""})),[g,v]=p.useState("append"),[b,y]=p.useState([]),[k,w]=p.useState(""),[S,N]=p.useState(!1),[C,T]=p.useState(""),[P,O]=p.useState(null),A=p.useRef(!1),R=e.map(ee=>_l(ee)).filter(ee=>ee!==null),M=R.filter(Si),_=s==="limiters"&&(g==="append"||g==="replace"),L=_&&b.some(ee=>ee.conditions.some(H=>H.metric!=="tokens"&&H.metric!=="requests")),$=s==="refresh"?R.filter(ee=>!qP(ee)):s==="usageQuery"||L?M:R,D=R.filter(ee=>!$.includes(ee)),F=s==="usageQuery"?M:R,V=F.find(ee=>ee.id===k),q=R.reduce((ee,H)=>Math.max(ee,Number(Ga(tn(H)).concurrencyDefault)||0),0),Q=R.length>0&&R.every(Hke),X=s==="remove"||s==="limiters"&&(g==="replace"||g==="clear"),U=s==="limiters"?g==="append"?a("追加限制规则"):zI.find(ee=>ee.value===g).label():$I.find(ee=>ee.value===s).label();function z(){V&&(s==="usageQuery"?m(RI(V)):y(F8(V)),T(""),Ct(a("已复制到草稿,执行后才会应用到所选账号")))}async function K(){const ee=ft().wbConfirm?.ask;if(s==="remove"&&!await Promise.resolve(ee?.({title:a("删除选中的账号"),html:a("确定删除选中的 {count} 个账号?此操作不可恢复,账号的登录态会一并移除。",{count:e.length}),okText:a("删除"),okClass:"danger"})??!1))return!1;if(s==="disable"||s==="remove"){const H=new Set(e);if(!Ml().filter(Y=>Y.enabled!==!1&&!H.has(Y.id)).length){const Y=a(s==="remove"?"删除":"禁用");return Promise.resolve(ee?.({title:a("全部启用中的账号将被{what}",{what:Y}),html:a("这会{what}所有启用中的账号,转发将不可用。确定继续?",{what:Y}),okText:Y,okClass:s==="remove"?"danger":"primary"})??!1)}}return s==="limiters"&&g==="replace"?Promise.resolve(ee?.({title:a("替换选中账号的限制规则"),html:a("将用草稿中的 {rules} 条规则替换 {count} 个账号的全部限制规则,原有规则不会保留。确定继续?",{rules:b.length,count:$.length})+(D.length?`

${a("以下 {count} 个账号不支持余额查询,本次会跳过:{names}",{count:D.length,names:Yo(D.map(tf).join(a("、")))})}

`:""),okText:a("替换全部规则"),okClass:"danger"})??!1):s==="limiters"&&g==="clear"?Promise.resolve(ee?.({title:a("清空选中账号的限制规则"),html:a("确定清空 {count} 个账号的全部限制规则?余额与 Token 将不再设限;已禁用的账号不会自动启用。",{count:$.length}),okText:a("清空全部规则"),okClass:"danger"})??!1):!0}async function J(){if(A.current)return;if(!e.length){Ct(a("没有选中的账号"),"err");return}if(!$.length){Ct(a("没有适用于本次操作的账号"),"err");return}const ee={action:s,ids:e};try{if(s==="proxy"&&(ee.proxy=yc(o)),s==="concurrency"){const H=Number(u.trim());if(!u.trim()||!Number.isFinite(H)||H<0)throw new Error(a("并发上限必须是 0~{max} 的整数",{max:Su}));ee.maxConcurrent=Math.min(Su,Math.round(H))}if(s==="usageQuery"){const H=U8(f);if("error"in H)throw new Error(H.error);ee.usageQuery=H.value}if(s==="limiters"&&(ee.limiterMode=g,_)){if(!b.length)throw new Error(a("请至少添加一条限制规则;清空请使用清空操作"));if(b.some(H=>H.conditions.some(G=>G.sourceId!==""&&G.sourceId!=="local"&&G.sourceId!=="account")))throw new Error(a("套餐实例不能跨账号复制,请改用通用额度或本地保护条件"));ee.limiterGroups=structuredClone(b)}}catch(H){T(r.jsx("span",{className:"text-destructive",children:dn(H)})),Ct(dn(H),"err");return}A.current=!0,N(!0),T(""),O(null);try{if(!await K())return;let H;if(s==="refresh")H=await xNe(e,O);else{const ie=ft().workbuddyDesktop;if(!ie?.batchAccounts)throw new Error(a("批量操作接口不可用,请重新打开页面"));H=EI(await ie.batchAccounts(ee),ee)}const G=H.ok||[],Y=s==="remove"?(H.removed||[]).length:s==="refresh"?G.length:G.filter(ie=>ie.changes?.length).length,se=s==="remove"?0:G.length-Y,re=H.failed||[],ne=H.skipped||[],de=s==="refresh"?a("刷新 Token 完成:成功 {ok} 个,跳过 {skip} 个,失败 {fail} 个",{ok:Y,skip:ne.length,fail:re.length}):a("{verb}完成:成功 {ok} 个,未变更 {unchanged} 个,跳过 {skip} 个,失败 {fail} 个",{verb:U,ok:Y,unchanged:se,skip:ne.length,fail:re.length});Ct(de,re.length?"err":"ok"),re.length||ne.length?T(r.jsxs("div",{role:"status",className:"space-y-2",children:[r.jsx("p",{children:de}),ne.length?r.jsxs("p",{children:[a("跳过 {count} 个:",{count:ne.length}),ne.map(ie=>`${tf(_l(String(ie.id)))||ie.name||ie.id}(${ie.reason})`).join(a(";"))]}):null,re.length?r.jsxs("p",{className:"text-destructive",children:[a("失败 {count} 个:",{count:re.length}),re.map(ie=>`${tf(_l(String(ie.id)))||ie.id}(${ie.error})`).join(a(";"))]}):null]})):n();try{await Qo(),await Ig()}catch(ie){Ct(a("批量操作已保存,但列表刷新失败:{error}",{error:dn(ie)}),"err")}}catch(H){T(r.jsx("span",{className:"text-destructive",children:dn(H)})),Ct(a("批量操作失败:{error}",{error:dn(H)}),"err")}finally{A.current=!1,N(!1),O(null)}}return r.jsx(at,{open:!0,onOpenChange:ee=>{ee||S||n()},children:r.jsxs(it,{className:"w-[min(900px,calc(100vw-48px))]",showCloseButton:!S,children:[r.jsx(ot,{children:r.jsx(st,{children:a("批量操作 · 已选 {count} 个账号",{count:e.length})})}),r.jsxs(lt,{children:[r.jsxs(C0e,{disabled:S,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0",children:[r.jsxs(as,{children:[r.jsx("h3",{children:a("将作用于以下账号")}),r.jsx("p",{className:"max-h-[84px] overflow-y-auto",children:$.map(tf).join(a("、"))||a("没有适用于本次操作的账号")}),D.length?r.jsx("p",{className:"max-h-[84px] overflow-y-auto",children:s==="refresh"?r.jsxs(r.Fragment,{children:[a("跳过 {count} 个:",{count:D.length}),D.map(ee=>`${tf(ee)}(${qP(ee)})`).join(a(";"))]}):a("以下 {count} 个账号不支持余额查询,本次会跳过:{names}",{count:D.length,names:D.map(tf).join(a("、"))})}):null,s==="refresh"?r.jsx("p",{children:a("逐个刷新所选账号的 Token,未到期也会尝试刷新;不改变启用状态、代理或转发顺序。")}):s!=="remove"?r.jsx("p",{children:a("只修改本次选择的设置,不影响备注、凭证、转发顺序或其他设置。")}):null]}),r.jsxs(as,{children:[r.jsx("h3",{children:a("操作")}),r.jsx(bg,{value:s,onValueChange:ee=>{i(ee),T("")},disabled:S,className:"flex-row flex-wrap items-center gap-5","aria-label":a("批量动作"),children:$I.map(ee=>r.jsxs(Ae,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",children:[r.jsx(Mh,{value:ee.value}),ee.label()]},ee.value))}),s==="proxy"?r.jsx("div",{className:"mt-2.5",children:r.jsx(pN,{draft:o,onChange:l,idPrefix:"batch-proxy",allowRotate:Q})}):null,s==="concurrency"?r.jsxs("div",{className:"mt-2.5",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:"batch-conc-input",children:a("并发上限")}),r.jsx(ze,{id:"batch-conc-input",type:"number",min:0,max:Su,step:1,className:"max-w-[110px]",placeholder:a("并发上限"),value:u,onChange:ee=>d(ee.currentTarget.value)}),r.jsx("span",{className:"detail",children:a("0 = 不限")})]}),r.jsx("p",{className:"detail mt-2.5",children:q>0?a("并发上限 0~{max};CodeArts 等有默认值的家填 0 即按本家默认;达到上限的账号会被跳过、请求转给其他账号",{max:Su}):a("并发上限 0~{max};达到上限的账号会被跳过、请求转给其他账号",{max:Su})})]}):null,s==="limiters"?r.jsxs("div",{className:"mt-2.5",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:"batch-limiter-mode",children:a("规则操作")}),r.jsxs(Pt,{value:g,onValueChange:ee=>{v(ee),T("")},children:[r.jsx(Mt,{id:"batch-limiter-mode",className:"min-w-[220px]",children:r.jsx(It,{children:zI.find(ee=>ee.value===g).label()})}),r.jsx(_t,{children:zI.map(ee=>r.jsx(Ze,{value:ee.value,children:ee.label()},ee.value))})]})]}),r.jsx("p",{className:"detail mt-2.5",children:a(g==="append"?"保留各账号原有规则,只追加下面的规则;完全相同的规则不会重复添加。":g==="replace"?"用下面的规则统一替换各账号的全部规则,执行前会再次确认。":g==="clear"?"删除各账号的全部限制规则,执行前会再次确认。":"仅统一修改现有规则的开关,保留阈值、动作和重置方式;不改变账号的启用状态。")})]}):null,s==="usageQuery"||_?r.jsxs("div",{className:"mt-2.5",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:"batch-settings-source",children:a("复制自账号")}),r.jsxs(Pt,{value:V?.id||"",disabled:!F.length,onValueChange:ee=>w(String(ee)),children:[r.jsx(Mt,{id:"batch-settings-source",className:"min-w-0 flex-1",children:r.jsx(It,{children:V?tf(V):a("选择所选账号作为模板(可选)")})}),r.jsx(_t,{children:F.map(ee=>r.jsx(Ze,{value:ee.id,children:tf(ee)},ee.id))})]}),r.jsx(B,{variant:"outline",size:"sm",disabled:!V,onClick:z,children:a("复制当前设置")})]}),s==="usageQuery"?r.jsxs(r.Fragment,{children:[r.jsx(H8,{draft:f,onChange:m,idPrefix:"batch-usage"}),r.jsx("p",{className:"detail mt-2.5",children:a("统一设置自动查询的开关、间隔和失败重试次数;不会复制或覆盖余额查询凭证。")})]}):r.jsx(B8,{draft:b,onChange:y,allowBalance:M.length>0})]}):null,s==="usageQuery"&&!f.enabled?r.jsx("p",{className:"detail mt-2.5",children:a("关闭自动查询后,余额限制器只能使用上次读数;手动查询仍可用。")}):null,s==="limiters"?r.jsx("p",{className:"detail mt-2.5",children:a("Token 规则按每个账号已有的窗口消耗判定,保存不会清零;停用或清空规则不会自动启用账号。")}):null]})]}),P?r.jsx("p",{role:"status",className:"detail",children:a("刷新 Token:已处理 {completed}/{total} 个,当前账号:{name}",P)}):null,r.jsx("div",{className:"detail min-h-[18px]",children:C})]}),r.jsxs(xt,{children:[r.jsx("div",{className:"mr-auto"}),r.jsx(B,{variant:"outline",disabled:S,onClick:n,children:a("取消")}),r.jsx(B,{variant:X?"destructive":"default",disabled:S||!$.length,onClick:()=>{J()},children:S?a("执行中…"):a("执行({action})",{action:U})})]})]})})}const BI=7*864e5;function ONe(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function W8(e){const t=typeof e=="string"?e.trim():"";return zh(t)?"积分":t}function gN(e){const t=ONe(e);return t?W8(t.unit)||(Object.prototype.hasOwnProperty.call(t,"totalLeft")?"积分":""):""}function Y8(e,t,n=Date.now()){if(["snapshot","record","daily","rolling","unlimited"].some(f=>e[f]===!0))return null;const s=Os(e.remain),i=Os(e.total),o=Os(e.used),l=Os(e.remainingPercent);if(i===-1||s!==null&&s<=0||s===null&&(o!==null&&i!==null&&i>0&&o>=i||l!==null&&l<=0))return null;const u=Os(e.startAt);if(u!==null&&u>n)return null;const d=Os(e.expireAt);return d===null||d<=n||d>n+BI||!Number.isFinite(new Date(d).getTime())?null:{expireAt:d,remain:s,unit:W8(e.unit)||t}}function RNe(e,t=Date.now()){const n=gN(e);return BP(e).map(s=>Y8(s,n,t)).filter(s=>s!==null)}function X8(e){const t=new Map;for(const n of e){let s=t.get(n.unit);s||(s={unit:n.unit,sum:null,count:0,unknownCount:0},t.set(n.unit,s)),s.count++,n.remain===null&&s.unknownCount++,n.remain!==null&&n.unit&&n.unit!=="%"&&(s.sum=(s.sum??0)+n.remain)}return[...t.values()]}function xN(e,t=Date.now()){const n=e.filter(o=>o.expireAt>t&&o.expireAt<=t+BI),s=new Date(t);s.setHours(24,0,0,0);const i=n.filter(o=>o.expireAt0&&e<.01?t("不足 {n}",{n:n(.01)}):n(e)}function Z8(e,t,n){return e.map(s=>{if(!s.unit)return t("{count} 份单位未知",{count:s.count});if(s.unit==="%")return t("{count} 份仅提供比例",{count:s.count});const i=mo(s.unit,t);if(s.sum===null)return t("{unit}余量未知({count} 份)",{unit:i,count:s.count});const o=`${Q8(s.sum,t,n)} ${i}`;return s.unknownCount>0?t("{amount},另 {count} 份余量未知",{amount:o,count:s.unknownCount}):o}).join(";")}function vN(e,t,n,s=""){if(!e.count)return{badge:"",group:"",summary:"",today:"",detail:""};const i=e.amounts.length===1?e.amounts[0]:null,o=zh(s)&&i?.unit==="积分"&&i.unknownCount===0&&i.sum!==null?Q8(i.sum,t,n):null,l=t("7 天内到期 {amount}({count} 份)",{amount:Z8(e.amounts,t,n),count:e.count}),u=e.todayCount>0?t("今天到期 {amount}({count} 份)",{amount:Z8(e.todayAmounts,t,n),count:e.todayCount}):"";return{badge:o===null?t("7天 {count}份",{count:e.count}):t("7天 {n}",{n:o}),group:o===null?t("即将到期 {count} 份",{count:e.count}):t("即将过期 {n}",{n:o}),summary:l,today:u,detail:[l,u].filter(Boolean).join(";")}}function J8(e,t,n=Date.now()){const s=new Date(e),i=e-n;if(!Number.isFinite(s.getTime())||i<=0)return"";const o=new Date(n);if(s.getFullYear()===o.getFullYear()&&s.getMonth()===o.getMonth()&&s.getDate()===o.getDate()){if(i<6e4)return t("不到 1 分钟到期");const d=Math.floor(i/36e5);return d<1?t("{minutes} 分钟后到期",{minutes:Math.floor(i/6e4)}):t("{hours} 小时后到期",{hours:d})}const l=d=>Date.UTC(d.getFullYear(),d.getMonth(),d.getDate()),u=Math.round((l(s)-l(o))/864e5);return u===1?t("明天到期"):t("{days} 天后到期",{days:u})}function $l(e){if(e==null||e==="")return null;const t=Number(e);return Number.isFinite(t)?t:null}function $g(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=s=>String(s).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function eG(e){return mo(e,a)}function PNe(e,t=Date.now()){const n=BP(e),s=gN(e);return n.map(i=>{const o=cq(i,a,Ln);if(o){const F=o.daily?a("每日重置"):null;return{name:o.name,view:o.view,tone:o.tone,percent:null,window:F,title:[o.name,o.view,F].filter(Boolean).join(" · "),spent:!1,snapshot:!0,amount:null,expiry:null}}const l=String(i?.name||"").trim()||a("积分包");if(i?.record===!0){const F=$l(i?.amount),V=String(i?.unit||"").trim(),q=$l(i?.at),Q=$l(i?.expireAt),X=F===null?"—":`${F>0?"+":""}${Ln(F)}`,U=V&&X!=="—"?`${X} ${eG(V)}`:X,z=[];q!==null&&q>0&&z.push($g(q)),Q!==null&&Q>0&&z.push(Q<=t?a("已过期"):a("{time} 到期",{time:$g(Q)}));const K=String(i?.remark||"").trim();return{name:l,view:U,tone:F!==null&&F<0?"muted":"ok",percent:null,window:z.length?z.join(" · "):null,title:[l,U,q!==null&&q>0?ki(q):"",Q!==null&&Q>0?a("到期 {time}",{time:ki(Q)}):"",K].filter(Boolean).join(" · "),spent:!1,amount:F,expiry:null}}const u=String(i?.unit||"").trim(),d=$l(i?.total),f=$l(i?.used),m=$l(i?.remain),g=i?.unlimited===!0,v=$l(i?.grantAt),b=$l(i?.startAt),y=$l(i?.expireAt),k=i?.daily===!0,w=i?.rolling===!0,S=$l(i?.resetAt),N=$l(i?.remainingPercent),C=String(i?.grantReason||"").trim(),T=y!==null&&y>0&&y<=t,P=d!==null&&d>0,O=g?a("不限"):m!==null?P?a("剩 {remaining} / {total}",{remaining:Ln(m),total:Ln(d)}):a("剩 {remaining}",{remaining:Ln(m)}):f!==null?a("已用 {used}",{used:Ln(f)}):N!==null?a("剩余 {percent}%",{percent:Math.round(N)}):"—",A=!g&&u&&O!=="—"?`${O} ${eG(u)}`:O,R=P&&m!==null?Math.max(0,Math.min(100,m/d*100)):N===null?null:Math.max(0,Math.min(100,N)),M=m!==null&&m<=0||m===null&&f!==null&&P&&f>=d,_=!g&&!k&&!w&&(M||T),L=[];v!==null&&v>0?L.push(a("{time} 领取",{time:$g(v)})):b!==null&&b>0&&L.push(a("{time} 生效",{time:$g(b)})),k?L.push(a("每日重置")):w&&S!==null&&S>0?L.push(a("重置 {date}",{date:$g(S)})):y!==null&&y>0&&L.push(T?a("已过期"):a("{time} 到期",{time:$g(y)})),C&&L.push(C);const $=T||m===0?"muted":R!==null&&R<20?"warn":m===null&&f===null&&!g?"muted":"ok",D=[l,A,v!==null&&v>0?a("领取 {time}",{time:ki(v)}):b!==null&&b>0?a("生效 {time}",{time:ki(b)}):"",y!==null&&y>0?T?a("已过期({time})",{time:ki(y)}):a("到期 {time}",{time:ki(y)}):"",k?a("每日重置(额度按周期回满,不是作废)"):"",C,R===null&&m!==null?a("上游未给总量,画不出剩余比例"):"",f!==null&&d!==null?a("已用 {used} / 共 {total}",{used:Ln(f),total:Ln(d)}):""].filter(Boolean).join(" · ");return{name:l,view:A,tone:$,percent:R,window:L.length?L.join(" · "):null,title:D,spent:_,amount:null,expiry:Y8(i,s,t)}})}function FI({row:e,now:t}){return r.jsxs("div",{className:"usage-pop-row",title:e.title,children:[r.jsxs("div",{className:"usage-pop-line",children:[r.jsx("span",{className:"usage-pop-name",children:e.name}),e.expiry?r.jsx("span",{className:"usage-pop-soon-tag",children:J8(e.expiry.expireAt,a,t)}):null,r.jsx("span",{className:`usage-pop-view ${e.tone}`,children:e.view})]}),e.window?r.jsx("div",{className:"usage-pop-window",children:e.window}):null,e.percent!==null?r.jsx(kg,{value:e.percent,variant:e.tone==="ok"?"success":e.tone==="warn"?"warning":"muted",className:"mt-1.5",trackClassName:"h-[3px]","aria-label":a("剩余 {percent}%",{percent:Math.round(e.percent)})}):null]})}function UI({rows:e,now:t,expiryUnit:n,subscriptionLine:s,aggregate:i,variant:o,kind:l,title:u,children:d}){const[f,m]=p.useState(!1),[g,v]=p.useState(!1),b=e.filter(R=>!R.spent),y=e.filter(R=>R.spent),k=e.length>0&&e.every(R=>R.snapshot)?a("余额详情"):a("积分明细"),w=b.filter(R=>R.expiry!==null),S=b.filter(R=>R.expiry===null),N=xN(w.flatMap(R=>R.expiry?[R.expiry]:[]),t),C=vN(N,a,Ln,n),T=o==="pool"?`usage-toggle usage-pool-line ${l}`:`usage-toggle ${l}`,P=p.useRef(null),O=p.useCallback(R=>{P.current=R,R&&(R.scrollTop=0)},[]),A=p.useCallback(()=>P.current??null,[]);return p.useLayoutEffect(()=>{if(!g)return;const R=P.current?.querySelector(".usage-pop-spent .usage-pop-row");R instanceof HTMLElement&&R.scrollIntoView({block:"nearest"})},[g]),r.jsxs(ui,{open:f,onOpenChange:m,children:[r.jsxs(wi,{render:r.jsx(B,{size:"default",variant:"ghost",type:"button",className:T,title:u,"aria-label":k}),children:[o==="pool"?d:r.jsx("span",{className:"val",children:d}),o==="sum"&&C.badge?r.jsx("span",{className:"usage-toggle-soon",children:C.badge}):null,r.jsx("span",{className:"caret","aria-hidden":!0,children:"▾"})]}),r.jsx(di,{align:"center",sideOffset:6,className:"w-[320px]",initialFocus:A,children:r.jsxs("div",{className:"usage-pop-credit",ref:O,tabIndex:-1,children:[s?r.jsx("div",{className:"usage-pop-sub",children:s}):null,i?r.jsxs("div",{className:"usage-pop-total",children:[r.jsx("span",{className:"k",children:i.label}),r.jsxs("span",{className:"v",children:[i.unlimited?a("不限"):Ln(i.remaining),!i.unlimited&&i.unit?r.jsxs(r.Fragment,{children:[" ",r.jsx("small",{children:i.unit})]}):null]})]}):null,r.jsx("div",{className:"usage-pop-group",children:k}),N.count>0?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"usage-pop-soon",children:[r.jsx("span",{children:C.summary}),C.today?r.jsx("span",{children:C.today}):null]}),w.map((R,M)=>r.jsx(FI,{row:R,now:t},`soon-${R.name}-${M}`))]}):null,S.map((R,M)=>r.jsx(FI,{row:R,now:t},`${R.name}-${M}`)),y.length>0?r.jsxs("div",{className:"usage-pop-spent",children:[r.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"usage-pop-spent-head","aria-expanded":g,title:a("展开或收起(默认收起)"),onClick:()=>v(R=>!R),children:[r.jsx("span",{className:"caret","aria-hidden":!0}),r.jsx("span",{children:a("已用完 / 已过期")}),r.jsx("span",{className:"n",children:a("{count} 份",{count:y.length})})]}),g?y.map((R,M)=>r.jsx(FI,{row:R,now:t},`spent-${R.name}-${M}`)):null]}):null]})})]})}const INe={workbuddy:"assets/providers/workbuddy.png","workbuddy-intl":"assets/providers/workbuddy.png",raccoon:"assets/providers/raccoon.png",catpaw:"assets/providers/catpaw.png",autoclaw:"assets/providers/autoclaw.png","autoclaw-intl":"assets/providers/autoclaw.png",qoder:"assets/providers/qoder.png","qoder-intl":"assets/providers/qoder.png",cline:"assets/providers/cline.png","cline-free":"assets/providers/cline.png","cline-pass":"assets/providers/cline.png",accio:"assets/providers/accio.png","accio-cn":"assets/providers/accio.png","accio-intl":"assets/providers/accio.png",zcode:"assets/providers/zcode.png","zcode-intl":"assets/providers/zcode.png",codearts:"assets/providers/codearts.png",trae:"assets/providers/trae.png",loomy:"assets/providers/loomy.png",kuku:"assets/providers/kuku.png",monkeycode:"assets/providers/monkeycode.png","monkeycode-intl":"assets/providers/monkeycode.png",commandcode:"assets/providers/commandcode.png",antigravity:"assets/providers/antigravity.png","agy-cli":"assets/providers/antigravity.png",officeace:"assets/providers/officeace.png",orcaterm:"assets/providers/orcaterm.png",chatglm:"assets/providers/chatglm.png","deepseek-web":"assets/providers/deepseek.png",tabbit:"assets/providers/tabbit.png","tabbit-intl":"assets/providers/tabbit.png",modelscope:"assets/providers/modelscope.png","modelscope-intl":"assets/providers/modelscope.png",atomcode:"assets/providers/atomcode.png",lobsterai:"assets/providers/lobsterai.png",doubaowork:"assets/providers/doubaowork.png",cursor:"assets/providers/cursor.svg",kiro:"assets/providers/kiro.svg",astudio:"assets/providers/astudio.png",quwork:"assets/providers/quwork.png",devin:"assets/providers/devin.svg",factory:"assets/providers/factory.svg",zed:"assets/providers/zed.svg",grok:"assets/providers/grok.svg","minimax-code":"assets/providers/minimax-code.svg","minimax-code-global":"assets/providers/minimax-code.svg",qwenwork:"assets/providers/qwenwork.svg","qwenwork-intl":"assets/providers/qwenwork.svg","qwenwork-enterprise":"assets/providers/qwenwork.svg","kimi-work":"assets/providers/kimi-work.svg",opendesign:"assets/providers/opendesign.svg","nous-portal":"assets/providers/nous-portal.svg","claude-subscription":"assets/providers/anthropic.png","codex-subscription":"assets/providers/openai.png","chatgpt-subscription":"assets/providers/openai.png","copilot-subscription":"assets/providers/copilot.svg","gemini-subscription":"assets/providers/gemini-cli.svg"};function tG(e){return typeof e=="string"&&/^\/plugins\/script-icons\/[a-f0-9]{64}\.(png|jpg|gif|webp|ico|svg)$/.test(e)?e:""}function MNe(e,t){return!t||!e||typeof e!="object"||Array.isArray(e)?"":tG(e[t])}function _Ne(...e){const t=e.filter(d=>typeof d=="string"&&d.length>0),n=JSON.stringify(t),[s,i]=p.useState({key:n,sources:[]}),o=s.key===n?s.sources:[],l=t.find(d=>!o.includes(d))||"",u=p.useCallback(()=>{l&&i(d=>({key:n,sources:[...d.key===n?d.sources:[],l]}))},[n,l]);return{src:l,onError:u}}const nG=[{id:"api-base",method:"",path:"/v1"},{id:"api-chat",method:"POST",path:"/v1/chat/completions"},{id:"api-responses",method:"POST",path:"/v1/responses"},{id:"api-messages",method:"POST",path:"/v1/messages"},{id:"api-count-tokens",method:"POST",path:"/v1/messages/count_tokens"},{id:"api-image-generations",method:"POST",path:"/v1/images/generations"},{id:"api-image-edits",method:"POST",path:"/v1/images/edits"},{id:"api-image-files",method:"GET",path:"/v1/images/files/{id}"},{id:"api-models",method:"GET",path:"/v1/models"},{id:"api-health",method:"GET",path:"/health"}];function rG(){const e=Z("对话协议与上下文预算"),t=Z("图片生成与编辑"),n=Z("模型清单与健康检查"),s={"api-base":{name:"Base URL",group:"",note:Z("OpenAI 兼容客户端使用此地址;Anthropic 官方 SDK 使用下方说明中的网关根地址。")},"api-chat":{name:"OpenAI Chat Completions",group:e,note:Z("多数 OpenAI 兼容客户端的默认协议")},"api-responses":{name:"OpenAI Responses",group:e,note:Z("Codex / 新版 OpenAI SDK;无状态转发,历史由客户端携带。")},"api-messages":{name:"Anthropic Messages",group:e,note:Z("Claude Code / Anthropic SDK;模型与账号池和 OpenAI 入口共用。")},"api-count-tokens":{name:Z("Token 数量估算"),group:e,note:Z("本地上下文预算估算,返回 estimated=true;不是上游精确分词。")},"api-image-generations":{name:Z("图片生成"),group:t,note:Z("文本生成图片;JSON 请求,非流式返回 base64 或下载链接。")},"api-image-edits":{name:Z("图片编辑"),group:t,note:Z("参考图编辑;支持 multipart 文件上传或 JSON 图片引用。")},"api-image-files":{name:Z("临时图片下载"),group:t,note:Z("仅用于响应返回的网关临时链接;{id} 必须替换为实际下载令牌。")},"api-models":{name:Z("模型列表"),group:n,note:Z("不强制鉴权;携带有效 Key 可查看该 Key 获准使用的模型。")},"api-health":{name:Z("健康检查"),group:n,note:Z("不强制鉴权;仅用于确认网关可访问,不保证模型或额度可用。")}};return nG.map(i=>({...i,...s[i.id]}))}const sG=3065;function DNe(){if(jc().workbuddyDesktop?.platform!=="web")return null;const e=typeof window>"u"?"":window.location?.origin;return e&&e!=="null"?e:null}function aG(e,t){return DNe()??(e?`http://127.0.0.1:${e}`:t)}function jc(){return window}function bN(e){return e instanceof Error?e.message:String(e)}function zg(e,t){jc().wbApp?.toast?.(e,t)}let Bg={backend:null,gatewayBase:aG(0,`http://127.0.0.1:${sG}`)};const HI=new Set;function yN(){return Bg}function VI(){return p.useSyncExternalStore(iG,yN).gatewayBase}function iG(e){return HI.add(e),()=>{HI.delete(e)}}function LNe(e){Bg=e;for(const t of HI)t()}function oG(){return Bg.gatewayBase.replace(/^https?:\/\//,"")}function $Ne(){return Bg.backend?.ready===!0}function lG(e){const t=(n,s)=>{const i=document.getElementById(n);i&&(i.textContent=s)};for(const n of nG)t(n.id,`${n.method?`${n.method} `:""}${e}${n.path}`)}let KI=!1;async function Xh(){if(!KI){KI=!0;try{const e=jc().workbuddyDesktop;if(!e)throw new Error("后端桥不可用");const t=await e.getBackendStatus(),n=Number(t?.port)||0,s=yN(),i={backend:t??null,gatewayBase:aG(n,s.gatewayBase)};i.gatewayBase!==s.gatewayBase&&lG(i.gatewayBase),LNe(i),jc().wbApp?.renderTopbarStatus?.()}catch(e){console.warn("读取后端状态失败:",bN(e))}finally{KI=!1}}}function zNe(){lG(Bg.gatewayBase),Xh()}async function cG(e){zg(e||a("正在重启…"));try{await jc().workbuddyDesktop?.restartApp()}catch(t){zg(a("重启失败:{reason}",{reason:bN(t)}),"err")}}const BNe={idle:a("结束占用进程"),querying:a("查询中…"),ending:a("结束中…")};function FNe({container:e}){const{backend:t,gatewayBase:n}=p.useSyncExternalStore(iG,yN),[s,i]=p.useState("idle"),o=t?.failure||null,l=oG(),u=t?.ready;let d="muted",f=a("正在检查… · {port}",{port:l});u===!0?(d="success",f=a("网关运行中 · {port}",{port:l})):o?(d="destructive",f=a("{label} · {port}",{label:o.label||a("网关启动失败"),port:l})):u===!1&&(f=a("网关启动中… · {port}",{port:l}));const m=o?o.message??"":u===!0?a("本地网关正在监听 {url},可直接调用 OpenAI 兼容接口",{url:n}):a("正在确认网关是否已就绪");p.useEffect(()=>{Xh()},[]),p.useEffect(()=>{const v=jc().workbuddyDesktop,b=[v?.onBackendError?.(()=>{Xh()}),v?.onBackendReady?.(()=>{Xh()})];return()=>{for(const y of b)typeof y=="function"&&y()}},[]),p.useEffect(()=>{e.title=m},[e,m]);async function g(){if(s!=="idle")return;const v=jc().workbuddyDesktop;if(v){i("querying");try{const b=await v.getPortOccupant(),y=b?.occupant;if(!y){zg(a("端口 {port} 上没有查到监听进程,请改用「更换端口」",{port:b?.port??""}),"err");return}const k=[a("即将结束以下进程:"),"",a("进程名:{name}",{name:String(y.name)}),a("PID:{pid}",{pid:String(y.pid)}),a("路径:{path}",{path:y.path||a("(未知)")}),"",a("结束它会强制退出该程序未保存的数据。确认继续?")],w=jc().wbConfirm?.ask;if(!w||!await w({title:a("结束占用端口的进程"),text:k.join(` -`),okText:a("结束进程"),okClass:"danger"}))return;i("ending"),(await v.endPortOccupant())?.released?(zg(a("已结束进程 {name}(PID {pid}),端口已释放",{name:String(y.name),pid:String(y.pid)})),await w({title:a("重启程序"),text:a("端口已释放。现在重启程序让网关用这个端口启动?"),okText:a("重启")})?await cG(a("重启中…")):await Xh()):(zg(a("进程已结束,但端口仍被占用,建议改用「更换端口」"),"err"),await Xh())}catch(b){zg(a("结束失败:{reason}",{reason:bN(b)}),"err")}finally{i("idle")}}}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"status-line",children:[r.jsx(Ka,{variant:d,pulse:u===!0}),r.jsx("span",{className:"txt",children:f})]}),o?.conflict?r.jsxs("div",{className:"status-actions",children:[o.canEndOccupant===!0?r.jsx(B,{size:"sm",disabled:s!=="idle",onClick:()=>{g()},children:BNe[s]}):null,r.jsx(B,{size:"sm",onClick:()=>{VNe()},children:a("更换端口")})]}):null]})}let jN=null,uG=null;function qI(){const e=document.getElementById("sidebar-status");uG!==e&&(jN?.unmount(),jN=null,uG=e,e&&(e.replaceChildren(),jN=zn.createRoot(e),jN.render(r.jsx(FNe,{container:e}))))}window.addEventListener("wb:shell-layout",qI);const UNe={idle:a("保存并重启"),checking:a("校验中…"),saving:a("保存中…")};function HNe({status:e,onClose:t}){const n=Number(e?.port)||sG,[s,i]=p.useState(()=>n<65535?String(n+1):String(n-1)),[o,l]=p.useState("idle"),[u,d]=p.useState(""),[f,m]=p.useState(""),g=p.useRef(!0),v=Number(s)||0,b=e?.failure?.message||a("当前端口 {port},网关运行正常。",{port:n});async function y(){if(o!=="idle")return;const k=jc().workbuddyDesktop;if(!k)return;const w=Number(s)||0;if(!w||w<1024||w>65535){m(a("端口需在 1024-65535 之间"));return}l("checking"),m(""),d("");try{const S=await k.checkPort(w);if(!S?.ok){d(S?.message||a("该端口不可用"));return}if(S.same){d(S.message??"");return}if(l("saving"),(await k.changePort(w))?.changed===!1){d(a("与当前端口相同,无需重启"));return}t(),await cG(a("端口已改为 {port},正在重启…",{port:w}))}catch(S){m(bN(S))}finally{l("idle")}}return r.jsx(at,{open:!0,onOpenChange:k=>{k||t()},children:r.jsxs(it,{children:[r.jsx(ot,{children:r.jsx(st,{children:a("更换网关端口")})}),r.jsxs(lt,{children:[r.jsxs(as,{children:[r.jsx("h3",{children:a("当前状态")}),r.jsx("p",{children:b})]}),r.jsxs(as,{children:[r.jsx("h3",{children:a("新端口")}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[r.jsx(Ae,{htmlFor:"port-input",className:"text-[12.5px] whitespace-nowrap text-subtle",children:a("端口号")}),r.jsx(ze,{id:"port-input",type:"number",min:1024,max:65535,step:1,placeholder:a("例如 3066"),autoComplete:"off",className:"max-w-[130px]",value:s,onChange:k=>{i(k.currentTarget.value)},onKeyDown:k=>{k.key==="Enter"&&y()},autoFocus:!0,onFocus:k=>{g.current&&(g.current=!1,k.currentTarget.select())}})]}),u?r.jsx("p",{children:u}):null,r.jsx("p",{children:a("端口需在 1024-65535 之间。1023 及以下是系统保留范围,普通程序无法监听。")})]}),r.jsxs(as,{children:[r.jsx("h3",{children:a("换端口后要改的地方")}),r.jsxs("p",{children:[a("网关地址会变成 "),r.jsx("code",{children:`http://127.0.0.1:${v||"—"}`}),a("。已经把这个地址填进其它工具(Claude Code、Cherry Studio 等)的,需要一并改成新地址,否则那些工具会连不上。")]})]}),r.jsx("p",{className:"min-h-[18px] text-[11.5px] text-muted-foreground",children:f})]}),r.jsxs(xt,{children:[r.jsx("div",{className:"mr-auto"}),r.jsx(B,{variant:"outline",onClick:t,children:a("取消")}),r.jsx(B,{variant:"default",disabled:o!=="idle",onClick:()=>{y()},children:UNe[o]})]})]})})}let vy=null,Fg=null;function dG(){vy&&(vy.unmount(),vy=null),Fg&&(Fg.remove(),Fg=null)}async function VNe(){let e=yN().backend;e||(e=await jc().workbuddyDesktop?.getBackendStatus().catch(()=>null)??null),dG(),Fg=document.createElement("div"),document.body.append(Fg),vy=zn.createRoot(Fg),vy.render(r.jsx(HNe,{status:e,onClose:dG}))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",qI,{once:!0}):qI(),window.wbPortPanel={render:zNe,sync:Xh,portLabel:oG,isReady:$Ne,gatewayBase:()=>Bg.gatewayBase};function KNe(e){let t;const n=()=>{t?.(),t=window.wbApp?.subscribeRefresh?.(e),e()};return window.addEventListener("wb:app-ready",n),n(),()=>{window.removeEventListener("wb:app-ready",n),t?.()}}function Qh(e,t=INe[e]||""){const n=p.useSyncExternalStore(KNe,()=>MNe(window.wbApp?.getState?.()?.providerIcons,e)),s=VI();return _Ne(n?`${s.replace(/\/+$/,"")}${n}`:"",t)}function GI(e){return e==="credit"?{name:a("积分到期时间"),hint:a("按账号最早到期、且还有剩余的积分包比较"),options:[{value:"soon",label:a("最快到期优先")},{value:"late",label:a("最晚到期优先")}]}:e==="balance"?{name:a("可用余额"),hint:a("按账号总可用余额比较,不重复累加积分明细"),options:[{value:"high",label:a("余额大优先")},{value:"low",label:a("余额小优先")}]}:{name:a("账号添加时间"),hint:a("所有提供商都有这个字段"),options:[{value:"new",label:a("最新添加优先")},{value:"old",label:a("最早添加优先")}]}}function WI(e,t){const n=t||Sn().sorting;return n?.balanceSortStates?n.balanceSortStates[e]!==void 0&&n.balanceSortStates[e]!=="unsupported":n?!1:Ga(e).usage||Ml().some(s=>tn(s)===e&&Si(s))}function zl(e,t,n){return t.filter(s=>s.on&&(s.key==="credit"?Eg(e):s.key==="balance"?WI(e,n):!0))}function wN(e){const t=e.filter(n=>n.on).map(n=>GI(n.key).name);return t.length?a("无法拖动:已启用自动消耗规则({rules})。请先在「消耗顺序」中关闭这些规则,再手动调整。",{rules:t.join("、")}):a("自动消耗排序已启用,请先关闭规则再手动调整")}function YI(e){return e.filter(t=>t.on).map(t=>t.key==="credit"?t.dir==="soon"?a("到期 近→远"):a("到期 远→近"):t.key==="balance"?t.dir==="high"?a("余额大优先"):a("余额小优先"):t.dir==="new"?a("添加 新→旧"):a("添加 旧→新")).join(" · ")}function qNe(e,t){if(t==="upgrade")return a("当前网关不支持余额排序,请先更新网关");if(e.key==="balance"){if(t==="unsupported")return a("这一家没有可用余额查询");if(t==="mixed-units")return a("账号余额单位不一致,暂不按余额排序,继续比较其他规则");if(t==="no-data")return a("暂无可比较余额;查到同单位的数值后自动生效,比例与无限额度不参与")}return t==="unsupported"?a("这一家查不到积分到期时间"):t==="no-data"?e.on?a("暂无数据:先查询一次余额,之后会自动按到期排序"):a("暂无数据:先查询一次余额,可按需启用到期排序"):GI(e.key).hint}function GNe({rule:e,priority:t,isLast:n,state:s,busy:i,onChange:o}){const l=GI(e.key),u=s==="unsupported"||s==="upgrade",d=qNe(e,s),f=!u&&!e.on;return r.jsxs("div",{className:Ne("grid items-center gap-2 rounded-sm px-1.5 py-1.5","grid-cols-[16px_15px_minmax(0,1fr)_132px_16px]","hover:bg-nav-hover",f&&"opacity-[.58]"),children:[r.jsx("span",{className:"text-center text-[10.5px] font-bold text-subtle tabular-nums",children:t}),r.jsx(jr,{checked:e.on&&!u,disabled:u||i,"aria-label":l.name,onCheckedChange:m=>o({on:m===!0})}),r.jsxs("span",{className:"flex min-w-0 flex-col gap-px",children:[r.jsx("span",{className:Ne("text-xs font-medium",u&&"text-subtle",f&&"text-subtle"),children:l.name}),r.jsx("span",{className:Ne("text-[10.5px] leading-relaxed",u||s==="mixed-units"?"text-warning":"text-subtle"),title:d,children:d})]}),u?r.jsx("span",{className:"rounded-xs border border-dashed border-border py-1 text-center text-[10.5px] text-subtle",children:a("不可用")}):r.jsxs(Pt,{value:e.dir,disabled:!e.on||i,onValueChange:m=>o({dir:m}),children:[r.jsx(Mt,{className:"h-[26px] w-full text-[11px]","aria-label":a("{name}的方向",{name:l.name}),children:r.jsx(It,{children:l.options.find(m=>m.value===e.dir)?.label||""})}),r.jsx(_t,{children:l.options.map(m=>r.jsx(Ze,{value:m.value,children:m.label},m.value))})]}),r.jsxs("span",{className:"flex flex-col gap-px",children:[r.jsx(B,{size:"default",variant:"ghost",type:"button",disabled:t<=1||i,className:"h-3 w-4 rounded-[3px] text-subtle hover:bg-nav-hover hover:text-foreground disabled:cursor-default disabled:opacity-30",title:a("提高优先级"),"aria-label":a("提高优先级"),onClick:()=>o({__move:"up"}),children:r.jsx("svg",{viewBox:"0 0 24 24",width:"10",height:"10",className:"mx-auto block",children:r.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",d:"m6 14 6-6 6 6"})})}),r.jsx(B,{size:"default",variant:"ghost",type:"button",disabled:n||i,className:"h-3 w-4 rounded-[3px] text-subtle hover:bg-nav-hover hover:text-foreground disabled:cursor-default disabled:opacity-30",title:a("降低优先级"),"aria-label":a("降低优先级"),onClick:()=>o({__move:"down"}),children:r.jsx("svg",{viewBox:"0 0 24 24",width:"10",height:"10",className:"mx-auto block",children:r.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",d:"m6 10 6 6 6-6"})})})]})]})}function fG({title:e,hint:t,children:n}){return r.jsxs("section",{className:"flex flex-col gap-1 border-t border-hairline pt-3.5 first:border-t-0 first:pt-0",children:[r.jsxs("div",{className:"mb-1 flex items-baseline gap-2",children:[r.jsx("h4",{className:"m-0 text-xs font-bold",children:e}),t?r.jsx("span",{className:"text-[10.5px] text-subtle",children:t}):null]}),n]})}function hG({provider:e,onClose:t,accounts:n,sorting:s,routeContext:i}){p.useSyncExternalStore(Hh,()=>Sn().version);const o=Nu(e),l=ft().wbProviders?.labelOf?.(e)||e,{src:u,onError:d}=Qh(e),f=Eg(e),m=Sn().version,g=s||Sn().sorting,v=(n||Ml()).filter(R=>tn(R)===e),b=p.useMemo(()=>v.some(R=>g?g.creditExpiresAt[R.id]!=null:Iq(po(R))!==null),[e,m,n,s,g]),y=f?b?"ready":"no-data":"unsupported",k=g?.balanceSortStates?.[e]||(WI(e,g)?bq(v.map(R=>vq(po(R)))):"unsupported"),w=g&&!g.balanceSortStates?"upgrade":k==="mixedUnits"?"mixed-units":k==="noData"?"no-data":k,S=zl(e,o,g),N=YI(S),C=S.some(R=>R.key==="balance"),T=S.length>0,P=bSe(e),O=Sn().sortBusy,A=(R,M)=>{const _=M.__move,L=o.map(D=>({...D})),$=L.findIndex(D=>D.key===R);if(!($<0)){if(_){const D=_==="up"?$-1:$+1;if(D<0||D>=L.length)return;const[F]=L.splice($,1);L.splice(D,0,F)}else L[$]={...L[$],...M};AI(e,L)}};return r.jsx(at,{open:!0,onOpenChange:R=>{!R&&!O&&t()},children:r.jsxs(it,{className:"w-[min(560px,calc(100vw-48px))]",showCloseButton:!0,children:[r.jsxs(ot,{children:[r.jsx("span",{className:"inline-flex size-[26px] flex-none items-center justify-center",children:u?r.jsx("img",{src:u,alt:"",className:"size-[26px] rounded-md object-contain",loading:"lazy",onError:d}):r.jsx("span",{className:"inline-flex size-[26px] items-center justify-center rounded-md bg-surface-3 text-[13px] font-bold text-muted-foreground",children:String(l||"?").trim().slice(0,1).toUpperCase()})}),r.jsx(st,{children:a("{name} · 分组设置",{name:a(l)})})]}),r.jsxs(lt,{children:[i,r.jsxs(fG,{title:a("消耗顺序"),hint:a("按优先级从上到下比较,勾选的项才参与"),children:[o.map((R,M)=>r.jsx(GNe,{rule:R,priority:M+1,isLast:M===o.length-1,state:R.key==="credit"?y:R.key==="balance"?w:"ready",busy:O,onChange:_=>A(R.key,_)},R.key)),r.jsxs("div",{className:"grid grid-cols-[16px_15px_minmax(0,1fr)] items-center gap-2 px-1.5 py-1.5",children:[r.jsx("span",{className:"text-center text-[10.5px] font-bold text-subtle tabular-nums",children:o.length+1}),r.jsx("span",{className:"inline-flex items-center justify-center text-subtle",title:a("固定兜底,不受开关影响"),children:r.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",children:r.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"4.5",y:"10",width:"15",height:"10.5",rx:"2"}),r.jsx("path",{d:"M8 10V7a4 4 0 0 1 8 0v3"})]})})}),r.jsxs("span",{className:"flex min-w-0 flex-col gap-px",children:[r.jsx("span",{className:"text-xs font-medium",children:a("组内手动顺序")}),r.jsx("span",{className:"text-[10.5px] text-subtle",children:a("上面所有规则都相同时,保持你拖出来的顺序")})]})]}),r.jsxs("p",{className:"m-0 mt-2 rounded-xs bg-surface-inset px-2.5 py-2 text-[10.5px] leading-relaxed text-subtle",children:[a("当前规则:{rules}。",{rules:N||a("仅按手动顺序")})," ",a(T?"已启用自动排序,组内拖动已锁定;关闭全部规则可恢复原手动顺序。":"当前可手动调整组内顺序。")]}),r.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a("上一条规则相同时才比较下一条;想优先按余额消耗,请把可用余额移到第一位。")}),C?r.jsxs("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:[a("使用最近一次成功查询的总余额,随余额刷新调整;查询失败保留上次读数,不额外增加查询频率。")," ",a("只比较同一家、同单位的数值余额;未知、比例和无限额度不作为零余额,有明确余额的账号优先。")]}):null,r.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a("账号页与全局路由共用此消耗顺序,网关按最新余额数据选路,不需要保持页面打开。模型独立顺序会覆盖全局。")}),r.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a("严格按消耗顺序使用账号需选择「顺序优先」;轮询、会话粘性及账号保护仍按原设置生效。")}),r.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a(f?"默认仅开启最快到期优先;可用余额和账号添加时间默认关闭。":"默认保持手动顺序,可按需开启支持的自动排序规则。")})]}),r.jsx(fG,{title:a("更多设置"),hint:a("后续加入"),children:r.jsx("div",{className:"flex flex-wrap gap-1.5",children:[a("默认展开 / 收起"),a("新账号落到组首 / 组尾"),a("组内并发上限"),a("余额低于阈值时的提示"),a("本组代理")].map(R=>r.jsx("span",{className:"inline-flex h-[22px] items-center rounded-pill border border-dashed border-border px-2.5 text-[10.5px] text-subtle",children:R},R))})})]}),r.jsxs(xt,{children:[r.jsx(B,{variant:"ghost",size:"sm",disabled:!P||O,title:a(P?f?"恢复默认:仅开启最快到期优先":"恢复默认:仅按手动顺序":"当前已经是默认规则"),onClick:()=>{AI(e,null)},children:a("恢复默认")}),r.jsx("span",{className:"mr-auto text-[10.5px] text-subtle",children:a(O?"保存中…":"改动即时生效")}),r.jsx(B,{variant:"default",disabled:O,onClick:t,children:a("完成")})]})]})})}function WNe(e,t){if(!e)return a("读取中…");const n=e.error||e.configError;if(n)return a("读取失败:{error}",{error:n});if(e.required===!1)return a("当前模型请求免人机验证");if(t?.state==="verifying")return a("正在验证…");if(t?.state==="error")return a("验证失败:{error}",{error:t.error});if(t?.state==="paused")return a("已暂停验证,需要时请手动重试");const s=`${Number(e.ready)||0} / ${Number(e.target)||3}`;return Number(e.startPlanAccounts)?Number(e.ready)>0?a("验证码令牌:{counts}",{counts:s}):e.needsTokens===!0?a("套餐池请求需要验证,请主动开始验证后重试请求"):a("没有近期套餐池请求,不生成验证码令牌"):a("未启用套餐池账号,不生成验证码令牌")}function YNe({accountId:e,disabled:t=!1,onBusy:n}){const[s,i]=p.useState(null),[o,l]=p.useState(null),[u,d]=p.useState(""),f=p.useRef(null),m=p.useRef(!0),g=p.useCallback(async()=>{const k=ft().workbuddyDesktop;try{const w=k?.zcodeCaptchaStats?await k.zcodeCaptchaStats():{error:a("验证码令牌池接口不可用")};m.current&&(i(w||null),ft().wbZcodeCaptchaPool?.status&&l(ft().wbZcodeCaptchaPool?.status?.()||null))}catch(w){m.current&&i({error:dn(w)})}},[]);p.useEffect(()=>{m.current=!0,g();const k=window.setInterval(()=>{g()},15e3),w=()=>{l(ft().wbZcodeCaptchaPool?.status?.()||null),g()};return window.addEventListener("zcode-captcha-status",w),()=>{m.current=!1,f.current?.abort(),n?.(!1),window.clearInterval(k),window.removeEventListener("zcode-captcha-status",w)}},[g,n]);async function v(){const k=ft().wbZcodeCaptchaPool;if(f.current||!k?.verify)return;const w=new AbortController;f.current=w,d("preparing"),n?.(!0);try{await k.verify(e,w.signal,S=>{m.current&&d(S)})}catch(S){m.current&&!w.signal.aborted&&S?.name!=="CaptchaCancelledError"&&l({state:"error",error:dn(S)})}finally{f.current===w&&(f.current=null),m.current&&(d(""),n?.(!1),g())}}const b=!!u,y=!!(s?.error||s?.configError||o?.state==="error");return r.jsxs("div",{className:"flex flex-wrap items-center gap-2",title:a("后台只读取状态,不会自动弹出验证码;验证结果一次性使用,短时间内过期。"),children:[r.jsx(Ka,{variant:y?"destructive":s?.required===!1?"success":"warning"}),r.jsx("span",{className:Ne("text-[12.5px]",y&&"text-destructive"),children:WNe(s,o)}),r.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[s?.required!==!1&&Number(s?.startPlanAccounts)>0?r.jsx(B,{variant:"outline",size:"xs",disabled:t||b||!!(s?.error||s?.configError)||!ft().wbZcodeCaptchaPool?.verify,onClick:()=>{v()},children:a(b?"正在验证…":"开始验证")}):null,b?r.jsx(B,{variant:"outline",size:"xs",disabled:u==="submitting",onClick:()=>f.current?.abort(),children:a("取消验证")}):null,r.jsx(B,{variant:"ghost",size:"xs",disabled:b||t,onClick:()=>{g()},children:a("刷新")})]})]})}function XNe({plan:e,hasJwt:t,onChange:n}){return r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5",children:[r.jsx(ut,{htmlFor:"account-plan-channel",children:a("使用套餐")}),r.jsxs(Pt,{value:e,onValueChange:s=>n(String(s)),children:[r.jsx(Mt,{id:"account-plan-channel",className:"min-w-[220px]",children:r.jsx(It,{children:sSe(e)})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:Pq,children:a("编码套餐(Coding Plan)— 走开放平台端点,消耗开放平台的额度(订阅套餐 / 资源包 / 充值余额)")}),r.jsx(Ze,{value:Uh,children:a("套餐池(Start Plan)— 走 zcode.z.ai 端点,消耗 ZCode 套餐池的额度(新用户体验额度 / 活动领取)")})]})]}),e===Uh&&!t?r.jsx("span",{className:"detail text-destructive",children:a("该账号没有套餐登录态(jwt),套餐池通道会失败:请重新登录该账号")}):null,e===Uh?r.jsx("p",{className:"detail",children:a("需要人机验证时,在该账号的「套餐明细」中主动开始验证。")}):null]})}const QNe={sub2api:{label:"Sub2API",endpoint:"{base}/v1/usage",note:a("用这条账号的 API Key 查询,不需要额外配置。"),fields:[]},new_api:{label:"NewAPI",endpoint:"{base}/api/user/self + /api/status",note:a("用 NewAPI 站点的个人访问令牌查询账户余额(不是这条账号的上游 API Key)。令牌在站点的「个人设置」里生成,只有旧版 / 定制站点才需要额外填用户 ID。"),fields:[{key:"accessToken",label:a("NewAPI 个人访问令牌"),secret:!0,placeholder:a("在 NewAPI 站点「个人设置」里生成的访问令牌"),hint:a("必填;留空 = 不修改,清除用右边的按钮")},{key:"userId",label:a("NewAPI 用户 ID"),placeholder:a("旧版 / 定制站点才需要,新版可留空"),hint:a("可留空:新版请求头只认令牌;旧版会把用户 ID 放进 New-Api-User 头")}]},deepseek:{label:"DeepSeek",endpoint:"{base}/user/balance",note:a("用这条账号的 API Key 查询,不需要额外配置。"),fields:[]},opencode:{label:"OpenCode Go",endpoint:"{base}/v1/usage",note:a("用这条账号的 API Key 查询订阅用量,不需要额外配置;读数展开成 5 小时 / 每周 / 每月三个窗口。"),fields:[]},sensenova:{label:"商汤日日新",endpoint:"platform.sensenova.cn 控制台",note:a("用商汤日日新控制台的账号密码查询(与推理用的 API Key 不是同一套)。网关会自动换取登录票并缓存,过期后自动重登,不需要手动维护。"),fields:[{key:"username",label:a("账号"),placeholder:a("商汤日日新控制台的登录账号"),hint:a("必填")},{key:"password",label:a("密码"),secret:!0,placeholder:a("商汤日日新控制台的登录密码"),hint:a("留空 = 不修改,清除用右边的按钮")}]},zhipu:{label:"智谱",endpoint:"bigmodel.cn 控制台",note:a("用 bigmodel.cn 控制台的访问令牌查询账户余额(人民币元)。令牌是登录后浏览器 Cookie `bigmodel_token_production` 的值:开发者工具 → 应用(Application)→ Cookie 里复制。"),fields:[{key:"token",label:a("访问令牌"),secret:!0,placeholder:a("bigmodel_token_production 的值"),hint:a("必填;留空 = 不修改,清除用右边的按钮")}]},zhipu_zai:{label:"智谱(z.ai 国际)",endpoint:"api.z.ai 控制台",note:a("用这条账号的 API Key 生成签名后查询账户余额(美元),不需要额外配置。要求 API Key 是 z.ai 的「id.secret」形态(控制台生成的 Key 就是)。"),fields:[]}};function by(e){return e?QNe[e]??null:null}function ZNe(e,t){return t.secret?t.key==="accessToken"?e?.hasAccessToken===!0:t.key==="password"?e?.hasPassword===!0:t.key==="token"?e?.hasToken===!0:!1:!1}function JNe(e){const t=String(e?.scheme||"");return t==="new_api"?e?.hasAccessToken===!0:t==="sensenova"?String(e?.username||"").trim()!==""&&e?.hasPassword===!0:t==="zhipu"?e?.hasToken===!0:!0}function eCe(e){return{userId:String(e?.userId||""),username:String(e?.username||""),accessToken:"",password:"",token:""}}function tCe(e,t){const n=by(e);if(!n||!n.fields.length)return null;const s={};for(const i of n.fields){const o=String(t[i.key]??"").trim();if(i.secret){o&&(s[i.key]=o);continue}s[i.key]=o}return Object.keys(s).length?s:null}function nCe({field:e,value:t,configured:n,onValue:s,onClear:i,clearBusy:o,idPrefix:l}){const u=`${l}-${e.key}`;return r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5",children:[r.jsx(ut,{htmlFor:u,children:e.label}),r.jsx(ze,{id:u,className:"min-w-[220px]",type:e.secret?"password":"text",autoComplete:e.secret?"new-password":"off",placeholder:n?a("已配置,留空则不修改"):e.placeholder,title:e.hint,value:t,onChange:d=>s(d.currentTarget.value)}),n&&i?r.jsx(B,{variant:"outline",size:"sm",disabled:o===!0,onClick:i,title:a("清除已配置的 {label}",{label:e.label}),children:a("清除")}):null]})}function rCe({spec:e,values:t,configured:n,onValue:s,onClear:i,clearBusy:o,idPrefix:l}){return r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"detail mt-2.5",children:[a("余额查询方案:{label}",{label:e.label}),r.jsx("span",{className:"ml-1 text-subtle",children:e.endpoint})," — ",e.note]}),e.fields.map(u=>r.jsx(nCe,{field:u,idPrefix:l,value:t[u.key]||"",configured:n[u.key]===!0,onValue:d=>s(u.key,d),onClear:i?()=>i(u.key):void 0,clearBusy:o},u.key))]})}function pr({value:e,onValueChange:t,options:n,placeholder:s="",displayValue:i,searchPlaceholder:o=Z("搜索…"),emptyHint:l=Z("没有匹配的选项"),disabled:u,className:d,id:f,title:m,searchable:g=!0,...v}){const[b,y]=p.useState(""),k=n.find(S=>S.value===e)??null,w=i??k?.label??(e||s);return g?r.jsxs(YV,{items:n,value:k,disabled:u,autoHighlight:!0,inputValue:b,onInputValueChange:y,onOpenChange:()=>y(""),itemToStringLabel:S=>S.label,itemToStringValue:S=>S.value,isItemEqualToValue:(S,N)=>S.value===N.value,filter:(S,N)=>`${S.label} ${S.value} ${S.searchText||""}`.toLowerCase().includes(N.trim().toLowerCase()),onValueChange:S=>{S&&!S.disabled&&t(S.value)},children:[r.jsx(QV,{id:f,className:d,title:m??w,"aria-label":v["aria-label"],children:r.jsx(XV,{children:w})}),r.jsxs(ZV,{children:[r.jsx("div",{className:"shrink-0 border-b border-hairline p-2",children:r.jsx(JV,{placeholder:o,"aria-label":o,autoComplete:"off"})}),r.jsx(nK,{children:l}),r.jsx(eK,{children:S=>r.jsx(tK,{value:S,disabled:S.disabled,title:S.label,children:S.label},S.value)})]})]}):r.jsxs(Pt,{value:e,disabled:u,onValueChange:S=>{typeof S=="string"&&t(S)},children:[r.jsx(Mt,{id:f,className:d,title:m??w,"aria-label":v["aria-label"],children:r.jsx(It,{children:w})}),r.jsx(_t,{children:n.map(S=>r.jsx(Ze,{value:S.value,disabled:S.disabled,children:S.label},S.value))})]})}let Au=null,yy=null;function sCe(){if(Au)return Promise.resolve(Au);if(yy)return yy;const t=window.workbuddyDesktop?.getClientIdentification?.();return t?(yy=t.then(n=>{const s=[];for(const i of n?.builtins||[]){const o=typeof i.id=="string"?i.id:"",l=typeof i.name=="string"?i.name:"",u=typeof i.ua=="string"?i.ua.trim():"";o&&l&&u&&s.push({id:o,name:l,ua:u})}return Au=s,s}).catch(()=>(Au=[],Au)).finally(()=>{yy=null}),yy):(Au=[],Promise.resolve(Au))}function jy(){const[e,t]=p.useState(()=>Au||[]);return p.useEffect(()=>{if(Au)return;let n=!0;return sCe().then(s=>{n&&t(s)}),()=>{n=!1}},[]),e}function wy(e){const t=window,n=t.wbProviders?.all?.()||t.wbApp?.getState?.()?.accounts?.providers;return Array.isArray(n)?n.find(i=>i?.id===e)?.userAgentOverridable!==!1:!0}async function mG(e,t,n){const s=n.trim();if(!s||!e||!wy(t))return;const i=window.__TAURI_INTERNALS__;if(i?.invoke)try{await i.invoke("api_request",{request:{method:"PATCH",path:`/api/accounts/${encodeURIComponent(e)}`,body:{userAgent:s}}})}catch{}}function pG(e){const t=e,n=t?.account?.id;if(typeof n=="string"&&n)return n;for(const s of["accountId","accountUid"]){const i=t?.session?.[s];if(typeof i=="string"&&i)return i}}function Ug({id:e,value:t,onChange:n,presets:s,disabled:i,className:o}){const l=s.find(u=>u.ua===t);return r.jsxs("div",{className:`flex min-w-0 items-center gap-2 ${o||""}`,children:[r.jsx(ze,{id:e,className:"min-w-0 flex-1",type:"text",maxLength:1024,spellCheck:!1,autoComplete:"off",disabled:i,placeholder:a("留空使用该提供商默认值"),value:t,onChange:u=>n(u.currentTarget.value)}),r.jsx(pr,{value:l?.id??"",disabled:i||!s.length,className:"w-[172px] shrink-0","aria-label":a("选择预置客户端"),displayValue:l?.name||a("选择预置客户端"),options:[{value:"",label:a("不使用预置")},...s.map(u=>({value:u.id,label:u.name,searchText:u.ua}))],onValueChange:u=>{if(!u){n("");return}const d=s.find(f=>f.id===u);d&&n(d.ua)}})]})}function ha({name:e,size:t=16}){return r.jsx("span",{className:"acct-dlg-icon","aria-hidden":"true",dangerouslySetInnerHTML:{__html:ft().wbIcons?.icon?.(e,t)||""}})}function wc({title:e,action:t,children:n}){return r.jsxs("section",{className:"acct-dlg-group-wrap",children:[r.jsxs("div",{className:"acct-dlg-group-label",children:[r.jsx("span",{children:e}),t?r.jsx("span",{className:"acct-dlg-label-action",children:t}):null]}),r.jsx("div",{className:"acct-dlg-group",children:n})]})}function aCe({configured:e,value:t,onChange:n,onClear:s,clearBusy:i}){return r.jsx(wc,{title:a("余额查询凭证"),action:r.jsx(Ee,{shape:"tag",variant:e?"success":"secondary",children:a(e?"已配置":"未配置")}),children:r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsxs("div",{className:"acct-dlg-field-head",children:[r.jsx(ut,{htmlFor:"account-balance-token-input",children:a("余额查询凭证")}),e?r.jsx(B,{variant:"ghost",size:"xs",disabled:i,onClick:s,className:"acct-dlg-clear",children:a("清除")}):null]}),r.jsx(ze,{id:"account-balance-token-input",type:"password",autoComplete:"new-password",placeholder:a(e?"已配置,留空则不修改":"一般不用填"),value:t,onChange:o=>n(o.currentTarget.value)}),r.jsx(wr,{children:a("积分查询已复用转发用的登录凭证,这里通常留空即可。只有旧版本填过、或从旧代理导入过凭证时才有值")})]})})}function iCe({hasApiKey:e,noAuth:t,value:n,onValue:s,onToggleNoAuth:i,onClear:o,clearBusy:l}){const[u,d]=p.useState(!1),f=!!n.trim();return r.jsxs(wc,{title:a("账号凭证"),action:r.jsx(Ee,{shape:"tag",variant:t||f?"secondary":e?"success":"warning",children:a(t?"无需鉴权":f?"新密钥待保存":e?"已配置":"未配置凭证")}),children:[r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{children:a("鉴权方式")}),r.jsxs(bg,{value:t?"none":"key",disabled:l,"aria-label":a("鉴权方式"),className:"acct-dlg-choice-grid",onValueChange:m=>i(m==="none"),children:[r.jsxs(Ae,{className:"acct-dlg-choice","data-selected":!t||void 0,children:[r.jsx(Mh,{value:"key"}),r.jsxs("span",{children:[r.jsx("strong",{children:"API Key"}),r.jsx("small",{children:a("使用密钥访问上游")})]})]}),r.jsxs(Ae,{className:"acct-dlg-choice","data-selected":t||void 0,children:[r.jsx(Mh,{value:"none"}),r.jsxs("span",{children:[r.jsx("strong",{children:a("无需鉴权")}),r.jsx("small",{children:a("本地服务或无需凭证的上游")})]})]})]})]}),r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsxs("div",{className:"acct-dlg-field-head",children:[r.jsx(ut,{htmlFor:"account-api-key-input",children:"API Key"}),e&&!t?r.jsx(B,{variant:"ghost",size:"xs",disabled:l,onClick:o,className:"acct-dlg-clear",children:a("清除已存密钥")}):null]}),r.jsxs(zs,{"data-disabled":t||l,children:[r.jsx(Bs,{id:"account-api-key-input",type:u&&!t?"text":"password",autoComplete:"new-password",spellCheck:!1,disabled:t||l,placeholder:e?a("留空保留当前密钥,输入新密钥以替换"):"sk-…",value:n,onChange:m=>s(m.currentTarget.value)}),r.jsx(As,{align:"inline-end",children:r.jsx(Db,{size:"icon-xs",disabled:t||l,"aria-pressed":u,"aria-label":a(u?"隐藏新输入的密钥":"显示新输入的密钥"),onClick:()=>d(m=>!m),children:r.jsx(ha,{name:u?"eyeOff":"eye"})})})]}),r.jsx(wr,{children:a("原密钥不会回显;更换密钥不会改变账号 ID。")})]}),r.jsxs("div",{className:`acct-dlg-inline-note${t||!e&&!f?" warning":""}`,children:[r.jsx(ha,{name:t||!e?"info":"shield",size:14}),r.jsx("span",{children:a(t?"保存后将移除密钥,转发与拉取模型都不发送鉴权头。请确认上游确实无需凭证。":e||f?"留空不修改,替换后点击「保存更改」生效。":"当前没有凭证,转发时会跳过此账号。请填写密钥或选择「无需鉴权」。")})]})]})}const oCe=64;function lCe({provider:e,name:t,protocol:n,baseUrl:s,accountBaseUrl:i,count:o,emulation:l,onName:u,onProtocol:d,onBaseUrl:f,onEmulation:m,onRemove:g,onModels:v,onClearAccountBaseUrl:b,disabled:y}){const[k,w]=p.useState(l==="opencode"),S=ft().wbProviders?.PROTOCOL_OPTIONS||[{value:"chat_completions",label:"OpenAI - Chat Completions"},{value:"responses",label:"OpenAI - Responses"},{value:"anthropic",label:"Anthropic - Messages"}],N=S.find(A=>A.value===n)?.label||n,C=n==="anthropic"?"/v1/messages":n==="responses"?"/responses":"/chat/completions",T=i.trim(),P=T||s.trim(),O=P?`${P.replace(/\/+$/,"")}${C}`:"";return r.jsxs(r.Fragment,{children:[r.jsxs(Fe,{variant:"warning",className:"acct-dlg-scope-notice",role:"note",children:[r.jsx(ha,{name:"accounts"}),r.jsxs("div",{children:[r.jsx("strong",{children:a("正在编辑提供商共用配置")}),r.jsx("p",{children:a("「{name}」名下 {count} 个账号共用;修改协议或地址可能中断正在进行的请求。",{name:e.name||e.id,count:o})})]})]}),r.jsxs(wc,{title:a("连接参数"),children:[r.jsxs("div",{className:"acct-dlg-field-grid",children:[r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{htmlFor:"account-provider-name",children:a("提供商名称")}),r.jsx(ze,{id:"account-provider-name",maxLength:oCe,disabled:y,value:t,onChange:A=>u(A.currentTarget.value)})]}),r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{htmlFor:"account-provider-protocol",children:a("协议")}),r.jsxs(Pt,{value:n,disabled:y,onValueChange:A=>d(String(A)),children:[r.jsx(Mt,{id:"account-provider-protocol",children:r.jsx(It,{children:N})}),r.jsx(_t,{children:S.map(A=>r.jsx(Ze,{value:A.value,children:A.label},A.value))})]})]}),r.jsxs(ct,{className:"acct-dlg-field acct-dlg-field-full",children:[r.jsxs("div",{className:"acct-dlg-field-head",children:[r.jsx(ut,{htmlFor:"account-provider-baseurl",children:"Base URL"}),T?r.jsx(B,{variant:"ghost",size:"xs",disabled:y,className:"acct-dlg-clear",onClick:b,children:a("改回跟随提供商")}):null]}),r.jsx(ze,{id:"account-provider-baseurl",className:"mono",disabled:y,spellCheck:!1,placeholder:a("OpenAI 兼容填到 /v1;Anthropic 填根地址"),value:s,onChange:A=>f(A.currentTarget.value)}),r.jsx(wr,{children:a("填写接口基址,无需追加 {path}。",{path:C})}),T?r.jsxs("div",{className:"acct-dlg-inline-note warning",children:[r.jsx(ha,{name:"info",size:14}),r.jsx("span",{children:a("这个账号单独存了一份地址:{url},转发时优先用它。上面改的是提供商共用地址,不会覆盖它。",{url:T})})]}):null]})]}),O?r.jsxs("div",{className:"acct-dlg-endpoint",children:[r.jsx("span",{children:a("请求端点")}),r.jsx("code",{children:O})]}):null,r.jsxs("div",{className:"acct-dlg-model-link",children:[r.jsx("span",{children:a("模型清单与映射在「模型管理」中维护。")}),r.jsxs(B,{variant:"link",size:"xs",disabled:y,onClick:v,children:[a("模型管理"),r.jsx(ha,{name:"caretRight",size:12})]})]})]}),r.jsx("div",{className:"acct-dlg-group-label",children:a("高级兼容")}),r.jsxs(gs,{open:k,onOpenChange:w,className:"acct-dlg-advanced",children:[r.jsxs(xs,{disabled:y,className:"acct-dlg-advanced-trigger",children:[r.jsx(ha,{name:"sliders"}),r.jsx("span",{children:a("高级兼容")}),r.jsx("small",{children:a(l==="opencode"?"已开启":"默认关闭")}),r.jsx(ha,{name:"caretRight",size:13})]}),r.jsxs(vs,{className:"acct-dlg-advanced-content",children:[r.jsxs(ct,{className:"acct-dlg-toggle-field",children:[r.jsxs("div",{children:[r.jsx(ut,{htmlFor:"account-provider-emulation",children:a("模拟 OpenCode 官方客户端")}),r.jsx(wr,{children:a("仅用于 OpenCode Zen 这类上游,普通提供商请保持关闭。")})]}),r.jsx(St,{id:"account-provider-emulation",checked:l==="opencode",disabled:y,onCheckedChange:A=>m(A?"opencode":"")})]}),r.jsx("p",{className:"detail acct-dlg-advanced-note",children:a("开启后会改写请求体,补齐会话头与占位工具;未填密钥时使用匿名凭证 public。")})]})]}),r.jsxs("div",{className:"acct-dlg-danger",children:[r.jsxs("div",{children:[r.jsx("h3",{children:a("删除提供商")}),r.jsx("p",{children:a("将同时删除名下 {count} 个账号,无法恢复。",{count:o})})]}),r.jsx(B,{variant:"outline",size:"sm",disabled:y,onClick:g,className:"acct-dlg-delete",children:a("删除提供商")})]})]})}function cCe(e,t){const n=tn(e);return t.filter(s=>s.id!==e.id&&tn(s)===n)}function uCe(e){return Ci(e)||e?.id||""}function gG({id:e,onClose:t,initialAccount:n,initialPane:s="basic",routeContext:i}){const[o,l]=p.useState(()=>n||_l(e)),[u,d]=p.useState(o?.enabled!==!1),[f,m]=p.useState(o?.allowRouteSkip!==!1),[g,v]=p.useState(o?.name||""),[b,y]=p.useState(o?.userAgent||""),k=jy(),w=wy(tn(o||{})),[S,N]=p.useState(()=>Lg(o?.proxy)),[C,T]=p.useState(""),[P,O]=p.useState(()=>nI(o)),[A,R]=p.useState(!1),[M,_]=p.useState(""),[L,$]=p.useState(null),[D,F]=p.useState(""),[V,q]=p.useState("chat_completions"),[Q,X]=p.useState(""),[U,z]=p.useState(""),[K,J]=p.useState(""),[ee,H]=p.useState(o?.noAuth===!0),[G,Y]=p.useState(()=>RI(o)),[se,re]=p.useState(()=>eCe(o?.balanceQuery)),[ne,de]=p.useState(()=>F8(o)),[ie,oe]=p.useState(s),[je,te]=p.useState(()=>String(Number(o?.maxConcurrent)||0)),[le,he]=p.useState(!1),ce=p.useRef(!1),ye=p.useRef(null),fe=p.useRef({}),Le=p.useRef({enabled:u,allowRouteSkip:f,name:g,userAgent:b,proxyDraft:S,planChannel:P,usageDraft:G,balanceQueryDraft:se,limiterDraft:ne,concDraft:je,noAuthDraft:ee}),pe=tn(o).startsWith("custom-")?a("凭证设置"):a("凭证与套餐"),xe={basic:{title:a("基本信息"),description:a("设置账号名称、启用状态与转发行为。"),icon:"sliders"},credential:{title:pe,description:a("管理当前账号的凭证与可用套餐。"),icon:"key"},query:{title:a("查询设置"),description:a("配置余额查询凭证、自动刷新间隔与失败重试。"),icon:"refresh"},limiter:{title:a("限制器"),description:a("用明确的规则保护当前账号的额度。"),icon:"shield"},network:{title:a("网络"),description:a("设置当前账号访问上游的出网方式。"),icon:"proxies"},provider:{title:a("连接设置"),description:a("统一管理提供商的协议、地址与兼容选项。"),icon:"agent"}},Se=xe[ie];p.useLayoutEffect(()=>{ye.current&&(ye.current.scrollTop=fe.current[ie]||0)},[ie]);function ge(ke){ye.current&&(fe.current[ie]=ye.current.scrollTop),oe(ke)}if(p.useEffect(()=>{let ke=!0;$(null);const Xe=n||_l(e);return Xe?(Promise.resolve(ft().wbCustomProvidersUi?.find?.(tn(Xe))).then(Qe=>{!ke||!Qe||($(Qe),F(Qe.name||""),q(Qe.protocol||"chat_completions"),X(Qe.baseUrl||""),z(typeof Qe.clientEmulation=="string"?Qe.clientEmulation:""))}).catch(()=>{}),()=>{ke=!1}):()=>{ke=!1}},[e]),!o)return r.jsx(at,{open:!0,onOpenChange:ke=>{ke||t()},children:r.jsxs(it,{children:[r.jsx(ot,{children:r.jsx(st,{children:a("账号设置")})}),r.jsx(lt,{children:r.jsx("p",{className:"detail",children:a("账号不存在,请刷新后重试。")})}),r.jsxs(xt,{children:[r.jsx("div",{className:"mr-auto"}),r.jsx(B,{variant:"outline",onClick:t,children:a("关闭")})]})]})});const ue=o,be=cCe(ue,Ml()),ve=tn(ue)==="catpaw",De=tn(ue).startsWith("custom-"),Ie=wq(L,ue.baseUrl)||S.mode==="rotate",We=by(ue.balanceQuery?.scheme),nt={};for(const ke of We?.fields??[])nt[ke.key]=ZNe(ue.balanceQuery,ke);const kt=!!(We&&We.fields.length)&&!JNe(ue.balanceQuery),Je=be.length+1,on=Le.current,nn=(ke,Xe)=>JSON.stringify(ke)===JSON.stringify(Xe),On={basic:u!==on.enabled||f!==on.allowRouteSkip||(g.trim()||on.name)!==on.name||b.trim()!==on.userAgent||je!==on.concDraft,credential:!!(C.trim()||K.trim())||ee!==on.noAuthDraft||P!==on.planChannel,query:!nn(G,on.usageDraft)||!nn(se,on.balanceQueryDraft),limiter:!nn(ne,on.limiterDraft),network:!nn(S,on.proxyDraft),provider:!!(L&&(D.trim()!==(L.name||"")||V!==(L.protocol||"chat_completions")||Q.trim()!==(L.baseUrl||"")||U!==(L.clientEmulation||"")))},Rn=Object.values(On).filter(Boolean).length,gt=A||le;async function sn(ke,Xe,Qe,Yt=!1){if(ce.current)return!1;ce.current=!0,he(!0);try{const Rt=ft().wbConfirm?.ask;if(!Rt)throw new Error(a("确认弹窗不可用,请重新打开页面"));return await Rt({title:ke,html:Yo(Xe).replace(/\n/g,"
"),okText:Qe,okClass:Yt?"danger":"primary",bodyClass:Yt?"danger-zone":""})}catch(Rt){return Ct(dn(Rt),"err"),!1}finally{ce.current=!1,he(!1)}}async function Ke(){gt||ce.current||Rn&&!await sn(a("放弃未保存的修改?"),a("所有分区中尚未保存的修改都会被放弃。已确认的独立清除操作不受影响。"),a("放弃修改"))||t()}async function zt(){if(!(gt||ce.current)&&await sn(a("清除余额查询凭证?"),a("确认后立即生效,不受底部保存按钮控制。通常可继续复用转发用的登录凭证。"),a("清除"),!0)){ce.current=!0,R(!0);try{const ke=await Gh(e,{balanceToken:null});l(ke),T(""),Ct(a("✅ 已清除余额查询凭证"));try{await Qo()}catch(Xe){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Xe)}),"err")}}catch(ke){Ct(a("清除失败:{error}",{error:dn(ke)}),"err")}finally{ce.current=!1,R(!1)}}}async function ht(){if(!(gt||ce.current)&&await sn(a("清除已存 API Key?"),a("确认后立即生效,不受底部保存按钮控制。没有凭证且未开启「无需鉴权」时,此账号将被转发跳过。"),a("清除"),!0)){ce.current=!0,R(!0);try{const ke=await Gh(e,{apiKey:null});l(ke),J(""),Ct(a("✅ 已清除 API Key(该账号现在没有凭证,转发会被跳过)"));try{await Qo()}catch(Xe){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Xe)}),"err")}}catch(ke){Ct(a("清除失败:{error}",{error:dn(ke)}),"err")}finally{ce.current=!1,R(!1)}}}async function Tt(){if(gt||ce.current)return;const ke=Q.trim();if(await sn(a("改回跟随提供商?"),a("这个账号将改用提供商当前保存的 Base URL:{url}。确认后立即生效,不受底部保存按钮控制。",{url:ke||"—"}),a("改回跟随"))){ce.current=!0,R(!0);try{const Xe=await Gh(e,{baseUrl:null});l(Xe),Ct(a("✅ 已改回跟随提供商的 Base URL"));try{await Qo()}catch(Qe){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Qe)}),"err")}}catch(Xe){Ct(a("操作失败:{message}",{message:dn(Xe)}),"err")}finally{ce.current=!1,R(!1)}}}async function Ht(ke){if(!(gt||ce.current)&&await sn(a("清除查询凭证?"),a("确认后立即生效,余额查询可能显示「未配置」。取消账号设置不会恢复已清除的凭证。"),a("清除"),!0)){ce.current=!0,R(!0);try{const Xe=await Gh(e,{balanceQuery:{[ke]:null}});l(Xe),re(Qe=>({...Qe,[ke]:""})),Ct(a("✅ 已清除查询凭证"));try{await Qo()}catch(Qe){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Qe)}),"err")}}catch(Xe){Ct(a("清除失败:{error}",{error:dn(Xe)}),"err")}finally{ce.current=!1,R(!1)}}}function jt(){if(!De)return null;const ke=K.trim(),Xe={};return ee?ue.noAuth!==!0&&(Xe.noAuth=!0):ke?Xe.apiKey=ke:ue.noAuth===!0&&(Xe.noAuth=!1),Object.keys(Xe).length?Xe:null}function an(){if(!L)return null;const ke=D.trim(),Xe=Q.trim();if(!ke)return{error:a("请填写提供商名称")};if(!Xe)return{error:a("请填写提供商的 Base URL")};try{if(!["http:","https:"].includes(new URL(Xe).protocol))throw new Error("invalid protocol")}catch{return{error:a("请填写有效的 HTTP 或 HTTPS 地址")}}const Qe=typeof L.clientEmulation=="string"?L.clientEmulation:"";return L.name===ke&&L.protocol===V&&L.baseUrl===Xe&&Qe===U?null:{id:L.id,name:ke,protocol:V,baseUrl:Xe,clientEmulation:U}}async function Xt(){if(gt||ce.current||!Rn)return;_("");let ke;try{ke=yc(S)}catch(Pn){ge("network"),_(r.jsx("span",{className:"text-destructive",children:dn(Pn)})),Ct(dn(Pn),"err");return}const Xe=an();if(Xe&&"error"in Xe){ge("provider"),_(r.jsx("span",{className:"text-destructive",children:Xe.error}));return}const Qe=Si(ue)?kNe(ue,G):null;if(Qe&&"error"in Qe){ge("query"),_(r.jsx("span",{className:"text-destructive",children:Qe.error}));return}const Yt=yNe(ue,ne),Rt=tCe(ue.balanceQuery?.scheme,se),fn=jt()||{},At=Number(je);if(!Number.isFinite(At)||At<0){ge("basic"),_(r.jsx("span",{className:"text-destructive",children:a("并发上限必须是 0~{max} 的整数",{max:Su})})),Ct(a("并发上限必须是 0~{max} 的整数",{max:Su}),"err");return}const Re=Math.min(Su,Math.round(At)),mt=Number(ue.maxConcurrent)||0,Bt=Re!==mt?{maxConcurrent:Re}:{};if(!(Xe&&!await sn(a("保存提供商共用配置?"),a("「{name}」名下 {count} 个账号共用这些连接设置。修改协议或 Base URL 可能中断正在进行的请求。",{name:L?.name||L?.id||"",count:Je}),a("确认保存")))){ce.current=!0,R(!0);try{const Pn=ve&&C.trim()?{balanceToken:C.trim()}:{},mn=JS(ue)&&P!==nI(ue)?{zcodePlan:P}:{},vn=g.trim()||ue.name,Qn=b.trim(),Ns=await Gh(e,{...vn!==ue.name?{name:vn}:{},...Qn!==(ue.userAgent||"").trim()?{userAgent:Qn}:{},enabled:u,allowRouteSkip:f,proxy:ke,...Pn,...mn,...fn,...Bt,...Rt?{balanceQuery:Rt}:{},...Qe&&"patch"in Qe?Qe.patch:{},...Yt&&"patch"in Yt?Yt.patch:{}});if((vn!==ue.name||ue.nameCustom===!0)&&Ns.nameCustom!==!0)throw new Error(a("账号更新结果未确认,请刷新后核对设置"));if(l(Ns),Xe)try{const Cr=ft().wbCustomProvidersUi?.update;if(!Cr)throw new Error(a("账号更新接口不可用,请重新打开页面"));await Cr(Xe)}catch(Cr){ge("provider"),_(r.jsx("span",{className:"text-destructive",children:a("账号已保存,但提供商未更新:{error}",{error:dn(Cr)})}));try{await Qo()}catch(Qr){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Qr)}),"err")}R(!1);return}t(),Ct(a("✅ 账号设置已保存"));try{await Qo(),await Ig()}catch(Cr){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Cr)}),"err")}}catch(Pn){_(r.jsx("span",{className:"text-destructive",children:dn(Pn)})),Ct(a("保存失败:{error}",{error:dn(Pn)}),"err")}finally{ce.current=!1,R(!1)}}}const gn=Number(Ga(tn(ue)).concurrencyDefault)||0,un=ve||De||JS(ue),lr=["basic",...un?["credential"]:[],...Si(ue)?["query"]:[],"limiter","network"],yn=L?.name||ft().wbProviders?.labelOf?.(tn(ue))||tn(ue);async function xn(){if(!(gt||ce.current||!L)){ce.current=!0,he(!0);try{const ke=ft().wbCustomProvidersUi?.remove;if(!ke)throw new Error(a("账号更新接口不可用,请重新打开页面"));await ke(L.id)&&t()}catch(ke){Ct(a("删除失败:{error}",{error:dn(ke)}),"err")}finally{ce.current=!1,he(!1)}}}async function jn(){gt||ce.current||Rn&&!await sn(a("放弃未保存的修改?"),a("前往模型管理会关闭账号设置,尚未保存的修改不会生效。"),a("前往模型管理"))||(t(),ft().wbApp?.showPage?.("gateway"))}return r.jsx(at,{open:!0,onOpenChange:(ke,Xe)=>{ke||(Xe.cancel(),Ke())},children:r.jsxs(it,{className:"acct-settings-dialog",showCloseButton:!gt,children:[r.jsxs(ot,{className:"acct-dlg-header",children:[r.jsx("div",{className:"acct-dlg-avatar",children:r.jsx(ha,{name:De?"agent":"accounts",size:23})}),r.jsxs("div",{className:"acct-dlg-identity",children:[r.jsxs("div",{className:"acct-dlg-title-row",children:[r.jsx(st,{children:a("账号设置")}),De?r.jsx(Ee,{variant:"secondary",shape:"tag",children:a("自定义 API")}):null]}),r.jsxs("p",{children:[r.jsx("span",{children:uCe(o)}),r.jsx("span",{className:"acct-dlg-title-dot",children:"·"}),r.jsxs("span",{className:`acct-dlg-account-state${o.enabled===!1?" off":""}`,children:[r.jsx(Yk,{}),o.enabled===!1?a("已停用"):a("已启用")]})]})]})]}),r.jsx(lt,{className:"acct-dlg-body",children:r.jsxs("div",{className:"acct-dlg",children:[r.jsxs($h,{className:"acct-dlg-rail","aria-label":a("账号设置分组"),children:[r.jsxs(Go,{className:"acct-dlg-nav",children:[r.jsx("div",{className:"acct-dlg-nav-label",children:a("当前账号")}),lr.map(ke=>r.jsx(Ts,{active:ie===ke,title:xe[ke].title,disabled:gt,className:"shadow-none",icon:r.jsx(ha,{name:xe[ke].icon}),trailing:On[ke]?r.jsx("span",{className:"acct-dlg-dirty-dot","aria-label":a("有未保存的修改")}):void 0,onClick:()=>ge(ke),children:xe[ke].title},ke)),L?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"acct-dlg-nav-divider"}),r.jsxs("div",{className:"acct-dlg-nav-label",children:[a("提供商"),r.jsx("span",{children:a("共用")})]}),r.jsx(Ts,{active:ie==="provider",disabled:gt,title:xe.provider.title,icon:r.jsx(ha,{name:xe.provider.icon}),trailing:On.provider?r.jsx("span",{className:"acct-dlg-dirty-dot","aria-label":a("有未保存的修改")}):void 0,onClick:()=>ge("provider"),children:xe.provider.title})]}):null]}),L?r.jsxs("div",{className:"acct-dlg-rail-context",children:[r.jsxs("strong",{children:[r.jsx(ha,{name:"accounts",size:14}),yn]}),r.jsx("p",{children:a("{count} 个账号共用连接配置",{count:Je})})]}):null]}),r.jsxs("div",{className:"acct-dlg-main",children:[r.jsxs("div",{className:"acct-dlg-pane-head",children:[r.jsxs("div",{children:[r.jsx("h3",{children:Se.title}),r.jsx("p",{children:Se.description})]}),r.jsxs("span",{className:`acct-dlg-scope${ie==="provider"?" shared":""}`,children:[r.jsx(ha,{name:"accounts",size:13}),ie==="provider"?a("{count} 个账号共用",{count:Je}):a("仅当前账号")]})]}),r.jsx("div",{ref:ye,className:"acct-dlg-scroll","aria-busy":A,children:r.jsxs("div",{className:"acct-dlg-pane",inert:gt?!0:void 0,children:[ie==="basic"?r.jsxs(r.Fragment,{children:[r.jsxs(wc,{title:a("账号信息"),children:[r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{htmlFor:"account-name-input",children:a("备注名")}),r.jsx(ze,{id:"account-name-input",maxLength:100,placeholder:a("账号显示名称"),value:g,onChange:ke=>v(ke.currentTarget.value)})]}),r.jsxs("div",{className:"acct-dlg-readonly",children:[r.jsx("span",{children:a("账号 ID")}),r.jsx("code",{children:ue.id})]}),r.jsxs(ct,{className:"acct-dlg-toggle-field",children:[r.jsxs("div",{children:[r.jsx(ut,{htmlFor:"account-enabled",children:a("启用账号")}),r.jsx(wr,{children:a("关闭后不参与转发,余额查询不受影响。")})]}),r.jsx(St,{id:"account-enabled",checked:u,onCheckedChange:d})]})]}),r.jsxs(wc,{title:a("转发行为"),children:[r.jsxs(ct,{className:"acct-dlg-toggle-field",children:[r.jsxs("div",{children:[r.jsx(ut,{htmlFor:"account-route-skip",children:a("失败后允许换号")}),r.jsx(wr,{children:a("关闭后,该账号转发失败时返回本次错误,不再顺延其他账号。禁用、无凭证和限制器等保护仍生效。")})]}),r.jsx(St,{id:"account-route-skip",checked:f,onCheckedChange:m})]}),r.jsxs(ct,{className:"acct-dlg-concurrency",children:[r.jsxs("div",{children:[r.jsx(ut,{htmlFor:"account-conc-input",children:a("并发上限")}),r.jsx(wr,{children:a("达到上限后,将请求交给其他账号。")})]}),r.jsx(ze,{id:"account-conc-input",type:"number",min:0,max:Su,step:1,value:je,onChange:ke=>te(ke.currentTarget.value)})]})]}),r.jsx("p",{className:"detail acct-dlg-hint",children:gn>0?a("0 = 按本家默认 {default}",{default:gn}):a("0 = 不限")}),w?r.jsx(wc,{title:a("请求标识"),children:r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{htmlFor:"account-user-agent",children:"User-Agent"}),r.jsx(Ug,{id:"account-user-agent",value:b,onChange:y,presets:k,disabled:gt}),r.jsx(wr,{children:a("用于当前账号的对话、余额查询、模型拉取、模型测试、签到及凭证刷新等上游请求。留空使用提供商默认值;可选预置或直接填写。")})]})}):null,i?r.jsx("div",{className:"acct-dlg-route-context",children:i}):r.jsxs("p",{className:"detail acct-dlg-group-note",children:[r.jsx(ha,{name:"route",size:14}),a("在账号列表中拖动分组或行首把手,调整转发顺序。")]})]}):null,ie==="credential"&&un?r.jsxs(r.Fragment,{children:[ve?r.jsx(aCe,{configured:o.hasBalanceToken===!0,value:C,onChange:T,clearBusy:gt,onClear:()=>{zt()}}):null,De?r.jsx(iCe,{hasApiKey:ue.hasApiKey===!0,noAuth:ee,value:K,clearBusy:gt,onClear:()=>{ht()},onValue:ke=>{J(ke),ke.trim()&&H(!1)},onToggleNoAuth:ke=>{H(ke),ke&&J("")}}):null,JS(ue)?r.jsx(wc,{title:a("使用套餐"),children:r.jsx(XNe,{plan:P,hasJwt:o.canClaim===!0,onChange:O})}):null,L?r.jsxs("div",{className:"acct-dlg-related",children:[r.jsx(ha,{name:"agent",size:18}),r.jsxs("div",{children:[r.jsx("h3",{children:a("要修改连接地址或协议?")}),r.jsx("p",{children:a("{count} 个账号共用提供商的连接配置。",{count:Je})})]}),r.jsxs(B,{variant:"link",size:"xs",onClick:()=>ge("provider"),children:[a("连接设置"),r.jsx(ha,{name:"caretRight",size:12})]})]}):null]}):null,ie==="query"&&Si(ue)?r.jsxs(r.Fragment,{children:[r.jsx(wc,{title:a("余额查询"),children:r.jsx(H8,{draft:G,onChange:Y})}),We?r.jsxs(wc,{title:a("查询凭证"),action:r.jsx(Ee,{variant:"secondary",shape:"tag",children:We.label}),children:[r.jsx(rCe,{spec:We,values:se,configured:nt,onValue:(ke,Xe)=>re(Qe=>({...Qe,[ke]:Xe})),onClear:ke=>{Ht(ke)},clearBusy:gt,idPrefix:"account-balance-query"}),kt?r.jsx("p",{className:"detail acct-dlg-inline-note",children:a("查询凭证还没配齐:填好后余额列才有读数,在此之前会显示「未配置」。")}):null]}):null,r.jsxs("p",{className:"detail acct-dlg-group-note",children:[r.jsx(ha,{name:"info",size:14}),a("余额读数也是限制器余额规则的数据来源。")]})]}):null,ie==="limiter"?r.jsxs(r.Fragment,{children:[r.jsx(B8,{account:ue,draft:ne,onChange:de,allowBalance:Si(ue)}),r.jsxs("p",{className:"detail acct-dlg-group-note",children:[r.jsx(ha,{name:"info",size:14}),a("没有规则或全部停用时不限制;跳过后自动恢复,禁用后需手动启用。")]})]}):null,ie==="network"?r.jsxs(r.Fragment,{children:[r.jsxs(wc,{title:a("出网方式"),children:[r.jsx(pN,{draft:S,onChange:N,idPrefix:"account-proxy",allowRotate:Ie}),o.proxy?.error?r.jsx("p",{className:"detail text-destructive acct-dlg-block",children:a("当前代理不可用:{error}(不会自动改为直连)",{error:o.proxy.error})}):null]}),r.jsxs("p",{className:"detail acct-dlg-group-note",children:[r.jsx(ha,{name:"shield",size:14}),a("代理只作用于当前账号,不改变其他账号的出网方式。")]})]}):null,ie==="provider"&&L?r.jsx(lCe,{provider:L,count:Je,name:D,protocol:V,baseUrl:Q,accountBaseUrl:ue.baseUrl||"",emulation:U,onName:F,onProtocol:q,onBaseUrl:X,onEmulation:z,onClearAccountBaseUrl:()=>{Tt()},disabled:gt,onRemove:()=>{xn()},onModels:()=>{jn()}}):null]})})]})]})}),r.jsxs(xt,{className:"acct-dlg-footer",children:[r.jsxs("div",{className:`acct-dlg-save-state${Rn?" dirty":""}`,role:"status",children:[r.jsx(ha,{name:M?"info":Rn?"timer":"shield",size:16}),r.jsxs("div",{children:[r.jsx("strong",{children:M||(A?a("正在保存…"):Rn?a("{count} 个分区有未保存的更改",{count:Rn}):a("没有未保存的更改"))}),r.jsx("p",{children:On.provider?a("包含提供商共用配置,将影响 {count} 个账号",{count:Je}):a("各分区的更改将统一保存")})]})]}),r.jsxs("div",{className:"acct-dlg-footer-actions",children:[r.jsx(B,{variant:"outline",disabled:gt,onClick:()=>{Ke()},children:a("取消")}),r.jsx(B,{variant:"default",disabled:gt||!Rn,onClick:()=>{Xt()},children:a(A?"保存中…":"保存更改")})]})]})]})})}function dCe(){const e=p.useSyncExternalStore(Hh,()=>Sn());return e.dialog?e.dialog.kind==="settings"?r.jsx(gG,{id:e.dialog.id,onClose:xy},e.dialog.id):e.dialog.kind==="group"?r.jsx(hG,{provider:e.dialog.provider,onClose:xy},e.dialog.provider):r.jsx(TNe,{ids:e.dialog.ids,action:e.dialog.action,onClose:xy},e.dialog.ids.join(",")):null}function Zh(e){return!!(e&&["queued","runtime","starting","loading","registering"].includes(e.phase))}function Jh(e){return e?.phase==="failed"||e?.phase==="timeout"}function em(e,t){switch(e?.phase){case"queued":return t("等待加载");case"runtime":return t("准备运行环境");case"starting":return t("正在启动");case"loading":return t("正在加载");case"registering":return t("即将就绪");case"ready":return t("已就绪");case"failed":return t("加载失败");case"timeout":return t("初始化超时");case"blocked":return t("等待运行环境恢复");case"disabled":return t("已停用");default:return t("状态待确认")}}function xG(e,t,n=Date.now()){if(e?.error&&Jh(e))return e.error;switch(e?.phase){case"queued":return t("等待前面的插件完成,不代表加载失败。");case"runtime":return t("正在检查或准备脚本运行环境。");case"starting":return t("正在启动插件,账号将在就绪后自动恢复。");case"loading":return n-e.updatedAt>1e4?t("启动较慢,仍在加载;尚未收到失败结果。"):t("正在初始化插件,尚未收到失败结果。");case"registering":return t("初始化已完成,正在等待校验和登记。");case"ready":return t("插件已就绪,账号列表将自动同步。");case"timeout":return t("本次初始化超过等待时限,已停止;可查看诊断后重试。");case"blocked":return t("共享运行环境尚未就绪,本插件没有明确的加载失败结果。");case"failed":return t("本次加载未完成,请查看诊断。");default:return t("暂未取得明确的加载结果,不能据此判断启动失败。")}}let kc={value:null,error:"",receivedAt:0,unavailable:!1};const XI=new Set,ky=e=>(XI.add(e),()=>{XI.delete(e)}),Bl=()=>kc;function QI(e){kc={...kc,...e},XI.forEach(t=>t())}let kN;function nf(){kN?.()}function fCe(e){let t=!1,n=!1,s=!1,i,o,l=null,u=!1,d="",f=0;QI({value:null,error:"",receivedAt:0,unavailable:!1});const m=()=>{if(l){u=!0;return}l=(async()=>{do{u=!1;try{await e.refresh()}catch{}}while(!t&&u)})().finally(()=>{l=null})},g=async()=>{if(t||document.hidden)return;if(n){s=!0;return}n=!0,o=new AbortController;const y=setTimeout(()=>o?.abort(),8e3);try{const k=await e.read(o.signal);if(t||o.signal.aborted)return;if(!k||typeof k.bootId!="string"||typeof k.revision!="string"||!k.providers||!Array.isArray(k.packs))throw new Error("Invalid plugin startup status");f=0;const w=kc.value?.bootId!==k.bootId||kc.value?.revision!==k.revision;QI({value:k,error:k.error||"",receivedAt:Date.now(),unavailable:!1}),w&&e.onChange?.();const S=`${k.bootId}:${k.availabilityRevision}`,N=e.session();(d&&d!==S||!N||N.bootId!==k.bootId||N.availabilityRevision!==k.availabilityRevision)&&m(),d=S}catch(k){if(t)return;f+=1;const w=k?.status;QI({error:k instanceof Error?k.message:String(k),unavailable:w===404})}finally{if(clearTimeout(y),n=!1,o=void 0,!t){clearTimeout(i);const k=s?0:kc.unavailable?6e4:f?Math.min(3e4,2e3*f):kc.value?.pending||kc.value?.scriptOperation?.active?1500:2e4;s=!1,i=setTimeout(()=>{g()},k)}}},v=()=>{clearTimeout(i),g()},b=()=>{document.hidden?clearTimeout(i):v()};return kN=v,document.addEventListener("visibilitychange",b),v(),()=>{t=!0,clearTimeout(i),o?.abort(),kN===v&&(kN=void 0),document.removeEventListener("visibilitychange",b)}}function ZI(e,t){const n=kc.value?.packs.find(s=>s.id===e)?.startup;return t&&(!n||t.updatedAt>n.updatedAt)?t:n||t}function hCe(e){const t=e.providers.map(n=>{const s=kc.value?.providers[n.id];if(!s||n.startup&&n.startup.updatedAt>s.startup.updatedAt)return n;if(!s.enabled)return{...n,packId:s.packId,startup:s.startup,reason:s.packEnabled?"provider_disabled":"pack_disabled"};const i=s.startup,o=Jh(i)?i.phase==="timeout"?"load_timeout":"load_failed":Zh(i)||s.available?"loading":"not_loaded";return{...n,packId:s.packId,startup:i,reason:o}});return{...e,providers:t}}const SN=e=>e.reason==="load_failed"||e.reason==="load_timeout";function vG(e,t){return t==="all"?!0:t==="loading"?e.reason==="loading"||e.reason==="not_loaded":t==="missing"?e.reason==="not_installed":t==="disabled"?e.reason==="pack_disabled"||e.reason==="provider_disabled":SN(e)}function mCe(e,t){switch(e.reason){case"not_installed":return t("插件未安装");case"pack_disabled":return t("插件包已停用");case"provider_disabled":return t("提供商已停用");case"load_failed":return t("加载失败");case"load_timeout":return t("初始化超时");case"loading":return e.startup?em(e.startup,t):t("正在加载");default:return em(e.startup,t)}}function pCe(e,t,n){switch(e.reason){case"not_installed":return t("重新安装这个插件后自动回来");case"pack_disabled":return t("启用插件包后自动回来");case"provider_disabled":return t("启用这家提供商后自动回来");default:return xG(e.startup,t,n)}}function gCe(e,t){return e.reason==="not_installed"?t("去安装"):e.reason==="pack_disabled"||e.reason==="provider_disabled"?t("去启用"):SN(e)||e.startup?.phase==="blocked"?t("查看原因"):t("查看进度")}let JI=null;const eM=new Set;function Sy(e){JI=e,eM.forEach(t=>t())}function xCe(){const e=JI;return JI=null,e}function vCe(e){return eM.add(e),()=>{eM.delete(e)}}function Ny(e,t){return p.useSyncExternalStore(ky,Bl),ZI(e,t)}function tM({id:e,status:t,t:n}){const s=Ny(e,t),i=Bl(),o=i.value?.now||Date.now(),l=s?.startedAt?Math.max(0,Math.round(((s.finishedAt||o)-s.startedAt)/1e3)):null;return r.jsxs("section",{className:"flex flex-col gap-2 text-xs","aria-label":n("加载状态"),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[Zh(s)?r.jsx(Qt,{className:"size-3.5"}):null,r.jsx(Ee,{variant:Jh(s)?"warning":"outline",shape:"tag",children:em(s,n)}),l!==null?r.jsx("span",{className:"text-muted-foreground",children:n("本次用时 {n} 秒",{n:l})}):null]}),r.jsx("p",{className:"m-0 whitespace-pre-wrap break-words text-muted-foreground",children:xG(s,n,o)}),s?.phase==="blocked"&&s.error?r.jsx("p",{className:"m-0 whitespace-pre-wrap break-words text-muted-foreground",children:s.error}):null,s?.startedAt?r.jsx("p",{className:"m-0 text-muted-foreground",children:n("开始时间:{time}",{time:new Date(s.startedAt).toLocaleString()})}):null,s?.finishedAt?r.jsx("p",{className:"m-0 text-muted-foreground",children:n("完成时间:{time}",{time:new Date(s.finishedAt).toLocaleString()})}):null,s?.steps?.length?r.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-muted-foreground",children:s.steps.map((u,d)=>r.jsxs("span",{children:[em({...s,phase:u.phase},n)," · ",(u.durationMs/1e3).toFixed(1)," s"]},d))}):null,s?.previousError?r.jsxs("details",{className:"text-muted-foreground",children:[r.jsx("summary",{children:n("上次加载记录(非本次故障)")}),r.jsx("p",{className:"whitespace-pre-wrap break-words",children:s.previousError})]}):null,i.error&&!i.unavailable?r.jsx("p",{className:"m-0 text-muted-foreground",children:n("暂时无法获取插件状态,显示上次结果;这不代表插件启动失败。")}):null]})}function bCe({id:e,name:t,status:n,script:s,onClose:i,retry:o,t:l}){const u=Ny(e,n),d=Bl().value?.packs.find(k=>k.id===e)?.name||t,f=Bl().value?.scriptOperation,[m,g]=p.useState(!1),[v,b]=p.useState("");p.useEffect(()=>{nf()},[e]);const y=async()=>{if(!(m||Zh(u)||Bl().error||s&&f?.active)){g(!0),b("");try{await o(),nf()}catch(k){b(k instanceof Error?k.message:String(k))}finally{g(!1)}}};return r.jsx(at,{open:!0,onOpenChange:k=>{!k&&!m&&i()},children:r.jsxs(it,{className:"w-[min(560px,calc(100vw-32px))]",children:[r.jsx(ot,{children:r.jsxs(st,{children:[d," · ",l("加载诊断")]})}),r.jsxs(lt,{children:[r.jsx(tM,{id:e,status:u,t:l}),s?r.jsx("p",{className:"m-0 text-xs text-muted-foreground",children:l("脚本插件共用运行环境;重试会等待当前任务结束,不会删除账号或重新安装插件。")}):null,f?.target?.id===e&&f.error&&!Zh(u)&&u?.phase!=="ready"&&(f.updatedAt||0)>=(u?.startedAt||0)?r.jsx("p",{role:"alert",className:"m-0 text-xs text-destructive",children:f.error}):null,s&&f?.active?r.jsx("p",{className:"m-0 text-xs text-muted-foreground",role:"status",children:l("正在重试…")}):null,v?r.jsx("p",{role:"alert",className:"m-0 text-xs text-destructive",children:v}):null]}),r.jsxs(xt,{children:[r.jsx(B,{variant:"outline",disabled:m,onClick:nf,children:l("刷新状态")}),u&&u.phase!=="ready"&&u.phase!=="disabled"?r.jsx(B,{disabled:m||Zh(u)||!!Bl().error||!!(s&&f?.active),onClick:()=>{y()},children:l(m?"正在重试…":"重新加载")}):null,r.jsx(B,{variant:"ghost",disabled:m,onClick:i,children:l("关闭")})]})]})})}function bG(e){return e.providers.filter(SN).length}function yCe({hidden:e,onOpen:t}){return e.total<=0?null:r.jsxs(B,{id:"btn-hidden-accounts",variant:"outline",className:"acct-hidden-entry",title:a("查看因插件未就绪而暂未显示的账号"),onClick:()=>{nf(),t()},children:[r.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:1.7,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("path",{d:"M2.5 12s3.4-6 9.5-6 9.5 6 9.5 6-3.4 6-9.5 6-9.5-6Z"}),r.jsx("path",{d:"m4 20 16-16"})]}),a("未显示账号"),r.jsx(Ee,{variant:bG(e)?"warning":"outline",shape:"tag",children:e.providers.length})]})}function jCe({hidden:e,open:t,onOpenChange:n}){const[s,i]=p.useState("all");p.useEffect(()=>{t&&nf()},[t]);const o=Bl(),l=m=>e.providers.filter(g=>vG(g,m)).length,u=e.providers.filter(m=>vG(m,s)),d=e.providers.filter(m=>m.reason==="loading").length,f=m=>{m?.packId&&!["not_installed","pack_disabled","provider_disabled"].includes(m.reason)&&Sy(m.packId),n(!1),ft().wbApp?.showPage?.("plugins")};return r.jsx(Qb,{open:t,onOpenChange:m=>{m||n(!1)},children:r.jsxs(Zb,{side:"right",showHandle:!1,className:"w-[min(480px,94vw)]",children:[r.jsx(MS,{children:r.jsx(IS,{children:a("未显示的账号")})}),r.jsxs(_S,{className:"acct-hidden-body",children:[r.jsx("p",{className:"acct-hidden-lead",children:a("{providers} 家提供商、共 {total} 个账号。数据仍在,只是当前没有可用的插件来执行它们。",{providers:e.providers.length,total:e.total})}),d?r.jsx("p",{className:"m-0 text-xs text-muted-foreground",role:"status",children:a("正在加载 · {n} 家提供商的账号暂未显示,就绪后自动恢复。",{n:d})}):null,o.error&&!o.unavailable?r.jsxs("p",{className:"m-0 text-xs text-muted-foreground",role:"status",children:[a("暂时无法获取插件状态,显示上次结果;这不代表插件启动失败。"),r.jsx(B,{variant:"link",size:"xs",onClick:nf,children:a("刷新状态")})]}):null,r.jsx(en,{"aria-label":a("按未显示原因筛选"),value:s,onValueChange:i,options:[{value:"all",label:a("全部"),count:l("all")},{value:"loading",label:a("待就绪"),count:l("loading")},{value:"missing",label:a("未安装"),count:l("missing")},{value:"disabled",label:a("已停用"),count:l("disabled")},{value:"broken",label:a("加载异常"),count:l("broken")}]}),r.jsxs("div",{className:"acct-hidden-rows",children:[u.map(m=>r.jsxs("div",{className:"acct-hidden-row",children:[r.jsx("span",{className:"acct-hidden-avatar","aria-hidden":"true",children:a(m.label).trim().slice(0,1)}),r.jsxs("div",{className:"acct-hidden-info",children:[r.jsxs("div",{className:"acct-hidden-name",children:[r.jsx("span",{className:"truncate",children:a(m.label)}),r.jsx(Ee,{variant:SN(m)?"warning":"outline",shape:"tag",children:mCe(m,a)})]}),r.jsxs("p",{className:"acct-hidden-detail",children:[a("保留 {n} 个账号",{n:m.count})," · ",pCe(m,a,o.value?.now)]})]}),r.jsx(B,{variant:"outline",size:"sm",onClick:()=>f(m),children:gCe(m,a)})]},m.id)),u.length?null:r.jsx("p",{className:"acct-hidden-none",children:a("这一类现在没有账号")})]}),r.jsx("p",{className:"acct-hidden-foot",children:a("这里只影响「显示」:卸载或停用插件不会删除账号;重新安装、启用并成功加载后,这些账号会自动回到列表。")})]}),r.jsxs(vP,{children:[r.jsx(B,{variant:"outline",onClick:()=>n(!1),children:a("知道了")}),r.jsx(B,{onClick:()=>f(),children:a("去「插件」页")})]})]})})}function wCe({hidden:e,onOpen:t}){return r.jsxs("div",{className:"acct-hidden-empty",role:"status",children:[r.jsxs("span",{children:[r.jsx(Ka,{variant:bG(e)?"warning":"muted",className:"size-1.5"}),a("共有 {n} 个账号暂未显示",{n:e.total})]}),r.jsx(B,{variant:"outline",size:"sm",onClick:t,children:a("查看")})]})}function yG(e){const t=Math.round(e/6e4);if(t<1)return a("不到 1 分钟");if(t<60)return a("还有 {n} 分钟",{n:t});const n=Math.floor(t/60),s=t%60;return n<24?s?a("还有 {h} 小时 {m} 分",{h:n,m:s}):a("还有 {h} 小时",{h:n}):a("还有 {d} 天",{d:Math.floor(n/24)})}function kCe(e){const t=Date.now();return oI(e).map(n=>{const s=Number(n.resetAt),i=Number(n.at),o=uI(n.resetAt),l=o===cI,u=n.message||(n.status?a("上游返回 {status}",{status:n.status}):""),d=s-i,f=i>0&&Number.isFinite(d)&&d>0?Math.max(0,Math.min(100,(t-i)/d*100)):null,m=l?a("恢复时间未知"):yG(s-t),g=l?"":a("{time} 恢复",{time:o});return{model:n.model,wait:m,tone:l?"muted":"warn",reset:g,reason:u,title:[n.model,m,g,u,a("到恢复时间后自动解除,无需手动操作")].filter(Boolean).join(" · "),progress:f}})}function SCe({accountName:e,rows:t,count:n,cooldown:s,soonest:i,onClear:o}){const[l,u]=p.useState(!1),d=p.useRef(null),f=p.useCallback(v=>{d.current=v,v&&(v.scrollTop=0)},[]),m=p.useCallback(()=>d.current??null,[]),g=i===cI?a("待定"):i;return r.jsxs(r.Fragment,{children:[r.jsxs(ui,{open:l,onOpenChange:u,children:[r.jsxs(wi,{render:r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"usage-toggle warn",title:a(s?"点击查看账号冷却与模型限流明细":"点击查看各模型的限流明细"),"aria-label":a("限流明细")}),children:[r.jsx("span",{className:"val",children:s?a("账号冷却"):a("{n} 个模型",{n})}),r.jsx("span",{className:"caret","aria-hidden":!0,children:"▾"})]}),r.jsx(di,{align:"center",sideOffset:6,className:"w-[320px]",initialFocus:m,children:r.jsxs("div",{className:"usage-pop-limit",ref:f,tabIndex:-1,children:[e?r.jsx("div",{className:"usage-pop-sub",children:e}):null,r.jsx("div",{className:"usage-pop-group",children:a("限流明细")}),s?r.jsxs("div",{className:"usage-pop-row",children:[r.jsxs("div",{className:"usage-pop-line",children:[r.jsx("span",{className:"usage-pop-name",children:a("账号冷却")}),r.jsx("span",{className:"usage-pop-view warn",children:yG(s.resetAt-Date.now())})]}),r.jsx("div",{className:"lp-pop-subline",children:r.jsxs("span",{className:"lp-pop-reason",children:[a("{time} 恢复",{time:i}),s.message?` · ${s.message}`:""]})})]}):null,t.map(v=>r.jsxs("div",{className:"usage-pop-row",title:v.title,children:[r.jsxs("div",{className:"usage-pop-line",children:[r.jsx("span",{className:"usage-pop-name lp-pop-model",children:v.model}),r.jsx("span",{className:`usage-pop-view ${v.tone}`,children:v.wait})]}),r.jsxs("div",{className:"lp-pop-subline",children:[r.jsxs("span",{className:"lp-pop-reason",children:[v.reset?`${v.reset} · `:"",v.reason]}),r.jsx(B,{variant:"ghost",size:"xs",title:a("清掉本机的限流标记,立刻重新尝试该模型(上游若仍在限流会再次被标记)"),onClick:()=>o(v.model),children:a("清除")})]}),v.progress!==null?r.jsx(kg,{value:v.progress,variant:"muted",className:"mt-1.5",trackClassName:"h-[3px]","aria-label":a("冷却进度 {percent}%",{percent:Math.round(v.progress)})}):null]},v.model)),r.jsxs("div",{className:"lp-pop-foot",children:[r.jsx("span",{className:"lp-pop-note",children:s?a("账号全部模型暂时停止转发 · 到恢复时间自动解除"):a("{n} 个模型限流中 · 到恢复时间自动解除",{n})}),r.jsx(B,{variant:"outline",size:"xs",title:a("清除该账号的冷却与全部模型限流标记"),onClick:()=>o(""),children:a("全部清除")})]})]})})]}),r.jsx("span",{className:"lim-sub",title:a(s?"账号冷却":"最早恢复"),children:s?a("{time} 恢复",{time:g}):a("最早 {soonest} 恢复",{soonest:g})})]})}function jG({account:e,onOpen:t}){if(e.enabled===!1||!ay(e))return null;const n=HP(e),s=sy(e),i=s.some((u,d)=>u.action==="skip"&&n[d]?.hit&&n[d]?.account),o=[...new Set(s.flatMap((u,d)=>u.action==="skip"&&n[d]?.hit?n[d].models:[]))],l=i||!o.length?a("限制器 · 账号已跳过"):a("限制器 · {n} 个模型",{n:o.length});return r.jsx(B,{variant:"ghost",size:"xs",className:"h-auto p-0",onClick:t,title:a(i?"账号级条件组已触发;点击查看限制器":"仅跳过命中条件的模型,其他模型仍可转发;点击查看限制器"),children:r.jsx(Ee,{variant:"warning",shape:"tag",children:l})})}const Cy=new Map,tm=new Map;let nM=null;function Ra(e,t,n){const s={selector:t,mount:n,done:!1},i=Cy.get(e);i?i.push(s):Cy.set(e,[s]),nM===e&&kG(e)}function wG(e){if(!(e.done||!document.querySelector(e.selector))){e.done=!0;try{e.mount()}catch(n){console.error("[islands] 页面挂载失败:",e.selector,n)}}}function kG(e){const t=Cy.get(e);if(!t||t.length===0)return;for(const i of t)wG(i);const n=t.filter(i=>!i.done);if(n.length===0){Cy.delete(e),tm.get(e)?.disconnect(),tm.delete(e);return}if(tm.has(e))return;const s=new MutationObserver(()=>{for(const i of n)wG(i);n.every(i=>i.done)&&(s.disconnect(),tm.delete(e),Cy.delete(e))});s.observe(document.body,{childList:!0,subtree:!0}),tm.set(e,s)}function NCe(e){if(e!==nM)for(const[t,n]of tm)t!==e&&(n.disconnect(),tm.delete(t));nM=e,kG(e)}window.addEventListener("wb:page",e=>{const t=e.detail;typeof t=="string"&&t&&NCe(t)});const nm=[20,50,100,200],rM=[20,50,100,200,"all"],Hg=50,SG="workbuddy-desktop-table-size:";function NG(e){return e==="all"?a("全部"):String(e)}function NN(e,t=rM,n=Hg){t.includes(n)||(n=t.includes(Hg)?Hg:t[0]);let s=null;try{s=localStorage.getItem(SG+e)}catch{return n}if(s===null||s.trim()==="")return n;if(s==="all")return t.includes("all")?"all":n;const i=Number(s);return Number.isFinite(i)&&t.includes(i)?i:n}function CN(e,t){try{localStorage.setItem(SG+e,String(t))}catch{}}function Ay(e,t,n={}){const s=n.sizes??rM,i=n.defaultSize??Hg,[o,l]=p.useState(()=>NN(t,s,i)),[u,d]=p.useState(1),f=Math.max(1,o==="all"?1:Math.ceil(e/o)),m=Math.min(Math.max(1,u),f);p.useEffect(()=>{m!==u&&d(m)},[m,u]);const g=p.useCallback(w=>{l(w),CN(t,w),d(1)},[t]),v=p.useCallback(w=>{d(Math.min(Math.max(1,Math.round(w)||1),f))},[f]),b=o==="all"?0:(m-1)*o,y=o==="all"?e:Math.min(e,b+o),k=p.useCallback(w=>o==="all"?w.slice():w.slice(b,y),[o,b,y]);return{size:o,page:m,pageCount:f,rangeStart:e?b+1:0,rangeEnd:e?y:0,paged:o!=="all",setSize:g,goto:v,slice:k}}function rf({total:e,page:t,pageCount:n,size:s,sizes:i=rM,onSizeChange:o,onPageChange:l,range:u=null,disabled:d=!1,leading:f,className:m}){const[g,v]=p.useState(String(t));p.useEffect(()=>v(String(t)),[t]);const b=()=>{const w=g.trim();if(!w){v(String(t));return}const S=Number(w);if(!Number.isFinite(S)){v(String(t));return}const N=Math.min(Math.max(1,Math.round(S)),n);v(String(N)),N!==t&&l(N)},y=n<=1,k=e===0?a("共 0 条"):u?a("共 {total} 条 · 当前第 {start}–{end} 条",{total:e,start:u.start,end:u.end}):a("共 {total} 条(全部显示)",{total:e});return r.jsxs(ju,{className:m?`panel-foot table-foot-bar ${m}`:"panel-foot table-foot-bar",children:[f,r.jsx("div",{className:"spacer"}),r.jsxs("div",{className:"table-foot-ctl",children:[r.jsx("span",{className:"table-foot-count",children:k}),r.jsxs("span",{className:"table-foot-size",children:[a("每页"),r.jsxs(Pt,{value:String(s),onValueChange:w=>o(w==="all"?"all":Number(w)),children:[r.jsx(Mt,{className:"h-[26px] w-[86px]",disabled:d,"aria-label":a("每页条数"),children:r.jsx(It,{children:NG(s)})}),r.jsx(_t,{children:i.map(w=>r.jsx(Ze,{value:String(w),children:NG(w)},String(w)))})]}),a("条")]}),r.jsxs("span",{className:"table-foot-jump",children:[a("跳至"),r.jsx(ze,{className:"h-[26px] w-[52px] px-1 text-center",value:g,disabled:d||y,"aria-label":a("跳转到指定页"),title:y?a("当前只有一页"):a("跳转到第 1–{pageCount} 页",{pageCount:n}),inputMode:"numeric",onChange:w=>v(w.target.value),onKeyDown:w=>{w.key==="Enter"?(w.preventDefault(),b()):w.key==="Escape"&&v(String(t))},onBlur:b}),a("页")]}),r.jsx(xP,{page:t,pageCount:n,onPageChange:l,disabled:d})]})]})}const sM=[{key:"pick",label:a("选择"),align:"center",legacyAlign:"left"},{key:"order",label:a("顺序"),title:a("组内先后:按住左边的把手上下拖动即可调整;整组的先后拖分组带的把手"),align:"center",legacyAlign:"left"},{key:"account",label:a("账号"),align:"center",legacyAlign:"left"},{key:"proxy",label:a("代理"),title:a("该账号出网走的代理(已保存的代理 / 自定义 / 直连);点击可修改"),align:"center"},{key:"connections",label:a("连接数"),title:a("此刻正在使用这个账号的请求数(含还在下发内容的流式请求);为 0 时不显示"),align:"center"},{key:"status",label:a("状态"),align:"center",legacyAlign:"left"},{key:"limits",label:a("限流"),title:a("该账号当前限流中的模型;点徽章看明细"),align:"center",legacyAlign:"left"},{key:"expiry",label:a("有效期"),align:"center",legacyAlign:"left"},{key:"usage",label:a("余额"),align:"center",legacyAlign:"left"},{key:"actions",label:a("操作"),align:"right"}],CG="agent2api-accounts-col-widths",Ey={pick:47,order:84,proxy:186,connections:56,status:80,limits:148,expiry:132,usage:308,actions:200},aM=new Set(["account"]),CCe=300,iM=56,ACe=new Set([...Object.keys(Ey),...aM]),Vg=(()=>{try{const e=JSON.parse(localStorage.getItem(CG)||"{}"),t={};for(const[n,s]of Object.entries(e||{})){const i=Number(s);ACe.has(n)&&Number.isFinite(i)&&i>=iM&&(t[n]=Math.round(i))}return t}catch{return{}}})();function AG(){try{localStorage.setItem(CG,JSON.stringify(Vg))}catch{}}function ECe(){return{...Ey,...Vg}}function TCe(e){let t=0;for(const n of e){const s=Vg[n];s?t+=s:aM.has(n)?t+=CCe:Ey[n]?t+=Ey[n]:t+=iM}return Math.round(t)}function EG(e,t){const n=e?.querySelector(`thead th:nth-child(${t+1})`),s=n?.getAttribute("data-col")||n?.className.match(/cell-([a-z]+)/)?.[1];if(!s)return null;const i=e?.querySelector(`colgroup col[data-col="${CSS.escape(s)}"]`)||e?.querySelectorAll("colgroup col")[t];return i?{key:s,col:i}:null}function OCe(e,t,n){const s=Math.max(iM,Math.round(n));e.style.width=s+"px",aM.has(t)||s!==Ey[t]?Vg[t]=s:delete Vg[t]}let oM=()=>{};function RCe(e,t){if(oM=t,!e)return;let n=null;e.addEventListener("pointerdown",s=>{if(s.button!==0)return;const i=s.target?.closest?.(".col-grip");if(!i)return;s.preventDefault();const o=i.closest("th"),l=o?.closest("table")||null,u=o?.parentElement?[...o.parentElement.children].indexOf(o):-1,d=EG(l,u);if(!d)return;const f=s.clientX,m=d.col.getBoundingClientRect().width;i.classList.add("active"),document.body.classList.add("col-resizing");try{i.setPointerCapture(s.pointerId)}catch{}n={...d,startX:f,startWidth:m,grip:i,pointerId:s.pointerId},window.addEventListener("pointermove",g),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),window.addEventListener("blur",v);function g(b){if(n){if(b.buttons===0){v();return}OCe(n.col,n.key,n.startWidth+b.clientX-n.startX)}}function v(){if(!n)return;const{grip:b,pointerId:y}=n;n=null,b.classList.remove("active"),document.body.classList.remove("col-resizing");try{b.releasePointerCapture(y)}catch{}window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),window.removeEventListener("blur",v),AG(),oM()}}),e.addEventListener("dblclick",s=>{const i=s.target?.closest?.(".col-grip");if(!i)return;const o=i.closest("th"),l=o?.closest("table")||null,u=o?.parentElement?[...o.parentElement.children].indexOf(o):-1,d=EG(l,u);d&&(delete Vg[d.key],AG(),oM())})}let lM=Date.now(),rm=null;const Kg=new Set;function Ty(){lM=Date.now();for(const e of Kg)e();TG()}function TG(){rm!==null&&clearTimeout(rm),rm=null,!(!Kg.size||document.hidden)&&(rm=setTimeout(Ty,6e4-Date.now()%6e4))}function PCe(e){return Kg.add(e),Kg.size===1&&(lM=Date.now(),document.addEventListener("visibilitychange",Ty),window.addEventListener("focus",Ty),TG()),()=>{Kg.delete(e),!Kg.size&&(rm!==null&&clearTimeout(rm),rm=null,document.removeEventListener("visibilitychange",Ty),window.removeEventListener("focus",Ty))}}const ICe=()=>lM,MCe=()=>0;function Oy(){return p.useSyncExternalStore(PCe,ICe,MCe),Date.now()}function _Ce(e){switch(e.trim().toLowerCase()){case"5h":return a("{n} 小时",{n:5});case"weekly":return a("每周");case"monthly":return a("每月");case"daily":return a("每日");default:return e.trim()}}function OG(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=Array.isArray(e.windows)?e.windows:[],n=[];for(const[s,i]of t.entries()){if(!i||typeof i!="object"||Array.isArray(i))continue;const o=i,l=oq(o.label,a),u=typeof o.group=="string"?o.group.trim():"",d=typeof o.window=="string"?o.window.trim().toLowerCase():"",f=_Ce(typeof o.window=="string"?o.window:"")||l;if(!u&&!f)continue;const m=Os(o.remainingPercent),g=m===null?null:Math.max(0,Math.min(100,m)),v=o.unlimited===!0,b=Os(o.remaining)===null&&Os(o.limit)===null&&!v,y=Os(o.resetsAt),k=Os(o.expiresAt);n.push({id:`${typeof o.key=="string"?o.key:[u,f].join("-")}-${s}`,group:u,label:l||[u,f].filter(Boolean).join(" · "),window:f,windowCode:d,view:lq(o,a,Ln),percent:g,remaining:Os(o.remaining),percentText:b&&g!==null?`${Ln(g)}%`:"",tone:v?"ok":g===null?"muted":g<20?"warn":"ok",unlimited:v,resetsAt:y!==null&&y>0&&y<=864e13?y:null,expiresAt:k!==null&&k>0&&k<=864e13?k:null,aside:o.aside===!0})}return n}function DCe(e){const t=new Map;for(const n of e){const s=n.group||n.id;let i=t.get(s);i||(i={id:s,name:n.group,rows:[]},t.set(s,i)),i.rows.push(n)}return[...t.values()]}function LCe(e,t){const n=new Set(t.map(l=>l.label)),s=Array.isArray(e.windows)?e.windows:[],i=new Set(s.flatMap(l=>l&&typeof l=="object"&&typeof l.key=="string"&&l.key?[l.key]:[])),o=Array.isArray(e.wallets)?e.wallets.filter(l=>!l||typeof l!="object"||Array.isArray(l)?!1:l.type!=="quota_window"&&!i.has(l.key??l.type)&&!n.has(l.displayName)):[];return FP({...e,wallets:o,subscription:null},a,Ln)}function $Ce({row:e}){const t=e.percentText||e.view,n=e.percent===null?e.view:a("剩余 {percent}%",{percent:Ln(e.percent)});return r.jsxs("span",{className:`usage-window-item ${e.tone}`,title:`${e.label} · ${n}`,children:[r.jsxs("span",{className:"usage-window-line",children:[r.jsx("span",{className:"usage-window-label",title:e.window,children:e.window}),r.jsx("span",{className:"usage-window-value",title:e.view,children:t})]}),e.percent!==null&&!e.unlimited?r.jsx(kg,{value:e.percent,variant:e.tone==="warn"?"warning":"success",className:"mt-1",trackClassName:"h-[3px]",indicatorClassName:e.tone==="ok"?"opacity-75":void 0,"aria-label":`${e.label} · ${n}`}):null]})}function zCe({entry:e,rows:t,updatedAt:n,creditDetail:s,children:i}){const o=e&&typeof e=="object"?e:{},l=o.subscription&&typeof o.subscription=="object"?o.subscription:{},u=typeof l.planName=="string"?l.planName.trim():"",d=DCe(t),f=t.some(O=>O.group),m=!f&&(t.length===1||t.some(O=>O.percent===null||O.view.length>10)),g=WS(o),v=LCe(o,t),b=t.filter(O=>!O.aside&&!O.unlimited),y=b.some(O=>O.percent!==null?O.percent<20:O.remaining!==null&&O.remaining<=0),k=b.some(O=>O.percent===null&&O.remaining===null)||g.length>0,w=b.length===0&&t.every(O=>!O.unlimited),S=a(w?"额度详情":y?"部分窗口偏低":k?"部分读数未知":"额度充足"),N=y?"warn":k||w?"muted":"ok",C=n?r8(n,a,Date.now()):"",T=n?a("上次成功查询:{time}",{time:ki(n)}):"",P=t.every(O=>O.percentText||O.view==="—")?a("剩余比例"):a("分窗口额度");return r.jsx("span",{className:"usage-cell usage-window-cell",children:r.jsxs("span",{className:"usage-window-quota",children:[r.jsxs("span",{className:"usage-window-top",children:[u?r.jsx(Ee,{variant:aI(u)?"secondary":"brand",shape:"tag",className:"usage-window-plan",title:u,children:Mq(u)}):null,r.jsxs("span",{className:`usage-window-status ${N}`,title:S,children:[r.jsx(Yk,{}),r.jsx("span",{children:S})]})]}),r.jsx("span",{className:`usage-window-grid${f?" grouped":" ungrouped"}${m?" compact":""}`,style:{"--quota-columns":Math.min(3,d.length)},children:d.map(O=>r.jsxs("span",{className:"usage-window-group",children:[O.name?r.jsx("span",{className:"usage-window-group-name",title:O.name,children:O.name}):null,O.rows.map(A=>r.jsx($Ce,{row:A},A.id))]},O.id))}),r.jsxs("span",{className:"usage-window-foot",children:[r.jsxs("span",{className:"usage-window-updated",title:T,children:[r.jsxs("span",{className:"usage-window-caption",children:[P,C?" · ":""]}),C]}),r.jsxs(ui,{children:[r.jsxs(wi,{render:r.jsx(B,{type:"button",size:"xs",variant:"ghost",className:"usage-window-detail"}),children:[a("额度详情"),r.jsx("span",{"aria-hidden":"true",className:"usage-window-caret",children:"⌄"})]}),r.jsxs(di,{align:"end",sideOffset:6,className:"usage-window-pop",children:[r.jsx(qwe,{children:r.jsx(lK,{children:a("窗口额度与时间")})}),r.jsxs("div",{className:"usage-window-pop-body",children:[t.map(O=>r.jsxs("div",{className:"usage-window-reset",children:[r.jsxs("div",{className:"usage-window-reset-head",children:[r.jsx("span",{title:O.label,children:O.label}),r.jsx("span",{className:`usage-window-reset-value ${O.tone}`,children:O.percentText||O.view})]}),O.resetsAt!==null?r.jsx("time",{dateTime:new Date(O.resetsAt).toISOString(),children:a("重置 {date}",{date:ki(O.resetsAt)})}):O.expiresAt===null?r.jsx("span",{className:"usage-window-reset-unknown",children:a("未返回重置时间")}):null,O.expiresAt!==null?r.jsx("time",{dateTime:new Date(O.expiresAt).toISOString(),children:a("到期 {date}",{date:ki(O.expiresAt)})}):null]},O.id)),v.length?r.jsx("div",{className:"usage-window-supplementary",children:v.map(O=>r.jsx("p",{children:O},O))}):null,g.map(O=>r.jsx("p",{className:"usage-window-warning",children:a(O)},O)),r.jsx(Gwe,{className:"usage-window-explanation",children:a("各窗口独立限制请求,不相加为总余额。")})]})]})]})]}),s?r.jsx("span",{className:"usage-window-credit",children:s}):null,i]})})}function BCe(e){return e.windowCode==="daily"||e.windowCode==="5h"}function FCe(e,t){const n=e.filter(f=>!f.aside),s=new Set(n.filter(f=>(f.windowCode==="weekly"||f.windowCode==="monthly")&&!f.unlimited&&(f.percent!==null&&f.percent<=0||f.remaining!==null&&f.remaining<=0)).map(f=>f.group));let i=!1;const o=n.map(f=>{const m=BCe(f),g=m&&s.has(f.group);return g&&(f.unlimited||f.percent!==0)&&(i=!0),{label:f.group?`${f.group} · ${f.window}`:f.window,percent:g?0:f.percent,unlimited:!g&&f.unlimited,shortWindow:m}}),l=o.filter(f=>f.shortWindow&&(f.percent!==null||f.unlimited)),u=(l.length?l:o).flatMap(f=>f.unlimited?[100]:f.percent===null?[]:[f.percent]);if(u.length)return{percent:Math.min(...u),hasShortWindow:l.length>0,adjusted:i,windows:o};if(t===null)return null;const d=Math.max(0,Math.min(100,t));return{percent:d,hasShortWindow:!1,adjusted:!1,windows:[{label:"",percent:d,unlimited:!1}]}}function UCe(e,t="group",n=Date.now()){const s={counted:0,total:e.length,sum:null,unlimited:0,unit:"",failed:0,uncountable:0,pending:0,partial:0,scope:t,additive:!0,ratio:null,expiring:xN([],n)},i=[];let o=0,l=null;for(const u of e){const d=po(u);if(d==null){s.pending++;continue}const f=Og(d);if(f){f.notConfigured||s.failed++;continue}if(typeof d!="object"||Array.isArray(d)){s.uncountable++;continue}if((d.statisticsError||WS(d).length>0)&&s.partial++,sI(u)&&i.push(...RNe(d,n)),d.unlimited===!0){s.unlimited++;continue}const m=Object.prototype.hasOwnProperty.call(d,"totalLeft"),g=Os(m?d.totalLeft:d.available),v=FCe(OG(d),g),b=String(d.unit||a("积分")).trim(),y=g===null&&v===null?null:b==="%"||g===null?"ratio":"additive";if(y===null){s.uncountable++;continue}if(l===null&&(l=y),l!==y){s.uncountable++;continue}if(y==="additive"&&s.unit&&b!==s.unit){s.uncountable++;continue}s.unit||(s.unit=b),s.counted++,y==="additive"?g!==null&&(o+=g):v&&(!s.ratio||v.percent[s.label,RG(s)].filter(Boolean).join(" ")).join(" · ")})),e.ratio.adjusted&&t.push(a("每周或每月额度已耗尽,短周期实际可用额度按 0% 计算;账号明细保留原始读数"))),e.pending&&t.push(a("{n} 个还没查到(未查询或正在查询)",{n:e.pending})),e.failed&&t.push(a("{n} 个查询失败",{n:e.failed})),e.uncountable&&t.push(e.additive?a("{n} 个读数没有绝对数(只给比例或无额度),未计入",{n:e.uncountable}):a("{n} 个读数里没有可用比例,未计入",{n:e.uncountable})),e.partial&&t.push(a("{n} 个读数只读到一半(读数可信但不完整)",{n:e.partial}));const n=vN(e.expiring,a,cM,e.unit===a("积分")?"积分":e.unit);return n.detail&&t.push(n.detail),t.join(";")}function VCe({balance:e}){const t=vN(e.expiring,a,cM,e.unit===a("积分")?"积分":e.unit),n=e.failed+e.partial>0,s=e.additive?e.sum===null&&e.unlimited===0:e.ratio===null&&e.unlimited===0,i=!e.additive&&e.ratio?.windows.some(f=>!f.unlimited&&f.percent!==null&&f.percent<20),o=n||i?"warn":s?"muted":"ok",l=e.unlimited>0?"∞":e.sum===null?"—":cM(e.sum),u=e.additive&&e.unit&&e.unit!=="积分"&&e.unit!==a("积分")?mo(e.unit,a):"",d=e.unlimited===0&&e.counted0?r.jsx("b",{className:"v",children:"∞"}):e.ratio?e.ratio.windows.map((f,m)=>r.jsxs(p.Fragment,{children:[m>0?r.jsx("span",{className:"k","aria-hidden":"true",children:"·"}):null,f.label?r.jsx("span",{className:"k",children:f.label}):null,r.jsx("b",{className:f.percent===null&&!f.unlimited?"k":"v",children:RG(f)})]},`${f.label}-${m}`)):r.jsx("b",{className:"v",children:"—"}),d?r.jsx("span",{className:"n",children:d}):null,t.group?r.jsx("span",{className:"n soon",title:t.detail,children:t.group}):null,n?r.jsx("span",{className:"warn-mark","aria-hidden":!0,children:"⚠"}):null]})}const KCe=["codearts"];function uM(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;const t=Number(e),n=Number.isFinite(t)?t<1e11?t*1e3:t:Date.parse(String(e));return Number.isFinite(n)&&n>0?n:null}function qCe(e,t){if(!KCe.includes(String(e.provider??"")))return[];if(e.hasAccessToken!==!0||e.hasRefreshToken!==!0)return[];const n=uM(e.refreshTokenExpiresAt??e.refreshExpiresAt);if(n===null&&e.refreshTokenLongLived!==!0)return[];const s=uM(e.accessTokenExpiresAt)??uM(t);return n!==null&&s!==null&&n===s?[]:[{label:"Access Token",expiresAt:s,longLived:!1},{label:"Refresh Token",expiresAt:n,longLived:n===null&&e.refreshTokenLongLived===!0}]}function GCe(e,t,n=Date.now()){if(e.longLived)return t("长期有效");if(e.expiresAt===null)return"—";const s=e.expiresAt-n;return s<=0?t("已过期"):s<36e5?t("{n} 分钟后",{n:Math.max(1,Math.round(s/6e4))}):s<48*36e5?t("{n} 小时后",{n:Number((s/36e5).toFixed(1))}):t("{n} 天后",{n:Math.floor(s/864e5)})}let dM=!1;async function PG(e){if(dM){Ct(a("账号正在导出,请稍候"));return}const t=ft().workbuddyDesktop;if(!t?.exportAccountFiles){Ct(a("当前客户端不支持逐账号导出,请更新客户端"),"err");return}dM=!0;try{const n=ft().wbConfirm?.ask,s=a("导出文件包含登录凭证,可直接用于登录。请妥善保管,不要外传或上传到公共位置。")+(e.provider?`

${a("本组每个账号会分别保存为一个 JSON 文件,包含被筛选隐藏的账号。")}`:"")+(e.provider&&t.platform==="web"?`

${a("网页端会逐个下载文件;浏览器提示时请允许本网站下载多个文件。")}`:"");if(!(n?await n({title:e.provider?a("导出本组账号"):a("导出账号"),html:s,okText:a("导出")}):window.confirm(a("导出文件包含登录凭证,可直接用于登录。请妥善保管,不要外传或上传到公共位置。"))))return;const o=await t.exportAccountFiles(e);if(o?.canceled)return;if(!o)throw new Error(a("导出未返回结果"));const l=o.count||0,u=o.failed||[];if(u.length){const d=u[0],f=[d.name||d.id,d.error].filter(Boolean).join(":");Ct(a("已导出 {count} 个账号文件,{failed} 个未导出:{reason}",{count:l,failed:u.length,reason:f}),"err")}else l?Ct(o.downloadStarted?a("已发起 {count} 个账号文件的下载,请在浏览器下载列表确认",{count:l}):a("✅ 已导出 {count} 个账号文件",{count:l}),"ok"):Ct(a("没有可导出的账号"))}catch(n){Ct(a("账号导出失败:{reason}",{reason:dn(n)}),"err")}finally{dM=!1}}function Ry(e,t){return ft().wbIcons?.icon?.(e,t)||""}function WCe({account:e,rank:t,sortActive:n}){const s=a("组内第 {rank} 位",{rank:t});return r.jsxs("div",{className:"order-cell",children:[r.jsx("span",{className:`order-grip${n?" locked":""}`,role:"button",tabIndex:-1,"aria-label":a("拖动调整组内顺序"),"aria-disabled":n||void 0,title:n?wN(zl(tn(e),Nu(tn(e)))):a("按住拖动,调整这个账号在本组内的顺序"),dangerouslySetInnerHTML:{__html:Ry("gripVertical",14)}}),r.jsx("span",{className:"order-rank",title:s,children:`#${t}`})]})}function YCe({group:e,ids:t,collapsed:n}){const[s,i]=p.useState(!1),o="w-full justify-start px-2 font-normal";return r.jsxs(ui,{open:s,onOpenChange:i,children:[r.jsx(wi,{render:r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"grp-iconbtn",title:a("本组操作")}),children:"⋯"}),r.jsx(di,{align:"end",sideOffset:4,className:"w-[196px] p-1.5",children:r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("启用这一组里的全部账号(含被筛选隐藏的)"),onClick:()=>{i(!1),M8(t,!0)},children:a("全部启用({n})",{n:t.length})}),r.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("禁用这一组里的全部账号(含被筛选隐藏的)"),onClick:()=>{i(!1),M8(t,!1)},children:a("全部禁用({n})",{n:t.length})}),r.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("打开批量操作弹窗,并预选这一组的账号(改代理等动作在弹窗里挑参数)"),onClick:()=>{i(!1),OI(t,"proxy")},children:a("批量操作本组")}),r.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("导出本组全部账号,每个账号一个 JSON 文件(含被筛选隐藏的)"),onClick:()=>{i(!1),PG({provider:e.provider})},children:a("导出本组账号")}),r.jsx("div",{className:"my-1 h-px bg-hairline"}),r.jsx(B,{variant:"ghost",size:"sm",className:o,onClick:()=>{i(!1),Jq(e.provider)},children:a(n?"展开这一组":"折叠这一组")})]})})]})}function XCe({group:e,collapsed:t,colSpan:n}){const s=Oy(),{src:i,onError:o}=Qh(e.provider),l=Sn().groupTotalFiltered,u=l?e.accounts:e.members,f=e.members.length>1&&u.length>0&&u.some(Si)?UCe(u,l?"filtered":"group",s):null,m=v=>{v.target?.closest?.("button, a, input, select, label, .queue-grip")||String(window.getSelection?.()||"").length>0||Jq(e.provider)},g=YI(Nu(e.provider));return r.jsx(Jt,{className:"grp-band","data-provider":e.provider,children:r.jsx(Ve,{colSpan:n,onClick:m,children:r.jsxs("div",{className:"grp-band-inner",children:[r.jsx("span",{className:"queue-grip",role:"button",tabIndex:-1,"aria-label":a("拖动调整整组顺序"),title:a("按住拖动,调整这一家的组顺位(整组一起动)"),dangerouslySetInnerHTML:{__html:Ry("gripVertical",14)}}),r.jsx("span",{className:"grp-rank",title:a("组顺位:越小越先用(拖动分组带调整)"),children:a("第 {rank} 顺位",{rank:e.rank})}),r.jsx("span",{className:"grp-logo",children:i?r.jsx("img",{src:i,alt:"",loading:"lazy",onError:o}):r.jsx("span",{className:"grp-logo-txt",children:String(e.label||"?").trim().slice(0,1).toUpperCase()})}),r.jsx("span",{className:"grp-name",children:a(e.label)}),r.jsx("span",{className:"grp-stat",children:a("{total} 个账号 · 启用 {enabled} · 禁用 {disabled}{limited}",{total:e.members.length,enabled:e.enabled,disabled:e.disabled,limited:e.limited>0?a(" · 限流 {n}",{n:e.limited}):""})}),f?r.jsx(VCe,{balance:f}):null,g?r.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"grp-sort-mark",title:a("当前排序规则:{rules}。点击调整",{rules:g}),onClick:()=>E8(e.provider),children:[r.jsx("span",{dangerouslySetInnerHTML:{__html:Ry("sort",10)}}),g]}):null,r.jsx("span",{className:"grp-spacer"}),r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"grp-iconbtn","aria-haspopup":"dialog",title:a("添加 {name} 账号",{name:a(e.label)}),"aria-label":a("添加 {name} 账号",{name:a(e.label)}),onClick:v=>{v.stopPropagation(),ft().wbAddAccountModal?.openProvider?.(e.provider)},children:r.jsx("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",focusable:"false",children:r.jsx("path",{d:"M12 5v14M5 12h14"})})}),r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"grp-iconbtn",title:a("分组设置"),"aria-label":a("分组设置"),onClick:()=>E8(e.provider),dangerouslySetInnerHTML:{__html:Ry("settings",14)}}),r.jsx(YCe,{group:e,ids:e.members.map(v=>v.id),collapsed:t})]})})})}function QCe({account:e}){const t=Ni(e),n=fSe(e);!t&&Jke(e,Wh(e))&&n.push({text:a("Token 限额 · 已禁用"),kind:"bad",title:a("本周期 Token 消耗达到限制器的上限,账号已被自动禁用(窗口重置也不恢复,需手动启用)")});const s=Ci(e)||e.id;return r.jsxs(r.Fragment,{children:[r.jsx(St,{checked:t,"aria-label":a("{action}{who}",{action:a(t?"禁用":"启用"),who:s}),title:a(t?"已启用,点击禁用(不参与转发)":"已禁用,点击启用"),onCheckedChange:i=>{P8(e.id,i)}}),n.length?r.jsx("div",{className:"status-tags",children:n.map(i=>r.jsx(Ee,{shape:"tag",variant:i.kind==="bad"?"destructive":"secondary",title:i.title,children:i.text},i.text))}):null]})}function ZCe({account:e,onClear:t}){const n=oI(e),s=pq(e),i=gq(e);return i?r.jsx(Ee,{variant:"destructive",shape:"tag",title:i,children:a("上游限制 · 已禁用")}):!n.length&&!s?Array.isArray(e.limiterGroups)&&ay(e)?r.jsx(jG,{account:e,onOpen:()=>Mg(e.id)}):eI(e,po(e))?r.jsx(Ee,{variant:"warning",shape:"tag",title:a("余额低于限制器的阈值,转发时会跳过该账号(余额回升自动恢复)"),children:a("余额不足")}):tI(e,Wh(e))?r.jsx(Ee,{variant:"warning",shape:"tag",title:a("本周期 Token 消耗达到限制器的上限,转发时会跳过该账号(窗口重置自动恢复)"),children:a("Token 限额")}):r.jsxs(Ee,{variant:"success",shape:"tag",title:a("当前没有任何模型处于限流中"),children:[r.jsx(Yk,{}),a("正常")]}):r.jsx(SCe,{accountName:Ci(e),rows:kCe(e),count:n.length,cooldown:s,soonest:uI(s?s.resetAt:n[0].resetAt),onClear:t})}function JCe({account:e}){const t=Ga(tn(e)),n=t.edition?Sq(e.expiresAt):Nq(e),s=qCe(e,n);if(s.length)return r.jsx("div",{className:"flex flex-col items-center gap-1",children:s.map(u=>r.jsx(e1e,{row:u},u.label))});if(t.longLived)return r.jsx("span",{title:a("主凭证没有固定到期时刻,到期由网关自动续期或本来就不会过期"),children:a("长期有效")});if(!n)return r.jsx("span",{className:"muted",title:a("记录里没有过期时间"),children:"—"});const i=n-Date.now();if(i<=0)return r.jsx(Ee,{variant:"destructive",shape:"tag",title:a("凭证已过期;能否续期取决于登录方式,本机引用需由原客户端处理"),children:a("已过期")});const o=i<36e5?a("{n} 分钟后",{n:Math.max(1,Math.round(i/6e4))}):i<48*36e5?a("{n} 小时后",{n:(i/36e5).toFixed(1)}):a("{n} 天后",{n:Math.floor(i/24/36e5)}),l=ki(n);return r.jsx("span",{title:l?a("{text}过期({full})",{text:o,full:l}):a("{text}过期",{text:o}),children:o})}function e1e({row:e}){const t=e.expiresAt!==null&&e.expiresAt<=Date.now(),n=e.expiresAt===null?a("记录里没有过期时间"):ki(e.expiresAt);return r.jsxs("div",{className:"flex items-center justify-center gap-1.5 whitespace-nowrap",title:`${e.label} · ${n}`,children:[r.jsx("span",{className:"text-[9px] text-subtle",translate:"no",children:e.label}),t?r.jsx(Ee,{variant:"destructive",shape:"tag",children:a("已过期")}):r.jsx("span",{className:e.expiresAt===null&&!e.longLived?"muted":void 0,children:GCe(e,a)})]})}function t1e({account:e}){const t=T8(e.id);return t<=0?null:r.jsx("span",{className:"conn-count",title:a("{n} 个请求正在使用该账号(含还在下发内容的流式请求)",{n:t}),children:t})}function n1e(e){return!e||typeof e!="object"||Array.isArray(e)?"":fM(e.subscription)}function fM(e){if(!e||typeof e!="object")return"";const t=e,n=[];t.planName&&n.push(a("套餐 {name}",{name:String(t.planName)})),t.status&&n.push(a("状态 {status}",{status:String(t.status)})),t.state&&String(t.state)!=="active"&&n.push(rI(t.state));const s=t.expireAt;if(s!=null&&s!==""){const i=Number(s),o=Number.isFinite(i)&&i>1e11?ki(i):String(s);o&&n.push(a("到期 {time}",{time:o}))}return Number.isFinite(Number(t.remainQuota))&&n.push(a("余量 {value}",{value:Ln(t.remainQuota)})),Number.isFinite(Number(t.totalQuota))&&n.push(a("总量 {value}",{value:Ln(t.totalQuota)})),n.join(" ")}function r1e(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=e.plans;return Array.isArray(t)?t.filter(n=>n&&typeof n=="object"&&String(n.state||"")==="pending"):[]}function s1e(e){const t=e.map(n=>{const s=String(n.name||n.planId||a("套餐")),i=Number(n.pendingUntil??n.startsAt);return Number.isFinite(i)&&i>0?a("{name}({time} 起生效)",{name:s,time:ki(i*1e3)}):s});return a(`已领到、还没到生效时间的套餐(生效后余额列会按它显示): +`+j.stack}}var on=Object.prototype.hasOwnProperty,nn=e.unstable_scheduleCallback,On=e.unstable_cancelCallback,Rn=e.unstable_shouldYield,gt=e.unstable_requestPaint,sn=e.unstable_now,qe=e.unstable_getCurrentPriorityLevel,zt=e.unstable_ImmediatePriority,ht=e.unstable_UserBlockingPriority,Tt=e.unstable_NormalPriority,Ht=e.unstable_LowPriority,jt=e.unstable_IdlePriority,an=e.log,Xt=e.unstable_setDisableYieldValue,gn=null,un=null;function lr(c){if(typeof an=="function"&&Xt(c),un&&typeof un.setStrictMode=="function")try{un.setStrictMode(gn,c)}catch{}}var yn=Math.clz32?Math.clz32:ke,xn=Math.log,jn=Math.LN2;function ke(c){return c>>>=0,c===0?32:31-(xn(c)/jn|0)|0}var Xe=256,Qe=262144,Yt=4194304;function Rt(c){var h=c&42;if(h!==0)return h;switch(c&-c){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 c&-c;case 262144:case 524288:case 1048576:case 2097152:return c&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return c&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return c}}function fn(c,h,x){var j=c.pendingLanes;if(j===0)return 0;var E=0,I=c.suspendedLanes,W=c.pingedLanes;c=c.warmLanes;var ae=j&134217727;return ae!==0?(j=ae&~I,j!==0?E=Rt(j):(W&=ae,W!==0?E=Rt(W):x||(x=ae&~c,x!==0&&(E=Rt(x))))):(ae=j&~I,ae!==0?E=Rt(ae):W!==0?E=Rt(W):x||(x=j&~c,x!==0&&(E=Rt(x)))),E===0?0:h!==0&&h!==E&&(h&I)===0&&(I=E&-E,x=h&-h,I>=x||I===32&&(x&4194048)!==0)?h:E}function At(c,h){return(c.pendingLanes&~(c.suspendedLanes&~c.pingedLanes)&h)===0}function Re(c,h){(h&8)!==0&&(h|=h&32);var x=c.entangledLanes;if(x!==0)for(c=c.entanglements,x&=h;0x;x++)h.push(c);return h}function mn(c,h){c.pendingLanes|=h,h!==268435456&&(c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0)}function vn(c,h,x,j,E,I){var W=c.pendingLanes;c.pendingLanes=x,c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0,c.expiredLanes&=x,c.entangledLanes&=x,c.errorRecoveryDisabledLanes&=x,c.shellSuspendCounter=0;var ae=c.entanglements,me=c.expirationTimes,Oe=c.hiddenUpdates;for(x=W&~x;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),rr=!1;if(bn)try{var qr={};Object.defineProperty(qr,"passive",{get:function(){rr=!0}}),window.addEventListener("test",qr,qr),window.removeEventListener("test",qr,qr)}catch{rr=!1}var Pr=null,Kr=null,Ks=null;function to(){if(Ks)return Ks;var c,h=Kr,x=h.length,j,E="value"in Pr?Pr.value:Pr.textContent,I=E.length;for(c=0;c=M0),nde=" ",rde=!1;function sde(c,h){switch(c){case"keyup":return nit.indexOf(h.keyCode)!==-1;case"keydown":return h.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ade(c){return c=c.detail,typeof c=="object"&&"data"in c?c.data:null}var Hv=!1;function sit(c,h){switch(c){case"compositionend":return ade(h);case"keypress":return h.which!==32?null:(rde=!0,nde);case"textInput":return c=h.data,c===nde&&rde?null:c;default:return null}}function ait(c,h){if(Hv)return c==="compositionend"||!s3&&sde(c,h)?(c=to(),Ks=Kr=Pr=null,Hv=!1,c):null;switch(c){case"paste":return null;case"keypress":if(!(h.ctrlKey||h.altKey||h.metaKey)||h.ctrlKey&&h.altKey){if(h.char&&1"u")return null;try{return c.activeElement||c.body}catch{return c.body}}function hde(c){for(;c&&c.firstChild;)c=c.firstChild;return c}function mde(c,h){var x=hde(c);c=0;for(var j;x;){if(x.nodeType===3){if(j=c+x.textContent.length,c<=h&&j>=h)return{node:x,offset:h-c};c=j}e:{for(;x;){if(x.nextSibling){x=x.nextSibling;break e}x=x.parentNode}x=void 0}x=hde(x)}}function pde(c,h){return c&&h?c===h?!0:c&&c.nodeType===3?!1:h&&h.nodeType===3?pde(c,h.parentNode):"contains"in c?c.contains(h):c.compareDocumentPosition?!!(c.compareDocumentPosition(h)&16):!1:!1}function gde(c){c=c!=null&&c.ownerDocument!=null&&c.ownerDocument.defaultView!=null?c.ownerDocument.defaultView:window;for(var h=o3(c.document);h instanceof c.HTMLIFrameElement;){try{var x=typeof h.contentWindow.location.href=="string"}catch{x=!1}if(x)c=h.contentWindow;else break;h=o3(c.document)}return h}function l3(c){var h=c&&c.nodeName&&c.nodeName.toLowerCase();return h&&(h==="input"&&(c.type==="text"||c.type==="search"||c.type==="tel"||c.type==="url"||c.type==="password")||h==="textarea"||c.contentEditable==="true")}var hit=bn&&"documentMode"in document&&11>=document.documentMode,Vv=null,c3=null,$0=null,u3=!1;function xde(c,h,x){var j=x.window===x?x.document:x.nodeType===9?x:x.ownerDocument;u3||Vv==null||Vv!==o3(j)||(j=Vv,"selectionStart"in j&&l3(j)?j={start:j.selectionStart,end:j.selectionEnd}:(j=(j.ownerDocument&&j.ownerDocument.defaultView||window).getSelection(),j={anchorNode:j.anchorNode,anchorOffset:j.anchorOffset,focusNode:j.focusNode,focusOffset:j.focusOffset}),$0&&L0($0,j)||($0=j,j=aO(c3,"onSelect"),0>=W,E-=W,Zc=1<<32-yn(h)+E|x<hn?(ca=rn,rn=null):ca=rn.sibling;var sr=Ce(Te,rn,Me[hn],Ue);if(sr===null){rn===null&&(rn=ca);break}c&&rn&&sr.alternate===null&&h(Te,rn),we=I(sr,we,hn),Jn===null?Lt=sr:Jn.sibling=sr,Jn=sr,rn=ca}if(hn===Me.length)return x(Te,rn),Fn&&yd(Te,hn),Lt;if(rn===null){for(;hnhn?(ca=rn,rn=null):ca=rn.sibling;var bh=Ce(Te,rn,sr.value,Ue);if(bh===null){rn===null&&(rn=ca);break}c&&rn&&bh.alternate===null&&h(Te,rn),we=I(bh,we,hn),Jn===null?Lt=bh:Jn.sibling=bh,Jn=bh,rn=ca}if(sr.done)return x(Te,rn),Fn&&yd(Te,hn),Lt;if(rn===null){for(;!sr.done;hn++,sr=Me.next())sr=He(Te,sr.value,Ue),sr!==null&&(we=I(sr,we,hn),Jn===null?Lt=sr:Jn.sibling=sr,Jn=sr);return Fn&&yd(Te,hn),Lt}for(rn=j(rn);!sr.done;hn++,sr=Me.next())sr=_e(rn,Te,hn,sr.value,Ue),sr!==null&&(c&&(ca=sr.alternate,ca!==null&&rn.delete(ca.key===null?hn:ca.key)),we=I(sr,we,hn),Jn===null?Lt=sr:Jn.sibling=sr,Jn=sr);return c&&rn.forEach(function(slt){return h(Te,slt)}),Fn&&yd(Te,hn),Lt}function Mn(Te,we,Me,Ue){if(typeof Me=="object"&&Me!==null&&Me.type===L&&Me.key===null&&Me.props.ref===void 0&&(Me=Me.props.children),typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case M:e:{for(var Lt=Me.key;we!==null;){if(we.key===Lt){if(Lt=Me.type,Lt===L){if(we.tag===7){x(Te,we.sibling),Ue=E(we,Me.props.children),eh(Ue,Me),Ue.return=Te,Te=Ue;break e}}else if(we.elementType===Lt||typeof Lt=="object"&&Lt!==null&&Lt.$$typeof===z&&Wp(Lt)===we.type){x(Te,we.sibling),Ue=E(we,Me.props),eh(Ue,Me),Ue.return=Te,Te=Ue;break e}x(Te,we);break}else h(Te,we);we=we.sibling}Me.type===L?(Ue=Fp(Me.props.children,Te.mode,Ue,Me.key),eh(Ue,Me),Ue.return=Te,Te=Ue):(Ue=uT(Me.type,Me.key,Me.props,null,Te.mode,Ue),eh(Ue,Me),Ue.return=Te,Te=Ue)}return W(Te);case _:e:{for(Lt=Me.key;we!==null;){if(we.key===Lt)if(we.tag===4&&we.stateNode.containerInfo===Me.containerInfo&&we.stateNode.implementation===Me.implementation){x(Te,we.sibling),Ue=E(we,Me.children||[]),Ue.return=Te,Te=Ue;break e}else{x(Te,we);break}else h(Te,we);we=we.sibling}Ue=x3(Me,Te.mode,Ue),Ue.return=Te,Te=Ue}return W(Te);case z:return Me=Wp(Me),Mn(Te,we,Me,Ue)}if(de(Me))return bt(Te,we,Me,Ue);if(se(Me)){if(Lt=se(Me),typeof Lt!="function")throw Error(s(150));return Me=Lt.call(Me),Kt(Te,we,Me,Ue)}if(typeof Me.then=="function")return Mn(Te,we,yT(Me),Ue);if(Me.$$typeof===V)return Mn(Te,we,gT(Te,Me),Ue);jT(Te,Me)}return typeof Me=="string"&&Me!==""||typeof Me=="number"||typeof Me=="bigint"?(Me=""+Me,we!==null&&we.tag===6?(x(Te,we.sibling),Ue=E(we,Me),Ue.return=Te,Te=Ue):(x(Te,we),Ue=g3(Me,Te.mode,Ue),Ue.return=Te,Te=Ue),W(Te)):x(Te,we)}return function(Te,we,Me,Ue){try{V0=0;var Lt=Mn(Te,we,Me,Ue);return Jv=null,Lt}catch(rn){if(rn===Zv||rn===vT)throw rn;var Jn=no(29,rn,null,Te.mode);return Jn.lanes=Ue,Jn.return=Te,Jn}}}var Xp=Fde(!0),Ude=Fde(!1),th=!1;function A3(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function E3(c,h){c=c.updateQueue,h.updateQueue===c&&(h.updateQueue={baseState:c.baseState,firstBaseUpdate:c.firstBaseUpdate,lastBaseUpdate:c.lastBaseUpdate,shared:c.shared,callbacks:null})}function nh(c){return{lane:c,tag:0,payload:null,callback:null,next:null}}function rh(c,h,x){var j=c.updateQueue;if(j===null)return null;if(j=j.shared,(gr&2)!==0){var E=j.pending;return E===null?h.next=h:(h.next=E.next,E.next=h),j.pending=h,h=cT(c),Nde(c,null,x),h}return lT(c,j,h,x),cT(c)}function q0(c,h,x){if(h=h.updateQueue,h!==null&&(h=h.shared,(x&4194048)!==0)){var j=h.lanes;j&=c.pendingLanes,x|=j,h.lanes=x,Ns(c,x)}}function T3(c,h){var x=c.updateQueue,j=c.alternate;if(j!==null&&(j=j.updateQueue,x===j)){var E=null,I=null;if(x=x.firstBaseUpdate,x!==null){do{var W={lane:x.lane,tag:x.tag,payload:x.payload,callback:null,next:null};I===null?E=I=W:I=I.next=W,x=x.next}while(x!==null);I===null?E=I=h:I=I.next=h}else E=I=h;x={baseState:j.baseState,firstBaseUpdate:E,lastBaseUpdate:I,shared:j.shared,callbacks:j.callbacks},c.updateQueue=x;return}c=x.lastBaseUpdate,c===null?x.firstBaseUpdate=h:c.next=h,x.lastBaseUpdate=h}var O3=!1;function K0(){if(O3){var c=Qv;if(c!==null)throw c}}function G0(c,h,x,j){O3=!1;var E=c.updateQueue;th=!1;var I=E.firstBaseUpdate,W=E.lastBaseUpdate,ae=E.shared.pending;if(ae!==null){E.shared.pending=null;var me=ae,Oe=me.next;me.next=null,W===null?I=Oe:W.next=Oe,W=me;var $e=c.alternate;$e!==null&&($e=$e.updateQueue,ae=$e.lastBaseUpdate,ae!==W&&(ae===null?$e.firstBaseUpdate=Oe:ae.next=Oe,$e.lastBaseUpdate=me))}if(I!==null){var He=E.baseState;W=0,$e=Oe=me=null,ae=I;do{var Ce=ae.lane&-536870913,_e=Ce!==ae.lane;if(_e?(Zn&Ce)===Ce:(j&Ce)===Ce){Ce!==0&&Ce===Kp&&(O3=!0),$e!==null&&($e=$e.next={lane:0,tag:ae.tag,payload:ae.payload,callback:null,next:null});e:{var bt=c,Kt=ae;Ce=h;var Mn=x;switch(Kt.tag){case 1:if(bt=Kt.payload,typeof bt=="function"){He=bt.call(Mn,He,Ce);break e}He=bt;break e;case 3:bt.flags=bt.flags&-65537|128;case 0:if(bt=Kt.payload,Ce=typeof bt=="function"?bt.call(Mn,He,Ce):bt,Ce==null)break e;He=A({},He,Ce);break e;case 2:th=!0}}Ce=ae.callback,Ce!==null&&(c.flags|=64,_e&&(c.flags|=8192),_e=E.callbacks,_e===null?E.callbacks=[Ce]:_e.push(Ce))}else _e={lane:Ce,tag:ae.tag,payload:ae.payload,callback:ae.callback,next:null},$e===null?(Oe=$e=_e,me=He):$e=$e.next=_e,W|=Ce;if(ae=ae.next,ae===null){if(ae=E.shared.pending,ae===null)break;_e=ae,ae=_e.next,_e.next=null,E.lastBaseUpdate=_e,E.shared.pending=null}}while(!0);$e===null&&(me=He),E.baseState=me,E.firstBaseUpdate=Oe,E.lastBaseUpdate=$e,I===null&&(E.shared.lanes=0),uh|=W,c.lanes=W,c.memoizedState=He}}function Hde(c,h){if(typeof c!="function")throw Error(s(191,c));c.call(h)}function Vde(c,h){var x=c.callbacks;if(x!==null)for(c.callbacks=null,c=0;cI?I:8;var W=ie.T,ae={};ae.types=W!==null?W.types:null,ie.T=ae,X3(c,!1,h,x);try{var me=E(),Oe=ie.S;if(Oe!==null&&Oe(ae,me),me!==null&&typeof me=="object"&&typeof me.then=="function"){var $e=Sit(me,j);Q0(c,h,$e,zo(c))}else Q0(c,h,j,zo(c))}catch(He){Q0(c,h,{then:function(){},status:"rejected",reason:He},zo())}finally{oe.p=I,W!==null&&ae.types!==null&&(W.types=ae.types),ie.T=W}}function Oit(){}function W3(c,h,x,j){if(c.tag!==5)throw Error(s(476));var E=wfe(c).queue;jfe(c,E,h,je,x===null?Oit:function(){return kfe(c),x(j)})}function wfe(c){var h=c.memoizedState;if(h!==null)return h;h={memoizedState:je,baseState:je,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sd,lastRenderedState:je},next:null};var x={};return h.next={memoizedState:x,baseState:x,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sd,lastRenderedState:x},next:null},c.memoizedState=h,c=c.alternate,c!==null&&(c.memoizedState=h),h}function kfe(c){var h=wfe(c);h.next===null&&(h=c.alternate.memoizedState),Q0(c,h.next.queue,{},zo())}function Y3(){return ai(jb)}function Sfe(){return Gs().memoizedState}function Nfe(){return Gs().memoizedState}function Rit(c){for(var h=c.return;h!==null;){switch(h.tag){case 24:case 3:var x=zo();c=nh(x);var j=rh(h,c,x);j!==null&&(io(j,h,x),q0(j,h,x)),h={cache:k3()},c.payload=h;return}h=h.return}}function Pit(c,h,x){var j=zo();x={lane:j,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null},RT(c)?Afe(h,x):(x=m3(c,h,x,j),x!==null&&(io(x,c,j),Efe(x,h,j)))}function Cfe(c,h,x){var j=zo();Q0(c,h,x,j)}function Q0(c,h,x,j){var E={lane:j,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null};if(RT(c))Afe(h,E);else{var I=c.alternate;if(c.lanes===0&&(I===null||I.lanes===0)&&(I=h.lastRenderedReducer,I!==null))try{var W=h.lastRenderedState,ae=I(W,x);if(E.hasEagerState=!0,E.eagerState=ae,Mo(ae,W))return lT(c,h,E,0),Gr===null&&oT(),!1}catch{}if(x=m3(c,h,E,j),x!==null)return io(x,c,j),Efe(x,h,j),!0}return!1}function X3(c,h,x,j){if(j={lane:2,revertLane:B4(),gesture:null,action:j,hasEagerState:!1,eagerState:null,next:null},RT(c)){if(h)throw Error(s(479))}else h=m3(c,x,j,2),h!==null&&io(h,c,2)}function RT(c){var h=c.alternate;return c===In||h!==null&&h===In}function Afe(c,h){eb=ST=!0;var x=c.pending;x===null?h.next=h:(h.next=x.next,x.next=h),c.pending=h}function Efe(c,h,x){if((x&4194048)!==0){var j=h.lanes;j&=c.pendingLanes,x|=j,h.lanes=x,Ns(c,x)}}var PT={readContext:ai,use:AT,useCallback:Ds,useContext:Ds,useEffect:Ds,useImperativeHandle:Ds,useLayoutEffect:Ds,useInsertionEffect:Ds,useMemo:Ds,useReducer:Ds,useRef:Ds,useState:Ds,useDebugValue:Ds,useDeferredValue:Ds,useTransition:Ds,useSyncExternalStore:Ds,useId:Ds,useHostTransitionStatus:Ds,useFormState:Ds,useActionState:Ds,useOptimistic:Ds,useMemoCache:Ds,useCacheRefresh:Ds,useEffectEvent:Ds},Tfe={readContext:ai,use:AT,useCallback:function(c,h){return Mi().memoizedState=[c,h===void 0?null:h],c},useContext:ai,useEffect:ffe,useImperativeHandle:function(c,h,x){x=x!=null?x.concat([c]):null,TT(4194308,4,gfe.bind(null,h,c),x)},useLayoutEffect:function(c,h){return TT(4194308,4,c,h)},useInsertionEffect:function(c,h){TT(4,2,c,h)},useMemo:function(c,h){var x=Mi();h=h===void 0?null:h;var j=c();if(Qp){lr(!0);try{c()}finally{lr(!1)}}return x.memoizedState=[j,h],j},useReducer:function(c,h,x){var j=Mi();if(x!==void 0){var E=x(h);if(Qp){lr(!0);try{x(h)}finally{lr(!1)}}}else E=h;return j.memoizedState=j.baseState=E,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:E},j.queue=c,c=c.dispatch=Pit.bind(null,In,c),[j.memoizedState,c]},useRef:function(c){var h=Mi();return c={current:c},h.memoizedState=c},useState:function(c){c=H3(c);var h=c.queue,x=Cfe.bind(null,In,h);return h.dispatch=x,[c.memoizedState,x]},useDebugValue:K3,useDeferredValue:function(c,h){var x=Mi();return G3(x,c,h)},useTransition:function(){var c=H3(!1);return c=jfe.bind(null,In,c.queue,!0,!1),Mi().memoizedState=c,[!1,c]},useSyncExternalStore:function(c,h,x){var j=In,E=Mi();if(Fn){if(x===void 0)throw Error(s(407));x=x()}else{if(x=h(),Gr===null)throw Error(s(349));(Zn&127)!==0||Xde(j,h,x)}E.memoizedState=x;var I={value:x,getSnapshot:h};return E.queue=I,ffe(Zde.bind(null,j,I,c),[c]),j.flags|=2048,nb(9,{destroy:void 0},Qde.bind(null,j,I,x,h),null),x},useId:function(){var c=Mi(),h=Gr.identifierPrefix;if(Fn){var x=Jc,j=Zc;x=(j&~(1<<32-yn(j)-1)).toString(32)+x,h="_"+h+"R_"+x,x=NT++,0<\/script>",I=I.removeChild(I.firstChild);break;case"select":I=typeof j.is=="string"?W.createElement("select",{is:j.is}):W.createElement("select"),j.multiple?I.multiple=!0:j.size&&(I.size=j.size);break;default:I=typeof j.is=="string"?W.createElement(E,{is:j.is}):W.createElement(E)}}I[Ca]=h,I[si]=j;e:for(W=h.child;W!==null;){if(W.tag===5||W.tag===6)I.appendChild(W.stateNode);else if(W.tag!==4&&W.tag!==27&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===h)break e;for(;W.sibling===null;){if(W.return===null||W.return===h)break e;W=W.return}W.sibling.return=W.return,W=W.sibling}h.stateNode=I;e:switch(ci(I,E,j),E){case"button":case"input":case"select":case"textarea":j=!!j.autoFocus;break e;case"img":j=!0;break e;default:j=!1}j&&Cd(h)}}return Jr(h),h.subtreeFlags&=-33554433,c4(h,h.type,c===null?null:c.memoizedProps,h.pendingProps,x),null;case 6:if(c&&h.stateNode!=null)c.memoizedProps!==j&&Cd(h);else{if(typeof j!="string"&&h.stateNode===null)throw Error(s(166));if(c=pe.current,Xv(h)){if(c=h.stateNode,x=h.memoizedProps,j=null,E=za,E!==null)switch(E.tag){case 27:case 5:j=E.memoizedProps}c[Ca]=h,c=!!(c.nodeValue===x||j!==null&&j.suppressHydrationWarning===!0||Zhe(c.nodeValue,x)),c||Zf(h,!0)}else c=uk(c).createTextNode(j),c[Ca]=h,h.stateNode=c}return Jr(h),null;case 31:if(x=h.memoizedState,c===null||c.memoizedState!==null){if(j=Xv(h),x!==null){if(c===null){if(!j)throw Error(s(318));if(c=h.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(s(557));c[Ca]=h}else Up(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;Jr(h),c=!1}else x=y3(),c!==null&&c.memoizedState!==null&&(c.memoizedState.hydrationErrors=x),c=!0;if(!c)return h.flags&256?(_o(h),h):(_o(h),null);if((h.flags&128)!==0)throw Error(s(558))}return Jr(h),null;case 13:if(j=h.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(E=Xv(h),j!==null&&j.dehydrated!==null){if(c===null){if(!E)throw Error(s(318));if(E=h.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(s(317));E[Ca]=h}else Up(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;Jr(h),E=!1}else E=y3(),c!==null&&c.memoizedState!==null&&(c.memoizedState.hydrationErrors=E),E=!0;if(!E)return h.flags&256?(_o(h),h):(_o(h),null)}return _o(h),(h.flags&128)!==0?(h.lanes=x,h):(x=j!==null,c=c!==null&&c.memoizedState!==null,x&&(j=h.child,E=null,j.alternate!==null&&j.alternate.memoizedState!==null&&j.alternate.memoizedState.cachePool!==null&&(E=j.alternate.memoizedState.cachePool.pool),I=null,j.memoizedState!==null&&j.memoizedState.cachePool!==null&&(I=j.memoizedState.cachePool.pool),I!==E&&(j.flags|=2048)),x!==c&&x&&(h.child.flags|=8192),$T(h,h.updateQueue),Jr(h),null);case 4:return ge(),c===null&&V4(h.stateNode.containerInfo),h.flags|=67108864,Jr(h),null;case 10:return wd(h.type),Jr(h),null;case 19:if(M3(h),j=h.memoizedState,j===null)return Jr(h),null;if(E=(h.flags&128)!==0,I=j.rendering,I===null)if(E)J0(j,!1);else{if(Ls!==0||c!==null&&(c.flags&128)!==0)for(c=h.child;c!==null;){if(I=kT(c),I!==null){for(h.flags|=128,J0(j,!1),c=I.updateQueue,h.updateQueue=c,$T(h,c),h.subtreeFlags=0,c=x,x=h.child;x!==null;)Cde(x,c),x=x.sibling;return W0(h,oi.current&1|2),Fn&&yd(h,j.treeForkCount),h.child}c=c.sibling}j.tail!==null&&sn()>XT&&(h.flags|=128,E=!0,J0(j,!1),h.lanes=4194304)}else{if(!E)if(c=kT(I),c!==null){if(h.flags|=128,E=!0,c=c.updateQueue,h.updateQueue=c,$T(h,c),J0(j,!0),j.tail===null&&j.tailMode!=="collapsed"&&j.tailMode!=="visible"&&!I.alternate&&!Fn)return Jr(h),null}else 2*sn()-j.renderingStartTime>XT&&x!==536870912&&(h.flags|=128,E=!0,J0(j,!1),h.lanes=4194304);j.isBackwards?(I.sibling=h.child,h.child=I):(c=j.last,c!==null?c.sibling=I:h.child=I,j.last=I)}if(j.tail!==null){c=j.tail;e:{for(x=c;x!==null;){if(x.alternate!==null){x=!1;break e}x=x.sibling}x=!0}return j.rendering=c,j.tail=c.sibling,j.renderingStartTime=sn(),c.sibling=null,I=oi.current,I=E?I&1|2:I&1,j.tailMode==="visible"||j.tailMode==="collapsed"||!x||Fn?W0(h,I):(x=I,ye(ii,h),ye(oi,x),yi===null&&(yi=h)),Fn&&yd(h,j.treeForkCount),c}return Jr(h),null;case 22:case 23:return _o(h),P3(),j=h.memoizedState!==null,c!==null?c.memoizedState!==null!==j&&(h.flags|=8192):j&&(h.flags|=8192),j?(x&536870912)!==0&&(h.flags&128)===0&&(Jr(h),h.subtreeFlags&6&&(h.flags|=8192)):Jr(h),x=h.updateQueue,x!==null&&$T(h,x.retryQueue),x=null,c!==null&&c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(x=c.memoizedState.cachePool.pool),j=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(j=h.memoizedState.cachePool.pool),j!==x&&(h.flags|=2048),c!==null&&ce(Gp),null;case 24:return x=null,c!==null&&(x=c.memoizedState.cache),h.memoizedState.cache!==x&&(h.flags|=2048),wd(ia),Jr(h),null;case 25:return null;case 30:return h.flags|=33554432,Jr(h),null}throw Error(s(156,h.tag))}function zit(c,h){switch(v3(h),h.tag){case 1:return c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 3:return wd(ia),ge(),c=h.flags,(c&65536)!==0&&(c&128)===0?(h.flags=c&-65537|128,h):null;case 26:case 27:case 5:return be(h),null;case 31:if(h.memoizedState!==null){if(_o(h),h.alternate===null)throw Error(s(340));Up()}return c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 13:if(_o(h),c=h.memoizedState,c!==null&&c.dehydrated!==null){if(h.alternate===null)throw Error(s(340));Up()}return c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 19:return M3(h),c=h.flags,c&65536?(h.flags=c&-65537|128,c=h.memoizedState,c!==null&&(c.rendering=null,c.tail=null),h.flags|=4,h):null;case 4:return ge(),null;case 10:return wd(h.type),null;case 22:case 23:return _o(h),P3(),c!==null&&ce(Gp),c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 24:return wd(ia),null;case 25:return null;default:return null}}function ehe(c,h){switch(v3(h),h.tag){case 3:wd(ia),ge();break;case 26:case 27:case 5:be(h);break;case 4:ge();break;case 31:h.memoizedState!==null&&_o(h);break;case 13:_o(h);break;case 19:M3(h);break;case 10:wd(h.type);break;case 22:case 23:_o(h),P3(),c!==null&&ce(Gp);break;case 24:wd(ia)}}function ek(c,h){try{var x=h.updateQueue,j=x!==null?x.lastEffect:null;if(j!==null){var E=j.next;x=E;do{if((x.tag&c)===c){j=void 0;var I=x.create,W=x.inst;j=I(),W.destroy=j}x=x.next}while(x!==E)}}catch(ae){Mr(h,h.return,ae)}}function oh(c,h,x){try{var j=h.updateQueue,E=j!==null?j.lastEffect:null;if(E!==null){var I=E.next;j=I;do{if((j.tag&c)===c){var W=j.inst,ae=W.destroy;if(ae!==void 0){W.destroy=void 0,E=h;var me=x,Oe=ae;try{Oe()}catch($e){Mr(E,me,$e)}}}j=j.next}while(j!==I)}}catch($e){Mr(h,h.return,$e)}}function the(c){var h=c.updateQueue;if(h!==null){var x=c.stateNode;try{Vde(h,x)}catch(j){Mr(c,c.return,j)}}}function nhe(c,h,x){x.props=Zp(c.type,c.memoizedProps),x.state=c.memoizedState;try{x.componentWillUnmount()}catch(j){Mr(c,h,j)}}function eu(c,h){try{var x=c.ref;if(x!==null){switch(c.tag){case 26:case 27:case 5:var j=c.stateNode;break;case 30:var E=c.stateNode,I=xd(c.memoizedProps,E);(E.ref===null||E.ref.name!==I)&&(E.ref=cme(I)),j=E.ref;break;case 7:if(c.stateNode===null){var W=new Bo(c);g(c.child,!1,Tot,W,void 0,void 0),c.stateNode=W}j=c.stateNode;break;default:j=c.stateNode}typeof x=="function"?c.refCleanup=x(j):x.current=j}}catch(ae){Mr(c,h,ae)}}function li(c,h){var x=c.ref,j=c.refCleanup;if(x!==null)if(typeof j=="function")try{j()}catch(E){Mr(c,h,E)}finally{c.refCleanup=null,c=c.alternate,c!=null&&(c.refCleanup=null)}else if(typeof x=="function")try{x(null)}catch(E){Mr(c,h,E)}else x.current=null}function zT(c,h){if((c.tag===5||c.tag===27||c.tag===6)&&c.alternate===null&&h!==null)for(var x=0;x title"))),ci(j,h,x),j[Ca]=c,aa(j),h=j;break e;case"link":if(I=Cme("link","href",E).get(h+(x.href||""))){for(W=0;WMn&&(W=Mn,Mn=Kt,Kt=W);var Te=mde(ae,Kt),we=mde(ae,Mn);if(Te&&we&&(_e.rangeCount!==1||_e.anchorNode!==Te.node||_e.anchorOffset!==Te.offset||_e.focusNode!==we.node||_e.focusOffset!==we.offset)){var Me=He.createRange();Me.setStart(Te.node,Te.offset),_e.removeAllRanges(),Kt>Mn?(_e.addRange(Me),_e.extend(we.node,we.offset)):(Me.setEnd(we.node,we.offset),_e.addRange(Me))}}}}for(He=[],_e=ae;_e=_e.parentNode;)_e.nodeType===1&&He.push({element:_e,left:_e.scrollLeft,top:_e.scrollTop});for(typeof ae.focus=="function"&&ae.focus(),ae=0;aex?32:x,ie.T=null,x=O4,O4=null;var I=cc,W=iu;if(Cs=0,ng=cc=null,iu=0,(gr&6)!==0)throw Error(s(331));var ae=gr;if(gr|=4,Nhe(I.current),whe(I,I.current,W,x),gr=ae,ok(0,!1),un&&typeof un.onPostCommitFiberRoot=="function")try{un.onPostCommitFiberRoot(gn,I)}catch{}return!0}finally{oe.p=E,ie.T=j,Bhe(c,h)}}function Fhe(c,h,x){h=wl(x,h),h=J3(c.stateNode,h,2),c=rh(c,h,2),c!==null&&(mn(c,2),ou(c))}function Mr(c,h,x){if(c.tag===3)Fhe(c,c,x);else for(;h!==null;){if(h.tag===3){Fhe(h,c,x);break}else if(h.tag===1){var j=h.stateNode;if(typeof h.type.getDerivedStateFromError=="function"||typeof j.componentDidCatch=="function"&&(dh===null||!dh.has(j))){c=wl(x,c),x=Lfe(2),j=rh(h,x,2),j!==null&&($fe(x,j,h,c),mn(j,2),ou(j));break}}h=h.return}}function L4(c,h,x){var j=c.pingCache;if(j===null){j=c.pingCache=new Hit;var E=new Set;j.set(h,E)}else E=j.get(h),E===void 0&&(E=new Set,j.set(h,E));E.has(x)||(A4=!0,E.add(x),c=Qit.bind(null,c,h,x),h.then(c,c))}function Qit(c,h,x){var j=c.pingCache;j!==null&&j.delete(h),c.pingedLanes|=c.suspendedLanes&x,c.warmLanes&=~x,Gr===c&&(Zn&x)===x&&((Ls===4||Ls===3&&(Zn&62914560)===Zn&&300>sn()-YT)&&(gr&2)===0?hb(c,0):WT|=x,lb===Zn&&(lb=0)),ou(c)}function Uhe(c,h){h===0&&(h=Bt()),c=Bp(c,h),c!==null&&(mn(c,h),ou(c))}function Zit(c){var h=c.memoizedState,x=0;h!==null&&(x=h.retryLane),Uhe(c,x)}function Jit(c,h){var x=0;switch(c.tag){case 31:case 13:var j=c.stateNode,E=c.memoizedState;E!==null&&(x=E.retryLane);break;case 19:j=c.stateNode;break;case 22:j=c.stateNode._retryCache;break;default:throw Error(s(314))}j!==null&&j.delete(h),Uhe(c,x)}function eot(c,h){return nn(c,h)}var pb=null,gb=null,$4=!1,rO=!1,z4=!1,hh=0;function ou(c){c!==gb&&c.next===null&&(gb===null?pb=gb=c:gb=gb.next=c),rO=!0,$4||($4=!0,not())}function ok(c,h){if(!z4&&rO){z4=!0;do for(var x=!1,j=pb;j!==null;){if(c!==0){var E=j.pendingLanes;if(E===0)var I=0;else{var W=j.suspendedLanes,ae=j.pingedLanes;I=(1<<31-yn(42|c)+1)-1,I&=E&~(W&~ae),I=I&201326741?I&201326741|1:I?I|2:0}I!==0&&(x=!0,Khe(j,I))}else I=Zn,I=fn(j,j===Gr?I:0,j.cancelPendingCommit!==null||j.timeoutHandle!==-1),(I&3)===0||At(j,I)||(x=!0,Khe(j,I));j=j.next}while(x);z4=!1}}function tot(){Hhe()}function Hhe(){rO=$4=!1;var c=0;hh!==0&&hot()&&(c=hh);for(var h=sn(),x=null,j=pb;j!==null;){var E=j.next,I=Vhe(j,h);I===0?(j.next=null,x===null?pb=E:x.next=E,E===null&&(gb=x)):(x=j,(c!==0||(I&3)!==0)&&(rO=!0)),j=E}Cs!==0&&Cs!==5||ok(c),hh!==0&&(hh=0)}function Vhe(c,h){for(var x=c.suspendedLanes,j=c.pingedLanes,E=c.expirationTimes,I=c.pendingLanes&-62914561;0ae)break;var $e=me.transferSize,He=me.initiatorType;$e&&Jhe(He)&&(me=me.responseEnd,W+=$e*(melO){Kt.length=bt;break}Me=new Promise(bot.bind(Me)),Kt.push(Me)}}}if(0"u"?null:document;function wme(c,h,x){var j=vb;if(j&&typeof h=="string"&&h){var E=Ii(h);E='link[rel="'+c+'"][href="'+E+'"]',typeof x=="string"&&(E+='[crossorigin="'+x+'"]'),jme.has(E)||(jme.add(E),c={rel:c,crossOrigin:x,href:h},j.querySelector(E)===null&&(h=j.createElement("link"),ci(h,"link",c),aa(h),j.head.appendChild(h)))}}function $ot(c){Ed.D(c),wme("dns-prefetch",c,null)}function zot(c,h){Ed.C(c,h),wme("preconnect",c,h)}function Bot(c,h,x){Ed.L(c,h,x);var j=vb;if(j&&c&&h){var E='link[rel="preload"][as="'+Ii(h)+'"]';h==="image"&&x&&x.imageSrcSet?(E+='[imagesrcset="'+Ii(x.imageSrcSet)+'"]',typeof x.imageSizes=="string"&&(E+='[imagesizes="'+Ii(x.imageSizes)+'"]')):E+='[href="'+Ii(c)+'"]';var I=E;switch(h){case"style":I=bb(c);break;case"script":I=yb(c)}if(!(El.has(I)||(c=A({rel:"preload",href:h==="image"&&x&&x.imageSrcSet?void 0:c,as:h},x),El.set(I,c),j.querySelector(E)!==null||h==="style"&&j.querySelector(fk(I))||h==="script"&&j.querySelector(hk(I))))){var W=j.createElement("link");ci(W,"link",c),h==="style"&&(W[Aa]=!0,W.onload=W.onerror=function(){k0(W)}),aa(W),j.head.appendChild(W)}}}function Fot(c,h){Ed.m(c,h);var x=vb;if(x&&c){var j=h&&typeof h.as=="string"?h.as:"script",E='link[rel="modulepreload"][as="'+Ii(j)+'"][href="'+Ii(c)+'"]',I=E;switch(j){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":I=yb(c)}if(!El.has(I)&&(c=A({rel:"modulepreload",href:c},h),El.set(I,c),x.querySelector(E)===null)){switch(j){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(x.querySelector(hk(I)))return}j=x.createElement("link"),ci(j,"link",c),aa(j),x.head.appendChild(j)}}}function Uot(c,h,x){Ed.S(c,h,x);var j=vb;if(j&&c){var E=Gf(j).hoistableStyles,I=bb(c);h=h||"default";var W=E.get(I);if(!W){var ae={loading:0,preload:null};if(W=j.querySelector(fk(I)))ae.loading=5;else{c=A({rel:"stylesheet",href:c,"data-precedence":h},x),(x=El.get(I))&&iF(c,x);var me=W=j.createElement("link");aa(me),ci(me,"link",c),me._p=new Promise(function(Oe,$e){me.onload=Oe,me.onerror=$e}),me.addEventListener("load",function(){ae.loading|=1}),me.addEventListener("error",function(){ae.loading|=2}),ae.loading|=4,iO(W,h,j)}W={type:"stylesheet",instance:W,count:1,state:ae},E.set(I,W)}}}function Hot(c,h){Ed.X(c,h);var x=vb;if(x&&c){var j=Gf(x).hoistableScripts,E=yb(c),I=j.get(E);I||(I=x.querySelector(hk(E)),I||(c=A({src:c,async:!0},h),(h=El.get(E))&&oF(c,h),I=x.createElement("script"),aa(I),ci(I,"link",c),x.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},j.set(E,I))}}function Vot(c,h){Ed.M(c,h);var x=vb;if(x&&c){var j=Gf(x).hoistableScripts,E=yb(c),I=j.get(E);I||(I=x.querySelector(hk(E)),I||(c=A({src:c,async:!0,type:"module"},h),(h=El.get(E))&&oF(c,h),I=x.createElement("script"),aa(I),ci(I,"link",c),x.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},j.set(E,I))}}function kme(c,h,x,j){var E=(E=pe.current)?dk(E):null;if(!E)throw Error(s(446));switch(c){case"meta":case"title":return null;case"style":return typeof x.precedence=="string"&&typeof x.href=="string"?(x=bb(x.href),h=Gf(E).hoistableStyles,j=h.get(x),j||(j={type:"style",instance:null,count:0,state:null},h.set(x,j)),j):{type:"void",instance:null,count:0,state:null};case"link":if(x.rel==="stylesheet"&&typeof x.href=="string"&&typeof x.precedence=="string"){c=bb(x.href);var I=Gf(E).hoistableStyles,W=I.get(c);if(W||(E=E.ownerDocument||E,W={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},I.set(c,W),(I=E.querySelector(fk(c)))?I._p||(W.instance=I,W.state.loading=5):(I=El.get(c),I||(I={rel:"preload",as:"style",href:x.href,crossOrigin:x.crossOrigin,integrity:x.integrity,media:x.media,hrefLang:x.hrefLang,referrerPolicy:x.referrerPolicy},El.set(c,I)),qot(E,c,I,W.state))),h&&j===null)throw Error(s(528,""));return W}if(h&&j!==null)throw Error(s(529,""));return null;case"script":return h=x.async,x=x.src,typeof x=="string"&&h&&typeof h!="function"&&typeof h!="symbol"?(x=yb(x),h=Gf(E).hoistableScripts,j=h.get(x),j||(j={type:"script",instance:null,count:0,state:null},h.set(x,j)),j):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,c))}}function bb(c){return'href="'+Ii(c)+'"'}function fk(c){return'link[rel="stylesheet"]['+c+"]"}function Sme(c){return A({},c,{"data-precedence":c.precedence,precedence:null})}function qot(c,h,x,j){if(h=c.querySelector('link[rel="preload"][as="style"]['+h+"]")){if(h[Aa]!==!0){j.loading=1;return}}else h=c.createElement("link"),h[Aa]=!0,h.onload=h.onerror=k0.bind(null,h),ci(h,"link",x),aa(h),c.head.appendChild(h);j.preload=h,h.addEventListener("load",function(){return j.loading|=1}),h.addEventListener("error",function(){return j.loading|=2})}function yb(c){return'[src="'+Ii(c)+'"]'}function hk(c){return"script[async]"+c}function Nme(c,h,x){if(h.count++,h.instance===null)switch(h.type){case"style":var j=c.querySelector('style[data-href~="'+Ii(x.href)+'"]');if(j)return h.instance=j,aa(j),j;var E=A({},x,{"data-href":x.href,"data-precedence":x.precedence,href:null,precedence:null});return j=(c.ownerDocument||c).createElement("style"),aa(j),ci(j,"style",E),iO(j,x.precedence,c),h.instance=j;case"stylesheet":E=bb(x.href);var I=c.querySelector(fk(E));if(I)return h.state.loading|=4,h.instance=I,aa(I),I;j=Sme(x),(E=El.get(E))&&iF(j,E),I=(c.ownerDocument||c).createElement("link"),aa(I);var W=I;return W._p=new Promise(function(ae,me){W.onload=ae,W.onerror=me}),ci(I,"link",j),h.state.loading|=4,iO(I,x.precedence,c),h.instance=I;case"script":return I=yb(x.src),(E=c.querySelector(hk(I)))?(h.instance=E,aa(E),E):(j=x,(E=El.get(I))&&(j=A({},x),oF(j,E)),c=c.ownerDocument||c,E=c.createElement("script"),aa(E),ci(E,"link",j),c.head.appendChild(E),h.instance=E);case"void":return null;default:throw Error(s(443,h.type))}else h.type==="stylesheet"&&(h.state.loading&4)===0&&(j=h.instance,h.state.loading|=4,iO(j,x.precedence,c));return h.instance}function iO(c,h,x){for(var j=x.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),E=j.length?j[j.length-1]:null,I=E,W=0;W title"):null)}function Kot(c,h,x){if(x===1||h.itemProp!=null)return!1;switch(c){case"meta":case"title":return!0;case"style":if(typeof h.precedence!="string"||typeof h.href!="string"||h.href==="")break;return!0;case"link":if(typeof h.rel!="string"||typeof h.href!="string"||h.href===""||h.onLoad||h.onError)break;return h.rel==="stylesheet"?(c=h.disabled,typeof h.precedence=="string"&&c==null):!0;case"script":if(h.async&&typeof h.async!="function"&&typeof h.async!="symbol"&&!h.onLoad&&!h.onError&&h.src&&typeof h.src=="string")return!0}return!1}function Ame(c,h){return c==="img"&&h.src!=null&&h.src!==""&&h.onLoad==null&&h.loading!=="lazy"}function Eme(c){return!(c.type==="stylesheet"&&(c.state.loading&3)===0)}function Tme(c){return(c.width||100)*(c.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function Ome(c,h){typeof h.decode=="function"&&(c.imgCount++,h.complete||(c.imgBytes+=Tme(h),c.suspenseyImages.push(h)),c=Yot.bind(c),h.decode().then(c,c))}function Got(c,h,x,j){if(x.type==="stylesheet"&&(typeof j.media!="string"||matchMedia(j.media).matches!==!1)&&(x.state.loading&4)===0){if(x.instance===null){var E=bb(j.href),I=h.querySelector(fk(E));if(I){h=I._p,h!==null&&typeof h=="object"&&typeof h.then=="function"&&(c.count++,c=mk.bind(c),h.then(c,c)),x.state.loading|=4,x.instance=I,aa(I);return}I=h.ownerDocument||h,j=Sme(j),(E=El.get(E))&&iF(j,E),I=I.createElement("link"),aa(I);var W=I;W._p=new Promise(function(ae,me){W.onload=ae,W.onerror=me}),ci(I,"link",j),x.instance=I}c.stylesheets===null&&(c.stylesheets=new Map),c.stylesheets.set(x,h),(h=x.state.preload)&&(x.state.loading&3)===0&&(c.count++,x=mk.bind(c),h.addEventListener("load",x),h.addEventListener("error",x))}}var lO=0;function Wot(c,h){return c.stylesheets&&c.count===0&&uO(c,c.stylesheets),0lO?50:800)+h);return c.unsuspend=x,function(){c.unsuspend=null,clearTimeout(j),clearTimeout(E)}}:null}function Rme(c){if(c.count===0&&(c.imgCount===0||!c.waitingForImages)){if(c.stylesheets)uO(c,c.stylesheets);else if(c.unsuspend){var h=c.unsuspend;c.unsuspend=null,h()}}}function mk(){this.count--,Rme(this)}function Yot(){this.imgCount--,Rme(this)}var cO=null;function uO(c,h){c.stylesheets=null,c.unsuspend!==null&&(c.count++,cO=new Map,h.forEach(Xot,c),cO=null,mk.call(c))}function Xot(c,h){if(!(h.state.loading&4)){var x=cO.get(c);if(x)var j=x.get(null);else{x=new Map,cO.set(c,x);for(var E=c.querySelectorAll("link[data-precedence],style[data-precedence]"),I=0;I"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),bO.exports=Qme(),bO.exports}var zn=Zme();const CF=Td({__proto__:null},[zn]);var p=sg();const wO=Td({__proto__:null,default:dc(p)},[p]);function bk(){return typeof window<"u"}function Ha(e){return kO(e)?(e.nodeName||"").toLowerCase():"#document"}function vr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function lu(e){var t;return(t=(kO(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function kO(e){return bk()?e instanceof Node||e instanceof vr(e).Node:!1}function Un(e){return bk()?e instanceof Element||e instanceof vr(e).Element:!1}function br(e){return bk()?e instanceof HTMLElement||e instanceof vr(e).HTMLElement:!1}function ag(e){return!bk()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof vr(e).ShadowRoot}function Cb(e){const{overflow:t,overflowX:n,overflowY:s,display:i}=Li(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&i!=="inline"&&i!=="contents"}function Jme(e){return/^(table|td|th)$/.test(Ha(e))}function yk(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const epe=/transform|translate|scale|rotate|perspective|filter/,tpe=/paint|layout|strict|content/,yh=e=>!!e&&e!=="none";let SO;function NO(e){const t=Un(e)?Li(e):e;return yh(t.transform)||yh(t.translate)||yh(t.scale)||yh(t.rotate)||yh(t.perspective)||!CO()&&(yh(t.backdropFilter)||yh(t.filter))||epe.test(t.willChange||"")||tpe.test(t.contain||"")}function npe(e){let t=Pd(e);for(;br(t)&&!Rd(t);){if(NO(t))return t;if(yk(t))return null;t=Pd(t)}return null}function CO(){return SO==null&&(SO=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),SO}function Rd(e){return/^(html|body|#document)$/.test(Ha(e))}function Li(e){return vr(e).getComputedStyle(e)}function jk(e){return Un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Pd(e){if(Ha(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ag(e)&&e.host||lu(e);return ag(t)?t.host:t}function AF(e){const t=Pd(e);return Rd(t)?(e.ownerDocument||e).body:br(t)&&Cb(t)?t:AF(t)}function ig(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=AF(e),o=i===((s=e.ownerDocument)==null?void 0:s.body),l=vr(i);if(o){const u=AO(l);return t.concat(l,l.visualViewport||[],Cb(i)?i:[],u&&n?ig(u):[])}else return t.concat(i,ig(i,[],n))}function AO(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const EO={...wO},EF={};function $s(e,t){const n=p.useRef(EF);return n.current===EF&&(n.current=e(t)),n}const TO=EO.useInsertionEffect,rpe=TO&&TO!==EO.useLayoutEffect?TO:e=>e();function Ke(e){const t=$s(spe).current;return t.next=e,rpe(t.effect),t.trampoline}function spe(){const e={next:void 0,callback:ape,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function ape(){}const Ge=typeof document<"u"?p.useLayoutEffect:()=>{};function OO(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}const RO={};function oo(e,t,n,s,i){if(!n&&!s&&!i&&!e)return wk(t);let o=wk(e);return t&&(o=Ab(o,t)),n&&(o=Ab(o,n)),s&&(o=Ab(o,s)),i&&(o=Ab(o,i)),o}function ipe(e){if(e.length===0)return RO;if(e.length===1)return wk(e[0]);let t=wk(e[0]);for(let n=1;n=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function PO(e){return typeof e=="function"}function OF(e,t){return PO(e)?e(t):e??RO}function cpe(e,t){return t?e?(...n)=>{const s=n[0];if(IF(s)){const o=s;kk(o);const l=t(...n);return o.baseUIHandlerPrevented||e?.(...n),l}const i=t(...n);return e?.(...n),i}:RF(t):e}function RF(e){return e&&((...t)=>{const n=t[0];return IF(n)&&kk(n),e(...t)})}function kk(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function PF(e,t){return t?e?t+" "+e:t:e}function IF(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function upe(e,t){return function(s,...i){const o=new URL(e);return o.searchParams.set("code",s.toString()),i.forEach(l=>o.searchParams.append("args[]",l)),`${t} error #${s}; visit ${o} for the full message.`}}const Vn=upe("https://base-ui.com/production-error","Base UI"),MF=p.createContext(void 0);function _F(e=!1){const t=p.useContext(MF);if(t===void 0&&!e)throw new Error(Vn(16));return t}function dpe(e){const{focusableWhenDisabled:t,disabled:n,composite:s=!1,tabIndex:i=0,isNativeButton:o}=e,l=s&&t!==!1,u=s&&t===!1;return{props:p.useMemo(()=>{const f={onKeyDown(m){n&&t&&m.key!=="Tab"&&m.preventDefault()}};return s||(f.tabIndex=i,!o&&n&&(f.tabIndex=t?i:-1)),(o&&(t||l)||!o&&n)&&(f["aria-disabled"]=n),o&&(!t||u)&&(f.disabled=n),f},[s,n,t,l,u,o,i])}}function _n(e){return e?.ownerDocument||document}function og(e,t,{detail:n=0}={}){e.dispatchEvent(new(vr(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function $i(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:s=0,native:i=!0,composite:o}=e,l=p.useRef(null),u=_F(!0),d=o??u!==void 0,{props:f}=dpe({focusableWhenDisabled:n,disabled:t,composite:d,tabIndex:s,isNativeButton:i}),m=p.useCallback(()=>{const b=l.current;IO(b)&&d&&t&&f.disabled===void 0&&b.disabled&&(b.disabled=!1)},[t,f.disabled,d]);Ge(m,[m]);const g=p.useCallback((b={})=>{const{onClick:y,onMouseDown:k,onKeyUp:w,onKeyDown:S,onPointerDown:N,...C}=b;return oo({onClick(T){if(t){T.preventDefault();return}y?.(T)},onMouseDown(T){t||k?.(T)},onKeyDown(T){if(t||(kk(T),S?.(T),T.baseUIHandlerPrevented))return;const P=T.target===T.currentTarget,O=T.currentTarget,A=IO(O),R=!i&&fpe(O),M=P&&(i?A:!R),_=T.key==="Enter",L=T.key===" ",$=O.getAttribute("role"),D=$?.startsWith("menuitem")||$==="option"||$==="gridcell";if(P&&d&&L){if(T.defaultPrevented&&D)return;T.preventDefault(),(!i||A)&&(T.preventBaseUIHandler(),og(O,T));return}if(!M||i||!L&&!_){P&&R&&L&&T.preventDefault();return}T.defaultPrevented||(T.preventDefault(),_&&(T.preventBaseUIHandler(),og(O,T)))},onKeyUp(T){if(!t){if(kk(T),w?.(T),T.target===T.currentTarget&&i&&d&&IO(T.currentTarget)&&T.key===" "){T.preventDefault();return}T.baseUIHandlerPrevented||T.target===T.currentTarget&&!i&&!d&&!T.defaultPrevented&&T.key===" "&&(T.preventBaseUIHandler(),og(T.currentTarget,T))}},onPointerDown(T){if(t){T.preventDefault();return}N?.(T)}},i?{type:"button"}:{role:"button"},f,C)},[t,f,d,i]),v=Ke(b=>{l.current=b,m()});return{getButtonProps:g,buttonRef:v}}function IO(e){return br(e)&&e.tagName==="BUTTON"}function fpe(e){return br(e)&&e.tagName==="A"&&!!e.href}function lo(e,t,n,s){const i=$s(DF).current;return mpe(i,e,t,n,s)&&LF(i,[e,t,n,s]),i.callback}function hpe(e){const t=$s(DF).current;return ppe(t,e)&&LF(t,e),t.callback}function DF(){return{callback:null,cleanup:null,refs:[]}}function mpe(e,t,n,s,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==s||e.refs[3]!==i}function ppe(e,t){return e.refs.length!==t.length||e.refs.some((n,s)=>n!==t[s])}function LF(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const s=Array(t.length).fill(null);for(let i=0;i{for(let i=0;i=e}function $F(e){if(!p.isValidElement(e))return null;const t=e,n=t.props;return(MO(19)?n?.ref:t.ref)??null}function Xn(){}const co=Object.freeze([]),yr=Object.freeze({});function xpe(e,t){const n={};for(const s in e){const i=e[s];if(t?.hasOwnProperty(s)){const o=t[s](i);o!=null&&Object.assign(n,o);continue}i===!0?n[`data-${s.toLowerCase()}`]="":i&&(n[`data-${s.toLowerCase()}`]=i.toString())}return n}function vpe(e,t){return typeof e=="function"?e(t):e}function zF(e,t){return typeof e=="function"?e(t):e}function qt(e,t,n={}){let s=t.render;n.enabled!==!1&&(s=wpe(s));const i=bpe(t,n,s);if(n.enabled===!1)return null;const o=n.state??yr;return kpe(e,s,i,o)}function bpe(e,t,n){const{className:s,style:i}=e,{state:o=yr,ref:l,props:u,stateAttributesMapping:d,enabled:f=!0}=t,m=f?vpe(s,o):void 0,g=f?zF(i,o):void 0,v=f?xpe(o,d):yr,b=f&&u?ype(u):void 0,y=f?OO(v,b)??{}:yr;return typeof document<"u"&&(f?Array.isArray(l)?y.ref=hpe([y.ref,$F(n),...l]):y.ref=lo(y.ref,$F(n),l):lo(null,null)),f?(m!==void 0&&(y.className=PF(y.className,m)),g!==void 0&&(y.style=OO(y.style,g)),y):yr}function ype(e){return Array.isArray(e)?ipe(e):oo(void 0,e)}const jpe=Symbol.for("react.lazy");function wpe(e){if(e?.$$typeof!==jpe)return e;const t=p.Children.toArray(e)[0];return p.isValidElement(t)?t:e}function kpe(e,t,n,s){if(t){if(typeof t=="function")return t(n,s);const i=oo(n,t.props);return i.ref=n.ref,p.cloneElement(t,i)}if(e&&typeof e=="string")return Spe(e,n);throw new Error(Vn(8))}function Spe(e,t){return e==="button"?p.createElement("button",{type:"button",...t,key:t.key}):e==="img"?p.createElement("img",{alt:"",...t,key:t.key}):p.createElement(e,t)}const Npe=p.forwardRef(function(t,n){const{render:s,className:i,disabled:o=!1,focusableWhenDisabled:l=!1,nativeButton:u=!0,style:d,...f}=t,{getButtonProps:m,buttonRef:g}=$i({disabled:o,focusableWhenDisabled:l,native:u});return qt("button",t,{state:{disabled:o},ref:[n,g],props:[f,m]})});function BF(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;ttypeof e=="boolean"?`${e}`:e===0?"0":e,HF=FF,jh=(e,t)=>n=>{var s;if(t?.variants==null)return HF(e,n?.class,n?.className);const{variants:i,defaultVariants:o}=t,l=Object.keys(i).map(f=>{const m=n?.[f],g=o?.[f];if(m===null)return null;const v=UF(m)||UF(g);return i[f][v]}),u=n&&Object.entries(n).reduce((f,m)=>{let[g,v]=m;return v===void 0||(f[g]=v),f},{}),d=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((f,m)=>{let{class:g,className:v,...b}=m;return Object.entries(b).every(y=>{let[k,w]=y;return Array.isArray(w)?w.includes({...o,...u}[k]):{...o,...u}[k]===w})?[...f,g,v]:f},[]);return HF(e,l,d,n?.class,n?.className)},Cpe=(e,t)=>{const n=new Array(e.length+t.length);for(let s=0;s({classGroupId:e,validator:t}),VF=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Sk="-",qF=[],Epe="arbitrary..",Tpe=e=>{const t=Rpe(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Ope(l);const u=l.split(Sk),d=u[0]===""&&u.length>1?1:0;return KF(u,d,t)},getConflictingClassGroupIds:(l,u)=>{if(u){const d=s[l],f=n[l];return d?f?Cpe(f,d):d:f||qF}return n[l]||qF}}},KF=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],o=n.nextPart.get(i);if(o){const f=KF(e,t+1,o);if(f)return f}const l=n.validators;if(l===null)return;const u=t===0?e.join(Sk):e.slice(t).join(Sk),d=l.length;for(let f=0;fe.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),s=t.slice(0,n);return s?Epe+s:void 0})(),Rpe=e=>{const{theme:t,classGroups:n}=e;return Ppe(n,t)},Ppe=(e,t)=>{const n=VF();for(const s in e){const i=e[s];_O(i,n,s,t)}return n},_O=(e,t,n,s)=>{const i=e.length;for(let o=0;o{if(typeof e=="string"){Mpe(e,t,n);return}if(typeof e=="function"){_pe(e,t,n,s);return}Dpe(e,t,n,s)},Mpe=(e,t,n)=>{const s=e===""?t:GF(t,e);s.classGroupId=n},_pe=(e,t,n,s)=>{if(Lpe(e)){_O(e(s),t,n,s);return}t.validators===null&&(t.validators=[]),t.validators.push(Ape(n,e))},Dpe=(e,t,n,s)=>{const i=Object.entries(e),o=i.length;for(let l=0;l{let n=e;const s=t.split(Sk),i=s.length;for(let o=0;o"isThemeGetter"in e&&e.isThemeGetter===!0,$pe=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),s=Object.create(null);const i=(o,l)=>{n[o]=l,t++,t>e&&(t=0,s=n,n=Object.create(null))};return{get(o){let l=n[o];if(l!==void 0)return l;if((l=s[o])!==void 0)return i(o,l),l},set(o,l){o in n?n[o]=l:i(o,l)}}},DO="!",WF=":",zpe=[],YF=(e,t,n,s,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:s,isExternal:i}),Bpe=e=>{const{prefix:t,experimentalParseClassName:n}=e;let s=i=>{const o=[];let l=0,u=0,d=0,f;const m=i.length;for(let k=0;kd?f-d:void 0;return YF(o,b,v,y)};if(t){const i=t+WF,o=s;s=l=>l.startsWith(i)?o(l.slice(i.length)):YF(zpe,!1,l,void 0,!0)}if(n){const i=s;s=o=>n({className:o,parseClassName:i})}return s},Fpe=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,s)=>{t.set(n,1e6+s)}),n=>{const s=[];let i=[];for(let o=0;o0&&(i.sort(),s.push(...i),i=[]),s.push(l)):i.push(l)}return i.length>0&&(i.sort(),s.push(...i)),s}},Upe=e=>({cache:$pe(e.cacheSize),parseClassName:Bpe(e),sortModifiers:Fpe(e),postfixLookupClassGroupIds:Hpe(e),...Tpe(e)}),Hpe=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let s=0;s{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:i,sortModifiers:o,postfixLookupClassGroupIds:l}=t,u=[],d=e.trim().split(Vpe);let f="";for(let m=d.length-1;m>=0;m-=1){const g=d[m],{isExternal:v,modifiers:b,hasImportantModifier:y,baseClassName:k,maybePostfixModifierPosition:w}=n(g);if(v){f=g+(f.length>0?" "+f:f);continue}let S=!!w,N;if(S){const A=k.substring(0,w);N=s(A);const R=N&&l[N]?s(k):void 0;R&&R!==N&&(N=R,S=!1)}else N=s(k);if(!N){if(!S){f=g+(f.length>0?" "+f:f);continue}if(N=s(k),!N){f=g+(f.length>0?" "+f:f);continue}S=!1}const C=b.length===0?"":b.length===1?b[0]:o(b).join(":"),T=y?C+DO:C,P=T+N;if(u.indexOf(P)>-1)continue;u.push(P);const O=i(N,S);for(let A=0;A0?" "+f:f)}return f},Kpe=(...e)=>{let t=0,n,s,i="";for(;t{if(typeof e=="string")return e;let t,n="";for(let s=0;s{let n,s,i,o;const l=d=>{const f=t.reduce((m,g)=>g(m),e());return n=Upe(f),s=n.cache.get,i=n.cache.set,o=u,u(d)},u=d=>{const f=s(d);if(f)return f;const m=qpe(d,n);return i(d,m),m};return o=l,(...d)=>o(Kpe(...d))},Wpe=[],ua=e=>{const t=n=>n[e]||Wpe;return t.isThemeGetter=!0,t.themeKey=e,t},QF=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ZF=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ype=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Xpe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Qpe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Zpe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,Jpe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ege=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Id=e=>Ype.test(e),Bn=e=>!!e&&!Number.isNaN(Number(e)),fc=e=>!!e&&Number.isInteger(Number(e)),LO=e=>e.endsWith("%")&&Bn(e.slice(0,-1)),cu=e=>Xpe.test(e),JF=()=>!0,tge=e=>Qpe.test(e)&&!Zpe.test(e),$O=()=>!1,nge=e=>Jpe.test(e),rge=e=>ege.test(e),sge=e=>!$t(e)&&!Ft(e),age=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),ige=e=>Md(e,aU,$O),$t=e=>QF.test(e),wh=e=>Md(e,iU,tge),eU=e=>Md(e,mge,Bn),oge=e=>Md(e,lU,JF),lge=e=>Md(e,oU,$O),tU=e=>Md(e,rU,$O),cge=e=>Md(e,sU,rge),Nk=e=>Md(e,cU,nge),Ft=e=>ZF.test(e),Eb=e=>kh(e,iU),uge=e=>kh(e,oU),nU=e=>kh(e,rU),dge=e=>kh(e,aU),fge=e=>kh(e,sU),Ck=e=>kh(e,cU,!0),hge=e=>kh(e,lU,!0),Md=(e,t,n)=>{const s=QF.exec(e);return s?s[1]?t(s[1]):n(s[2]):!1},kh=(e,t,n=!1)=>{const s=ZF.exec(e);return s?s[1]?t(s[1]):n:!1},rU=e=>e==="position"||e==="percentage",sU=e=>e==="image"||e==="url",aU=e=>e==="length"||e==="size"||e==="bg-size",iU=e=>e==="length",mge=e=>e==="number",oU=e=>e==="family-name",lU=e=>e==="number"||e==="weight",cU=e=>e==="shadow",pge=Gpe(()=>{const e=ua("color"),t=ua("font"),n=ua("text"),s=ua("font-weight"),i=ua("tracking"),o=ua("leading"),l=ua("breakpoint"),u=ua("container"),d=ua("spacing"),f=ua("radius"),m=ua("shadow"),g=ua("inset-shadow"),v=ua("text-shadow"),b=ua("drop-shadow"),y=ua("blur"),k=ua("perspective"),w=ua("aspect"),S=ua("ease"),N=ua("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...T(),Ft,$t],O=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],R=()=>[Ft,$t,d],M=()=>[Id,"full","auto",...R()],_=()=>[fc,"none","subgrid",Ft,$t],L=()=>["auto",{span:["full",fc,Ft,$t]},fc,Ft,$t],$=()=>[fc,"auto",Ft,$t],D=()=>["auto","min","max","fr",Ft,$t],F=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],V=()=>["start","end","center","stretch","center-safe","end-safe"],K=()=>["auto",...R()],Q=()=>[Id,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],X=()=>[u,Id,"screen","full","dvw","lvw","svw","min","max","fit",...R()],U=()=>[Id,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],z=()=>[e,Ft,$t],q=()=>[...T(),nU,tU,{position:[Ft,$t]}],J=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ee=()=>["auto","cover","contain",dge,ige,{size:[Ft,$t]}],H=()=>[LO,Eb,wh],G=()=>["","none","full",f,Ft,$t],Y=()=>["",Bn,Eb,wh],se=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ne=()=>[Bn,LO,nU,tU],de=()=>["","none",y,Ft,$t],ie=()=>["none",Bn,Ft,$t],oe=()=>["none",Bn,Ft,$t],je=()=>[Bn,Ft,$t],te=()=>[Id,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[cu],breakpoint:[cu],color:[JF],container:[cu],"drop-shadow":[cu],ease:["in","out","in-out"],font:[sge],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[cu],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[cu],shadow:[cu],spacing:["px",Bn],text:[cu],"text-shadow":[cu],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Id,$t,Ft,w]}],container:["container"],"container-type":[{"@container":["","normal","size",Ft,$t]}],"container-named":[age],columns:[{columns:[Bn,"auto",$t,Ft,u]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[fc,"auto",Ft,$t]}],basis:[{basis:[Id,"full","auto",u,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Bn,Id,"auto","initial","none",$t]}],grow:[{grow:["",Bn,Ft,$t]}],shrink:[{shrink:["",Bn,Ft,$t]}],order:[{order:[fc,"first","last","none",Ft,$t]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...F(),"normal"]}],"justify-items":[{"justify-items":[...V(),"normal"]}],"justify-self":[{"justify-self":["auto",...V()]}],"align-content":[{content:["normal",...F()]}],"align-items":[{items:[...V(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...V(),{baseline:["","last"]}]}],"place-content":[{"place-content":F()}],"place-items":[{"place-items":[...V(),"baseline"]}],"place-self":[{"place-self":["auto",...V()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:K()}],mx:[{mx:K()}],my:[{my:K()}],ms:[{ms:K()}],me:[{me:K()}],mbs:[{mbs:K()}],mbe:[{mbe:K()}],mt:[{mt:K()}],mr:[{mr:K()}],mb:[{mb:K()}],ml:[{ml:K()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...X()]}],"min-inline-size":[{"min-inline":["auto",...X()]}],"max-inline-size":[{"max-inline":["none",...X()]}],"block-size":[{block:["auto",...U()]}],"min-block-size":[{"min-block":["auto",...U()]}],"max-block-size":[{"max-block":["none",...U()]}],w:[{w:[u,"screen",...Q()]}],"min-w":[{"min-w":[u,"screen","none",...Q()]}],"max-w":[{"max-w":[u,"screen","none","prose",{screen:[l]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh","none",...Q()]}],"font-size":[{text:["base",n,Eb,wh]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,hge,oge]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",LO,$t]}],"font-family":[{font:[uge,lge,t]}],"font-features":[{"font-features":[$t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Ft,$t]}],"line-clamp":[{"line-clamp":[Bn,"none",Ft,eU]}],leading:[{leading:["none",o,...R()]}],"list-image":[{"list-image":["none",Ft,$t]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ft,$t]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:z()}],"text-color":[{text:z()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...se(),"wavy"]}],"text-decoration-thickness":[{decoration:[Bn,"from-font","auto",Ft,wh]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[Bn,"auto",Ft,$t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[fc,Ft,$t]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ft,$t]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ft,$t]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:q()}],"bg-repeat":[{bg:J()}],"bg-size":[{bg:ee()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},fc,Ft,$t],radial:["",Ft,$t],conic:["",fc,Ft,$t]},fge,cge]}],"bg-color":[{bg:z()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:z()}],"gradient-via":[{via:z()}],"gradient-to":[{to:z()}],rounded:[{rounded:G()}],"rounded-s":[{"rounded-s":G()}],"rounded-e":[{"rounded-e":G()}],"rounded-t":[{"rounded-t":G()}],"rounded-r":[{"rounded-r":G()}],"rounded-b":[{"rounded-b":G()}],"rounded-l":[{"rounded-l":G()}],"rounded-ss":[{"rounded-ss":G()}],"rounded-se":[{"rounded-se":G()}],"rounded-ee":[{"rounded-ee":G()}],"rounded-es":[{"rounded-es":G()}],"rounded-tl":[{"rounded-tl":G()}],"rounded-tr":[{"rounded-tr":G()}],"rounded-br":[{"rounded-br":G()}],"rounded-bl":[{"rounded-bl":G()}],"border-w":[{border:Y()}],"border-w-x":[{"border-x":Y()}],"border-w-y":[{"border-y":Y()}],"border-w-s":[{"border-s":Y()}],"border-w-e":[{"border-e":Y()}],"border-w-bs":[{"border-bs":Y()}],"border-w-be":[{"border-be":Y()}],"border-w-t":[{"border-t":Y()}],"border-w-r":[{"border-r":Y()}],"border-w-b":[{"border-b":Y()}],"border-w-l":[{"border-l":Y()}],"divide-x":[{"divide-x":Y()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Y()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...se(),"hidden","none"]}],"divide-style":[{divide:[...se(),"hidden","none"]}],"border-color":[{border:z()}],"border-color-x":[{"border-x":z()}],"border-color-y":[{"border-y":z()}],"border-color-s":[{"border-s":z()}],"border-color-e":[{"border-e":z()}],"border-color-bs":[{"border-bs":z()}],"border-color-be":[{"border-be":z()}],"border-color-t":[{"border-t":z()}],"border-color-r":[{"border-r":z()}],"border-color-b":[{"border-b":z()}],"border-color-l":[{"border-l":z()}],"divide-color":[{divide:z()}],"outline-style":[{outline:[...se(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Bn,Ft,$t]}],"outline-w":[{outline:["",Bn,Eb,wh]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","inner","none",m,Ck,Nk]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",g,Ck,Nk]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:Y()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[Bn,wh]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":Y()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",v,Ck,Nk]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[Bn,Ft,$t]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Bn]}],"mask-image-linear-from-pos":[{"mask-linear-from":ne()}],"mask-image-linear-to-pos":[{"mask-linear-to":ne()}],"mask-image-linear-from-color":[{"mask-linear-from":z()}],"mask-image-linear-to-color":[{"mask-linear-to":z()}],"mask-image-t-from-pos":[{"mask-t-from":ne()}],"mask-image-t-to-pos":[{"mask-t-to":ne()}],"mask-image-t-from-color":[{"mask-t-from":z()}],"mask-image-t-to-color":[{"mask-t-to":z()}],"mask-image-r-from-pos":[{"mask-r-from":ne()}],"mask-image-r-to-pos":[{"mask-r-to":ne()}],"mask-image-r-from-color":[{"mask-r-from":z()}],"mask-image-r-to-color":[{"mask-r-to":z()}],"mask-image-b-from-pos":[{"mask-b-from":ne()}],"mask-image-b-to-pos":[{"mask-b-to":ne()}],"mask-image-b-from-color":[{"mask-b-from":z()}],"mask-image-b-to-color":[{"mask-b-to":z()}],"mask-image-l-from-pos":[{"mask-l-from":ne()}],"mask-image-l-to-pos":[{"mask-l-to":ne()}],"mask-image-l-from-color":[{"mask-l-from":z()}],"mask-image-l-to-color":[{"mask-l-to":z()}],"mask-image-x-from-pos":[{"mask-x-from":ne()}],"mask-image-x-to-pos":[{"mask-x-to":ne()}],"mask-image-x-from-color":[{"mask-x-from":z()}],"mask-image-x-to-color":[{"mask-x-to":z()}],"mask-image-y-from-pos":[{"mask-y-from":ne()}],"mask-image-y-to-pos":[{"mask-y-to":ne()}],"mask-image-y-from-color":[{"mask-y-from":z()}],"mask-image-y-to-color":[{"mask-y-to":z()}],"mask-image-radial":[{"mask-radial":[Ft,$t]}],"mask-image-radial-from-pos":[{"mask-radial-from":ne()}],"mask-image-radial-to-pos":[{"mask-radial-to":ne()}],"mask-image-radial-from-color":[{"mask-radial-from":z()}],"mask-image-radial-to-color":[{"mask-radial-to":z()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[Bn]}],"mask-image-conic-from-pos":[{"mask-conic-from":ne()}],"mask-image-conic-to-pos":[{"mask-conic-to":ne()}],"mask-image-conic-from-color":[{"mask-conic-from":z()}],"mask-image-conic-to-color":[{"mask-conic-to":z()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:q()}],"mask-repeat":[{mask:J()}],"mask-size":[{mask:ee()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ft,$t]}],filter:[{filter:["","none",Ft,$t]}],blur:[{blur:de()}],brightness:[{brightness:[Bn,Ft,$t]}],contrast:[{contrast:[Bn,Ft,$t]}],"drop-shadow":[{"drop-shadow":["","none",b,Ck,Nk]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",Bn,Ft,$t]}],"hue-rotate":[{"hue-rotate":[Bn,Ft,$t]}],invert:[{invert:["",Bn,Ft,$t]}],saturate:[{saturate:[Bn,Ft,$t]}],sepia:[{sepia:["",Bn,Ft,$t]}],"backdrop-filter":[{"backdrop-filter":["","none",Ft,$t]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[Bn,Ft,$t]}],"backdrop-contrast":[{"backdrop-contrast":[Bn,Ft,$t]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Bn,Ft,$t]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Bn,Ft,$t]}],"backdrop-invert":[{"backdrop-invert":["",Bn,Ft,$t]}],"backdrop-opacity":[{"backdrop-opacity":[Bn,Ft,$t]}],"backdrop-saturate":[{"backdrop-saturate":[Bn,Ft,$t]}],"backdrop-sepia":[{"backdrop-sepia":["",Bn,Ft,$t]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ft,$t]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Bn,"initial",Ft,$t]}],ease:[{ease:["linear","initial",S,Ft,$t]}],delay:[{delay:[Bn,Ft,$t]}],animate:[{animate:["none",N,Ft,$t]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[k,Ft,$t]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ie()}],"rotate-x":[{"rotate-x":ie()}],"rotate-y":[{"rotate-y":ie()}],"rotate-z":[{"rotate-z":ie()}],scale:[{scale:oe()}],"scale-x":[{"scale-x":oe()}],"scale-y":[{"scale-y":oe()}],"scale-z":[{"scale-z":oe()}],"scale-3d":["scale-3d"],skew:[{skew:je()}],"skew-x":[{"skew-x":je()}],"skew-y":[{"skew-y":je()}],transform:[{transform:[Ft,$t,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:te()}],"translate-x":[{"translate-x":te()}],"translate-y":[{"translate-y":te()}],"translate-z":[{"translate-z":te()}],"translate-none":["translate-none"],zoom:[{zoom:[fc,Ft,$t]}],accent:[{accent:z()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:z()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ft,$t]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":z()}],"scrollbar-track-color":[{"scrollbar-track":z()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ft,$t]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[Bn,Eb,wh,eU]}],stroke:[{stroke:["none",...z()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Ne(...e){return pge(FF(e))}const gge=jh(["group/button inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap border [font-family:inherit]","font-medium transition-[background-color,border-color,color,transform,box-shadow] duration-150 ease-out","outline-none select-none active:translate-y-[0.5px] focus-visible:shadow-focus","disabled:pointer-events-none disabled:opacity-45 disabled:shadow-none","[&_svg]:pointer-events-none [&_svg]:shrink-0"],{variants:{variant:{default:"border-primary bg-primary font-semibold text-primary-on shadow-glow hover:border-primary-hover hover:bg-primary-hover",outline:"border-control-border bg-control text-foreground shadow-1 hover:border-control-border-hover hover:bg-control-hover",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"border-transparent bg-transparent text-subtle shadow-none hover:bg-control-hover hover:text-foreground",destructive:"border-destructive-bd bg-destructive-soft text-destructive hover:bg-destructive-hover",dashed:"border-dashed border-border-strong bg-transparent text-muted-foreground shadow-none hover:border-primary hover:text-primary-fg",link:"border-transparent bg-transparent text-primary shadow-none underline-offset-4 hover:underline"},size:{default:"h-[30px] rounded-md px-3 text-[12.5px]","2xs":"h-4 rounded-pill px-1.5 text-[10px]",xs:"h-6 rounded-sm px-2 text-[11.5px]",sm:"h-[26px] rounded-sm px-2.5 text-[12px]",lg:"h-9 rounded-md px-4 text-[13px]",icon:"h-[30px] w-[30px] rounded-md p-0","icon-2xs":"size-4 rounded-pill p-0","icon-xs":"size-6 rounded-sm p-0","icon-sm":"h-[26px] w-[26px] rounded-sm p-0","icon-lg":"size-9 rounded-md p-0",touch:"h-[46px] rounded-md px-4 text-[14px]","touch-sm":"h-[34px] rounded-sm px-3 text-[12.5px]","icon-touch":"size-9 rounded-full p-0"}},defaultVariants:{variant:"default",size:"default"}});function B({className:e,variant:t,size:n,...s}){return r.jsx(Npe,{"data-slot":"button",className:Ne(gge({variant:t,size:n}),e),...s})}const xge="data-valid",vge="data-invalid",Ak={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},uU={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},bge={disabled:!1,...uU},hc={valid(e){return e===null?null:e?{[xge]:""}:{[vge]:""}}},dU={invalid:void 0,name:void 0,validityData:{state:Ak,errors:[],error:"",value:"",initialValue:null},setValidityData:Xn,disabled:void 0,setTouched:Xn,setDirty:Xn,setFilled:Xn,setFocused:Xn,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:bge,registerFieldControl:Xn,validation:{getValidationProps:(e,t=yr)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Xn,getInputControl:()=>null,commit:async()=>{},change:Xn}},zO=p.createContext(dU);function uo(e=!0){const t=p.useContext(zO);if(t.setValidityData===Xn&&!e)throw new Error(Vn(28));return t}const fU=p.createContext(void 0);function BO(e=!1){const t=p.useContext(fU);if(!t&&!e)throw new Error(Vn(86));return t}const yge=p.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Xn,validationMode:"onSubmit",submitCountRef:{current:0}});function uu(){return p.useContext(yge)}let hU=0;function jge(e,t="mui"){const[n,s]=p.useState(e),i=e||n;return p.useEffect(()=>{n==null&&(hU+=1,s(`${t}-${hU}`))},[n,t]),i}const mU=EO.useId;function lg(e,t){if(mU!==void 0){const n=mU();return e??(t?`${t}-${n}`:n)}return jge(e,t)}function Ws(e){return lg(e,"base-ui")}const pU=p.createContext({controlId:void 0,registerControlId:Xn,resetControlId:Xn,labelId:void 0,setLabelId:Xn,messageIds:[],setMessageIds:Xn,getDescriptionProps:e=>e});function zi(){return p.useContext(pU)}const wge=function(t){const n=Ws(),[s,i]=p.useState(n),[o,l]=p.useState(),[u,d]=p.useState([]),f=s===void 0?n:s,m=$s(()=>new Map),{messageIds:g}=zi(),v=Ke((w,S)=>{const N=m.current;S===void 0?N.delete(w):N.set(w,S),i(C=>{if(N.size===0)return C;let T;for(const P of N.values()){if(P===C)return C;T===void 0&&(T=P)}return T})}),b=Ke(()=>{m.current.size===0&&i(n)}),y=p.useCallback(w=>{const S=w["aria-describedby"]?w["aria-describedby"].split(" "):[];return S.push(...g,...u),{...w,"aria-describedby":Array.from(new Set(S)).join(" ")||void 0}},[g,u]),k=p.useMemo(()=>({controlId:f,registerControlId:v,resetControlId:b,labelId:o,setLabelId:l,messageIds:u,setMessageIds:d,getDescriptionProps:y}),[f,v,b,o,l,u,d,y]);return r.jsx(pU.Provider,{value:k,children:t.children})};function FO(e,t,n,s=!0,i){const[o,l]=p.useState(),u=Ws(i?`${i}-label`:void 0),d=e??t??o;return Ge(()=>{const f=e||t||!s?void 0:kge(n.current,u);o!==f&&l(f)}),d}function kge(e,t){const n=Sge(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function Sge(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const i=e.nextElementSibling;if(i&&i.htmlFor===n)return i}const s=e.labels;return s&&s[0]}function _d(e={}){const{id:t,enabled:n=!0}=e,{controlId:s,registerControlId:i,resetControlId:o}=zi(),l=Ws(),u=$s(()=>Symbol()),d=p.useRef(!1),f=p.useRef(!1),m=Ke(()=>{!d.current||i===Xn||(d.current=!1,i(u.current,void 0))});return Ge(()=>{if(!n||i===Xn){m();return}let g;if(t!==void 0)f.current=!0,g=t;else if(f.current)g=l;else{o();return}if(g===void 0){m();return}d.current=!0,i(u.current,g)},[t,n,i,o,l,u,m]),Ge(()=>m,[m]),(n?s:void 0)??t??l}function Nge(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:Cge,platform:Age,maxTouchPoints:Ege}=Nge(),Ek=Cge.toLowerCase(),Tb=Age.toLowerCase(),Ob=/^i(os$|p)/.test(Tb)||Tb==="macintel"&&Ege>1,gU="android",Tk=Tb===gU||Ek.includes(gU),xU=!Ob&&Tb.startsWith("mac");Tb.startsWith("win");const Tge=xU||Ob,du=typeof CSS<"u"&&!!CSS.supports?.("-webkit-backdrop-filter:none"),vU=!du&&Ek.includes("firefox");!du&&Ek.includes("chrom");const Oge=Tge,UO=/jsdom|happydom/.test(Ek);function Ys(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Et(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&ag(n)){let s=t;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function Er(e){return"composedPath"in e?e.composedPath()[0]??e.target:e.target}const HO="data-base-ui-focusable",bU="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Sh="ArrowLeft",Nh="ArrowRight",VO="ArrowUp",Ok="ArrowDown",qO="data-starting-style",Rge="data-ending-style",Pge={[qO]:""},Ige={[Rge]:""},Fo={transitionStatus(e){return e==="starting"?Pge:e==="ending"?Ige:null}},Mge="data-open",_ge="data-closed",Dge="data-anchor-hidden",yU="data-popup-open",Lge="data-pressed",$ge={[yU]:""},zge={[yU]:"",[Lge]:""},Bge={[Mge]:""},Fge={[_ge]:""},Uge={[Dge]:""},Rk={open(e){return e?$ge:null}},KO={open(e){return e?zge:null}},cg={open(e){return e?Bge:Fge},anchorHidden(e){return e?Uge:null}},GO={...cg,...Fo},WO="data-trigger-disabled";function Pk(e,t){if(!Un(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute(WO);for(const[,s]of t.entries())if(Et(s,n))return!s.hasAttribute(WO);return!1}function YO(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Hge(e){return e.matches("html,body")}function Ik(e){return br(e)&&e.matches(bU)}function Vge(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${bU}`)!=null}function XO(e){return e?e.getAttribute("role")==="combobox"&&Ik(e):!1}function Mk(e){if(!e||UO)return!0;try{return e.matches(":focus-visible")}catch{return!0}}function _k(e){return e?e.hasAttribute(HO)?e:e.querySelector(`[${HO}]`)||e:null}function Dd(e,t,n=!0){return e.filter(i=>i.parentId===t).flatMap(i=>[...!n||i.context?.open?[i]:[],...Dd(e,i.id,n)])}function jU(e,t){let n=[],s=e.find(i=>i.id===t)?.parentId;for(;s;){const i=e.find(o=>o.id===s);s=i?.parentId,i&&(n=n.concat(i))}return n}function da(e){e.preventDefault(),e.stopPropagation()}function qge(e){return"nativeEvent"in e}function Dk(e){return e.pointerType===""&&e.isTrusted?!0:Tk&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function QO(e){return UO?!1:!Tk&&e.width===0&&e.height===0||Tk&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function Ld(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Kge(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const ug=Math.min,fu=Math.max,Lk=Math.round,Ch=Math.floor,hu=e=>({x:e,y:e}),Gge={left:"right",right:"left",bottom:"top",top:"bottom"};function wU(e,t,n){return fu(e,ug(t,n))}function $d(e,t){return typeof e=="function"?e(t):e}function Uo(e){return e.split("-")[0]}function mu(e){return e.split("-")[1]}function ZO(e){return e==="x"?"y":"x"}function JO(e){return e==="y"?"height":"width"}function Ho(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function eR(e){return ZO(Ho(e))}function Wge(e,t,n){n===void 0&&(n=!1);const s=mu(e),i=eR(e),o=JO(i);let l=i==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(l=$k(l)),[l,$k(l)]}function Yge(e){const t=$k(e);return[tR(e),t,tR(t)]}function tR(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const kU=["left","right"],SU=["right","left"],Xge=["top","bottom"],Qge=["bottom","top"];function Zge(e,t,n){switch(e){case"top":case"bottom":return n?t?SU:kU:t?kU:SU;case"left":case"right":return t?Xge:Qge;default:return[]}}function Jge(e,t,n,s){const i=mu(e);let o=Zge(Uo(e),n==="start",s);return i&&(o=o.map(l=>l+"-"+i),t&&(o=o.concat(o.map(tR)))),o}function $k(e){const t=Uo(e);return Gge[t]+e.slice(t.length)}function exe(e){var t,n,s,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(s=e.bottom)!=null?s:0,left:(i=e.left)!=null?i:0}}function NU(e){return typeof e!="number"?exe(e):{top:e,right:e,bottom:e,left:e}}function Rb(e){const{x:t,y:n,width:s,height:i}=e;return{width:s,height:i,top:n,left:t,right:t+s,bottom:n+i,x:t,y:n}}function zk(e,t,n){return Math.floor(e/t)!==n}function zd(e,t){return t<0||t>=e.length}function Bk(e,t){return Ta(e.current,{disabledIndices:t})}function nR(e,t){return Ta(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Ta(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:s,amount:i=1}={}){let o=t;do o+=n?-i:i;while(o>=0&&o<=e.length-1&&Bd(e,o,s));return o}function txe(e,{event:t,orientation:n,loopFocus:s,onLoop:i,rtl:o,cols:l,disabledIndices:u,minIndex:d,maxIndex:f,prevIndex:m,stopEvent:g=!1}){let v=m,b;if(t.key===VO?b="up":t.key===Ok&&(b="down"),b){const y=[],k=[];let w=!1,S=0;{let M=null,_=-1;e.forEach((L,$)=>{if(L==null)return;S+=1;const D=L.closest('[role="row"]');D&&(w=!0),(D!==M||_===-1)&&(M=D,_+=1,y[_]=[]),y[_].push($),k[$]=_})}let N=!1,C=0;if(w)for(const M of y){const _=M.length;_>C&&(C=_),_!==l&&(N=!0)}const T=N&&S{if(!N||m===-1)return;const _=k[m];if(_==null)return;const L=y[_].indexOf(m),$=M==="up"?-1:1;for(let D=_+$,F=0;F=y.length){if(!s||T)return;if(D=D<0?y.length-1:0,i){const K=Math.min(L,y[D].length-1),Q=y[D][K]??y[D][0],X=i(t,m,Q);D=k[X]??D}}const V=y[D];for(let K=Math.min(L,V.length-1);K>=0;K-=1){const Q=V[K];if(!Bd(e,Q,u))return Q}}},A=M=>{if(!T||m===-1)return;const _=m%P,L=M==="up"?-P:P,$=f-f%P,D=Ch(f/P)+1;for(let F=m-_+L,V=0;Vf){if(!s)return;F=F<0?$:0}const K=Math.min(F+P-1,f);for(let Q=Math.min(F+_,K);Q>=F;Q-=1)if(!Bd(e,Q,u))return Q}};g&&da(t);const R=O(b)??A(b);if(R!==void 0)v=R;else if(m===-1)v=b==="up"?f:d;else if(v=Ta(e,{startingIndex:m,amount:P,decrement:b==="up",disabledIndices:u}),s){if(b==="up"&&(m-PM?L:L-P,i&&(v=i(t,m,v))}b==="down"&&m+P>f&&(v=Ta(e,{startingIndex:m%P-P,amount:P,disabledIndices:u}),i&&(v=i(t,m,v)))}zd(e,v)&&(v=m)}if(n==="both"){const y=Ch(m/l);t.key===(o?Sh:Nh)&&(g&&da(t),m%l!==l-1?(v=Ta(e,{startingIndex:m,disabledIndices:u}),s&&zk(v,l,y)&&(v=Ta(e,{startingIndex:m-m%l-1,disabledIndices:u}),i&&(v=i(t,m,v)))):s&&(v=Ta(e,{startingIndex:m-m%l-1,disabledIndices:u}),i&&(v=i(t,m,v))),zk(v,l,y)&&(v=m)),t.key===(o?Nh:Sh)&&(g&&da(t),m%l!==0?(v=Ta(e,{startingIndex:m,decrement:!0,disabledIndices:u}),s&&zk(v,l,y)&&(v=Ta(e,{startingIndex:m+(l-m%l),decrement:!0,disabledIndices:u}),i&&(v=i(t,m,v)))):s&&(v=Ta(e,{startingIndex:m+(l-m%l),decrement:!0,disabledIndices:u}),i&&(v=i(t,m,v))),zk(v,l,y)&&(v=m));const k=Ch(f/l)===y;zd(e,v)&&(s&&k?(v=t.key===(o?Nh:Sh)?f:Ta(e,{startingIndex:m-m%l-1,disabledIndices:u}),i&&(v=i(t,m,v))):v=m)}return v}function Bd(e,t,n){if(typeof n=="function"?n(t):n?.includes(t)??!1)return!0;const i=e[t];return i?!Fk(i)||i.matches(":disabled")?!0:!n&&(i.hasAttribute("disabled")||i.getAttribute("aria-disabled")==="true"):!1}function nxe(e){return e.visibility==="hidden"||e.visibility==="collapse"}function Fk(e,t=e?Li(e):null){return!e||!e.isConnected||!t||nxe(t)?!1:typeof e.checkVisibility=="function"?e.checkVisibility():t.display!=="none"&&t.display!=="contents"}const rxe='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function sxe(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return ag(n)?n.host:null}function rR(e){for(const t of Array.from(e.children))if(Ha(t)==="summary")return t;return null}function axe(e,t){const n=rR(t);return!!n&&(e===n||Et(n,e))}function CU(e){const t=e?Ha(e):"";return e!=null&&e.matches(rxe)&&(t!=="summary"||e.parentElement!=null&&Ha(e.parentElement)==="details"&&rR(e.parentElement)===e)&&(t!=="details"||rR(e)==null)&&(t!=="input"||e.type!=="hidden")}function AU(e){if(!CU(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=sxe(t)){const n=t!==e,s=Ha(t)==="slot";if(t.hasAttribute("inert")||n&&Ha(t)==="details"&&!t.open&&!axe(e,t)||t.hasAttribute("hidden")||!s&&!ixe(t,n))return!1}return!0}function ixe(e,t){const n=Li(e);return t?n.display!=="none":Fk(e,n)}function EU(e){const t=e.tabIndex;if(t<0){const n=Ha(e);if(n==="details"||n==="audio"||n==="video"||br(e)&&e.isContentEditable)return 0}return t}function sR(e){if(Ha(e)!=="input")return null;const t=e;return t.type==="radio"&&t.name!==""?t:null}function oxe(e,t){const n=sR(e);if(!n)return!0;const s=t.find(i=>{const o=sR(i);return o?.name===n.name&&o.form===n.form&&o.checked});return s?s===n:t.find(i=>{const o=sR(i);return o?.name===n.name&&o.form===n.form})===n}function TU(e){if(br(e)&&Ha(e)==="slot"){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return br(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function OU(e,t){TU(e).forEach(n=>{CU(n)&&t.push(n),OU(n,t)})}function RU(e,t,n){TU(e).forEach(s=>{br(s)&&s.matches(t)&&n.push(s),RU(s,t,n)})}function aR(e){return AU(e)&&EU(e)>=0}function PU(e){const t=[];return OU(e,t),t.filter(AU)}function Pb(e){const t=PU(e);return t.filter(n=>EU(n)>=0&&oxe(n,t))}function IU(e,t){const n=Pb(e),s=n.length;if(s===0)return;const i=Ys(_n(e)),o=n.indexOf(i),l=o===-1?t===1?0:s-1:o+t;return n[l]}function iR(e){return IU(_n(e).body,1)||e}function MU(e){return IU(_n(e).body,-1)||e}function _U(e,t){if(!e)return null;const n=Pb(_n(e).body),s=n.length;if(s===0)return null;const i=n.indexOf(e);if(i===-1)return null;const o=(i+t+s)%s;return n[o]}function lxe(e){return _U(e,1)}function cxe(e){return _U(e,-1)}function dg(e,t){const n=t||e.currentTarget,s=e.relatedTarget;return!s||!Et(n,s)}function uxe(e){Pb(e).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function DU(e){const t=[];RU(e,"[data-tabindex]",t),t.forEach(n=>{const s=n.dataset.tabindex;delete n.dataset.tabindex,s?n.setAttribute("tabindex",s):n.removeAttribute("tabindex")})}function dxe(e,t){const n=Ws(e);return Ge(()=>(t(n),()=>{t(s=>s===n?void 0:s)}),[n,t]),n}function fxe(e={}){const{id:t,fallbackControlId:n,native:s=!1,setLabelId:i,focusControl:o}=e,{controlId:l,setLabelId:u}=zi(),d=Ke(b=>{u(b),i?.(b)}),f=dxe(t,d),m=l??n;function g(b){if(o){o(b,m);return}if(!m)return;const y=_n(b.currentTarget).getElementById(m);br(y)&&hxe(y)}function v(b){Er(b.nativeEvent)?.closest("button,input,select,textarea")||(!b.defaultPrevented&&b.detail>1&&b.preventDefault(),!s&&g(b))}return s?{id:f,htmlFor:m,onMouseDown:v}:{id:f,onClick:v,onPointerDown(b){b.preventDefault()}}}function hxe(e){e.focus({focusVisible:!0})}function Uk(e){p.useEffect(e,co)}const Ib=0;class Bi{constructor(){Cn(this,"currentId",Ib);Cn(this,"clear",()=>{this.currentId!==Ib&&(clearTimeout(this.currentId),this.currentId=Ib)});Cn(this,"disposeEffect",()=>this.clear)}static create(){return new Bi}start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ib,n()},t)}isStarted(){return this.currentId!==Ib}}function fa(){const e=$s(Bi.create).current;return Uk(e.disposeEffect),e}function oR(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}const lR=Object.keys(Ak);function LU(e,t){return e.matches(":disabled")?!1:!t||e.form===t?!0:e.form===null&&!e.hasAttribute("form")}function $U(e,t){let n=null;for(const s of e.keys())if(LU(s,t)){if(!s.validity.valid)return s;n??(n=s)}return n}function zU(e){return{...Ak,valid:!e,customError:e}}function cR(e){return e&&e.validationMessage?[e.validationMessage]:[]}function mxe(e){const{elementRef:t,formRef:n}=uu(),{setValidityData:s,validate:i,validityData:o,validationDebounceTime:l,invalid:u,markedDirtyRef:d,state:f,shouldValidateOnChange:m,validationMode:g,registeredFieldIdRef:v}=e,{controlId:b,getDescriptionProps:y}=zi(),k=fa(),w=p.useRef(null),S=$s(()=>new Map).current,N=p.useRef(0),C=p.useRef(null),T=p.useCallback((M,_)=>(S.set(M,_),()=>{S.delete(M)}),[S]),P=Ke(()=>{const M=$U(S,t.current);return M&&S.get(M)?.controlRef.current||null}),O=Ke(async(M,_=!1)=>{N.current+=1;const L=N.current;function $(H,G=u){const Y=v.current??b;if(Y==null)return;const se=n.current.fields.get(Y);if(!se)return;const re=oR(H,G);n.current.fields.set(Y,{...se,validityData:re})}function D(H,G){const Y=H.valid===!1?G:[];return{value:M,state:H,error:Y[0]??"",errors:Y,initialValue:o.initialValue}}function F(H,G){const Y=H.validity.customError?H.validationMessage:"",se=G.replace(/\r\n?/g,` +`);H.setCustomValidity(se),C.current=[H,se,Y]}function V(){const H=C.current;C.current=null,H&&(!H[0].willValidate||H[0].validationMessage===H[1])&&H[0].setCustomValidity(H[2])}function K(H,G,Y){const se=D(H,G);$(se,Y),s(se)}function Q(H){const G=lR.reduce((se,re)=>(se[re]=H.validity[re],se),{});let Y=!1;for(const se of lR)if(se!=="valid"){if(se==="valueMissing"&&G[se])Y=!0;else if(G[se])return G}return Y&&!d.current&&(G.valid=!0,G.valueMissing=!1),G}function X(){return S.size>0?$U(S,t.current):w.current}let U=X();function z(){return U=X(),U?.willValidate?Q(U):zU(!1)}if(_){if(f.valid!==!1||!U)return;if(!U.validity.valueMissing){V();const H=X(),G=H?.validity.customError?cR(H):[];K(zU(G.length>0),G,!1);return}for(const H of lR)if(H!=="valid"&&H!=="valueMissing"&&H!=="customError"&&U.validity[H])return}k.clear(),V();let q=z(),J=cR(U);const ee=m();if(J.length===0||ee){const H=Array.from(n.current.fields.values()).reduce((se,re)=>(re.name&&(se[re.name]=re.getValue()),se),{}),G=i(M,H);let Y;if(typeof G=="object"&&G!==null&&"then"in G){if(q.valid===!1?K(q,J):(g==="onSubmit"||!o.state.customError)&&(q.valid=null,K(q,J)),Y=await G,L!==N.current)return;q=z()}else Y=G;J=Y?[].concat(Y).filter(Boolean):[],J.length>0?(q.valid=!1,q.customError=!0,U?.willValidate&&F(U,J.join(` +`))):J=cR(U)}K(q,J)}),A=Ke((M,_=!1)=>{if(k.clear(),N.current+=1,_)return;const L=m();L&&M!==""&&l?k.start(l,()=>{O(M)}):O(M,!L)}),R=p.useCallback((M,_={})=>oo(y(_),f.valid===!1&&!f.disabled&&!M?{"aria-invalid":!0}:yr),[y,f.disabled,f.valid]);return p.useMemo(()=>({getValidationProps:R,inputRef:w,registeredInputs:S,registerInput:T,getInputControl:P,commit:O,change:A}),[R,S,T,P,O,A])}function pxe(e){const{change:t,commit:n,invalid:s,markedDirtyRef:i,name:o,setRegisteredFieldName:l,registeredFieldIdRef:u,setValidityData:d,validityData:f}=e,{formRef:m}=uu(),g=p.useRef(null),v=p.useRef(null),b=p.useRef(!1),y=Ke(()=>{const P=v.current;if(P)return P.getValue?P.getValue():P.value});function k(P){return P.value===void 0?y():P.value}const w=Ke(()=>{const P=v.current;if(i.current=!0,!P){n(f.value);return}n(k(P))});function S(){const P=v.current;!P||!P.id||m.current.fields.set(P.id,{getValue:y,name:o??P.name,controlRef:P.controlRef,validityData:oR(f,s),validate:w})}function N(P=v.current?.id){P&&m.current.fields.delete(P)}function C(P){if(b.current)return;b.current=!0;const O=k(P);d(A=>A.initialValue===O?A:{...A,initialValue:O})}Ge(()=>{const P=v.current;!P||!P.id||(l(o?void 0:P.name),m.current.fields.set(P.id,{getValue:y,name:o??P.name,controlRef:P.controlRef,validityData:oR(f,s),validate:w}))},[m,y,s,o,l,w,f]),Ge(()=>{const P=m.current.fields;return()=>{const O=v.current?.id;O&&P.delete(O)}},[m]);const T=Ke((P,O)=>{if(!O){g.current===P&&(g.current=null,t(void 0,!0),N(),v.current=null,l(void 0),u.current=void 0);return}const A=v.current?.id,R=g.current;R&&R!==P&&t(void 0,!0),g.current=P,v.current=O,o||l(O.name),u.current=O.id,A&&A!==O.id&&N(A),C(O),S()});return[w,T]}const gxe=p.forwardRef(function(t,n){const{errors:s,validationMode:i,submitCountRef:o}=uu(),{render:l,className:u,validate:d,validationDebounceTime:f=0,validationMode:m=i,name:g,disabled:v=!1,invalid:b,dirty:y,touched:k,actionsRef:w,style:S,...N}=t,C=BO(!0)?.disabled,T=Ke(d||(()=>null)),P=C||v,[O,A]=p.useState(!1),[R,M]=p.useState(!1),[_,L]=p.useState(!1),[$,D]=p.useState(!1),F=y??R,V=k??O,K=p.useRef(F),Q=p.useRef(void 0),[X,U]=p.useState(),z=g??X;Ge(()=>{y!==void 0&&(K.current=y)},[y]);const q=Ke(he=>{y===void 0&&(he&&(K.current=!0),M(he))}),J=Ke(he=>{k===void 0&&A(he)}),ee=Ke(()=>m==="onChange"||m==="onSubmit"&&o.current>0),H=z&&Object.hasOwn(s,z)?s[z]:null,G=!!(Array.isArray(H)?H.length:H),Y=b===!0||G,[se,re]=p.useState({state:Ak,error:"",errors:[],value:null,initialValue:null}),ne=!Y&&(P?null:se.state.valid),de=p.useMemo(()=>({disabled:P,touched:V,dirty:F,valid:ne,filled:_,focused:$}),[P,V,F,ne,_,$]),ie=mxe({setValidityData:re,validate:T,validityData:se,validationDebounceTime:f,invalid:Y,markedDirtyRef:K,state:de,shouldValidateOnChange:ee,validationMode:m,registeredFieldIdRef:Q}),[oe,je]=pxe({change:ie.change,commit:ie.commit,invalid:Y,markedDirtyRef:K,name:g,setRegisteredFieldName:U,registeredFieldIdRef:Q,setValidityData:re,validityData:se});p.useImperativeHandle(w,()=>({validate:oe}),[oe]);const te=p.useMemo(()=>({invalid:Y,name:z,validityData:se,setValidityData:re,disabled:P,setTouched:J,setDirty:q,setFilled:L,setFocused:D,validationMode:m,shouldValidateOnChange:ee,state:de,registerFieldControl:je,validation:ie}),[Y,z,se,P,J,q,L,D,m,ee,de,je,ie]),le=qt("div",t,{ref:n,state:de,props:N,stateAttributesMapping:hc});return r.jsx(zO.Provider,{value:te,children:le})}),xxe=p.forwardRef(function(t,n){return r.jsx(wge,{children:r.jsx(gxe,{...t,ref:n})})}),vxe=p.createContext({disabled:!1});function Hk(){return p.useContext(vxe)}const bxe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,nativeLabel:u=!0,...d}=t,f=uo(!1),m=Hk(),{labelId:g}=zi(),v={...f.state,disabled:f.disabled||m.disabled},b=p.useRef(null),y=fxe({id:g??l,native:u});return qt("label",t,{ref:[n,b],state:v,props:[y,d],stateAttributesMapping:hc})}),Vk=null;class yxe{constructor(){Cn(this,"callbacks",[]);Cn(this,"callbacksCount",0);Cn(this,"nextId",1);Cn(this,"startId",1);Cn(this,"isScheduled",!1);Cn(this,"tick",t=>{this.isScheduled=!1;const n=this.callbacks,s=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,s>0)for(let i=0;i=this.callbacks.length||this.callbacks[n]!==null&&(this.callbacks[n]=null,this.callbacksCount-=1)}}let qk=new yxe;class Fi{constructor(){Cn(this,"currentId",Vk);Cn(this,"cancel",()=>{this.currentId!==Vk&&(qk.cancel(this.currentId),this.currentId=Vk)});Cn(this,"disposeEffect",()=>this.cancel)}static create(){return new Fi}static request(t){return qk.request(t)}static cancel(t){return qk.cancel(t)}request(t){this.cancel(),this.currentId=qk.request(()=>{this.currentId=Vk,t()})}}function fg(){const e=$s(Fi.create).current;return Uk(e.disposeEffect),e}function pu(e){return e==null?e:"current"in e?e.current:e}let Kk=null;function jxe(e){if(!Kk){const t=[];Kk=t,queueMicrotask(()=>{Kk=null,xr.flushSync(()=>{for(const n of t)n()})})}Kk.push(e)}function uR(e,t=!1,n=!1){const s=fg();return Ke((i,o=null)=>{s.cancel();const l=pu(e);if(l==null)return;const u=l,d=()=>{if(!n){xr.flushSync(i);return}jxe(()=>{o?.aborted||i()})};if(typeof u.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function f(){Promise.all(u.getAnimations().map(m=>m.finished)).then(()=>{o?.aborted||d()},()=>{if(o?.aborted)return;if(u.getAnimations().some(g=>g.pending||g.playState!=="finished")){f();return}d()})}if(t){const m=qO;if(!u.hasAttribute(m)){s.request(f);return}const g=new MutationObserver(()=>{u.hasAttribute(m)||(g.disconnect(),f())});g.observe(u,{attributes:!0,attributeFilter:[m]}),o?.addEventListener("abort",()=>g.disconnect(),{once:!0});return}s.request(f)})}function ji(e){const{enabled:t=!0,open:n,ref:s,batch:i=!1,onComplete:o}=e,l=Ke(o),u=uR(s,n,i);p.useEffect(()=>{if(!t)return;const d=new AbortController;return u(l,d.signal),()=>{d.abort()}},[t,n,l,u])}function gu(e,t=!1,n=!1,s=!1){const[i,o]=p.useState(e&&t?"idle":void 0),[l,u]=p.useState(e&&!s);return e&&!l&&(u(!0),o("starting")),!e&&l&&i!=="ending"&&!n&&o("ending"),!e&&!l&&i==="ending"&&o(void 0),Ge(()=>{if(!e&&l&&i!=="ending"&&n){const d=Fi.request(()=>{o("ending")});return()=>{Fi.cancel(d)}}},[e,l,i,n]),Ge(()=>{if(!e||t)return;const d=Fi.request(()=>{o(void 0)});return()=>{Fi.cancel(d)}},[t,e]),Ge(()=>{if(!e||!t)return;e&&l&&i!=="idle"&&o("starting");const d=Fi.request(()=>{o("idle")});return()=>{Fi.cancel(d)}},[t,e,l,i]),{mounted:l,setMounted:u,transitionStatus:i}}const wxe=p.forwardRef(function(t,n){const{render:s,id:i,className:o,style:l,...u}=t,d=Ws(i),f=uo(!1),m=Hk(),{setMessageIds:g}=zi(),v={...f.state,disabled:f.disabled||m.disabled};return Ge(()=>{if(d)return g(y=>y.concat(d)),()=>{g(y=>y.filter(k=>k!==d))}},[d,g]),qt("p",t,{ref:n,state:v,props:[{id:d},u],stateAttributesMapping:hc})});function Tl({controlled:e,default:t,name:n,state:s="value"}){const{current:i}=p.useRef(e!==void 0),[o,l]=p.useState(t),u=i&&e!==void 0?e:o,d=p.useCallback(f=>{i||l(f)},[]);return[u,d]}function hg(e,t,n,s,i=!0,o){const{registerFieldControl:l}=uo(),u=$s(()=>Symbol());Ge(()=>{const d=u.current;if(!i){l(d,void 0);return}l(d,{controlRef:e,getValue:s,id:t,name:o,value:n})},[e,i,s,t,o,l,u,n]),Ge(()=>{const d=u.current;return()=>{l(d,void 0)}},[l,u])}function Vo(e,t){const n=p.useRef(e),s=Ke(t);Ge(()=>{n.current!==e&&s(n.current),n.current=e},[e,s])}const rs="none",xu="trigger-press",Va="trigger-hover",Gk="trigger-focus",Wk="outside-press",Mb="item-press",dR="close-press",_b="input-change",mc="input-clear",kxe="input-press",Fd="focus-out",mg="escape-key",fR="list-navigation",BU="keyboard",FU="pointer",UU="cancel-open",Sxe="disabled",hR="imperative-action",Nxe="window-resize";function Nt(e,t,n,s){let i=!1,o=!1;const l=s??yr;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){o=!0},get isCanceled(){return i},get isPropagationAllowed(){return o},trigger:n,...l}}function Cxe(e,t,n){const s=n??yr;return{reason:e,event:t??new Event("base-ui"),...s}}const Axe=p.forwardRef(function(t,n){const{render:s,className:i,id:o,name:l,value:u,disabled:d=!1,onValueChange:f,defaultValue:m,autoFocus:g=!1,style:v,...b}=t,{state:y,name:k,disabled:w,setTouched:S,setDirty:N,validityData:C,setFocused:T,setFilled:P,validationMode:O,validation:A}=uo(),{clearErrors:R,elementRef:M,submitCountRef:_}=uu(),L=w||d,$=k??l,D={...y,disabled:L},{labelId:F}=zi(),V=_d({id:o}),[K]=Tl({controlled:u,default:m,name:"FieldControl",state:"value"}),Q=u!==void 0,X=Q?K:void 0,U=X==null?void 0:String(X),z=Ke(()=>A.inputRef.current?.value);hg(A.inputRef,V,U,z,!L,l),Ge(()=>{const H=U??A.inputRef.current?.value;H!==void 0&&P(H!=="")},[U,A.inputRef,P]),Vo(U,()=>{U!==void 0&&(R($),N(U!==(C.initialValue??"")),A.change(U))});const q=p.useRef(null),J=fa();return Ge(()=>{g&&q.current===Ys(_n(q.current))&&T(!0)},[g,T]),qt("input",t,{ref:[n,q],state:D,props:[{id:V,disabled:L,name:$,ref:A.inputRef,"aria-labelledby":F,autoFocus:g,...Q?{value:X}:{defaultValue:m},onChange(H){const G=H.currentTarget.value,Y=Nt(rs,H.nativeEvent);f?.(G,Y),!Q&&(N(G!==(C.initialValue??"")),P(G!==""),!H.nativeEvent.defaultPrevented&&!Y.isCanceled&&(R($),A.change(G)))},onFocus(){T(!0)},onBlur(H){if(S(!0),T(!1),O==="onBlur"){const G=H.currentTarget.value;A.commit(G),Q&&queueMicrotask(()=>{const Y=A.inputRef.current?.value;Y!==void 0&&Y!==G&&Y!==(C.initialValue??"")&&A.commit(Y)})}},onKeyDown(H){if(H.currentTarget.tagName==="INPUT"&&H.key==="Enter"){S(!0);const G=H.currentTarget.value,Y=H.currentTarget.form;if(Y&&Y===M.current&&!H.defaultPrevented){const se=H.currentTarget,re=_.current;J.start(0,()=>{_.current===re&&A.commit(se.value)})}else A.commit(G)}}},b,H=>A.getValidationProps(L,H)],stateAttributesMapping:hc})}),Exe=p.forwardRef(function(t,n){return r.jsx(Axe,{ref:n,...t})});function ze({className:e,type:t,ref:n,...s}){return t==="file"||t==="hidden"?r.jsx("input",{ref:n,type:t,"data-slot":"input",className:Ne(e),...s}):r.jsx(Exe,{ref:n,type:t,"data-slot":"input",className:Ne("h-[30px] w-full min-w-0 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] text-foreground outline-none max-[767px]:h-10 max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out","placeholder:text-muted-foreground","hover:border-control-border-hover","focus:border-primary focus:shadow-focus","disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-surface-3 disabled:text-muted-foreground","file:inline-flex file:border-0 file:bg-transparent file:text-foreground",e),...s})}function Xs({className:e,...t}){return r.jsx("textarea",{"data-slot":"textarea",className:Ne("min-h-26 w-full resize-y rounded-md border border-control-border bg-control px-3 py-2.5","font-mono text-[12px] leading-[1.6] text-foreground outline-none max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out","placeholder:text-muted-foreground","hover:border-control-border-hover","focus:border-primary focus:shadow-focus","disabled:cursor-not-allowed disabled:bg-surface-3 disabled:text-muted-foreground",e),...t})}function zs({className:e,...t}){return r.jsx("div",{"data-slot":"input-group",role:"group",className:Ne("group/input-group relative flex h-[30px] w-full min-w-0 items-center rounded-md border border-control-border bg-control max-[767px]:h-10","transition-[border-color,box-shadow] duration-150 ease-out","outline-none","has-[[data-slot=input-group-control]:focus-visible]:border-primary","has-[[data-slot=input-group-control]:focus-visible]:shadow-focus","has-[[data-slot=input-group-control]:hover:not(:focus-visible)]:border-control-border-hover","has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>[data-slot=input-group-control]]:pl-1.5","has-[>[data-align=inline-end]]:[&>[data-slot=input-group-control]]:pr-1.5","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-start]]:[&>[data-slot=input-group-control]]:pb-1.5","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col","has-[>[data-align=block-end]]:[&>[data-slot=input-group-control]]:pt-1.5",e),...t})}const Txe=jh(["flex h-auto cursor-text items-center justify-center gap-1.5 select-none","text-[12px] font-medium text-muted-foreground","group-data-[disabled=true]/input-group:opacity-50"],{variants:{align:{"inline-start":"order-first pl-[9px] has-[>button]:-ml-1","inline-end":"order-last pr-[9px] has-[>button]:-mr-1","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-1.5","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-1.5"}},defaultVariants:{align:"inline-start"}});function As({className:e,align:t="inline-start",...n}){return r.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Ne(Txe({align:t}),e),onClick:s=>{s.target.closest("button")||s.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}const Oxe=jh("flex items-center shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-xs px-1.5",sm:"h-8 gap-1.5 rounded-sm px-2.5","icon-xs":"size-6 rounded-xs p-0","icon-sm":"size-8 rounded-sm p-0"}},defaultVariants:{size:"xs"}});function Db({className:e,type:t="button",variant:n="ghost",size:s="xs",...i}){return r.jsx(B,{type:t,"data-size":s,variant:n,className:Ne(Oxe({size:s}),e),...i})}function Bs({className:e,...t}){return r.jsx(ze,{"data-slot":"input-group-control",className:Ne("flex-1 rounded-none border-0 bg-transparent shadow-none focus:border-0 focus:shadow-none",e),...t})}function Ah(e){return qt(e.defaultTagName??"div",e,e)}const Rxe=jh("inline-flex w-fit shrink-0 items-center justify-center gap-[5px] overflow-hidden whitespace-nowrap border font-semibold",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-destructive-bd bg-destructive-soft text-destructive",outline:"border-control-border bg-control text-subtle",ghost:"border-transparent bg-transparent text-muted-foreground",link:"border-transparent bg-transparent text-primary underline-offset-4 hover:underline",success:"border-success-bd bg-success-soft text-success",warning:"border-warning-bd bg-warning-soft text-warning",info:"border-info-bd bg-info-soft text-info",brand:"border-primary-bd bg-primary-soft text-primary-fg",cn:"border-cn-bd bg-cn-soft text-cn",intl:"border-intl-bd bg-intl-soft text-intl",sensitive:"border-sensitive-bd bg-sensitive-soft text-sensitive"},shape:{pill:"min-h-[21px] rounded-pill px-[9px] py-px text-[11.5px]",tag:"min-h-[19px] rounded-xs px-2 py-0 text-[11px]"}},defaultVariants:{variant:"default",shape:"pill"}});function Ee({className:e,variant:t,shape:n,render:s,...i}){return Ah({render:s,defaultTagName:"span",props:oo({"data-slot":"badge"},i,{className:Ne(Rxe({variant:t,shape:n}),e)})})}function Yk({className:e,...t}){return r.jsx("span",{className:Ne("size-1.5 flex-none rounded-full bg-current",e),...t})}const HU=p.createContext(void 0);function VU(){const e=p.useContext(HU);if(e===void 0)throw new Error(Vn(13));return e}const mR={imageLoadingStatus:()=>null},Pxe=p.forwardRef(function(t,n){const{className:s,render:i,style:o,...l}=t,[u,d]=p.useState("idle"),f={imageLoadingStatus:u},m=p.useMemo(()=>({imageLoadingStatus:u,setImageLoadingStatus:d}),[u,d]),g=qt("span",t,{state:f,ref:n,props:l,stateAttributesMapping:mR});return r.jsx(HU.Provider,{value:m,children:g})});function Ixe(e,{referrerPolicy:t,crossOrigin:n,sizes:s,srcSet:i},o){const l=p.useState("idle"),u=l[1];return Ge(()=>{if(!o)return Xn;if(!e&&!i)return u("error"),Xn;let d=!0;const f=new window.Image,m=g=>()=>{d&&u(g)};return u("loading"),f.onload=m("loaded"),f.onerror=m("error"),t&&(f.referrerPolicy=t),f.crossOrigin=n??null,s&&(f.sizes=s),i&&(f.srcset=i),e&&(f.src=e),f.complete&&u(f.naturalWidth>0?"loaded":"error"),()=>{d=!1}},[o,e,i,s,n,t,u]),l}const Mxe={...mR,...Fo},_xe=p.forwardRef(function(t,n){const{className:s,render:i,onLoadingStatusChange:o,keepMounted:l=!1,style:u,sizes:d,srcSet:f,src:m,...g}=t,{setImageLoadingStatus:v}=VU(),[b,y]=Ixe(m,t,!l),k=b==="loaded",{mounted:w,transitionStatus:S,setMounted:N}=gu(k),C=p.useRef(null),T=p.useRef(!0);Ge(()=>{if(!l)return;const L=T.current;T.current=!1;const $=C.current;if(!$)return;if(!$.complete){y("loading");return}const D=$.naturalWidth>0?"loaded":"error";y(D),D==="loaded"&&L&&N(!0)},[l,m,f,d,g.crossOrigin,g.referrerPolicy,i,y,N]);const P=l?{"data-loading":b==="loading"?"":void 0,"data-error":b==="error"?"":void 0,"aria-hidden":b!=="loaded"||void 0,onLoad(){y("loaded")},onError(){y("error")}}:void 0,O=Ke(L=>{o?.(L),v(L)});Ge(()=>{b!=="idle"&&O(b)},[b,O]),Ge(()=>()=>v("idle"),[v]),ji({enabled:!k,open:k,ref:C,onComplete(){k||N(!1)}});const A={imageLoadingStatus:b,transitionStatus:l&&S==="ending"?void 0:S},R=l||w,M={};d!==void 0&&(M.sizes=d),f!==void 0&&(M.srcSet=f),m!==void 0&&(M.src=m);const _=qt("img",t,{state:A,ref:[n,C],props:[P,g,M],stateAttributesMapping:Mxe,enabled:R});return R?_:null}),Dxe=p.forwardRef(function(t,n){const{className:s,render:i,delay:o=0,style:l,...u}=t,{imageLoadingStatus:d}=VU(),[f,m]=p.useState(o===0),g=fa();return p.useEffect(()=>(o>0?g.start(o,()=>m(!0)):m(!0),g.clear),[g,o]),qt("span",t,{state:{imageLoadingStatus:d},ref:n,props:u,stateAttributesMapping:mR,enabled:d!=="loaded"&&(o===0||f)})});function qU({className:e,...t}){return r.jsx(Pxe,{"data-slot":"avatar",className:n=>Ne("relative inline-flex size-8 shrink-0 overflow-hidden rounded-full text-foreground",typeof e=="function"?e(n):e),...t})}function KU({className:e,...t}){return r.jsx(_xe,{"data-slot":"avatar-image",className:n=>Ne("absolute inset-0 block size-full object-cover data-loading:invisible data-error:invisible",typeof e=="function"?e(n):e),...t})}function GU({className:e,...t}){return r.jsx(Dxe,{"data-slot":"avatar-fallback",className:n=>Ne("absolute inset-0 flex items-center justify-center bg-control text-[12px] font-semibold text-subtle",typeof e=="function"?e(n):e),...t})}function Z(e,t){if(typeof window>"u")return e;const n=window.wbI18n;return n?n.t(e,t)??e:e}function Qt({className:e,...t}){return r.jsx("svg",{"data-slot":"spinner",role:"status","aria-label":Z("加载中"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:Ne("size-4 animate-spin [animation-duration:0.7s]",e),...t,children:r.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function Ae({className:e,...t}){return r.jsx("label",{"data-slot":"label",className:Ne("flex items-center gap-[6px] text-[11.5px] text-muted-foreground",e),...t})}const WU={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},vu={...WU,position:"fixed",top:0,left:0},pg={...WU,position:"absolute"},YU=p.createContext(void 0);function Lxe(){const e=p.useContext(YU);if(e===void 0)throw new Error(Vn(63));return e}const $xe="data-checked",zxe="data-unchecked",XU={...hc,checked(e){return e?{[$xe]:""}:{[zxe]:""}}},Bxe=p.forwardRef(function(t,n){const{checked:s,className:i,defaultChecked:o,"aria-labelledby":l,form:u,id:d,inputRef:f,name:m,nativeButton:g=!1,onCheckedChange:v,readOnly:b=!1,required:y=!1,disabled:k=!1,render:w,uncheckedValue:S,value:N,style:C,...T}=t,{clearErrors:P}=uu(),{state:O,setTouched:A,setDirty:R,validityData:M,setFilled:_,setFocused:L,validationMode:$,disabled:D,name:F,validation:V}=uo(),{labelId:K}=zi(),Q=D||k,X=F??m,U=p.useRef(null),z=lo(U,f,V.inputRef),q=p.useRef(null),J=Ws(),ee=_d({id:d}),H=g?void 0:ee,[G,Y]=Tl({controlled:s,default:!!o,name:"Switch",state:"checked"});hg(q,J,G,void 0,!Q,m),Ge(()=>{_(G)},[G,_]),Vo(G,()=>{P(X),R(G!==M.initialValue),V.change(G)});const{getButtonProps:se,buttonRef:re}=$i({disabled:Q,native:g}),ne=FO(l,K,U,!g,H),de={id:g?ee:J,role:"switch","aria-checked":G,"aria-readonly":b||void 0,"aria-required":y||void 0,"aria-labelledby":ne,onFocus(){Q||L(!0)},onBlur(){const te=U.current;!te||Q||(A(!0),L(!1),$==="onBlur"&&V.commit(te.checked))},onClick(te){if(b||Q)return;te.preventDefault();const le=U.current;le&&og(le,te)}},ie={...V.getValidationProps(Q),checked:G,disabled:Q,form:u,id:H,name:X,required:y,style:X?pg:vu,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:z,onChange(te){if(te.nativeEvent.defaultPrevented)return;if(b){te.preventDefault();return}const le=te.currentTarget.checked,he=Nt(rs,te.nativeEvent);v?.(le,he),!he.isCanceled&&Y(le)},onClick(te){te.stopPropagation()},onFocus(){q.current?.focus()},...N!==void 0?{value:N}:yr},oe=p.useMemo(()=>({...O,checked:G,disabled:Q,readOnly:b,required:y}),[O,G,Q,b,y]),je=qt("span",t,{state:oe,ref:[n,q,re],props:[de,T,se,te=>V.getValidationProps(Q,te)],stateAttributesMapping:XU});return r.jsxs(YU.Provider,{value:oe,children:[je,!G&&X&&S!==void 0&&r.jsx("input",{type:"hidden",form:u,name:X,value:S,disabled:Q}),r.jsx("input",{...ie,suppressHydrationWarning:!0})]})}),Fxe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=Lxe();return qt("span",t,{state:u,ref:n,stateAttributesMapping:XU,props:l})});function St({className:e,size:t="default",variant:n="default",...s}){const i=t==="sm";return r.jsx(Bxe,{"data-slot":"switch",className:Ne("relative inline-flex flex-none cursor-pointer items-center rounded-pill border-0 bg-border-strong p-0","transition-colors duration-[180ms] ease-out",n==="success"?"data-checked:bg-success":"data-checked:bg-primary","focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:opacity-50",i?"h-[14px] w-6":t==="touch"?"h-6 w-10":"h-[21px] w-9",e),...s,children:r.jsx(Fxe,{"data-slot":"switch-thumb",className:Ne("block rounded-full bg-primary-on shadow-1","transition-transform duration-[180ms] [transition-timing-function:cubic-bezier(.3,1.4,.6,1)]",i?"size-[10px] translate-x-0.5 data-checked:translate-x-[10px]":t==="touch"?"size-5 translate-x-0.5 data-checked:translate-x-[18px]":"size-[17px] translate-x-0.5 data-checked:translate-x-[17px]")})})}function Uxe(e){if(!e)return null;for(const t of e.elements){const n=t.tagName;if(n==="BUTTON"||n==="INPUT"){const s=t;if(s.type==="submit")return s}}return null}const Hxe="data-checked",Vxe="data-unchecked";function QU(e){return{checked(t){return e.indeterminate?{}:t?{[Hxe]:""}:{[Vxe]:""}},...hc}}const qxe=p.createContext(void 0);function Kxe(){return p.useContext(qxe)}const ZU=p.createContext(void 0);function Gxe(){const e=p.useContext(ZU);if(e===void 0)throw new Error(Vn(14));return e}const Wxe="data-parent",Yxe=p.forwardRef(function(t,n){const{checked:s,className:i,defaultChecked:o=!1,"aria-labelledby":l,disabled:u=!1,form:d,id:f,indeterminate:m=!1,inputRef:g,name:v,onCheckedChange:b,parent:y=!1,readOnly:k=!1,render:w,required:S=!1,uncheckedValue:N,value:C,nativeButton:T=!1,style:P,...O}=t,{clearErrors:A}=uu(),{disabled:R,name:M,setDirty:_,setFilled:L,setFocused:$,setTouched:D,state:F,validationMode:V,validityData:K,validation:Q}=uo(),X=Hk(),{labelId:U,registerControlId:z,getDescriptionProps:q}=zi(),J=Kxe(),ee=J?.allValues===void 0?void 0:J.parent,H=ee!==void 0,G=R||X.disabled||J?.disabled||u,Y=M??v,se=C??Y,re=Ws(),ne=J?.registerControlId!==z,de=_d({id:f||void 0,enabled:ne}),ie=T?de:re;let oe={};H&&(y?oe=ee.getParentProps():se!==void 0&&(oe=ee.getChildProps(se)));const{checked:je=s,indeterminate:te=m,onCheckedChange:le,...he}=oe,ce=J?.value,ye=p.useRef(null),{getButtonProps:fe,buttonRef:Le}=$i({disabled:G,native:T}),pe=J?.validation??Q,[xe,Se]=Tl({controlled:se!==void 0&&ce!==void 0&&!y?ce.includes(se):je,default:o,name:"Checkbox",state:"checked"}),ge=H?!!je:xe,ue=H&&te||m;hg(ye,re,xe,void 0,!J&&!G,v);const be=ee?.registerChildId,ve=p.useRef(null),De=pe.registerInput,Ie=J?se:void 0,We=p.useCallback(gt=>De(gt,{controlRef:ye,value:Ie}),[De,Ie]),nt=lo(g,ve,y?void 0:We),kt=FO(l,U,ve,!T,de);Ge(()=>{ve.current&&(ve.current.indeterminate=ue),J||L(xe)},[xe,ue,J,L]),Vo(xe,()=>{J||(A(Y),_(xe!==K.initialValue),pe.change(xe))});const Je=oo({checked:xe,disabled:G,form:d,name:y?void 0:Y,id:T?void 0:de,required:S,ref:nt,style:Y?pg:vu,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(gt){if(gt.nativeEvent.defaultPrevented)return;if(k){gt.preventDefault();return}const sn=gt.currentTarget.checked,qe=Nt(rs,gt.nativeEvent);if(b?.(sn,qe),!qe.isCanceled&&(le?.(sn,qe),!qe.isCanceled&&(Se(sn),se!==void 0&&J!==void 0&&!y&&!H))){const zt=sn?[...J.value,se]:J.value.filter(ht=>ht!==se);J.setValue(zt,qe)}},onClick(gt){gt.stopPropagation()},onFocus(){ye.current?.focus()}},C!==void 0?{value:(J?xe&&C:C)||""}:yr,q,gt=>pe.getValidationProps(G,gt));p.useEffect(()=>{if(!ee||se===void 0)return;const gt=ee.disabledStatesRef.current;return gt.set(se,G),()=>{gt.delete(se)}},[ee,G,se]);const on=p.useMemo(()=>({...F,checked:ge,disabled:G,readOnly:k,required:S,indeterminate:ue}),[F,ge,G,k,S,ue]),nn=QU(on),On=qt("span",t,{state:on,ref:[Le,ye,n],props:[{id:ie,role:"checkbox","aria-checked":ue?"mixed":ge,"aria-readonly":k||void 0,"aria-required":S||void 0,"aria-labelledby":kt,[Wxe]:y?"":void 0,onFocus(){G||$(!0)},onBlur(){const gt=ve.current;gt&&(D(!0),$(!1),V==="onBlur"&&pe.commit(J?ce:gt.checked))},onKeyDown(gt){if(gt.key!=="Enter"||(gt.preventBaseUIHandler(),gt.defaultPrevented))return;const sn=ve.current?.form??null,qe=gt.currentTarget,zt=gt.nativeEvent,ht=gt.preventDefault,Tt=zt.preventDefault;let Ht=!1;gt.preventDefault=()=>{Ht=!0,ht.call(gt)},zt.preventDefault=()=>{Ht=!0,Tt.call(zt)},Tt.call(zt),vr(qe).queueMicrotask(()=>{gt.preventDefault=ht,zt.preventDefault=Tt,Ht||Uxe(sn)?.click()})},onClick(gt){if(k||G)return;gt.preventDefault();const sn=ve.current;sn&&og(sn,gt)}},O,he,fe,q,gt=>pe.getValidationProps(G,gt)],stateAttributesMapping:nn}),Rn=On.props.id;return Ge(()=>{if(!(!be||y||se===void 0||Rn===void 0))return be(se,Rn)},[be,y,se,Rn]),r.jsxs(ZU.Provider,{value:on,children:[On,!xe&&!J&&Y&&!y&&N!==void 0&&r.jsx("input",{type:"hidden",form:d,name:Y,value:N,disabled:G}),r.jsx("input",{...Je,suppressHydrationWarning:!0})]})}),Xxe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,keepMounted:l=!1,...u}=t,d=Gxe(),f=d.checked||d.indeterminate,{mounted:m,transitionStatus:g,setMounted:v}=gu(f),b=p.useRef(null),y={...d,transitionStatus:g};ji({batch:!0,enabled:!f,open:f,ref:b,onComplete(){f||v(!1)}});const w={...QU(d),...Fo},S=l||m,N=qt("span",t,{ref:[n,b],state:y,stateAttributesMapping:w,props:u});return S?N:null});function jr({className:e,...t}){return r.jsx(Yxe,{"data-slot":"checkbox",className:Ne("group/checkbox relative inline-flex size-3.5 shrink-0 cursor-pointer items-center justify-center rounded-[3px] border border-control-border bg-control","outline-none transition-colors duration-150 ease-out","hover:border-control-border-hover","data-checked:border-primary data-checked:bg-primary","focus-visible:shadow-focus","data-disabled:cursor-not-allowed data-disabled:opacity-45",e),...t,children:r.jsx(Xxe,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-primary-foreground data-unchecked:hidden",children:r.jsxs("svg",{viewBox:"0 0 12 12",className:"size-2.5","aria-hidden":"true",children:[r.jsx("path",{d:"M2 6h8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none",className:"hidden group-aria-[checked=indeterminate]/checkbox:block"}),r.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",className:"group-aria-[checked=indeterminate]/checkbox:hidden"})]})})})}function pR(e){return Array.isArray(e)?e.map(t=>pR(t)).join(","):e==null?"":String(e)}const JU=new Map;function Qxe(e,t){const n=JSON.stringify({locale:pR(e),options:t}),s=JU.get(n);if(s)return s;const i=new Intl.NumberFormat(e,t);return JU.set(n,i),i}function Xk(e,t,n){return e==null?"":Qxe(t,n).format(e)}function bu(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function e6(e,t,n){return(e-t)*100/(n-t)}const t6=p.createContext(void 0);function n6(){const e=p.useContext(t6);if(e===void 0)throw new Error(Vn(51));return e}const Zxe="data-complete",Jxe="data-indeterminate",eve="data-progressing",gR={status(e){return e==="progressing"?{[eve]:""}:e==="complete"?{[Zxe]:""}:e==="indeterminate"?{[Jxe]:""}:null}},tve=p.forwardRef(function(t,n){const{format:s,getAriaValueText:i,locale:o,max:l=100,min:u=0,value:d,render:f,className:m,children:g,style:v,...b}=t,[y,k]=p.useState();let w="indeterminate",S=null,N=null,C="",T="indeterminate progress";if(d!=null&&Number.isFinite(d)){const M=e6(d,u,l);S=bu(Number.isNaN(M)?0:M,0,100),N=bu(d,u,l),w=N===l?"complete":"progressing",C=s?Xk(N,o,s):Xk(S/100,o,{style:"percent"}),T=C}const P=p.useMemo(()=>({status:w}),[w]),O={"aria-labelledby":y,"aria-valuemax":l,"aria-valuemin":u,"aria-valuenow":N??void 0,"aria-valuetext":i?i(C,d):T,role:"progressbar",children:r.jsxs(p.Fragment,{children:[g,r.jsx("span",{role:"presentation",style:vu,children:"x"})]})},A=p.useMemo(()=>({formattedValue:C,percentageValue:S,setLabelId:k,state:P,value:d}),[C,S,k,P,d]),R=qt("div",t,{state:P,ref:n,props:[O,b],stateAttributesMapping:gR});return r.jsx(t6.Provider,{value:A,children:R})}),nve=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,{state:u}=n6();return qt("div",t,{state:u,ref:n,props:l,stateAttributesMapping:gR})}),rve=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,{percentageValue:u,state:d}=n6(),f=u==null?{}:{insetInlineStart:0,height:"inherit",width:`${u}%`};return qt("div",t,{state:d,ref:n,props:[{style:f},l],stateAttributesMapping:gR})});function gg({className:e,children:t,value:n,...s}){return r.jsxs(tve,{value:n,"data-slot":"progress",className:Ne("flex w-full flex-wrap items-center gap-3",e),...s,children:[t,r.jsx(sve,{children:r.jsx(ave,{})})]})}function sve({className:e,...t}){return r.jsx(nve,{"data-slot":"progress-track",className:Ne("relative flex h-1.5 w-full items-center overflow-x-hidden overflow-y-hidden rounded-pill bg-surface-3",e),...t})}function ave({className:e,...t}){return r.jsx(rve,{"data-slot":"progress-indicator",className:Ne("h-full rounded-[inherit] bg-primary transition-[width] duration-300 ease-out data-[indeterminate]:w-1/3 data-[indeterminate]:animate-pulse",e),...t})}const xR=[];let vR;function ive(){return vR}function ove(e){xR.push(e)}function Qk(e){const t=(n,s)=>{const i=$s(lve).current;let o;try{vR=i;for(const l of xR)l.before(i);o=e(n,s);for(const l of xR)l.after(i);i.didInitialize=!0}finally{vR=void 0}return o};return t.displayName=e.displayName||e.name,t}function bR(e){return p.forwardRef(Qk(e))}function lve(){return{didInitialize:!1}}const r6=p.createContext(void 0);function Lb(e){const t=p.useContext(r6);if(t===void 0&&!e)throw new Error(Vn(72));return t}function cve(e,t){return t!=null&&!Ld(t)?0:typeof e=="function"?e():e}function Eh(e,t,n){const s=cve(e,n);return typeof s=="number"?s:s?.[t]}function s6(e){return typeof e=="function"?e():e}function a6(e,t){return t||e==="click"||e==="mousedown"}function uve(e){return e?.includes("mouse")&&e!=="mousedown"}const i6=p.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new Bi,currentIdRef:{current:null},currentContextRef:{current:null}});function dve(e,t){e.current=t.current}function fve(e){const{children:t,delay:n,timeoutMs:s=0}=e,i=p.useRef(n),o=p.useRef(n),l=p.useRef(null),u=p.useRef(null),d=fa();return Ge(()=>{if(o.current=n,!l.current){i.current=n;return}i.current={open:Eh(i.current,"open"),close:Eh(n,"close")}},[n,l,i,o]),r.jsx(i6.Provider,{value:p.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:o,currentIdRef:l,timeoutMs:s,currentContextRef:u,timeout:d}),[s,d]),children:t})}function hve(e,t={open:!1}){const{open:n}=t,s="rootStore"in e?e.rootStore:e,i=s.useState("floatingId"),o=p.useContext(i6),{currentIdRef:l,delayRef:u,timeoutMs:d,initialDelayRef:f,currentContextRef:m,hasProvider:g,timeout:v}=o,[b,y]=p.useState(!1),k=p.useRef(n);return Ge(()=>{k.current=n},[n]),Ge(()=>{function w(){m.current?.setIsInstantPhase(!1),l.current=null,m.current=null,u.current=f.current,v.clear()}if(l.current&&!n&&l.current===i){if(y(!1),d){const S=i;return v.start(d,()=>{s.select("open")||l.current&&l.current!==S||w()}),()=>{(k.current||l.current!==S)&&v.clear()}}w()}},[n,i,l,u,d,f,m,v,s]),Ge(()=>{if(!n)return;const w=m.current,S=l.current;v.clear(),m.current={onOpenChange:s.setOpen,setIsInstantPhase:y},l.current=i,u.current={open:0,close:Eh(f.current,"close")},S!==null&&S!==i?(y(!0),w?.setIsInstantPhase(!0),w?.onOpenChange(!1,Nt(rs))):(y(!1),w?.setIsInstantPhase(!1))},[n,i,s,l,u,f,m,v]),Ge(()=>()=>{if(l.current===i){if(m.current=null,!k.current)return;l.current=null,dve(u,f),v.clear()}},[m,l,u,i,f,v]),p.useMemo(()=>({activeIdRef:l,hasProvider:g,delayRef:u,isInstantPhase:b}),[l,g,u,b])}function kn(e,t,n,s){return e.addEventListener(t,n,s),()=>{e.removeEventListener(t,n,s)}}function Ol(...e){return()=>{for(let t=0;t{t.current=t.next}};return t}const Th=p.forwardRef(function(t,n){const[s,i]=p.useState();Ge(()=>{Oge&&du&&i("button")},[]);const o={tabIndex:0,role:s};return r.jsx("span",{...t,ref:n,style:vu,"aria-hidden":s?void 0:!0,...o,"data-base-ui-focus-guard":""})});function $b(e){return`data-base-ui-${e}`}let Zk=0;function Jk(e,t={}){const{preventScroll:n=!1,sync:s=!1,shouldFocus:i}=t;cancelAnimationFrame(Zk);function o(){i&&!i()||e?.focus({preventScroll:n})}if(s)return o(),Xn;const l=requestAnimationFrame(o);return Zk=l,()=>{Zk===l&&(cancelAnimationFrame(l),Zk=0)}}const yR={inert:new WeakMap,"aria-hidden":new WeakMap},o6="data-base-ui-inert",jR={inert:new WeakSet,"aria-hidden":new WeakSet};let zb=new WeakMap,wR=0;function pve(e){return jR[e]}function l6(e){return e?ag(e)?e.host:l6(e.parentNode):null}const c6=(e,t)=>t.map(n=>{if(e.contains(n))return n;const s=l6(n);return e.contains(s)?s:null}).filter(n=>n!=null),u6=e=>{const t=new Set;return e.forEach(n=>{let s=n;for(;s&&!t.has(s);)t.add(s),s=s.parentNode}),t},d6=(e,t,n)=>{const s=[],i=o=>{!o||n.has(o)||Array.from(o.children).forEach(l=>{Ha(l)!=="script"&&(t.has(l)?i(l):s.push(l))})};return i(e),s};function gve(e,t,n,s,{mark:i=!0}){let o=null;s?o="inert":n&&(o="aria-hidden");let l=null,u=null;const d=c6(t,e),f=i?d6(t,u6(d),new Set(d)):[],m=[],g=[];if(o){const v=yR[o],b=pve(o);u=b,l=v;const y=c6(t,Array.from(t.querySelectorAll("[aria-live]"))),k=d.concat(y);d6(t,u6(k),new Set(k)).forEach(S=>{const N=S.getAttribute(o),C=N!==null&&N!=="false",T=(v.get(S)||0)+1;v.set(S,T),m.push(S),T===1&&C&&b.add(S),C||S.setAttribute(o,o==="inert"?"":"true")})}return i&&f.forEach(v=>{const b=(zb.get(v)||0)+1;zb.set(v,b),g.push(v),b===1&&v.setAttribute(o6,"")}),wR+=1,()=>{l&&m.forEach(v=>{const y=(l.get(v)||0)-1;l.set(v,y),y||(!u?.has(v)&&o&&v.removeAttribute(o),u?.delete(v))}),i&&g.forEach(v=>{const b=(zb.get(v)||0)-1;zb.set(v,b),b||v.removeAttribute(o6)}),wR-=1,wR||(yR.inert=new WeakMap,yR["aria-hidden"]=new WeakMap,jR.inert=new WeakSet,jR["aria-hidden"]=new WeakSet,zb=new WeakMap)}}function f6(e,t={}){const{ariaHidden:n=!1,inert:s=!1,mark:i=!0}=t,o=_n(e[0]).body;return gve(e,o,n,s,{mark:i})}const xve=500,vve={style:{transition:"none"}},kR="data-base-ui-click-trigger",bve="data-base-ui-swipe-ignore",yve="data-swipe-ignore",jve=`[${bve}]`,wve=`[${yve}]`,h6={fallbackAxisSide:"none"},m6={fallbackAxisSide:"end"},kve={clipPath:"inset(50%)",position:"fixed",top:0,left:0},p6=p.createContext(null),g6=()=>p.useContext(p6),Sve=$b("portal");function x6(e={}){const{ref:t,container:n,componentProps:s=yr,elementProps:i}=e,o=lg(),u=g6()?.portalNode,[d,f]=p.useState(null),[m,g]=p.useState(null),v=Ke(w=>{w!==null&&g(w)}),b=p.useRef(null);Ge(()=>{if(n===null){b.current&&(b.current=null,g(null),f(null));return}const w=(n&&(kO(n)?n:n.current))??u??document.body;if(w==null){b.current&&(b.current=null,g(null),f(null));return}b.current!==w&&(b.current=w,g(null),f(w))},[n,u]);const y=qt("div",s,{ref:[t,v],props:[{id:o,[Sve]:""},i]}),k=d&&y?xr.createPortal(y,d):null;return{node:m,nodeId:p.isValidElement(y)?y.props.id:void 0,subtree:k}}const eS=p.forwardRef(function(t,n){const{render:s,className:i,style:o,children:l,container:u,portalOwnerRole:d,...f}=t,{node:m,nodeId:g,subtree:v}=x6({container:u,ref:n,componentProps:t,elementProps:f}),b=p.useRef(null),y=p.useRef(null),k=p.useRef(null),w=p.useRef(null),[S,N]=p.useState(null),C=p.useRef(!1),T=S?.modal,P=S?.open,O=!!S&&!S.modal&&S.open&&!!m;p.useEffect(()=>{if(!m||T)return;function R(M){m&&M.relatedTarget&&dg(M)&&(M.type==="focusin"?C.current&&(DU(m),C.current=!1):(uxe(m),C.current=!0))}return Ol(kn(m,"focusin",R,!0),kn(m,"focusout",R,!0))},[m,T]),Ge(()=>{!m||P!==!0||!C.current||(DU(m),C.current=!1)},[P,m]);const A=p.useMemo(()=>({beforeOutsideRef:b,afterOutsideRef:y,beforeInsideRef:k,afterInsideRef:w,portalNode:m,setFocusManagerState:N}),[m]);return r.jsxs(p.Fragment,{children:[v,r.jsxs(p6.Provider,{value:A,children:[O&&m&&r.jsx(Th,{"data-type":"outside",ref:b,onFocus:R=>{if(dg(R,m))k.current?.focus();else{const M=S?S.domReference:null;MU(M)?.focus()}}}),O&&m&&r.jsx("span",{role:d,"aria-owns":g,style:kve}),m&&xr.createPortal(l,m),O&&m&&r.jsx(Th,{"data-type":"outside",ref:y,onFocus:R=>{if(dg(R,m))w.current?.focus();else{const M=S?S.domReference:null;iR(M)?.focus(),S?.closeOnFocusOut&&S?.onOpenChange(!1,Nt(Fd,R.nativeEvent))}}})]})]})});function v6(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(s=>s(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class Nve{constructor(){Cn(this,"nodesRef",{current:[]});Cn(this,"events",v6())}addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(s=>s===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const b6=p.createContext(null),y6=p.createContext(null),xg=()=>p.useContext(b6)?.id||null,Oh=e=>{const t=p.useContext(y6);return e??t};function Cve(e){const t=lg(),n=Oh(e),s=xg();return Ge(()=>{if(!t)return;const i={id:t,parentId:s};return n?.addNode(i),()=>{n?.removeNode(i)}},[n,t,s]),t}function Ave(e){const{children:t,id:n}=e,s=xg();return r.jsx(b6.Provider,{value:p.useMemo(()=>({id:n,parentId:s}),[n,s]),children:t})}function Eve(e){const{children:t,externalTree:n}=e,s=$s(()=>n??new Nve).current;return r.jsx(y6.Provider,{value:s,children:t})}function Tve(e,t){const n=vr(Er(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const j6=20;let Ud=[];function SR(){Ud=Ud.filter(e=>e.deref()?.isConnected)}function w6(e){SR(),e&&Ha(e)!=="body"&&(Ud.push(new WeakRef(e)),Ud.length>j6&&(Ud=Ud.slice(-j6)))}function k6(){return SR(),Ud[Ud.length-1]?.deref()}function Ove(e){return e?aR(e)?e:Pb(e)[0]||e:null}function S6(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!e.getAttribute("role")?.includes("dialog"))return;const n=PU(e).filter(i=>{const o=i.getAttribute("data-tabindex")||"";return aR(i)||i.hasAttribute("data-tabindex")&&!o.startsWith("-")}),s=e.getAttribute("tabindex");n.length===0?s!=="0"&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):(s!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function tS(e){const{context:t,children:n,disabled:s=!1,initialFocus:i=!0,returnFocus:o=!0,restoreFocus:l=!1,modal:u=!0,closeOnFocusOut:d=!0,openInteractionType:f="",nextFocusableElement:m,previousFocusableElement:g,beforeContentFocusGuardRef:v,externalTree:b,getInsideElements:y}=e,k="rootStore"in t?t.rootStore:t,w=k.useState("open"),S=k.useState("domReferenceElement"),N=k.useState("floatingElement"),{events:C,dataRef:T}=k.context,P=Ke(()=>T.current.floatingContext?.nodeId),O=i===!1,A=XO(S)&&O,R=ss(i),M=ss(o),_=ss(f),L=ss(w),$=Oh(b),D=g6(),F=p.useRef(!1),V=p.useRef(!1),K=p.useRef(!1),Q=p.useRef(null),X=p.useRef(""),U=p.useRef(""),z=p.useRef(null),q=p.useRef(null),J=lo(z,v,D?.beforeInsideRef),ee=lo(q,D?.afterInsideRef),H=fa(),G=fa(),Y=fg(),se=D!=null,re=_k(N),ne=Ke((oe=re)=>oe?Pb(oe):[]),de=Ke(()=>y?.().filter(oe=>oe!=null)??[]);p.useEffect(()=>{if(s||!u)return;function oe(te){te.key==="Tab"&&Et(re,Ys(_n(re)))&&ne().length===0&&!A&&da(te)}const je=_n(re);return kn(je,"keydown",oe)},[s,re,u,A,ne]),p.useEffect(()=>{if(s||!w)return;const oe=_n(re);function je(){K.current=!1}function te(he){const ce=Er(he),ye=de(),fe=Et(N,ce)||Et(S,ce)||Et(D?.portalNode,ce)||ye.some(Le=>Le===ce||Et(Le,ce));K.current=!fe,U.current=he.pointerType||"keyboard",ce?.closest(`[${kR}]`)&&(V.current=!0,G.start(0,()=>{V.current=!1}))}function le(){U.current="keyboard"}return Ol(kn(oe,"pointerdown",te,!0),kn(oe,"pointerup",je,!0),kn(oe,"pointercancel",je,!0),kn(oe,"keydown",le,!0),je)},[s,N,S,re,w,D,G,de]),p.useEffect(()=>{if(s||!d)return;const oe=_n(re);function je(){V.current=!0,G.start(0,()=>{V.current=!1})}function te(ye){const fe=Er(ye);aR(fe)&&(Q.current=fe)}function le(ye){const fe=ye.relatedTarget,Le=ye.currentTarget,pe=Er(ye);u&&fe==null&&pe!=null&&Et(N,pe)&&w6(pe),queueMicrotask(()=>{const xe=P(),Se=k.context.triggerElements,ge=de(),ue=fe?.hasAttribute($b("focus-guard"))&&[z.current,q.current,D?.beforeInsideRef.current,D?.afterInsideRef.current,D?.beforeOutsideRef.current,D?.afterOutsideRef.current,pu(g),pu(m)].includes(fe),be=!(Et(S,fe)||Et(N,fe)||Et(fe,N)||Et(D?.portalNode,fe)||ge.some(ve=>ve===fe||Et(ve,fe))||Se.hasMatchingElement(ve=>Et(ve,fe))||ue||$&&(Dd($.nodesRef.current,xe).find(ve=>Et(ve.context?.elements.floating,fe)||Et(ve.context?.elements.domReference,fe))||jU($.nodesRef.current,xe).find(ve=>[ve.context?.elements.floating,_k(ve.context?.elements.floating)].includes(fe)||ve.context?.elements.domReference===fe)));if(Le===S&&re&&S6(re),l&&Le!==S&&!Fk(pe)&&Ys(oe)===oe.body){if(br(re)&&(re.focus(),l==="popup")){Y.request(()=>{re.focus()});return}const ve=ne(),De=Q.current,Ie=(De&&ve.includes(De)?De:null)||ve[ve.length-1]||re;br(Ie)&&Ie.focus()}if(T.current.insideReactTree){T.current.insideReactTree=!1;return}(A||!u)&&fe&&be&&!V.current&&(A||fe!==k6())&&(F.current=!0,k.setOpen(!1,Nt(Fd,ye)))})}function he(){K.current||(T.current.insideReactTree=!0,H.start(0,()=>{T.current.insideReactTree=!1}))}const ce=br(S)?S:null;if(!(!N&&!ce))return Ol(ce&&kn(ce,"focusout",le),ce&&kn(ce,"pointerdown",je),N&&kn(N,"focusin",te),N&&kn(N,"focusout",le),N&&D&&kn(N,"focusout",he,!0))},[s,S,N,re,u,$,D,k,d,l,ne,A,P,T,H,G,Y,m,g,de]),p.useEffect(()=>{if(s||!N||!w)return;const oe=Array.from(D?.portalNode?.querySelectorAll(`[${$b("portal")}]`)||[]),te=($?jU($.nodesRef.current,P()):[]).find(Le=>XO(Le.context?.elements.domReference||null))?.context?.elements.domReference,he=[...[N,...oe,z.current,q.current,D?.beforeOutsideRef.current,D?.afterOutsideRef.current,...de()],te,pu(g),pu(m),A?S:null].filter(Le=>Le!=null),ce=f6(he,{ariaHidden:u||A,mark:!1}),ye=[N,...oe].filter(Le=>Le!=null),fe=f6(ye);return()=>{fe(),ce()}},[w,s,S,N,u,D,A,$,P,m,g,de]),Ge(()=>{if(!w||s||!br(re))return;X.current="",U.current="";const oe=_n(re),je=Ys(oe);queueMicrotask(()=>{const te=R.current,le=typeof te=="function"?te(_.current||""):te;if(le===void 0||le===!1||Et(re,je))return;let ce=null;const ye=()=>(ce==null&&(ce=ne(re)),ce[0]||re);let fe;le===!0||le===null?fe=ye():fe=pu(le),fe=fe||ye();const Le=Et(re,Ys(oe));Jk(fe,{preventScroll:fe===re,shouldFocus(){if(!L.current)return!1;if(Le)return!0;const pe=Ys(oe);return!(pe!==fe&&Et(re,pe))}})})},[s,w,re,ne,R,_,L]),Ge(()=>{if(s||!re)return;const oe=_n(re),je=Ys(oe),te=_.current==null;w6(je);function le(ce){if(ce.open||(X.current=Tve(ce.nativeEvent,U.current)),ce.reason===Va&&ce.nativeEvent.type==="mouseleave"&&(F.current=!0),ce.reason===Wk)if(ce.nested)F.current=!1;else if(Dk(ce.nativeEvent)||QO(ce.nativeEvent))F.current=!1;else{let ye=!1;_n(re).createElement("div").focus({get preventScroll(){return ye=!0,!1}}),ye?F.current=!1:F.current=!0}}C.on("openchange",le);function he(ce){const ye=M.current;let fe=typeof ye=="function"?ye(ce):ye;if(fe===void 0||fe===!1)return null;fe===null&&(fe=!0);const Le=S?.isConnected?S:null,pe=je?.isConnected&&Ha(je)!=="body"?je:null;let xe=te?pe||Le:Le||pe;return xe||(xe=k6()||null),typeof fe=="boolean"?xe:pu(fe)||xe||null}return()=>{C.off("openchange",le);const ce=Ys(oe),ye=de(),fe=Et(N,ce)||ye.some(Se=>Se===ce||Et(Se,ce))||$&&Dd($.nodesRef.current,P(),!1).some(Se=>Et(Se.context?.elements.floating,ce)),Le=M.current,pe=X.current,xe=he(pe);queueMicrotask(()=>{const Se=Ove(xe),ge=typeof Le!="boolean";if(Le&&!F.current&&br(Se)&&(!(!ge&&Se!==ce&&ce!==oe.body)||fe)){const ue={preventScroll:!0};pe==="keyboard"&&(ue.focusVisible=!0),Se.focus(ue)}F.current=!1})}},[s,N,re,M,_,C,$,S,P,de]),Ge(()=>{if(!du||w||!N)return;const oe=Ys(_n(N));!br(oe)||!Ik(oe)||Et(N,oe)&&oe.blur()},[w,N]),Ge(()=>{if(!(s||!D))return D.setFocusManagerState({modal:u,closeOnFocusOut:d,open:w,onOpenChange:k.setOpen,domReference:S}),()=>{D.setFocusManagerState(null)}},[s,D,u,w,k,d,S]),Ge(()=>{if(!(s||!re))return S6(re),()=>{queueMicrotask(SR)}},[s,re]);const ie=!s&&(u?!A:!0)&&(se||u);return r.jsxs(p.Fragment,{children:[ie&&r.jsx(Th,{"data-type":"inside",ref:J,onFocus:oe=>{if(u){const je=ne();Jk(je[je.length-1])}else D?.portalNode&&(F.current=!1,dg(oe,D.portalNode)?iR(S)?.focus():pu(g??D.beforeOutsideRef)?.focus())}}),n,ie&&r.jsx(Th,{"data-type":"inside",ref:ee,onFocus:oe=>{u?Jk(ne()[0]):D?.portalNode&&(d&&(F.current=!0),dg(oe,D.portalNode)?MU(S)?.focus():pu(m??D.afterOutsideRef)?.focus())}})]})}function Bb(e,t={}){const{enabled:n=!0,event:s="click",toggle:i=!0,ignoreMouse:o=!1,stickIfOpen:l=!0,touchOpenDelay:u=0,reason:d=xu}=t,f="rootStore"in e?e.rootStore:e,m=f.context.dataRef,g=p.useRef(void 0),v=fg(),b=fa(),y=p.useMemo(()=>{function k(S,N,C,T){const P=Nt(d,N,C);S&&T==="touch"&&u>0?b.start(u,()=>{f.setOpen(!0,P)}):f.setOpen(S,P)}function w(S,N,C){const T=m.current.openEvent,P=f.select("domReferenceElement")!==N;return S&&P||!S||!i?!0:T&&l?!C(T.type):!1}return{onPointerDown(S){g.current=Ld(S.pointerType,!0)&&QO(S.nativeEvent)?"virtual":S.pointerType},onMouseDown(S){const N=g.current,C=S.nativeEvent,T=f.select("open");if(S.button!==0||s==="click"||Ld(N,!0)&&o)return;const P=w(T,S.currentTarget,R=>R==="click"||R==="mousedown"),O=Er(C);if(Ik(O)){k(P,C,O,N);return}const A=S.currentTarget;v.request(()=>{k(P,C,A,N)})},onClick(S){if(s==="mousedown-only")return;const N=g.current;if(s==="mousedown"&&N){g.current=void 0;return}if(Ld(N,!0)&&o)return;const C=f.select("open"),T=w(C,S.currentTarget,P=>P==="click"||P==="mousedown"||P==="keydown"||P==="keyup");k(T,S.nativeEvent,S.currentTarget,N)},onKeyDown(){g.current=void 0}}},[m,s,o,d,f,l,i,v,b,u]);return p.useMemo(()=>n?{reference:y}:yr,[n,y])}function Rve(e,t){let n=null,s=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){const o=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},l=t.axis==="x"||t.axis==="both",u=t.axis==="y"||t.axis==="both",d=["mouseenter","mousemove"].includes(t.dataRef.current.openEvent?.type||"")&&t.pointerType!=="touch";let f=o.width,m=o.height,g=o.x,v=o.y;return n==null&&t.x&&l&&(n=o.x-t.x),s==null&&t.y&&u&&(s=o.y-t.y),g-=n||0,v-=s||0,f=0,m=0,!i||d?(f=t.axis==="y"?o.width:0,m=t.axis==="x"?o.height:0,g=l&&t.x!=null?t.x:g,v=u&&t.y!=null?t.y:v):i&&!d&&(m=t.axis==="x"?o.height:m,f=t.axis==="y"?o.width:f),i=!0,{width:f,height:m,x:g,y:v,top:v,right:g+f,bottom:v+m,left:g}}}}function N6(e){return e!=null&&e.clientX!=null}function Pve(e,t={}){const{enabled:n=!0,axis:s="both"}=t,i="rootStore"in e?e.rootStore:e,o=i.useState("open"),l=i.useState("floatingElement"),u=i.useState("domReferenceElement"),d=i.context.dataRef,f=p.useRef(!1),m=p.useRef(null),[g,v]=p.useState(),[b,y]=p.useState([]),k=Ke(T=>{i.set("positionReference",T)}),w=Ke((T,P,O)=>{f.current||d.current.openEvent&&!N6(d.current.openEvent)||i.set("positionReference",Rve(O??u,{x:T,y:P,axis:s,dataRef:d,pointerType:g}))}),S=Ke(T=>{o?m.current||(w(T.clientX,T.clientY,T.currentTarget),y([])):w(T.clientX,T.clientY,T.currentTarget)}),N=Ld(g)?l:o;p.useEffect(()=>{if(!n){k(u);return}if(!N)return;function T(){m.current?.(),m.current=null}const P=vr(l);function O(A){const R=Er(A);Et(l,R)?T():w(A.clientX,A.clientY)}return!d.current.openEvent||N6(d.current.openEvent)?m.current=kn(P,"mousemove",O):k(u),T},[N,n,l,d,u,i,w,k,b]),p.useEffect(()=>()=>{i.set("positionReference",null)},[i]),p.useEffect(()=>{n&&!l&&(f.current=!1)},[n,l]),p.useEffect(()=>{!n&&o&&(f.current=!0)},[n,o]);const C=p.useMemo(()=>{function T(P){v(P.pointerType)}return{onPointerDown:T,onPointerEnter:T,onMouseMove:S,onMouseEnter:S}},[S]);return p.useMemo(()=>n?{reference:C,trigger:C}:{},[n,C])}function Ive(){return!1}function Mve(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function Fb(e,t={}){const{enabled:n=!0,escapeKey:s=!0,outsidePress:i=!0,outsidePressEvent:o="sloppy",referencePress:l=Ive,bubbles:u,externalTree:d}=t,f="rootStore"in e?e.rootStore:e,m=f.useState("open"),g=f.useState("floatingElement"),{dataRef:v,events:b}=f.context,y=Oh(d),k=Ke(typeof i=="function"?i:()=>!1),w=typeof i=="function"?k:i,S=w!==!1,N=Ke(()=>o),{escapeKey:C,outsidePress:T}=Mve(u),P=p.useRef(!1),O=p.useRef(!1),A=p.useRef(!1),R=p.useRef(!1),M=p.useRef(!1),_=p.useRef(""),L=p.useRef(null),$=fa(),D=fa(),F=Ke(()=>{D.clear(),v.current.insideReactTree=!1}),V=Ke(H=>{const G=v.current.floatingContext?.nodeId;return(y?Dd(y.nodesRef.current,G):[]).some(se=>se.context?.open&&!se.context.dataRef.current[H])}),K=Ke(H=>YO(H,f.select("floatingElement"))||YO(H,f.select("domReferenceElement"))),Q=Ke(H=>{l()&&f.setOpen(!1,Nt(xu,H.nativeEvent))}),X=Ke(H=>{if(!m||!n||!s||H.key!=="Escape"||M.current||!C&&V("__escapeKeyBubbles"))return;const G=qge(H)?H.nativeEvent:H,Y=Nt(mg,G);f.setOpen(!1,Y),Y.isCanceled||H.preventDefault(),!C&&!Y.isPropagationAllowed&&H.stopPropagation()}),U=Ke(()=>{v.current.insideReactTree=!0,D.start(0,F)}),z=Ke(H=>{if(!m||!n||H.button!==0)return;const G=Er(H.nativeEvent);Et(f.select("floatingElement"),G)&&(P.current||(P.current=!0,O.current=!1))}),q=Ke(H=>{!m||!n||(H.defaultPrevented||H.nativeEvent.defaultPrevented)&&P.current&&(O.current=!0)});p.useEffect(()=>{function H(G){G.open||(R.current=!1)}return b.on("openchange",H),()=>{b.off("openchange",H)}},[b]),p.useEffect(()=>{if(!m||!n)return m||(R.current=!1),F;v.current.__escapeKeyBubbles=C,v.current.__outsidePressBubbles=T;const H=new Bi,G=new Bi,Y=_n(g);function se(){H.clear(),M.current=!0}function re(){H.start(du?5:0,()=>{M.current=!1})}function ne(){A.current=!0,G.start(0,()=>{A.current=!1})}function de(){P.current=!1,O.current=!1}function ie(){const be=_.current,ve=be==="pen"||!be?"mouse":be,De=N(),Ie=typeof De=="function"?De():De;return typeof Ie=="string"?Ie:Ie[ve]}function oe(be){const ve=ie();return ve==="intentional"&&be.type!=="click"||ve==="sloppy"&&be.type==="click"}function je(be){const ve=v.current.floatingContext?.nodeId,De=y&&Dd(y.nodesRef.current,ve).some(Ie=>YO(be,Ie.context?.elements.floating));return K(be)||De}function te(be){if(oe(be)){be.type!=="click"&&!K(be)&&(G.clear(),A.current=!1),F();return}if(v.current.insideReactTree){F();return}const ve=Er(be),De=`[${$b("inert")}]`,Ie=Un(ve)?ve.getRootNode():null,We=Array.from((ag(Ie)?Ie:_n(f.select("floatingElement"))).querySelectorAll(De)),nt=f.context.triggerElements;if(ve&&(nt.hasElement(ve)||nt.hasMatchingElement(Je=>Et(Je,ve))))return;let kt=Un(ve)?ve:null;for(;kt&&!Rd(kt);){const Je=Pd(kt);if(Rd(Je)||!Un(Je))break;kt=Je}if(!(We.length&&Un(ve)&&!Hge(ve)&&!Et(ve,f.select("floatingElement"))&&We.every(Je=>!Et(kt,Je)))){if(br(ve)&&!("touches"in be)){const Je=Rd(ve),on=Li(ve),nn=/auto|scroll/,On=Je||nn.test(on.overflowX),Rn=Je||nn.test(on.overflowY),gt=On&&ve.clientWidth>0&&ve.scrollWidth>ve.clientWidth,sn=Rn&&ve.clientHeight>0&&ve.scrollHeight>ve.clientHeight,qe=on.direction==="rtl",zt=sn&&(qe?be.offsetX<=ve.offsetWidth-ve.clientWidth:be.offsetX>ve.clientWidth),ht=gt&&be.offsetY>ve.clientHeight;if(zt||ht)return}if(!je(be)){if(ie()==="intentional"){if(be.detail!==0&&!Dk(be)&&!R.current)return;if(A.current){G.clear(),A.current=!1;return}}typeof w=="function"&&!w(be)||V("__outsidePressBubbles")||(f.setOpen(!1,Nt(Wk,be)),F())}}}function le(be){ie()!=="sloppy"||be.pointerType==="touch"||!f.select("open")||!n||K(be)||te(be)}function he(be){if(ie()!=="sloppy"||!f.select("open")||!n||K(be))return;const ve=be.touches[0];ve&&(L.current={startTime:Date.now(),startX:ve.clientX,startY:ve.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},$.start(1e3,()=>{L.current&&(L.current.dismissOnTouchEnd=!1,L.current.dismissOnMouseDown=!1)}))}function ce(be,ve){const De=Er(be);if(!De)return;const Ie=kn(De,be.type,()=>{ve(be),Ie()})}function ye(be){_.current="touch",ce(be,he)}function fe(be){$.clear(),be.type==="pointerdown"&&(be.button===0&&(R.current=!0),_.current=be.pointerType),!(be.type==="mousedown"&&L.current&&!L.current.dismissOnMouseDown)&&ce(be,ve=>{ve.type==="pointerdown"?le(ve):te(ve)})}function Le(be){if(be.type==="pointercancel"&&(R.current=!1),!P.current)return;const ve=O.current;if(de(),ie()==="intentional"){if(be.type==="pointercancel"){ve&&ne();return}if(!je(be)){if(ve){ne();return}typeof w=="function"&&!w(be)||(G.clear(),A.current=!0,F())}}}function pe(be){if(ie()!=="sloppy"||!L.current||K(be))return;const ve=be.touches[0];if(!ve)return;const De=Math.abs(ve.clientX-L.current.startX),Ie=Math.abs(ve.clientY-L.current.startY),We=Math.sqrt(De*De+Ie*Ie);We>5&&(L.current.dismissOnTouchEnd=!0),We>10&&(te(be),$.clear(),L.current=null)}function xe(be){ce(be,pe)}function Se(be){ie()!=="sloppy"||!L.current||K(be)||(L.current.dismissOnTouchEnd&&te(be),$.clear(),L.current=null)}function ge(be){ce(be,Se)}const ue=Ol(s&&Ol(kn(Y,"keydown",X),kn(Y,"compositionstart",se),kn(Y,"compositionend",re)),S&&Ol(kn(Y,"click",fe,!0),kn(Y,"pointerdown",fe,!0),kn(Y,"pointerup",Le,!0),kn(Y,"pointercancel",Le,!0),kn(Y,"mousedown",fe,!0),kn(Y,"mouseup",Le,!0),kn(Y,"touchstart",ye,{capture:!0,passive:!0}),kn(Y,"touchmove",xe,{capture:!0,passive:!0}),kn(Y,"touchend",ge,{capture:!0,passive:!0})));return()=>{ue(),H.clear(),G.clear(),de(),A.current=!1,F()}},[v,g,s,S,w,m,n,C,T,X,F,N,V,K,y,f,$]);const J=p.useMemo(()=>({onKeyDown:X,onPointerDown:Q,onClick:Q}),[X,Q]),ee=p.useMemo(()=>({onKeyDown:X,onPointerDown:q,onMouseDown:q,onClickCapture:U,onMouseDownCapture(H){U(),z(H)},onPointerDownCapture(H){U(),z(H)},onMouseUpCapture:U,onTouchEndCapture:U,onTouchMoveCapture:U}),[X,U,z,q]);return p.useMemo(()=>n?{reference:J,floating:ee,trigger:J}:{},[n,J,ee])}function C6(e,t,n){let{reference:s,floating:i}=e;const o=Ho(t),l=eR(t),u=JO(l),d=Uo(t),f=o==="y",m=s.x+s.width/2-i.width/2,g=s.y+s.height/2-i.height/2,v=s[u]/2-i[u]/2;let b;switch(d){case"top":b={x:m,y:s.y-i.height};break;case"bottom":b={x:m,y:s.y+s.height};break;case"right":b={x:s.x+s.width,y:g};break;case"left":b={x:s.x-i.width,y:g};break;default:b={x:s.x,y:s.y}}const y=mu(t);return y&&(b[l]+=v*(y==="end"?1:-1)*(n&&f?-1:1)),b}async function _ve(e,t){var n;t===void 0&&(t={});const{x:s,y:i,platform:o,rects:l,elements:u,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:m="viewport",elementContext:g="floating",altBoundary:v=!1,padding:b=0}=$d(t,e),y=NU(b),w=u[v?g==="floating"?"reference":"floating":g],S=Rb(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(w)))==null||n?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(u.floating)),boundary:f,rootBoundary:m,strategy:d})),N=g==="floating"?{x:s,y:i,width:l.floating.width,height:l.floating.height}:l.reference,C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u.floating)),T=await(o.isElement==null?void 0:o.isElement(C))&&await(o.getScale==null?void 0:o.getScale(C))||{x:1,y:1},P=Rb(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:N,offsetParent:C,strategy:d}):N);return{top:(S.top-P.top+y.top)/T.y,bottom:(P.bottom-S.bottom+y.bottom)/T.y,left:(S.left-P.left+y.left)/T.x,right:(P.right-S.right+y.right)/T.x}}const Dve=50,Lve=async(e,t,n)=>{const{placement:s="bottom",strategy:i="absolute",middleware:o=[],platform:l}=n,u=l.detectOverflow?l:{...l,detectOverflow:_ve},d=await(l.isRTL==null?void 0:l.isRTL(t));let f=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:m,y:g}=C6(f,s,d),v=s,b=0;const y={};for(let k=0;kF<=0)){var L,$;const F=(((L=o.flip)==null?void 0:L.index)||0)+1,V=A[F];if(V&&(!(g==="alignment"?N!==Ho(V):!1)||_.every(X=>Ho(X.placement)===N?X.overflows[0]>0:!0)))return{data:{index:F,overflows:_},reset:{placement:V}};let K=($=_.filter(Q=>Q.overflows[0]<=0).sort((Q,X)=>Q.overflows[1]-X.overflows[1])[0])==null?void 0:$.placement;if(!K)switch(b){case"bestFit":{var D;const Q=(D=_.filter(X=>{if(O){const U=Ho(X.placement);return U===N||U==="y"}return!0}).map(X=>[X.placement,X.overflows.filter(U=>U>0).reduce((U,z)=>U+z,0)]).sort((X,U)=>X[1]-U[1])[0])==null?void 0:D[0];Q&&(K=Q);break}case"initialPlacement":K=u;break}if(i!==K)return{reset:{placement:K}}}return{}}}},A6=new Set(["left","top"]);async function zve(e,t){const{placement:n,platform:s,elements:i}=e,o=await(s.isRTL==null?void 0:s.isRTL(i.floating)),l=Uo(n),u=mu(n),d=Ho(n)==="y",f=A6.has(l)?-1:1,m=o&&d?-1:1,g=$d(t,e);let{mainAxis:v,crossAxis:b,alignmentAxis:y}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof y=="number"&&(b=u==="end"?y*-1:y),d?{x:b*m,y:v*f}:{x:v*f,y:b*m}}const Bve=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:i,y:o,placement:l,middlewareData:u}=t,d=await zve(t,e);return l===((n=u.offset)==null?void 0:n.placement)&&(s=u.arrow)!=null&&s.alignmentOffset?{}:{x:i+d.x,y:o+d.y,data:{...d,placement:l}}}}},Fve=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:i,platform:o}=t,{mainAxis:l=!0,crossAxis:u=!1,limiter:d={fn:N=>{let{x:C,y:T}=N;return{x:C,y:T}}},...f}=$d(e,t),m={x:n,y:s},g=await o.detectOverflow(t,f),v=Ho(i),b=ZO(v);let y=m[b],k=m[v];const w=(N,C)=>wU(C+g[N==="y"?"top":"left"],C,C-g[N==="y"?"bottom":"right"]);l&&(y=w(b,y)),u&&(k=w(v,k));const S=d.fn({...t,[b]:y,[v]:k});return{...S,data:{x:S.x-n,y:S.y-s,enabled:{[b]:l,[v]:u}}}}}},Uve=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,s;const{x:i,y:o,placement:l,rects:u,middlewareData:d}=t,{offset:f=0,mainAxis:m=!0,crossAxis:g=!0}=$d(e,t),v={x:i,y:o},b=Ho(l),y=ZO(b);let k=v[y],w=v[b];const S=$d(f,t),N=typeof S=="number"?{mainAxis:S,crossAxis:0}:{mainAxis:(n=S.mainAxis)!=null?n:0,crossAxis:(s=S.crossAxis)!=null?s:0};if(m){const P=y==="y"?"height":"width",O=u.reference[y]-u.floating[P]+N.mainAxis,A=u.reference[y]+u.reference[P]-N.mainAxis;kA&&(k=A)}if(g){var C,T;const P=y==="y"?"width":"height",O=A6.has(Uo(l)),A=u.reference[b]-u.floating[P]+(O&&((C=d.offset)==null?void 0:C[b])||0)+(O?0:N.crossAxis),R=u.reference[b]+u.reference[P]+(O?0:((T=d.offset)==null?void 0:T[b])||0)-(O?N.crossAxis:0);wR&&(w=R)}return{[y]:k,[b]:w}}}},Hve=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:s,platform:i,elements:o}=t,{apply:l=()=>{},...u}=$d(e,t),d=await i.detectOverflow(t,u),f=Uo(n),m=mu(n),g=Ho(n)==="y",{width:v,height:b}=s.floating;let y,k;f==="top"||f==="bottom"?(y=f,k=m===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(k=f,y=m==="end"?"top":"bottom");const w=b-d.top-d.bottom,S=v-d.left-d.right,N=ug(b-d[y],w),C=ug(v-d[k],S),T=t.middlewareData.shift,P=!T;let O=N,A=C;T!=null&&T.enabled.x&&(A=S),T!=null&&T.enabled.y&&(O=w),P&&!m&&(g?A=v-2*fu(d.left,d.right):O=b-2*fu(d.top,d.bottom)),await l({...t,availableWidth:A,availableHeight:O});const R=await i.getDimensions(o.floating);return v!==R.width||b!==R.height?{reset:{rects:!0}}:{}}}};function E6(e){const t=Li(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const i=br(e),o=i?e.offsetWidth:n,l=i?e.offsetHeight:s,u=Lk(n)!==o||Lk(s)!==l;return u&&(n=o,s=l),{width:n,height:s,$:u}}function NR(e){return Un(e)?e:e.contextElement}function vg(e){const t=NR(e);if(!br(t))return hu(1);const n=t.getBoundingClientRect(),{width:s,height:i,$:o}=E6(t);let l=(o?Lk(n.width):n.width)/s,u=(o?Lk(n.height):n.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!u||!Number.isFinite(u))&&(u=1),{x:l,y:u}}const Vve=hu(0);function T6(e){const t=vr(e);return!CO()||!t.visualViewport?Vve:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function qve(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===vr(e)}function Rh(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=NR(e);let l=hu(1);t&&(s?Un(s)&&(l=vg(s)):l=vg(e));const u=qve(o,n,s)?T6(o):hu(0);let d=(i.left+u.x)/l.x,f=(i.top+u.y)/l.y,m=i.width/l.x,g=i.height/l.y;if(o&&s){const v=vr(o),b=Un(s)?vr(s):s;let y=v,k=AO(y);for(;k&&b!==y;){const w=vg(k),S=k.getBoundingClientRect(),N=Li(k),C=S.left+(k.clientLeft+parseFloat(N.paddingLeft))*w.x,T=S.top+(k.clientTop+parseFloat(N.paddingTop))*w.y;d*=w.x,f*=w.y,m*=w.x,g*=w.y,d+=C,f+=T,y=vr(k),k=AO(y)}}return Rb({width:m,height:g,x:d,y:f})}function nS(e,t){const n=jk(e).scrollLeft;return t?t.left+n:Rh(lu(e)).left+n}function O6(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-nS(e,n),i=n.top+t.scrollTop;return{x:s,y:i}}function Kve(e){let{elements:t,rect:n,offsetParent:s,strategy:i}=e;const o=i==="fixed",l=lu(s),u=t?yk(t.floating):!1;if(s===l||u&&o)return n;let d={scrollLeft:0,scrollTop:0},f=hu(1);const m=hu(0),g=br(s);if((g||!o)&&((Ha(s)!=="body"||Cb(l))&&(d=jk(s)),g)){const b=Rh(s);f=vg(s),m.x=b.x+s.clientLeft,m.y=b.y+s.clientTop}const v=l&&!g&&!o?O6(l,d):hu(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+m.x+v.x,y:n.y*f.y-d.scrollTop*f.y+m.y+v.y}}function Gve(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Wve(e){const t=jk(e),n=e.ownerDocument.body,s=fu(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=fu(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+nS(e);const l=-t.scrollTop;return Li(n).direction==="rtl"&&(o+=fu(e.clientWidth,n.clientWidth)-s),{width:s,height:i,x:o,y:l}}const Yve=25;function Xve(e,t,n){n===void 0&&(n="viewport");const s=n==="layoutViewport",i=vr(e),o=lu(e),l=i.visualViewport;let u=o.clientWidth,d=o.clientHeight,f=0,m=0;if(l){const v=!CO()||t==="fixed";s?v||(f=-l.offsetLeft,m=-l.offsetTop):(u=l.width,d=l.height,v&&(f=l.offsetLeft,m=l.offsetTop))}if(nS(o)<=0){const v=o.ownerDocument,b=v.body,y=getComputedStyle(b),k=v.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,w=Math.abs(o.clientWidth-b.clientWidth-k),S=getComputedStyle(o).scrollbarGutter==="stable both-edges"?w/2:w;S<=Yve&&(u-=S)}return{width:u,height:d,x:f,y:m}}function Qve(e,t){const n=Rh(e,!0,t==="fixed"),s=n.top+e.clientTop,i=n.left+e.clientLeft,o=vg(e),l=e.clientWidth*o.x,u=e.clientHeight*o.y,d=i*o.x,f=s*o.y;return{width:l,height:u,x:d,y:f}}function R6(e,t,n){let s;if(t==="viewport"||t==="layoutViewport")s=Xve(e,n,t);else if(t==="document")s=Wve(lu(e));else if(Un(t))s=Qve(t,n);else{const i=T6(e);s={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Rb(s)}function Zve(e,t){const n=t.get(e);if(n)return n;let s=ig(e,[],!1).filter(u=>Un(u)&&Ha(u)!=="body"),i=null;const o=Li(e).position==="fixed";let l=o?Pd(e):e;for(;Un(l)&&!Rd(l);){const u=Li(l),d=NO(l),f=i?i.position:o?"fixed":"";!d&&(f==="fixed"||f==="absolute"&&u.position==="static")?s=s.filter(g=>g!==l):i=u,l=Pd(l)}return t.set(e,s),s}function Jve(e){let{element:t,boundary:n,rootBoundary:s,strategy:i}=e;const l=[...n==="clippingAncestors"?yk(t)?[]:Zve(t,this._c):[].concat(n),s],u=R6(t,l[0],i);let d=u.top,f=u.right,m=u.bottom,g=u.left;for(let v=1;v{u(!1,1e-7)},1e3)}A=!1}try{s=new IntersectionObserver(R,{...O,root:o.ownerDocument})}catch{s=new IntersectionObserver(R,O)}s.observe(e)}const d=vr(e),f=()=>u(n);return d.addEventListener("resize",f),u(!0),()=>{d.removeEventListener("resize",f),l()}}function D6(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,f=NR(e),m=i||o?[...f?ig(f):[],...t?ig(t):[]]:[];m.forEach(S=>{i&&S.addEventListener("scroll",n),o&&S.addEventListener("resize",n)});const g=f&&u?sbe(f,n,o):null;let v=-1,b=null;l&&(b=new ResizeObserver(S=>{let[N]=S;N&&N.target===f&&b&&t&&(b.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var C;(C=b)==null||C.observe(t)})),n()}),f&&!d&&b.observe(f),t&&b.observe(t));let y,k=d?Rh(e):null;d&&w();function w(){const S=Rh(e);k&&!_6(k,S)&&n(),k=S,y=requestAnimationFrame(w)}return n(),()=>{var S;m.forEach(N=>{i&&N.removeEventListener("scroll",n),o&&N.removeEventListener("resize",n)}),g?.(),(S=b)==null||S.disconnect(),b=null,d&&cancelAnimationFrame(y)}}const abe=Bve,ibe=Fve,obe=$ve,lbe=Hve,cbe=Uve,ube=(e,t,n)=>{const s=new Map,i=n??{},o={...M6,...i.platform,_c:s};return Lve(e,t,{...i,platform:o})};var dbe=typeof document<"u",fbe=function(){},rS=dbe?p.useLayoutEffect:fbe;function sS(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!sS(e[s],t[s]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,i[s]))return!1;for(s=n;s--!==0;){const o=i[s];if(!(o==="_owner"&&e.$$typeof)&&!sS(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function L6(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $6(e,t){const n=L6(e);return Math.round(t*n)/n}function AR(e){const t=p.useRef(e);return rS(()=>{t.current=e}),t}function hbe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:i,elements:{reference:o,floating:l}={},transform:u=!0,whileElementsMounted:d,open:f}=e,[m,g]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[v,b]=p.useState(s);sS(v,s)||b(s);const[y,k]=p.useState(null),[w,S]=p.useState(null),N=p.useCallback(X=>{X!==O.current&&(O.current=X,k(X))},[]),C=p.useCallback(X=>{X!==A.current&&(A.current=X,S(X))},[]),T=o||y,P=l||w,O=p.useRef(null),A=p.useRef(null),R=p.useRef(m),M=d!=null,_=AR(d),L=AR(i),$=AR(f),D=p.useCallback(()=>{if(!O.current||!A.current)return;const X={placement:t,strategy:n,middleware:v};L.current&&(X.platform=L.current),ube(O.current,A.current,X).then(U=>{const z={...U,isPositioned:$.current!==!1};F.current&&!sS(R.current,z)&&(R.current=z,xr.flushSync(()=>{g(z)}))})},[v,t,n,L,$]);rS(()=>{f===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,g(X=>({...X,isPositioned:!1})))},[f]);const F=p.useRef(!1);rS(()=>(F.current=!0,()=>{F.current=!1}),[]),rS(()=>{if(T&&(O.current=T),P&&(A.current=P),T&&P){if(_.current)return _.current(T,P,D);D()}},[T,P,D,_,M]);const V=p.useMemo(()=>({reference:O,floating:A,setReference:N,setFloating:C}),[N,C]),K=p.useMemo(()=>({reference:T,floating:P}),[T,P]),Q=p.useMemo(()=>{const X={position:n,left:0,top:0};if(!K.floating)return X;const U=$6(K.floating,m.x),z=$6(K.floating,m.y);return u?{...X,transform:"translate("+U+"px, "+z+"px)",...L6(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:z}},[n,u,K.floating,m.x,m.y]);return p.useMemo(()=>({...m,update:D,refs:V,elements:K,floatingStyles:Q}),[m,D,V,K,Q])}const mbe=(e,t)=>{const n=abe(e);return{name:n.name,fn:n.fn,options:[e,t]}},pbe=(e,t)=>{const n=ibe(e);return{name:n.name,fn:n.fn,options:[e,t]}},gbe=(e,t)=>({fn:cbe(e).fn,options:[e,t]}),xbe=(e,t)=>{const n=obe(e);return{name:n.name,fn:n.fn,options:[e,t]}},vbe=(e,t)=>{const n=lbe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var ER={exports:{}},TR={};var z6;function bbe(){if(z6)return TR;z6=1;var e=sg();function t(g,v){return g===v&&(g!==0||1/g===1/v)||g!==g&&v!==v}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,i=e.useEffect,o=e.useLayoutEffect,l=e.useDebugValue;function u(g,v){var b=v(),y=s({inst:{value:b,getSnapshot:v}}),k=y[0].inst,w=y[1];return o(function(){k.value=b,k.getSnapshot=v,d(k)&&w({inst:k})},[g,b,v]),i(function(){return d(k)&&w({inst:k}),g(function(){d(k)&&w({inst:k})})},[g]),l(b),b}function d(g){var v=g.getSnapshot;g=g.value;try{var b=v();return!n(g,b)}catch{return!0}}function f(g,v){return v()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return TR.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,TR}var B6;function F6(){return B6||(B6=1,ER.exports=bbe()),ER.exports}var OR=F6(),RR={exports:{}},PR={};var U6;function ybe(){if(U6)return PR;U6=1;var e=sg(),t=F6();function n(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var s=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,l=e.useEffect,u=e.useMemo,d=e.useDebugValue;return PR.useSyncExternalStoreWithSelector=function(f,m,g,v,b){var y=o(null);if(y.current===null){var k={hasValue:!1,value:null};y.current=k}else k=y.current;y=u(function(){function S(O){if(!N){if(N=!0,C=O,O=v(O),b!==void 0&&k.hasValue){var A=k.value;if(b(A,O))return T=A}return T=O}if(A=T,s(C,O))return A;var R=v(O);return b!==void 0&&b(A,R)?(C=O,A):(C=O,T=R)}var N=!1,C,T,P=g===void 0?null:g;return[function(){return S(m())},P===null?void 0:function(){return S(P())}]},[m,g,v,b]);var w=i(f,y[0],y[1]);return l(function(){k.hasValue=!0,k.value=w},[w]),d(w),w},PR}var H6;function jbe(){return H6||(H6=1,RR.exports=ybe()),RR.exports}var V6=jbe();const wbe=MO(19)?Sbe:Nbe;function q6(e,t,n,s,i){return wbe(e,t,n,s,i)}function kbe(e,t,n,s,i){const o=p.useCallback(()=>t(e.getSnapshot(),n,s,i),[e,t,n,s,i]);return OR.useSyncExternalStore(e.subscribe,o,o)}ove({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=new Set;for(const i of e.syncHooks)n.add(i.store);const s=[];for(const i of n)s.push(i.subscribe(t));return()=>{for(const i of s)i()}}),OR.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Sbe(e,t,n,s,i){const o=ive();if(!o)return kbe(e,t,n,s,i);const l=o.syncIndex;o.syncIndex+=1;let u;return o.didInitialize?(u=o.syncHooks[l],(u.store!==e||u.selector!==t||!Object.is(u.a1,n)||!Object.is(u.a2,s)||!Object.is(u.a3,i))&&(u.store!==e&&(o.didChangeStore=!0),u.store=e,u.selector=t,u.a1=n,u.a2=s,u.a3=i,u.value=t(e.getSnapshot(),n,s,i))):(u={store:e,selector:t,a1:n,a2:s,a3:i,value:t(e.getSnapshot(),n,s,i)},o.syncHooks.push(u)),u.value}function Nbe(e,t,n,s,i){return V6.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,o=>t(o,n,s,i))}class Cbe{constructor(t){Cn(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));Cn(this,"getSnapshot",()=>this.state);this.state=t,this.listeners=new Set,this.updateTick=0}static create(t){return new this(t)}setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const s of this.listeners){if(n!==this.updateTick)return;s(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){const t={...this.state};this.setState(t)}use(t,n,s,i){return q6(this,t,n,s,i)}}class Ph extends Cbe{constructor(t,n={},s){super(t),this.context=n,this.selectors=s}useSyncedValue(t,n){p.useDebugValue(t);const s=this;Ge(()=>{s.state[t]!==n&&s.set(t,n)},[s,t,n])}useSyncedValueWithCleanup(t,n){const s=this;Ge(()=>(s.state[t]!==n&&s.set(t,n),()=>{s.set(t,void 0)}),[s,t,n])}useSyncedValues(t){const n=this,s=Object.values(t);Ge(()=>{n.update(t)},[n,...s])}useControlledProp(t,n){p.useDebugValue(t);const s=this,i=n!==void 0;Ge(()=>{i&&!Object.is(s.state[t],n)&&s.setState({...s.state,[t]:n})},[s,t,n,i])}select(t,n,s,i){const o=this.selectors[t];return o(this.state,n,s,i)}useState(t,n,s,i){return p.useDebugValue(t),q6(this,this.selectors[t],n,s,i)}useContextCallback(t,n){p.useDebugValue(t);const s=Ke(n??Xn);this.context[t]=s}useStateSetter(t){const n=p.useRef(void 0);return n.current===void 0&&(n.current=s=>{this.set(t,s)}),n.current}observe(t,n){let s;typeof t=="function"?s=t:s=this.selectors[t];let i=s(this.state);return n(i,i,this),this.subscribe(o=>{const l=s(o);if(!Object.is(i,l)){const u=i;i=l,n(l,u,this)}})}}const Abe={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};class IR extends Ph{constructor(n){const{syncOnly:s,nested:i,onOpenChange:o,triggerElements:l,...u}=n;super({...u,positionReference:u.referenceElement,domReferenceElement:u.referenceElement},{onOpenChange:o,dataRef:{current:{}},events:v6(),nested:i,triggerElements:l},Abe);Cn(this,"syncOpenEvent",(n,s)=>{(!n||!this.state.open||s!=null&&Kge(s))&&(this.context.dataRef.current.openEvent=n?s:void 0)});Cn(this,"dispatchOpenChange",(n,s)=>{this.syncOpenEvent(n,s.event);const i={open:n,reason:s.reason,nativeEvent:s.event,nested:this.context.nested,triggerElement:s.trigger};this.context.events.emit("openchange",i)});Cn(this,"setOpen",(n,s)=>{if(this.syncOnly){this.context.onOpenChange?.(n,s);return}this.dispatchOpenChange(n,s),this.context.onOpenChange?.(n,s)});this.syncOnly=s}}function Ebe(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:s,floatingId:i,nested:o,onOpenChange:l}=e,u=t.useState("open"),d=t.useState("activeTriggerElement"),f=t.useState(n?"popupElement":"positionerElement"),m=t.context.triggerElements,g=l,v=p.useRef(null);s===void 0&&v.current===null&&(v.current=new IR({open:u,transitionStatus:void 0,referenceElement:d,floatingElement:f,triggerElements:m,onOpenChange:g,floatingId:i,syncOnly:!0,nested:o}));const b=s??v.current;return t.useSyncedValue("floatingId",i),Ge(()=>{const y={open:u,floatingId:i,referenceElement:d,floatingElement:f};Un(d)&&(y.domReferenceElement=d),b.state.positionReference===b.state.referenceElement&&(y.positionReference=d),b.update(y)},[u,i,d,f,b]),b.context.onOpenChange=g,b.context.nested=o,b}const Ub={tabIndex:-1,[HO]:""};function K6(e){return t=>t==="touch"?e.current:!0}function MR(e,t=!1){const n=lg(),s=xg()!=null,i=$s(()=>e(n,s)).current;return Ebe({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:s,onOpenChange:i.setOpen}),i}function _R({handle:e,store:t}){return Ge(()=>e.attachStore(t),[e,t]),null}function G6(e){const t=e.context.triggerElements.size;e.select("open")&&e.state.triggerCount!==t&&e.set("triggerCount",t)}function Tbe(e,t){const n=p.useRef(null);return Ke(s=>{const i=n.current;if(i!==null){if(i.element===s&&i.store===t&&i.id===e)return;n.current=null;const o=i.store;o.context.triggerElements.getById(i.id)===i.element&&(o.context.triggerElements.delete(i.id),G6(o))}s!==null&&e!==void 0&&(n.current={store:t,id:e,element:s},t.context.triggerElements.add(e,s),G6(t))})}function DR(e,t,n,s=!1){let i=e.preventUnmountingOnClose;t?i=!1:s&&(i=!0);const o=n?.id??null;let l=e.activeTriggerId,u=e.activeTriggerElement;return(o||t)&&(l=o,u=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:l,activeTriggerElement:u}}function W6(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Obe(e,t,n,s={}){const i=n.reason,o=i===Va,l=t&&i===Gk,u=!t&&(i===xu||i===mg),d=W6(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;s.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);const f=()=>{const m=DR(e.state,t,n.trigger,d()),g={...s.extraState,...m};l?g.instantType="focus":u?g.instantType="dismiss":o&&(g.instantType=void 0),e.update(g)};o?xr.flushSync(f):f()}function LR(e,t,n,s){const i=n.useState("isMountedByTrigger",e),o=Tbe(e,n),l=Ke(d=>{const f=n.select("open"),m=n.select("activeTriggerId");if(m===e){const g={activeTriggerElement:d,...f?s:null};n.update(g);return}if(m==null&&f){const g={activeTriggerId:e??null,activeTriggerElement:d,...s};n.update(g)}}),u=Ke(d=>{o(d),d&&l(d)});return Ge(()=>(u(t.current),()=>u(null)),[u,t,n,e]),Ge(()=>{if(i){const d={activeTriggerElement:t.current,...s};n.update(d)}},[i,n,t,...Object.values(s)]),{registerTrigger:u,isMountedByThisTrigger:i}}function $R(e,t={}){const{closeOnActiveTriggerUnmount:n=!1}=t,s=p.useRef(null),i=e.useState("open"),o=e.useState("triggerCount"),l=e.useState("activeTriggerId"),u=e.useState("activeTriggerElement");Ge(()=>{if(!i){s.current=null,e.state.triggerCount!==0&&e.set("triggerCount",0);return}const d=e.context.triggerElements.size,f={};e.state.triggerCount!==d&&(f.triggerCount=d);const m=e.select("activeTriggerId");let g=null;if(m){const v=e.context.triggerElements.getById(m);if(v)s.current=m,v!==e.state.activeTriggerElement&&(f.activeTriggerElement=v);else{for(const[b,y]of e.context.triggerElements.entries())if(y===e.state.activeTriggerElement){f.activeTriggerId=b,f.activeTriggerElement=y,s.current=b;break}f.activeTriggerId===void 0&&(s.current===m?g=m:s.current=null)}}else s.current=null;if(!g&&!m&&d===1){const v=e.context.triggerElements.entries().next();if(!v.done){const[b,y]=v.value;f.activeTriggerId=b,f.activeTriggerElement=y,s.current=b}}(f.triggerCount!==void 0||f.activeTriggerId!==void 0||f.activeTriggerElement!==void 0)&&e.update(f),g&&n&&queueMicrotask(()=>{if(e.select("open")&&e.select("activeTriggerId")===g&&!e.context.triggerElements.getById(g)){const v=Nt(rs);e.setOpen(!1,v),v.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,o,l,u,n])}function zR(e,t,n,s){const{mounted:i,setMounted:o,transitionStatus:l}=gu(e,!1,!1,s),u=t.useState("preventUnmountingOnClose"),d=e?!1:u;t.useSyncedValues({mounted:i,transitionStatus:l,preventUnmountingOnClose:d});const f=Ke(()=>{o(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return ji({enabled:i&&!e&&!d,open:e,ref:t.context.popupRef,onComplete(){e||f()}}),{forceUnmount:f,transitionStatus:l}}function BR(e,t){e.useSyncedValues(t),Ge(()=>()=>{e.update({activeTriggerProps:yr,inactiveTriggerProps:yr,popupProps:yr})},[e])}function Y6(e,t){Ge(()=>{!t&&e.state.openMethod!==null&&e.set("openMethod",null)},[t,e]),Ge(()=>()=>{e.state.openMethod!==null&&e.set("openMethod",null)},[e])}class aS{constructor(){this.idMap=new Map}add(t,n){this.idMap.set(t,n)}delete(t){this.idMap.delete(t)}hasElement(t){for(const n of this.idMap.values())if(n===t)return!0;return!1}hasMatchingElement(t){for(const n of this.idMap.values())if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}}function FR(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new IR({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:yr,inactiveTriggerProps:yr,popupProps:yr}}const Hb=e=>e.triggerIdProp??e.activeTriggerId,UR=e=>e.openProp??e.open,X6=e=>(e.popupElement?.id??e.floatingId)||void 0;function Q6(e,t){return t!==void 0&&UR(e)&&Hb(e)===t}function Rbe(e,t){return Q6(e,t)?!0:t!==void 0&&UR(e)&&Hb(e)==null&&e.triggerCount===1}const HR={open:UR,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Hb,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:X6,isTriggerActive:(e,t)=>t!==void 0&&Hb(e)===t,isOpenedByTrigger:(e,t)=>Q6(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Hb(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Rbe(e,t)?X6(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function VR(e){const t=p.useCallback(s=>e===void 0?Xn:e.subscribeStore(s),[e]),n=p.useCallback(()=>e===void 0?void 0:e.store,[e]);return OR.useSyncExternalStore(t,n,()=>e?.serverStore)}function Z6(e){const{open:t=!1,onOpenChange:n,elements:s={}}=e,i=lg(),o=xg()!=null,l=$s(()=>new IR({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:s.reference??null,floatingElement:s.floating??null,triggerElements:new aS,floatingId:i,syncOnly:!1,nested:o})).current;return Ge(()=>{const u={open:t,floatingId:i};s.reference!==void 0&&(u.referenceElement=s.reference,u.domReferenceElement=Un(s.reference)?s.reference:null),s.floating!==void 0&&(u.floatingElement=s.floating),l.update(u)},[t,i,s.reference,s.floating,l]),l.context.onOpenChange=n,l.context.nested=o,l}function Pbe(e){return Ibe(e,e.rootContext)}function Ibe(e,t){const{nodeId:n,externalTree:s}=e,i=t.useState("referenceElement"),o=t.useState("floatingElement"),l=t.useState("domReferenceElement"),u=t.useState("open"),d=t.useState("floatingId"),[f,m]=p.useState(null),[g,v]=p.useState(void 0),[b,y]=p.useState(void 0),k=p.useRef(null),w=Oh(s),S=p.useMemo(()=>({reference:i,floating:o,domReference:l}),[i,o,l]),N=hbe({...e,elements:{...S,...f&&{reference:f}}}),C=Un(g)?g:null,T=b===void 0?t.state.floatingElement:b;t.useSyncedValue("referenceElement",g??null),t.useSyncedValue("domReferenceElement",g===void 0?l:C),t.useSyncedValue("floatingElement",T);const P=p.useCallback(L=>{const $=Un(L)?{getBoundingClientRect:()=>L.getBoundingClientRect(),getClientRects:()=>L.getClientRects(),contextElement:L}:L;m($),N.refs.setReference($)},[N.refs]),O=p.useCallback(L=>{(Un(L)||L===null)&&(k.current=L,v(L)),(Un(N.refs.reference.current)||N.refs.reference.current===null||L!==null&&!Un(L))&&N.refs.setReference(L)},[N.refs,v]),A=p.useCallback(L=>{y(L),N.refs.setFloating(L)},[N.refs]),R=p.useMemo(()=>({...N.refs,setReference:O,setFloating:A,setPositionReference:P,domReference:k}),[N.refs,O,A,P]),M=p.useMemo(()=>({...N.elements,domReference:l}),[N.elements,l]),_=p.useMemo(()=>({...N,dataRef:t.context.dataRef,open:u,onOpenChange:t.setOpen,events:t.context.events,floatingId:d,refs:R,elements:M,nodeId:n,rootStore:t}),[N,R,M,n,t,u,d]);return Ge(()=>{l&&(k.current=l)},[l]),Ge(()=>{t.context.dataRef.current.floatingContext=_;const L=w?.nodesRef.current.find($=>$.id===n);L&&(L.context=_)}),p.useMemo(()=>({...N,context:_,refs:R,elements:M,rootStore:t}),[N,R,M,_,t])}const qR=xU&&du;function Mbe(e,t={}){const{enabled:n=!0,delay:s}=t,i="rootStore"in e?e.rootStore:e,{events:o,dataRef:l}=i.context,u=p.useRef(!1),d=p.useRef(null),f=p.useRef(!0),m=fa();p.useEffect(()=>{const v=i.select("domReferenceElement");if(!n)return;const b=vr(v);function y(){const S=i.select("domReferenceElement");!i.select("open")&&br(S)&&S===Ys(_n(S))&&(u.current=!0,d.current=S)}function k(){f.current=!0}function w(){f.current=!1}return Ol(kn(b,"blur",y),qR&&kn(b,"keydown",k,!0),qR&&kn(b,"pointerdown",w,!0))},[i,n]),p.useEffect(()=>{if(!n)return;function v(b){if(b.reason===xu||b.reason===mg){const y=i.select("domReferenceElement");Un(y)&&(d.current=y,u.current=!0)}}return o.on("openchange",v),()=>{o.off("openchange",v)}},[o,n,i]);const g=p.useMemo(()=>{function v(){u.current=!1,d.current=null}return{onMouseLeave(){v()},onFocus(b){const y=b.currentTarget;if(u.current){if(d.current===y)return;v()}const k=Er(b.nativeEvent);if(Un(k)){if(qR&&!b.relatedTarget){if(!f.current&&!Ik(k))return}else if(!Mk(k))return}const w=Pk(b.relatedTarget,i.context.triggerElements),{nativeEvent:S,currentTarget:N}=b,C=typeof s=="function"?s():s;if(i.select("open")&&w||C===0||C===void 0){i.setOpen(!0,Nt(Gk,S,N));return}m.start(C,()=>{u.current||i.setOpen(!0,Nt(Gk,S,N))})},onBlur(b){v();const y=b.relatedTarget,k=b.nativeEvent,w=Un(y)&&y.hasAttribute($b("focus-guard"))&&y.getAttribute("data-type")==="outside";m.start(0,()=>{const S=i.select("domReferenceElement"),N=Ys(_n(S));!y&&N===S||Et(l.current.floatingContext?.refs.floating.current,N)||Et(S,N)||w||Pk(y??N,i.context.triggerElements)||i.setOpen(!1,Nt(Gk,k))})}}},[l,s,i,m]);return p.useMemo(()=>n?{reference:g,trigger:g}:{},[n,g])}class KR{constructor(){Cn(this,"dispose",()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()});Cn(this,"disposeEffect",()=>this.dispose);this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new Bi,this.restTimeout=new Bi,this.handleCloseOptions=void 0}static create(){return new KR}}const iS=new WeakMap;function oS(e){if(!e.performedPointerEventsMutation)return;const t=e.pointerEventsScopeElement;t&&iS.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),iS.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function J6(e,t){const{scopeElement:n,referenceElement:s,floatingElement:i}=t,o=iS.get(n);o&&o!==e&&oS(o),oS(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=s,e.pointerEventsFloatingElement=i,iS.set(n,e),n.style.pointerEvents="none",s.style.pointerEvents="auto",i.style.pointerEvents="auto"}function GR(e){const t=e.context.dataRef.current,n=$s(()=>t.hoverInteractionState??KR.create()).current;return t.hoverInteractionState||(t.hoverInteractionState=n),Uk(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function eH(e,t={}){const{enabled:n=!0,closeDelay:s=0,nodeId:i}=t,o="rootStore"in e?e.rootStore:e,l=o.useState("open"),u=o.useState("floatingElement"),d=o.useState("domReferenceElement"),{dataRef:f}=o.context,m=Oh(),g=xg(),v=GR(o),b=fa(),y=Ke(()=>a6(f.current.openEvent?.type,v.interactedInside)),k=Ke(()=>uve(f.current.openEvent?.type)),w=Ke(()=>{oS(v)});Ge(()=>{l||(v.pointerType=void 0,v.restTimeoutPending=!1,v.interactedInside=!1,w())},[l,v,w]),p.useEffect(()=>w,[w]),Ge(()=>{if(n&&l&&v.handleCloseOptions?.blockPointerEvents&&k()&&Un(d)&&u){const S=d,N=u,C=_n(u),T=m?.nodesRef.current.find(R=>R.id===g)?.context?.elements.floating;T&&(T.style.pointerEvents="");const P=v.pointerEventsScopeElement!==N?v.pointerEventsScopeElement:null,O=T!==N?T:null,A=v.handleCloseOptions?.getScope?.()??P??O??S.closest("[data-rootownerid]")??C.body;return J6(v,{scopeElement:A,referenceElement:S,floatingElement:N}),()=>{w()}}},[n,l,d,u,v,k,m,g,w]),p.useEffect(()=>{if(!n)return;function S(){return!!(m&&g&&Dd(m.nodesRef.current,g).length>0)}function N(R){const M=Eh(s,"close",v.pointerType),_=()=>{o.setOpen(!1,Nt(Va,R)),m?.events.emit("floating.closed",R)};M?v.openChangeTimeout.start(M,_):(v.openChangeTimeout.clear(),_())}function C(R){const M=Er(R);if(!Vge(M)){v.interactedInside=!1;return}v.interactedInside=M?.closest("[aria-haspopup]")!=null}function T(){v.openChangeTimeout.clear(),b.clear(),m?.events.off("floating.closed",O),w()}function P(R){if(S()&&m){m.events.on("floating.closed",O);return}if(Pk(R.relatedTarget,o.context.triggerElements))return;const M=f.current.floatingContext?.nodeId??i,_=R.relatedTarget;if(!(m&&M&&Un(_)&&Dd(m.nodesRef.current,M,!1).some($=>Et($.context?.elements.floating,_)))){if(v.handler){v.handler(R);return}w(),k()&&!y()&&N(R)}}function O(R){!m||!g||S()||b.start(0,()=>{m.events.off("floating.closed",O),o.setOpen(!1,Nt(Va,R)),m.events.emit("floating.closed",R)})}const A=u;return Ol(A&&kn(A,"mouseenter",T),A&&kn(A,"mouseleave",P),A&&kn(A,"pointerdown",C,!0),()=>{m?.events.off("floating.closed",O)})},[n,u,o,f,s,i,k,y,w,v,m,g,b])}const _be={current:null};function tH(e,t={}){const{enabled:n=!0,delay:s=0,handleClose:i=null,mouseOnly:o=!1,restMs:l=0,move:u=!0,triggerElementRef:d=_be,externalTree:f,isActiveTrigger:m=!0,getHandleCloseContext:g,isClosing:v,shouldOpen:b,guardStaleOpen:y=!1}=t,k="rootStore"in e?e.rootStore:e,{dataRef:w,events:S}=k.context,N=Oh(f),C=GR(k),T=p.useRef(!1),P=ss(i),O=ss(s),A=ss(l),R=ss(n),M=ss(b),_=ss(v),L=Ke(()=>a6(w.current.openEvent?.type,C.interactedInside)),$=Ke(()=>M.current?.()!==!1),D=Ke((K,Q,X)=>{const U=k.context.triggerElements;if(U.hasElement(Q))return!K||!Et(K,Q);if(!Un(X))return!1;const z=X;return U.hasMatchingElement(q=>Et(q,z))&&(!K||!Et(K,z))}),F=Ke(()=>{if(!C.handler)return;_n(k.select("domReferenceElement")).removeEventListener("mousemove",C.handler),C.handler=void 0}),V=Ke(()=>{oS(C)});return m&&(C.handleCloseOptions=i?.__options),p.useEffect(()=>F,[F]),p.useEffect(()=>{if(!n)return;function K(Q){Q.open?T.current=!1:(T.current=Q.reason===Va,F(),C.openChangeTimeout.clear(),C.restTimeout.clear(),C.blockMouseMove=!0,C.restTimeoutPending=!1)}return S.on("openchange",K),()=>{S.off("openchange",K)}},[n,S,C,F]),p.useEffect(()=>{if(!n)return;function K(J,ee=!0){const H=Eh(O.current,"close",C.pointerType);H?C.openChangeTimeout.start(H,()=>{k.setOpen(!1,Nt(Va,J)),N?.events.emit("floating.closed",J)}):ee&&(C.openChangeTimeout.clear(),k.setOpen(!1,Nt(Va,J)),N?.events.emit("floating.closed",J))}const Q=d.current??(m?k.select("domReferenceElement"):null);if(!Un(Q))return;function X(J){if(C.openChangeTimeout.clear(),C.blockMouseMove=!1,o&&!Ld(C.pointerType))return;const ee=s6(A.current),H=Eh(O.current,"open",C.pointerType),G=Er(J),Y=J.currentTarget??null,se=k.select("domReferenceElement");let re=Y;if(Un(G)&&!k.context.triggerElements.hasElement(G)){for(const ce of k.context.triggerElements.elements())if(Et(ce,G)){re=ce;break}}Un(Y)&&Un(se)&&!k.context.triggerElements.hasElement(Y)&&Et(Y,se)&&(re=se);const ne=re==null?!1:D(se,re,G),de=k.select("open"),ie=_.current?.()??k.select("transitionStatus")==="ending",oe=!de&&ie&&T.current,je=!ne&&Un(re)&&Un(se)&&Et(se,re)&&oe,te=ee>0&&!H,le=ne&&(de||oe)||je,he=!de||ne;if(le){$()&&k.setOpen(!0,Nt(Va,J,re));return}te||(H?C.openChangeTimeout.start(H,()=>{he&&$()&&k.setOpen(!0,Nt(Va,J,re))}):he&&$()&&k.setOpen(!0,Nt(Va,J,re)))}function U(J){if(L()){V();return}F();const ee=k.select("domReferenceElement"),H=_n(ee);C.restTimeout.clear(),C.restTimeoutPending=!1;const G=w.current.floatingContext??g?.();if(Pk(J.relatedTarget,k.context.triggerElements))return;if(P.current&&G){k.select("open")||C.openChangeTimeout.clear();const se=d.current;C.handler=P.current({...G,tree:N,x:J.clientX,y:J.clientY,onClose(){V(),F(),R.current&&!L()&&se===k.select("domReferenceElement")&&K(J,!0)}}),H.addEventListener("mousemove",C.handler),C.handler(J);return}(C.pointerType!=="touch"||!Et(k.select("floatingElement"),J.relatedTarget))&&K(J)}function z(J){Et(Q,J.relatedTarget)||(C.openChangeTimeout.clear(),C.restTimeout.clear(),C.restTimeoutPending=!1)}const q=y?kn(Q,"mouseout",z):void 0;return u?Ol(kn(Q,"mousemove",X,{once:!0}),kn(Q,"mouseenter",X),kn(Q,"mouseleave",U),q):Ol(kn(Q,"mouseenter",X),kn(Q,"mouseleave",U),q)},[F,V,w,O,k,n,P,C,m,D,L,o,u,A,d,N,R,g,_,$,y]),p.useMemo(()=>{if(!n)return;function K(Q){C.pointerType=Q.pointerType}return{onPointerDown:K,onPointerEnter:K,onMouseMove(Q){const{nativeEvent:X}=Q,U=Q.currentTarget,z=k.select("domReferenceElement"),q=k.select("open"),J=D(z,U,Q.target);if(o&&!Ld(C.pointerType))return;if(q&&J&&C.handleCloseOptions?.blockPointerEvents){const G=k.select("floatingElement");if(G){const Y=C.handleCloseOptions?.getScope?.()??U.ownerDocument.body;J6(C,{scopeElement:Y,referenceElement:U,floatingElement:G})}}const ee=s6(A.current);if(q&&!J||ee===0||!J&&C.restTimeoutPending&&Q.movementX**2+Q.movementY**2<2)return;C.restTimeout.clear();function H(){if(C.restTimeoutPending=!1,L())return;const G=k.select("open");!C.blockMouseMove&&(!G||J)&&$()&&k.setOpen(!0,Nt(Va,X,U))}C.pointerType==="touch"?xr.flushSync(()=>{H()}):J&&q?H():(C.restTimeoutPending=!0,C.restTimeout.start(ee,H))}}},[n,C,L,D,o,k,A,$])}const Dbe="Escape";function nH(e){return du&&e.movementX===0&&e.movementY===0}function lS(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function cS(e,t){return lS(t,e===VO||e===Ok,e===Sh||e===Nh)}function WR(e,t,n){return lS(t,e===Ok,n?e===Sh:e===Nh)||e==="Enter"||e===" "||e===""}function Lbe(e,t,n){return lS(t,n?e===Sh:e===Nh,e===Ok)}function $be(e,t,n,s){const i=n?e===Nh:e===Sh,o=e===VO;return t==="both"||t==="horizontal"&&s?e===Dbe:lS(t,i,o)}function rH(e,t){const{listRef:n,activeIndex:s,onNavigate:i=()=>{},enabled:o=!0,selectedIndex:l=null,allowEscape:u=!1,loopFocus:d=!1,nested:f=!1,rtl:m=!1,virtual:g=!1,focusItemOnOpen:v="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:y=!0,disabledIndices:k=void 0,orientation:w="vertical",parentOrientation:S,id:N,resetOnPointerLeave:C=!0,externalTree:T,grid:P}=t,O=P!=null,A="rootStore"in e?e.rootStore:e,R=A.useState("open"),M=A.useState("floatingElement"),_=A.useState("domReferenceElement"),L=A.context.dataRef,$=_k(M),D=XO(_),F=ss($),V=xg(),K=Oh(T),Q=p.useRef(v),X=p.useRef(l??-1),U=p.useRef(null),z=p.useRef(!0),q=Ke(ge=>{i(X.current===-1?null:X.current,ge)}),J=p.useRef(!!M),ee=p.useRef(R),H=p.useRef(!1),G=p.useRef(!1),Y=p.useRef(null),se=ss(k),re=ss(R),ne=ss(l),de=ss(C),ie=fg(),oe=fg(),je=Ke(()=>{function ge(De){g?K?.events.emit("virtualfocus",De):Y.current=Jk(De,{sync:H.current,preventScroll:!0})}const ue=n.current[X.current],be=G.current;ue&&ge(ue),(H.current?De=>De():De=>ie.request(De))(()=>{const De=n.current[X.current]||ue;if(!De)return;ue||ge(De),fe&&(be||!z.current)&&De.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Ge(()=>{L.current.orientation=w},[L,w]),Ge(()=>{o&&(R&&M?(X.current=l??-1,Q.current&&l!=null&&(G.current=!0,q())):J.current&&(X.current=-1,q()))},[o,R,M,l,q]),Ge(()=>{if(o){if(!R){H.current=!1;return}if(M)if(s==null){if(H.current=!1,ne.current!=null)return;if(J.current&&(X.current=-1,je()),(!ee.current||!J.current)&&Q.current&&(U.current!=null||Q.current===!0&&U.current==null)){let ge=0;const ue=()=>{n.current[0]==null?(ge<2&&(ge?ve=>oe.request(ve):queueMicrotask)(ue),ge+=1):(X.current=U.current==null||WR(U.current,w,m)||f?Bk(n):nR(n),U.current=null,q())};ue()}}else zd(n.current,s)||(X.current=s,je(),G.current=!1)}},[o,R,M,s,ne,f,n,w,m,q,je,oe]),Ge(()=>{if(!o||M||!K||g||!J.current)return;const ge=K.nodesRef.current,ue=ge.find(De=>De.id===V)?.context?.elements.floating,be=Ys(_n(_??ue??null)),ve=ge.some(De=>De.context&&Et(De.context.elements.floating,be));ue&&!ve&&z.current&&ue.focus({preventScroll:!0})},[o,M,_,K,V,g]),Ge(()=>{ee.current=R,J.current=!!M}),Ge(()=>{R||(U.current=null,Q.current=v)},[R,v]);const te=s!=null,le=Ke(ge=>{if(!re.current)return;const ue=n.current.indexOf(ge.currentTarget);ue!==-1&&(X.current!==ue||s!==ue)&&(X.current=ue,q(ge))}),he=Ke(()=>S??K?.nodesRef.current.find(ge=>ge.id===V)?.context?.dataRef?.current.orientation),ce=Ke(()=>Bk(n,se.current)),ye=Ke(ge=>{if(z.current=!1,H.current=!0,ge.which===229||!re.current&&ge.currentTarget===F.current)return;if(f&&$be(ge.key,w,m,O)){cS(ge.key,he())||da(ge),A.setOpen(!1,Nt(fR,ge.nativeEvent)),br(_)&&(g?K?.events.emit("virtualfocus",_):_.focus());return}const ue=X.current,be=Bk(n,k),ve=nR(n,k);if(D||(ge.key==="Home"&&(da(ge),X.current=be,q(ge)),ge.key==="End"&&(da(ge),X.current=ve,q(ge))),P!=null){const De=P(ge,X.current,n,w,d,m,k,be,ve);if(De!=null&&(X.current=De,q(ge)),w==="both")return}if(cS(ge.key,w)){if(da(ge),R&&!g&&Ys(ge.currentTarget.ownerDocument)===ge.currentTarget){X.current=WR(ge.key,w,m)?be:ve,q(ge);return}WR(ge.key,w,m)?d?ue>=ve?u&&ue!==n.current.length?X.current=-1:(H.current=!1,X.current=be):X.current=Ta(n.current,{startingIndex:ue,disabledIndices:k}):X.current=Math.min(ve,Ta(n.current,{startingIndex:ue,disabledIndices:k})):d?ue<=be?u&&ue!==-1?X.current=n.current.length:(H.current=!1,X.current=ve):X.current=Ta(n.current,{startingIndex:ue,decrement:!0,disabledIndices:k}):X.current=Math.max(be,Ta(n.current,{startingIndex:ue,decrement:!0,disabledIndices:k})),zd(n.current,X.current)&&(X.current=-1),q(ge)}}),fe=p.useMemo(()=>({onFocus(ue){H.current=!0,le(ue)},onClick:({currentTarget:ue})=>ue.focus({preventScroll:!0}),onMouseMove(ue){nH(ue)||(H.current=!0,G.current=!1,b&&le(ue))},onPointerLeave(ue){if(!re.current||!z.current||ue.pointerType==="touch")return;H.current=!0;const be=ue.relatedTarget;if(!(!b||n.current.includes(be))&&de.current&&(Y.current?.(),Y.current=null,X.current=-1,q(ue),!g)){const ve=F.current,De=Ys(_n(ve));ve&&Et(ve,De)&&ve.focus({preventScroll:!0})}}}),[le,re,F,b,n,q,de,g]),Le=p.useMemo(()=>g&&R&&te&&{"aria-activedescendant":`${N}-${s}`},[g,R,te,N,s]),pe=p.useMemo(()=>({...D?{}:Le,onKeyDown(ge){if(ge.key==="Tab"&&ge.shiftKey&&R&&!g){const ue=Er(ge.nativeEvent);if(ue&&!Et(F.current,ue))return;da(ge),A.setOpen(!1,Nt(Fd,ge.nativeEvent)),br(_)&&_.focus();return}ye(ge)},onPointerMove(ge){nH(ge)||(z.current=!0)}}),[Le,ye,F,D,A,R,g,_]),xe=p.useMemo(()=>{function ge(ve){A.setOpen(!0,Nt(fR,ve.nativeEvent,ve.currentTarget))}function ue(ve){v==="auto"&&Dk(ve.nativeEvent)&&(Q.current=!g)}function be(ve){Q.current=v,v==="auto"&&QO(ve.nativeEvent)&&(Q.current=!0)}return{onKeyDown(ve){const De=A.select("open");z.current=!1;const Ie=ve.key.startsWith("Arrow"),We=Lbe(ve.key,he(),m),nt=cS(ve.key,w),kt=(f?We:nt)||ve.key==="Enter"||ve.key.trim()==="";if(g&&De)return ye(ve);if(!(!De&&!y&&Ie)){if(kt){const Je=cS(ve.key,he());U.current=f&&Je?null:ve.key}if(f){We&&(da(ve),De?(X.current=ce(),q(ve)):ge(ve));return}nt&&(ne.current!=null&&(X.current=ne.current),da(ve),!De&&y?ge(ve):ye(ve),De&&q(ve))}},onFocus(ve){A.select("open")&&!g&&(X.current=-1,q(ve))},onPointerDown:be,onPointerEnter:be,onMouseDown:ue,onClick:ue}},[ye,v,ce,f,q,A,y,w,he,m,ne,g]),Se=p.useMemo(()=>({...Le,...xe}),[Le,xe]);return p.useMemo(()=>o?{reference:Se,floating:pe,item:fe,trigger:xe}:{},[o,Se,pe,xe,fe])}function sH(e,t){const{listRef:n,elementsRef:s,activeIndex:i,onMatch:o,disabledIndices:l,onTyping:u,enabled:d=!0,resetMs:f=750,selectedIndex:m=null}=t,g="rootStore"in e?e.rootStore:e,v=g.useState("open"),b=fa(),y=p.useRef(""),k=p.useRef(m??i??-1),w=p.useRef(null),S=Ke(T=>{function P(F){return s?.current[F]}function O(F){const V=P(F);return V&&!Fk(V)||V?.matches(":disabled")?!1:l==null||!Bd(co,F,l)}function A(F,V,K=0){if(F.length===0)return-1;const Q=(K%F.length+F.length)%F.length,X=V.toLowerCase();for(let U=0;U0&&T.key===" "&&(da(T),u?.(!0)),y.current.length>0&&y.current[0]!==" "&&A(R,y.current)===-1&&T.key!==" "&&u?.(!1),R==null||T.key.length!==1||T.ctrlKey||T.metaKey||T.altKey)return;v&&T.key!==" "&&(da(T),u?.(!0));const M=y.current==="";M&&(k.current=m??i??-1),R.every((F,V)=>F&&O(V)?F[0]?.toLowerCase()!==F[1]?.toLowerCase():!0)&&y.current===T.key&&(y.current="",k.current=w.current),y.current+=T.key,b.start(f,()=>{y.current="",k.current=w.current,u?.(!1)});const $=((M?m??i??-1:k.current)??0)+1,D=A(R,y.current,$);D!==-1?(o?.(D),w.current=D):T.key!==" "&&(y.current="",u?.(!1))}),N=Ke(T=>{const P=T.relatedTarget,O=g.select("domReferenceElement"),A=g.select("floatingElement");Et(O,P)||Et(A,P)||(b.clear(),y.current="",k.current=w.current,u?.(!1))});Ge(()=>{!v&&m!==null||(b.clear(),w.current=null,y.current!==""&&(y.current=""))},[v,m,b]);const C=p.useMemo(()=>({onKeyDown:S,onBlur:N}),[S,N]);return p.useMemo(()=>d?{reference:C,floating:C}:{},[d,C])}const aH=.1,zbe=aH*aH,Dr=.5;function uS(e,t,n,s,i,o){return s>=t!=o>=t&&e<=(i-n)*(t-s)/(o-s)+n}function dS(e,t,n,s,i,o,l,u,d,f){let m=!1;return uS(e,t,n,s,i,o)&&(m=!m),uS(e,t,i,o,l,u)&&(m=!m),uS(e,t,l,u,d,f)&&(m=!m),uS(e,t,d,f,n,s)&&(m=!m),m}function Bbe(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function fS(e,t,n,s,i,o){const l=Math.min(n,i),u=Math.max(n,i),d=Math.min(s,o),f=Math.max(s,o);return e>=l&&e<=u&&t>=d&&t<=f}function iH(e={}){const{blockPointerEvents:t=!1}=e,n=new Bi,s=({x:i,y:o,placement:l,elements:u,onClose:d,nodeId:f,tree:m})=>{const g=l?.split("-")[0];let v=!1,b=null,y=null,k=typeof performance<"u"?performance.now():0;function w(N,C){const T=performance.now(),P=T-k;if(b===null||y===null||P===0)return b=N,y=C,k=T,!1;const O=N-b,A=C-y,R=O*O+A*A,M=P*P*zbe;return b=N,y=C,k=T,R0)}function D(){$()||S()}if($())return;const F=T.getBoundingClientRect(),V=P.getBoundingClientRect(),K=i>V.right-V.width/2,Q=o>V.bottom-V.height/2,X=V.width>F.width,U=V.height>F.height,z=(X?F:V).left,q=(X?F:V).right,J=(U?F:V).top,ee=(U?F:V).bottom;if(g==="top"&&o>=F.bottom-1||g==="bottom"&&o<=F.top+1||g==="left"&&i>=F.right-1||g==="right"&&i<=F.left+1){D();return}let H=!1;switch(g){case"top":H=fS(O,A,z,F.top+1,q,V.bottom-1);break;case"bottom":H=fS(O,A,z,V.top+1,q,F.bottom-1);break;case"left":H=fS(O,A,V.right-1,ee,F.left+1,J);break;case"right":H=fS(O,A,F.right-1,ee,V.left+1,J);break}if(H)return;if(v&&!Bbe(O,A,F)){D();return}if(!M&&w(O,A)){D();return}let G=!1;switch(g){case"top":{const Y=X?Dr/2:Dr*4,se=X||K?i+Y:i-Y,re=X?i-Y:K?i+Y:i-Y,ne=o+Dr+1,de=K||X?V.bottom-Dr:V.top,ie=K?X?V.bottom-Dr:V.top:V.bottom-Dr;G=dS(O,A,se,ne,re,ne,V.left,de,V.right,ie);break}case"bottom":{const Y=X?Dr/2:Dr*4,se=X||K?i+Y:i-Y,re=X?i-Y:K?i+Y:i-Y,ne=o-Dr,de=K||X?V.top+Dr:V.bottom,ie=K?X?V.top+Dr:V.bottom:V.top+Dr;G=dS(O,A,se,ne,re,ne,V.left,de,V.right,ie);break}case"left":{const Y=U?Dr/2:Dr*4,se=U||Q?o+Y:o-Y,re=U?o-Y:Q?o+Y:o-Y,ne=i+Dr+1,de=Q||U?V.right-Dr:V.left,ie=Q?U?V.right-Dr:V.left:V.right-Dr;G=dS(O,A,de,V.top,ie,V.bottom,ne,se,ne,re);break}case"right":{const Y=U?Dr/2:Dr*4,se=U||Q?o+Y:o-Y,re=U?o-Y:Q?o+Y:o-Y,ne=i-Dr,de=Q||U?V.left+Dr:V.right,ie=Q?U?V.left+Dr:V.right:V.left+Dr;G=dS(O,A,ne,se,ne,re,de,V.top,ie,V.bottom);break}}G?v||n.start(40,D):D()}};return s.__options={...e,blockPointerEvents:t},s}const Fbe={...HR,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class Ube extends Ph{constructor(n,s,i){const o=new aS;super(Hbe(n,o,s,i),Vbe(o),Fbe);Cn(this,"setOpen",(n,s)=>{Obe(this,n,s,{extraState:{openChangeReason:s.reason}})})}cancelPendingOpen(n){this.state.floatingRootContext.dispatchOpenChange(!1,Nt(xu,n))}}function Hbe(e,t,n,s=!1){return{...FR(t,n,s),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function Vbe(e){return{popupRef:p.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}const qbe=Qk(function(t){const{disabled:n=!1,defaultOpen:s=!1,open:i,disableHoverablePopup:o=!1,trackCursorAxis:l="none",actionsRef:u,onOpenChange:d,onOpenChangeComplete:f,handle:m,triggerId:g,defaultTriggerId:v=null,children:b}=t,y=MR((L,$)=>new Ube({open:s,openProp:i,activeTriggerId:v,triggerIdProp:g},L,$));y.useControlledProp("openProp",i),y.useControlledProp("triggerIdProp",g),y.useContextCallback("onOpenChange",d),y.useContextCallback("onOpenChangeComplete",f);const k=y.useState("open"),w=!n&&k,S=y.useState("activeTriggerId"),N=y.useState("mounted"),C=y.useState("payload");y.useSyncedValues({trackCursorAxis:l,disableHoverablePopup:o,disabled:n}),$R(y,{closeOnActiveTriggerUnmount:!0});const{forceUnmount:T,transitionStatus:P}=zR(w,y),O=y.useState("isInstantPhase"),A=y.useState("instantType"),R=y.useState("lastOpenChangeReason"),M=p.useRef(null);Ge(()=>{k&&n&&y.setOpen(!1,Nt(Sxe))},[k,n,y]),Ge(()=>{P==="ending"&&R===rs||P!=="ending"&&O?(A!=="delay"&&(M.current=A),y.set("instantType","delay")):M.current!==null&&(y.set("instantType",M.current),M.current=null)},[P,O,R,A,y]),Ge(()=>{w&&S==null&&y.set("payload",void 0)},[y,S,w]),p.useImperativeHandle(u,()=>({unmount:T,close:()=>y.setOpen(!1,Nt(hR))}),[T,y]);const _=w||N||!n&&l!=="none";return r.jsxs(r6.Provider,{value:y,children:[m&&r.jsx(_R,{handle:m,store:y}),_&&r.jsx(Kbe,{store:y,disabled:n,trackCursorAxis:l}),typeof b=="function"?b({payload:C}):b]})});function Kbe({store:e,disabled:t,trackCursorAxis:n}){const s=e.useState("floatingRootContext"),i=Fb(s,{enabled:!t,referencePress:()=>e.select("closeOnClick")}),o=Pve(s,{enabled:!t&&n!=="none",axis:n==="none"?void 0:n}),l=p.useMemo(()=>oo(o.reference,i.reference),[o.reference,i.reference]);return BR(e,{activeTriggerProps:l,inactiveTriggerProps:l,popupProps:i.floating??yr}),null}const oH=p.createContext(void 0);function Gbe(){return p.useContext(oH)}const Wbe=600,lH="data-base-ui-tooltip-trigger";function cH(e){if("composedPath"in e){const n=e.composedPath();for(let s=0;sw.select("transitionStatus")==="ending",shouldOpen(){return!z.current}}),se=Mbe(T,{enabled:!K}).reference,re=je=>{const te=z.current,le=cH(je),he=G(le),ce=P.current,ye=ce&&le&&Et(ce,le);if(he&&w.select("open")&&w.select("lastOpenChangeReason")===Va){w.setOpen(!1,Nt(Va,je));return}if(te&&!he&&ye&&!Q.current&&!w.select("open")&&ce&&Ld(J.current)){const fe=()=>{!z.current&&!Q.current&&!w.select("open")&&w.setOpen(!0,Nt(Va,je,ce))},Le=ee();Le===0?(q.clear(),fe()):q.start(Le,fe)}},ne=w.useState("triggerProps",R);return qt("button",t,{state:{open:C},ref:[n,A,P],props:[Y,se,R||X!=="none"?ne:void 0,{onMouseOver(je){re(je.nativeEvent)},onFocus(je){H(cH(je.nativeEvent))&&je.preventBaseUIHandler()},onMouseLeave(){z.current=!1,q.clear(),J.current=void 0},onPointerEnter(je){J.current=je.pointerType},onPointerDown(je){J.current=je.pointerType,w.set("closeOnClick",m),m&&!w.select("open")&&w.cancelPendingOpen(je.nativeEvent)},onClick(je){m&&!w.select("open")&&w.cancelPendingOpen(je.nativeEvent)},id:S,[WO]:K?"":void 0,[lH]:K?void 0:""},b],stateAttributesMapping:Rk})}),uH=p.createContext(void 0);function Qbe(){const e=p.useContext(uH);if(e===void 0)throw new Error(Vn(70));return e}const dH=p.forwardRef(function(t,n){const{children:s,container:i,className:o,render:l,style:u,...d}=t,{node:f,subtree:m}=x6({container:i,ref:n,componentProps:t,elementProps:d});return!m&&!f?null:r.jsxs(p.Fragment,{children:[m,f&&xr.createPortal(s,f)]})}),Zbe=p.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t;return Lb().useState("mounted")||s?r.jsx(uH.Provider,{value:s,children:r.jsx(dH,{ref:n,...i})}):null}),fH=p.createContext(void 0);function hH(){const e=p.useContext(fH);if(e===void 0)throw new Error(Vn(71));return e}const Jbe=p.createContext(void 0);function Vb(){return p.useContext(Jbe)?.direction??"ltr"}const eye=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:i,rects:o,platform:l,elements:u,middlewareData:d}=t,{element:f,padding:m=0,offsetParent:g="real"}=$d(e,t)||{};if(f==null)return{};const v=NU(m),b={x:n,y:s},y=eR(i),k=JO(y),w=await l.getDimensions(f),S=y==="y",N=S?"top":"left",C=S?"bottom":"right",T=S?"clientHeight":"clientWidth",P=o.reference[k]+o.reference[y]-b[y]-o.floating[k],O=b[y]-o.reference[y],A=g==="real"?await l.getOffsetParent?.(f):u.floating;let R=u.floating[T]||o.floating[k];(!R||!await l.isElement?.(A))&&(R=u.floating[T]||o.floating[k]);const M=P/2-O/2,_=R/2-w[k]/2-1,L=Math.min(v[N],_),$=Math.min(v[C],_),D=L,F=R-w[k]-$,V=R/2-w[k]/2+M,K=wU(D,V,F),Q=!d.arrow&&mu(i)!=null&&V!==K&&o.reference[k]/2-(V{const{name:n,fn:s}=eye(e);return{name:n,fn:s,options:[e,t]}},nye={name:"hide",async fn(e){const{width:t,height:n,x:s,y:i}=e.rects.reference,o=t===0&&n===0&&s===0&&i===0,l=await e.platform.detectOverflow(e,{elementContext:"reference"});return{data:{referenceHidden:l.top-n>=0||l.right-t>=0||l.bottom-n>=0||l.left-t>=0||o}}}},rye={sideX:"left",sideY:"top"},sye="--available-width",aye="--available-height",iye="--anchor-width",oye="--anchor-height",lye="--transform-origin",mH=sye,pH=aye;function gH(e,t,n){const s=e==="inline-start"||e==="inline-end";return{top:"top",right:s?n?"inline-start":"inline-end":"right",bottom:"bottom",left:s?n?"inline-end":"inline-start":"left"}[t]}function xH(e,t,n){const{rects:s,placement:i}=e;return{side:gH(t,Uo(i),n),align:mu(i)||"center",anchor:{width:s.reference.width,height:s.reference.height},positioner:{width:s.floating.width,height:s.floating.height}}}function hS(e){return cye(e,Pbe)}function cye(e,t){const{anchor:n,positionMethod:s="absolute",side:i="bottom",sideOffset:o=0,align:l="center",alignOffset:u=0,collisionBoundary:d,collisionPadding:f=5,sticky:m=!1,arrowPadding:g=5,disableAnchorTracking:v=!1,inline:b,keepMounted:y=!1,floatingRootContext:k,mounted:w,collisionAvoidance:S,shift:N,nodeId:C,adaptiveOrigin:T,lazyFlip:P=!1,externalTree:O}=e,[A,R]=p.useState(null);!w&&A!==null&&R(null);const M=S.side||"flip",_=S.align||"flip",L=S.fallbackAxisSide||"end",$=N?.crossAxis??!1,D=N?.rootBoundary,F=typeof n=="function"?n:void 0,V=Ke(F),K=F?V:n,Q=ss(n),X=ss(w),z=Vb()==="rtl",q=A||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":z?"left":"right","inline-start":z?"right":"left"}[i],J=l==="center"?q:`${q}-${l}`;let ee=f;typeof ee=="number"?ee={top:ee,right:ee,bottom:ee,left:ee}:ee&&(ee={top:ee.top||0,right:ee.right||0,bottom:ee.bottom||0,left:ee.left||0});const H=1,G=i==="bottom"?H:0,Y=i==="top"?H:0,se=i==="right"?H:0,re=i==="left"?H:0,ne={boundary:d==="clipping-ancestors"?"clippingAncestors":d,padding:ee},de=p.useRef(null),ie=ss(o),oe=ss(u),je=typeof o!="function"?o:0,te=typeof u!="function"?u:0,le=[];b&&le.push(b),le.push(mbe(ht=>{const Tt=xH(ht,i,z),Ht=typeof ie.current=="function"?ie.current(Tt):ie.current,jt=typeof oe.current=="function"?oe.current(Tt):oe.current;return{mainAxis:Ht,crossAxis:jt,alignmentAxis:jt}},[je,te,z,i]));const he=_==="none"&&M!=="shift",ce=!he&&(m||$||M==="shift"),ye=M==="none"?null:xbe({...ne,padding:{top:ee.top+H+G,right:ee.right+H+re,bottom:ee.bottom+H+Y,left:ee.left+H+se},mainAxis:!$&&M==="flip",crossAxis:_==="flip"?"alignment":!1,fallbackAxisSideDirection:L}),fe=he?null:pbe({...ne,rootBoundary:D,mainAxis:_!=="none",crossAxis:ce,limiter:m||$?void 0:gbe(ht=>{if(!de.current)return{};const{width:Tt,height:Ht}=de.current.getBoundingClientRect(),jt=Ho(Uo(ht.placement)),an=jt==="y"?Tt:Ht,Xt=jt==="y"?ee.left+ee.right:ee.top+ee.bottom;return{offset:an/2+Xt/2}})},[ne,m,$,D,ee,_]);M==="shift"||_==="shift"||l==="center"?le.push(fe,ye):le.push(ye,fe),le.push(vbe({...ne,apply({elements:{floating:ht},availableWidth:Tt,availableHeight:Ht,rects:jt}){if(!X.current)return;const an=ht.style;an.setProperty(mH,`${Tt}px`),an.setProperty(pH,`${Ht}px`);const Xt=vr(ht).devicePixelRatio||1,{x:gn,y:un,width:lr,height:yn}=jt.reference,xn=(Math.round((gn+lr)*Xt)-Math.round(gn*Xt))/Xt,jn=(Math.round((un+yn)*Xt)-Math.round(un*Xt))/Xt;an.setProperty(iye,`${xn}px`),an.setProperty(oye,`${jn}px`)}}),tye(ht=>({element:de.current||_n(ht.elements.floating).createElement("div"),padding:de.current?g:0,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(ht){const{elements:{floating:Tt},middlewareData:Ht,placement:jt,platform:an,rects:Xt,y:gn}=ht,un=Uo(jt),lr=mu(jt),yn=Ho(un)==="y",xn=de.current,jn=typeof o=="function"?o(xH(ht,i,z)):o;let ke;if(!xn&&lr&&Math.abs(yn?Ht.shift?.x||0:Ht.shift?.y||0)<=1)ke=lr==="start"===(yn&&an.isRTL?.(Tt)===!0)?"100%":"0%";else{const Qe=yn?Ht.arrow?.x||0:Ht.arrow?.y||0,Yt=yn?xn?.clientWidth||0:xn?.clientHeight||0;ke=`${Qe+Yt/2}px`}let Xe=un==="top"||un==="left"?`calc(100% + ${jn}px)`:`${-jn}px`;return ce&&yn&&Math.abs(Ht.shift?.y||0)>jn&&(Xe=`${Xt.reference.y+Xt.reference.height/2-gn}px`),Tt.style.setProperty(lye,yn?`${ke} ${Xe}`:`${Xe} ${ke}`),{}}},nye,T),Ge(()=>{!w&&k&&k.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[w,k]);const Le=p.useMemo(()=>({ancestorScroll:!v,elementResize:!v&&typeof ResizeObserver<"u",layoutShift:!v&&typeof IntersectionObserver<"u"}),[v]),{refs:pe,elements:xe,x:Se,y:ge,middlewareData:ue,update:be,placement:ve,context:De,isPositioned:Ie,floatingStyles:We}=t({rootContext:k,open:y?w:void 0,placement:J,middleware:le,strategy:s,whileElementsMounted:y?void 0:(...ht)=>D6(...ht,Le),nodeId:C,externalTree:O}),{sideX:nt,sideY:kt}=ue.adaptiveOrigin||rye,Je=Ie?s:"fixed",on=p.useMemo(()=>{let ht;return Ie?T?ht={position:Je,[nt]:Se,[kt]:ge}:ht={...We,position:Je}:ht={position:Je,top:0,left:0},ht[mH]="100vw",ht[pH]="100vh",Ie||(ht.opacity=0),ht},[T,Je,nt,Se,kt,ge,We,Ie]),nn=p.useRef(null);Ge(()=>{if(!w)return;const ht=Q.current,Tt=typeof ht=="function"?ht():ht,jt=(vH(Tt)?Tt.current:Tt)||null||null;jt!==nn.current&&(pe.setPositionReference(jt),nn.current=jt)},[w,pe,K,Q]),p.useEffect(()=>{if(!w)return;const ht=Q.current;typeof ht!="function"&&vH(ht)&&ht.current!==nn.current&&(pe.setPositionReference(ht.current),nn.current=ht.current)},[w,pe,K,Q]),p.useEffect(()=>{if(y&&w&&xe.reference&&xe.floating)return D6(xe.reference,xe.floating,be,Le)},[y,w,xe,be,Le]);const On=Uo(ve),Rn=gH(i,On,z),gt=mu(ve)||"center",sn=!!ue.hide?.referenceHidden;Ge(()=>{P&&w&&Ie&&On!==q&&R(On)},[P,w,Ie,On,q]);const qe=p.useMemo(()=>({position:"absolute",top:ue.arrow?.y,left:ue.arrow?.x}),[ue.arrow]),zt=ue.arrow?.centerOffset!==0;return p.useMemo(()=>({positionerStyles:on,arrowStyles:qe,arrowRef:de,arrowUncentered:zt,side:Rn,align:gt,physicalSide:On,anchorHidden:sn,refs:pe,context:De,isPositioned:Ie,update:be}),[on,qe,de,zt,Rn,gt,On,sn,pe,De,Ie,be])}function vH(e){return e!=null&&"current"in e}function qb(e){return e==="starting"?vve:yr}function mS(e,t,{styles:n,transitionStatus:s,props:i,refs:o,hidden:l,inert:u=!1}){const d={...n};return u&&(d.pointerEvents="none"),qt("div",e,{state:t,ref:o,props:[{role:"presentation",hidden:l,style:d},qb(s),i],stateAttributesMapping:cg})}const uye=p.forwardRef(function(t,n){const{render:s,className:i,anchor:o,positionMethod:l="absolute",side:u="top",align:d="center",sideOffset:f=0,alignOffset:m=0,collisionBoundary:g="clipping-ancestors",collisionPadding:v=5,arrowPadding:b=5,sticky:y=!1,disableAnchorTracking:k=!1,collisionAvoidance:w=m6,style:S,...N}=t,C=Lb(),T=Qbe(),P=C.useState("open"),O=C.useState("mounted"),A=C.useState("trackCursorAxis"),R=C.useState("disableHoverablePopup"),M=C.useState("floatingRootContext"),_=C.useState("instantType"),L=C.useState("transitionStatus"),$=C.useState("adaptiveOrigin"),D=hS({anchor:o,positionMethod:l,floatingRootContext:M,mounted:O,side:u,sideOffset:f,align:d,alignOffset:m,collisionBoundary:g,collisionPadding:v,sticky:y,arrowPadding:b,disableAnchorTracking:k,keepMounted:T,collisionAvoidance:w,adaptiveOrigin:$}),F=p.useMemo(()=>({open:P,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:A!=="none"?"tracking-cursor":_}),[P,D.side,D.align,D.anchorHidden,A,_]),V=mS(t,F,{styles:D.positionerStyles,transitionStatus:L,props:N,refs:[n,C.useStateSetter("positionerElement")],hidden:!O,inert:!P||A==="both"||R});return r.jsx(fH.Provider,{value:D,children:V})}),dye=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=Lb(),{side:d,align:f}=hH(),m=u.useState("open"),g=u.useState("instantType"),v=u.useState("transitionStatus"),b=u.useState("popupProps"),y=u.useState("floatingRootContext"),k=u.useState("disabled"),w=u.useState("closeDelay");ji({open:m,ref:u.context.popupRef,onComplete(){m&&u.context.onOpenChangeComplete?.(!0)}}),eH(y,{enabled:!k,closeDelay:w});const S=u.useStateSetter("popupElement");return qt("div",t,{state:{open:m,side:d,align:f,instant:g,transitionStatus:v},ref:[n,u.context.popupRef,S],props:[Ub,b,qb(v),l],stateAttributesMapping:GO})}),fye=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=Lb(),{arrowRef:d,side:f,align:m,arrowUncentered:g,arrowStyles:v}=hH(),b=u.useState("open"),y=u.useState("instantType");return qt("div",t,{state:{open:b,side:f,align:m,uncentered:g,instant:y},ref:[n,d],props:[{style:v,"aria-hidden":!0},l],stateAttributesMapping:cg})}),hye=function(t){const{delay:n,closeDelay:s,timeout:i=400}=t,o=p.useMemo(()=>({open:n,close:s}),[n,s]);return r.jsx(oH.Provider,{value:n,children:r.jsx(fve,{delay:o,timeoutMs:i,children:t.children})})};function Kb(e){return MO(19)?e:e?"true":void 0}function mye(e){const[t,n]=p.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function pS(e){return r.jsx(hye,{"data-slot":"tooltip-provider",...e})}function pc(e){return r.jsx(qbe,{"data-slot":"tooltip",...e})}function Ih(e){return r.jsx(Xbe,{"data-slot":"tooltip-trigger",...e})}function gc({className:e,sideOffset:t=8,side:n="top",anchor:s,variant:i="default",children:o,...l}){return r.jsx(Zbe,{children:r.jsx(uye,{anchor:s,positionMethod:"fixed",collisionPadding:8,sideOffset:t,side:n,className:"z-[90] data-anchor-hidden:hidden",children:r.jsx(dye,{"data-slot":"tooltip-content",className:Ne("max-w-[min(320px,calc(100vw-16px))] rounded-md px-2.5 py-2 text-[11.5px] leading-[1.55] shadow-3",i==="plain"?"border border-border bg-raised text-foreground":"bg-primary text-primary-on","break-words outline-none","transition-[opacity,transform] duration-150 ease-out","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95","data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...l,children:o})})})}function pye({className:e,...t}){return r.jsx(fye,{className:Ne("size-2 rotate-45 rounded-[1px] bg-primary","data-[side=top]:-bottom-1 data-[side=bottom]:-top-1",e),...t})}const bH=p.createContext(void 0);function Hd(e){const t=p.useContext(bH);if(!e&&t===void 0)throw new Error(Vn(27));return t}const YR=p.forwardRef(function(t,n){const{render:s,className:i,style:o,forceRender:l=!1,...u}=t,d=Hd(),f=d.useState("open"),m=d.useState("nested"),g=d.useState("mounted"),v=d.useState("transitionStatus");return qt("div",t,{state:{open:f,transitionStatus:v},ref:[d.context.backdropRef,n],stateAttributesMapping:GO,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},u],enabled:l||!m})}),Gb=p.forwardRef(function(t,n){const{render:s,className:i,style:o,disabled:l=!1,nativeButton:u=!0,...d}=t,f=Hd(),m=f.useState("open"),{getButtonProps:g,buttonRef:v}=$i({disabled:l,native:u}),b={disabled:l};function y(k){m&&f.setOpen(!1,Nt(dR,k.nativeEvent))}return qt("button",t,{state:b,ref:[n,v],props:[{onClick:y},d,g]})}),yH=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,...u}=t,d=Hd(),f=Ws(l);return d.useSyncedValueWithCleanup("descriptionElementId",f),qt("p",t,{ref:n,props:[{id:f},u]})}),jH=p.createContext(void 0);function gye(){const e=p.useContext(jH);if(e===void 0)throw new Error(Vn(26));return e}const XR="ArrowUp",QR="ArrowDown",ZR="ArrowLeft",JR="ArrowRight",eP="Home",tP="End",gS=new Set([XR,QR,ZR,JR,eP,tP]),wH="Shift",xye=[wH,"Control","Alt","Meta"];function vye(e){return br(e)&&e.tagName==="INPUT"}function kH(e){return!!(vye(e)&&e.selectionStart!=null||br(e)&&e.tagName==="TEXTAREA")}function SH(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,o=e.scrollTop;const l=e.clientWidthe.scrollLeft+e.clientWidth-f.scrollPaddingRight?i=d+t.offsetWidth+m.scrollMarginRight-e.clientWidth+f.scrollPaddingRight:d-m.scrollMarginLefte.scrollLeft+e.clientWidth-f.scrollPaddingRight&&(i=d+t.offsetWidth+m.scrollMarginRight-e.clientWidth+f.scrollPaddingRight))}if(u&&s!=="horizontal"){const d=NH(e,t,"top"),f=xS(e),m=xS(t);d-m.scrollMarginTope.scrollTop+e.clientHeight-f.scrollPaddingBottom&&(o=d+t.offsetHeight+m.scrollMarginBottom-e.clientHeight+f.scrollPaddingBottom)}e.scrollTo({left:i,top:o,behavior:"auto"})}function NH(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[s],t.offsetParent!==e);)t=t.offsetParent;return i}function xS(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const bye="--nested-dialogs",yye="data-nested-dialog-open",jye={...cg,...Fo,nestedDialogOpen(e){return e?{[yye]:""}:null}},nP=p.forwardRef(function(t,n){const{render:s,className:i,style:o,finalFocus:l,initialFocus:u,...d}=t,f=Hd(),m=f.useState("descriptionElementId"),g=f.useState("disablePointerDismissal"),v=f.useState("floatingRootContext"),b=f.useState("popupProps"),y=f.useState("modal"),k=f.useState("mounted"),w=f.useState("nested"),S=f.useState("nestedOpenDialogCount"),N=f.useState("open"),C=f.useState("openMethod"),T=f.useState("titleElementId"),P=f.useState("transitionStatus"),O=f.useState("role"),A=v.useState("floatingId");gye(),ji({open:N,ref:f.context.popupRef,onComplete(){N&&f.context.onOpenChangeComplete?.(!0)}});const R=u===void 0?K6(f.context.popupRef):u,M=S>0,_=f.useStateSetter("popupElement"),$=qt("div",t,{state:{open:N,nested:w,transitionStatus:P,nestedDialogOpen:M},props:[b,{id:A,"aria-labelledby":T,"aria-describedby":m,role:O,...Ub,hidden:!k,onKeyDown(D){gS.has(D.key)&&D.stopPropagation()},style:{[bye]:S}},d],ref:[n,f.context.popupRef,_],stateAttributesMapping:jye});return r.jsx(tS,{context:v,openInteractionType:C,disabled:!k,closeOnFocusOut:!g,initialFocus:R,returnFocus:l,modal:y!==!1,restoreFocus:"popup",children:$})}),vS=p.forwardRef(function(t,n){const{cutout:s,...i}=t;let o;if(s){const l=s.getBoundingClientRect();o=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${l.left}px ${l.top}px,${l.left}px ${l.bottom}px,${l.right}px ${l.bottom}px,${l.right}px ${l.top}px,${l.left}px ${l.top}px)`}return r.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})}),rP=p.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,o=Hd(),l=o.useState("mounted"),u=o.useState("modal"),d=o.useState("open");return l||s?r.jsx(jH.Provider,{value:s,children:r.jsxs(eS,{ref:n,...i,children:[l&&u===!0&&r.jsx(vS,{ref:o.context.internalBackdropRef,inert:Kb(!d)}),t.children]})}):null});let CH={},AH={},EH="";function bS(e,t){return Cb(e)?e:t}function TH(e,t,n){return/hidden|clip/.test(e.getComputedStyle(bS(t,n)).overflowY)}function wye(e){if(typeof document>"u")return!1;const t=_n(e);return vr(t).innerWidth-t.documentElement.clientWidth>0}function kye(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=_n(e),s=n.documentElement,i=n.body,o=bS(s,i),l=o.style.overflowY,u=s.style.scrollbarGutter;s.style.scrollbarGutter="stable",o.style.overflowY="scroll";const d=o.offsetWidth;o.style.overflowY="hidden";const f=o.offsetWidth;return o.style.overflowY=l,s.style.scrollbarGutter=u,d===f}function Sye(e){const t=_n(e),n=t.documentElement,s=t.body,i=bS(n,s),o={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(i.style,o)}}function Nye(e){const t=_n(e),n=t.documentElement,s=t.body,i=vr(n);let o=0,l=0,u=!1;const d=Fi.create();if(du&&(i.visualViewport?.scale??1)!==1)return()=>{};function f(){const b=i.getComputedStyle(n),y=i.getComputedStyle(s),S=(b.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,l=n.scrollLeft,CH={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},EH=n.style.scrollBehavior,AH={position:s.style.position,height:s.style.height,width:s.style.width,boxSizing:s.style.boxSizing,overflowY:s.style.overflowY,overflowX:s.style.overflowX,scrollBehavior:s.style.scrollBehavior};const N=n.scrollHeight>n.clientHeight,C=n.scrollWidth>n.clientWidth,T=b.overflowY==="scroll"||y.overflowY==="scroll",P=b.overflowX==="scroll"||y.overflowX==="scroll",O=Math.max(0,i.innerWidth-s.clientWidth),A=Math.max(0,i.innerHeight-s.clientHeight),R=parseFloat(y.marginTop)+parseFloat(y.marginBottom),M=parseFloat(y.marginLeft)+parseFloat(y.marginRight),_=bS(n,s);if(u=kye(e),u){n.style.scrollbarGutter=S,_.style.overflowY="hidden",_.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:S,overflowY:"hidden",overflowX:"hidden"}),(N||T)&&(n.style.overflowY="scroll"),(C||P)&&(n.style.overflowX="scroll"),Object.assign(s.style,{position:"relative",height:R||A?`calc(100dvh - ${R+A}px)`:"100dvh",width:M||O?`calc(100vw - ${M+O}px)`:"100vw",boxSizing:"border-box",overflowY:"hidden",overflowX:"hidden",scrollBehavior:"unset"}),s.scrollTop=o,s.scrollLeft=l,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function m(){Object.assign(n.style,CH),Object.assign(s.style,AH),u||(n.scrollTop=o,n.scrollLeft=l,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=EH)}function g(){m(),d.request(f)}f();const v=kn(i,"resize",g);return()=>{d.cancel(),m(),typeof i.removeEventListener=="function"&&v()}}class Cye{constructor(){Cn(this,"lockCount",0);Cn(this,"restore",null);Cn(this,"timeoutLock",Bi.create());Cn(this,"timeoutUnlock",Bi.create());Cn(this,"release",()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)});Cn(this,"unlock",()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)})}acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}lock(t){if(this.lockCount===0||this.restore!==null)return;const n=_n(t),s=n.documentElement,i=n.body,o=vr(s);if(TH(o,s,i)){const u=new o.MutationObserver(()=>{TH(o,s,i)||(u.disconnect(),this.restore=null,this.lock(t))}),d={attributes:!0};u.observe(s,d),u.observe(i,d),this.restore=()=>u.disconnect();return}const l=Ob||!wye(t);this.restore=l?Sye(t):Nye(t)}}const Aye=new Cye;function OH(e=!0,t=null){Ge(()=>{if(e)return Aye.acquire(t)},[e,t])}function Eye({store:e,parentContext:t,isDrawer:n}){const s=e.useState("open"),i=e.useState("disablePointerDismissal"),o=e.useState("modal"),l=e.useState("popupElement"),u=e.useState("floatingRootContext"),[d,f]=p.useState(0),[m,g]=p.useState(0),v=d===0,b=Fb(u,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(y){if(!e.context.outsidePressEnabledRef.current||"button"in y&&y.button!==0)return!1;if("touches"in y){if(y.type==="touchend"){if(y.changedTouches.length!==1||y.touches.length!==0)return!1}else if(y.touches.length!==1)return!1}const k=Er(y);if(v&&!i){if(o){const w=e.context.internalBackdropRef.current,S=e.context.backdropRef.current;return w||S?w===k||S===k||Et(k,l)&&!k?.hasAttribute("data-base-ui-portal"):!0}return!0}return!1},escapeKey:v});return OH(s&&o===!0,l),e.useContextCallback("onNestedDialogOpen",(y,k)=>{f(y),g(k)}),Ge(()=>(t?.onNestedDialogOpen&&(s?t.onNestedDialogOpen(d+1,m+(n?1:0)):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&s&&t.onNestedDialogOpen(0,0)}),[n,s,d,m,t]),BR(e,{activeTriggerProps:b.reference,inactiveTriggerProps:b.trigger,popupProps:b.floating,nestedOpenDialogCount:d,nestedOpenDrawerCount:m}),null}const Tye={...HR,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role};class Oye extends Ph{constructor(n,s,i){const o=new aS,l=Rye(n,o,s,i);super(l,Pye(o),Tye);Cn(this,"setOpen",(n,s)=>{s.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!n&&s.trigger==null&&this.state.activeTriggerId!=null&&(s.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(n,s),!s.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(n,s),this.update(DR(this.state,n,s.trigger)))})}}function Rye(e,t,n,s=!1){return{...FR(t,n,s),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function Pye(e){return{popupRef:p.createRef(),backdropRef:p.createRef(),internalBackdropRef:p.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function RH(e,t){const{children:n,open:s,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:l,disablePointerDismissal:u=!1,modal:d=!0,actionsRef:f,handle:m,triggerId:g,defaultTriggerId:v=null}=t,b=e==="drawer",y=e==="alert-dialog",k=y?!0:d,w=y||u,S=y?"alertdialog":"dialog",N=Hd(!0),C=N!=null,T={modal:k,disablePointerDismissal:w,nested:C,role:S},P=MR((L,$)=>new Oye({open:i,openProp:s,activeTriggerId:v,triggerIdProp:g,...T},L,$),!0);P.useControlledProp("openProp",s),P.useControlledProp("triggerIdProp",g),P.useSyncedValues(T),P.useContextCallback("onOpenChange",o),P.useContextCallback("onOpenChangeComplete",l);const O=P.useState("open"),A=P.useState("mounted"),R=P.useState("payload");Y6(P,O),$R(P);const{forceUnmount:M}=zR(O,P);p.useImperativeHandle(f,()=>({unmount:M,close:()=>P.setOpen(!1,Nt(hR))}),[M,P]);const _=O||A;return r.jsxs(bH.Provider,{value:P,children:[m&&r.jsx(_R,{handle:m,store:P}),_&&r.jsx(Eye,{store:P,parentContext:N?.context,isDrawer:b}),typeof n=="function"?n({payload:R}):n]})}const PH=Qk(function(t){return RH("dialog",t)}),sP=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,...u}=t,d=Hd(),f=Ws(l);return d.useSyncedValueWithCleanup("titleElementId",f),qt("h2",t,{ref:n,props:[{id:f},u]})});function Iye(e){const t=p.useRef(""),n=p.useCallback(i=>{i.defaultPrevented||(t.current=i.pointerType,e(i,i.pointerType))},[e]);return{onClick:p.useCallback(i=>{if(i.detail===0){e(i,"keyboard");return}"pointerType"in i?e(i,i.pointerType):e(i,t.current),t.current=""},[e]),onPointerDown:n}}function aP(e,t){const n=Ke((o,l)=>{(typeof e=="function"?e():e)||t(l||(Ob?"touch":""))}),{onClick:s,onPointerDown:i}=Iye(n);return p.useMemo(()=>({onClick:s,onPointerDown:i}),[s,i])}function IH(e){const[t,n]=p.useState(null),s=aP(e,n);return Vo(e,i=>{i&&!e&&n(null)}),p.useMemo(()=>({openMethod:t,triggerProps:s}),[t,s])}const MH=bR(function(t,n){const{render:s,className:i,style:o,disabled:l=!1,nativeButton:u=!0,id:d,payload:f,handle:m,...g}=t,v=Hd(!0),y=VR(m)??v;if(!y)throw new Error(Vn(79));const k=Ws(d),w=y.useState("floatingRootContext"),S=y.useState("isOpenedByTrigger",k),N=y.useState("triggerPopupId",k),C=p.useRef(null),{registerTrigger:T,isMountedByThisTrigger:P}=LR(k,C,y,{payload:f}),{getButtonProps:O,buttonRef:A}=$i({disabled:l,native:u}),R=Bb(w),M=aP(()=>y.select("open"),$=>{y.set("openMethod",$)}),_={disabled:l,open:S},L=y.useState("triggerProps",P);return qt("button",t,{state:_,ref:[A,n,T,C],props:[R.reference,L,M,{[kR]:"",id:k,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":N},g,O],stateAttributesMapping:Rk})});function at(e){return r.jsx(PH,{"data-slot":"dialog",...e})}function _H(e){return r.jsx(MH,{"data-slot":"dialog-trigger",...e})}function Mye(e){return r.jsx(rP,{"data-slot":"dialog-portal",...e})}function DH(e){return r.jsx(Gb,{"data-slot":"dialog-close",...e})}const st=e=>r.jsx(sP,{"data-slot":"dialog-title",...e}),fo=e=>r.jsx(yH,{"data-slot":"dialog-description",...e});function _ye({className:e,...t}){return r.jsx(YR,{"data-slot":"dialog-overlay",className:Ne("fixed inset-0 isolate z-30 bg-mask backdrop-blur-[3px]","transition-opacity duration-150","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...t})}function it({className:e,children:t,showCloseButton:n=!0,keepMounted:s=!1,overlayForceRender:i=!1,...o}){return r.jsxs(Mye,{keepMounted:s,children:[r.jsx(_ye,{forceRender:i}),r.jsxs(nP,{"data-slot":"dialog-content",className:Ne("fixed top-1/2 left-1/2 z-30 flex max-h-[calc(100vh-48px)] w-[min(620px,calc(100vw-48px))] -translate-x-1/2 -translate-y-1/2 flex-col","overflow-hidden rounded-lg border border-border bg-surface shadow-3 outline-none","transition-[opacity,transform] duration-200 [transition-timing-function:cubic-bezier(.2,.9,.3,1)]","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[.985] data-open:slide-in-from-bottom-2.5","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...o,children:[t,n&&r.jsxs(Gb,{"data-slot":"dialog-close",render:r.jsx(B,{variant:"ghost",size:"icon-sm",className:"absolute top-3 right-3"}),children:[r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 2.5l7 7M9.5 2.5l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),r.jsx("span",{className:"sr-only",children:Z("关闭")})]})]})]})}function ot({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-header",className:Ne("flex items-center gap-2.5 border-b border-hairline px-5 py-[15px] pr-10","[&_h2]:flex-1 [&_h2]:text-[14.5px] [&_h2]:font-semibold",e),...t})}function lt({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-body",className:Ne("flex flex-col gap-4 overflow-y-auto px-5 py-[18px]",e),...t})}function xt({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-footer",className:Ne("flex items-center justify-end gap-2 border-t border-hairline bg-surface-2 px-5 py-[13px]",e),...t})}function as({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-section",className:Ne("flex flex-col gap-2.5 rounded-md border border-border bg-surface-inset p-3.5","[&_h3]:text-[12.5px] [&_h3]:font-semibold","[&_p]:text-xs [&_p]:leading-[1.65] [&_p]:text-subtle",e),...t})}function Dye(e){return RH("alert-dialog",e)}const LH=Dye,Lye=rP,$H=e=>r.jsx(sP,{"data-slot":"alert-dialog-title",...e});function $ye({className:e,...t}){return r.jsx(YR,{"data-slot":"alert-dialog-overlay",className:Ne("fixed inset-0 isolate z-[38] bg-mask backdrop-blur-[3px]","transition-opacity duration-150","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...t})}function zH({className:e,children:t,showCloseButton:n=!1,...s}){return r.jsxs(Lye,{children:[r.jsx($ye,{}),r.jsxs(nP,{"data-slot":"alert-dialog-content",className:Ne("fixed top-1/2 left-1/2 z-[38] flex max-h-[calc(100vh-48px)] w-[min(440px,calc(100vw-48px))] -translate-x-1/2 -translate-y-1/2 flex-col","overflow-hidden rounded-lg border border-border bg-surface shadow-3 outline-none","transition-[opacity,transform] duration-200 [transition-timing-function:cubic-bezier(.2,.9,.3,1)]","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[.985] data-open:slide-in-from-bottom-2.5","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...s,children:[t,n&&r.jsxs(Gb,{"data-slot":"alert-dialog-close",render:r.jsx(B,{variant:"ghost",size:"icon-sm",className:"absolute top-3 right-3"}),children:[r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 2.5l7 7M9.5 2.5l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),r.jsx("span",{className:"sr-only",children:Z("关闭")})]})]})]})}function BH({className:e,...t}){return r.jsx("div",{"data-slot":"alert-dialog-header",className:Ne("flex items-center gap-2.5 border-b border-hairline px-5 py-[15px]","[&_h2]:flex-1 [&_h2]:text-[14.5px] [&_h2]:font-semibold",e),...t})}function FH({className:e,...t}){return r.jsx("div",{"data-slot":"alert-dialog-body",className:Ne("flex flex-col gap-4 overflow-y-auto px-5 py-[18px]",e),...t})}function UH({className:e,...t}){return r.jsx("div",{"data-slot":"alert-dialog-footer",className:Ne("flex items-center justify-end gap-2 border-t border-hairline bg-surface-2 px-5 py-[13px]",e),...t})}function zye({className:e,tone:t="danger",...n}){return r.jsx("div",{"data-slot":"alert-dialog-banner","data-tone":t,className:Ne("rounded-md border px-3.5 py-3 text-xs leading-[1.65] text-subtle","[&_strong]:font-semibold",t==="danger"?"border-destructive-bd bg-destructive-soft [&_strong]:text-destructive":"border-border bg-surface-inset [&_strong]:text-foreground",e),...n})}function ps({className:e,containerClassName:t,container:n=!0,...s}){const i=r.jsx("table",{"data-slot":"table",className:Ne("w-full caption-bottom border-collapse text-[12.5px]",e),...s});return n?r.jsx("div",{"data-slot":"table-container",className:Ne("relative w-full overflow-auto",t),children:i}):i}function Qs({className:e,...t}){return r.jsx("thead",{"data-slot":"table-header",className:Ne(e),...t})}function Es({className:e,...t}){return r.jsx("tbody",{"data-slot":"table-body",className:Ne(e),...t})}function Bye({className:e,...t}){return r.jsx("tfoot",{"data-slot":"table-footer",className:Ne("border-t border-border bg-surface-2 font-medium",e),...t})}function Jt({className:e,...t}){return r.jsx("tr",{"data-slot":"table-row",className:Ne("transition-colors duration-100 hover:[&>td]:bg-control-hover",e),...t})}function tt({className:e,children:t,sortDirection:n=!1,onSortChange:s,sortLabel:i,...o}){return r.jsx("th",{"data-slot":"table-head",className:Ne("sticky top-0 z-[2] whitespace-nowrap border-b border-border bg-[var(--ui-table-head-bg)] px-2 py-2","text-left text-[10.5px] font-semibold tracking-[.05em] text-muted-foreground",e),...o,"aria-sort":s?n==="asc"?"ascending":n==="desc"?"descending":"none":o["aria-sort"],children:s?r.jsxs(B,{type:"button",variant:"ghost",size:"xs","data-table-sort":"",className:"h-auto max-w-full gap-1 border-0 px-0 py-0 align-middle [font-size:inherit] font-semibold tracking-[inherit] text-inherit hover:bg-transparent active:translate-y-0","aria-label":i,title:[i,o.title].filter(Boolean).join(` +`)||void 0,onClick:()=>s(n==="asc"?"desc":"asc"),children:[r.jsx("span",{className:"min-w-0 truncate",children:t}),r.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"m8 9 4-4 4 4",className:n==="asc"?"text-primary-fg":"opacity-35"}),r.jsx("path",{d:"m8 15 4 4 4-4",className:n==="desc"?"text-primary-fg":"opacity-35"})]})]}):t})}function Ve({className:e,...t}){return r.jsx("td",{"data-slot":"table-cell",className:Ne("border-b border-hairline px-2 py-2 align-middle",e),...t})}function Fye({className:e,...t}){return r.jsx("caption",{"data-slot":"table-caption",className:Ne("mt-4 text-xs text-muted-foreground",e),...t})}const Uye="data-checked",Hye="data-unchecked",iP={checked(e){return e?{[Uye]:""}:{[Hye]:""}},...Fo,...hc},oP="data-composite-item-active",HH=p.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Vye(){return p.useContext(HH)}function lP(e={}){const{guess:t,label:n,metadata:s,textRef:i,index:o}=e,{register:l,unregister:u,subscribeMapChange:d,nextIndexRef:f}=Vye(),m=p.useRef(-1),[g,v]=p.useState(o==null&&t?()=>{if(m.current===-1){const w=f.current;f.current+=1,m.current=w}return m.current}:-1),b=o??g,y=p.useRef(null),k=p.useCallback(w=>{const S=y.current;S&&u(S),y.current=w,w&&l(w,{metadata:s??null,index:o??null,label:n,textRef:i})},[o,l,u,s,n,i]);return Ge(()=>{if(o==null)return d(w=>{const S=y.current?w.get(y.current)?.index:null;S!=null&&v(S)})},[o,d]),{ref:k,index:b}}function qye(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=_F(),{ref:i,index:o}=lP(e),l=n===o,u=p.useRef(null),d=lo(i,u);return{compositeProps:{tabIndex:l?0:-1,onFocus(){s(o)},onMouseMove(){const m=u.current;if(!t||!m)return;const g=m.hasAttribute("disabled")||m.ariaDisabled==="true";!l&&!g&&m.focus()}},compositeRef:d,index:o}}function VH(e){const{render:t,className:n,style:s,state:i=yr,props:o=co,refs:l=co,metadata:u,stateAttributesMapping:d,tag:f="div",...m}=e,{compositeProps:g,compositeRef:v}=qye({metadata:u});return qt(f,e,{state:i,ref:[v,...l],props:[g,...o,m],stateAttributesMapping:d})}const qH=p.createContext(void 0);function Kye(){return p.useContext(qH)}function yS(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}const KH=p.createContext(void 0);function Gye(){const e=p.useContext(KH);if(e===void 0)throw new Error(Vn(52));return e}const GH=p.forwardRef(function(t,n){const{render:s,className:i,disabled:o=!1,readOnly:l=!1,required:u=!1,"aria-labelledby":d,value:f,inputRef:m,nativeButton:g=!1,id:v,style:b,...y}=t,k=Kye(),{disabled:w,readOnly:S,required:N,form:C,checkedValue:T,touched:P=!1,validation:O,name:A,setCheckedValue:R=Xn,setTouched:M=Xn,registerInputRef:_=Xn}=k??{},{setTouched:L,setFilled:$,state:D,disabled:F}=uo(),V=Hk(),{labelId:K,getDescriptionProps:Q}=zi(),X=F||V.disabled||w||o,U=S||l,z=N||u,q=C,J=k?T===f:f==="",ee=p.useRef(null),H=p.useRef(null),G=O?.registerInput,Y=p.useCallback(xe=>G?.(xe,{controlRef:ee,value:void 0}),[G]),se=lo(m,H,_,Y);Ge(()=>{H.current?.checked&&$(!0)},[$]),Ge(()=>{if(H.current){if(X&&J){_(null);return}_(H.current)}},[J,X,_]);const re=Ws(),ne=_d({id:v}),de=g?void 0:ne,ie=FO(d,K,H,!g,de),oe={role:"radio","aria-checked":J,"aria-labelledby":ie,[oP]:J?"":void 0,id:g?ne:re,onKeyDown(xe){xe.key==="Enter"&&xe.preventDefault()},onClick(xe){if(xe.defaultPrevented||X||U)return;xe.preventDefault();const Se=H.current;Se&&og(Se,xe)},onFocus(xe){xe.defaultPrevented||X||U||!P||(H.current?.click(),M(!1))}},{getButtonProps:je,buttonRef:te}=$i({disabled:X,native:g,composite:!1}),le={type:"radio",ref:se,form:q,id:de,name:A,tabIndex:-1,style:A?pg:vu,"aria-hidden":!0,...f!==void 0?{value:yS(f)}:yr,disabled:X,checked:J,required:z,readOnly:U,onChange(xe){if(xe.nativeEvent.defaultPrevented||X||U||f===void 0)return;const Se=Nt(rs,xe.nativeEvent);R(f,Se),!Se.isCanceled&&L(!0)},onClick(xe){xe.stopPropagation()},onFocus(){ee.current?.focus()}},he=p.useMemo(()=>({...D,required:z,disabled:X,readOnly:U,checked:J}),[D,X,U,J,z]),ce=he,ye=k!==void 0,fe=[n,ee,te],Le=[oe,y,je,Q,O?xe=>O.getValidationProps(X,xe):yr],pe=qt("span",t,{enabled:!ye,state:he,ref:fe,props:Le,stateAttributesMapping:iP});return r.jsxs(KH.Provider,{value:ce,children:[ye?r.jsx(VH,{tag:"span",render:s,className:i,style:b,state:he,refs:fe,props:Le,stateAttributesMapping:iP}):pe,r.jsx("input",{...le,suppressHydrationWarning:!0})]})}),Wye=p.forwardRef(function(t,n){const{render:s,className:i,style:o,keepMounted:l=!1,...u}=t,d=Gye(),f=d.checked,{mounted:m,transitionStatus:g,setMounted:v}=gu(f),b={...d,transitionStatus:g},y=p.useRef(null),k=l||m,w=qt("span",t,{ref:[n,y],state:b,props:u,stateAttributesMapping:iP});return ji({batch:!0,enabled:!f,open:f,ref:y,onComplete(){f||v(!1)}}),k?w:null});function cP(e){const{children:t,elementsRef:n,labelsRef:s,onMapChange:i}=e,o=Ke(i),[,l]=p.useState(!1),u=$s(Xye).current,d=$s(Yye).current,f=p.useRef(0),m=p.useRef(!0),g=p.useRef(null),v=p.useRef(null),b=Ke(()=>{m.current||(m.current=!0,l(P=>!P))}),y=Ke((P,O)=>{d.set(P,O),b()}),k=Ke(P=>{d.delete(P),b()}),w=Ke(P=>{const O=new Map;return n.current.length=0,s&&(s.current.length=0),P.forEach(A=>{O.set(A.element,{...A.registration.metadata??{},index:A.index}),n.current[A.index]=A.element,s&&(s.current[A.index]=A.registration.label!==void 0?A.registration.label:A.registration.textRef?.current?.textContent??A.element.textContent)}),f.current=n.current.length,O});function S(P){if(v.current?.disconnect(),v.current=null,typeof MutationObserver!="function"||P.length<2)return;const O=new MutationObserver(R=>{if(!Jye(R))return;let M=null;for(const _ of P)if(_.isConnected){if(M&&WH(M,_)>0){O.disconnect(),b();return}M=_}});v.current=O;const A=new Set;for(let R=1;RO.observe(R,{childList:!0}))}const N=Ke(()=>{const[P,O]=Qye(d),A=w(P),R=g.current,M=!R||R.length!==P.length||P.some((_,L)=>{const $=R[L];return _.index!==$.index||_.element!==$.element||_.registration.index!==$.registration.index||_.registration.metadata!==$.registration.metadata});S(O),g.current=P,m.current=!1,M&&(u.forEach(_=>_(A)),o(A))});Ge(()=>(!m.current&&g.current&&w(g.current),()=>{n.current=[],s&&(s.current=[])}),[n,s,w]),Ge(()=>{m.current&&N()}),Ge(()=>()=>{v.current?.disconnect(),m.current=!0},[]);const C=Ke(P=>(u.add(P),()=>{u.delete(P)})),T=p.useMemo(()=>({register:y,unregister:k,subscribeMapChange:C,nextIndexRef:f}),[y,k,C,f]);return r.jsx(HH.Provider,{value:T,children:t})}function Yye(){return new Map}function Xye(){return new Set}function Qye(e){const t=new Set,n=[],s=[];e.forEach((o,l)=>{if(!l.isConnected)return;const u=o.index,d={index:u??-1,element:l,registration:o};u===null?s.push(d):u>=0&&(t.add(u),n.push(d))});let i=0;return s.sort((o,l)=>WH(o.element,l.element)),s.forEach(o=>{for(;t.has(i);)i+=1;o.index=i,n.push(o),i+=1}),t.size>0&&n.sort((o,l)=>o.index-l.index),[n,s.map(o=>o.element)]}function Zye(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Jye(e){for(const t of e)for(let n=0;n{if(T.current=N.current[L]??null,(u??y)(L),$){const D=N.current[L];SH(w.current,D,o,n)}}),A=Ke(L=>{if(L.size===0)return;if(C.current){const V=N.current,K=V.indexOf(T.current);if(K===-1){const Q=V[P];!Q||Bd(V,P,g)?O(tje(V,g)):T.current=Q}else K!==P&&O(K);return}C.current=!0;const $=Array.from(L.keys()),D=$.find(V=>V?.hasAttribute(oP))??null,F=D?L.get(D)?.index??-1:-1;if(F!==-1)O(F);else if(Bd($,P,g)){const V=Ta($,{disabledIndices:g});zd($,V)||O(V)}SH(w.current,D,o,n)});Ge(()=>{if(g==null||l!=null||!C.current)return;const L=N.current;if(Bd(L,P,g)){const $=Ta(L,{disabledIndices:g});zd(L,$)||O($)}},[g,l,P,N,O]);const R=Ke((L,$,D)=>i?i(L,$,D,N):D),M=Ke(L=>{const $=L.key===eP||L.key===tP;if(!gS.has(L.key)||!f&&$||nje(L,v)||!w.current)return;const F=o==="rtl",V=F?ZR:JR,K=F?JR:ZR,Q=n==="vertical"?QR:V,X=n==="vertical"?XR:K,U=Er(L.nativeEvent);if(U!=null&&kH(U)&&!YH(U)){const G=U.selectionStart,Y=U.selectionEnd,se=U.value;if(G==null||L.shiftKey||G!==Y||L.key!==X&&G0)return}let z=P;const q=Bk(N,g),J=nR(N,g);s!=null&&(z=s({disabledIndices:g,elementsRef:N,event:L,highlightedIndex:P,loopFocus:t,maxIndex:J,minIndex:q,onLoop:R,orientation:n,rtl:F}));const ee=n!=="vertical"&&L.key===V||n!=="horizontal"&&L.key===QR,H=n!=="vertical"&&L.key===K||n!=="horizontal"&&L.key===XR;f&&(L.key===eP?z=q:L.key===tP&&(z=J)),z===P&&(ee||H)&&(t&&z===J&&ee?(z=q,i&&(z=i(L,P,z,N))):t&&z===q&&H?(z=J,i&&(z=i(L,P,z,N))):z=Ta(N.current,{startingIndex:z,decrement:H,disabledIndices:g})),z!==P&&!zd(N.current,z)&&(m&&L.stopPropagation(),(k||$||ee||H)&&L.preventDefault(),O(z,!0),queueMicrotask(()=>{N.current[z]?.focus()}))});return{props:{ref:S,onFocus(L){const $=w.current,D=Er(L.nativeEvent);!$||D==null||!kH(D)||D.setSelectionRange(0,D.value.length)},onKeyDown:M},highlightedIndex:P,onHighlightedIndexChange:O,elementsRef:N,onMapChange:A,relayKeyboardEvent:M}}function tje(e,t){let n=-1;for(let s=0;s({highlightedIndex:M,onHighlightedIndexChange:_,highlightItemOnHover:T,relayKeyboardEvent:D}),[M,_,T,D]);return r.jsx(MF.Provider,{value:V,children:r.jsx(cP,{elementsRef:L,onMapChange:K=>{k?.(K),$(K)},children:F})})}const sje=[wH],XH=p.forwardRef(function(t,n){const{render:s,className:i,disabled:o,readOnly:l,required:u,onValueChange:d,value:f,defaultValue:m,form:g,name:v,inputRef:b,id:y,style:k,...w}=t,{setTouched:S,setFocused:N,validationMode:C,name:T,disabled:P,state:O,validation:A,setDirty:R,setFilled:M,validityData:_}=uo(),{labelId:L}=zi(),{clearErrors:$,elementRef:D}=uu(),F=BO(!0),V=P||o,K=T??v,Q=Ws(y),[X,U]=Tl({controlled:f,default:m,name:"RadioGroup",state:"value"}),[z,q]=p.useState(!1),J=Ke((te,le)=>{d?.(te,le),!le.isCanceled&&U(te)}),ee=A.getInputControl,H=p.useMemo(()=>({get current(){return ee()}}),[ee]),G=p.useRef(null),Y=p.useRef(null);function se(te){let le;return b&&(typeof b=="function"?le=b(te):b.current=te),G.current=te,le}const re=Ke(te=>{if(!te||te.disabled)return;Y.current||(Y.current=te);const le=G.current,he=te.checked||le==null||le.disabled?se(te):void 0;return()=>{Y.current===te&&(Y.current=null),G.current===te?he?(he(),G.current=null):se(null):he?.()}}),ne=Ke(()=>{const te=D.current;if(!te)return X??null;for(const le of A.registeredInputs.keys())if(le.checked&&LU(le,te))return X??null;return null});hg(H,Q,X??null,ne,!V,v),Vo(X,()=>{$(K),R(X!==_.initialValue),M(X!=null),A.change(X);const te=Y.current;X==null&&te&&!te.disabled&&se(te)});const de=L??F?.legendId,ie={...O,disabled:V??!1,required:u??!1,readOnly:l??!1},oe=p.useMemo(()=>({checkedValue:X,disabled:V,form:g,validation:A,name:K,readOnly:l,registerInputRef:re,required:u,setCheckedValue:J,setTouched:q,touched:z}),[X,V,g,A,K,l,re,u,J,q,z]),je={id:y,role:"radiogroup","aria-required":u||void 0,"aria-disabled":V||void 0,"aria-readonly":l||void 0,"aria-labelledby":de,onFocus(){N(!0)},onBlur(te){Et(te.currentTarget,te.relatedTarget)||(S(!0),N(!1),C==="onBlur"&&A.commit(X))},onKeyDownCapture(te){te.key.startsWith("Arrow")&&(q(!0),N(!0))}};return r.jsx(qH.Provider,{value:oe,children:r.jsx(rje,{render:s,className:i,style:k,state:ie,props:[je,w,te=>A.getValidationProps(V??!1,te)],refs:[n],stateAttributesMapping:hc,enableHomeAndEndKeys:!1,modifierKeys:sje})})});function bg({className:e,...t}){return r.jsx(XH,{"data-slot":"radio-group",className:Ne("flex flex-col gap-2",e),...t})}function Mh({className:e,children:t,...n}){return r.jsxs(GH,{"data-slot":"radio-group-item",className:Ne("relative inline-flex size-3.5 flex-none cursor-pointer items-center justify-center rounded-full border border-control-border bg-control","outline-none transition-colors duration-150 ease-out","hover:border-control-border-hover","data-checked:border-primary data-checked:bg-primary","focus-visible:shadow-focus","data-disabled:cursor-not-allowed data-disabled:opacity-45",e),...n,children:[t,r.jsx(Wye,{"data-slot":"radio-group-indicator",className:"grid place-content-center data-unchecked:hidden",children:r.jsx("span",{className:"block size-[5px] rounded-full bg-primary-foreground"})})]})}function QH(e){const t=p.useRef(!0);t.current&&(t.current=!1,e())}const ZH=p.createContext(void 0),JH=p.createContext(void 0),eV=p.createContext(void 0);function Vd(){const e=p.useContext(ZH);if(e===void 0)throw new Error(Vn(60));return e}function uP(){const e=p.useContext(JH);if(e===void 0)throw new Error(Vn(101));return e}function tV(){const e=p.useContext(eV);if(e===void 0)throw new Error(Vn(61));return e}function aje(e,t,n=Object.is){const{length:s}=e;if(s!==t.length)return!1;for(let i=0;iObject.is(e,t);function qo(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function nV(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!aje(e,t,(s,i)=>qo(s,i,n)):e!==t}function wS(e,t,n){return e?e.some(s=>s===void 0?!1:qo(t,s,n)):!1}function yg(e,t,n){return e?e.findIndex(s=>s===void 0?!1:qo(s,t,n)):-1}function ije(e,t){if(t!==jS)return s=>wS(e,s,t);const n=new Set(e);return n.delete(void 0),s=>n.has(s)&&(s!==0||e.some(i=>Object.is(s,i)))}function Wb(e,t,n,s){const i=s&&Array.isArray(t)?e.findIndex(ije(t,n)):yg(e,t,n);return i===-1?null:i}function rV(e,t,n,s,i,o){return wS(s,t,i)?o!=null&&e>o&&wS(s,n[o],i)?o:e:e===o?Wb(n,s,i,!0):o}function sV(e,t,n){return e.filter(s=>!qo(t,s,n))}function oje(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function dP(e){return oje(e?.[0])}function kS(e){return dP(e)?e.flatMap(t=>t.items):e}function aV(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(dP(t)){for(const n of t)for(const s of n.items)if(s&&s.value==null&&s.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function qd(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return yS(e)}function Rl(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?yS(e.value):yS(e)}function fP(e,t,n){function s(){return qd(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??s();if(Array.isArray(t)){const o=kS(t);if(e==null||typeof e!="object"){const l=o.find(u=>u.value===e);return l&&l.label!=null?l.label:s()}if("value"in e){const l=o.find(u=>u&&u.value===e.value);if(l&&l.label!=null)return l.label}}return s()}function iV(e,t,n){return e.reduce((s,i,o)=>(o>0&&s.push(", "),s.push(r.jsx(p.Fragment,{children:fP(i,t,n)},o)),s),[])}const lje={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:s}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Rl(t,s)!==""},hasNullItemLabel:(e,t)=>t?aV(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,s=e.value;return e.multiple?Array.isArray(s)&&s.some(i=>qo(t,i,n)):qo(t,s,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},yu=1;function oV(e,t){return Math.max(0,e-t)}function cje(e,t){if(t<=0)return 0;const n=bu(e,0,t),s=n,i=t-n,o=s<=yu,l=i<=yu;return o&&l?s<=i?0:t:o?0:l?t:n}function uje(e){const{id:t,value:n,defaultValue:s=null,onValueChange:i,open:o,defaultOpen:l=!1,onOpenChange:u,name:d,form:f,autoComplete:m,disabled:g=!1,readOnly:v=!1,required:b=!1,modal:y=!0,actionsRef:k,inputRef:w,onOpenChangeComplete:S,items:N,multiple:C=!1,itemToStringLabel:T,itemToStringValue:P,isItemEqualToValue:O=jS,highlightItemOnHover:A=!0,children:R}=e,{clearErrors:M}=uu(),{setDirty:_,setTouched:L,setFocused:$,validityData:D,setFilled:F,name:V,disabled:K,validation:Q,validationMode:X}=uo(),U=_d({id:t}),z=K||g,q=V??d,[J,ee]=Tl({controlled:n,default:C?s??co:s,name:"Select",state:"value"}),[H,G]=Tl({controlled:o,default:l,name:"Select",state:"open"}),Y=p.useRef([]),se=p.useRef([]),re=p.useRef(null),ne=p.useRef(null),de=p.useRef(0),ie=p.useRef(null),oe=p.useRef([]),je=p.useRef(!1),te=p.useRef(null),le=p.useRef(null),he=p.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ce=p.useRef(!1),ye=p.useRef(J),{mounted:fe,setMounted:Le,transitionStatus:pe}=gu(H),{openMethod:xe,triggerProps:Se}=IH(H),ge=$s(()=>new Ph({id:U,labelId:void 0,modal:y,multiple:C,itemToStringLabel:T,itemToStringValue:P,isItemEqualToValue:O,value:J,open:H,mounted:fe,transitionStatus:pe,items:N,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:yr,triggerProps:yr,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Xn,setOpen:Xn,handleScrollArrowVisibility:Xn,onOpenChangeComplete:Xn,listRef:Y,popupRef:re,scrollHandlerRef:ne,scrollArrowsMountedCountRef:de,valueRef:ie,valuesRef:oe,labelsRef:se,typingRef:je,selectionRef:he,firstItemTextRef:te,selectedItemTextRef:le,alignItemWithTriggerActiveRef:ce,initialValueRef:ye},lje)).current,ue=ge.useState("activeIndex"),be=ge.useState("selectedIndex"),ve=ge.useState("triggerElement"),De=ge.useState("positionerElement"),Ie=mye(xe),We=xe??Ie,nt=p.useMemo(()=>C?"":Rl(J,P),[C,J,P]),kt=p.useMemo(()=>C&&Array.isArray(J)?J.map(xn=>Rl(xn,P)):Rl(J,P),[C,J,P]),Je=ss(ve),on=Ke(()=>kt);hg(Je,U,J,on,!z,d);const nn=C?Array.isArray(J)&&J.length>0:J!=null&&nt!=="";Ge(()=>{F(nn)},[nn,F]),Ge(function(){const jn=Wb(oe.current,J,O,C);jn===null&&(le.current=null),!H&&ge.set("selectedIndex",jn)},[C,H,J,O,ge]),Vo(J,()=>{M(q),_(nV(J,D.initialValue,O)),Q.change(J)});const On=Ke((xn,jn)=>{u?.(xn,jn),!jn.isCanceled&&(G(xn),!xn&&(jn.reason===Fd||jn.reason===Wk)&&(L(!0),$(!1),X==="onBlur"&&Q.commit(J)))}),Rn=Ke(()=>{Le(!1),ge.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),S?.(!1)});ji({enabled:!k,open:H,ref:re,onComplete(){H||Rn()}}),p.useImperativeHandle(k,()=>({unmount:Rn}),[Rn]);const gt=Ke((xn,jn)=>{i?.(xn,jn),!jn.isCanceled&&ee(xn)}),sn=Ke(xn=>{const jn=oV(xn.scrollHeight,xn.clientHeight),ke=cje(xn.scrollTop,jn),Xe=ke>0,Qe=keYH(Y.current[xn]),onMatch(xn){H?ge.set("activeIndex",xn):gt(oe.current[xn],Nt(rs))},onTyping(xn){je.current=xn}}),jt=p.useMemo(()=>oo(Ht.reference,Tt.reference,ht.reference,zt.reference,Se),[zt.reference,Ht.reference,Tt.reference,ht.reference,Se]),an=p.useMemo(()=>oo(Ub,Ht.floating,Tt.floating,ht.floating),[Ht.floating,Tt.floating,ht.floating]),Xt=Tt.item??yr;ge.useContextCallback("setValue",gt),ge.useContextCallback("setOpen",On),ge.useContextCallback("handleScrollArrowVisibility",sn),ge.useContextCallback("onOpenChangeComplete",S),QH(()=>{ge.update({popupProps:an,triggerProps:jt})}),ge.useSyncedValues({id:U,modal:y,multiple:C,value:J,open:H,mounted:fe,transitionStatus:pe,popupProps:an,triggerProps:jt,items:N,itemToStringLabel:T,itemToStringValue:P,isItemEqualToValue:O,openMethod:We});const gn=p.useMemo(()=>({disabled:z,readOnly:v,required:b,multiple:C,highlightItemOnHover:A,itemProps:Xt}),[z,v,b,C,A,Xt]),un=lo(w,Q.inputRef),lr=C?void 0:q,yn=p.useMemo(()=>!C||!Array.isArray(J)||!q?null:J.map(xn=>{const jn=Rl(xn,P);return r.jsx("input",{type:"hidden",form:f,name:q,value:jn,disabled:z},jn)}),[C,J,f,q,P,z]);return r.jsxs(ZH.Provider,{value:ge,children:[r.jsx(JH.Provider,{value:gn,children:r.jsx(eV.Provider,{value:qe,children:R})}),r.jsx("input",{...Q.getValidationProps(z,{onFocus(){ge.state.triggerElement?.focus({focusVisible:!0})},onChange(xn){if(xn.nativeEvent.defaultPrevented||z||v)return;const jn=xn.currentTarget.value,ke=Nt(rs,xn.nativeEvent);function Xe(){if(C)return;const Qe=jn.toLowerCase();let Yt=oe.current.findIndex(fn=>Rl(fn,P).toLowerCase()===Qe||qd(fn,T).toLowerCase()===Qe);Yt===-1&&(Yt=oe.current.findIndex((fn,At)=>{const Re=se.current[At];return Re!=null&&Re.toLowerCase()===Qe}));const Rt=oe.current[Yt];Rt!=null&>(Rt,ke)}ge.set("forceMount",!0),queueMicrotask(Xe)}}),id:U&&lr==null?`${U}-hidden-input`:void 0,form:f,name:lr,autoComplete:m,value:nt,disabled:z,required:b&&!(C&&nn),readOnly:v,ref:un,style:q?pg:vu,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),yn]})}function lV(e,t){return e??t}const SS=5;function cV(e,t){const n=dje(t);return e.clientX>=n.left-SS&&e.clientX<=n.right+SS&&e.clientY>=n.top-SS&&e.clientY<=n.bottom+SS}function dje(e){const t=e.getBoundingClientRect(),n=vr(e);if(UO)return t;const s=n.getComputedStyle(e,"::before"),i=n.getComputedStyle(e,"::after");if(!(s.content!=="none"||i.content!=="none"))return t;const l=parseFloat(s.width)||0,u=parseFloat(s.height)||0,d=parseFloat(i.width)||0,f=parseFloat(i.height)||0,m=Math.max(t.width,l,d),g=Math.max(t.height,u,f),v=m-t.width,b=g-t.height;return{left:t.left-v/2,right:t.right+v/2,top:t.top-b/2,bottom:t.bottom+b/2}}const fje="data-popup-side",hje=400,mje={...KO,...hc,popupSide:e=>e?{[fje]:e}:null,value:()=>null},pje=p.forwardRef(function(t,n){const{render:s,className:i,id:o,disabled:l=!1,nativeButton:u=!0,style:d,...f}=t,{setTouched:m,setFocused:g,validationMode:v,validation:b,state:y,disabled:k}=uo(),{labelId:w}=zi(),S=Vd(),{readOnly:N,required:C,disabled:T}=uP(),P=k||T||l,O=S.useState("open"),A=S.useState("mounted"),R=S.useState("value"),M=S.useState("triggerProps"),_=S.useState("positionerElement"),L=S.useState("listElement"),$=S.useState("popupSide"),D=S.useState("id"),F=S.useState("labelId"),V=S.useState("hasSelectedValue"),K=A&&_?$:null,Q=o??D,X=lV(w,F);_d({id:o});const U=ss(_),z=p.useRef(null),{getButtonProps:q,buttonRef:J}=$i({disabled:P,native:u}),ee=S.useStateSetter("triggerElement"),H=fa(),G=fa(),Y=fa();p.useEffect(()=>{if(O)return Y.start(hje,()=>{S.context.selectionRef.current.allowUnselectedMouseUp=!0,S.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{Y.clear()};S.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},G.clear()},[O,S,G,Y]);const se=oo(M,{id:Q,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?L?.id??_k(_)?.id:void 0,"aria-labelledby":X,"aria-readonly":N||void 0,"aria-required":C||void 0,tabIndex:P?-1:0,onFocus(de){g(!0),O&&S.context.alignItemWithTriggerActiveRef.current&&S.context.setOpen(!1,Nt(rs,de.nativeEvent)),H.start(0,()=>{S.set("forceMount",!0)})},onBlur(de){Et(_,de.relatedTarget)||(m(!0),g(!1),v==="onBlur"&&b.commit(R))},onMouseDown(de){if(O)return;const ie=_n(de.currentTarget);function oe(je){if(!z.current)return;const te=je.target;Et(z.current,te)||Et(U.current,te)||cV(je,z.current)||S.context.setOpen(!1,Nt(UU,je))}G.start(0,()=>{ie.addEventListener("mouseup",oe,{once:!0})})}},f,q),re=b.getValidationProps(P,se);re.role="combobox";const ne={...y,open:O,disabled:P,value:R,readOnly:N,popupSide:K,placeholder:!V};return qt("button",t,{ref:[n,z,J,ee],state:ne,stateAttributesMapping:mje,props:re})}),gje={value:()=>null},xje=p.forwardRef(function(t,n){const{className:s,render:i,children:o,placeholder:l,style:u,...d}=t,f=Vd(),m=f.useState("value"),g=f.useState("items"),v=f.useState("itemToStringLabel"),b=f.useState("hasSelectedValue"),y=!b&&l!=null&&o==null,k=f.useState("hasNullItemLabel",y),w={value:m,placeholder:!b};let S=null;return typeof o=="function"?S=o(m):o!=null?S=o:y&&!k?S=l:Array.isArray(m)?S=iV(m,g,v):S=fP(m,g,v),qt("span",t,{state:w,ref:[n,f.context.valueRef],props:[{children:S},d],stateAttributesMapping:gje})}),vje=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,f={open:Vd().useState("open")};return qt("span",t,{state:f,ref:n,props:[{"aria-hidden":!0,children:"▼"},l],stateAttributesMapping:Rk})}),bje=p.forwardRef(function(t,n){const s=Vd(),i=s.useState("mounted"),o=s.useState("forceMount");return i||o?r.jsx(eS,{ref:n,...t}):null}),uV=p.createContext(void 0);function yje(){const e=p.useContext(uV);if(!e)throw new Error(Vn(59));return e}function NS(e,t){e&&Object.assign(e.style,t)}const jje={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},wje=20;function hP(e,t,n,s){const[i,o]=p.useState(!1);Ge(()=>{if(!e||!t||n==null){o(!1);return}const l=_n(n).documentElement.clientWidth,u=n.offsetWidth;o(l>0&&u>0&&u>=l-wje)},[e,t,n]),OH(e&&(!t||i),s)}const kje={position:"fixed"},Sje=p.forwardRef(function(t,n){const{anchor:s,className:i,render:o,positionMethod:l,side:u,align:d,sideOffset:f,alignOffset:m,collisionBoundary:g="clipping-ancestors",collisionPadding:v,arrowPadding:b,sticky:y,disableAnchorTracking:k,alignItemWithTrigger:w=!0,collisionAvoidance:S=h6,style:N,...C}=t,T=Vd(),P=tV(),O=T.useState("open"),A=T.useState("mounted"),R=T.useState("modal"),M=T.useState("value"),_=T.useState("openMethod"),L=T.useState("positionerElement"),$=T.useState("triggerElement"),D=T.useState("isItemEqualToValue"),F=T.useState("transitionStatus"),V=p.useRef(null),K=p.useRef(null),[Q,X]=p.useState(w),U=A&&Q&&_!=="touch";!A&&Q!==w&&X(w),p.useImperativeHandle(T.context.alignItemWithTriggerActiveRef,()=>U),hP((U||R)&&O,_==="touch",L,$);const z=hS({anchor:s,floatingRootContext:P,positionMethod:l,mounted:A,side:u,sideOffset:f,align:d,alignOffset:m,arrowPadding:b,collisionBoundary:g,collisionPadding:v,sticky:y,disableAnchorTracking:k??U,collisionAvoidance:S,keepMounted:!0}),q=U?"none":z.side,J=U?kje:z.positionerStyles,ee={open:O,side:q,align:z.align,anchorHidden:z.anchorHidden};Ge(()=>{T.set("popupSide",z.side)},[T,z.side]);const H=T.useStateSetter("positionerElement"),G=mS(t,ee,{styles:J,transitionStatus:F,props:C,refs:[n,H],hidden:!A,inert:!O}),Y=p.useRef(0),se=Ke(ne=>{if(T.context.valuesRef.current.length===0)return;const de=Y.current;Y.current=ne.size;const ie=Nt(rs);if(de!==0&&!T.state.multiple&&M!==null&&yg(T.context.valuesRef.current,M,D)===-1){const je=T.context.initialValueRef.current,le=je!=null&&yg(T.context.valuesRef.current,je,D)!==-1?je:null;T.context.setValue(le,ie),le===null&&(T.set("selectedIndex",null),T.context.selectedItemTextRef.current=null)}if(de!==0&&T.state.multiple&&Array.isArray(M)){const oe=M.filter(je=>yg(T.context.valuesRef.current,je,D)!==-1);oe.length!==M.length&&(T.context.setValue(oe,ie),oe.length===0&&(T.set("selectedIndex",null),T.context.selectedItemTextRef.current=null))}if(O&&U){T.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const oe={height:""};NS(L,oe),NS(T.context.popupRef.current,oe)}}),re=p.useMemo(()=>({...z,side:q,alignItemWithTriggerActive:U,setControlledAlignItemWithTrigger:X,scrollUpArrowRef:V,scrollDownArrowRef:K}),[z,q,U,X]);return r.jsx(cP,{elementsRef:T.context.listRef,labelsRef:T.context.labelsRef,onMapChange:se,children:r.jsxs(uV.Provider,{value:re,children:[A&&R&&r.jsx(vS,{inert:Kb(!O),cutout:$}),G]})})}),CS="base-ui-disable-scrollbar",dV={className:CS,getElement(e){return r.jsx("style",{nonce:e,href:CS,precedence:"base-ui:low",children:`.${CS}{scrollbar-width:none}.${CS}::-webkit-scrollbar{display:none}`})}},Nje=p.createContext(void 0);function fV(e){return p.useContext(Nje)}const Cje=p.createContext(void 0),Aje={disableStyleElements:!1};function Eje(){return p.useContext(Cje)??Aje}const hV="--transform-origin",Tje={...cg,...Fo},Oje=p.forwardRef(function(t,n){const{render:s,className:i,style:o,finalFocus:l,...u}=t,d=Vd(),{multiple:f,readOnly:m,highlightItemOnHover:g}=uP(),v=tV(),{side:b,align:y,alignItemWithTriggerActive:k,isPositioned:w,setControlledAlignItemWithTrigger:S}=yje(),N=fV()!=null,C=Vb(),{nonce:T,disableStyleElements:P}=Eje(),O=d.useState("id"),A=d.useState("open"),R=d.useState("openMethod"),M=d.useState("mounted"),_=d.useState("popupProps"),L=d.useState("transitionStatus"),$=d.useState("triggerElement"),D=d.useState("positionerElement"),F=d.useState("listElement"),V=p.useRef(!1),K=p.useRef(!1),Q=p.useRef({}),X=fg(),U=Ke(ee=>{if(!D||!d.context.popupRef.current||!K.current)return;const H=D.style.top==="0px",G=D.style.bottom==="0px";if(V.current||!k||!H&&!G){d.context.handleScrollArrowVisibility(ee);return}const Y=pV(D),se=Yb(D.getBoundingClientRect().height,"y",Y),re=_n(D),ne=vr(D),de=ne.getComputedStyle(D),ie=parseFloat(de.marginTop),oe=parseFloat(de.marginBottom),je=mV(ne.getComputedStyle(d.context.popupRef.current)),te=Math.min(re.documentElement.clientHeight-ie-oe,je),le=ee.scrollTop,he=AS(ee);let ce=null;const ye=xe=>{D.style.height=`${xe}px`},fe=H?he-le:le,Le=Math.min(se+fe,te);if(fe<=yu){const xe=bu(fe,0,te-se);xe>0&&ye(se+xe),ee.scrollTop=H?he:0,te-(se+xe)<=yu&&(V.current=!0),d.context.handleScrollArrowVisibility(ee);return}if(te-Le>yu)ce=H?1/0:0;else if(G&&leyu&&(ee.scrollTop=xe)}pe>=te-yu&&(V.current=!0),d.context.handleScrollArrowVisibility(ee)});p.useImperativeHandle(d.context.scrollHandlerRef,()=>U,[U]),ji({open:A,ref:d.context.popupRef,onComplete(){A&&d.context.onOpenChangeComplete(!0)}});const z={open:A,transitionStatus:L,side:b,align:y};Ge(()=>{!D||!d.context.popupRef.current||Object.keys(Q.current).length||(Q.current={top:D.style.top||"0",left:D.style.left||"0",right:D.style.right,height:D.style.height,bottom:D.style.bottom,minHeight:D.style.minHeight,maxHeight:D.style.maxHeight,marginTop:D.style.marginTop,marginBottom:D.style.marginBottom})},[d,D]),Ge(()=>{A||k||(K.current=!1,V.current=!1,NS(D,Q.current))},[A,k,D]),Ge(()=>{const ee=d.context.popupRef.current;if(!A||!$||!D||!ee||k&&!w||d.state.transitionStatus==="ending")return;if(K.current=!0,ee.style.removeProperty(hV),!k){X.request(()=>d.context.handleScrollArrowVisibility(F||ee));return}const H=Rje(ee);try{let G=d.context.selectedItemTextRef.current;G?.isConnected||(G=!d.select("hasSelectedValue")&&d.context.firstItemTextRef.current?.isConnected?d.context.firstItemTextRef.current:null);const Y=d.context.valueRef.current,se=vr(D),re=se.getComputedStyle(D),ne=se.getComputedStyle(ee),de=_n($),ie=pV($),oe=ES($.getBoundingClientRect(),ie),je=ES(D.getBoundingClientRect(),ie),te=oe.height,le=F||ee,he=le.scrollHeight,ce=parseFloat(ne.borderBottomWidth),ye=parseFloat(re.marginTop)||10,fe=parseFloat(re.marginBottom)||10,Le=parseFloat(re.minHeight)||100,pe=mV(ne),xe=5,Se=5,ge=20,ue=de.documentElement.clientHeight-ye-fe,be=de.documentElement.clientWidth,ve=ue-oe.bottom+te;let De,Ie=C==="rtl"?oe.right-je.width:oe.left,We=0;if(G&&Y){const zt=ES(Y.getBoundingClientRect(),ie);De=ES(G.getBoundingClientRect(),ie),Ie=je.left+(C==="rtl"?zt.right-De.right:zt.left-De.left);const ht=zt.top-oe.top+zt.height/2;We=De.top-je.top+De.height/2-ht}const nt=ve+We+fe+ce;let kt=Math.min(ue,nt);const Je=ue-ye-fe,on=nt-kt,nn=be-Se;D.style.left=`${bu(Ie,xe,nn-je.width)}px`,D.style.height=`${kt}px`,D.style.maxHeight="none",D.style.marginTop=`${ye}px`,D.style.marginBottom=`${fe}px`,ee.style.height="100%";const On=AS(le),Rn=on>=On-yu;Rn&&(kt=Math.min(ue,je.height)-(on-On));const gt=oe.topue-ge||Math.ceil(kt)+yu=Je?"0":`${zt}px`,D.style.height=`${kt}px`,le.scrollTop=AS(le)}else D.style.bottom="0",le.scrollTop=on;if(De){const zt=je.top,ht=je.height,Tt=De.top+De.height/2,Ht=bu(ht>0?(Tt-zt)/ht*100:50,0,100);ee.style.setProperty(hV,`50% ${Ht}%`)}(qe===ue||kt>=pe)&&(V.current=!0),d.context.handleScrollArrowVisibility(le),g&&d.state.selectedIndex===null&&d.state.activeIndex===null&&d.context.listRef.current[0]!=null&&d.set("activeIndex",0)}finally{H()}},[d,A,D,$,k,S,X,F,g,C,w]),p.useEffect(()=>{if(!k||!D||!A)return;const ee=vr(D);function H(G){d.context.setOpen(!1,Nt(Nxe,G))}return kn(ee,"resize",H)},[d,k,D,A]);const q={...F?{role:"presentation"}:{role:"listbox","aria-multiselectable":f||void 0,"aria-readonly":m||void 0,id:`${O}-list`},onKeyDown(ee){N&&gS.has(ee.key)&&ee.stopPropagation()},onScroll(ee){F||U(ee.currentTarget)},...k&&{style:F?{height:"100%"}:jje},className:!F&&k?dV.className:void 0},J=qt("div",t,{ref:[n,d.context.popupRef],state:z,stateAttributesMapping:Tje,props:[_,q,qb(L),u]});return r.jsxs(p.Fragment,{children:[!P&&dV.getElement(T),r.jsx(tS,{context:v,modal:!1,disabled:!M,openInteractionType:R,returnFocus:l,restoreFocus:!0,children:J})]})});function mV(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function AS(e){return oV(e.scrollHeight,e.clientHeight)}function pV(e){return M6.getScale(e)}function Yb(e,t,n){return e/n[t]}function ES(e,t){return Rb({x:Yb(e.x,"x",t),y:Yb(e.y,"y",t),width:Yb(e.width,"x",t),height:Yb(e.height,"y",t)})}const gV=[["transform","none"],["scale","1"],["translate","0 0"]];function Rje(e){const{style:t}=e,n={};for(const[s,i]of gV)n[s]=t.getPropertyValue(s),t.setProperty(s,i,"important");return()=>{for(const[s]of gV){const i=n[s];i?t.setProperty(s,i):t.removeProperty(s)}}}const xV=p.createContext(void 0);function mP(){const e=p.useContext(xV);if(!e)throw new Error(Vn(57));return e}const Pje=p.memo(p.forwardRef(function(t,n){const{render:s,className:i,style:o,value:l=null,label:u,disabled:d=!1,nativeButton:f=!1,...m}=t,g=p.useRef(null),v=lP({guess:!0,label:u,textRef:g}),b=Vd(),{itemProps:y,multiple:k,disabled:w,readOnly:S}=uP(),N=w||d,C=b.useState("isActive",v.index),T=b.useState("open"),P=b.useState("isSelected",l),O=b.useState("isSelectedByFocus",v.index),A=b.useState("isItemEqualToValue"),R=v.index,M=p.useRef(null);Ge(()=>{const z=b.context.valuesRef.current;return z[R]=l,()=>{delete z[R]}},[R,l,b]),Ge(()=>{const z=b.state.value,q=b.state.selectedIndex;let J=q,ee;k&&Array.isArray(z)?(J=rV(R,l,b.context.valuesRef.current,z,A,q),ee=J===R,R===q&&!ee&&(b.context.selectedItemTextRef.current=null)):(ee=z!==void 0&&qo(l,z,A),ee&&(J=R)),b.set("selectedIndex",J),ee&&g.current&&(b.context.selectedItemTextRef.current=g.current)},[R,k,A,b,l]);const _=p.useRef("mouse"),L=p.useRef(!1),{getButtonProps:$,buttonRef:D}=$i({disabled:N,focusableWhenDisabled:!0,native:f,composite:!0}),F={disabled:N,selected:P,highlighted:C};function V(z){if(w||S)return;const q=b.state.value;if(k){const J=Array.isArray(q)?q:[],ee=P?sV(J,l,A):[...J,l];b.context.setValue(ee,Nt(Mb,z))}else b.context.setValue(l,Nt(Mb,z)),b.context.setOpen(!1,Nt(Mb,z))}function K(){b.context.selectionRef.current.dragY=0}const Q={role:"option","aria-selected":P,tabIndex:T&&C?0:-1,onKeyDown(z){b.set("activeIndex",R),z.key===" "&&b.context.typingRef.current&&z.preventDefault()},onClick(z){const q=_.current!=="touch",J=z.nativeEvent.pointerType,ee=q&&Dk(z.nativeEvent)&&(J!==void 0||C),H=q&&!ee&&!L.current;L.current=!1,!(N||H)&&V(z.nativeEvent)},onPointerEnter(z){_.current=z.pointerType},onPointerMove(z){if(z.pointerType==="mouse"&&z.buttons===1){const q=b.context.selectionRef.current;q.dragY+=z.movementY,q.dragY**2>=64&&(q.allowUnselectedMouseUp=!0)}},onPointerDown(z){_.current=z.pointerType,L.current=!0,K()},onMouseUp(){if(K(),N||_.current==="touch"||L.current)return;const z=!b.context.selectionRef.current.allowSelectedMouseUp&&P,q=!b.context.selectionRef.current.allowUnselectedMouseUp&&!P;z||q||(L.current=!0,M.current?.click(),L.current=!1)}},X=qt("div",t,{ref:[D,n,v.ref,M],state:F,props:[y,Q,m,$]}),U=p.useMemo(()=>({selected:P,index:R,textRef:g,selectedByFocus:O}),[P,R,g,O]);return r.jsx(xV.Provider,{value:U,children:X})})),Ije=p.forwardRef(function(t,n){const{selected:s}=mP();return t.keepMounted||s?r.jsx(Mje,{...t,ref:n}):null}),Mje=p.memo(p.forwardRef((e,t)=>{const{render:n,className:s,style:i,keepMounted:o,...l}=e,{selected:u}=mP(),d=p.useRef(null),{transitionStatus:f,setMounted:m}=gu(u),v=qt("span",e,{ref:[t,d],state:{selected:u,transitionStatus:f},props:[{"aria-hidden":!0,children:"✔️"},l],stateAttributesMapping:Fo});return ji({batch:!0,enabled:!u,open:u,ref:d,onComplete(){u||m(!1)}}),v})),_je=p.memo(p.forwardRef(function(t,n){const{index:s,textRef:i,selectedByFocus:o}=mP(),l=Vd(),{render:u,className:d,style:f,...m}=t,g=p.useCallback(b=>{b&&(s===0&&(l.context.firstItemTextRef.current=b),o&&(l.context.selectedItemTextRef.current=b))},[l,s,o]);return qt("div",t,{ref:[g,n,i],props:m})})),vV=p.createContext(void 0);function Dje(){const e=p.useContext(vV);if(e===void 0)throw new Error(Vn(56));return e}const Lje=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,[u,d]=p.useState(),f=p.useMemo(()=>({labelId:u,setLabelId:d}),[u,d]),m=qt("div",t,{ref:n,props:[{role:"group","aria-labelledby":u},l]});return r.jsx(vV.Provider,{value:f,children:m})}),$je=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,...u}=t,{setLabelId:d}=Dje(),f=Ws(l);return Ge(()=>(d(f),()=>{d(g=>g===f?void 0:g)}),[f,d]),qt("div",t,{ref:n,props:[{id:f,"aria-hidden":!0},u]})}),zje=p.forwardRef(function(t,n){const{className:s,render:i,orientation:o="horizontal",style:l,...u}=t;return qt("div",t,{state:{orientation:o},ref:n,props:[{role:"presentation"},u]})});function bV(e,t){const[n,s]=p.useState();return p.useLayoutEffect(()=>{if(!t)return;const i=e?.closest('[role="dialog"], [role="alertdialog"]'),o=e?.ownerDocument.defaultView;if(!e||!i||!o){s(void 0);return}const l=[i];for(let u=e.parentElement;u&&u!==i;u=u.parentElement){const d=o.getComputedStyle(u);(/(auto|scroll)/.test(`${d.overflowX} ${d.overflowY}`)||u.matches('[data-slot="dialog-body"], [data-slot="sheet-body"], [data-slot="alert-dialog-body"]'))&&l.push(u)}s(l)},[e,t]),n}const TS=p.createContext(null);function Pt({open:e,defaultOpen:t=!1,onOpenChange:n,children:s,...i}){const[o,l]=p.useState(t),[u,d]=p.useState(null),[f,m]=p.useState(!1),g=e??o;p.useLayoutEffect(()=>{g&&m(!1)},[g]);const v=p.useCallback((k,w)=>{n?.(k,w),!w.isCanceled&&(k&&m(!1),l(k))},[n]),b=p.useCallback(()=>{if(!g||f)return;const k=Nt("none",void 0,u??void 0);v(!1,k),k.isCanceled||m(!0)},[g,f,u,v]),y=p.useMemo(()=>({open:g,trigger:u,setTrigger:d,closeOnAnchorHidden:b,closedOnAnchorHidden:f}),[g,u,b,f]);return r.jsx(TS.Provider,{value:y,children:r.jsx(uje,{...i,open:g,onOpenChange:v,children:s})})}function Bje({anchorHidden:e,open:t,...n}){const i=p.useContext(TS)?.closeOnAnchorHidden;return p.useLayoutEffect(()=>{t&&e&&i?.()},[t,e,i]),r.jsx("div",{...n})}const It=xje,Fje=Lje,Uje=$je,Hje=zje;function Mt({className:e,children:t,ref:n,...s}){const i=p.useContext(TS);return Ah({render:r.jsx(pje,{}),ref:[n??null,i?.setTrigger??null],props:{...s,"data-slot":"select-trigger",className:Ne("inline-flex h-[30px] min-w-0 cursor-pointer items-center justify-between gap-1.5 rounded-md border border-control-border bg-control px-2.5","[&>span]:min-w-0 [&>span]:truncate","text-[12.5px] font-normal text-foreground max-[767px]:h-10 max-[767px]:text-base","transition-colors duration-150 ease-out","hover:border-control-border-hover hover:bg-control-hover","focus-visible:border-primary focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:bg-control data-disabled:text-muted-foreground data-disabled:opacity-60",e),children:r.jsxs(r.Fragment,{children:[t,r.jsx(vje,{className:"flex flex-none text-muted-foreground transition-transform duration-[180ms] data-popup-open:rotate-180",children:r.jsx("svg",{viewBox:"0 0 10 6",className:"size-2.5","aria-hidden":"true",children:r.jsx("path",{d:"M1 1l4 4 4-4",stroke:"currentColor",strokeWidth:"1.4",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}})}function _t({className:e,sideOffset:t=4,children:n,finalFocus:s,...i}){const o=p.useContext(TS),l=bV(o?.trigger??null,o?.open??!1);return r.jsx(bje,{children:r.jsx(Sje,{sideOffset:t,alignItemWithTrigger:!1,collisionBoundary:l,className:"z-[35] data-anchor-hidden:invisible data-anchor-hidden:pointer-events-none",render:(u,d)=>r.jsx(Bje,{...u,anchorHidden:d.anchorHidden,open:d.open}),children:r.jsx(Oje,{"data-slot":"select-content",className:Ne("max-h-[min(260px,var(--available-height))] min-w-[min(var(--anchor-width),var(--available-width))] max-w-[var(--available-width)] overflow-y-auto overscroll-contain rounded-lg border border-border-strong bg-raised p-[5px] shadow-3","outline-none","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0",e),finalFocus:o?.closedOnAnchorHidden?!1:s,...i,children:n})})})}function Ze({className:e,children:t,...n}){return r.jsxs(Pje,{"data-slot":"select-item",className:Ne("flex min-h-7 cursor-pointer items-center gap-2 rounded-sm px-[9px] text-[12.5px] leading-[1.4] text-foreground select-none","transition-colors duration-[120ms] ease-out","data-[highlighted]:bg-nav-hover","data-[selected]:bg-primary-soft data-[selected]:font-semibold data-[selected]:text-primary-fg","data-[highlighted]:data-[selected]:bg-primary-tint","data-disabled:pointer-events-none data-disabled:font-normal data-disabled:text-muted-foreground",e),...n,children:[r.jsx(_je,{className:"min-w-0 flex-1 truncate",children:t}),r.jsx(Ije,{className:"flex flex-none text-primary",children:r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}function Vje(e,t,n,s,i,o,l,u,d,f=2){const m=txe(n.current,{event:e,orientation:s,loopFocus:i,rtl:o,cols:f,disabledIndices:l,minIndex:u,maxIndex:d,prevIndex:t>d?u:t,stopEvent:!0});return zd(n.current,m)?void 0:m}const yV=p.createContext(void 0),jV=p.createContext(void 0),wV=p.createContext(void 0),kV=p.createContext(!1),SV=p.createContext("");function Ko(){const e=p.useContext(yV);if(!e)throw new Error(Vn(22));return e}function OS(){const e=p.useContext(jV);if(!e)throw new Error(Vn(23));return e}function Xb(){const e=p.useContext(wV);if(!e)throw new Error(Vn(24));return e}function NV(){return p.useContext(SV)}function qje(){return p.useContext(kV)}const Kje={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{const t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{const{selectedValue:t,selectionMode:n}=e;return t==null?!1:n==="multiple"&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?aV(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,s=e.selectedValue;return Array.isArray(s)?s.some(i=>qo(t,i,n)):qo(t,s,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemProps:e=>e.itemProps,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight};function CV(e){return e==null?void 0:`${e}-popup`}function Gje(e,t){return(n,s)=>n==null?!1:e.contains(n,s,t)}const AV=new Map;function Wje(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${pR(e.locale)}|${JSON.stringify(t)}`,s=AV.get(n);if(s)return s;const i=new Intl.Collator(e.locale,t),o={contains(l,u,d){if(!u)return!0;const f=qd(l,d);for(let m=0;m<=f.length-u.length;m+=1)if(i.compare(f.slice(m,m+u.length),u)===0)return!0;return!1},startsWith(l,u,d){if(!u)return!0;const f=qd(l,d);return i.compare(f.slice(0,u.length),u)===0},endsWith(l,u,d){if(!u)return!0;const f=qd(l,d),m=u.length;return f.length>=m&&i.compare(f.slice(f.length-m),u)===0}};return AV.set(n,o),o}const Yje=Wje;function Xje(e,t=!1){const{overflowY:n}=Li(e);return n!=="auto"&&n!=="scroll"?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}const EV=Symbol("none"),pP={value:EV,index:-1};function Qje(e,t,n){const s=e.get(t);if(s!==void 0||n===jS)return s;for(const[i,o]of e)if(qo(i,t,n))return o}function Zje(e){const{id:t,onOpenChangeComplete:n,defaultSelectedValue:s=null,selectedValue:i,onSelectedValueChange:o,defaultInputValue:l,inputValue:u,open:d,defaultOpen:f=!1,selectionMode:m,onItemHighlighted:g,name:v,form:b,disabled:y=!1,readOnly:k=!1,required:w=!1,inputRef:S,grid:N=!1,items:C,filteredItems:T,filter:P,filterQuery:O,openOnInputClick:A=!0,autoHighlight:R=!1,keepHighlight:M=!1,highlightItemOnHover:_=!0,loopFocus:L=!0,itemToStringLabel:$,itemToStringValue:D,isItemEqualToValue:F=jS,virtualized:V=!1,inline:K=!1,fillInputOnItemPress:Q=!0,modal:X=!1,limit:U=-1,autoComplete:z="list",formAutoComplete:q,locale:J,submitOnItemClick:ee=!1}=e,{clearErrors:H}=uu(),{setDirty:G,validityData:Y,setFilled:se,name:re,disabled:ne,setTouched:de,setFocused:ie,validationMode:oe,validation:je}=uo(),te=Vb(),le=_d({id:t}),he=Yje({locale:J}),ce=Array.isArray(C)?null:C;if(ce&&typeof ce.label!="function")throw new Error(Vn(100));const ye=ce?ce.data:C,fe=ce?.value,Le=fe?void 0:ye,pe=p.useMemo(()=>{if(!T||!fe)return;const rt=kS(T),vt=rt.map(fe);let bn;return{values:vt,findItem(rr,qr){if(!bn){bn=new Map;for(let Pr=0;Prce?rt=>ce.label(rt,F,vt=>{const bn=pe?.findItem(vt,F);return bn!=null?ce.itemLabel(bn):qd(vt,$)}):$,[ce,$,pe,F]),Se=p.useMemo(()=>ce?Object.assign(rt=>ce.itemLabel(rt),{selected:rt=>qd(rt,xe)}):$,[ce,xe,$]);function ge(rt){return qd(rt,xe)}const[ue,be]=p.useState(!1),[ve,De]=p.useState(null),Ie=p.useRef(ve),We=p.useRef([]),nt=p.useRef([]),kt=p.useRef(null),Je=p.useRef(null),on=p.useRef(null),nn=p.useRef(null),On=p.useRef(null),Rn=p.useRef(!0),gt=p.useRef(!1),sn=p.useRef(null),qe=p.useRef(null),zt=p.useRef(null),ht=p.useRef(pP),Tt=p.useRef(null),Ht=p.useRef([]),jt=p.useRef(null),an=ne||y,Xt=re??v,gn=m==="multiple",un=m==="single",lr=u!==void 0||l!==void 0,yn=ye!==void 0,xn=T!==void 0;let jn;R==="always"?jn="always":jn=R?"input-change":!1;const[ke,Xe]=Tl({controlled:i,default:gn?s??co:s,name:"Combobox",state:"selectedValue"}),Qe=p.useMemo(()=>P===null?()=>!0:P!==void 0?P:Gje(he,Se),[P,he,Se]),Yt=$s(()=>lr?l??"":un?ge(ke):"").current,[Rt,fn]=Tl({controlled:u,default:Yt,name:"Combobox",state:"inputValue"}),[At,Re]=Tl({controlled:d,default:f,name:"Combobox",state:"open"}),mt=dP(ye),Bt=!At&&ve!==null?ve:String(Rt).trim(),Pn=un?ge(ke):"",mn=un&&!ue&&Bt!==""&&Pn.length===Bt.length&&he.contains(Pn,Bt),vn=mn?"":O??Bt,Qn=yn&&xn&&mn&&(!ce||ce.hasValue(ke,F)),Ns=p.useMemo(()=>ye?kS(ye):co,[ye]),Cr=p.useMemo(()=>{if(T&&!Qn)return T;if(!ye)return co;if(mt){const vt=ye,bn=[];let rr=0;for(const qr of vt){if(U>-1&&rr>=U)break;const Pr=U>-1?U-rr:1/0,Kr=vn===""?qr.items.slice(0,Pr):[];if(vn!=="")for(const Ks of qr.items){if(Kr.length>=Pr)break;Qe(Ks,vn,Se)&&Kr.push(Ks)}if(Kr.length>0){const Ks={...qr,items:Kr};bn.push(Ks),rr+=Kr.length}}return bn}if(vn==="")return U>-1?Ns.slice(0,U):Ns;const rt=[];for(const vt of Ns){if(U>-1&&rt.length>=U)break;Qe(vt,vn,Se)&&rt.push(vt)}return rt},[T,Qn,ye,mt,vn,U,Qe,Se,Ns]),Qr=p.useMemo(()=>{if(pe&&Cr===T)return pe.values;const rt=kS(Cr);return fe?rt.map(vt=>fe(vt)):rt},[Cr,T,pe,fe]),Vt=$s(()=>{let rt=null;return K&&At&&yn&&m!=="none"&&(rt=Wb(Qr,ke,F,gn)),new Ph({id:le,labelId:void 0,selectedValue:ke,open:At,items:Le,selectionMode:m,name:Xt,form:b,disabled:an,readOnly:k,required:w,grid:N,virtualized:V,openOnInputClick:A,itemToStringLabel:xe,isItemEqualToValue:F,modal:X,autoHighlight:jn,submitOnItemClick:ee,hasInputValue:lr,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:K,activeIndex:null,selectedIndex:rt,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:yr,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:m==="none"},{onOpenChangeComplete:Xn,setOpen:Xn,setInputValue:Xn,setSelectedValue:Xn,setIndices:Xn,handleSelection:Xn,forceMount:Xn,requestSubmit:Xn,listRef:We,labelsRef:nt,popupRef:kt,emptyRef:On,inputRef:Je,startDismissRef:on,endDismissRef:nn,keyboardActiveRef:Rn,chipsContainerRef:sn,clearRef:qe,valuesRef:Ht,pointerDownItemRef:jt,selectionEventRef:zt},Kje)}).current,eo=m==="none"?Rt:ke,qf=p.useMemo(()=>m==="none"?eo:Array.isArray(ke)?ke.map(rt=>Rl(rt,D)):Rl(ke,D),[eo,D,m,ke]),nc=Ke(g),Ca=Ke(n),si=Vt.useState("activeIndex"),Kf=Vt.useState("selectedIndex"),Tp=Vt.useState("positionerElement"),XE=Vt.useState("listElement"),Op=Vt.useState("triggerElement"),Rp=Vt.useState("inputElement"),Pp=Vt.useState("inputGroupElement"),Aa=Vt.useState("inline"),bi=Vt.useState("inputInsidePopup"),dd=Vt.useState("inputOwnsFormValue"),fd=un&&!bi&&Rt===Pn,Ip=ss(Op),{mounted:Gf,setMounted:aa,transitionStatus:k0}=gu(At),{openMethod:QE,triggerProps:S0}=IH(At),hd=Ke(()=>qf);hg(bi?Ip:Je,le,eo,hd,!an,v);const md=Ke(()=>{ye?nt.current=Qr.map(ge):Vt.set("forceMounted",!0)}),Wf=Ke((rt,vt,bn)=>{if(vt===-1){if(ht.current===pP)return;ht.current=pP}else ht.current={value:rt,index:vt};nc(rt,Cxe(bn,void 0,{index:vt}))}),Oo=Ke(rt=>{const vt={};rt.activeIndex!==void 0&&(vt.activeIndex=rt.activeIndex),rt.selectedIndex!==void 0&&(vt.selectedIndex=rt.selectedIndex),Vt.update(vt);const bn=rt.activeIndex;if(bn===void 0)return;const rr=rt.type||rs;bn===null?Wf(void 0,-1,rr):Wf(Ht.current[bn],bn,rr)}),Ro=Ke((rt,vt)=>{if(e.onInputValueChange?.(rt,vt),!vt.isCanceled){if(gt.current=vt.reason===mc,vt.reason===_b){At&&ve!==null&&De(null);const bn=vt.event,rr=bn.inputType;if(bn.type==="compositionend"||rr!=null&&rr!==""&&rr!=="insertReplacementText"){const Pr=rt.trim()!=="";Pr&&be(!0),Tt.current={hasQuery:Pr};const Kr=Vt.state.listElement;if(!Vt.state.virtualized&&Kr){const Ks=kt.current;for(const to of ig(Kr.firstElementChild??Kr)){if(!br(to)||(Ks?!Et(Ks,to):to.getAttribute("role")==="dialog"))break;if(Xje(to)){to.scrollTop=0;break}}}Pr&&jn&&Vt.state.activeIndex==null&&(At||Aa)&&Vt.set("activeIndex",0)}}else vt.reason===mc&&rt===""&&Vt.state.inputInsidePopup&&(Tt.current={hasQuery:!1,selection:!0});fn(rt)}}),ZE=Ke(rt=>{const vt=!rt&&bi&&!Aa&&Rt!==""&&(String(Rt).trim()===ve||Rt===Pn);!rt&&(vt||Rt===""||fd)&&be(!1),De(null),vt&&Ro("",Nt(mc))}),Hn=Ke((rt,vt)=>{if(At!==rt&&(vt.reason===mg&&yn&&Qr.length===0&&!On.current&&vt.allowPropagation(),e.onOpenChange?.(rt,vt),!vt.isCanceled&&(rt&&ve!==null&&ZE(vt.reason===_b),!rt&&ue&&(un?(Aa||De(Bt),Bt===""&&be(!1)):gn&&(Aa||De(Bt),bi&&Oo({activeIndex:null}),(!bi||Aa)&&Ro("",Nt(mc,vt.event,void 0,{isItemPress:vt.reason===Mb})))),Re(rt),!rt&&bi&&(vt.reason===Fd||vt.reason===Wk)&&(de(!0),ie(!1),oe==="onBlur")))){const bn=m==="none"?Rt:ke;je.commit(bn)}}),Mp=Ke((rt,vt)=>{if(o?.(rt,vt),vt.isCanceled)return;Xe(rt),(m==="none"&&kt.current&&Q||un&&!Vt.state.inputInsidePopup)&&Ro(ge(rt),Nt(vt.reason,vt.event))}),Lv=Ke((rt,vt)=>{const bn=Er(rt),rr=zt.current??rt;zt.current=null;const qr=Nt(Mb,rr),Pr=bn?.closest("a")?.getAttribute("href");if(Pr){Pr.startsWith("#")&&Hn(!1,qr);return}if(gn){const Kr=Array.isArray(ke)?ke:[],Ks=wS(Kr,vt,F),to=Ks?sV(Kr,vt,F):[...Kr,vt];if(Mp(to,qr),qr.isCanceled||!(Je.current?Je.current.value.trim()!=="":!1))return;if(Vt.state.inputInsidePopup){Ro("",Nt(mc,qr.event,void 0,{isItemPress:!0}));const Io=Tt.current;Io&&!Ks&&(Io.toggledValue=vt)}else Hn(!1,qr)}else{if(Mp(vt,qr),qr.isCanceled)return;Hn(!1,qr)}}),$v=Ke(()=>{const rt=je.inputRef.current?.form??Vt.state.inputElement?.form;rt&&typeof rt.requestSubmit=="function"&&rt.requestSubmit()}),Po=Ke(()=>{if(aa(!1),Ca?.(!1),be(!1),De(null),Oo(m==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),gn&&Je.current&&Je.current.value!==""&&!gt.current&&Ro("",Nt(mc)),un)if(Vt.state.inputInsidePopup)Je.current&&Je.current.value!==""&&Ro("",Nt(mc));else{const rt=ge(ke);Je.current&&Je.current.value!==rt&&Ro(rt,Nt(rt===""?mc:rs))}}),Pi=p.useMemo(()=>Aa&&Tp?{current:Tp.closest('[role="dialog"]')}:kt,[Aa,Tp]);ji({enabled:!e.actionsRef,open:At,ref:Pi,onComplete(){At||Po()}}),p.useImperativeHandle(e.actionsRef,()=>({unmount:Po}),[Po]),Ge(function(){const vt=Ie.current!==null&&ve===null;if(Ie.current=ve,At&&(!vt||!yn)||(At||(jt.current=null),m==="none"))return;const bn=yn?Qr:Ht.current;Oo({selectedIndex:Wb(bn,ke,F,gn)})},[At,ve,ke,m,gn,yn,Qr,F,Oo]),Ge(()=>{ye&&(Ht.current=Qr,We.current.length=Qr.length)},[ye,Qr]),Ge(()=>{const rt=Tt.current;if(rt){const Ks=At||Aa||Vt.state.positionerElement?.hidden===!1;if(rt.hasQuery)jn&&Ks&&Vt.set("activeIndex",0),Tt.current=null;else if(String(Rt).trim()===""&&(Tt.current=null,Ks)){const to=rt.selection;jn==="always"&&!to&&Vt.state.selectionMode==="none"&&Vt.set("activeIndex",0),queueMicrotask(()=>{if(!Vt.state.open&&!Vt.state.inline||Je.current&&Je.current.value.trim()!=="")return;const yl=Vt.state.selectedValue,Io=Vt.state.selectionMode==="multiple";if(Io&&Array.isArray(yl)?yl.length>0:Vt.state.selectionMode!=="none"&&yl!=null){const $a=yn||xn?Qr:Ht.current,sc=yg($a,rt.toggledValue,Vt.state.isItemEqualToValue);Vt.set("activeIndex",sc!==-1?sc:Wb($a,yl,Vt.state.isItemEqualToValue,Io))}else to?Vt.set("activeIndex",null):jn==="always"&&Vt.set("activeIndex",0)})}}if(!At&&!Aa)return;const bn=yn||xn?Qr:Ht.current,rr=Vt.state.activeIndex;if(rr==null){if(jn==="always"&&bn.length>0){Vt.set("activeIndex",0);return}Wf(void 0,-1,rs);return}if(rr>=bn.length){Wf(void 0,-1,rs),Vt.set("activeIndex",null);return}const qr=bn[rr],Pr=ht.current.value,Kr=Pr!==EV&&qo(qr,Pr,Vt.state.isItemEqualToValue);(ht.current.index!==rr||!Kr)&&Wf(qr,rr,rs)},[si,jn,Wf,xn,yn,Qr,Aa,At,Vt,Rt]),Ge(()=>{if(m==="none"){se(String(Rt)!=="");return}se(gn?Array.isArray(ke)&&ke.length>0:ke!=null)},[se,m,Rt,ke,gn]),p.useEffect(()=>{yn&&jn&&Qr.length===0&&Oo({activeIndex:null})},[yn,jn,Qr.length,Oo]);function JE(){At&&Bt!==""&&Bt!==String(Yt)&&!fd&&be(!0)}function QB(){At&&ve!==null&&ZE(!1)}let zv=!1;function N0(){!zv&&Rt!==Pn&&(zv=!0,Ro(Pn,Nt(rs)))}function ZB(){m!=="none"&&(H(Xt),G(nV(ke,Y.initialValue,F)),je.change(ke),un&&!lr&&!bi&&N0())}function Ii(){un&&!lr&&!bi&&!ue&&N0()}function C0(){m==="none"&&(H(Xt),G(Rt!==Y.initialValue),je.change(Rt))}Vo(Bt,JE),Vo(At,QB),Vo(ke,ZB),Vo(Pn,Ii),Vo(ye,Ii),Vo(Rt,C0);const _p=Z6({open:Aa?!0:At,onOpenChange:Hn,elements:{reference:bi?Op:Rp,floating:Tp}}),Bv=N?"grid":"listbox",rc=At||Aa,A0=rc?"true":"false",Dp=p.useMemo(()=>{const rt=Rp?.tagName==="INPUT",vt=Rp==null||rt,bn=vt||rc,rr=vt?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return bn&&(rr.role="combobox",rr["aria-expanded"]=A0,rr["aria-haspopup"]=Bv,rr["aria-controls"]=rc?XE?.id:void 0,rr["aria-autocomplete"]=k?"none":z),{reference:rr,floating:{role:"presentation"}}},[Rp,rc,A0,Bv,XE?.id,z,k]),pd=Bb(_p,{enabled:!an&&A,event:"mousedown-only",toggle:!1,touchOpenDelay:bi?0:100,reason:kxe}),Fv=Fb(_p,{enabled:!an&&!Aa,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:Aa?!0:void 0,outsidePress(rt){const vt=Er(rt);return!Et(Op,vt)&&!Et(qe.current,vt)&&!Et(sn.current,vt)&&!Et(Pp,vt)}}),gd=rH(_p,{enabled:!an,id:le,listRef:We,activeIndex:si,selectedIndex:Kf,virtual:!0,loopFocus:L,allowEscape:L&&!jn,focusItemOnOpen:ue||m==="none"&&!jn?!1:"auto",focusItemOnHover:_,resetOnPointerLeave:!M,orientation:N?"horizontal":void 0,rtl:te==="rtl",disabledIndices:co,grid:N?Vje:void 0,onNavigate(rt,vt){!vt&&!At||k0==="ending"||Oo(vt?{activeIndex:rt,type:Rn.current?BU:FU}:{activeIndex:rt})}}),E0=p.useMemo(()=>oo(gd.reference,{onKeyDown(rt){N&&Vt.state.activeIndex==null&&(rt.key==="ArrowLeft"||rt.key==="ArrowRight")&&rt.preventBaseUIHandler()}},Fv.reference,pd.reference,Dp.reference),[gd.reference,Fv.reference,pd.reference,Dp.reference,N,Vt]),Uv=p.useMemo(()=>oo(Ub,Fv.floating),[Fv.floating]),eT=p.useMemo(()=>oo(gd.floating,Dp.floating),[gd.floating,Dp.floating]),tT=p.useMemo(()=>{const rt=gd.item;return rt?{...rt,onFocus:void 0}:yr},[gd.item]);Vt.useContextCallback("setOpen",Hn),Vt.useContextCallback("setInputValue",Ro),Vt.useContextCallback("setSelectedValue",Mp),Vt.useContextCallback("setIndices",Oo),Vt.useContextCallback("handleSelection",Lv),Vt.useContextCallback("forceMount",md),Vt.useContextCallback("requestSubmit",$v),Vt.useContextCallback("onOpenChangeComplete",n),QH(()=>{Vt.update({inline:K,popupProps:Uv,listProps:eT,inputProps:E0,triggerProps:S0,itemProps:tT})});const Lp={id:le,selectedValue:ke,open:At,mounted:Gf,transitionStatus:k0,items:Le,inline:K,popupProps:Uv,listProps:eT,inputProps:E0,triggerProps:S0,itemProps:tT,openMethod:QE,selectionMode:m,name:Xt,form:b,disabled:an,readOnly:k,required:w,grid:N,virtualized:V,openOnInputClick:A,itemToStringLabel:xe,modal:X,autoHighlight:jn,isItemEqualToValue:F,submitOnItemClick:ee,hasInputValue:lr};Ge(()=>{Vt.update({...Lp,inputOwnsFormValue:m==="none"&&(K||!Vt.state.inputInsidePopup)})},[Vt,...Object.values(Lp)]);const bl=lo(S,je.inputRef),T0=p.useMemo(()=>({query:Bt,hasItems:yn,filteredItems:Cr,flatFilteredValues:Qr}),[Bt,yn,Cr,Qr]),O0=p.useMemo(()=>Array.isArray(eo)?"":Rl(eo,D),[eo,D]),Yf=gn&&Array.isArray(ke)&&ke.length>0,Qc=gn||m==="none"&&dd?void 0:Xt,nT=p.useMemo(()=>!gn||!Array.isArray(ke)||!Xt?null:ke.map(rt=>{const vt=Rl(rt,D);return r.jsx("input",{type:"hidden",form:b,name:Xt,value:vt,disabled:an},vt)}),[gn,ke,b,Xt,D,an]),R0=r.jsxs(p.Fragment,{children:[e.children,r.jsx("input",{...je.getValidationProps(an,{onFocus(){if(bi){Op?.focus();return}(Je.current||Op)?.focus()},onChange(rt){if(rt.nativeEvent.defaultPrevented||an||k)return;const vt=rt.currentTarget.value,bn=vt.toLowerCase(),rr=Nt(rs,rt.nativeEvent),qr=()=>Ht.current.findIndex(Kr=>Rl(Kr,D).toLowerCase()===bn||ge(Kr).toLowerCase()===bn);function Pr(){if(gn)return;if(m==="none"){Ro(vt,rr);return}let Kr=qr();Kr===-1&&(Kr=Ht.current.findIndex((to,yl)=>{const Io=nt.current[yl];return Io!=null&&Io.toLowerCase()===bn}));const Ks=Kr===-1?void 0:Ht.current[Kr];Ks!=null&&Mp?.(Ks,rr)}un&&(md(),ye&&qr()===-1&&Vt.set("forceMounted",!0)),queueMicrotask(Pr)}}),id:le&&Qc==null?`${le}-hidden-input`:void 0,form:b,name:Qc,autoComplete:q,disabled:an,required:w&&!Yf,readOnly:k,value:O0,ref:bl,style:Qc?pg:vu,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),nT]});return r.jsx(yV.Provider,{value:Vt,children:r.jsx(jV.Provider,{value:_p,children:r.jsx(kV.Provider,{value:yn,children:r.jsx(wV.Provider,{value:T0,children:r.jsx(SV.Provider,{value:Rt,children:R0})})})})})}function TV(e){const{multiple:t=!1,defaultValue:n,value:s,onValueChange:i,autoComplete:o,...l}=e;return r.jsx(Zje,{...l,selectionMode:t?"multiple":"single",selectedValue:s,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:o})}function Jje(e){const{children:t,placeholder:n}=e,s=Ko(),i=s.useState("itemToStringLabel"),o=s.useState("selectedValue"),l=s.useState("items"),u=s.useState("selectionMode")==="multiple",d=s.useState("hasSelectedValue"),f=!d&&n!=null&&t==null,m=s.useState("hasNullItemLabel",f);let g=null;return typeof t=="function"?g=t(o):t!=null?g=t:!d&&n!=null&&!m?g=n:u&&Array.isArray(o)?g=iV(o,l,i):g=fP(o,l,i),r.jsx(p.Fragment,{children:g})}const ewe="data-popup-side",twe="data-list-empty",OV={...KO,...hc,popupSide:e=>e?{[ewe]:e}:null,listEmpty:e=>e?{[twe]:""}:null},nwe=p.createContext(void 0);function rwe(){return p.useContext(nwe)}const RV=p.createContext(void 0);function gP(e){const t=p.useContext(RV);if(t===void 0&&!e)throw new Error(Vn(21));return t}const PV=p.forwardRef(function(t,n){const s=Ko(),{buttonRef:i,getButtonProps:o}=$i({native:!1}),l=lo(n,i);function u(f){s.context.setOpen(!1,Nt(dR,f.nativeEvent,f.currentTarget))}const d=o({onClick:u});return r.jsx("span",{ref:l,...d,"aria-label":"Dismiss",tabIndex:void 0,style:pg})});function IV(e){const t=e.useState("mounted"),n=e.useState("popupSide"),s=e.useState("positionerElement");return t&&s?n:null}function RS(){return Xb().filteredItems.length===0}function swe(e){return e==="rtl"?["ArrowRight","ArrowLeft"]:["ArrowLeft","ArrowRight"]}function awe(e,t){const n=e>=t-1?t-2:e;return n>=0?n:void 0}function MV(e,t,n){const s=e.context.listRef.current[t];s&&(e.context.selectionEventRef.current=n,s.click(),e.context.selectionEventRef.current=null)}const _V=p.forwardRef(function(t,n){const{render:s,className:i,disabled:o=!1,id:l,style:u,...d}=t,{state:f,disabled:m,setTouched:g,setFocused:v,validationMode:b,validation:y}=uo(),{labelId:k}=zi(),w=rwe(),N=!!gP(!0),C=Ko(),T=NV(),P=Vb(),O=C.useState("required"),A=C.useState("disabled"),R=C.useState("readOnly"),M=C.useState("name"),_=C.useState("form"),L=C.useState("selectionMode"),$=C.useState("autoHighlight"),D=C.useState("inputProps"),F=C.useState("triggerProps"),V=C.useState("open"),K=C.useState("mounted"),Q=C.useState("selectedValue"),X=C.useState("id"),U=C.useState("inline"),z=C.useState("modal"),q=!!$,J=IV(C),ee=m||A||o,H=RS(),G=N||U,Y=!G||z,se=Ws(l??(G?void 0:X)),re=N?uU:f,[ne,de]=p.useState(null),ie=p.useRef(!1),oe=p.useRef(null),je=p.useRef(!1),te=L==="none"&&!N,le=Ke(Se=>{const ge=N||C.state.inline;ge&&!C.state.hasInputValue&&C.context.setInputValue("",Nt(rs)),C.update({inputElement:Se,inputInsidePopup:ge,inputOwnsFormValue:te})}),he=N?d:y.getValidationProps(ee,d);function ce(){C.context.setIndices({activeIndex:null,selectedIndex:null,type:C.context.keyboardActiveRef.current?BU:FU})}function ye(){C.context.keyboardActiveRef.current=!1}const fe={...re,open:V,disabled:ee,readOnly:R,popupSide:J,listEmpty:H};function Le(Se){if(!w)return;let ge;const{highlightedChipIndex:ue}=w,be=w.chipsRef.current.length,[ve,De]=swe(P);return ue!==void 0?(Se.key===ve?(Se.preventDefault(),ue>0?ge=ue-1:ge=void 0):Se.key===De?(Se.preventDefault(),ue0&&(Se.preventDefault(),ge=be>0?be-1:void 0),ge)}const pe=qt("input",t,{state:fe,ref:[n,C.context.inputRef,le],props:[D,F,{value:ne??T,"aria-readonly":R||void 0,"aria-required":O||void 0,"aria-labelledby":k,disabled:ee,readOnly:R,required:L==="none"?O:void 0,form:_,...te&&M&&{name:M},id:se,onFocus(){if(v(!0),!U||!je.current)return;je.current=!1;const Se=oe.current;Se==null||!Object.hasOwn(C.context.valuesRef.current,Se)||C.context.setIndices({activeIndex:Se})},onBlur(){g(!0),v(!1);const Se=C.state.activeIndex;if(U&&Se!==null&&$!=="always"&&(oe.current=Se,je.current=!0,C.context.setIndices({activeIndex:null})),b==="onBlur"){const ge=L==="none"?T:Q;y.commit(ge)}},onCompositionStart(Se){Tk||(ie.current=!0,de(Se.currentTarget.value))},onCompositionEnd(Se){ie.current=!1;const ge=Se.currentTarget.value;de(null),C.context.setInputValue(ge,Nt(_b,Se.nativeEvent))},onChange(Se){const ge=Se.nativeEvent,ue=ge.inputType,be=!ue||ue==="insertReplacementText",ve=ie.current||!be;function De(kt){R||ee||!kt||!ve||(C.context.setOpen(!0,Nt(_b,ge)),q||ce())}if(ie.current){const kt=Se.currentTarget.value;de(kt),kt===""&&!C.state.openOnInputClick&&!C.state.inputInsidePopup&&C.context.setOpen(!1,Nt(mc,ge));const Je=kt.trim(),on=q&&Je!=="";De(Je),V&&C.state.activeIndex!==null&&!on&&ce();return}const Ie=Nt(_b,ge);if(C.context.setInputValue(Se.currentTarget.value,Ie),Ie.isCanceled)return;const We=Se.currentTarget.value==="",nt=Nt(mc,ge);We&&!C.state.inputInsidePopup&&(L==="single"&&C.context.setSelectedValue(null,nt),C.state.openOnInputClick||C.context.setOpen(!1,nt)),De(Se.currentTarget.value.trim()),V&&C.state.activeIndex!==null&&!q&&ce()},onKeyDown(Se){if(Se.ctrlKey||Se.shiftKey||Se.altKey||Se.metaKey)return;if(C.context.keyboardActiveRef.current=!0,ee||R){R&&Se.key==="Enter"&&V&&C.state.activeIndex!==null&&da(Se);return}const ge=Se.currentTarget,ue=ge.scrollWidth-ge.clientWidth,be=P==="rtl";if(Se.key==="Home"){da(Se);const Ie=vU&&be?ge.value.length:0;ge.setSelectionRange(Ie,Ie),ge.scrollLeft=0;return}if(Se.key==="End"){da(Se);const Ie=vU&&be?0:ge.value.length;ge.setSelectionRange(Ie,Ie),ge.scrollLeft=be?-ue:ue;return}if(!K&&Se.key==="Escape"){const Ie=L==="multiple"&&Array.isArray(Q)?Q.length===0:Q===null,We=Nt(mg,Se.nativeEvent),nt=L==="multiple"?[]:null;C.context.setInputValue("",We),C.context.setSelectedValue(nt,We),!Ie&&!C.state.inline&&!We.isPropagationAllowed&&Se.stopPropagation();return}if(w&&Se.key==="Backspace"&&ge.value===""&&w.highlightedChipIndex===void 0&&Array.isArray(Q)&&Q.length>0){const Ie=w.chipsRef.current.length,We=Ie>0?Ie-1:Q.length-1,nt=Q.filter((kt,Je)=>Je!==We);ce(),C.context.setSelectedValue(nt,Nt(rs,Se.nativeEvent));return}const ve=w?.highlightedChipIndex!==void 0,De=Le(Se);if(w?.setHighlightedChipIndex(De),De!==void 0?w?.chipsRef.current[De]?.focus():ve&&C.context.inputRef.current?.focus(),Se.which!==229&&Se.key==="Enter"&&V){const Ie=C.state.activeIndex,We=Se.nativeEvent;if(Ie===null){if(U)return;C.context.setOpen(!1,Nt(rs,We));return}da(Se),MV(C,Ie,We)}},onPointerMove:ye,onPointerDown:ye},he],stateAttributesMapping:OV}),xe=N?r.jsx(zO.Provider,{value:dU,children:pe}):pe;return r.jsxs(p.Fragment,{children:[V&&Y&&r.jsx(PV,{ref:C.context.startDismissRef}),xe]})}),DV=p.forwardRef(function(t,n){const{render:s,className:i,nativeButton:o=!0,disabled:l=!1,id:u,style:d,...f}=t,{state:m,disabled:g,setTouched:v,setFocused:b,validationMode:y,validation:k}=uo(),{labelId:w}=zi(),S=Ko(),N=S.useState("selectionMode"),C=S.useState("disabled"),T=S.useState("readOnly"),P=S.useState("required"),O=S.useState("positionerElement"),A=S.useState("listElement"),R=S.useState("popupId"),M=S.useState("triggerProps"),_=S.useState("inputInsidePopup"),L=S.useState("id"),$=S.useState("labelId"),D=S.useState("open"),F=S.useState("selectedValue"),V=S.useState("activeIndex"),K=S.useState("selectedIndex"),Q=S.useState("hasSelectedValue"),X=OS(),U=NV(),z=fa(),q=g||C||l,J=RS(),ee=IV(S);_d({id:_?u:void 0});const H=_?u??L:u,G=lV(w,$);let Y;D&&_?Y=R??CV(L):D&&(Y=A?.id);const se=p.useRef("");function re(he){se.current=he.pointerType}const{reference:ne}=sH(X,{enabled:!D&&!T&&!C&&N==="single",listRef:S.context.labelsRef,activeIndex:V,selectedIndex:K,onMatch(he){const ce=S.context.valuesRef.current[he];ce!==void 0&&S.context.setSelectedValue(ce,Nt(rs))}}),{reference:de}=Bb(X,{enabled:!C,event:"mousedown"}),{buttonRef:ie,getButtonProps:oe}=$i({native:o,disabled:q}),je={...m,readOnly:T,open:D,disabled:q,popupSide:ee,listEmpty:J,placeholder:N==="none"?!1:!Q},te=Ke(he=>{S.set("triggerElement",he)});return qt("button",t,{ref:[n,ie,te],state:je,props:[M,de,ne,{id:H,tabIndex:_?0:-1,role:_?"combobox":void 0,"aria-expanded":D,"aria-haspopup":_?"dialog":"listbox","aria-controls":Y,"aria-required":_&&P||void 0,"aria-readonly":_&&T||void 0,"aria-labelledby":G,onPointerDown:re,onPointerEnter:re,onFocus(){b(!0),!q&&z.start(0,S.context.forceMount)},onBlur(he){if(!Et(O,he.relatedTarget)&&(v(!0),b(!1),y==="onBlur")){const ce=N==="none"?U:F;k.commit(ce)}},onMouseDown(he){if(q||(_||X.set("domReferenceElement",he.currentTarget),S.context.forceMount(),se.current!=="touch"&&(S.context.inputRef.current?.focus(),_||he.preventDefault()),D))return;const ce=_n(he.currentTarget);function ye(fe){const Le=S.state.triggerElement;if(!Le)return;const pe=Er(fe),xe=S.state.positionerElement,Se=S.state.listElement;Et(Le,pe)||Et(xe,pe)||Et(Se,pe)||cV(fe,Le)||S.context.setOpen(!1,Nt(UU,fe))}_&&ce.addEventListener("mouseup",ye,{once:!0})},onKeyDown(he){(he.key==="ArrowDown"||he.key==="ArrowUp")&&(da(he),S.context.setOpen(!0,Nt(fR,he.nativeEvent)),S.context.inputRef.current?.focus())}},k.getValidationProps(q,f),oe],stateAttributesMapping:OV})}),iwe=p.createContext(null);function owe(){return p.useContext(iwe)}function lwe(e){const{children:t}=e,{filteredItems:n}=Xb(),s=owe(),i=s?s.items:n;return r.jsx(p.Fragment,{children:i.map(t)})}const LV=p.forwardRef(function(t,n){var s;const{render:i,className:o,style:l,children:u,...d}=t,f=Ko(),m=OS(),g=!!gP(!0),{filteredItems:v,hasItems:b}=Xb(),y=f.useState("selectionMode"),k=f.useState("grid"),w=f.useState("readOnly"),S=f.useState("listProps"),N=f.useState("virtualized"),C=f.useState("forceMounted"),T=y==="multiple",P=v.length===0,O=Ke(D=>{f.set("positionerElement",D)}),A=Ke(D=>{f.set("listElement",D)}),R=p.useMemo(()=>typeof u=="function"?s||(s=r.jsx(lwe,{children:u})):u,[u]),M={empty:P},_=m.useState("floatingId"),L=qt("div",t,{state:M,ref:[n,A,g?null:O],props:[S,{children:R,tabIndex:-1,id:_,role:k?"grid":"listbox","aria-multiselectable":T?"true":void 0,"aria-readonly":!k&&w?!0:void 0,onKeyDown(D){if(!(f.state.disabled||f.state.readOnly)&&D.key==="Enter"){const F=f.state.activeIndex;if(F==null)return;da(D),MV(f,F,D.nativeEvent)}},onKeyDownCapture(){f.context.keyboardActiveRef.current=!0},onPointerMoveCapture(){f.context.keyboardActiveRef.current=!1}},d]});if(N)return L;const $=b&&!C?void 0:f.context.labelsRef;return r.jsx(cP,{elementsRef:f.context.listRef,labelsRef:$,children:L})}),cwe="⁠",uwe=200;function dwe(e){const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let n=null;for(;t.nextNode();){const s=t.currentNode;s.nodeValue!==""&&(n=s)}return n}function fwe(){const e=fa(),t=p.useRef(null);return p.useEffect(()=>{if(Ob)return;const n=t.current;if(n==null)return;const s=dwe(n);if(s==null)return;const i=s.data,o=`${i}${cwe}`;return s.nodeValue=o,e.start(uwe,()=>{s.nodeValue===o&&(s.nodeValue=i)}),()=>{e.clear(),s.nodeValue===o&&(s.nodeValue=i)}},[t,e]),t}const $V=p.createContext(void 0);function hwe(){const e=p.useContext($V);if(e===void 0)throw new Error(Vn(20));return e}const zV=p.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,o=Ko(),l=o.useState("mounted"),u=o.useState("forceMounted");return l||s||u?r.jsx($V.Provider,{value:s,children:r.jsx(eS,{ref:n,...i})}):null}),BV=p.forwardRef(function(t,n){const{render:s,className:i,anchor:o,positionMethod:l,side:u,align:d,sideOffset:f,alignOffset:m,collisionBoundary:g="clipping-ancestors",collisionPadding:v,arrowPadding:b,sticky:y,disableAnchorTracking:k=!1,collisionAvoidance:w=h6,style:S,...N}=t,C=Ko(),T=OS(),P=hwe(),O=C.useState("modal"),A=C.useState("open"),R=C.useState("mounted"),M=C.useState("openMethod"),_=C.useState("positionerElement"),L=C.useState("triggerElement"),$=C.useState("inputElement"),D=C.useState("inputGroupElement"),F=C.useState("inputInsidePopup"),V=C.useState("transitionStatus"),K=RS(),X=hS({anchor:o??(F?L:D??$),floatingRootContext:T,positionMethod:l,mounted:R,side:u,sideOffset:f,align:d,alignOffset:m,arrowPadding:b,collisionBoundary:g,collisionPadding:v,sticky:y,disableAnchorTracking:k,keepMounted:P,collisionAvoidance:w,lazyFlip:!0});hP(A&&O,M==="touch",_,L);const U={open:A,side:X.side,align:X.align,anchorHidden:X.anchorHidden,empty:K};Ge(()=>{C.set("popupSide",X.side)},[C,X.side]);const z=Ke(J=>{C.set("positionerElement",J)}),q=mS(t,U,{styles:X.positionerStyles,transitionStatus:V,props:N,refs:[n,z],hidden:!R,inert:!A});return r.jsxs(RV.Provider,{value:X,children:[R&&O&&r.jsx(vS,{inert:Kb(!A),cutout:D??$??L}),q]})}),mwe={...cg,...Fo},FV=p.forwardRef(function(t,n){const{render:s,className:i,style:o,initialFocus:l,finalFocus:u,...d}=t,f=Ko(),m=gP(),g=OS(),v=f.useState("mounted"),b=f.useState("open"),y=f.useState("openMethod"),k=f.useState("popupProps"),w=f.useState("transitionStatus"),S=f.useState("inputInsidePopup"),N=f.useState("inputElement"),C=f.useState("modal"),T=f.useState("id"),P=RS(),O=d.id??(S?CV(T):void 0);Ge(()=>(f.set("popupId",f.context.popupRef.current?.id||O),()=>{f.set("popupId",void 0)}),[f,O]),ji({open:b,ref:f.context.popupRef,onComplete(){b&&f.context.onOpenChangeComplete(!0)}});const A={open:b,side:m.side,align:m.align,anchorHidden:m.anchorHidden,transitionStatus:w,empty:P},R=qt("div",t,{state:A,ref:[n,f.context.popupRef],props:[k,{id:O,role:S?"dialog":"presentation",onFocus(D){const F=Er(D.nativeEvent);y!=="touch"&&(Et(f.state.listElement,F)||F===D.currentTarget)&&f.context.inputRef.current?.focus()}},qb(w),d],stateAttributesMapping:mwe}),_=l===void 0?S?D=>D==="touch"?f.context.popupRef.current:N:!1:l;let L;u!=null?L=u:L=S?void 0:!1;const $=!S||C;return r.jsx(tS,{context:g,disabled:!v,modal:$,openInteractionType:y,initialFocus:_,returnFocus:L,getInsideElements:()=>[f.context.startDismissRef.current,f.context.endDismissRef.current],children:r.jsxs(p.Fragment,{children:[R,$&&r.jsx(PV,{ref:f.context.endDismissRef})]})})}),UV=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t;return qt("span",t,{ref:n,props:[{"aria-hidden":!0,children:"▼"},l]})}),HV=p.createContext(void 0);function VV(){const e=p.useContext(HV);if(!e)throw new Error(Vn(19));return e}const pwe=p.createContext(!1);function gwe(){return p.useContext(pwe)}function qV(e){const{componentProps:t,forwardedRef:n,virtualized:s,indexFromFilter:i}=e,{render:o,className:l,style:u,value:d=null,index:f,disabled:m=!1,nativeButton:g=!1,...v}=t,b=p.useRef(null),y=lP({guess:!0,index:f,textRef:b}),k=Ko(),w=gwe(),S=qje(),N=k.useState("selectionMode"),C=k.useState("disabled"),T=k.useState("readOnly"),P=k.useState("isItemEqualToValue"),O=C||m,A=N!=="none",R=f??i??y.index,M=R!==-1,_=k.useState("id"),L=k.useState("isActive",R),$=k.useState("isSelected",d),D=k.useState("itemProps"),F=p.useRef(null),V=_!=null&&M?`${_}-${R}`:void 0,K=$&&A;Ge(()=>{if(!(M&&(s||f!=null)))return;const G=k.context.listRef.current;return G[R]=F.current,()=>{delete G[R]}},[M,s,R,f,k]),Ge(()=>{if(!M||S)return;const H=k.context.valuesRef.current;return H[R]=d,()=>{delete H[R]}},[M,S,R,d,k]),Ge(()=>{if(!M||S)return;const H=k.state.selectedValue;let G=k.state.selectedIndex;k.state.selectionMode==="multiple"&&Array.isArray(H)?G=rV(R,d,k.context.valuesRef.current,H,P,G):qo(d,H,P)&&(G=R),k.set("selectedIndex",G)},[M,S,k,R,d,P]);const{getButtonProps:Q,buttonRef:X}=$i({disabled:O,focusableWhenDisabled:!0,native:g,composite:!0}),U={disabled:O,selected:K,highlighted:L};function z(H){function G(){k.context.handleSelection(H,d)}k.state.submitOnItemClick?(xr.flushSync(G),k.context.requestSubmit()):G()}const q={id:V,role:w?"gridcell":"option","aria-selected":A?K:void 0,tabIndex:void 0,onPointerDownCapture(H){H.isPrimary&&(k.context.pointerDownItemRef.current=H.currentTarget),H.preventDefault()},onMouseDown(H){H.preventDefault()},onClick(H){O||T||z(H.nativeEvent)},onMouseUp(H){const G=k.context.pointerDownItemRef.current===H.currentTarget;k.context.pointerDownItemRef.current=null,!(O||T||H.button!==0||G||!L)&&z(H.nativeEvent)}},J=qt("div",t,{ref:[X,n,y.ref,F],state:U,props:[D,q,v,Q]}),ee=p.useMemo(()=>({selected:K,textRef:b}),[K,b]);return r.jsx(HV.Provider,{value:ee,children:J})}function xwe(e){const{componentProps:t,forwardedRef:n}=e,i=Ko().useState("isItemEqualToValue"),{flatFilteredValues:o}=Xb(),l=t.value??null,u=yg(o,l,i);return r.jsx(qV,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:u})}const KV=p.memo(p.forwardRef(function(t,n){const i=Ko().useState("virtualized");return i&&t.index==null?r.jsx(xwe,{componentProps:t,forwardedRef:n}):r.jsx(qV,{componentProps:t,forwardedRef:n,virtualized:i,indexFromFilter:void 0})})),GV=p.forwardRef(function(t,n){const{selected:s}=VV();return t.keepMounted||s?r.jsx(vwe,{...t,ref:n}):null}),vwe=p.memo(p.forwardRef((e,t)=>{const{render:n,className:s,style:i,keepMounted:o,...l}=e,{selected:u}=VV(),d=p.useRef(null),{transitionStatus:f,setMounted:m}=gu(u),v=qt("span",e,{ref:[t,d],state:{selected:u,transitionStatus:f},props:[{"aria-hidden":!0,children:"✔️"},l],stateAttributesMapping:Fo});return ji({batch:!0,enabled:!u,open:u,ref:d,onComplete(){u||m(!1)}}),v})),WV=p.forwardRef(function(t,n){const{render:s,className:i,style:o,children:l,...u}=t,{filteredItems:d}=Xb(),f=Ko(),m=fwe(),g=d.length===0?l:null;return qt("div",t,{ref:[n,f.context.emptyRef,m],props:[{children:g,role:"status","aria-live":"polite","aria-atomic":!0},u]})}),PS=p.createContext(null);function YV({open:e,defaultOpen:t=!1,onOpenChange:n,children:s,...i}){const[o,l]=p.useState(t),[u,d]=p.useState(null),[f,m]=p.useState(!1),g=e??o;p.useLayoutEffect(()=>{g&&m(!1)},[g]);const v=p.useCallback((k,w)=>{n?.(k,w),!w.isCanceled&&(k&&m(!1),l(k))},[n]),b=p.useCallback(()=>{if(!g||f)return;const k=Nt("none",void 0,u??void 0);v(!1,k),k.isCanceled||m(!0)},[g,f,u,v]),y=p.useMemo(()=>({open:g,trigger:u,setTrigger:d,closeOnAnchorHidden:b,closedOnAnchorHidden:f}),[g,u,b,f]);return r.jsx(PS.Provider,{value:y,children:r.jsx(TV,{...i,open:g,onOpenChange:v,children:s})})}function bwe({anchorHidden:e,open:t,...n}){const i=p.useContext(PS)?.closeOnAnchorHidden;return p.useLayoutEffect(()=>{t&&e&&i?.()},[t,e,i]),r.jsx("div",{...n})}const XV=Jje;function QV({className:e,children:t,ref:n,...s}){const i=p.useContext(PS);return Ah({render:r.jsx(DV,{}),ref:[n??null,i?.setTrigger??null],props:{...s,"data-slot":"combobox-trigger",className:Ne("inline-flex h-[30px] min-w-0 cursor-pointer items-center justify-between gap-1.5 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] font-normal text-foreground max-[767px]:h-10 max-[767px]:text-base","transition-colors duration-150 ease-out","hover:border-control-border-hover hover:bg-control-hover","focus-visible:border-primary focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:bg-control data-disabled:text-muted-foreground data-disabled:opacity-60",e),children:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t}),r.jsx(UV,{className:"flex flex-none text-muted-foreground transition-transform duration-[180ms] data-popup-open:rotate-180",children:r.jsx("svg",{viewBox:"0 0 10 6",className:"size-2.5","aria-hidden":"true",children:r.jsx("path",{d:"M1 1l4 4 4-4",stroke:"currentColor",strokeWidth:"1.4",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}})}function ZV({className:e,sideOffset:t=4,children:n,finalFocus:s,...i}){const o=p.useContext(PS),l=bV(o?.trigger??null,o?.open??!1);return r.jsx(zV,{children:r.jsx(BV,{sideOffset:t,align:"start",collisionBoundary:l,className:"z-[35] data-anchor-hidden:invisible data-anchor-hidden:pointer-events-none",render:(u,d)=>r.jsx(bwe,{...u,anchorHidden:d.anchorHidden,open:d.open}),children:r.jsx(FV,{"data-slot":"combobox-content",className:Ne("flex max-h-[min(300px,var(--available-height))] w-[max(var(--anchor-width),220px)] max-w-[var(--available-width)] flex-col overflow-hidden","rounded-lg border border-border-strong bg-raised shadow-3 outline-none","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0",e),finalFocus:o?.closedOnAnchorHidden?!1:s,...i,children:n})})})}function JV({className:e,...t}){return r.jsx(_V,{"data-slot":"combobox-input",className:Ne("h-[30px] w-full min-w-0 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] text-foreground outline-none max-[767px]:h-10 max-[767px]:text-base","transition-[border-color,box-shadow] duration-150 ease-out placeholder:text-muted-foreground","hover:border-control-border-hover focus:border-primary focus:shadow-focus","disabled:pointer-events-none disabled:cursor-not-allowed disabled:text-muted-foreground",e),...t})}function eq({className:e,...t}){return r.jsx(LV,{"data-slot":"combobox-list",className:Ne("min-h-0 flex-1 overflow-y-auto overscroll-contain p-[5px]",e),...t})}function tq({className:e,children:t,...n}){return r.jsxs(KV,{"data-slot":"combobox-item",className:Ne("flex min-h-7 cursor-pointer items-center gap-2 rounded-sm px-[9px] py-[5px] text-[12.5px] leading-[1.4] text-foreground select-none outline-none","max-[767px]:min-h-10 max-[767px]:text-sm transition-colors duration-[120ms] ease-out","data-[highlighted]:bg-nav-hover","data-[selected]:bg-primary-soft data-[selected]:font-semibold data-[selected]:text-primary-fg","data-[highlighted]:data-[selected]:bg-primary-tint","data-disabled:pointer-events-none data-disabled:font-normal data-disabled:text-muted-foreground",e),...n,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),r.jsx(GV,{className:"flex flex-none text-primary",children:r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}function nq({className:e,children:t,...n}){return r.jsx(WV,{"data-slot":"combobox-empty",...n,children:r.jsx("div",{className:Ne("px-2.5 py-3 text-[11.5px] leading-[1.5] text-muted-foreground",e),children:t})})}const ywe={left:0,top:0,width:0,height:0,ready:!1};function rq(e,t){const n=p.useRef(null),[s,i]=p.useState(ywe),[o,l]=p.useState(!1),u=p.useRef(!1),d=p.useRef(null),f=p.useCallback(()=>{const g=n.current,v=g?.querySelector(t);if(!g||!v||!g.offsetWidth||!g.offsetHeight||!v.getClientRects().length){u.current=!1,l(!1),i(N=>N.ready?{...N,ready:!1}:N);return}const b=g.getBoundingClientRect(),y=v.getBoundingClientRect();if(!b.width||!b.height||!y.width||!y.height)return;const k=b.width/g.offsetWidth,w=b.height/g.offsetHeight,S={left:(y.left-b.left)/k-g.clientLeft+g.scrollLeft,top:(y.top-b.top)/w-g.clientTop+g.scrollTop,width:y.width/k,height:y.height/w,ready:!0};u.current=!0,i(N=>N.ready&&Math.abs(N.left-S.left)<.1&&Math.abs(N.top-S.top)<.1&&Math.abs(N.width-S.width)<.1&&Math.abs(N.height-S.height)<.1?N:S)},[t]),m=p.useCallback(()=>{if(!u.current){f();return}d.current===null&&(d.current=requestAnimationFrame(()=>{d.current=null,f()}))},[f]);return p.useLayoutEffect(()=>{m()}),p.useLayoutEffect(()=>{const g=n.current;if(!g)return;const v=typeof ResizeObserver>"u"?null:new ResizeObserver(m),b=()=>{v?.disconnect(),v?.observe(g),g.querySelectorAll(e).forEach(k=>v?.observe(k))};b();const y=new MutationObserver(k=>{const w=k.filter(S=>!(S.target instanceof Element&&S.target.hasAttribute("data-selection-indicator")));w.length&&(w.some(S=>S.type==="childList")&&b(),m())});return y.observe(g,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["data-active","data-checked","class","hidden","style"]}),window.addEventListener("resize",m),document.fonts?.addEventListener("loadingdone",m),()=>{v?.disconnect(),y.disconnect(),d.current!==null&&cancelAnimationFrame(d.current),d.current=null,window.removeEventListener("resize",m),document.fonts?.removeEventListener("loadingdone",m)}},[e,m]),p.useEffect(()=>{if(!s.ready||o)return;let g=0;const v=requestAnimationFrame(()=>{g=requestAnimationFrame(()=>{u.current&&l(!0)})});return()=>{cancelAnimationFrame(v),cancelAnimationFrame(g)}},[s.ready,o]),{containerRef:n,indicator:{"data-selection-indicator":"","data-ready":s.ready?"true":"false","data-animate":o?"true":"false",style:{transform:`translate3d(${s.left}px, ${s.top}px, 0)`,width:s.width,height:s.height}}}}function en({options:e,value:t,onValueChange:n,disabled:s=!1,className:i,...o}){const{containerRef:l,indicator:u}=rq('[data-slot="segmented-item"]','[data-slot="segmented-item"][data-checked]');return r.jsxs(XH,{ref:l,"data-slot":"segmented-control",className:Ne("relative inline-flex gap-0.5 rounded-md border border-hairline bg-control p-0.5 shadow-none",i),value:t,disabled:s,onValueChange:d=>n(d),...o,children:[r.jsx("span",{"aria-hidden":"true","data-slot":"segmented-thumb",...u}),e.map(d=>r.jsxs(GH,{value:d.value,"data-slot":"segmented-item",title:d.title,disabled:d.disabled,"data-zero":d.count===0?"true":void 0,className:Ne("group/seg relative z-[1] inline-flex h-6 items-center gap-[5px] rounded-sm border-0 bg-transparent px-2.5","text-xs font-normal whitespace-nowrap text-subtle select-none","transition-[background-color,color] duration-150 ease-out","hover:bg-nav-hover hover:text-foreground focus-visible:outline-none focus-visible:shadow-focus","data-checked:bg-transparent data-checked:text-foreground data-checked:hover:bg-transparent","data-disabled:cursor-not-allowed data-disabled:opacity-40","data-[zero=true]:data-unchecked:opacity-45"),children:[d.label,d.count!==void 0&&r.jsx("span",{className:Ne("min-w-4 rounded-pill bg-surface-3 px-[5px] text-center text-[10.5px] font-semibold tabular-nums text-muted-foreground","group-data-checked/seg:bg-surface-2 group-data-checked/seg:text-foreground"),children:d.count})]},d.value))]})}const jwe=p.createContext(void 0);function wwe(){return p.useContext(jwe)}const kwe=p.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:o=!1,form:l,onPressedChange:u,pressed:d,render:f,type:m,value:g,nativeButton:v=!0,style:b,...y}=t,k=Ws(g||void 0),w=wwe(),S=w?.value??[],N=(o||w?.disabled)??!1,[C,T]=Tl({controlled:w?k!==void 0&&S.indexOf(k)>-1:d,default:i,name:"Toggle",state:"pressed"}),{getButtonProps:P,buttonRef:O}=$i({disabled:N,native:v}),A={disabled:N,pressed:C},R=[O,n],M=[{"aria-pressed":C,onClick($){const D=!C,F=Nt(rs,$.nativeEvent);u?.(D,F),!F.isCanceled&&(k&&w?.setGroupValue?.(k,D,F),!F.isCanceled&&T(D))}},y,P],_=qt("button",t,{enabled:!w,state:A,ref:R,props:M}),L=p.useMemo(()=>({disabled:N,focusableWhenDisabled:!1}),[N]);return w?r.jsx(VH,{tag:"button",render:f,className:s,style:b,metadata:L,state:A,refs:R,props:M}):_}),Swe=jh(["inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border","font-medium transition-[background-color,border-color,color] duration-150 ease-out","outline-none select-none disabled:pointer-events-none disabled:opacity-45","[&_svg]:pointer-events-none [&_svg]:shrink-0","data-pressed:border-primary-bd data-pressed:bg-primary-soft data-pressed:font-semibold data-pressed:text-primary-fg","data-pressed:hover:bg-primary-tint"],{variants:{variant:{default:"border-transparent bg-transparent text-subtle hover:bg-nav-hover hover:text-foreground",outline:"border-control-border bg-control text-foreground shadow-1 hover:border-control-border-hover hover:bg-control-hover"},size:{default:"h-[30px] rounded-md px-3 text-[12.5px]",xs:"h-6 rounded-sm px-2 text-[11.5px]",sm:"h-[26px] rounded-sm px-2.5 text-[12px]",lg:"h-9 rounded-md px-4 text-[13px]"}},defaultVariants:{variant:"default",size:"default"}});function Nwe({className:e,variant:t,size:n,...s}){return r.jsx(kwe,{"data-slot":"toggle",className:Ne(Swe({variant:t,size:n}),e),...s})}const Cwe="、";function xc({value:e,onValueChange:t,options:n,placeholder:s="",emptyHint:i=Z("没有匹配的选项"),searchPlaceholder:o=Z("搜索…"),disabled:l=!1,className:u,id:d,title:f,...m}){const g=p.useMemo(()=>n.filter(b=>e.includes(b.value)),[n,e]),v=g.length?g.map(b=>b.label).join(Cwe):s;return r.jsxs(TV,{items:n,multiple:!0,value:g,onValueChange:b=>t(b.map(y=>y.value)),isItemEqualToValue:(b,y)=>b?.value===y?.value,disabled:l,children:[r.jsxs(DV,{"data-slot":"multi-select-trigger",id:d,title:f,"aria-label":m["aria-label"],className:Ne("inline-flex h-[30px] min-w-0 cursor-pointer items-center justify-between gap-1.5 rounded-md border border-control-border bg-control px-2.5","text-[12.5px] font-normal text-foreground","transition-colors duration-150 ease-out","hover:border-control-border-hover hover:bg-control-hover","focus-visible:border-primary focus-visible:shadow-focus focus-visible:outline-none","data-disabled:cursor-not-allowed data-disabled:bg-control data-disabled:text-muted-foreground data-disabled:opacity-60",u),children:[r.jsx("span",{"data-slot":"multi-select-value",className:"min-w-0 flex-1 truncate text-left data-[placeholder]:text-muted-foreground","data-placeholder":g.length?void 0:"",title:v,children:v}),r.jsx(UV,{className:"flex flex-none text-muted-foreground transition-transform duration-[180ms] data-popup-open:rotate-180",children:r.jsx("svg",{viewBox:"0 0 10 6",className:"size-2.5","aria-hidden":"true",children:r.jsx("path",{d:"M1 1l4 4 4-4",stroke:"currentColor",strokeWidth:"1.4",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),r.jsx(zV,{children:r.jsx(BV,{sideOffset:4,className:"z-[35]",children:r.jsxs(FV,{"data-slot":"multi-select-content",className:Ne("flex max-h-[280px] w-[max(var(--anchor-width),220px)] flex-col overflow-hidden","rounded-lg border border-border-strong bg-raised shadow-3 outline-none","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0"),children:[r.jsxs("div",{className:"flex flex-none items-center gap-1.5 border-b border-hairline px-2.5 py-1.5",children:[r.jsxs("svg",{viewBox:"0 0 12 12",className:"size-3 flex-none text-muted-foreground","aria-hidden":"true",children:[r.jsx("circle",{cx:"5",cy:"5",r:"3.4",stroke:"currentColor",strokeWidth:"1.3",fill:"none"}),r.jsx("path",{d:"M7.6 7.6 10.5 10.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),r.jsx(_V,{placeholder:o,className:"min-w-0 flex-1 border-0 bg-transparent p-0 text-[12.5px] text-foreground outline-none placeholder:text-muted-foreground"})]}),r.jsx(WV,{children:r.jsx("div",{className:"px-2.5 py-3 text-[11.5px] leading-[1.5] text-muted-foreground",children:i})}),r.jsx(LV,{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-[5px]",children:b=>r.jsxs(KV,{value:b,disabled:b.disabled===!0,className:Ne("grid cursor-pointer grid-cols-[14px_minmax(0,1fr)] items-center gap-2 rounded-sm px-[9px] py-[5px]","text-[12.5px] leading-[1.4] text-foreground select-none outline-none","transition-colors duration-[120ms] ease-out","data-[highlighted]:bg-nav-hover","data-[selected]:bg-primary-soft data-[selected]:font-semibold data-[selected]:text-primary-fg","data-[highlighted]:data-[selected]:bg-primary-tint","data-disabled:pointer-events-none data-disabled:text-muted-foreground"),children:[r.jsx(GV,{className:"col-start-1 flex text-primary",children:r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",stroke:"currentColor",strokeWidth:"1.8",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("span",{className:"col-start-2 min-w-0 truncate",children:b.label})]},b.value)})]})})})]})}const sq=p.createContext(void 0);function _h(e){const t=p.useContext(sq);if(t===void 0&&!e)throw new Error(Vn(47));return t}const Awe={...HR,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class Ewe extends Ph{constructor(n,s,i){const o=new aS;super(Twe(n,o,s,i),Owe(o),Awe);Cn(this,"setOpen",(n,s)=>{const i=s.reason===Va,o=s.reason===xu&&s.event.detail===0,l=!n&&(s.reason===mg||s.reason==null),u=W6(s),d=this.select("activeTriggerId");if(!n&&s.reason===dR&&s.trigger==null&&d!=null&&(s.trigger=this.context.triggerElements.getById(d)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(n,s),s.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(n,s);const f=()=>{const g=DR(this.state,n,s.trigger,u());g.openChangeReason=s.reason,this.update(g)};i?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(xve,()=>{this.set("stickIfOpen",!1)}),xr.flushSync(f)):f();let m;o?m="click":l?m="dismiss":s.reason===Fd&&(m="focus"),this.set("instantType",m)})}}function Twe(e,t,n,s=!1){const i={...FR(t,n,s),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function Owe(e){return{popupRef:p.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:p.createRef(),beforeContentFocusGuardRef:p.createRef(),stickIfOpenTimeout:new Bi,triggerElements:e}}const aq=Qk(function({props:t}){const{children:n,open:s,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:l,modal:u=!1,handle:d,triggerId:f,defaultTriggerId:m=null}=t,g=Pwe(d,{modal:u,open:i,openProp:s,activeTriggerId:m,triggerIdProp:f});g.useControlledProp("openProp",s),g.useControlledProp("triggerIdProp",f);const v=g.useState("open"),b=g.useState("mounted"),y=g.useState("payload");g.useContextCallback("onOpenChange",o),g.useContextCallback("onOpenChangeComplete",l),Y6(g,v),$R(g);const{forceUnmount:k}=zR(v,g,()=>{g.update({stickIfOpen:!0,openChangeReason:null})});g.useSyncedValues({modal:u}),p.useEffect(()=>{v||g.context.stickIfOpenTimeout.clear()},[g,v]),p.useImperativeHandle(t.actionsRef,()=>({unmount:k,close:()=>g.setOpen(!1,Nt(hR))}),[k,g]);const w=v||b;return r.jsxs(sq.Provider,{value:g,children:[d&&r.jsx(_R,{handle:d,store:g}),w&&r.jsx(Iwe,{store:g,modal:u}),typeof n=="function"?n({payload:y}):n]})});function Rwe(e){return _h(!0)?r.jsx(aq,{props:e}):r.jsx(Eve,{children:r.jsx(aq,{props:e})})}function Pwe(e,t){const n=MR((s,i)=>new Ewe(t,s,i));return p.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function Iwe({store:e,modal:t}){const n=e.useState("floatingRootContext"),s=Fb(n,{outsidePressEvent:{mouse:t==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),i=s.reference,o=s.floating;return BR(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:o}),null}const Mwe=300;function _we(e,t){const n=p.useRef(null);function s(o){xr.flushSync(()=>{e.setOpen(!1,Nt(Fd,o.nativeEvent,o.currentTarget))}),cxe(n.current)?.focus()}function i(o){const l=e.select("positionerElement");if(l&&dg(o,l))e.context.beforeContentFocusGuardRef.current?.focus();else{xr.flushSync(()=>{e.setOpen(!1,Nt(Fd,o.nativeEvent,o.currentTarget))});let u=lxe(e.context.triggerFocusTargetRef.current||t.current);for(;u!==null&&Et(l,u);){const d=u;if(u=iR(u),u===d)break}u?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:s,handleFocusTargetFocus:i}}const Dwe=bR(function(t,n){const{render:s,className:i,style:o,disabled:l=!1,nativeButton:u=!0,handle:d,payload:f,openOnHover:m=!1,delay:g=Mwe,closeDelay:v=0,id:b,...y}=t,k=_h(!0),S=VR(d)??k;if(!S)throw new Error(Vn(74));const N=Ws(b),C=S.useState("isTriggerActive",N),T=S.useState("floatingRootContext"),P=S.useState("isOpenedByTrigger",N),O=S.useState("triggerPopupId",N),A=p.useRef(null),{registerTrigger:R,isMountedByThisTrigger:M}=LR(N,A,S,{payload:f,disabled:l,openOnHover:m,closeDelay:v}),_=S.useState("openChangeReason"),L=S.useState("stickIfOpen"),$=S.useState("openMethod"),D=S.useState("focusManagerModal"),F=tH(T,{enabled:!l&&m&&($!=="touch"||_!==xu),mouseOnly:!0,move:!1,handleClose:iH(),restMs:g,delay:{close:v},triggerElementRef:A,isActiveTrigger:C,isClosing:()=>S.select("transitionStatus")==="ending"}),V=Bb(T,{stickIfOpen:L}),K=aP(()=>S.select("open"),se=>{S.set("openMethod",se)}),Q=S.useState("triggerProps",M),{getButtonProps:X,buttonRef:U}=$i({disabled:l,native:u}),z={open(se){return se&&_===xu?KO.open(se):Rk.open(se)}},{preFocusGuardRef:q,handlePreFocusGuardFocus:J,handleFocusTargetFocus:ee}=_we(S,A),G=qt("button",t,{state:{disabled:l,open:P},ref:[U,n,R,A],props:[V.reference,F,Q,K,{[kR]:"",id:N,"aria-haspopup":"dialog","aria-expanded":P,"aria-controls":O},y,X],stateAttributesMapping:z}),Y=r.jsx(p.Fragment,{children:G},N);return M&&!D?r.jsxs(p.Fragment,{children:[r.jsx(Th,{ref:q,onFocus:J}),Y,r.jsx(Th,{ref:S.context.triggerFocusTargetRef,onFocus:ee})]}):Y}),iq=p.createContext(void 0);function Lwe(){const e=p.useContext(iq);if(e===void 0)throw new Error(Vn(45));return e}const $we=p.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t;return _h().useState("mounted")||s?r.jsx(iq.Provider,{value:s,children:r.jsx(eS,{ref:n,...i})}):null}),oq=p.createContext(void 0);function zwe(){const e=p.useContext(oq);if(!e)throw new Error(Vn(46));return e}const Bwe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,anchor:l,positionMethod:u,side:d,align:f,sideOffset:m,alignOffset:g,collisionBoundary:v="clipping-ancestors",collisionPadding:b,arrowPadding:y,sticky:k,disableAnchorTracking:w=!1,collisionAvoidance:S=m6,...N}=t,C=_h(),T=Lwe(),P=Cve(),O=C.useState("floatingRootContext"),A=C.useState("mounted"),R=C.useState("open"),M=C.useState("openChangeReason"),_=C.useState("activeTriggerElement"),L=C.useState("modal"),$=C.useState("openMethod"),D=C.useState("positionerElement"),F=C.useState("instantType"),V=C.useState("transitionStatus"),K=C.useState("adaptiveOrigin"),Q=p.useRef(null),X=uR(D),U=hS({anchor:l,floatingRootContext:O,positionMethod:u,mounted:A,side:d,sideOffset:m,align:f,alignOffset:g,arrowPadding:y,collisionBoundary:v,collisionPadding:b,sticky:k,disableAnchorTracking:w,keepMounted:T,nodeId:P,collisionAvoidance:S,adaptiveOrigin:K}),z=O.useState("domReferenceElement");Ge(()=>{const G=z,Y=Q.current;if(G&&(Q.current=G),Y&&G&&G!==Y){C.set("instantType",void 0);const se=new AbortController;return X(()=>{C.set("instantType","trigger-change")},se.signal),()=>{se.abort()}}},[z,X,C]);const q=L===!0&&M!==Va;hP(R&&q,$==="touch",D,_);const J=C.useStateSetter("positionerElement"),ee={open:R,side:U.side,align:U.align,anchorHidden:U.anchorHidden,instant:F},H=mS(t,ee,{styles:U.positionerStyles,transitionStatus:V,props:N,refs:[n,J],hidden:!A,inert:!R});return r.jsxs(oq.Provider,{value:U,children:[A&&q&&r.jsx(vS,{inert:Kb(!R),cutout:_}),r.jsx(Ave,{id:P,children:H})]})}),Fwe=p.createContext(void 0);function Uwe(){const[e,t]=p.useState(0),n=Ke(()=>(t(i=>i+1),()=>{t(i=>Math.max(0,i-1))}));return{context:p.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}const Hwe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,initialFocus:l,finalFocus:u,...d}=t,f=_h(),m=zwe(),g=fV()!=null,{context:v,hasClosePart:b}=Uwe(),y=f.useState("open"),k=f.useState("openMethod"),w=f.useState("instantType"),S=f.useState("transitionStatus"),N=f.useState("popupProps"),C=f.useState("titleElementId"),T=f.useState("descriptionElementId"),P=f.useState("modal"),O=f.useState("mounted"),A=f.useState("openChangeReason"),R=f.useState("activeTriggerElement"),M=f.useState("floatingRootContext"),_=M.useState("floatingId"),L=f.useState("disabled"),$=f.useState("openOnHover"),D=f.useState("closeDelay");ji({open:y,ref:f.context.popupRef,onComplete(){y&&f.context.onOpenChangeComplete?.(!0)}}),eH(M,{enabled:$&&!L,closeDelay:D});const F=l===void 0?K6(f.context.popupRef):l,V=P!==!1&&b;f.useSyncedValue("focusManagerModal",V);const K=f.useStateSetter("popupElement"),Q={open:y,side:m.side,align:m.align,instant:w,transitionStatus:S},X=qt("div",t,{state:Q,ref:[n,f.context.popupRef,K],props:[N,{id:_,role:"dialog",...Ub,"aria-labelledby":C,"aria-describedby":T,onKeyDown(U){g&&gS.has(U.key)&&U.stopPropagation()}},qb(S),d],stateAttributesMapping:GO});return r.jsx(tS,{context:M,openInteractionType:k,modal:V,disabled:!O||A===Va,initialFocus:F,returnFocus:u,restoreFocus:"popup",previousFocusableElement:br(R)?R:void 0,nextFocusableElement:f.context.triggerFocusTargetRef,beforeContentFocusGuardRef:f.context.beforeContentFocusGuardRef,children:r.jsx(Fwe.Provider,{value:v,children:X})})}),Vwe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=_h(),d=Ws(l.id);return u.useSyncedValueWithCleanup("titleElementId",d),qt("h2",t,{ref:n,props:[{id:d},l]})}),qwe=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,u=_h(),d=Ws(l.id);return u.useSyncedValueWithCleanup("descriptionElementId",d),qt("p",t,{ref:n,props:[{id:d},l]})});function ui(e){return r.jsx(Rwe,{"data-slot":"popover",...e})}function wi(e){return r.jsx(Dwe,{"data-slot":"popover-trigger",...e})}function di({className:e,sideOffset:t=6,align:n="start",side:s,alignOffset:i,collisionPadding:o=8,anchor:l,children:u,...d}){return r.jsx($we,{children:r.jsx(Bwe,{className:"z-[35] outline-none",sideOffset:t,align:n,side:s,alignOffset:i,collisionPadding:o,anchor:l,children:r.jsx(Hwe,{"data-slot":"popover-content",className:Ne("flex max-h-[min(70vh,560px)] flex-col overflow-hidden rounded-lg border border-border-strong bg-raised text-foreground shadow-3","outline-none","data-open:animate-in data-open:fade-in-0 data-open:slide-in-from-top-1","data-closed:animate-out data-closed:fade-out-0",e),...d,children:u})})})}function Kwe({className:e,...t}){return r.jsx("div",{"data-slot":"popover-header",className:Ne("flex items-center gap-2 border-b border-hairline px-3 py-2",e),...t})}function lq({className:e,...t}){return r.jsx(Vwe,{"data-slot":"popover-title",className:Ne("text-[12.5px] font-semibold text-foreground",e),...t})}function Gwe({className:e,...t}){return r.jsx(qwe,{"data-slot":"popover-description",className:Ne("text-[11.5px] leading-[1.55] text-muted-foreground",e),...t})}function xP({page:e,pageCount:t,onPageChange:n,disabled:s=!1,className:i,infoFirst:o=!1}){const l=Math.max(1,Number(t)||1),u=Math.min(Math.max(1,Number(e)||1),l),d=r.jsx("span",{"data-slot":"pager-info",className:"text-[11.5px] text-subtle [font-variant-numeric:tabular-nums]",children:Z("第 {current} / {total} 页",{current:u,total:l})});return r.jsxs("div",{"data-slot":"pager",className:Ne("flex items-center gap-2",i),children:[o&&d,r.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:s||u<=1,onClick:()=>n(u-1),children:Z("上一页")}),r.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:s||u>=l,onClick:()=>n(u+1),children:Z("下一页")}),!o&&d]})}const cq=p.createContext(!1);function Go({className:e,render:t,children:n,...s}){const{containerRef:i,indicator:o}=rq('[data-slot="nav-item"]','[data-slot="nav-item"][data-active]'),l=Ah({defaultTagName:"div",render:t,ref:i,props:{...s,"data-slot":"nav-list",className:Ne("relative isolate flex min-h-0 flex-col gap-0.5",e),children:r.jsxs(r.Fragment,{children:[r.jsx("span",{"data-slot":"nav-list-indicator","aria-hidden":"true",...o}),n]})}});return r.jsx(cq.Provider,{value:!0,children:l})}const Wwe=jh(["relative flex h-auto w-full items-center justify-start gap-2.5 whitespace-normal text-left active:translate-y-0","border border-transparent rounded-md","shadow-none","transition-[background-color,border-color,color] duration-150 ease-out","outline-none focus-visible:shadow-focus","disabled:pointer-events-none disabled:opacity-45","[&_svg]:pointer-events-none [&_svg]:shrink-0"],{variants:{variant:{default:["cursor-pointer px-2.5 py-2","text-[12.5px] font-medium text-sidebar-fg","hover:bg-nav-hover hover:text-foreground","data-[active]:border-nav-selected-border data-[active]:bg-nav-selected-bg data-[active]:font-medium data-[active]:text-nav-selected-fg"],add:["cursor-pointer justify-center px-2 py-1.5","border-dashed border-border-strong bg-transparent","text-[11.5px] text-muted-foreground","hover:border-primary hover:text-primary-fg"]}},defaultVariants:{variant:"default"}});function Ts({className:e,variant:t,active:n=!1,count:s,icon:i,trailing:o,children:l,...u}){const d=p.useContext(cq);return r.jsxs(B,{type:"button",variant:"ghost","data-slot":"nav-item","data-active":n?"":void 0,"data-sliding":d?"":void 0,"aria-current":n?"true":void 0,className:Ne(Wwe({variant:t}),d&&"data-[active]:border-transparent data-[active]:bg-transparent data-[active]:hover:bg-transparent",e),...u,children:[i,r.jsx("span",{"data-slot":"nav-item-label",className:"min-w-0 flex-1 truncate",children:l}),o,s!=null&&r.jsx("span",{"data-slot":"nav-item-count",className:Ne("flex-none text-[10.5px] text-sidebar-muted [font-variant-numeric:tabular-nums]",n&&"text-inherit"),children:s})]})}function Qb(e){return r.jsx(PH,{"data-slot":"sheet",...e})}function Ywe(e){return r.jsx(MH,{"data-slot":"sheet-trigger",...e})}function uq(e){return r.jsx(Gb,{"data-slot":"sheet-close",...e})}function Xwe(e){return r.jsx(rP,{"data-slot":"sheet-portal",...e})}const IS=e=>r.jsx(sP,{"data-slot":"sheet-title",...e}),Qwe=e=>r.jsx(yH,{"data-slot":"sheet-description",...e});function Zwe({className:e,...t}){return r.jsx(YR,{"data-slot":"sheet-overlay",className:Ne("fixed inset-0 isolate z-30 bg-mask backdrop-blur-[3px]","transition-opacity duration-200","data-open:animate-in data-open:fade-in-0","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",e),...t})}function Zb({className:e,children:t,showCloseButton:n=!0,showHandle:s=!0,side:i="bottom",keepMounted:o=!1,...l}){const u=i==="center",d=i==="right",f=i==="left";return r.jsxs(Xwe,{keepMounted:o,children:[r.jsx(Zwe,{}),r.jsxs(nP,{"data-slot":"sheet-content",className:Ne("fixed z-30 flex flex-col overflow-hidden border border-border bg-surface shadow-3 outline-none","transition-[opacity,transform] duration-200 [transition-timing-function:cubic-bezier(.32,.9,.3,1)]",u?["top-1/2 left-1/2 max-h-[calc(100vh-48px)] w-[min(560px,calc(100vw-48px))]","-translate-x-1/2 -translate-y-1/2 rounded-lg","data-open:animate-in data-open:fade-in-0 data-open:zoom-in-[.985]","data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards"]:d?["top-0 right-0 bottom-0 h-full w-[min(340px,86vw)] rounded-l-xl","data-open:animate-in data-open:slide-in-from-right data-open:fade-in-0","data-closed:animate-out data-closed:slide-out-to-right data-closed:fade-out-0 data-closed:fill-mode-forwards"]:f?["top-0 left-0 bottom-0 h-full w-[min(340px,86vw)] rounded-r-xl","data-open:animate-in data-open:slide-in-from-left data-open:fade-in-0","data-closed:animate-out data-closed:slide-out-to-left data-closed:fade-out-0 data-closed:fill-mode-forwards"]:["inset-x-0 bottom-0 max-h-[85svh] rounded-t-xl","data-open:animate-in data-open:slide-in-from-bottom data-open:fade-in-0","data-closed:animate-out data-closed:slide-out-to-bottom data-closed:fade-out-0 data-closed:fill-mode-forwards"],e),...l,children:[s&&!u&&!d&&!f&&r.jsx("div",{"aria-hidden":"true",className:"mx-auto mt-2 mb-1 h-1 w-9.5 shrink-0 rounded-pill bg-border-strong"}),t,n&&r.jsxs(Gb,{"data-slot":"sheet-close",render:r.jsx(B,{variant:"ghost",size:"icon-sm",className:"absolute top-3 right-3"}),children:[r.jsx("svg",{viewBox:"0 0 12 12",className:"size-3","aria-hidden":"true",children:r.jsx("path",{d:"M2.5 2.5l7 7M9.5 2.5l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})}),r.jsx("span",{className:"sr-only",children:Z("关闭")})]})]})]})}function MS({className:e,...t}){return r.jsx("div",{"data-slot":"sheet-header",className:Ne("flex shrink-0 items-center gap-2.5 border-b border-hairline px-5 py-3 pr-10","[&_h2]:flex-1 [&_h2]:text-[15px] [&_h2]:font-semibold",e),...t})}function _S({className:e,...t}){return r.jsx("div",{"data-slot":"sheet-body",className:Ne("flex min-h-0 flex-1 flex-col gap-3.5 overflow-y-auto px-5 py-4",e),...t})}function vP({className:e,...t}){return r.jsx("div",{"data-slot":"sheet-footer",className:Ne("flex shrink-0 items-center gap-2 border-t border-hairline bg-surface-2 px-5 py-3 pb-[max(12px,env(safe-area-inset-bottom))]",e),...t})}function bP(e){const t=p.useMemo(()=>typeof window>"u"?null:window.matchMedia(e),[e]);return p.useSyncExternalStore(p.useCallback(n=>(t?.addEventListener("change",n),()=>t?.removeEventListener("change",n)),[t]),()=>t?.matches??!1,()=>!1)}function DS({open:e,onOpenChange:t,title:n,actions:s,children:i,breakpoint:o=767,side:l="right",inlineClassName:u,inlineAs:d="div",contentClassName:f,bodyClassName:m}){const g=bP(`(max-width: ${o}px)`);return p.useEffect(()=>{!g&&e&&t(!1)},[g,e,t]),p.useEffect(()=>{const v=()=>t(!1);return window.addEventListener("wb:navigation-close",v),()=>window.removeEventListener("wb:navigation-close",v)},[t]),g?r.jsx(Qb,{open:e,onOpenChange:t,children:r.jsxs(Zb,{side:l,keepMounted:!0,showHandle:!1,className:f,children:[r.jsxs(MS,{children:[r.jsx(IS,{children:n}),s]}),r.jsx(_S,{className:Ne("gap-4 [&>*]:w-full [&>*]:min-w-0 [&>*]:max-w-none",m),children:i})]})}):r.jsx(d,{"data-slot":"responsive-sheet-inline",className:u,children:i})}function Jwe(e){const{open:t,defaultOpen:n=!1,onOpenChange:s,disabled:i}=e,[o,l]=Tl({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:u,setMounted:d,transitionStatus:f}=gu(o,!0,!0),m=Ws(),[g,v]=p.useState(),b=g===null?void 0:g??m,y=Ke(k=>{const w=!o,S=Nt(xu,k.nativeEvent);s(w,S),!S.isCanceled&&l(w)});return p.useMemo(()=>({defaultPanelId:m,disabled:i,handleTrigger:y,mounted:u,open:o,panelId:b,setMounted:d,setOpen:l,setPanelIdState:v,transitionStatus:f}),[m,i,y,u,o,b,d,l,v,f])}const dq=p.createContext(void 0);function fq(){const e=p.useContext(dq);if(e===void 0)throw new Error(Vn(15));return e}const e0e="data-open",t0e="data-closed",n0e=qO,r0e="data-panel-open",s0e={[e0e]:""},a0e={[t0e]:""},i0e={open(e){return e?{[r0e]:""}:null}},hq={...{open(e){return e?s0e:a0e}},...Fo},o0e=p.forwardRef(function(t,n){const{render:s,className:i,defaultOpen:o=!1,disabled:l=!1,onOpenChange:u,open:d,style:f,...m}=t,g=Ke(u),v=Jwe({open:d,defaultOpen:o,onOpenChange:g,disabled:l}),b=p.useMemo(()=>({open:v.open,disabled:v.disabled,transitionStatus:v.transitionStatus}),[v.open,v.disabled,v.transitionStatus]),y=p.useMemo(()=>({...v,onOpenChange:g,state:b}),[v,g,b]),k=qt("div",t,{state:b,ref:n,props:m,stateAttributesMapping:hq});return r.jsx(dq.Provider,{value:y,children:k})}),l0e={...i0e,...Fo},c0e=p.forwardRef(function(t,n){const{panelId:s,open:i,handleTrigger:o,state:l,disabled:u}=fq(),{className:d,disabled:f=u,render:m,nativeButton:g=!0,style:v,...b}=t,{getButtonProps:y,buttonRef:k}=$i({disabled:f,focusableWhenDisabled:!0,native:g});return qt("button",t,{state:l,ref:[n,k],props:[{"aria-controls":i?s:void 0,"aria-expanded":i,onClick:o},b,y],stateAttributesMapping:l0e})}),Jb={height:void 0,width:void 0};function u0e(e){const{externalRef:t,hiddenUntilFound:n,id:s,keepMounted:i,mounted:o,onOpenChange:l,open:u,setMounted:d,setOpen:f,transitionStatus:m}=e,g=p.useRef(null),v=p.useRef(null),[b,y]=p.useState(Jb),k=p.useRef(Jb),w=p.useRef(!1),S=p.useRef(u),N=p.useRef(!1),[C,T]=p.useState(!1),P=p.useRef(null),O=lo(t,g),A=ss(u),R=uR(g),M=!u&&!o,_=C?"idle":m,L=u&&(S.current||N.current),$=!u&&o&&v.current==="css-animation"&&b.height===void 0&&b.width===void 0?k.current:b,D=n&&M&&v.current!=="css-animation",F=Ke((U,z=!0)=>{z&&(k.current=U),y(U)}),V=Ke(()=>{P.current?.(),P.current=null}),K=Ke(U=>{V(),P.current=()=>{P.current=null,U()}}),Q=Ke(()=>{u&&o&&v.current==="css-animation"&&(N.current=!0)});Ge(()=>{!C||m==="starting"||T(!1)},[C,m]),p.useEffect(()=>()=>{Q(),V()},[Q,V]),Ge(()=>{const U=g.current;if(!U)return;!u&&P.current&&V();const z=d0e(U,L);if(v.current=z,u&&m==="idle"&&S.current&&z==="css-animation"){k.current=jg(U);return}if(u&&m==="starting"){const ee=w.current;if(w.current=!1,z==="none"){F(jg(U)),T(!0);return}if(z==="css-transition"){const Y=f0e(U);if(F(jg(U)),!ee)return Y;const se=LS(U,"transition-duration","0s");return K(se),T(!0),Y}F(jg(U));const H=LS(U,"animation-name","none");if(!ee){H();return}const G=LS(U,"animation-duration","0s");H(),K(G),T(!0);return}if(!u&&o&&(m==="idle"||m==="starting")){if(S.current=!1,N.current=!1,z==="none"){F(Jb,!1),d(!1);return}F(jg(U));return}if(m!=="ending")return;if(z==="none"){d(!1);return}const q=jg(U);if(!(q.height>0||q.width>0)){d(!1);return}F(q),z==="css-animation"&&LS(U,"animation-name","none")()},[o,u,V,F,d,K,L,m]),ji({enabled:u&&o&&_==="idle",open:!0,ref:g,onComplete(){u&&F(Jb,!1)}}),p.useEffect(()=>{if(u||!o||_!=="ending"||!g.current)return;const z=new AbortController;let q=-1;function J(){A.current||(d(!1),F(Jb,!1))}return q=Fi.request(()=>{R(J,z.signal)}),()=>{Fi.cancel(q),z.abort()}},[A,o,u,_,R,F,d]),Ge(()=>{const U=g.current;!U||!n||!M||U.setAttribute("hidden","until-found")},[M,n]),p.useEffect(function(){const z=g.current;if(!z)return;function q(J){const ee=Nt(rs,J);l(!0,ee),!ee.isCanceled&&(w.current=!0,f(!0))}return kn(z,"beforematch",q)},[l,f]);const X=i||n||o||u;return{height:$.height,props:{...D?{[n0e]:""}:void 0,hidden:M,id:s},ref:O,shouldPreventOpenAnimation:L,shouldRender:X,transitionStatus:_,width:$.width}}function jg(e){return{height:e.scrollHeight,width:e.scrollWidth}}function d0e(e,t){const n=vr(e).getComputedStyle(e),s=(n.animationName.split(",").map(o=>o.trim()).some(o=>o!==""&&o!=="none")||t)&&mq(n.animationDuration),i=mq(n.transitionDuration);return s&&i||i?"css-transition":s?"css-animation":"none"}function mq(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function LS(e,t,n){const s=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(s===""){e.style.removeProperty(t);return}e.style.setProperty(t,s,i)}}function f0e(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(i=>{e.style.setProperty(i,"initial","important")});function n(){Object.entries(t).forEach(([i,o])=>{if(o===""){e.style.removeProperty(i);return}e.style.setProperty(i,o)})}const s=Fi.request(n);return()=>{Fi.cancel(s),n()}}const h0e="--collapsible-panel-height",m0e="--collapsible-panel-width",p0e=p.forwardRef(function(t,n){const{className:s,hiddenUntilFound:i,keepMounted:o,render:l,id:u,style:d,...f}=t,{defaultPanelId:m,mounted:g,onOpenChange:v,open:b,setMounted:y,setPanelIdState:k,setOpen:w,state:S,transitionStatus:N}=fq(),C=i??!1,T=o??!1,P=u||void 0,O=P??m;Ge(()=>(k(Q=>P??(Q===null?void 0:Q)),()=>{k(Q=>Q===P?null:Q)}),[P,k]);const{height:A,props:R,ref:M,shouldPreventOpenAnimation:_,shouldRender:L,transitionStatus:$,width:D}=u0e({externalRef:n,hiddenUntilFound:C,id:O,keepMounted:T,mounted:g,onOpenChange:v,open:b,setMounted:y,setOpen:w,transitionStatus:N}),F={...S,transitionStatus:$},V=zF(d,F),K=qt("div",{...t,style:void 0},{state:F,ref:M,props:[R,{style:{[h0e]:A===void 0?"auto":`${A}px`,[m0e]:D===void 0?"auto":`${D}px`}},f,V?{style:V}:void 0,_?{style:{animationName:"none"}}:void 0],stateAttributesMapping:hq});return L?K:null});function gs(e){return r.jsx(o0e,{"data-slot":"collapsible",...e})}function xs({className:e,render:t,...n}){return r.jsx(c0e,{"data-slot":"collapsible-trigger",render:t??r.jsx(B,{variant:"ghost"}),className:e,...n})}function vs({className:e,...t}){return r.jsx(p0e,{"data-slot":"collapsible-content",className:Ne("min-w-0",typeof e=="string"&&e),...t})}function Fe({className:e,variant:t="default",...n}){return r.jsx("div",{"data-slot":"alert",role:"alert",className:Ne("rounded-md border px-3 py-2.5 text-[12.5px] leading-relaxed",t==="default"&&"border-border bg-surface-2 text-subtle",t==="destructive"&&"border-destructive-bd bg-destructive-soft text-destructive",t==="warning"&&"border-warning-bd bg-warning-soft text-warning",t==="success"&&"border-success-bd bg-success-soft text-success",e),...n})}function wg({className:e,...t}){return r.jsx("div",{"data-slot":"alert-title",className:Ne("font-semibold",e),...t})}function ho({className:e,...t}){return r.jsx("div",{"data-slot":"alert-description",className:Ne("text-[12px] leading-relaxed",e),...t})}function pt({className:e,...t}){return r.jsx("div",{"data-slot":"empty",className:Ne("flex flex-col items-center justify-center gap-2 px-4 py-8 text-center text-[12.5px] leading-relaxed text-muted-foreground",e),...t})}function yP({className:e,...t}){return r.jsx("div",{"data-slot":"empty-title",className:Ne("text-[13px] font-semibold text-foreground",e),...t})}function jP({className:e,...t}){return r.jsx("div",{"data-slot":"empty-description",className:Ne("text-[12px] leading-relaxed text-muted-foreground",e),...t})}function qa({className:e,variant:t="success",pulse:n,...s}){return r.jsx("span",{"data-slot":"status-dot","aria-hidden":"true",className:Ne("inline-block size-[7px] shrink-0 rounded-full",t==="success"&&"bg-success",t==="warning"&&"bg-warning",t==="destructive"&&"bg-destructive",t==="muted"&&"bg-muted-foreground",n&&"animate-pulse motion-reduce:animate-none",e),...s})}const g0e=new Set(["a","article","b","blockquote","br","code","del","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","kbd","li","ol","p","pre","s","section","small","span","strong","sub","sup","ul","col","colgroup"]),pq={button:B,input:ze,label:Ae,textarea:Xs,table:ps,thead:Qs,tbody:Es,tfoot:Bye,tr:Jt,th:tt,td:Ve,caption:Fye},x0e=new Set(["text-align","white-space","word-break","overflow-wrap","font-weight","font-style","font-size","line-height","color","background-color","width","max-width","min-width","height","padding","margin","display","gap","flex","grid-column"]);function gq(e,t=!1){if(t&&/^data:image\/(?:png|jpe?g|gif|webp|avif);base64,/i.test(e)||/^(?:https?:\/\/|\/[^/]|\.\.?\/|#)/i.test(e))return e}function v0e(e){const t={};for(const n of e.attributes)n.name==="class"?t.className=n.value:n.name==="colspan"?t.colSpan=Number(n.value)||1:n.name==="rowspan"?t.rowSpan=Number(n.value)||1:n.name==="target"&&["_blank","_self"].includes(n.value)?t.target=n.value:n.name==="loading"&&["lazy","eager"].includes(n.value)?t.loading=n.value:["title","id","role","alt","scope","type","placeholder"].includes(n.name)||/^(aria-|data-)/.test(n.name)?t[n.name]=n.value:n.name==="href"?t.href=gq(n.value):n.name==="src"&&(t.src=gq(n.value,!0));if(e.tagName==="A"&&(t.rel="noopener noreferrer"),e instanceof HTMLElement){const n={};for(const s of e.style){if(!x0e.has(s))continue;const i=e.style.getPropertyValue(s);/url\(|expression\(/i.test(i)||(n[s.replace(/-([a-z])/g,(o,l)=>l.toUpperCase())]=i)}Object.keys(n).length&&(t.style=n)}return t}function $S(e,t=""){return Array.from(e).map((n,s)=>{const i=`${t}${s}`;if(n.nodeType===Node.TEXT_NODE)return n.textContent;if(!(n instanceof Element))return null;const o=n.tagName.toLowerCase();if(["script","style","iframe","object","embed"].includes(o))return null;const l=v0e(n),u=$S(n.childNodes,`${i}-`);if(o==="details"){const d=Array.from(n.children).find(f=>f.tagName==="SUMMARY");return r.jsxs(gs,{defaultOpen:n.hasAttribute("open"),...l,children:[r.jsxs(xs,{className:Ne("h-auto w-full justify-start whitespace-normal px-0 text-left",d?.className),children:[r.jsx("span",{className:"shrink-0 transition-transform in-data-panel-open:rotate-90","aria-hidden":"true",children:"▸"}),d?$S(d.childNodes,`${i}-summary-`):"…"]}),r.jsx(vs,{keepMounted:!0,children:$S(Array.from(n.childNodes).filter(f=>f!==d),`${i}-body-`)})]},i)}if(o==="span"&&n.classList.contains("badge")){const d=n.classList.contains("ok")||n.classList.contains("phase-streaming")?"success":n.classList.contains("bad")?"destructive":n.classList.contains("warn")?"warning":n.classList.contains("brand")?"brand":"outline";return r.jsx(Ee,{variant:d,shape:n.classList.contains("tag")?"tag":"pill",...l,children:u},i)}return o==="span"&&n.classList.contains("req-live-dot")?r.jsx(qa,{pulse:!0,className:"size-[5px] bg-current"},i):o==="div"&&n.classList.contains("empty")?r.jsx(pt,{...l,children:u},i):o==="input"&&n.getAttribute("type")==="checkbox"?r.jsx(jr,{checked:n.hasAttribute("checked"),readOnly:!0},i):o==="table"?r.jsx(ps,{container:!1,...l,children:u},i):pq[o]?p.createElement(pq[o],{key:i,...l},o==="input"?void 0:u):g0e.has(o)?["br","hr","img","col"].includes(o)?p.createElement(o,{key:i,...l}):p.createElement(o,{key:i,...l},u):r.jsx(p.Fragment,{children:u},i)})}function Wo({html:e,className:t,render:n,...s}){const i=p.useMemo(()=>{if(!e)return[];const o=new DOMParser().parseFromString(e,"text/html");return $S(o.body.childNodes)},[e]);return Ah({defaultTagName:"div",render:n,props:{...s,"data-slot":"html-content",className:Ne(t),children:i}})}const xq=p.createContext(void 0);function b0e(){const e=p.useContext(xq);if(e===void 0)throw new Error(Vn(38));return e}const y0e=p.forwardRef(function(t,n){const{format:s,getAriaValueText:i,locale:o,max:l=100,min:u=0,value:d,render:f,className:m,children:g,style:v,...b}=t,[y,k]=p.useState(),w=e6(d,u,l),S=bu(Number.isNaN(w)?0:w,0,100),N=bu(Number.isNaN(d)?u:d,u,l),C=s?Xk(N,o,s):Xk(S/100,o,{style:"percent"});let T=C;i&&(T=i(C,d));const P={"aria-labelledby":y,"aria-valuemax":l,"aria-valuemin":u,"aria-valuenow":N,"aria-valuetext":T,role:"meter",children:r.jsxs(p.Fragment,{children:[g,r.jsx("span",{role:"presentation",style:vu,children:"x"})]})},O=p.useMemo(()=>({formattedValue:C,percentageValue:S,setLabelId:k,value:d}),[C,S,k,d]),A=qt("div",t,{ref:n,props:[P,b]});return r.jsx(xq.Provider,{value:O,children:A})}),j0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t;return qt("div",t,{ref:n,props:l})}),w0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,...l}=t,{percentageValue:u}=b0e();return qt("div",t,{ref:n,props:[{style:{insetInlineStart:0,height:"inherit",width:`${u}%`}},l]})});function kg({value:e,variant:t="default",className:n,trackClassName:s,indicatorClassName:i,...o}){const l=Ne("block h-1 w-full overflow-hidden rounded-pill bg-hairline",s);return e===null?r.jsx("span",{"data-slot":"meter","aria-hidden":"true",className:Ne("block w-full",n),children:r.jsx("span",{"data-slot":"meter-track",className:l})}):r.jsx(y0e,{render:r.jsx("span",{}),value:e,"data-slot":"meter",className:Ne("block w-full",n),...o,children:r.jsx(j0e,{render:r.jsx("span",{}),"data-slot":"meter-track",className:l,children:r.jsx(w0e,{render:r.jsx("span",{}),"data-slot":"meter-indicator",className:Ne("block h-full rounded-[inherit] transition-[width] duration-300 motion-reduce:transition-none",t==="default"&&"bg-primary",t==="success"&&"bg-success",t==="warning"&&"bg-warning",t==="destructive"&&"bg-destructive",t==="muted"&&"bg-muted-foreground",i)})})})}function et({className:e,size:t="default",render:n,...s}){return Ah({defaultTagName:"div",render:n,props:{...s,"data-slot":"card","data-size":t,className:Ne("group/card min-w-0 overflow-hidden rounded-lg border border-border bg-surface text-foreground shadow-1",e)}})}function pn({className:e,...t}){return r.jsx("div",{"data-slot":"card-header",className:Ne("flex flex-wrap items-center gap-2.5 border-b border-border px-4 py-3 group-data-[size=sm]/card:px-3 group-data-[size=sm]/card:py-2",e),...t})}function Fs({className:e,...t}){return r.jsx("h3",{"data-slot":"card-title",className:Ne("m-0 text-[14px] font-semibold leading-snug",e),...t})}function k0e({className:e,...t}){return r.jsx("p",{"data-slot":"card-description",className:Ne("m-0 text-[12px] leading-relaxed text-subtle",e),...t})}function vq({className:e,...t}){return r.jsx("div",{"data-slot":"card-action",className:Ne("ml-auto flex shrink-0 flex-wrap items-center gap-2",e),...t})}function Gt({className:e,...t}){return r.jsx("div",{"data-slot":"card-content",className:Ne("min-w-0 p-4 group-data-[size=sm]/card:p-3",e),...t})}function ju({className:e,...t}){return r.jsx("div",{"data-slot":"card-footer",className:Ne("flex flex-wrap items-center gap-2 border-t border-border px-4 py-2.5 text-[11.5px] leading-relaxed text-muted-foreground",e),...t})}function wP({className:e,...t}){return r.jsx(et,{"data-slot":"metric-card",className:Ne("rounded-md bg-surface-inset px-3.5 py-3",e),...t})}function bq({className:e,...t}){return r.jsx("div",{"data-slot":"metric-label",className:Ne("mb-1 text-[11.5px] text-muted-foreground",e),...t})}function yq({className:e,...t}){return r.jsx("div",{"data-slot":"metric-value",className:Ne("break-all text-[13px] font-semibold leading-normal tabular-nums",e),...t})}function jq({className:e,...t}){return r.jsx("div",{"data-slot":"metric-grid",className:Ne("grid grid-cols-[repeat(auto-fit,minmax(min(178px,100%),1fr))] gap-2.5",e),...t})}function Ka(e,t={}){return new Promise(n=>{const s=document.createElement("div");document.body.append(s);const i=zn.createRoot(s),o=p.createRef();let l=!1;const u=d=>{l||(l=!0,queueMicrotask(()=>{i.unmount(),s.remove()}),n(d))};i.render(r.jsx(LH,{open:!0,onOpenChange:d=>{d||u(!1)},children:r.jsxs(zH,{initialFocus:o,children:[r.jsx(BH,{children:r.jsx($H,{children:t.title||Z("请确认")})}),r.jsx(FH,{children:r.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-relaxed",children:e})}),r.jsxs(UH,{children:[r.jsx(B,{ref:o,variant:"outline",onClick:()=>u(!1),children:Z("取消")}),r.jsx(B,{variant:t.destructive===!1?"default":"destructive",onClick:()=>u(!0),children:t.confirmText||Z("确定")})]})]})}))})}function Dh({className:e,render:t,variant:n="default",size:s="default",...i}){return Ah({defaultTagName:"div",render:t,props:{...i,"data-slot":"item","data-size":s,className:Ne("flex w-full min-w-0 items-center gap-2.5 rounded-md text-left text-foreground transition-colors",s==="sm"?"px-3 py-2 text-[12.5px]":"px-3.5 py-3 text-[13px]",n==="outline"&&"border border-border",n==="muted"&&"bg-surface-2","has-[[data-slot=item-content]]:justify-start",e)}})}function wq({className:e,...t}){return r.jsx("div",{"data-slot":"item-group",role:"list",className:Ne("flex flex-col",e),...t})}function kq({className:e,...t}){return r.jsx("div",{"data-slot":"item-content",className:Ne("min-w-0 flex-1",e),...t})}function Sq({className:e,...t}){return r.jsx("div",{"data-slot":"item-title",className:Ne("text-[13px] font-medium",e),...t})}function Nq({className:e,...t}){return r.jsx("p",{"data-slot":"item-description",className:Ne("m-0 mt-0.5 text-[12px] leading-relaxed text-muted-foreground",e),...t})}function S0e({className:e,...t}){return r.jsx("div",{"data-slot":"item-media",className:Ne("flex shrink-0 items-center justify-center",e),...t})}function Cq({className:e,...t}){return r.jsx("div",{"data-slot":"item-actions",className:Ne("ml-auto flex shrink-0 items-center gap-2",e),...t})}const N0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,disabled:l=!1,...u}=t,[d,f]=p.useState(void 0),g=BO(!0)?.disabled||l,b=qt("fieldset",t,{ref:n,state:{disabled:g},props:[{"aria-labelledby":d,disabled:g},u]}),y=p.useMemo(()=>({legendId:d,setLegendId:f,disabled:g}),[d,f,g]);return r.jsx(fU.Provider,{value:y,children:b})}),Aq=jh("min-w-0",{variants:{orientation:{vertical:"flex flex-col gap-1.5",horizontal:"flex flex-wrap items-center gap-2.5",responsive:"flex flex-col gap-1.5 min-[768px]:flex-row min-[768px]:items-center min-[768px]:gap-2.5"}},defaultVariants:{orientation:"vertical"}});function ct({className:e,orientation:t,...n}){return r.jsx(xxe,{"data-slot":"field",className:s=>Ne(Aq({orientation:t}),typeof e=="function"?e(s):e),...n})}function Lh({className:e,orientation:t,...n}){return r.jsx("div",{"data-slot":"field-group",className:Ne(t?Aq({orientation:t}):"flex flex-col gap-3",e),...n})}function C0e({className:e,...t}){return r.jsx(N0e,{"data-slot":"field-set",className:n=>Ne("m-0 min-w-0 border-0 p-0",typeof e=="function"?e(n):e),...t})}function ut({className:e,...t}){return r.jsx(bxe,{"data-slot":"field-label",className:n=>Ne("flex items-center gap-[6px] text-[11.5px] text-muted-foreground",typeof e=="function"?e(n):e),...t})}function kP({className:e,...t}){return r.jsx("div",{"data-slot":"field-content",className:Ne("min-w-0 flex-1",e),...t})}function wr({className:e,...t}){return r.jsx(wxe,{"data-slot":"field-description",className:n=>Ne("m-0 text-[11.5px] leading-relaxed text-subtle",typeof e=="function"?e(n):e),...t})}const Eq=p.createContext(void 0);function SP(){const e=p.useContext(Eq);if(!e)throw new Error(Vn(73));return e}let Tq=0;function Oq(e){return Tq+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${Tq}`}function NP(e,t){if(typeof e=="string")return{description:e};if(typeof e=="function"){const n=e(t);return typeof n=="string"?{description:n}:n}return e}function CP(e){const t=new Map;let n=0,s=0;return e.forEach((i,o)=>{const l=i.transitionStatus==="ending";t.set(i.id,{value:i,domIndex:o,visibleIndex:l?-1:n,offsetY:s}),s+=i.height||0,l||(n+=1)}),t}function AP(e,t){let n=0;return e.map(s=>{if(s.transitionStatus==="ending")return s;const i=n>=t;return n+=1,s.limited===i?s:{...s,limited:i}})}const Pl={toasts:e=>e.toasts,isEmpty:e=>e.toasts.length===0,toast:(e,t)=>e.toastMetadata.get(t)?.value,toastIndex:(e,t)=>e.toastMetadata.get(t)?.domIndex??-1,toastOffsetY:(e,t)=>e.toastMetadata.get(t)?.offsetY??0,toastVisibleIndex:(e,t)=>e.toastMetadata.get(t)?.visibleIndex??-1,focused:e=>e.focused,expanded:e=>e.hovering||e.focused,expandedOrOutOfFocus:e=>e.hovering||e.focused||!e.isWindowFocused,prevFocusElement:e=>e.prevFocusElement};class A0e extends Ph{constructor(n){super({...n,toastMetadata:CP(n.toasts)},{},Pl);Cn(this,"timers",new Map);Cn(this,"areTimersPaused",!1);Cn(this,"setViewport",n=>{this.set("viewport",n)});Cn(this,"disposeEffect",()=>()=>{this.timers.forEach(n=>{n.timeout?.clear()}),this.timers.clear()});Cn(this,"addToast",n=>{const{timeout:s,limit:i}=this.state,o=n.id||Oq("toast");if(n.id){const f=Pl.toast(this.state,n.id);if(f)if(f.transitionStatus==="ending")this.removeToast(n.id,!0);else{const{id:m,transitionStatus:g,...v}=n;return this.updateToastInternal(n.id,v,!0,!0),n.id}}const l={...n,id:o,updateKey:0,transitionStatus:"starting"},u=[l,...this.state.toasts];this.setToasts(AP(u,i));const d=l.timeout??s;return l.type!=="loading"&&d>0&&this.scheduleTimer(o,d,()=>this.closeToast(o)),Pl.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),o});Cn(this,"updateToast",(n,s)=>{const i=Pl.toast(this.state,n);!i||i.transitionStatus==="ending"||this.updateToastInternal(n,typeof s=="function"?s(i):s,!1,!0)});Cn(this,"updateToastInternal",(n,s,i=!1,o=!1)=>{const{timeout:l,toasts:u}=this.state,d=Pl.toast(this.state,n);if(!d||d.transitionStatus==="ending")return;const f={...d,...s,...o&&{updateKey:d.updateKey+1}};this.setToasts(u.map(S=>S.id===n?f:S));const m=f.timeout??l,g=d.timeout??l,v=Object.hasOwn(s,"timeout"),b=f.transitionStatus!=="ending"&&f.type!=="loading"&&m>0,y=this.timers.has(n),k=g!==m,w=d.type==="loading";if(!b&&y){this.clearTimer(n);return}b&&(!y||k||v||w||i)&&(this.clearTimer(n),this.scheduleTimer(n,m,()=>this.closeToast(n)),Pl.expandedOrOutOfFocus(this.state)&&this.pauseTimers())});Cn(this,"closeToast",n=>{const s=n===void 0,{limit:i,toasts:o}=this.state;let l;if(s)l=o,this.clearTimers();else{const f=Pl.toast(this.state,n);if(!f)return;l=[f],this.clearTimer(n)}const u=o.map(f=>s||f.id===n?{...f,transitionStatus:"ending",height:0}:f),d=AP(u,i);this.setToasts(d,!d.some(f=>f.transitionStatus!=="ending")),l.forEach(f=>{f.transitionStatus!=="ending"&&f.onClose?.()}),this.handleFocusManagement(n)});Cn(this,"promiseToast",(n,s)=>{const i=NP(s.loading),o=this.addToast({...i,type:"loading"}),l=n.then(u=>{const d=NP(s.success,u);return this.updateToast(o,{...d,type:"success",timeout:d.timeout}),u}).catch(u=>{const d=NP(s.error,u);return this.updateToast(o,{...d,type:"error",timeout:d.timeout}),Promise.reject(u)});return{}.hasOwnProperty.call(s,"setPromise")&&s.setPromise(l),l});Cn(this,"handleDocumentPointerDown",n=>{if(n.pointerType!=="touch")return;const s=Er(n);Et(this.state.viewport,s)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))})}syncProviderProps(n,s){const i=this.state.limit!==s;if(this.state.timeout===n&&!i)return;const o={timeout:n,limit:s};if(i){const l=AP(this.state.toasts,s);o.toasts=l,o.toastMetadata=CP(l)}this.update(o)}removeToast(n,s=!1){const i=Pl.toastIndex(this.state,n);if(i===-1)return;const o=this.state.toasts[i];s||o?.onRemove?.();const l=[...this.state.toasts];l.splice(i,1),this.setToasts(l)}pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(n=>{n.timeout&&(n.timeout.clear(),n.remaining=Math.max(n.remaining-(Date.now()-n.start),0))}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((n,s)=>{n.remaining=n.remaining>0?n.remaining:n.delay,n.timeout??(n.timeout=Bi.create()),n.timeout.start(n.remaining,()=>{this.handleTimerFired(s),n.callback()}),n.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}scheduleTimer(n,s,i){const o=Date.now(),u=!Pl.expandedOrOutOfFocus(this.state)?Bi.create():void 0;u?.start(s,()=>{this.handleTimerFired(n),i()}),this.timers.set(n,{timeout:u,start:o,delay:s,remaining:s,callback:i})}clearTimers(){this.timers.forEach(n=>{n.timeout?.clear()}),this.timers.clear(),this.areTimersPaused=!1}clearTimer(n){this.timers.get(n)?.timeout?.clear(),this.timers.delete(n),this.resetPausedStateIfNoTimersRemain()}handleTimerFired(n){this.timers.delete(n),this.resetPausedStateIfNoTimersRemain()}resetPausedStateIfNoTimersRemain(){this.timers.size===0&&(this.areTimersPaused=!1)}setToasts(n,s=n.length===0){const i={toasts:n,toastMetadata:CP(n)};s&&(i.hovering=!1,i.focused=!1),this.update(i)}handleFocusManagement(n){const s=Ys(_n(this.state.viewport));if(!this.state.viewport||!Et(this.state.viewport,s)||!Mk(s))return;if(n===void 0){this.restoreFocusToPrevElement();return}const i=Pl.toasts(this.state),o=Pl.toastIndex(this.state,n),l=(d,f)=>{for(let m=d;m>=0&&mnew A0e({timeout:s,limit:i,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return Uk(l.disposeEffect),p.useEffect(function(){return o?o[" subscribe"](({action:f,options:m})=>{const g=m.id;f==="promise"&&m.promise?l.promiseToast(m.promise,m):f==="update"&&g?l.updateToast(g,m.updates):f==="close"?l.closeToast(g):l.addToast(m)}):void 0},[l,o]),r.jsxs(Eq.Provider,{value:l,children:[r.jsx(T0e,{store:l,timeout:s,limit:i}),n]})};function T0e(e){const{store:t,timeout:n,limit:s}=e;return Ge(()=>{t.syncProviderProps(n,s)},[t,n,s]),null}const O0e="--toast-frontmost-height",R0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,children:l,...u}=t,d=SP(),f=fa(),m=p.useRef(!1),g=p.useRef(!1),v=p.useRef(!1),b=d.useState("isEmpty"),y=d.useState("toasts"),k=d.useState("focused"),w=d.useState("expanded"),S=d.useState("prevFocusElement"),N=y[0]?.height,C=y.some(U=>U.transitionStatus==="ending"),T=y.filter(U=>U.priority==="high");p.useEffect(()=>{const U=d.state.viewport;if(!U||b)return;const z=vr(U),q=_n(U);function J(G){G.key==="F6"&&Er(G)!==U&&(G.preventDefault(),d.set("prevFocusElement",Ys(q)),U?.focus({preventScroll:!0}),d.pauseTimers(),d.set("focused",!0))}function ee(G){Er(G)===z&&(d.set("isWindowFocused",!1),d.pauseTimers())}function H(G){if(G.relatedTarget)return;const Y=Er(G),se=Ys(_n(U));(Y===z||!Et(U,Y)||!Mk(se))&&d.resumeTimers(),f.start(0,()=>d.set("isWindowFocused",!0))}return Ol(kn(z,"keydown",J),kn(z,"blur",ee,!0),kn(z,"focus",H,!0),kn(q,"pointerdown",d.handleDocumentPointerDown,!0))},[d,f,b]);function P(U){m.current=!0;const z=U.relatedTarget===d.state.viewport?y.find(q=>q.transitionStatus!=="ending"&&!q.limited):void 0;z?z.ref?.current?.focus():d.restoreFocusToPrevElement()}function O(U){U.key==="Tab"&&U.shiftKey&&Er(U.nativeEvent)===d.state.viewport&&(U.preventDefault(),d.restoreFocusToPrevElement())}function A(){d.state.toasts.some(z=>z.transitionStatus==="ending")||v.current||!g.current||(d.state.isWindowFocused&&d.resumeTimers(),d.set("hovering",!1),g.current=!1)}p.useEffect(A,[C,d]);function R(){d.pauseTimers(),d.set("hovering",!0),g.current=!1}function M(){d.state.isWindowFocused&&d.resumeTimers()}function _(){g.current=!0,A()}function L(U){U.pointerType==="touch"&&(v.current=!0)}function $(U){U.pointerType==="touch"&&(v.current=!1,A())}function D(){if(m.current){m.current=!1;return}k||Mk(Ys(_n(d.state.viewport)))&&(d.set("focused",!0),d.pauseTimers())}function F(U){!k||Et(d.state.viewport,U.relatedTarget)||(d.set("focused",!1),M())}const V={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:R,onMouseMove:R,onMouseLeave:_,onFocus:D,onBlur:F,onKeyDown:O,onClick:D,onPointerDown:L,onPointerUp:$,onPointerCancel:$,style:{[O0e]:N?`${N}px`:void 0}},K={expanded:w},Q=!b&&S&&r.jsx(Th,{onFocus:P}),X=qt("div",t,{ref:[n,d.setViewport],state:K,props:[V,u,{children:r.jsxs(p.Fragment,{children:[Q,l,Q]})}]});return r.jsxs(p.Fragment,{children:[Q,X,!k&&T.length>0&&r.jsx("div",{style:vu,children:T.map(U=>r.jsxs("div",{role:"alert","aria-atomic":!0,children:[r.jsx("div",{children:U.title}),r.jsx("div",{children:U.description})]},U.id))})]})}),Rq=p.createContext(void 0);function P0e(){const e=p.useContext(Rq);if(!e)throw new Error(Vn(66));return e}function I0e(e,t){const n=vr(e).getComputedStyle(e).transform;let s=0,i=0,o=1;if(n&&n!=="none"){const l=n.match(/matrix(?:3d)?\(([^)]+)\)/);if(l){const u=l[1].split(", ").map(parseFloat);u.length===6?(s=u[4],i=u[5],o=Math.sqrt(u[0]*u[0]+u[1]*u[1])):u.length===16&&(s=u[12],i=u[13],o=u[0])}}return{x:s,y:i,scale:o}}function EP(e,t,n){switch(e){case"up":return-n;case"down":return n;case"left":return-t;case"right":return t;default:return 0}}const M0e="--toast-index",_0e="--toast-offset-y",D0e="--toast-height",L0e="--toast-swipe-movement-x",$0e="--toast-swipe-movement-y",z0e="data-swipe-direction",B0e={...Fo,swipeDirection(e){return e?{[z0e]:e}:null}},Pq=40,F0e=10,Iq=.5,U0e=1,H0e=`${jve},${wve}`,V0e=p.forwardRef(function(t,n){const{toast:s,render:i,className:o,swipeDirection:l=["down","right"],style:u,...d}=t,f=s.positionerProps?.anchor!==void 0;let m=[];f||(m=Array.isArray(l)?l:[l]);const g=m.length>0,v=SP(),[b,y]=p.useState(void 0),[k,w]=p.useState(!1),[S,N]=p.useState(!1),[C,T]=p.useState({x:0,y:0}),[P,O]=p.useState({x:0,y:0,scale:1}),[A,R]=p.useState(),[M,_]=p.useState(),[L,$]=p.useState(null),D=p.useRef(null),F=p.useRef(void 0),V=p.useRef({x:0,y:0}),K=p.useRef({x:0,y:0,scale:1}),Q=p.useRef(void 0),X=p.useRef(0),U=p.useRef(!1),z=p.useRef({x:0,y:0}),q=p.useRef(!1),J=p.useRef({x:0,y:0}),ee=p.useRef(null),H=p.useRef(null),G=v.useState("toastIndex",s.id),Y=v.useState("toastVisibleIndex",s.id),se=v.useState("toastOffsetY",s.id),re=v.useState("focused"),ne=v.useState("expanded");ji({open:s.transitionStatus!=="ending",ref:D,onComplete(){s.transitionStatus==="ending"&&v.removeToast(s.id)}});const de=Ke((Se=!1)=>{const ge=D.current;if(!ge)return;const ue=ge.style.height;ge.style.height="auto";const be=ge.offsetHeight;ge.style.height=ue;function ve(){v.updateToastInternal(s.id,{ref:D,height:be,transitionStatus:void 0})}Se?xr.flushSync(ve):ve()});Ge(()=>{const Se=F.current;s.transitionStatus!=="starting"&&Se===s.id||(Se!==void 0&&(y(void 0),O({x:0,y:0,scale:1}),ie({x:0,y:0})),F.current=s.id,de())},[de,s.id,s.transitionStatus]);function ie(Se){J.current=Se,T(Se)}Ge(()=>()=>{H.current?.abort()},[]);function oe(Se,ge){const ue=De=>De>0?De**Iq:-(Math.abs(De)**Iq),be=Se>0&&!m.includes("right")||Se<0&&!m.includes("left"),ve=ge>0&&!m.includes("down")||ge<0&&!m.includes("up");return{x:be?ue(Se):Se,y:ve?ue(ge):ge}}const je=Ke(Se=>{if(Se.pointerId!==ee.current)return;ee.current=null,H.current?.abort(),H.current=null,w(!1),N(!1),$(null);const ge=K.current;if(Se.type==="pointercancel"||U.current){ie({x:ge.x,y:ge.y}),y(void 0);return}const ue=J.current,be=ue.x-ge.x,ve=ue.y-ge.y;let De;for(const Ie of m)if(EP(Ie,be,ve)>Pq){De=Ie;break}De?(y(De),v.closeToast(s.id)):(ie({x:ge.x,y:ge.y}),y(void 0))});function te(Se){if(Se.button!==0||(Se.pointerType==="touch"&&v.pauseTimers(),Er(Se.nativeEvent)?.closest(`button,a,input,textarea,[role="button"],${H0e}`)))return;U.current=!1,Q.current=void 0,X.current=0,ee.current=Se.pointerId,V.current={x:Se.clientX,y:Se.clientY},z.current=V.current;const be=Se.currentTarget,ve=I0e(be);K.current=ve,O(ve),ie({x:ve.x,y:ve.y}),v.set("hovering",!0),w(!0),N(!1),$(null),q.current=!0,H.current?.abort();const De=new AbortController;H.current=De;const Ie=_n(be);Ie.addEventListener("pointerup",je,{signal:De.signal}),Ie.addEventListener("pointercancel",je,{signal:De.signal}),be.setPointerCapture?.(Se.pointerId)}function le(Se){if(Se.pointerId!==ee.current)return;Se.preventDefault(),q.current&&(V.current={x:Se.clientX,y:Se.clientY},q.current=!1);const{clientY:ge,clientX:ue,movementX:be,movementY:ve}=Se;(ve<0&&ge>z.current.y||ve>0&&gez.current.x||be>0&&ue=U0e){N(!0);const qe=m.includes("left")||m.includes("right"),zt=m.includes("up")||m.includes("down");if(qe&&zt){const ht=Math.abs(De),Tt=Math.abs(Ie);kt=ht>Tt?"horizontal":"vertical",$(kt)}}let Je;if(!Q.current)kt==="vertical"?Ie>0?Je="down":Ie<0&&(Je="up"):kt==="horizontal"?De>0?Je="right":De<0&&(Je="left"):Math.abs(De)>=Math.abs(Ie)?Je=De>0?"right":"left":Je=Ie>0?"down":"up",Je&&m.includes(Je)&&(Q.current=Je,X.current=EP(Je,De,Ie),y(Je));else{const sn=Q.current,qe=EP(sn,nt,We);qe>Pq?(U.current=!1,y(sn)):!(m.includes("left")&&m.includes("right"))&&!(m.includes("up")&&m.includes("down"))&&X.current-qe>=F0e&&(U.current=!0)}const on=oe(De,Ie);let nn=K.current.x,On=K.current.y;const Rn=m.includes("left")||m.includes("right"),gt=m.includes("up")||m.includes("down");kt!=="vertical"&&Rn&&(nn+=on.x),kt!=="horizontal"&>&&(On+=on.y),ie({x:nn,y:On})}function he(Se){if(Se.key==="Escape"){if(!D.current||!Et(D.current,Ys(_n(D.current))))return;v.closeToast(s.id)}}p.useEffect(()=>{const Se=D.current;if(!g||!Se)return;function ge(ue){ee.current===null||!Et(Se,Er(ue))||ue.preventDefault()}return kn(Se,"touchmove",ge,{passive:!1})},[g]);function ce(){const Se=C.x-P.x,ge=C.y-P.y;return{transition:k?"none":void 0,transform:k?`translateX(${C.x}px) translateY(${C.y}px) scale(${P.scale})`:void 0,[L0e]:`${Se}px`,[$0e]:`${ge}px`}}const ye=s.priority==="high",fe={role:ye?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":A,"aria-describedby":M,"aria-hidden":ye&&!re?!0:void 0,onPointerDown:g?te:void 0,onPointerMove:g?le:void 0,onPointerUp:g?je:void 0,onPointerCancel:g?je:void 0,onKeyDown:he,inert:Kb(s.limited),style:{...ce(),[M0e]:s.transitionStatus==="ending"?G:Y,[_0e]:`${se}px`,[D0e]:s.height?`${s.height}px`:void 0}},Le=p.useMemo(()=>({toast:s,setTitleId:R,setDescriptionId:_,recalculateHeight:de,visibleIndex:Y,expanded:ne}),[s,R,_,de,Y,ne]),pe={transitionStatus:s.transitionStatus,expanded:ne,limited:s.limited||!1,type:s.type,swiping:k,swipeDirection:b},xe=qt("div",t,{ref:[n,D],state:pe,stateAttributesMapping:B0e,props:[fe,d]});return r.jsx(Rq.Provider,{value:Le,children:xe})});function Mq(e){return e==null||typeof e=="boolean"||e===""?!1:Array.isArray(e)?e.some(Mq):!0}function q0e(e){return p.isValidElement(e)&&Mq(e.props.children)}function _q(e,t,n){const{toast:s,setTitleId:i,setDescriptionId:o}=P0e(),l=n==="title"?i:o,u=t??(n==="title"?s.title:s.description);return{id:lg(e),children:u,type:s.type,setId:l}}function Dq(e,t,n){const s=q0e(e);return Ge(()=>{if(s)return n(t),()=>{n(i=>i===t?void 0:i)}},[s,t,n]),s?e:null}const K0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,children:u,...d}=t,{id:f,children:m,type:g,setId:v}=_q(l,u,"description"),y=qt("p",t,{ref:n,state:{type:g},props:{...d,id:f,children:m}});return Dq(y,f,v)}),G0e=p.forwardRef(function(t,n){const{render:s,className:i,style:o,id:l,children:u,...d}=t,{id:f,children:m,type:g,setId:v}=_q(l,u,"title"),y=qt("h2",t,{ref:n,state:{type:g},props:{...d,id:f,children:m}});return Dq(y,f,v)}),W0e=p.forwardRef(function(t,n){return r.jsx(dH,{ref:n,...t})});function Y0e(){const e=SP(),t=e.useState("toasts");return p.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function X0e(){const e=new Set;function t(n){e.forEach(s=>s(n))}return{" subscribe":function(s){return e.add(s),()=>{e.delete(s)}},add(n){const s=n.id||Oq("toast"),i={...n,id:s,transitionStatus:"starting"};return t({action:"add",options:i}),s},close(n){t({action:"close",options:{id:n}})},update(n,s){t({action:"update",options:{id:n,updates:s}})},promise(n,s){let i=n;return t({action:"promise",options:{...s,promise:n,setPromise(o){i=o}}}),i}}}const TP=X0e(),Q0e=E0e;function Z0e({className:e,...t}){return r.jsx(G0e,{"data-slot":"toast-title",className:n=>Ne("m-0 text-[12.5px] font-semibold leading-relaxed [overflow-wrap:anywhere]",typeof e=="function"?e(n):e),...t})}function J0e({className:e,...t}){return r.jsx(K0e,{"data-slot":"toast-description",className:n=>Ne("m-0 text-[12px] leading-relaxed text-subtle [overflow-wrap:anywhere]",typeof e=="function"?e(n):e),...t})}function eke({className:e,...t}){return r.jsx(V0e,{"data-slot":"toast",className:Ne("pointer-events-auto max-w-full rounded-lg border border-border bg-raised px-4 py-2.5 text-[12.5px] text-foreground shadow-3 outline-none","data-[type=success]:border-success-bd data-[type=success]:text-success","data-[type=error]:border-destructive-bd data-[type=error]:text-destructive","data-[type=warning]:border-warning-bd data-[type=warning]:text-warning","data-limited:hidden data-ending-style:opacity-0 transition-opacity duration-150",typeof e=="string"&&e),...t})}function tke(){const{toasts:e}=Y0e();return e.map(t=>r.jsxs(eke,{toast:t,children:[r.jsx(Z0e,{children:t.title}),t.description&&r.jsx(J0e,{className:"mt-1",children:t.description})]},t.id))}function Lq({manager:e=TP,position:t="top-center",className:n}){return r.jsx(Q0e,{toastManager:e,timeout:3500,limit:1,children:r.jsx(W0e,{children:r.jsx(R0e,{"data-slot":"toast-viewport",className:Ne("pointer-events-none fixed left-1/2 z-[100] flex w-max max-w-[84vw] -translate-x-1/2 flex-col items-center gap-2 outline-none",t==="top-center"?"top-4":"bottom-[calc(78px+env(safe-area-inset-bottom,0px))]",n),children:r.jsx(tke,{})})})})}function nke({className:e,...t}){return r.jsx("div",{"data-slot":"app-frame",className:Ne("min-h-0 bg-background text-foreground",e),...t})}function $h({className:e,...t}){return r.jsx("aside",{"data-slot":"sidebar",className:Ne("flex min-h-0 flex-col gap-3 border-r border-sidebar-border bg-sidebar p-3 text-sidebar-foreground",e),...t})}function $q({className:e,...t}){return r.jsx("div",{"data-slot":"sidebar-header",className:Ne("shrink-0",e),...t})}function zq({className:e,...t}){return r.jsx("nav",{"data-slot":"sidebar-content",className:Ne("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",e),...t})}function Bq({className:e,...t}){return r.jsx("div",{"data-slot":"sidebar-footer",className:Ne("flex shrink-0 flex-col gap-2 border-t border-sidebar-border pt-2.5",e),...t})}function Sg({className:e,...t}){return r.jsx("div",{"data-slot":"sidebar-group-label",className:Ne("px-2 pb-1 pt-2 text-[10.5px] font-semibold uppercase tracking-[.09em] text-sidebar-muted",e),...t})}function zS({className:e,...t}){return r.jsx("header",{"data-slot":"page-header",className:Ne("flex shrink-0 items-center justify-between gap-3",e),...t})}function Fq({className:e,...t}){return r.jsx("h1",{"data-slot":"page-title",className:Ne("m-0 text-[20px] font-semibold tracking-tight",e),...t})}function Uq({className:e,...t}){return r.jsx("p",{"data-slot":"page-description",className:Ne("m-0 text-[12.5px] text-muted-foreground",e),...t})}function rke({className:e,...t}){return r.jsx("header",{"data-slot":"window-titlebar","data-tauri-drag-region":"",className:Ne("flex h-8 shrink-0 items-center gap-2.5 overflow-hidden border-b border-sidebar-border bg-sidebar pl-3 text-sidebar-fg select-none",e),...t})}function OP({className:e,action:t,...n}){return r.jsx(B,{"data-slot":"window-control",variant:"ghost",className:Ne("h-8 w-11 rounded-none p-0 shadow-none active:translate-y-0",t==="close"&&"hover:bg-destructive hover:text-white",e),...n})}const Hq="w-auto flex-auto";function Vq({onInput:e,domRef:t,icon:n,className:s,inputClassName:i,...o}){const l=d=>{t.current=d},u=d=>{e?.(d.currentTarget.value)};return n?r.jsxs(zs,{className:Ne(Hq,s),children:[r.jsx(Bs,{ref:l,className:i,onInput:u,...o}),r.jsx(As,{"aria-hidden":"true",children:n})]}):r.jsx(ze,{ref:l,className:Ne(Hq,i),onInput:u,...o})}function ske(e,t){const n=zn.createRoot(e),s={current:null};return n.render(r.jsx(Vq,{domRef:s,defaultValue:t.value,placeholder:t.placeholder,type:t.type??"search",icon:t.icon,"aria-label":t.ariaLabel,onInput:t.onInput})),{setValue(i){const o=s.current;o&&o.value!==i&&(o.value=i)},getValue(){return s.current?.value??""},focus(){s.current?.focus()},unmount(){n.unmount()}}}const ake=[["id","id"],["type","type"],["name","name"],["title","title"],["placeholder","placeholder"],["min","min"],["max","max"],["step","step"],["autocomplete","autoComplete"]];function ike(e){const t={defaultValue:e.value||void 0,inputClassName:e.className||void 0};for(const[l,u]of ake){const d=e.getAttribute(l);d!=null&&(t[u]=d)}const n=e.getAttribute("maxlength");n!=null&&(t.maxLength=Number(n));const s=e.getAttribute("inputmode");s!=null&&(t.inputMode=s),e.hasAttribute("spellcheck")&&(t.spellCheck=e.spellcheck),e.disabled&&(t.disabled=!0),e.readOnly&&(t.readOnly=!0),e.hidden&&(t.hidden=!0);const i=e.getAttribute("aria-label");i!=null&&(t["aria-label"]=i);for(const l of e.getAttributeNames())!l.startsWith("data-")||l.startsWith("data-island-")||(t[l]=e.getAttribute(l)??"");const o=e.getAttribute("data-island-icon");return o!=null&&(t.icon=o),t}function qq(e){if(e.dataset.islandUpgraded)return;e.dataset.islandUpgraded="1";const t=ike(e),n=e.parentElement?.classList.contains("input-affix")?e.parentElement:null;let s;n?(n.className=n.className.replace(/\binput-affix\b/,"").trim(),n.style.display="flex",n.style.alignItems="center",s=n):(s=document.createElement("span"),s.style.display="contents",e.replaceWith(s));const i={current:null},o=zn.createRoot(s);xr.flushSync(()=>{o.render(r.jsx(Vq,{...t,domRef:i}))})}function Kq(e=document){if(e instanceof HTMLInputElement&&e.matches("[data-island-input]")){qq(e);return}e.querySelectorAll("input[data-island-input]").forEach(qq)}function oke(){Kq();const e=new MutationObserver(t=>{for(const n of t)for(const s of n.addedNodes)s instanceof Element&&Kq(s)});return e.observe(document.body,{childList:!0,subtree:!0}),e}function lke(e,t){const n=zn.createRoot(e);let s={options:t.options,value:t.value,ariaLabel:t.ariaLabel,className:t.className};const i=()=>{n.render(r.jsx(en,{options:s.options,value:s.value,onValueChange:t.onChange,"aria-label":s.ariaLabel,className:s.className}))};return i(),{setValue(o){o!==s.value&&(s={...s,value:o},i())},setOptions(o){s={...s,options:o},i()},unmount(){n.unmount()}}}window.wbUiKit={React:wO,createRoot:zn.createRoot,flushSync:xr.flushSync,Badge:Ee,Button:B,Checkbox:jr,Input:ze,Label:Ae,Progress:gg,SegmentedControl:en,Spinner:Qt,Switch:St,Card:et,CardHeader:pn,CardContent:Gt,CardFooter:ju,Collapsible:gs,CollapsibleTrigger:xs,CollapsibleContent:vs,HtmlContent:Wo,Toaster:Lq,toastManager:TP,Select:{Root:Pt,Trigger:Mt,Value:It,Content:_t,Item:Ze,Group:Fje,Label:Uje,Separator:Hje}};function a(e,t){const n=typeof window<"u"?window.wbI18n:void 0;return n&&typeof n.t=="function"?n.t(e,t):e}const ey=Object.freeze({displayName:"Agent2API",logoUrl:null}),cke=2*1024*1024;function Gq(e,t){if(!e||typeof e!="object")throw new Error("品牌设置格式无效");const n=e;if(typeof n.displayName!="string"||!n.displayName.trim()||Array.from(n.displayName).length>64)throw new Error("品牌设置格式无效");let s=null;if(n.logoUrl!==null&&n.logoUrl!==void 0){if(typeof n.logoUrl!="string"||!/^\/api\/panel\/branding\/logo\?v=[a-f0-9]{64}$/.test(n.logoUrl))throw new Error("品牌 Logo 地址无效");s=new URL(n.logoUrl,t).href}return{displayName:n.displayName,logoUrl:s}}function uke(e,t){let n="",s=ey,i=0,o=null;const l=new Set,u=()=>{for(const g of l)g()},d=()=>n===e()?s:ey,f=g=>(i+=1,n=e(),(s.displayName!==g.displayName||s.logoUrl!==g.logoUrl)&&(s=g,u()),g);return{snapshot:d,refresh:()=>{const g=e();if(o?.scope===g)return o.request;n!==g&&(n=g,s=ey,u());const v=++i,b=t().then(y=>(v===i&&e()===g&&f(y),y)).finally(()=>{o?.request===b&&(o=null)});return o={scope:g,request:b},b},accept:f,subscribe(g){return l.add(g),()=>{l.delete(g)}},useValue(){return p.useSyncExternalStore(this.subscribe,d)}}}function dke(e,t,n=!0){p.useEffect(()=>{if(!n)return;const s=()=>{document.hidden||e.refresh().catch(()=>{})};s();const i=window.setInterval(s,6e4);return window.addEventListener("focus",s),document.addEventListener("visibilitychange",s),()=>{window.clearInterval(i),window.removeEventListener("focus",s),document.removeEventListener("visibilitychange",s)}},[e,t,n])}let BS=null,wu=null;function fke(e,t){document.querySelector("title")?.removeAttribute("data-i18n"),document.title=t,BS||(BS=[...document.querySelectorAll('link[rel="icon"]')].map(n=>({element:n,href:n.href,type:n.type,sizes:n.sizes.value})));for(const n of BS)n.element.href=e.logoUrl||n.href,n.element.type=e.logoUrl?"image/png":n.type,n.element.sizes.value=e.logoUrl?"any":n.sizes;!BS.length&&e.logoUrl?(wu||(wu=document.createElement("link"),wu.rel="icon",document.head.appendChild(wu)),wu.type="image/png",wu.href=e.logoUrl):wu&&(wu.remove(),wu=null)}const RP=()=>window.workbuddyDesktop;async function Wq(){const e=RP();if(e?.platform&&e.platform!=="web"){const t=await e.waitForBackend?.();if(!t?.port||!Number.isInteger(t.port)||t.port<1||t.port>65535)throw new Error(a("网关尚未就绪"));return`http://127.0.0.1:${t.port}`}return window.location.origin}const Ng=uke(()=>"local",async()=>{const e=await Wq(),t=await fetch(new URL("/api/panel/branding",e),{cache:"no-store"});if(!t.ok)throw new Error(a("无法读取品牌设置"));const n=await t.json();return Gq(n.data,e)});async function hke(e){const t=RP();if(!t?.saveBranding)throw new Error(a("当前版本不支持品牌设置"));const n=await t.saveBranding(e),s=Gq(n,await Wq());return Ng.accept(s),t.syncBrandingTitle?.().catch(()=>{}),s}function mke(e){const t=Ng.useValue();return dke(Ng,"local"),p.useEffect(()=>{const n=RP(),s=n?.title?.startsWith("[Dev]")?"[Dev] ":"",i=t.displayName==="Agent2API"?n?.title||a("Agent2API · 多提供商本地网关"):`${s}${t.displayName}`;fke(t,i),n?.syncBrandingTitle?.().catch(()=>{})},[t,e]),t}function PP({branding:e,size:t=32,className:n=""}){const[s,i]=p.useState(null);return e.logoUrl&&e.logoUrl!==s?r.jsx("img",{src:e.logoUrl,alt:"","aria-hidden":"true",width:t,height:t,className:`block shrink-0 object-contain ${n}`,style:{width:t,height:t},onError:()=>i(e.logoUrl)}):r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24","aria-hidden":"true",className:`block shrink-0 ${n}`,children:[r.jsx("rect",{width:"24",height:"24",rx:"5.4",fill:"#007AFF"}),r.jsxs("g",{fill:"none",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M5.23 9.24h10.71"}),r.jsx("path",{d:"M15.94 6.72 18.77 9.24 15.94 11.76"}),r.jsx("path",{d:"M18.77 14.76H8.06"}),r.jsx("path",{d:"M8.06 12.24 5.23 14.76 8.06 17.28"})]})]})}function pke(){const e=()=>window.wbZcodeClaimVerification,[t,n]=p.useState(()=>e()?.status()||null);if(p.useEffect(()=>{const i=()=>n(e()?.status()||null);return window.addEventListener("zcode-claim-verification",i),i(),()=>window.removeEventListener("zcode-claim-verification",i)},[]),!t)return null;const s=t.phase==="submitting";return r.jsxs(et,{className:"fixed bottom-5 right-5 z-[2147482900] w-[min(380px,calc(100vw-40px))] space-y-2 p-4 shadow-lg",role:"status","aria-live":"polite",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[r.jsx(Qt,{className:"size-4 shrink-0"}),a("ZCode 自动领取验证")]}),r.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:[t.accountName," · ",t.planName]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:a(s?"验证凭据正在提交,领取结果请查看签到记录":"正在为本次领取验证;若出现滑块,请手动完成")}),r.jsx(B,{variant:"outline",size:"xs",disabled:s,onClick:()=>e()?.cancel(),children:a("取消验证")})]})}const Kd=()=>window;let FS=[],ty="overview",Yq=a("报表"),Xq=localStorage.getItem("workbuddy-desktop-theme")||"system",Qq=[],Zq="";const ku=new Set;let ny=0;const US=()=>{ny+=1;for(const e of ku)e()};function gke({name:e,size:t=17}){return r.jsx("span",{className:"ico shrink-0","aria-hidden":"true",dangerouslySetInnerHTML:{__html:Kd().wbIcons?.icon(e,t)||Kd().wbIcons?.icon("plugins",t)||""}})}function xke(){return p.useSyncExternalStore(e=>(ku.add(e),()=>ku.delete(e)),()=>ny),r.jsx(r.Fragment,{children:FS.length?FS.map((e,t)=>r.jsxs(p.Fragment,{children:[r.jsx(Sg,{className:"nav-group-label",children:Kd().wbSidebarLayout?.groupLabel(e.label)||e.label}),e.items.map(n=>{const s=n.key==="requests"?"nav-count-requests":n.key==="logs"?"nav-count-logs":n.key==="settings"?"nav-count-update":"";return r.jsx(Ts,{className:`nav-item ${ty===n.key?"active":""}`,active:ty===n.key,"data-page":n.key,"data-icon":n.icon,icon:r.jsx(gke,{name:n.icon}),trailing:s?r.jsx(Ee,{id:s,variant:"destructive",shape:"tag",className:"count min-w-5 px-1.5 py-0 text-[10.5px]",style:{display:"none"},children:n.key==="settings"?a("新"):"0"}):void 0,children:r.jsx("span",{className:"label",children:a(n.label)})},n.key)})]},`${e.label}-${t}`)):r.jsx(pt,{className:"nav-empty px-2 py-3 text-[11px]",children:a("侧边栏没有显示任何菜单。到「设置 → 显示 → 侧边栏菜单」里打开需要的项。")})})}function vke(){return p.useSyncExternalStore(e=>(ku.add(e),()=>ku.delete(e)),()=>ny),r.jsx(en,{className:"w-full",value:Xq,"aria-label":a("显示模式"),options:[{value:"system",label:a("跟随系统")},{value:"light",label:a("浅色")},{value:"dark",label:a("深色")}],onValueChange:e=>Kd().wbApp?.applyTheme(e)})}function bke(){p.useSyncExternalStore(t=>(ku.add(t),()=>ku.delete(t)),()=>ny);const e={ok:"success",warn:"warning",bad:"destructive",brand:"brand"};return r.jsx(r.Fragment,{children:Qq.map((t,n)=>r.jsxs(Ee,{variant:e[t.kind]||"outline",className:t.optional?"badge optional":"badge",children:[t.dot&&r.jsx(Yk,{}),t.text]},n))})}function yke(){p.useSyncExternalStore(o=>(ku.add(o),()=>ku.delete(o)),()=>ny);const e=mke(),[t,n]=p.useState(!1),s=bP("(max-width: 767px)");p.useEffect(()=>{s||n(!1),window.dispatchEvent(new Event("wb:shell-layout")),Kd().wbApp?.syncNavBadges()},[s]),p.useEffect(()=>{const o=()=>n(!1);return window.addEventListener("wb:navigation-close",o),()=>window.removeEventListener("wb:navigation-close",o)},[]);const i=r.jsxs($h,{className:"sidebar",children:[r.jsxs($q,{className:"brand",children:[r.jsx("div",{className:"brand-logo",children:r.jsx(PP,{branding:e,size:32})}),r.jsx("div",{className:"brand-text min-w-0",children:r.jsx("h1",{className:"truncate",title:e.displayName,children:e.displayName})})]}),r.jsx(Go,{render:r.jsx(zq,{}),className:"nav",id:"nav","aria-label":a("主导航"),onClick:o=>{const l=o.target.closest(".nav-item[data-page]");l?.dataset.page&&Kd().wbApp?.showPage(l.dataset.page)},children:r.jsx(xke,{})}),r.jsxs(Bq,{className:"sidebar-foot",children:[r.jsx("div",{className:"sidebar-status",id:"sidebar-status",title:a("本地网关监听状态")}),r.jsx("div",{id:"theme-switch",children:r.jsx(vke,{})})]})]});return r.jsxs(nke,{className:"shell","data-navigation-open":t?"true":void 0,children:[s?r.jsx(Qb,{open:t,onOpenChange:n,children:r.jsxs(Zb,{side:"left",keepMounted:!0,showHandle:!1,showCloseButton:!1,"aria-label":a("主导航"),className:"w-[min(280px,86vw)] rounded-none border-0 p-0",children:[r.jsx(uq,{render:r.jsx(B,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 z-10"}),"aria-label":a("关闭菜单"),children:"✕"}),i]})}):i,r.jsxs("main",{className:"main",children:[r.jsxs(zS,{className:"topbar",children:[r.jsx(B,{variant:"ghost",size:"icon",className:"mobile-menu-btn","aria-label":a("切换菜单"),onClick:()=>n(!t),children:"☰"}),r.jsxs("div",{className:"crumb min-w-0",children:[r.jsx("span",{className:"max-w-[200px] truncate",title:e.displayName,children:e.displayName}),r.jsx("span",{className:"sep",children:"/"}),r.jsx("span",{className:"cur",id:"crumb-page",children:Yq})]}),r.jsx("div",{className:"spacer"}),r.jsx("div",{className:"topbar-actions",id:"topbar-status",title:Zq,children:r.jsx(bke,{})}),r.jsx("div",{id:"page-refresh-actions"})]}),r.jsx("div",{className:"content",children:r.jsxs("div",{className:"content-inner",children:[["assistant","overview","accounts","checkin","routing","gateway","agent","tools","proxies","keys","docs","logs","tasks","requests","plugins","settings"].map(o=>r.jsx("section",{className:`page${ty===o?" active":""}`,"data-page":o},o)),r.jsx("section",{className:`page${ty.startsWith("plugin:")?" active":""}`,"data-page":"__plugin__",id:"plugin-page-host"})]})})]}),r.jsx(pke,{})]})}function jke(){const e=document.getElementById("desktop-app");if(!e)return;const t=Kd().wbSidebarLayout;t&&(FS=t.renderGroups(t.readLayout())),Kd().wbShell={sidebar(s){FS=s,xr.flushSync(US)},page(s,i){ty=s,Yq=i,US()},status(s,i=""){Qq=s,Zq=i,US()},theme(s){Xq=s,US()},closeNavigation(){window.dispatchEvent(new Event("wb:navigation-close"))},toast(s,i="ok"){TP.add({id:"desktop-feedback",title:s,type:i==="err"?"error":i==="warn"?"warning":"success",timeout:3500})}},xr.flushSync(()=>zn.createRoot(e).render(r.jsx(yke,{})));const n=document.createElement("div");document.body.append(n),xr.flushSync(()=>zn.createRoot(n).render(r.jsx(Lq,{})))}jke();const Jq="wb-tip-bubble",IP=new WeakSet;let es=null,Cg=!1,ry=0,HS=0,eK=0;const MP=new Set,_P=()=>{eK+=1;for(const e of MP)e()},DP=e=>({text:e.getAttribute("data-tip")?.trim()||"",variant:e.getAttribute("data-tip-variant")});let VS=null;function qS(e){const t=e.getBoundingClientRect();return e.isConnected&&t.width>0&&t.height>0&&t.bottom>0&&t.top{es&&!qS(es)&&Il()})),VS?.observe(e),es.classList.add("active"),es.setAttribute("aria-describedby",Jq),_P())}function wke(){p.useSyncExternalStore(t=>(MP.add(t),()=>MP.delete(t)),()=>eK);const e=es?DP(es):null;return r.jsx(pS,{children:r.jsx(pc,{open:!!es,disableHoverablePopup:!0,onOpenChange:t=>{!t&&!Cg&&Il()},children:r.jsx(gc,{id:Jq,anchor:es,side:"bottom",variant:e?.variant==="plain"?"plain":"default",className:"pointer-events-none",children:e?.text.split(` +`).map((t,n)=>{const s=/^\[(#[0-9a-fA-F]{3}|#[0-9a-fA-F]{6})\]/.exec(t);return r.jsxs("span",{className:"flex items-start gap-1.5",children:[s&&r.jsx("span",{className:"mt-1 size-1.5 shrink-0 rounded-full",style:{background:s[1]}}),r.jsx("span",{children:s?t.slice(s[0].length):t})]},n)})})})})}function LP(e){IP.has(e)||!DP(e).text||(IP.add(e),e.classList.contains("tip-q")&&!e.textContent?.trim()&&(e.textContent="?"),e.matches("a[href], button, input, select, textarea, [tabindex]")||e.setAttribute("tabindex","0"))}function tK(){const e=document.createElement("div");document.body.append(e),xr.flushSync(()=>zn.createRoot(e).render(r.jsx(wke,{})));const t=o=>{o.matches("[data-tip]")&&LP(o),o.querySelectorAll("[data-tip]").forEach(LP)};t(document.body),new MutationObserver(o=>{es&&!qS(es)&&Il();for(const l of o){l.type==="attributes"&&l.target instanceof Element&&(LP(l.target),l.target===es&&_P());for(const u of l.addedNodes)u instanceof Element&&t(u)}}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tip","data-tip-variant"]});const s=o=>o.target instanceof Element?o.target.closest("[data-tip]"):null;document.addEventListener("pointerover",o=>{if(!window.matchMedia("(hover: hover)").matches)return;const l=s(o);!l||o.relatedTarget instanceof Node&&l.contains(o.relatedTarget)||(window.clearTimeout(HS),window.clearTimeout(ry),ry=window.setTimeout(()=>KS(l),es?0:150))}),document.addEventListener("pointerout",o=>{const l=s(o);!l||o.relatedTarget instanceof Node&&l.contains(o.relatedTarget)||Cg||(window.clearTimeout(ry),HS=window.setTimeout(()=>{es===l&&!Cg&&Il()},80))}),document.addEventListener("focusin",o=>{const l=s(o);l?.matches(":focus-visible")&&KS(l)}),document.addEventListener("focusout",o=>{s(o)===es&&Il()}),document.addEventListener("click",o=>{const l=s(o);if(!l){es&&Il();return}es===l&&Cg?Il():(KS(l),Cg=!0)},!0),document.addEventListener("keydown",o=>{o.key==="Escape"&&es&&Il()});const i=()=>{es&&!qS(es)&&Il()};window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),window.wbTooltip={open:KS,close:Il,enhanced:o=>IP.has(o)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",tK,{once:!0}):tK();const Gd=window.workbuddyDesktop;function $P({action:e,maximized:t=!1}){return r.jsx("svg",{viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="minimize"?r.jsx("path",{d:"M5 12h14"}):e==="close"?r.jsx("path",{d:"M6 6l12 12M18 6 6 18"}):t?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:8.5,y:4.5,width:11,height:11,rx:1.5}),r.jsx("rect",{x:4.5,y:8.5,width:11,height:11,rx:1.5,className:"fill-sidebar"})]}):r.jsx("rect",{x:5.5,y:5.5,width:13,height:13,rx:1.5})})}function kke({api:e}){const t=Ng.useValue(),[n,s]=p.useState(!1),i=p.useCallback(async()=>{try{e.windowIsMaximized&&s(await e.windowIsMaximized())}catch{}},[e]);p.useEffect(()=>{i();const u=e.onWindowResize?.(()=>{i()});return typeof u=="function"?u:void 0},[e,i]);const o=e.platform==="macos",l=t.displayName==="Agent2API"?e.title||a("Agent2API · 多提供商本地网关"):`${e.title?.startsWith("[Dev]")?"[Dev] ":""}${t.displayName}`;return r.jsxs(rke,{className:o?"titlebar is-macos pl-[84px] pr-3.5":"titlebar",children:[r.jsxs("div",{className:"titlebar-brand pointer-events-none flex min-w-0 items-center gap-2 text-[12.5px] font-semibold [&_*]:pointer-events-none",children:[r.jsx(PP,{branding:t,size:16}),r.jsx("span",{className:"txt truncate",children:l})]}),!o&&r.jsxs("div",{className:"ml-auto flex h-full shrink-0",children:[r.jsx(OP,{action:"minimize",title:a("最小化"),"aria-label":a("最小化"),onClick:()=>{e.windowMinimize?.().catch(()=>{})},children:r.jsx($P,{action:"minimize"})}),r.jsx(OP,{action:"maximize",title:a(n?"还原":"最大化"),"aria-label":a(n?"还原":"最大化"),onClick:async()=>{try{await e.windowToggleMaximize?.(),await i()}catch(u){console.warn("切换窗口大小失败:",u)}},children:r.jsx($P,{action:"maximize",maximized:n})}),r.jsx(OP,{action:"close",title:a("关闭"),"aria-label":a("关闭"),onClick:()=>{e.windowClose?.().catch(()=>{})},children:r.jsx($P,{action:"close"})})]})]})}function Ske(){if(!document.getElementById("desktop-app")||!Gd?.platform||Gd.platform==="web"||Gd.platform!=="macos"&&(!Gd.windowMinimize||!Gd.windowToggleMaximize||!Gd.windowClose))return;const e=document.createElement("div");document.body.prepend(e),document.body.classList.add("has-titlebar"),document.title=Gd.title||a("Agent2API · 多提供商本地网关"),zn.createRoot(e).render(r.jsx(kke,{api:Gd}))}Ske();const Su=999;function zP(e){const t=e.resolved||e;if(t.protocol&&t.host&&t.port){const n=t.host.includes(":")&&!t.host.startsWith("[")?`[${t.host}]`:t.host;return`${String(t.protocol).toLowerCase()}://${n}:${t.port}`}return e.resolved?.label||""}function Ag(e){const t=e.name||e.id,n=[e.source==="clash"?"Clash Verge":"",e.resolveError?a("解析失败"):zP(e),e.enabled===!1?a("已禁用"):""].filter(Boolean);return n.length?a("{name}({parts})",{name:t,parts:n.join(" · ")}):t}const vc="pool:";function ft(){return window}function Ct(e,t){ft().wbApp?.toast?.(e,t)}function Yo(e){const t=ft().wbApp?.esc;return t?t(e):String(e??"").replace(/[&<>"']/g,n=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[n]||n)}function ki(e){const t=ft().wbApp?.formatTime;if(t)return t(e);const n=Number(e);return!Number.isFinite(n)||n<=0?"":new Date(n).toLocaleString("zh-CN")}function dn(e){return e instanceof Error?e.message:String(e)}function Ln(e){if(e==null||e==="")return"—";const t=Number(e);return Number.isFinite(t)?String(Number(t.toFixed(2))):String(e)}const Nke={workbuddy:{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!0,identifier:["uid"],expiry:["expiresAt"]},"workbuddy-intl":{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!1,identifier:["uid"],expiry:["expiresAt"]},raccoon:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"]},catpaw:{usage:!0,edition:!1,identifier:["uid"],expiry:["tokenExpiresAt"]},autoclaw:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"]},"autoclaw-intl":{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"],emailAsName:!0},qoder:{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"qoder-intl":{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},qwenwork:{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"qwenwork-intl":{usage:!0,creditDetail:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"cline-free":{usage:!0,edition:!1,identifier:["account"],expiry:["expiresAt"]},"cline-pass":{usage:!0,edition:!1,identifier:["account"],expiry:["expiresAt"]},accio:{usage:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},"accio-cn":{usage:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"],emailAsName:!0},zcode:{usage:!0,creditDetail:!0,claim:!0,planChannel:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"]},"zcode-intl":{usage:!0,creditDetail:!0,claim:!0,planChannel:!0,edition:!0,identifier:["userId"],expiry:["expiresAt"]},codearts:{usage:!0,usageDetail:!0,edition:!1,identifier:["userId"],expiry:["expiresAt"],concurrencyDefault:3},trae:{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!1,identifier:["uid"],expiry:["expiresAt"]},loomy:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:[""]},kuku:{usage:!0,edition:!1,identifier:["uid"],expiry:[""]},officeace:{usage:!0,creditDetail:!0,creditExpiry:!0,edition:!1,identifier:["id"],expiry:["expiresAt"]},antigravity:{usage:!0,edition:!1,identifier:["userId"],expiry:[""],longLived:!0},chatglm:{usage:!0,creditDetail:!0,edition:!1,identifier:["uid"],expiry:[""],longLived:!0},modelscope:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:[""],longLived:!0},"modelscope-intl":{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:[""],longLived:!0},atomcode:{usage:!0,edition:!1,identifier:["userId"],expiry:["expiresAt"]},commandcode:{usage:!1,edition:!1,identifier:["id"],expiry:[""],longLived:!0},lobsterai:{usage:!0,creditDetail:!0,edition:!1,identifier:["userId"],expiry:["expiresAt"]},monkeycode:{usage:!1,edition:!1,identifier:["userId"],expiry:["expiresAt"]},"monkeycode-intl":{usage:!1,edition:!1,identifier:["userId"],expiry:["expiresAt"]},orcaterm:{usage:!0,edition:!1,identifier:["uid"],expiry:["tokenExpireAt"]}},GS={usage:!1,edition:!1,identifier:["userId"],expiry:["tokenExpiresAt"],emailAsName:!1};let nK=new Map,rK=null;function Cke(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=new Map;for(const[n,s]of Object.entries(e))!n||!s||typeof s!="object"||Array.isArray(s)||t.set(n,Eke(s));nK=t}function Ake(){const e=ft().wbApp?.getState?.()?.accountFeatures;return e!==rK&&(rK=e,Cke(e)),nK}function Eke(e){return{usage:e.usage===!0,edition:e.edition===!0,identifier:sK(e.identifier,GS.identifier),expiry:sK(e.expiry,GS.expiry),longLived:e.long_lived===!0,emailAsName:e.email_as_name===!0,claim:e.claim===!0,planChannel:e.plan_channel===!0,usageDetail:e.usage_detail===!0,creditDetail:e.credit_detail===!0,creditExpiry:e.credit_expiry===!0,concurrencyDefault:Number(e.concurrency_default)>0?Number(e.concurrency_default):void 0,defaultLimiters:Tke(e.default_limiters)}}function sK(e,t){if(typeof e=="string")return e?[e]:[];if(!Array.isArray(e))return t;const n=e.filter(s=>typeof s=="string"&&s.length>0);return n.length?n:[]}function Tke(e){if(!Array.isArray(e))return;const t=[];for(const n of e){if(!n||typeof n!="object"||Array.isArray(n))continue;const s=n,i=Number(s.threshold);if(!Number.isFinite(i)||i<=0)continue;const o=s.kind==="token"?"token":s.kind==="balance"?"balance":null;if(!o)continue;const l=s.action==="disable"?"disable":"skip",u=Number(s.period_seconds),d=o==="token"&&Number.isFinite(u)&&u>0;t.push({type:o,action:l,threshold:i,enabled:!0,...d?{period:u,reset:"fixed"}:{},...o==="token"&&!d?{reset:"daily"}:{}})}return t}function Ga(e){if(!e)return GS;const t=Ake().get(e);return t||Nke[e]||GS}function Oke(e,t){const n=Ui(e);if(!n)return null;const s=Object.prototype.hasOwnProperty.call(n,"totalLeft"),o=(Array.isArray(n.quotaSources)?n.quotaSources:[]).map(Ui).find(f=>f?.id==="account"),l=String(n.unit||o?.unit||(s?"积分":"")).trim(),u=Os(s?n.totalLeft:n.available),d=n.unlimited===!0;return u===null&&!d?null:{label:zh(l)?t("总积分"):t("可用合计"),unit:mo(l,t),remaining:u,unlimited:d}}function Ui(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function aK(e,t){const n=Ui(e);if(n?.empty!==!0||n.error)return null;const s=n.emptyText==="暂无可用积分信息"?t("暂无可用积分信息"):typeof n.emptyText=="string"?t(n.emptyText.trim()):"";return{text:t("暂无额度信息"),detail:[s,t("查询已成功,但上游未提供额度数据,不代表余额为零。")].filter(Boolean).join(" · ")}}function Os(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;const t=Number(e);return Number.isFinite(t)?t:null}function iK(e){const t=Ui(e);return t?.snapshot===!0||t?.type==="magicubes"}function BP(e){const t=Ui(e);if(!t)return[];const n=Array.isArray(t.credits)?t.credits.filter(i=>Ui(i)):[];return Array.isArray(t.wallets)&&t.wallets.some(i=>Ui(i)?.type==="magicubes")?n.map(i=>{if(i.snapshot===!0||i.record===!0)return i;const{remain:o,...l}=i;switch(i.name){case"可用魔粒":return{...l,key:"available",name:"可用余额",balance:o,unit:"魔粒",snapshot:!0};case"冻结魔粒":return{...l,key:"frozen",name:"冻结余额",balance:o,unit:"魔粒",snapshot:!0};case"今日已用(次)":return{...l,key:"used-today",name:"今日已用",used:i.used??o,unit:"次",daily:!0,snapshot:!0};default:return i}}):n}function zh(e){return e.trim()==="积分"||e.trim().toLowerCase()==="credits"}function mo(e,t){if(zh(e))return t("积分");switch(e){case"额度":return t("额度");case"魔粒":return t("魔粒");case"次":return t("次");case"copilot_quota_units":return t("Copilot 额度单位");default:return e}}function oK(e,t){switch(e){case"Premium requests":return t("高级请求");case"Chat requests":return t("对话请求");case"Completions":return t("补全请求");default:return typeof e=="string"?t(e):""}}function lK(e,t,n){const s=typeof e.view=="string"?e.view.trim():"",i=Os(e.remaining),o=Os(e.limit),l=Os(e.remainingPercent),u=typeof e.unit=="string"?mo(e.unit,t):"";return e.unlimited===!0&&(!s||s==="不限")?t("不限"):i!==null&&(!s||/^剩余 [-+\d.eE]+(?: \/ [-+\d.eE]+)?(?: .+)?$/.test(s))?[o===null?t("剩 {remaining}",{remaining:n(i)}):t("剩 {remaining} / {total}",{remaining:n(i),total:n(o)}),u].filter(Boolean).join(" "):l!==null&&(!s||/^剩余 [-+\d.]+%$/.test(s))?t("剩余 {percent}%",{percent:Math.round(Math.max(0,Math.min(100,l)))}):s?t(s):"—"}function cK(e,t,n){if(e.snapshot!==!0)return null;const s=Os(e.used),i=s??Os(e.balance)??Os(e.remain),o=String(e.unit||"").trim(),l=String(e.name||"").trim(),u=l==="可用余额"?t("可用余额"):l==="冻结余额"?t("冻结余额"):l==="今日已用"?t("今日已用"):l==="今日发放"?t("今日发放"):l||t("明细"),d=i===null?"—":o==="次"?t("{count} 次",{count:n(i)}):o?`${n(i)} ${mo(o,t)}`:n(i);return{name:u,view:d,tone:s!==null||e.key==="frozen"||i===null||i<=0?"muted":"ok",daily:e.daily===!0}}function Rke(e,t,n){return BP(e).map(s=>cK(s,t,n)).filter(s=>s!==null)}function uK(e){const t=Ui(e);return!Array.isArray(t?.wallets)||!t.wallets.some(n=>String(Ui(n)?.type||"").startsWith("meter:"))?null:t.wallets.map(Ui).filter(n=>n!==null&&(n.creditRemaining!=null||n.creditTotal!=null||n.creditUsed!=null))}function FP(e,t,n){const s=Ui(e);if(!s)return[];const i=[],o=Ui(s.subscription);typeof o?.planName=="string"&&o.planName.trim()&&i.push(t("套餐 {name}",{name:o.planName})),typeof s.balanceView=="string"&&s.balanceView.trim()&&i.push(t(s.balanceView));for(const l of uK(s)??(Array.isArray(s.wallets)?s.wallets:[])){const u=Ui(l);if(!u)continue;const d=typeof u.balanceView=="string"&&u.balanceView.trim()?t(u.balanceView):Os(u.balance)===null?"":n(Os(u.balance));if(!d)continue;const f=typeof u.displayName=="string"?t(u.displayName):typeof u.type=="string"?u.type:t("明细");i.push([f,d].filter(Boolean).join(" "))}return[...new Set(i)]}function WS(e){const t=Ui(e);return Array.isArray(t?.warnings)?t.warnings.filter(n=>typeof n=="string"&&!!n.trim()):[]}let Bh={};function Pke(e){if(!e?.limiterStates)return!1;const t=JSON.stringify([Bh.limiterStates,Bh.quotaSources,Bh.limiterModels])!==JSON.stringify([e.limiterStates,e.quotaSources,e.limiterModels]);return Bh={tokenAt:e.tokenAt,limiterStates:e.limiterStates,quotaSources:e.quotaSources,limiterModels:e.limiterModels},t}function sy(e,t=[]){return Array.isArray(e?.limiterGroups)?e.limiterGroups:t.map(n=>({enabled:n.enabled!==!1,action:n.action,target:"account",conditions:[{join:"or",sourceId:"",models:[],threshold:n.threshold,metric:n.type==="balance"?"remaining":"tokens",comparison:n.type==="balance"?"lt":"gte",...n.type==="token"?{window:{reset:n.reset==="daily"?"daily":"fixed",seconds:n.period||0}}:{}}]}))}function UP(e){const t=e?Bh.quotaSources?.[e.id]:void 0;return Array.isArray(t)?t.slice():[{id:"account",label:a("账号主额度"),provider:String(e?.provider||"")},{id:"local",label:a("本地用量保护"),provider:String(e?.provider||""),localOnly:!0}]}function Ike(e){const t=String(e?.provider||"");return(Bh.limiterModels?.[t]||[]).map(s=>({value:s.id,label:s.name&&s.name!==s.id?`${s.name}(${s.id})`:s.id}))}function HP(e){return e?Bh.limiterStates?.[e.id]||[]:[]}function ay(e,t,n="skip"){if(!e)return!1;const s=sy(e),i=HP(e);return s.some((o,l)=>o.enabled&&o.action===n&&i[l]?.hit&&(!t||o.conditions.some(u=>t==="token"?u.metric==="tokens"||u.metric==="requests":u.metric!=="tokens"&&u.metric!=="requests")))}function VP(e,t=e?.id||"account"){return t==="local"?a("本地用量保护"):t==="account"||!t?zh(e?.unit||"")?a("总积分"):a("账号主额度"):e?.label?a(e.label):a("账号主额度")}function dK(e){const{remaining:t,total:n,used:s,remainingPercent:i,resetsAt:o,...l}=e;return l}function fK(e,t){const n=e.sourceId||(e.metric==="tokens"||e.metric==="requests"?"local":"account"),s=UP(t).find(m=>m.id===n),i=VP(s||e.source,n),o=e.models.length?e.models.join("、"):a("全部模型"),l=qP(e.metric),u=e.comparison==="lt"?"<":e.comparison==="lte"?"≤":"≥",d=e.metric.endsWith("percent")?"%":e.metric==="tokens"?"Token":e.metric==="requests"?a("次"):mo(s?.unit||e.source?.unit||"",a),f=e.metric==="tokens"?hK(e.threshold):String(e.threshold);return`${i} · ${o} · ${l} ${u} ${f} ${d}`.trim()}function qP(e){switch(e){case"remaining":return a("剩余额度");case"remaining_percent":return a("剩余比例");case"used":return a("已用额度");case"used_percent":return a("已用比例");case"tokens":return a("本地 Token 消耗");case"requests":return a("本地请求次数")}}function hK(e){return window.wbUnits?.formatTokens?.(e)||e.toLocaleString()}function Mke(e,t,n){if(!e?.known||e.value===null)return _ke(e?.reason);const s=UP(n).find(u=>u.id===(t.sourceId||"account")),i=mo(s?.unit||t.source?.unit||"",a),o=u=>t.metric==="tokens"?`${hK(u)} Token`:t.metric.endsWith("percent")?`${Number(u.toFixed(2))}%`:`${Number(u.toFixed(2))} ${t.metric==="requests"?a("次"):i}`.trim(),l=Object.entries(e.modelValues||{});return l.length?l.map(([u,d])=>`${u}:${o(d)}`).join(" · "):o(e.value)}function _ke(e){switch(e){case"此额度不属于账号当前使用的通道":return a("此额度不属于账号当前使用的通道");case"套餐尚未生效或已经到期":return a("套餐尚未生效或已经到期");case"上游额度无上限":return a("上游额度无上限");case"统计周期尚未开始或已经结束":return a("统计周期尚未开始或已经结束");default:return a("暂无读数")}}function Dke(e,t){const n=[];return e.forEach((s,i)=>{(i===0||s.join==="or")&&n.push([]),n[n.length-1].push(fK(s,t))}),n.map(s=>s.length>1?`(${s.join(` ${a("与")} `)})`:s[0]).join(` ${a("或")} `)}function mK(e){return e.desktop!==!0&&(e.canRefresh===!0||e.hasRefreshToken===!0)}function KP(e){return e.desktop===!0?a("桌面端实时登录态请在原客户端更新"):e.needsRelogin===!0?iy(e):mK(e)?"":a("该账号不支持刷新 Token 或未提供刷新凭证")}function iy(e){return e.needsReloginReason?.trim()||a("登录授权已失效,请重新登录;自动续期无法恢复已过期或已撤销的刷新令牌。")}function pK(e,t=Date.now()){const n=Number(e?.upstreamCooldownUntil);return!Number.isFinite(n)||n<=t||n>864e13?null:{resetAt:n,message:String(e?.upstreamBlockedReason||"").trim()}}function gK(e){return e?.enabled===!1?String(e.upstreamBlockedReason||"").trim():""}function GP(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function xK(e){return typeof e=="string"?e.trim():""}function vK(e){const t=GP(e);if(t?.stale)return{remaining:null,unit:"",unlimited:!1};const n=t?.error?GP(t.lastUsage):t,s=!!(n&&Object.prototype.hasOwnProperty.call(n,"totalLeft")),o=(Array.isArray(n?.quotaSources)?n.quotaSources:[]).map(GP).find(g=>g?.id==="account"),l=xK(n?.unit)||xK(o?.unit)||(s?"积分":""),u=/^(credits?|积分)$/i.test(l)?"积分":l,d=s?n?.totalLeft:n?.available,f=!!n?.unlimited;return{remaining:!f&&typeof d=="number"&&Number.isFinite(d)?d:null,unit:u,unlimited:f}}function WP(e){return!e||e.unlimited||!e.unit||e.unit==="%"?null:typeof e.remaining=="number"&&Number.isFinite(e.remaining)?e.remaining:null}function bK(e){const t=new Set(e.filter(n=>WP(n)!==null).map(n=>n.unit));return t.size>1?"mixedUnits":t.size?"ready":"noData"}const YP=30,yK=86400,Lke=60,$ke=3,YS=10,XS=60,XP=180;function jK(e){const t=e?.usageQuery,n=t?.enabled===void 0?!0:t.enabled===!0,s=Number(t?.interval)||0,i=s>=YP&&s<=yK,o=t?.retries;return{enabled:n,interval:n&&!i?Lke:s,retries:typeof o=="number"&&Number.isInteger(o)&&o>=0&&o<=YS?o:$ke,timeoutSeconds:typeof t?.timeoutSeconds=="number"&&Number.isInteger(t.timeoutSeconds)&&t.timeoutSeconds>=15&&t.timeoutSeconds<=XP?t.timeoutSeconds:XS}}const QP="workbuddy",zke="raccoon";function tn(e){const t=e?.provider;return typeof t=="string"&&t?t:QP}const Bke="opencode",Fke="https://opencode.ai/zen/go/v1";function wK(e,t){if(!e||e.clientEmulation!==Bke)return!1;const s=((typeof t=="string"?t.trim():"")||String(e.baseUrl||"")).trim().replace(/\/+$/,"").toLowerCase();return s?s!==Fke:!1}function Uke(e){const t=e?tn(e):"";return t.startsWith("custom-")&&(ft().wbProviders?.customList?.()||[]).find(s=>s?.id===t)||null}function Hke(e){return e?wK(Uke(e),e.baseUrl):!1}function kK(e){const t=Array.isArray(e?.providers)?e.providers:[],n=Array.isArray(e?.accounts)?e.accounts:[],s=new Map;n.forEach(o=>{const l=tn(o);s.set(l,(s.get(l)||0)+1)});const i=new Map;return t.forEach(o=>{o?.id&&i.set(String(o.id),{id:String(o.id),label:String(o.label||o.id),count:Number(o.count)||0})}),s.forEach((o,l)=>{i.has(l)||i.set(l,{id:l,label:ft().wbProviders?.labelOf?.(l)||l,count:o})}),[...i.values()]}function QS(e){return qke(e,Ga(tn(e)).identifier)}function Vke(e){for(const t of Ga(tn(e)).identifier){const n=e?.[t];if(!(n==null||n===""))return t}return""}function qke(e,t){for(const n of t){const s=e?.[n];if(!(s==null||s===""))return String(s)}return""}function SK(e){const t=Number(e)||0;return t<=0?0:t<1e11?t*1e3:t}function NK(e){const t=Ga(tn(e)).expiry;for(const n of t){const s=SK(e?.[n]);if(s>0)return s}return 0}function Si(e){if(e?.isGuest===!0)return!1;const t=tn(e);return t.startsWith("custom-")?!!e?.balanceQuery?.scheme:Ga(t).usage}const Kke=1800,Gke=86400,CK=1;function Wke(e){const t=e?Ga(e).defaultLimiters:void 0;return t&&(e!=="codearts"||t.every(n=>n.type==="balance"))?t.slice():e==="cline-free"?[]:[{type:"balance",action:"skip",threshold:CK,enabled:!0}]}function Yke(e){if(!e||typeof e!="object")return!1;const t=e;if(t.type!=="balance"&&t.type!=="token"||t.action!=="skip"&&t.action!=="disable")return!1;const n=Number(t.threshold);if(!Number.isFinite(n)||n<=0)return!1;if(t.type==="token"&&t.reset!=="daily"){const s=Number(t.period);if(!Number.isInteger(s)||sGke)return!1}return!0}function Xke(e){const t=e?.lowBalance;if(!t||typeof t!="object"||!t.mode)return Wke(tn(e));const n=Number(t.threshold),s=Number.isFinite(n)&&n>0?n:CK;return t.mode!=="skip"&&t.mode!=="disable"?[]:[{type:"balance",action:t.mode,threshold:s,enabled:!0}]}function Fh(e){const t=e?.limiters;return Array.isArray(t)?t.filter(Yke):Xke(e)}function Qke(e){return Fh(e).filter(t=>t.type==="token")}function Zke(e,t){const n=t*1e3;return e-e%n}function AK(e){return e.reset==="daily"?0:e.period??0}function ZP(e,t=Date.now()){if(e===0){const n=new Date(t);return n.setHours(0,0,0,0),n.getTime()}return Zke(t,e)}function JP(e,t,n=Date.now()){if(e.type!=="token")return null;const s=AK(e),i=(t||[]).find(o=>Number(o.kind)===s);return i&&Number(i.windowStart)===ZP(s,n)?i:null}function eI(e,t){if(t&&typeof t=="object"&&t.stale)return!1;if(Array.isArray(e?.limiterGroups))return ay(e,"balance");const n=Fh(e).filter(l=>l.type==="balance"&&l.action==="skip"&&l.enabled!==!1&&l.threshold>0);if(!n.length||!t||typeof t!="object")return!1;const s=t;if(s.unlimited)return!1;const i=s.totalLeft??s.available;if(i==null||i==="")return!1;const o=Number(i);return Number.isFinite(o)&&n.some(l=>oi.type==="token"&&i.action==="skip"&&i.enabled!==!1);if(!n.length||!t?.length)return!1;const s=Date.now();return n.some(i=>{const o=JP(i,t,s);return o!==null&&Number(o.used)>=i.threshold})}function Jke(e,t){return Array.isArray(e?.limiterGroups)?ay(e,"token","disable"):Fh(e).some(n=>{if(n.type!=="token"||n.action!=="disable"||n.enabled===!1)return!1;const s=JP(n,t);return s!==null&&Number(s.used)>=n.threshold})}function eSe(e,t=Date.now()){const n=AK(e),s=ZP(n,t),i=n===0?Math.max(0,ZP(0,s+864e5+36e5)-t):Math.max(0,s+n*1e3-t);return{kind:n,startMs:s,remainingMs:i,daily:n===0}}function EK(e,t){if(e<=0)return"";const n=Math.ceil(e/6e4);if(t){const s=Math.ceil(e/36e5);return s>=1?a("今日剩 {n} 小时",{n:s}):a("今日剩 {n} 分钟",{n})}return n>=1?a("剩 {n} 分钟",{n}):a("剩不到 1 分钟")}function TK(e){const t=Number(e);if(!Number.isFinite(t))return"—";const n=window.wbUnits;return n?.formatTokens?n.formatTokens(t):String(Math.round(t))}function tSe(e){return e>0&&e%3600===0?a("{n} 小时",{n:e/3600}):e>0&&e%60===0?a("{n} 分钟",{n:e/60}):a("{n} 秒",{n:e})}function oy(e){return e?.desktop===!0}function OK(e){return e?.chatSupported!==!1}function nSe(e){return typeof e=="string"&&e.startsWith("custom-")}function rSe(e){return a(e==="enterprise"?"企业":e==="ultimate"?"旗舰":"个人")}function ZS(e,t){const n=Number(e?.priority??100)-Number(t?.priority??100);return n!==0?n:(Number(e?.addedAt)||0)-(Number(t?.addedAt)||0)}function Ni(e){return e?.enabled!==!1}function ly(e,t=""){if(pK(e))return!0;const n=e?.rateLimits||{},s=Date.now();return t?Number(n[t]?.resetAt)>s:Object.values(n).some(i=>Number(i?.resetAt)>s)}function RK(e){return e?.edition==="intl"?"intl":"cn"}const PK="coding-plan",Uh="start-plan";function JS(e){return!!Ga(tn(e)).planChannel}function nI(e){return JS(e)?String(e?.zcodePlan||"").trim()===Uh?Uh:PK:""}function sSe(e){return a(e===Uh?"套餐池(Start Plan)":"编码套餐(Coding Plan)")}function rI(e){switch(String(e??"").trim()){case"pending":return a("待生效");case"active":return a("生效中");case"expired":return a("已过期");case"unknown":return a("状态未知");default:return String(e??"")}}function aSe(e){const t=e?.claimPlans;if(!t||typeof t!="object"||Array.isArray(t))return[];const n=_K();return Object.entries(t).filter(([,s])=>Number(s)>0&&_K(Number(s))===n).map(([s])=>s)}function iSe(e){return!!Ga(tn(e)).usageDetail}function sI(e){return!!Ga(tn(e)).creditDetail}function IK(e,t=Date.now()){if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e,s=Array.isArray(n.credits)?n.credits:[];let i=null;for(const o of s){if(!o||typeof o!="object"||o.snapshot===!0||o.record===!0||o.daily===!0||o.unlimited===!0)continue;const l=Number(o.expireAt);if(!Number.isFinite(l)||l<=0||l<=t)continue;const u=o.remain;u!=null&&u!==""&&Number(u)<=0||(i===null||lString(i||"").toLowerCase().includes(n)):!0}function LK(e,t){return t.provider==="all"||tn(e)===t.provider}function iI(e,t){return t.enabled==="all"?!0:t.enabled==="enabled"?Ni(e):!Ni(e)}function $K(e,t,n,s){if(t.limit==="all")return!0;if(!Ni(e))return!1;const i=cy(e,n?.(e),s?.(e));return t.limit==="limited"?i:!i}function zK(e,t,n,s){return LK(e,t)&&iI(e,t)&&$K(e,t,n,s)&&DK(e,t)}function oSe(e,t,n,s){return(e||[]).filter(i=>zK(i,t,n,s))}function BK(e,t,n,s){const i=e||[],o=d=>i.filter(f=>LK(f,t)&&(d==="enabled"||iI(f,t))&&DK(f,t)),l=o("enabled"),u=o("limit");return{enabledAll:l.length,enabled:l.filter(Ni).length,disabled:l.filter(d=>!Ni(d)).length,limitAll:u.length,normal:u.filter(d=>Ni(d)&&!cy(d,n?.(d),s?.(d))).length,limited:u.filter(d=>Ni(d)&&cy(d,n?.(d),s?.(d))).length}}function oI(e){const t=e?.rateLimits;if(!t||typeof t!="object")return[];const n=Date.now();return Object.entries(t).map(([s,i])=>({model:s,...i&&typeof i=="object"?i:{}})).filter(s=>Number(s.resetAt)>n).sort((s,i)=>Number(s.resetAt)-Number(i.resetAt))}function lI(e,t){const n=new Map((t?.providerOrder||[]).flatMap(o=>t?.accountOrder[o]||[]).map((o,l)=>[o,l])),s=(e||[]).slice().sort(n.size?(o,l)=>(n.get(o.id)??1/0)-(n.get(l.id)??1/0):ZS),i=new Map;return s.forEach((o,l)=>i.set(o.id,{position:l+1,total:s.length})),i}function FK(e){return[{key:"credit",on:Eg(e),dir:"soon"},{key:"balance",on:!1,dir:"high"},{key:"added",on:!1,dir:"new"}]}function lSe(e,t,n,s=Date.now()){const i=(t||[]).filter(f=>f.on);if(!i.length)return e.slice();const o=e.map((f,m)=>({account:f,index:m})),l=new Map,u=new Map(e.map(f=>[f.id,vK(n?.(f))])),d=bK([...u.values()])==="ready";for(const{account:f}of o)l.set(f.id,IK(n?.(f),s));return o.sort((f,m)=>{for(const g of i){let v=0;if(g.key==="added"?v=cSe(g.dir,f.account,m.account):g.key==="credit"?v=UK(g.dir,l.get(f.account.id)??null,l.get(m.account.id)??null):g.key==="balance"&&d&&(v=UK(g.dir==="high"?"late":"soon",WP(u.get(f.account.id)),WP(u.get(m.account.id)))),v!==0)return v}return f.index-m.index}),o.map(f=>f.account)}function cSe(e,t,n){const s=Number(t.addedAt)||0,i=Number(n.addedAt)||0;return e==="new"?i-s:s-i}function UK(e,t,n){return t===null&&n===null?0:t===null?1:n===null?-1:e==="soon"?t-n:n-t}function uSe(e,t,n,s,i,o){const l=(e||[]).slice().sort(ZS),u=[],d=new Map;for(const f of l){const m=tn(f);d.has(m)||(d.set(m,[]),u.push(m)),d.get(m).push(f)}if(o){const f=new Map(o.providerOrder.map((m,g)=>[m,g]));u.sort((m,g)=>(f.get(m)??1/0)-(f.get(g)??1/0))}return u.map((f,m)=>{const g=d.get(f)||[],v=o?.accountOrder[f],b=new Map((v||[]).map((k,w)=>[k,w])),y=v?g.slice().sort((k,w)=>(b.get(k.id)??1/0)-(b.get(w.id)??1/0)):i?lSe(g,i(f),n):g;return{provider:f,label:ft().wbProviders?.labelOf?.(f)||f,rank:o?.providerOrder.includes(f)?o.providerOrder.indexOf(f)+1:m+1,members:y,queueMembers:g,accounts:t?y.filter(t):y,enabled:y.filter(Ni).length,disabled:y.filter(k=>!Ni(k)).length,limited:y.filter(k=>Ni(k)&&cy(k,n?.(k),s?.(k))).length}})}function Ci(e){if(!e)return"";const t=String(e.name||"").trim();if(e.nameCustom===!0&&t)return t;const n=String(e.email||"").trim();return Ga(tn(e)).emailAsName&&n?n:e?.nickname||t||QS(e)||e?.id||""}const cI="已限流",HK=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function uI(e){const t=Number(e);if(!Number.isFinite(t)||t<=0||t<=Date.now())return cI;const n=new Date(t),s=n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}),i=Math.round((HK(n)-HK(new Date))/864e5);return i===0?a("今天 {clock}",{clock:s}):i===1?a("明天 {clock}",{clock:s}):a("{month}月{day}日 {clock}",{month:n.getMonth()+1,day:n.getDate(),clock:s})}function dSe(e){const t=tn(e);if(!Ga(t).edition)return"";const n=RK(e),s=e?.editionLabel,i=s||(n==="intl"?"国际版":"国内版");return(ft().wbProviders?.labelOf?.(t)||"").includes(i)?"":s||a(n==="intl"?"国际版":"国内版")}function fSe(e){const t=gK(e);return[t?{text:a("上游限制 · 已禁用"),kind:"bad",title:t}:null,e.needsRelogin?{text:a("需要重新登录"),kind:"bad",title:iy(e)}:null,OK(e)?null:{text:a("仅账号管理"),kind:"plain",title:a("该提供商的推理转发尚未接入,账号不参与转发")},nSe(tn(e))&&e.hasCredentials===!1?{text:a("未配置凭证"),kind:"bad",title:a("这条自定义账号既没有 API Key,也没有勾选「无需鉴权」:转发时会被跳过,该提供商下的模型也不会出现在模型列表里。去账号「设置」里补上 Key,或勾选「该上游无需鉴权」")}:null,e.proxy?.error?{text:a("代理异常"),kind:"bad",title:a("{error}(不会自动改为直连)",{error:e.proxy.error})}:null,nI(e)===Uh?{text:a("套餐池"),kind:"plain",title:a("转发走套餐池(Start Plan)通道(zcode.z.ai 的 Anthropic 端点,用账号里的体验额度 / 活动领取额度);在账号设置里可切回编码套餐")}:null].filter(n=>n!==null)}const VK="workbuddy-desktop-accounts-filters",qK="workbuddy-desktop-accounts-collapsed",dI="workbuddy-desktop-accounts-names-hidden",fI="workbuddy-desktop-accounts-group-total-filtered",hSe="workbuddy-desktop-accounts-group-sort";function mSe(){try{const e=JSON.parse(localStorage.getItem(hSe)||"{}");if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e)){if(!Array.isArray(s))continue;const i=[];for(const o of s){if(!o||typeof o!="object")continue;const l=o;l.key==="credit"?i.push({key:"credit",on:l.on!==!1,dir:l.dir==="late"?"late":"soon"}):l.key==="balance"?i.push({key:"balance",on:l.on!==!1,dir:l.dir==="low"?"low":"high"}):l.key==="added"&&i.push({key:"added",on:l.on!==!1,dir:l.dir==="old"?"old":"new"})}i.length&&(t[n]=i)}return t}catch{return{}}}function pSe(){const e={provider:"all",enabled:"all",limit:"all",q:""},t=ft().wbFilterMemory?.load(VK,e)||e;return{provider:String(t.provider||"all"),enabled:String(t.enabled||"all"),limit:String(t.limit||"all"),q:""}}function gSe(){try{const e=JSON.parse(localStorage.getItem(qK)||"[]");return new Set(Array.isArray(e)?e.map(t=>String(t)).filter(Boolean):[])}catch{return new Set}}function KK(){return WK()}function GK(){return hI()}function WK(){try{return localStorage.getItem(dI)==="1"}catch{return!1}}function hI(){try{return localStorage.getItem(fI)==="1"}catch{return!1}}let ar={version:0,listBusy:!1,listError:"",filter:pSe(),collapsed:gSe(),selected:new Set,connections:new Map,dialog:null,namesHidden:WK(),usageBusy:!1,usageInflight:new Set,usageTasks:new Map,usageStarting:new Set,groupTotalFiltered:hI(),groupSort:mSe(),sorting:null,sortBusy:!1};const mI=new Set;function Hh(e){return mI.add(e),()=>{mI.delete(e)}}function Sn(){return ar}function Tr(e){ar={...ar,...e,version:ar.version+1},mI.forEach(t=>t())}function eN(){Tr({})}function Wd(){return ft().wbApp?.getState?.()?.accounts}function Ml(){const e=Wd()?.accounts;return Array.isArray(e)?e:[]}function xSe(){const e=Wd()?.hiddenAccounts,t=e?.byProvider,n={};if(t&&typeof t=="object"&&!Array.isArray(t))for(const[l,u]of Object.entries(t)){const d=Number(u);Number.isFinite(d)&&d>0&&(n[l]=d)}const s=new Map;for(const l of Array.isArray(e?.providers)?e.providers:[]){if(!l||typeof l.id!="string"||!l.id)continue;const u=l.reason==="not_installed"||l.reason==="pack_disabled"||l.reason==="provider_disabled"||l.reason==="loading"||l.reason==="load_failed"||l.reason==="load_timeout"?l.reason:"not_loaded";s.set(l.id,{id:l.id,label:typeof l.label=="string"&&l.label?l.label:l.id,count:Number(l.count)||0,reason:u,packId:l.packId,startup:l.startup})}const i=Object.entries(n).map(([l,u])=>{const d=s.get(l);return{id:l,count:u,label:d?.label||ft().wbProviders?.labelOf?.(l)||l,reason:d?.reason||"not_loaded",packId:d?.packId,startup:d?.startup}}).sort((l,u)=>u.count-l.count),o=Number(e?.total);return{total:Number.isFinite(o)&&o>0?o:0,byProvider:n,providers:i}}function _l(e){return Ml().find(t=>t.id===e)||null}function vSe(e,t){const n=uSe(Ml(),i=>zK(i,ar.filter,e,t),e,t,Nu,ar.sorting||Wd()?.sorting);return{groups:n.filter(i=>i.accounts.length>0),allGroups:n}}function Nu(e){const n=ar.sorting?.rules[e]||Wd()?.sorting?.rules[e]||ar.groupSort[e];if(n){const s=n.map(i=>({...i}));return[...s,...FK(e).filter(i=>!s.some(o=>o.key===i.key)).map(i=>({...i,on:!1}))]}return FK(e)}function bSe(e){return Object.prototype.hasOwnProperty.call(ar.sorting?.configured||ar.groupSort,e)}function YK(){return kK(Wd())}function ySe(e,t){return BK(Ml(),ar.filter,e,t)}function jSe(){return lI(Ml(),ar.sorting||Wd()?.sorting)}function tN(){ft().wbFilterMemory?.save(VK,{provider:ar.filter.provider,enabled:ar.filter.enabled,limit:ar.filter.limit})}function wSe(e){ar.filter.q!==e&&Tr({filter:{...ar.filter,q:e}})}function kSe(e){const t=e||"all";ar.filter.provider!==t&&(Tr({filter:{...ar.filter,provider:t}}),tN())}function XK(e,t){const n={...ar.filter,[e]:t};n.enabled==="disabled"&&n.limit!=="all"&&(n.limit="all"),Tr({filter:n}),tN()}function QK(){return ar.filter.provider!=="all"||ar.filter.enabled!=="all"||ar.filter.limit!=="all"||ar.filter.q.trim()!==""}function pI(){Tr({filter:{provider:"all",enabled:"all",limit:"all",q:""}}),tN()}function SSe(){const e=ar.filter.provider;e!=="all"&&(YK().some(t=>t.id===e)||(Tr({filter:{...ar.filter,provider:"all"}}),tN()))}function ZK(e){try{localStorage.setItem(qK,JSON.stringify([...e]))}catch{}}function JK(e){const t=new Set(ar.collapsed);t.has(e)?t.delete(e):t.add(e),ZK(t),Tr({collapsed:t})}function NSe(e,t){const n=new Set(ar.collapsed);for(const s of e)t?n.add(s):n.delete(s);ZK(n),Tr({collapsed:n})}function CSe(e){return ar.selected.has(e)}function ASe(e,t){const n=new Set(ar.selected);t?n.add(e):n.delete(e),Tr({selected:n})}function e8(e,t){const n=new Set(ar.selected);for(const s of e)t?n.add(s):n.delete(s);Tr({selected:n})}function ESe(){const e=!ar.namesHidden;try{localStorage.setItem(dI,e?"1":"0")}catch{}Tr({namesHidden:e})}function TSe(e){try{localStorage.setItem(dI,e?"1":"0")}catch{}Tr({namesHidden:e})}function OSe(){const e=hI();e!==ar.groupTotalFiltered&&Tr({groupTotalFiltered:e})}function RSe(e){try{localStorage.setItem(fI,e?"1":"0")}catch{}Tr({groupTotalFiltered:e})}function t8(e){return"*".repeat(Math.min(Math.max(e.length,4),12))}const n8="usage_not_configured";function gI(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Vh(e){const t=Number(e);return Number.isFinite(t)&&t>0&&t<=864e13?t:0}function PSe(e,t){if(!e.error)return{...e,lastUsage:null,lastSuccessAt:Vh(e.lastSuccessAt)||Vh(e.at)};const n=Object.prototype.hasOwnProperty.call(e,"lastUsage"),s=gI(n?e.lastUsage:t?.error?t.lastUsage:t?.usage),i=n?Vh(e.lastSuccessAt):Vh(e.lastSuccessAt)||Vh(t?.lastSuccessAt)||(t?.error?0:Vh(t?.at));return{...e,usage:null,lastUsage:s,lastSuccessAt:s?i:0}}function r8(e,t,n){const s=Math.max(0,n-e);return s<1e4?t("刚刚更新"):s<6e4?t("{n} 秒前更新",{n:Math.floor(s/1e3)}):s<36e5?t("{n} 分钟前更新",{n:Math.floor(s/6e4)}):s<864e5?t("{n} 小时前更新",{n:Math.floor(s/36e5)}):t("{n} 天前更新",{n:Math.floor(s/864e5)})}function ISe(e,t,n,s=Date.now()){if(!e.error||e.code===n8)return null;const i=gI(e.lastUsage)?Vh(e.lastSuccessAt):0,o=i?`${t("更新失败")} · ${r8(i,t,s)}`:t("查询失败"),l=i?n(i):"";return{text:o,detail:[t(e.error),l?t("上次成功查询:{time}",{time:l}):""].filter(Boolean).join(` +`)}}const MSe=n8,uy=new Map,qh=new Map,_Se=()=>uy,Tg=e=>qh.get(e);function DSe(e){const t=qh.get(e);t&&a8({...t,stale:!0})}function Og(e){return e==null?null:typeof e=="string"?{message:e,notConfigured:!1}:e.error?{message:String(e.error),notConfigured:e.code===MSe}:null}function s8(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function a8(e){qh.set(e.id,e),uy.set(e.id,e.error?{error:e.error,code:e.code,lastUsage:e.lastUsage,lastSuccessAt:e.lastSuccessAt,stale:e.stale,requestId:e.requestId}:e.usage?{...e.usage,stale:e.stale}:void 0)}function LSe(e,t){const n=String(e.id||"");if(!n)return!1;const s=Sn().usageTasks.get(n);if(s&&e.requestId===s.requestId&&s.status==="config_changed")return!1;const i={id:n,usage:s8(e.usage),error:e.error?String(e.error):e.usage?null:a("余额响应为空"),code:typeof e.code=="string"||typeof e.code=="number"?e.code:null,at:Number(e.at)||t,stale:e.stale===!0,requestId:typeof e.requestId=="string"?e.requestId:void 0};Object.prototype.hasOwnProperty.call(e,"lastSuccessAt")&&(i.lastSuccessAt=Number(e.lastSuccessAt)||0),Object.prototype.hasOwnProperty.call(e,"lastUsage")&&(i.lastUsage=s8(e.lastUsage));const o=qh.get(n);if(o&&Number(o.at)>Number(i.at))return!1;const l=PSe(i,o);return o&&JSON.stringify(o)===JSON.stringify(l)?!1:(a8(l),!0)}function po(e){if(e.isGuest!==!0)return uy.get(e.id)}function $Se(e){const n=qh.get(e.id)?.lastSuccessAt??0;return Number.isFinite(n)&&n>0&&n<=864e13?n:0}function zSe(e){const t=Og(po(e));if(!t||t.notConfigured)return null;const n=qh.get(e.id);return n?ISe(n,a,ki):null}function BSe(e){let t=!1;for(const n of uy.keys())e.has(n)||(uy.delete(n),qh.delete(n),t=!0);return t}const FSe=800;function USe(e,t){switch(e?.status){case"running":return t("查询中…");case"cancelled":return t("已取消查询");case"config_changed":return t("配置已变更,请重新查询");case"failed":return e.error?t(e.error):t("查询失败");case"timeout":return t("查询超时,可重新查询");default:return""}}function nN(e,t=15e3){return new Promise((n,s)=>{const i=setTimeout(()=>s(new Error("等待余额查询响应超时,请重新查询")),t);e.then(o=>{clearTimeout(i),n(o)},o=>{clearTimeout(i),s(o)})})}let bc,xI,vI=!1,dy=null,HSe=0,fy=0;const i8=()=>fy,Cu=new Map,rN=new Map;function VSe(e){bc=e}function o8(){xI||vI||!bc||!Sn().usageInflight.size||(xI=setTimeout(async()=>{xI=void 0,vI=!0;try{await nN(bc(),5e3)}catch{}const e=new Map(Sn().usageTasks);let t=!1;for(const[n,s]of e)s.status==="running"&&Date.now()>s.deadlineAt+15e3&&(e.set(n,{...s,status:"timeout"}),t=!0,ft().workbuddyDesktop?.cancelBalanceQuery?.(n,s.requestId).catch(()=>{}));t&&(fy++,sN(e)),vI=!1,o8()},FSe))}function hy(e,t){const n=rN.get(e);if(n){rN.delete(e);for(const s of n)clearTimeout(s.timer),s.resolve(t)}}function sN(e){const t=Sn().usageTasks;for(const[i,o]of e){const l=t.get(i);if(l&&l.requestId!==o.requestId&&hy(l.requestId,null),o.status!=="running"){const u=Tg(i);hy(o.requestId,u?.requestId===o.requestId?u:null)}}const n=new Set([...e].filter(([,i])=>i.status==="running").map(([i])=>i)),s=!!(dy&&[...dy].some(([i,o])=>{const l=e.get(i);return l?.requestId===o&&l.status==="running"}));Tr({usageTasks:e,usageInflight:n,usageBusy:s}),o8()}function bI(e){if(!Array.isArray(e))return;const t=new Map(Sn().usageTasks);let n=!1;for(const s of e){if(!s?.id||!s.requestId||!Number.isFinite(s.startedAt)||!Number.isFinite(s.deadlineAt))continue;const i=t.get(s.id);if(!(i&&(i.startedAt>s.startedAt||i.requestId===s.requestId&&i.status!=="running"&&s.status==="running"||i.requestId===s.requestId&&i.status==="config_changed"))){if(i?.requestId===s.requestId&&i.status===s.status){if(s.status!=="running"){const o=Tg(s.id);hy(s.requestId,o?.requestId===s.requestId?o:null)}continue}t.set(s.id,s),n=!0}}n&&sN(t)}async function yI(e,t=!0){const n=e||"*";if(Cu.has(n))return null;const s=ft().workbuddyDesktop;if(!s?.startBalanceQuery)throw new Error(a("余额查询接口不可用,请更新网关后重试"));const i=++HSe;Cu.set(n,i),Tr({usageStarting:new Set(Cu.keys())});try{const o=await nN(s.startBalanceQuery(e,t));if(Cu.get(n)!==i)return null;if(!Array.isArray(o?.queries)||e&&!o.queries.some(l=>l.id===e))throw new Error(a("余额查询接口返回异常"));return fy++,e||(dy=new Map(o.queries.map(l=>[l.id,l.requestId]))),bI(o.queries),e||sN(new Map(Sn().usageTasks)),bc&&bc(),o}finally{Cu.get(n)===i&&Cu.delete(n),Tr({usageStarting:new Set(Cu.keys())})}}function qSe(e){const t=Sn().usageTasks.get(e.id);if(!t||t.requestId!==e.requestId)return Promise.resolve(null);if(t.status!=="running"){const n=Tg(e.id);return n?.requestId===e.requestId?Promise.resolve(n):!["success","failed","timeout"].includes(t.status)||!bc?Promise.resolve(null):bc().then(async()=>{Tg(e.id)?.requestId!==e.requestId&&await bc();const s=Tg(e.id);return Sn().usageTasks.get(e.id)?.requestId===e.requestId&&s?.requestId===e.requestId?s:null})}return new Promise(n=>{const s=Math.max(1e3,Math.min(195e3,e.deadlineAt-Date.now()+15e3)),i=setTimeout(()=>hy(e.requestId,null),s);rN.set(e.requestId,[...rN.get(e.requestId)||[],{resolve:n,timer:i}])})}async function l8(e){const t=Sn().usageTasks.get(e);if(!(!t||t.status!=="running"))try{const n=await nN(ft().workbuddyDesktop.cancelBalanceQuery(e,t.requestId));if(Sn().usageTasks.get(e)?.requestId!==t.requestId)return;n.cancelled?(fy++,bI([{...t,status:"cancelled"}])):bc&&bc()}catch(n){Ct(a("取消查询失败:{message}",{message:dn(n)}),"err")}}async function KSe(){dy&&await Promise.all([...dy].map(([e,t])=>Sn().usageTasks.get(e)?.requestId===t?l8(e):Promise.resolve()))}function jI(e){fy++;const t=new Map(Sn().usageTasks);for(const n of e){DSe(n),Cu.delete(n);const s=t.get(n);s&&(hy(s.requestId,null),t.set(n,{...s,status:"config_changed"}),s.status==="running"&&ft().workbuddyDesktop?.cancelBalanceQuery?.(n,s.requestId).catch(()=>{}))}Tr({usageStarting:new Set(Cu.keys())}),sN(t)}let Dl=null,aN=null,wI=0,my=null,Rg=0,c8=!1,iN=null;function u8(e){return e.map(t=>[t.id,t.name||"",t.enabled===!1?0:1,t.protocol||"",t.host||"",t.resolved?.protocol||"",t.resolved?.host||"",t.resolved?.port??"",t.port??"",t.resolveError??"",t.usedBy?.length??0,t.usedByServices?.join(",")??""].join(":")).join("|")}function d8(e){return iN!==null&&u8(e)===iN}function f8(e){iN=u8(e)}const kI=new Set;function GSe(e){return kI.add(e),()=>{kI.delete(e)}}function oN(){kI.forEach(e=>e())}function h8(){return Dl}function WSe(){return my}function YSe(){Dl=null,iN=null}function m8(e){Array.isArray(e)&&(Dl=e,wI+=1,my=null,Rg=0,!d8(e)&&(f8(e),oN()))}async function SI(e={}){if(!e.force&&Dl)return Dl;const t=wI;aN||(aN=(async()=>{try{const o=await ft().workbuddyDesktop?.getProxyPool?.();if(!o||typeof o!="object"||!Array.isArray(o.items))throw new Error(a("代理池响应异常({type})",{type:typeof o}));return{items:o.items}}finally{aN=null}})());const s=(await aN).items,i=wI===t||Dl===null;return my=null,!i&&Dl||(Dl=s,d8(s)||(f8(s),oN())),Dl}function XSe(){if(!(Dl||Date.now(){Rg=0}).catch(e=>{my=e instanceof Error?e.message:String(e),oN()})}}async function QSe(){Rg=0;try{await SI({force:!0})}catch(e){my=e instanceof Error?e.message:String(e),oN()}}let p8=!1;function g8(){if(p8)return;const e=ft().wbApp;if(!e?.getRefreshStatus||!e.subscribeRefresh)return;p8=!0;const t=e.getRefreshStatus,n=()=>{const s=t(),i=Sn();i.listBusy===s.pending&&i.listError===s.error||Tr({listBusy:s.pending,listError:s.error})};e.subscribeRefresh(n),n()}async function x8(e={}){g8();try{const t=ft().wbApp?.refresh;if(!t)throw new Error(a("账号列表刷新不可用,请重新打开页面"));const n=await t();return n&&ft().wbProviders?.refreshCustom?.(),e.feedback&&(n?Ct(a("账号列表已刷新")):Ct(a("刷新账号列表失败:{message}",{message:Sn().listError||a("请求失败")}),"err")),n}catch(t){const n=dn(t);return Tr({listBusy:!1,listError:n}),e.feedback&&Ct(a("刷新账号列表失败:{message}",{message:n}),"err"),!1}}const NI="workbuddy-desktop-accounts-group-sort";let lN=null,CI="",v8=0,b8,y8=0,j8="";function Xo(e){if(!e?.rules||!e.configured||!e.accountOrder||!Array.isArray(e.providerOrder)||e.updatedAtf&&typeof f.on=="boolean"&&(f.key==="credit"&&(f.dir==="soon"||f.dir==="late")||f.key==="balance"&&(f.dir==="high"||f.dir==="low")||f.key==="added"&&(f.dir==="new"||f.dir==="old"))).length!==u.length)){if(!Sn().sorting?.rules[l]){i[l]=u;continue}Xo(await e.saveAccountSorting({provider:l,rules:u,onlyIfUnset:!0}))}const o=Object.keys(i).length===0;return o?localStorage.removeItem(NI):localStorage.setItem(NI,JSON.stringify(i)),o}function w8(){const e=Wd()?.sorting;e&&e!==b8&&!Sn().sortBusy&&(b8=e,Xo(e));const t=JSON.stringify(Sn().sorting?.providerOrder||[]);Sn().sortBusy||!lN&&Sn().sorting&&CI!==t&&Date.now()>=v8&&(CI=t,lN=ZSe().then(n=>{n||(lN=null)}).catch(n=>{lN=null,CI="",v8=Date.now()+6e4,Ct(a("排序设置迁移失败:{message}",{message:dn(n)}),"err")}))}async function JSe(){const e=ft().workbuddyDesktop;if(!(!e?.getAccountSorting||Sn().sortBusy))try{Xo(await e.getAccountSorting())}catch(t){Ct(a("读取消耗排序失败:{message}",{message:dn(t)}),"err")}}async function AI(e,t){if(!e||Sn().sortBusy)return;const n=ft().workbuddyDesktop;if(!n?.saveAccountSorting){Ct(a("账号排序接口不可用,请确认网关与界面已更新"),"err");return}const s=Sn().sorting?.balanceSortStates!==void 0;if(!s&&t?.some(o=>o.key==="balance"&&o.on)){Ct(a("当前网关不支持余额排序,请先更新网关"),"err");return}const i=s?t:t?.filter(o=>o.key!=="balance")??null;Tr({sortBusy:!0});try{const o=await n.saveAccountSorting({provider:e,rules:i});if(!o?.rules||!o.accountOrder||!Array.isArray(o.providerOrder))throw new Error(a("保存响应不完整,请刷新当前配置确认结果"));Xo(o),window.dispatchEvent(new CustomEvent("wb:account-sorting",{detail:o}));try{await ft().wbApp?.refresh?.()}catch(l){Ct(a("排序已保存,但列表刷新失败:{message}",{message:dn(l)}),"err")}}catch(o){Ct(a("排序未保存:{message}",{message:dn(o)}),"err")}finally{Tr({sortBusy:!1})}}function Kh(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Yd(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((i,o)=>Yd(i,t[o]));const n=Kh(e),s=Kh(t);return!!(n&&s&&Object.keys(n).length===Object.keys(s).length&&Object.entries(n).every(([i,o])=>Object.hasOwn(s,i)&&Yd(o,s[i])))}function k8(e){return e?{reset:e.reset||"fixed",seconds:e.seconds||0,startsAt:e.startsAt||0,endsAt:e.endsAt||0,utcOffsetMinutes:e.utcOffsetMinutes??null}:null}function eNe(e){return e?{id:e.id,label:e.label,provider:e.provider||"",channel:e.channel||"",planId:e.planId||"",planName:e.planName||"",models:e.models||[],unit:e.unit||"",remaining:null,total:null,used:null,remainingPercent:null,startsAt:e.startsAt||0,endsAt:e.endsAt||0,resetsAt:0,window:k8(e.window),unlimited:e.unlimited===!0,localEstimate:e.localEstimate===!0,localOnly:e.localOnly===!0}:null}function Pg(e){return e.map(t=>({enabled:t.enabled!==!1,action:t.action||"skip",target:t.target||"models",conditions:t.conditions.map((n,s)=>({join:s===0?"or":n.join||"or",sourceId:n.sourceId.trim(),source:eNe(n.source),models:[...new Set(n.models.map(i=>i.trim()).filter(Boolean))].sort(),metric:n.metric,comparison:n.comparison,threshold:n.threshold,window:k8(n.window)}))}))}function cN(e,t){return Object.entries(t).every(([n,s])=>{if(n==="proxy"){const i=e.proxy?.config||e.proxy;if(s===null)return!i||i.source==="direct";const o=Kh(s),l=Kh(i);return!!(o&&l&&Object.entries(o).every(([u,d])=>Yd(d,l[u])))}if(n==="maxConcurrent"){const i=Number(s),o=e.provider==="codearts"?i===0?3:Math.min(i,64):i;return e.maxConcurrent===o}if(n==="limiterGroups")return Array.isArray(s)&&Array.isArray(e.limiterGroups)&&Yd(Pg(e.limiterGroups),Pg(s));if(n==="balanceToken")return e.hasBalanceToken===(s!==null&&s!=="");if(n==="apiKey")return e.hasApiKey===(s!==null&&s!=="");if(n==="baseUrl"){const i=typeof s=="string"?s.trim().replace(/\/+$/,""):"";return i?String(e.baseUrl||"").replace(/\/+$/,"")===i:!e.baseUrl}if(n==="balanceQuery"){const i=Kh(s),o=Kh(e.balanceQuery);return!!(i&&o&&Object.entries(i).every(([l,u])=>{const f={accessToken:"hasAccessToken",password:"hasPassword",token:"hasToken"}[l];return f?o[f]===(u!==null&&u!==""):Yd(o[l],u)}))}return Yd(e[n],s)})}async function Gh(e,t){const n=ft().workbuddyDesktop;if(!n?.updateAccount)throw new Error(a("账号更新接口不可用,请重新打开页面"));const s=ft().wbApp?.getState?.()?.accounts?.accounts?.find(u=>u.id===e),i=await n.updateAccount(e,t);i?.changes?.length&&["proxy","baseUrl","balanceToken","apiKey","noAuth","balanceQuery","zcodePlan","userAgent"].some(u=>{if(!Object.prototype.hasOwnProperty.call(t,u))return!1;if(u==="balanceQuery"&&s){const d=Kh(t.balanceQuery);return!!(d&&["accessToken","password","token"].some(m=>Object.prototype.hasOwnProperty.call(d,m))||!cN(s,{balanceQuery:t.balanceQuery}))}return s&&!["balanceToken","apiKey"].includes(u)?!cN(s,{[u]:t[u]}):!0})&&jI([e]);const l=i?.account;if(!l||l.id!==e||s&&l.provider!==s.provider||!cN(l,t))throw new Error(a("账号更新结果未确认,请刷新后核对设置"));return l}function tNe(e){switch(e.action){case"enable":return{enabled:!0};case"disable":return{enabled:!1};case"proxy":return{proxy:e.proxy};case"concurrency":return{maxConcurrent:e.maxConcurrent};case"usageQuery":return{usageQuery:e.usageQuery};default:return{}}}function EI(e,t){if(!e||!Array.isArray(t.action==="remove"?e.removed:e.ok))throw new Error(a("批量操作未返回结果,请刷新后确认状态"));const n=t.action==="remove"?e.removed||[]:e.ok||[],s=new Set(t.ids),i=new Set;if([...n,...e.failed||[],...e.skipped||[]].some(d=>!d.id||!s.has(d.id)||i.has(d.id)?!0:(i.add(d.id),!1))||i.size!==s.size)throw new Error(a("批量操作结果不完整,请刷新后核对所选账号"));const l=e.list?.accounts;if(!Array.isArray(l))throw new Error(a("批量操作结果不完整,请刷新后核对所选账号"));const u=tNe(t);if(n.some(d=>{const f=l.find(g=>g.id===d.id);if(t.action==="remove")return!!f;if(!f||!cN(f,u))return!0;if(t.action!=="limiters")return!1;const m=f.limiterGroups;if(!Array.isArray(m))return!0;switch(t.limiterMode){case"append":return Pg(t.limiterGroups||[]).some(g=>!Pg(m).some(v=>Yd(v,g)));case"replace":return!Yd(Pg(m),Pg(t.limiterGroups||[]));case"enable":return m.some(g=>g.enabled!==!0);case"disable":return m.some(g=>g.enabled!==!1);case"clear":return m.length!==0;default:return!0}}))throw new Error(a("批量操作结果未确认,请刷新后核对设置"));if(t.action==="proxy"||t.action==="remove"){const d=t.action==="remove"?e.removed||[]:(e.ok||[]).filter(f=>f.changes?.length);jI(d.map(f=>f.id).filter(Boolean))}return e}async function Qo(){const e=ft().wbApp;if(!e?.refresh)throw new Error(a("账号列表刷新接口不可用,请重新打开页面"));if(await e.refresh()!==!0)throw new Error(e.getRefreshStatus?.().error||a("账号列表刷新失败"))}const py=new Map;let S8=0,N8=!1,uN;VSe(Ig);function Wh(e){return e?py.get(e.id)||[]:[]}function nNe(e){const t=Number(e?.tokenAt)||0;if(!t||t===S8)return!1;const n=e?.tokenUsage;if(!n||typeof n!="object")return!1;S8=t;const s=new Map;for(const[o,l]of Object.entries(n)){if(!Array.isArray(l))continue;const u=[];for(const d of l){if(!d||typeof d!="object")continue;const f=Number(d.kind),m=Number(d.windowStart),g=Number(d.used);!Number.isFinite(f)||f<0||!Number.isFinite(m)||m<=0||!Number.isFinite(g)||g<0||u.push({kind:f,windowStart:m,used:g})}s.set(o,u)}const i=s.size!==py.size||[...s].some(([o,l])=>{const u=py.get(o);return!u||u.length!==l.length||l.some((d,f)=>d.used!==u[f]?.used||d.windowStart!==u[f]?.windowStart)});py.clear();for(const[o,l]of s)py.set(o,l);return i}function rNe(){return Ml().filter(e=>Si(e)&&e.available!==!1)}function C8(e){const t=Array.isArray(e?.results)?e.results:[],n=Number(e?.at)||Date.now();let s=0;for(const i of t)i&&LSe(i,n)&&(s++,i.code==="refresh_token_expired"&&ft().wbApp?.refresh?.());return s&&(eN(),ft().wbApp?.renderTopbarStatus?.()),s}function sNe(e){if(!sI(e)||e.needsRelogin)return!1;const t=po(e);return!t||typeof t!="object"||Array.isArray(t)||Og(t)?!1:!Array.isArray(t.credits)}async function aNe(){if(!N8){N8=!0;for(const e of Ml().filter(sNe))try{await TI(e.id,!1)}catch{}}}function Ig(){return uN||(uN=iNe().finally(()=>{uN=void 0})),uN}async function iNe(){try{const e=i8(),t=await nN(Promise.resolve(ft().workbuddyDesktop?.getBalancesSnapshot?.()),5e3);if(e!==i8())return!1;const n=Pke(t),s=!Sn().sortBusy&&Xo(t?.sorting),i=nNe(t)||n||s;i&&(eN(),ft().wbApp?.renderTopbarStatus?.());const o=C8(t);return bI(t?.queries),o?(aNe(),!0):i}catch{return!1}}async function TI(e,t=!0){const n=await yI(e||void 0,t);if(!n)return{results:[]};const s=await Promise.all(n.queries.map(qSe));return JSe(),{results:s.filter(i=>i!==null)}}async function A8(){if(!Sn().usageStarting.has("*")){if(!rNe().length){Ct(a("暂无可查询余额的账号"),"err");return}try{await yI(void 0,!0)}catch(e){Ct(a("余额查询失败:{message}",{message:dn(e)}),"err")}}}async function oNe(e){try{if(!(await TI(e)).results.length)return;const n=_Se().get(e),s=Og(n),i=aK(n,a);s?.notConfigured?Ct(s.message,"ok"):s?Ct(a("余额查询失败:{message}",{message:s.message}),"err"):i?Ct(i.detail,"ok"):Ct(a("✅ 已更新余额"))}catch(t){Ct(a("余额查询失败:{message}",{message:dn(t)}),"err")}}async function gy(e){const t=e?_l(e):null;if(!(e&&(!t||!Si(t)||t.needsRelogin)))try{await yI(e,!1)}catch{}}function Mg(e){if(!_l(e)){Ct(a("账号不存在,请刷新后重试"),"err");return}Tr({dialog:{kind:"settings",id:e}})}function xy(){Tr({dialog:null})}function OI(e,t="enable"){const n=(Array.isArray(e)?e:[]).filter(s=>_l(s));if(!n.length){Ct(a("请先勾选要操作的账号"),"err");return}Tr({dialog:{kind:"batch",ids:n,action:t}})}function E8(e){e&&Tr({dialog:{kind:"group",provider:e}})}function lNe(e){let t=BSe(e);const n=new Map(Sn().connections);for(const o of[...n.keys()])e.has(o)||(n.delete(o),t=!0);const s=new Set(Sn().usageInflight);for(const o of[...s])e.has(o)||(s.delete(o),t=!0);const i=new Set(Sn().selected);for(const o of[...i])e.has(o)||(i.delete(o),t=!0);t&&Tr({connections:n,usageInflight:s,selected:i})}const cNe=2e3;function T8(e){return Sn().connections.get(e)||0}async function O8(){try{const e=await ft().workbuddyDesktop?.getAccountConnections?.(),t=e?.counts&&typeof e.counts=="object"?e.counts:{},n=new Map;for(const[s,i]of Object.entries(t)){const o=Number(i)||0;o>0&&n.set(s,o)}return uNe(n,Sn().connections)||Tr({connections:n}),!0}catch{return!1}}function uNe(e,t){if(e.size!==t.size)return!1;for(const[n,s]of e)if(t.get(n)!==s)return!1;return!0}let R8=null;function dNe(){R8||(R8=setInterval(()=>{document.hidden||ft().wbApp?.currentPage!=="accounts"||O8()},cNe))}async function P8(e,t){try{await Gh(e,{enabled:t}),Ct(a(t?"✅ 已启用":"✅ 已禁用"));try{await Qo()}catch(n){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(n)}),"err")}}catch(n){Ct(a("操作失败:{message}",{message:dn(n)}),"err"),ft().wbApp?.refresh?.()}}async function I8(e,t){if(!e.length)return!1;try{return await ft().workbuddyDesktop?.reorderAccounts?.(e),Ct(t?a("✅ 已保存:{note}",{note:t}):a("✅ 顺序已保存")),await ft().wbApp?.refresh?.(),!0}catch(n){return Ct(a("顺序未保存:{message}",{message:dn(n)}),"err"),ft().wbApp?.refresh?.(),!1}}async function M8(e,t){if(e.length)try{const n=ft().workbuddyDesktop;if(!n?.batchAccounts)throw new Error(a("批量操作接口不可用,请重新打开页面"));const s={action:t?"enable":"disable",ids:e},i=EI(await n.batchAccounts(s),s),o=i.ok?.length||0,l=i.ok?.filter(d=>d.changes?.length).length||0,u=i.failed?.length||0;u||i.skipped?.length?Ct(a("{verb}完成:成功 {ok} 个,未变更 {unchanged} 个,跳过 {skip} 个,失败 {fail} 个",{verb:a(t?"启用":"禁用"),ok:l,unchanged:o-l,skip:i.skipped?.length||0,fail:u}),u?"err":"ok"):Ct(t?a("✅ 已启用 {n} 个账号",{n:o}):a("✅ 已禁用 {n} 个账号",{n:o}));try{await Qo()}catch(d){Ct(a("批量操作已保存,但列表刷新失败:{error}",{error:dn(d)}),"err")}}catch(n){Ct(a("操作失败:{message}",{message:dn(n)}),"err"),ft().wbApp?.refresh?.()}}async function fNe(e,t){try{await ft().workbuddyDesktop?.clearRateLimits?.(e,t||null),Ct(t?a("✅ 已清除 {model} 的限流标记",{model:t}):a("✅ 已清除该账号全部限流标记")),await ft().wbApp?.refresh?.()}catch(n){Ct(a("清除失败:{message}",{message:dn(n)}),"err")}}async function hNe(e,t,n){if(typeof t!="string")return;if(t===_8){Mg(e);return}if(t===dN||t===n)return;const s=t.startsWith(vc)?t.slice(vc.length).trim():"";if(!(t!==""&&!s)){if(s){const i=(h8()||[]).find(o=>o.id===s);if(i&&i.enabled===!1){Ct(a("「{name}」已在「网络代理」页禁用,请先启用它或换一条",{name:i.name||s}),"err");return}}try{await Gh(e,{proxy:s?{source:"pool",proxyId:s}:null}),Ct(`✅ ${a("代理已更新")}`)}catch(i){Ct(a("保存失败:{message}",{message:dn(i)}),"err")}finally{try{await Qo()}catch(i){Ct(a("刷新账号列表失败:{message}",{message:dn(i)}),"err")}}}}const dN="__proxy_custom__",_8="__proxy_custom_edit__";function mNe(e,t,n=1){return{seat:t.get(e.id)||{position:1,total:1},rank:n,picked:CSe(e.id),usageEntry:po(e),connections:T8(e.id)}}const pNe={DEFAULT_PROVIDER_ID:QP,RACCOON_PROVIDER_ID:zke,providerOf:tn,providerFeatures:Ga,providerSummaries:kK,identifierOf:QS,tokenExpiryOf:NK,supportsUsage:Si,isDesktopAccount:oy,supportsChat:OK,byPriorityOrder:ZS,typeLabel:rSe,isEnabled:Ni,isRateLimited:ly,isLimited:e=>cy(e,e?po(e):void 0,Wh(e)),accountEdition:RK,matchEnabled:iI,matchLimit:$K,visibleAccounts:oSe,filterCounts:BK,positionMap:lI,activeLimits:oI,editionSuffix:dSe,formatResetText:uI};function gNe(){g8(),window.wbAccountsView={render:()=>{w8(),eN()},refreshList:x8,refreshCaches:lNe,invalidateUsageTasks:jI,syncConnections:O8,refreshProxyPool:QSe,applyBalances:C8,syncBalancesSnapshot:Ig,queryUsageFor:TI,queryAllUsage:A8,refreshUsageAfterCheckin:gy,supportsUsage:Si,isDesktopAccount:oy,isEnabled:Ni,isRateLimited:ly},window.wbAccountsModel=pNe,window.wbAccountPanel={open:Mg,close:xy,openBatch:OI,closeBatch:xy,syncAddProvider:()=>ft().wbAccountAddForms?.syncAddProvider?.(),invalidate:()=>{YSe()}}}async function xNe(e,t){const n=ft().workbuddyDesktop;if(!n?.refreshAccountToken)throw new Error(a("Token 刷新接口不可用,请重新打开页面"));const s=[...new Set(e)],i=[],o=[],l=[];for(const[u,d]of s.entries()){const f=_l(d),m=Ci(f)||d;t({completed:u,total:s.length,name:m});try{if(!f)throw new Error(a("账号不存在,请刷新后重试"));const g=KP(f);if(g)l.push({id:d,name:m,reason:g});else{const v=await n.refreshAccountToken(d),b=v?.list?.accounts?.find(y=>y.id===d);if(v?.refreshedId!==d||!b||b.needsRelogin===!0||tn(b)!==tn(f))throw new Error(a("Token 刷新结果未确认,请刷新后核对账号状态"));i.push({id:d,name:m})}}catch(g){o.push({id:d,error:dn(g)})}t({completed:u+1,total:s.length,name:m})}return{ok:i,failed:o,skipped:l}}const D8=[{value:"fixed",label:()=>a("固定周期")},{value:"rolling",label:()=>a("滚动窗口")},{value:"daily",label:()=>a("自然日")},{value:"weekly",label:()=>a("自然周")},{value:"monthly",label:()=>a("自然月")},{value:"total",label:()=>a("生效至到期累计(不自动回满)")}];function vNe(){return{join:"or",sourceId:"local",models:[],metric:"tokens",comparison:"gte",threshold:5e5,window:{reset:"daily",utcOffsetMinutes:null}}}function L8(e){if(!e||!Number.isFinite(e))return"";const t=new Date(e);return new Date(e-t.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function $8(e){const t=e.metric==="tokens"&&e.threshold%1e8===0?"yi":e.metric==="tokens"&&e.threshold%1e4===0?"wan":"unit";return{condition:{...structuredClone(e),window:e.window||e.source?.window,sourceId:e.sourceId||(e.metric==="tokens"||e.metric==="requests"?"local":"account")},unit:t,threshold:String(e.threshold/(t==="yi"?1e8:t==="wan"?1e4:1)),period:String(((e.window||e.source?.window)?.seconds||3600)/3600),anchor:L8((e.window||e.source?.window)?.startsAt),end:L8((e.window||e.source?.window)?.endsAt)}}function z8(e){if(!e||e.id==="local"||e.localOnly)return["tokens","requests"];if(e.id==="account")return["remaining"];const t=[];return e.unlimited||(e.remaining!==null&&e.remaining!==void 0&&t.push("remaining"),e.used!==null&&e.used!==void 0&&t.push("used"),(e.remainingPercent!==null&&e.remainingPercent!==void 0||(e.total||0)>0)&&t.push("remaining_percent","used_percent")),e.window&&t.push("tokens","requests"),t.length?t:["tokens","requests"]}function bNe({account:e,value:t,allowBalance:n=!0,onSave:s,onClose:i}){const[o,l]=p.useState(()=>$8(t)),[u,d]=p.useState(""),f=o.condition,m=UP(e).filter(M=>(n||M.id==="local")&&(tn(e)!=="codearts"||M.id==="account"||zh(M.unit||"")));f.source&&!m.some(M=>M.id===f.sourceId)&&m.push(f.source);const g=m.find(M=>M.id===f.sourceId),v=m.find(M=>M.id==="account"&&zh(M.unit||"")),b=[...new Map(m.filter(M=>M.planId).map(M=>[M.planId,M.planName||M.planId])).entries()],y=g?.planId||"",k=m.filter(M=>M.id==="account"||(y?M.planId===y:!M.planId)),w=f.metric==="tokens"||f.metric==="requests",S=Number(o.threshold)*(o.unit==="yi"?1e8:o.unit==="wan"?1e4:1),N=f.metric==="tokens"&&o.unit!=="unit"&&o.threshold.trim()&&Number.isSafeInteger(S)&&S>0?S.toLocaleString("en-US"):"",C=v?.unlimited?a("不限"):v?.remaining==null?a("暂无读数"):`${Ln(v.remaining)} ${a("积分")}`,T=g?.models?.length?g.models.map(M=>({value:M,label:M})):Ike(e);for(const M of f.models)T.some(_=>_.value===M)||T.push({value:M,label:M});const P=[...new Set([...z8(g),f.metric])].filter(M=>tn(e)!=="codearts"||M!=="tokens"&&M!=="requests"),O=M=>{d(""),l(_=>({..._,condition:{..._.condition,...M}}))},A=M=>{const _=m.find(D=>D.id===M);if(!_)return;const L=_.localOnly||_.localEstimate?"tokens":z8(_)[0],$=L==="tokens"?_.total||5e5:L.endsWith("percent")?5:1;l($8({...f,sourceId:M,source:dK(_),models:_.models?.length===1?_.models.slice():[],metric:L,comparison:L.startsWith("remaining")?"lte":"gte",threshold:$,window:_.window||{reset:"daily",utcOffsetMinutes:null}})),d("")},R=()=>{const M=Number(o.threshold),_=f.metric==="tokens"?Math.round(M*(o.unit==="yi"?1e8:o.unit==="wan"?1e4:1)):M;if(!o.threshold.trim()||!Number.isFinite(_)||_<0){d(a("限制阈值必须是非负有限数字"));return}if(w&&(!Number.isSafeInteger(_)||_<=0)){d(a("本地消耗上限必须是大于 0 的安全整数"));return}if(f.metric.endsWith("percent")&&_>100){d(a("百分比阈值必须在 0~100 之间"));return}let L=f.window;if(w){if(L={...L,reset:L?.reset||"daily"},L.reset==="fixed"||L.reset==="rolling"){const $=Math.round(Number(o.period)*3600);if(!Number.isFinite($)||$<60||$>2678400){d(a("统计窗口必须是 1 分钟~31 天"));return}L.seconds=$}if((L.reset==="total"||L.reset==="fixed")&&(L.startsAt=o.anchor?new Date(o.anchor).getTime():0,L.endsAt=o.end?new Date(o.end).getTime():0,!Number.isFinite(L.startsAt)||!Number.isFinite(L.endsAt)||L.endsAt>0&&L.endsAt<=L.startsAt)){d(a("统计结束时间必须晚于开始时间"));return}}s({...f,threshold:_,window:L,source:g&&g.id!=="account"&&g.id!=="local"?dK(g):null})};return r.jsx(at,{open:!0,onOpenChange:M=>{M||i()},children:r.jsxs(it,{className:"w-[min(680px,calc(100vw-48px))]",showCloseButton:!0,overlayForceRender:!0,children:[r.jsx(ot,{children:r.jsx(st,{children:a("编辑限制条件")})}),r.jsxs(lt,{className:"space-y-3",children:[b.length?r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("套餐")}),r.jsxs(Pt,{value:y,onValueChange:M=>{const _=m.find(L=>M?L.planId===M:!L.planId);_&&A(_.id)},children:[r.jsx(Mt,{className:"min-w-0 flex-1",children:r.jsx(It,{children:b.find(([M])=>M===y)?.[1]||a("通用额度/本地保护")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"",children:a("通用额度/本地保护")}),b.map(([M,_])=>r.jsx(Ze,{value:M,children:_},M))]})]})]}):null,r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("额度来源")}),r.jsxs(Pt,{value:f.sourceId||"account",onValueChange:M=>{M&&A(M)},children:[r.jsx(Mt,{className:"min-w-0 flex-1",children:r.jsx(It,{children:VP(g,f.sourceId||"account")})}),r.jsx(_t,{children:k.map(M=>r.jsx(Ze,{value:M.id,children:VP(M)},M.id))})]})]}),v?r.jsxs(wP,{className:"space-y-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("span",{className:"text-xs text-subtle",children:a("总积分")}),r.jsx("span",{className:"text-[13px] font-semibold tabular-nums",children:C}),r.jsx(B,{variant:"outline",size:"sm",className:"ml-auto",disabled:g?.id===v.id&&f.metric==="remaining",onClick:()=>A(v.id),children:a("按总积分设置限制")})]}),r.jsx("p",{className:"detail",children:a("总积分是当前可用积分的汇总,与余额列一致;不重复累加汇总行,不包含 Token、次数或其他单位的额度。")})]}):null,r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("模型范围")}),r.jsx(xc,{value:f.models,options:T,onValueChange:M=>O({models:M}),placeholder:g?.models?.length?a("该额度中的全部模型"):a("全部模型"),className:"min-w-0 flex-1","aria-label":a("模型范围")})]}),r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("限制指标")}),r.jsxs(Pt,{value:f.metric,onValueChange:M=>{M&&(O({metric:M,comparison:M.startsWith("remaining")?"lte":"gte"}),l(_=>({..._,threshold:"",unit:"unit"})))},children:[r.jsx(Mt,{className:"min-w-[190px]",children:r.jsx(It,{children:qP(f.metric)})}),r.jsx(_t,{children:P.map(M=>r.jsx(Ze,{value:M,children:qP(M)},M))})]})]}),r.jsxs(Lh,{orientation:"horizontal",className:"field-row",children:[r.jsx("span",{className:"text-[12.5px] text-subtle",children:a("触发条件")}),r.jsxs(Pt,{value:f.comparison,onValueChange:M=>O({comparison:M}),children:[r.jsx(Mt,{className:"w-[92px]","aria-label":a("触发条件"),children:r.jsx(It,{children:f.comparison==="lt"?"<":f.comparison==="lte"?"≤":"≥"})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"lt",children:"<"}),r.jsx(Ze,{value:"lte",children:"≤"}),r.jsx(Ze,{value:"gte",children:"≥"})]})]}),r.jsx(ze,{type:"number",min:0,className:"max-w-[160px]",value:o.threshold,onChange:M=>l({...o,threshold:M.currentTarget.value}),placeholder:a("阈值"),"aria-label":a("阈值")}),f.metric==="tokens"?r.jsxs(Pt,{value:o.unit,onValueChange:M=>l({...o,unit:M}),children:[r.jsx(Mt,{className:"w-[84px]","aria-label":a("Token 单位"),children:r.jsx(It,{children:o.unit==="yi"?a("亿"):o.unit==="wan"?a("万"):a("个")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"yi",children:a("亿")}),r.jsx(Ze,{value:"wan",children:a("万")}),r.jsx(Ze,{value:"unit",children:a("个")})]})]}):r.jsx("span",{className:"detail",children:f.metric.endsWith("percent")?"%":f.metric==="requests"?a("次"):mo(g?.unit||"",a)})]}),N?r.jsx("p",{className:"detail",children:a("实际阈值:{value} Token",{value:N})}):null,w?r.jsxs(r.Fragment,{children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("统计周期")}),r.jsxs(Pt,{value:f.window?.reset||"daily",onValueChange:M=>O({window:{...f.window,reset:M}}),children:[r.jsx(Mt,{className:"min-w-0 flex-1",children:r.jsx(It,{children:D8.find(M=>M.value===(f.window?.reset||"daily")).label()})}),r.jsx(_t,{children:D8.map(M=>r.jsx(Ze,{value:M.value,children:M.label()},M.value))})]})]}),f.window?.reset==="fixed"||f.window?.reset==="rolling"?r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("窗口长度")}),r.jsx(ze,{type:"number",min:1/60,max:744,step:"any",value:o.period,className:"max-w-[130px]",onChange:M=>l({...o,period:M.currentTarget.value})}),r.jsx("span",{className:"detail",children:a("小时")})]}):null,f.window?.reset==="total"||f.window?.reset==="fixed"?r.jsxs(r.Fragment,{children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("累计起点")}),r.jsx(ze,{type:"datetime-local",value:o.anchor,onChange:M=>l({...o,anchor:M.currentTarget.value}),className:"min-w-0 flex-1"})]}),r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("到期时间")}),r.jsx(ze,{type:"datetime-local",value:o.end,onChange:M=>l({...o,end:M.currentTarget.value}),className:"min-w-0 flex-1"})]})]}):null,["daily","weekly","monthly"].includes(f.window?.reset||"daily")?r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{children:a("重置时区")}),r.jsxs(Pt,{value:f.window?.utcOffsetMinutes===480?"beijing":f.window?.utcOffsetMinutes===0?"utc":"local",onValueChange:M=>O({window:{...f.window,reset:f.window?.reset||"daily",utcOffsetMinutes:M==="beijing"?480:M==="utc"?0:null}}),children:[r.jsx(Mt,{className:"min-w-[190px]",children:r.jsx(It,{children:f.window?.utcOffsetMinutes===480?a("北京时间(UTC+8)"):f.window?.utcOffsetMinutes===0?"UTC":a("服务器本地时区")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"local",children:a("服务器本地时区")}),r.jsx(Ze,{value:"beijing",children:a("北京时间(UTC+8)")}),r.jsx(Ze,{value:"utc",children:"UTC"})]})]})]}):null]}):null,r.jsx("p",{className:"detail",children:a(w?"本地统计只包含经过本网关的请求,不等于上游账单;清理请求日志不会清零。套餐选择用于限定保护范围,不会强制上游扣指定套餐。":"按上游额度查询的读数判定;模型共用同一个额度池时,选择模型不会拆分该池余额。")}),w&&T.length>0?r.jsx("p",{className:"detail",children:a("选中多个模型时,每个模型单独累计、单独比较阈值;不合并用量。")}):null,g?.localEstimate?r.jsx("p",{className:"detail text-warning",children:a("上游没有提供此额度的分桶用量,当前使用本地估算保护;在其他客户端产生的消耗不会计入。")}):null,g?.channel&&g.channel!==String(e?.quotaChannel||e?.zcodePlan||"")?r.jsx("p",{className:"detail text-warning",children:a("此额度不属于账号当前使用的通道,切换到对应通道后才参与判定。")}):null,u?r.jsx("p",{className:"detail text-destructive",children:u}):null]}),r.jsxs(xt,{children:[r.jsx(B,{variant:"outline",onClick:i,children:a("取消")}),r.jsx(B,{onClick:R,children:a("保存条件")})]})]})})}function B8({account:e,draft:t,onChange:n,allowBalance:s=!0}){const[i,o]=p.useState(null),[l,u]=p.useState(!1);p.useEffect(()=>{Ig()},[e?.id]);const d=(k,w)=>{n(t.map((S,N)=>N===k?{...S,...w}:S))},f=()=>tn(e)==="codearts"?{join:"or",sourceId:"account",models:[],metric:"remaining",comparison:"lt",threshold:1}:vNe(),m=()=>o({group:-1,condition:-1,value:f()}),g=k=>{if(i){if(i.group<0)n([...t,{enabled:!0,action:"skip",target:"models",conditions:[k]}]);else{const S=t[i.group].conditions.slice();i.condition<0?S.push(k):S[i.condition]=k,d(i.group,{conditions:S})}o(null)}},v=async()=>{if(!(!e||l)){u(!0);try{await gy(e.id),await Ig()}finally{u(!1)}}},b=HP(e),y=e?sy(e,Fh(e)):[];return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"acct-limiter-toolbar flex flex-wrap items-center gap-2",children:[r.jsx(B,{variant:"outline",onClick:m,children:a("+ 添加限制")}),e&&s?r.jsx(B,{variant:"ghost",disabled:l,onClick:()=>{v()},children:a(l?"查询中…":"刷新套餐与额度")}):null]}),r.jsx("p",{className:"detail acct-limiter-lead",children:a("每组共用一个触发动作;第二条条件起可选择「与/或」。与优先于或,下面会显示明确分组。各条件组独立生效。")}),t.length?null:r.jsx("p",{className:"detail acct-limiter-lead",children:a("还没有条件组:账号照常参与转发,不设置额度保护。")}),t.map((k,w)=>{const S=JSON.stringify(k)===JSON.stringify(y[w])?b[w]:void 0;return r.jsxs("div",{className:"acct-limiter-group rounded-lg border border-hairline p-3 space-y-2",children:[r.jsxs("div",{className:"acct-limiter-head flex flex-wrap items-center gap-2",children:[r.jsx(St,{checked:k.enabled,onCheckedChange:N=>d(w,{enabled:N}),"aria-label":a("启用该规则")}),r.jsx("span",{className:"text-[13px] font-medium",children:a("条件组 {n}",{n:w+1})}),S?r.jsx(Ee,{shape:"tag",variant:k.enabled?S.hit?"warning":"success":"secondary",children:k.enabled?S.hit?a("已触发"):a("未触发"):a("已停用")}):null,r.jsx("div",{className:"flex-1"}),r.jsx(B,{variant:"ghost",size:"sm",onClick:()=>n(t.filter((N,C)=>C!==w)),children:a("删除组")})]}),k.conditions.map((N,C)=>r.jsxs("div",{className:"acct-limiter-condition flex flex-wrap items-center gap-2 rounded-md bg-control p-2",children:[C>0?r.jsxs(Pt,{value:N.join,onValueChange:T=>d(w,{conditions:k.conditions.map((P,O)=>O===C?{...P,join:T}:P)}),children:[r.jsx(Mt,{className:"w-[78px]",children:r.jsx(It,{children:N.join==="and"?a("与"):a("或")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"and",children:a("与")}),r.jsx(Ze,{value:"or",children:a("或")})]})]}):r.jsx("span",{className:"text-xs text-muted-foreground",children:a("当")}),r.jsxs("div",{className:"min-w-0 flex-1 text-xs",children:[r.jsx("div",{className:"break-words",children:fK(N,e)}),S?r.jsx("div",{className:"text-muted-foreground mt-1",children:a("当前:{value}",{value:Mke(S.conditions[C],N,e)})}):null]}),r.jsx(B,{variant:"ghost",size:"xs",onClick:()=>o({group:w,condition:C,value:N}),children:a("编辑")}),r.jsx(B,{variant:"ghost",size:"xs",disabled:k.conditions.length===1,onClick:()=>d(w,{conditions:k.conditions.filter((T,P)=>P!==C).map((T,P)=>P===0?{...T,join:"or"}:T)}),children:a("删除")})]},C)),r.jsx(B,{variant:"ghost",size:"sm",onClick:()=>o({group:w,condition:-1,value:f()}),children:a("+ 添加条件")}),r.jsxs(Lh,{orientation:"horizontal",className:"field-row acct-limiter-actions",children:[r.jsx(Ae,{children:a("触发动作")}),r.jsxs(Pt,{value:k.action,onValueChange:N=>d(w,{action:N}),children:[r.jsx(Mt,{className:"min-w-[190px]","aria-label":a("触发动作"),children:r.jsx(It,{children:k.action==="disable"?a("禁用整个账号(手动恢复)"):a("跳过(自动恢复)")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"skip",children:a("跳过(自动恢复)")}),r.jsx(Ze,{value:"disable",children:a("禁用整个账号(手动恢复)")})]})]}),k.action==="skip"?r.jsxs(Pt,{value:k.target,onValueChange:N=>d(w,{target:N}),children:[r.jsx(Mt,{className:"min-w-[170px]","aria-label":a("模型范围"),children:r.jsx(It,{children:k.target==="account"?a("整个账号"):a("命中条件的模型")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"models",children:a("命中条件的模型")}),r.jsx(Ze,{value:"account",children:a("整个账号")})]})]}):null]}),r.jsx("p",{className:"detail break-words acct-limiter-expression",children:Dke(k.conditions,e)})]},w)}),e?null:r.jsx("p",{className:"detail",children:a("跨账号批量配置仅支持通用条件;套餐实例不能直接复制到其他账号。")}),i?r.jsx(bNe,{account:e,value:i.value,allowBalance:s,onSave:g,onClose:()=>o(null)},`${i.group}:${i.condition}`):null]})}function yNe(e,t){const n=sy(e,Fh(e));return JSON.stringify(t)===JSON.stringify(n)?null:{patch:{limiterGroups:t}}}function F8(e){return structuredClone(sy(e,Fh(e)))}const jNe={seconds:1,minutes:60,hours:3600};function wNe(e){return e>0&&e%3600===0?{value:String(e/3600),unit:"hours"}:e>0&&e%60===0?{value:String(e/60),unit:"minutes"}:e>0?{value:String(e),unit:"seconds"}:{value:"5",unit:"minutes"}}function RI(e){const{enabled:t,interval:n,retries:s,timeoutSeconds:i}=jK(e),o=wNe(t?n:0);return{enabled:t,intervalInput:o.value,unit:o.unit,retriesInput:String(s),timeoutInput:String(i||XS)}}function U8(e){const t=Number(e.retriesInput);if(!e.retriesInput.trim()||!Number.isInteger(t)||t<0||t>YS)return{error:a("失败重试次数必须是 0~{max} 的整数",{max:YS})};const n=Number(e.timeoutInput??XS);if(!Number.isInteger(n)||n<15||n>XP)return{error:a("整轮查询时限必须是 15~180 秒的整数")};if(!e.enabled)return{value:{enabled:!1,interval:0,retries:t,timeoutSeconds:n}};const s=Number(e.intervalInput),i=Math.round(s*jNe[e.unit]);return!Number.isFinite(s)||s<=0?{error:a("请填写查询间隔")}:iyK?{error:a("查询间隔必须是 {min} 秒 ~ 24 小时",{min:YP})}:{value:{enabled:!0,interval:i,retries:t,timeoutSeconds:n}}}function kNe(e,t){const n=U8(t);if("error"in n)return n;const{enabled:s,interval:i,retries:o,timeoutSeconds:l}=n.value,u=jK(e);return s===u.enabled&&(!s||i===u.interval)&&o===u.retries&&l===u.timeoutSeconds?null:{patch:{usageQuery:{enabled:s,interval:s?i:u.interval,retries:o,timeoutSeconds:l}}}}function H8({draft:e,onChange:t,idPrefix:n="account-usage"}){const s=i=>t({...e,...i});return r.jsxs(r.Fragment,{children:[r.jsx(ct,{orientation:"horizontal",className:"field-row mt-2.5 acct-usage-toggle",children:r.jsxs(ut,{className:"inline-flex cursor-pointer items-center gap-2.5 font-normal",children:[r.jsx(St,{checked:e.enabled,onCheckedChange:i=>s({enabled:i===!0}),"aria-label":a("自动查询余额")}),r.jsx("span",{className:"text-xs text-subtle",children:a("自动查询余额(按下面的间隔自动刷新余额列的读数)")})]})}),e.enabled?r.jsxs(Lh,{orientation:"horizontal",className:"field-row mt-2.5 acct-usage-interval",children:[r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-interval`,children:a("查询间隔")}),r.jsx(ze,{id:`${n}-interval`,type:"number",min:1,step:1,className:"max-w-[110px]",value:e.intervalInput,onChange:i=>s({intervalInput:i.currentTarget.value})})]}),r.jsxs(Pt,{value:e.unit,onValueChange:i=>s({unit:i}),children:[r.jsx(Mt,{className:"w-[92px]","aria-label":a("间隔单位"),children:r.jsx(It,{children:e.unit==="hours"?a("小时"):e.unit==="minutes"?a("分钟"):a("秒")})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"seconds",children:a("秒")}),r.jsx(Ze,{value:"minutes",children:a("分钟")}),r.jsx(Ze,{value:"hours",children:a("小时")})]})]}),r.jsx("span",{className:"detail",children:a("30 秒 ~ 24 小时;手动查询会顺延下一轮")})]}):null,r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5 acct-usage-interval",children:[r.jsx(ut,{htmlFor:`${n}-timeout`,children:a("整轮查询时限")}),r.jsx(ze,{id:`${n}-timeout`,type:"number",min:15,max:XP,step:1,className:"max-w-[110px]",value:e.timeoutInput??String(XS),onChange:i=>s({timeoutInput:i.currentTarget.value})}),r.jsx("span",{className:"detail",children:a("秒;默认 60 秒,包含重试等待,多步骤查询可适当延长。")})]}),r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5 acct-usage-interval",children:[r.jsx(ut,{htmlFor:`${n}-retries`,children:a("失败重试次数")}),r.jsx(ze,{id:`${n}-retries`,type:"number",min:0,max:YS,step:1,className:"max-w-[110px]",value:e.retriesInput,"aria-describedby":`${n}-retries-hint`,onChange:i=>s({retriesInput:i.currentTarget.value})}),r.jsx("span",{id:`${n}-retries-hint`,className:"detail",children:a("只重试临时故障;次数与整轮时间上限任一用尽即停止,凭证错误不重试。")})]})]})}const Xd="max-w-full flex-wrap [&_[data-slot=segmented-item]]:h-7 [&_[data-slot=segmented-item]]:px-3 [&_[data-slot=segmented-item]]:text-[12.5px]";function SNe(e,t){const n=e&&typeof e=="object"?e.proxy:void 0;if(n==null)throw new Error(t("网关电脑未检测到可导入的系统代理;请手动填写,或选择已保存的代理。"));if(typeof n!="object"||Array.isArray(n))throw new Error(t("系统代理信息无效,请手动填写。"));const s=n;if(s.source!=="custom"||!["http","socks5"].includes(String(s.protocol))||typeof s.host!="string"||!s.host.trim()||typeof s.port!="number"||!Number.isInteger(s.port)||s.port<1||s.port>65535||typeof s.username!="string"||typeof s.password!="string")throw new Error(t("系统代理信息无效,请手动填写。"));return{source:"custom",protocol:s.protocol,host:s.host,port:s.port,username:s.username,password:s.password}}const NNe=new Set(["qwenwork-intl","qwenwork-enterprise","claude-subscription","codex-subscription","chatgpt-subscription","copilot-subscription","gemini-subscription"]);function PI(e){return NNe.has(e)}function CNe(e){return PI(e)}function fN(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n=typeof t.warning=="string"?t.warning.trim():"",s=typeof t.importNotice=="string"?t.importNotice.trim():"";if(!(!s&&!n))return{text:s||n,warning:!!n}}function Wt(){return window}function cr(e,t){Wt().wbApp?.toast?.(e,t)}function II(e,t=0){if(typeof e=="string")return e.trim();if(e instanceof Error)return e.message.trim();if(!e||typeof e!="object"||t>3)return"";const n=e;for(const s of["message","error","msg","reason"]){const i=II(n[s],t+1);if(i)return i}return""}function Oa(e){const t=II(e);return a(t||"未知错误")}function V8(e,t=0){if(e&&typeof e=="object"&&t<4){const s=e;for(const i of["status","statusCode","status_code","httpStatus"]){const o=s[i];if((typeof o=="number"||typeof o=="string")&&Number(o)===501)return!0}if(s.code==="not_implemented"||s.code==="auth_methods_unavailable"||s.error&&s.error!==e&&V8(s.error,t+1))return!0}const n=II(e);return n==="该提供商尚未申报动态登录方式,请使用既有登录入口"||/\b501\b|auth\.methods[^\n]*(?:not implemented|no method|未实现|不支持)/i.test(n)}function go(e){if(PI(e))return;const t=Wt().wbApp?.getState?.()?.accounts?.providers;return(Array.isArray(t)?t:Wt().wbProviders?.all?.()||[]).find(s=>s.id===e)}function ANe(e){return(Wt().wbApp?.getState?.()?.accounts?.accounts||[]).filter(n=>(n?.provider||"workbuddy")===e).length}async function _g(e,t,n){const s=Wt().__TAURI_INTERNALS__;if(!s||typeof s.invoke!="function")throw new Error(a("桌面运行时不可用(Tauri 未初始化)"));const i=await s.invoke("api_request",{request:{method:e,path:t,body:n===void 0?null:n}});if(i&&typeof i=="object"){const o=i;if(o.success===!1)throw i;if(o.success===!0&&Object.hasOwn(o,"data"))return o.data}return i}function Qd(e){return _g("POST","/api/accounts",e)}function Zd(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function ENe(e){const t=Zd(e);if(!t)return;const n={};for(const s of["id","name","uid","userId","provider"])typeof t[s]=="string"&&(n[s]=t[s]);return n.id||n.uid||n.userId?n:void 0}function hN(e){let t=Zd(e);if(t?.success===!1)throw e;t?.success===!0&&Object.hasOwn(t,"data")&&(t=Zd(t.data));const n=Zd(t?.payload),s=Zd(t?.session)||Zd(n?.session),i=[t,n,s].filter(f=>!!f);if(i.some(f=>f.canceled===!0||f.state==="canceled"||f.status==="canceled"))return{ok:!1,canceled:!0,silent:i.some(f=>f.silent===!0)};for(const f of i){if(f.error||f.ok===!1||f.success===!1||f.state==="failed"||f.status==="failed"||f.type==="error")throw new Error(Oa(f.error||f));if(f.pending===!0||Zd(f.pending)||f.accepted===!0||f.done===!1||f.state==="pending"||f.status==="pending")throw new Error(a("登录尚未完成,请继续通过共享登录桥等待结果"))}const o=i.map(f=>ENe(f.account)).find(Boolean),l=i.find(f=>typeof f.accountUid=="string"&&!!f.accountUid||typeof f.accountId=="string"&&!!f.accountId||typeof f.nickname=="string"&&!!f.nickname);if(!o&&!l&&i.some(f=>(f.flow||f.authUrl)&&f.done!==!0))throw new Error(a("登录尚未完成,请继续通过共享登录桥等待结果"));if(!o&&!l&&t?.ok!==!0)throw new Error(s&&!Object.keys(s).length?a("登录桥返回了空会话,无法确认账号已添加"):a("登录桥未返回已完成的账号或会话,请重试"));const u=f=>{const m=i.map(g=>g[f]).find(g=>typeof g=="string"&&g.trim());return typeof m=="string"?m:void 0},d=i.map(f=>f.proxySaved).find(f=>typeof f=="boolean");return{ok:!0,canceled:!1,account:o,warning:u("warning"),instructions:u("instructions"),...typeof d=="boolean"?{proxySaved:d}:{},session:l?Object.fromEntries(["accountUid","accountId","nickname","edition","provider"].filter(f=>typeof l[f]=="string").map(f=>[f,l[f]])):void 0}}async function q8(e,t){if(e.canceled||e.proxySaved===!0)return e;const n=e.account?.id||e.session?.accountUid||e.session?.accountId;let s=a("旧网关未确认代理同次保存,已使用兼容接口保存;请在账号设置中确认代理选择。");try{if(typeof n!="string"||!n)throw new Error("Missing account ID");await _g("PATCH",`/api/accounts/${encodeURIComponent(n)}`,{proxy:t??{source:"direct"}})}catch{s=a("账号已添加,但代理选择未确认保存;请在账号设置中重新检查。")}return{...e,warning:[e.warning,s].filter(Boolean).join(` +`)}}async function mN(e,t="cn",n="embedded",s,i){const o=i!==void 0&&i.methodIndex!==void 0;if(PI(e)||o&&!go(e))throw new Error(a("该提供商已不在运行时目录中,请返回列表重新选择"));try{const l=Wt().workbuddyDesktop;let u;if(o&&l?.platform!=="web"){const f=Wt().__TAURI_INTERNALS__;if(!f?.invoke)throw new Error(a("桌面运行时不可用(Tauri 未初始化)"));u=await f.invoke("start_login",{provider:e,edition:t,mode:n,socialRestore:s===!0,options:i})}else{if(!l?.startLogin)throw new Error(a("共享登录桥不可用,请重新打开面板"));u=await l.startLogin(t,n,e,s,i)}const d=hN(u);if(o&&!d.canceled){const f=d.account?.id||d.session?.accountUid||d.session?.accountId,m=d.account?.provider||d.session?.provider;if(!f||m&&m!==e)throw new Error(a("登录桥返回了空会话,无法确认账号已添加"))}return i&&Object.hasOwn(i,"proxy")&&!d.canceled?await q8(d,i.proxy):d}catch(l){const u=Zd(l);if(u?.canceled===!0)return{ok:!1,canceled:!0,silent:u.silent===!0};throw new Error(Oa(l))}}function Jd(e){return e?.name||e?.uid||e?.userId||""}function MI(){Wt().wbAddAccountModal?.close?.()}async function Ll(e,t,n){MI(),await Wt().wbApp?.refresh?.();const s=a("✅ {label}账号已添加{name}",{label:t,name:e?`:${e}`:""}),i=fN(n);cr(i?`${s} +${a(i.text)}`:s,i?.warning?"warn":"ok")}const Dg=new Map;function xo(e){return{defaultValue:Dg.get(e)??"",onChange:t=>{const n=t.currentTarget.value;n?Dg.set(e,n):Dg.delete(e)}}}function ef(e,t){t?Dg.set(e,t):Dg.delete(e);const n=document.getElementById(e);(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&(n.value=t)}function Zo(e){const t=document.getElementById(e);return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t.value.trim():(Dg.get(e)??"").trim()}function _I(e){for(const t of e)ef(t,"")}const Yh={edition:"cn",loginMode:"embedded",socialRestore:!1},K8=8;function DI(e){return e?.success?e.status===void 0||e.status===""||Number(e.status)>=200&&Number(e.status)<300:!1}function LI(e){return e?.error||(e?.status?`HTTP ${String(e.status)}`:a("连接失败"))}function Lg(e){const t=e?.config?.source||e?.source,n=e?.config||null,s=t==="rotate";return{mode:t==="pool"?"pool":s?"rotate":t==="clash"?"clash":t==="custom"?"custom":t==="subscription"?"retired":"none",listenerUid:t==="clash"?String(n?.listenerUid||""):"",proxyId:t==="pool"?String(n?.proxyId||""):"",rotateAll:s?n?.all!==!1:!0,rotateIds:s&&Array.isArray(n?.proxyIds)?n.proxyIds.map(String):[],protocol:n?.protocol==="socks5"?"socks5":"http",host:n?.host||"",port:n?.port===void 0||n?.port===null?"":String(n.port),username:n?.username||"",password:n?.password||"",nonDirect:n?.nonDirect===!0}}function yc(e){if(e.mode==="none")return null;if(e.mode==="retired")throw new Error(a("原代理来源已下线,请选择已保存的代理、自定义地址或直连"));if(e.mode==="clash"){if(!e.listenerUid)throw new Error(a("请先选择 Clash Verge 出口"));return{source:"clash",listenerUid:e.listenerUid}}if(e.mode==="pool"){if(!e.proxyId)throw new Error(a("请先选择已保存的代理"));return{source:"pool",proxyId:e.proxyId}}if(e.mode==="rotate"){if(e.rotateAll)return{source:"rotate",all:!0};if(!e.rotateIds.length)throw new Error(a("轮询至少要选择一条代理(或改选「全部」)"));return{source:"rotate",all:!1,proxyIds:[...e.rotateIds]}}const t=e.host.trim(),n=Number(e.port);if(!t)throw new Error(a("请填写代理主机地址"));if(!Number.isInteger(n)||n<1||n>65535)throw new Error(a("代理端口必须是 1-65535 的整数"));return{source:"custom",protocol:e.protocol==="socks5"?"socks5":"http",host:t,port:n,username:e.username.trim(),password:e.password,nonDirect:e.nonDirect===!0}}function G8(e){return`${e.name||e.uid} :${e.port}${e.profileActive===!1?a("(其他订阅,可能未生效)"):""}${e.enabled===!1?a("(已在 Clash 中禁用)"):""}`}function pN({draft:e,onChange:t,idPrefix:n,allowRotate:s=!1,allowSystemImport:i=!1,onSystemImportBusy:o}){const[l,u]=p.useState(!1),[d,f]=p.useState(!1),[m,g]=p.useState(""),v=p.useRef({draft:e,onChange:t,onSystemImportBusy:o});v.current={draft:e,onChange:t,onSystemImportBusy:o};const b=p.useRef(0),y=p.useRef(!1);p.useEffect(()=>()=>{b.current+=1,y.current&&(y.current=!1,v.current.onSystemImportBusy?.(!1))},[]);const[k,w]=p.useState(null),[S,N]=p.useState(null),[C,T]=p.useState(""),[P,O]=p.useState(null),[A,R]=p.useState(""),M=P?.options||[],_=JSON.stringify(e),[L,$]=p.useState(""),D=U=>t({...e,...U}),F=p.useCallback(()=>{R(""),Promise.resolve(ft().workbuddyDesktop?.getProxies?.()).then(U=>{if(!U?.clash||!Array.isArray(U.clash.options))throw new Error(a("代理列表响应异常"));O(U.clash)}).catch(U=>{O({available:!1,options:[]}),R(dn(U))})},[]);p.useEffect(()=>{e.mode==="clash"&&P===null&&F()},[e.mode,P,F]);const V=p.useCallback((U=!1)=>{T(""),SI({force:U}).then(z=>N(z)).catch(z=>{N([]),T(dn(z))})},[]);p.useEffect(()=>{(e.mode==="pool"||e.mode==="rotate")&&S===null&&V()},[e.mode,S,V]);function K(){return e.rotateAll?(S??[]).filter(U=>U.enabled!==!1).map(U=>U.id):[...e.rotateIds]}async function Q(){if(y.current)return;y.current=!0;const U=++b.current,z=JSON.stringify(v.current.draft);f(!0),g(""),v.current.onSystemImportBusy?.(!0);try{const q=SNe(await _g("GET","/api/proxies/system"),a);if(U!==b.current||JSON.stringify(v.current.draft)!==z)return;v.current.onChange({...v.current.draft,mode:"custom",protocol:q.protocol,host:q.host,port:String(q.port),username:q.username,password:q.password,nonDirect:!1})}catch(q){U===b.current&&g(dn(q))}finally{U===b.current&&(y.current=!1,f(!1),v.current.onSystemImportBusy?.(!1))}}async function X(){if(l)return;if($(_),w(null),e.mode==="rotate"){const z=K();if(!z.length){Ct(a("轮询至少要选择一条代理(或改选「全部」)"),"err");return}const q=z.slice(0,K8);u(!0),w(a("正在连接上游…"));let J=0;const ee=[];for(const Y of q){const se=S?.find(re=>re.id===Y)?.name||Y;try{const re=await ft().workbuddyDesktop?.testProxyPoolItem?.(Y);DI(re)?J+=1:ee.push(`${se}(${LI(re)})`)}catch(re){ee.push(`${se}(${dn(re)})`)}}const H=z.length-q.length,G=a("✅ {ok}/{total} 个出口可用",{ok:J,total:q.length})+(H>0?a("(只测了前 {limit} 个,还有 {rest} 个未测)",{limit:K8,rest:H}):"");w(r.jsxs("span",{className:ee.length?"text-destructive":"text-success",children:[G,ee.length?` ${Yo(ee.join(a(";")))}`:""]})),u(!1);return}if(e.mode==="pool"){if(!e.proxyId){Ct(a("请先选择已保存的代理"),"err");return}u(!0),w(a("正在连接上游…"));try{const z=await ft().workbuddyDesktop?.testProxyPoolItem?.(e.proxyId);w(DI(z)?r.jsxs("span",{className:"text-success",children:[a("✅ 出口可用"),z.ip?a(" 出口 IP {ip}",{ip:Yo(z.ip)}):"",z.durationMs!==void 0&&z.durationMs!==""?` ${Yo(String(z.durationMs))}ms`:""]}):r.jsxs("span",{className:"text-destructive",children:["❌ ",Yo(LI(z))]}))}catch(z){w(r.jsxs("span",{className:"text-destructive",children:["❌ ",Yo(dn(z))]}))}finally{u(!1)}return}let U;try{U=yc(e)}catch(z){Ct(dn(z),"err");return}u(!0),w(a("正在连接上游…"));try{const z=await ft().workbuddyDesktop?.testProxy?.({proxy:U});DI(z)?w(r.jsxs("span",{className:"text-success",children:[a("✅ 出口可用"),z.status!==void 0&&z.status!==""?` HTTP ${Yo(String(z.status))}`:"",z.ip?a(" 出口 IP {ip}",{ip:Yo(z.ip)}):"",z.durationMs!==void 0&&z.durationMs!==""?` ${Yo(String(z.durationMs))}ms`:""]})):w(r.jsxs("span",{className:"text-destructive",children:["❌ ",Yo(LI(z))]}))}catch(z){w(r.jsxs("span",{className:"text-destructive",children:["❌ ",Yo(dn(z))]}))}finally{u(!1)}}return r.jsxs("div",{className:"acct-proxy-form flex flex-col",children:[e.mode==="retired"?r.jsx("p",{className:"mb-3 text-xs text-destructive",children:a("原代理来源已下线,请选择已保存的代理、自定义地址或直连")}):null,r.jsx(en,{"aria-label":a("代理方式"),className:Xd,value:e.mode,onValueChange:U=>D({mode:U}),options:[{value:"none",label:a("无代理(直连)")},{value:"pool",label:a("已保存的代理")},...s?[{value:"rotate",label:a("轮询(换 IP)"),title:a("逐请求轮换出口(换 IP):OpenCode Zen 免费档按 IP 限流,单个 IP 的额度用完会对它一律 429")}]:[],...e.mode==="clash"?[{value:"clash",label:"Clash Verge"}]:[],{value:"custom",label:a("自定义")}]}),i?r.jsxs("div",{className:"mt-3 flex flex-col items-start gap-1.5",children:[r.jsx(B,{variant:"outline",size:"sm",disabled:d,onClick:()=>{Q()},children:a(d?"正在读取…":"填入系统代理")}),r.jsx("p",{className:"detail",children:a("读取网关电脑当前的 HTTPS 系统代理,填入自定义地址;后续系统设置变化不会自动同步。")}),m?r.jsx("p",{className:"text-xs text-destructive",role:"alert",children:m}):null]}):null,e.mode==="pool"?r.jsxs("div",{className:"mt-3",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:`${n}-pool-exit`,children:a("代理")}),r.jsxs(Pt,{value:e.proxyId,disabled:!S?.length,onValueChange:U=>D({proxyId:String(U)}),children:[r.jsx(Mt,{id:`${n}-pool-exit`,className:"min-w-[220px]",children:r.jsx(It,{children:S?.find(U=>U.id===e.proxyId)?Ag(S.find(U=>U.id===e.proxyId)):e.proxyId?a("当前代理不可用,请重新选择"):S===null?a("正在读取…"):S.length?a("请选择代理"):a("还没有保存的代理")})}),r.jsx(_t,{children:(S??[]).map(U=>r.jsx(Ze,{value:U.id,disabled:U.enabled===!1,children:Ag(U)},U.id))})]}),r.jsx(B,{variant:"outline",size:"sm",onClick:()=>V(!0),children:a("重新读取")})]}),r.jsx("div",{className:"detail mt-1.5",children:C?a("读取失败:{error}",{error:C}):S===null?a("正在读取代理列表…"):S.length?a("地址与端口由「网络代理」页管理:那边改一次、测一次,所有引用它的账号一起生效"):a("「网络代理」页还没有出口 —— 去那里添加手动地址或同步 Clash Verge 的端点")})]}):null,e.mode==="rotate"?r.jsxs("div",{className:"mt-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1",children:[r.jsx(jr,{id:`${n}-rotate-all`,checked:e.rotateAll,"aria-label":a("轮询全部代理节点"),onCheckedChange:U=>D({rotateAll:U===!0})}),r.jsx(Ae,{htmlFor:`${n}-rotate-all`,className:"cursor-pointer text-xs text-subtle",children:a("全部代理节点(推荐)")}),r.jsx("span",{className:"detail",children:a("「网络代理」页里每个启用的出口轮流使用;之后新加的出口自动加入")})]}),e.rotateAll?null:r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5",children:[r.jsx(ut,{htmlFor:`${n}-rotate-exits`,children:a("轮询的代理")}),r.jsx(xc,{id:`${n}-rotate-exits`,value:e.rotateIds,onValueChange:U=>D({rotateIds:U.map(String)}),options:(S??[]).map(U=>({value:U.id,label:Ag(U),disabled:U.enabled===!1})),placeholder:a("选择要轮询的代理(可多选)"),"aria-label":a("轮询的代理")}),r.jsx(B,{variant:"outline",size:"sm",onClick:()=>V(!0),children:a("重新读取")})]}),r.jsx("div",{className:"detail mt-1.5",children:C?a("读取失败:{error}",{error:C}):S===null?a("正在读取代理列表…"):S.length?a("每条请求换一个出口(按顺序轮流),上游看到的 IP 因此是变化的;出口的地址与端口由「网络代理」页管理"):a("「网络代理」页还没有出口 —— 去那里添加手动地址或同步 Clash Verge 的端点")})]}):null,e.mode==="clash"?r.jsxs("div",{className:"mt-3",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:`${n}-clash-exit`,children:a("出口")}),r.jsxs(Pt,{value:e.listenerUid,disabled:!M.length,onValueChange:U=>D({listenerUid:String(U)}),children:[r.jsx(Mt,{id:`${n}-clash-exit`,className:"min-w-[220px]",children:r.jsx(It,{children:M.find(U=>U.uid===e.listenerUid)?G8(M.find(U=>U.uid===e.listenerUid)):e.listenerUid?a("当前代理不可用,请重新选择"):a("请选择出口")})}),r.jsx(_t,{children:M.filter(U=>U.uid).map(U=>r.jsx(Ze,{value:String(U.uid),disabled:U.enabled===!1,children:G8(U)},U.uid))})]}),r.jsx(B,{variant:"outline",size:"sm",onClick:F,children:a("重新读取")})]}),r.jsx("p",{className:"detail mt-1.5",children:A?a("读取失败:{error}",{error:A}):P===null?a("正在读取 Clash Verge 配置…"):P.available===!1?a("不可用:{error}",{error:P.error||a("未检测到 Clash Verge 配置")}):a("读取自 {dir};端口由 Clash Verge 管理,这里实时同步",{dir:P.dir||"Clash Verge"})}),r.jsx("p",{className:"detail mt-1.5",children:a("既有 Clash Verge 直接引用继续可用;也可在「网络代理」页同步端点,再改选「已保存的代理」。")})]}):null,e.mode==="custom"?r.jsxs("div",{className:"mt-3",children:[r.jsxs(Lh,{orientation:"horizontal",className:"field-row",children:[r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-protocol`,children:a("协议")}),r.jsxs(Pt,{value:e.protocol,onValueChange:U=>D({protocol:U}),children:[r.jsx(Mt,{id:`${n}-protocol`,className:"min-w-[110px]",children:r.jsx(It,{children:e.protocol==="socks5"?"SOCKS5":"HTTP"})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:"http",children:"HTTP"}),r.jsx(Ze,{value:"socks5",children:"SOCKS5"})]})]})]}),r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-host`,className:"ml-2",children:a("主机")}),r.jsx(ze,{id:`${n}-host`,className:"min-w-[140px]",placeholder:"127.0.0.1",value:e.host,onChange:U=>D({host:U.currentTarget.value})})]}),r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-port`,children:a("端口")}),r.jsx(ze,{id:`${n}-port`,type:"number",min:1,max:65535,className:"max-w-[110px]",placeholder:"7890",value:e.port,onChange:U=>D({port:U.currentTarget.value})})]})]}),r.jsxs(Lh,{orientation:"horizontal",className:"field-row mt-2.5",children:[r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-user`,children:a("用户名")}),r.jsx(ze,{id:`${n}-user`,placeholder:a("可选"),autoComplete:"off",value:e.username,onChange:U=>D({username:U.currentTarget.value})})]}),r.jsxs(ct,{className:"contents",children:[r.jsx(ut,{htmlFor:`${n}-pass`,children:a("密码")}),r.jsx(ze,{id:`${n}-pass`,type:"password",placeholder:a("可选"),autoComplete:"new-password",value:e.password,onChange:U=>D({password:U.currentTarget.value})})]})]}),r.jsxs(Ae,{className:"mt-3 flex cursor-pointer items-center gap-2 text-xs font-normal",children:[r.jsx(jr,{checked:e.nonDirect===!0,onCheckedChange:U=>D({nonDirect:U})}),a("非直连代理")]}),r.jsx("p",{className:"detail mt-1.5",children:a("非直连会先经过网关所在设备的系统代理,再连接到此代理;系统代理不可用时不会改走直连。")})]}):null,r.jsxs(Lh,{orientation:"horizontal",className:"field-row mt-3",children:[r.jsx(B,{variant:"outline",size:"sm",disabled:l,onClick:()=>{X()},children:a(l?"测试中…":"测试出口")}),r.jsx("span",{className:"detail",children:L===_?k:null})]})]})}const $I=[{value:"enable",label:()=>a("启用")},{value:"disable",label:()=>a("禁用")},{value:"refresh",label:()=>a("刷新 Token")},{value:"proxy",label:()=>a("修改代理")},{value:"concurrency",label:()=>a("设置并发上限")},{value:"usageQuery",label:()=>a("查询设置")},{value:"limiters",label:()=>a("限制器")},{value:"remove",label:()=>a("删除")}],zI=[{value:"append",label:()=>a("追加规则(保留原有)")},{value:"replace",label:()=>a("替换全部规则")},{value:"enable",label:()=>a("启用全部规则")},{value:"disable",label:()=>a("停用全部规则")},{value:"clear",label:()=>a("清空全部规则")}];function tf(e){return Ci(e)||e?.id||""}function TNe({ids:e,action:t,onClose:n}){const[s,i]=p.useState($I.some(ee=>ee.value===t)?t:"enable"),[o,l]=p.useState(()=>Lg(null)),[u,d]=p.useState(""),[f,m]=p.useState(()=>({...RI(null),intervalInput:""})),[g,v]=p.useState("append"),[b,y]=p.useState([]),[k,w]=p.useState(""),[S,N]=p.useState(!1),[C,T]=p.useState(""),[P,O]=p.useState(null),A=p.useRef(!1),R=e.map(ee=>_l(ee)).filter(ee=>ee!==null),M=R.filter(Si),_=s==="limiters"&&(g==="append"||g==="replace"),L=_&&b.some(ee=>ee.conditions.some(H=>H.metric!=="tokens"&&H.metric!=="requests")),$=s==="refresh"?R.filter(ee=>!KP(ee)):s==="usageQuery"||L?M:R,D=R.filter(ee=>!$.includes(ee)),F=s==="usageQuery"?M:R,V=F.find(ee=>ee.id===k),K=R.reduce((ee,H)=>Math.max(ee,Number(Ga(tn(H)).concurrencyDefault)||0),0),Q=R.length>0&&R.every(Hke),X=s==="remove"||s==="limiters"&&(g==="replace"||g==="clear"),U=s==="limiters"?g==="append"?a("追加限制规则"):zI.find(ee=>ee.value===g).label():$I.find(ee=>ee.value===s).label();function z(){V&&(s==="usageQuery"?m(RI(V)):y(F8(V)),T(""),Ct(a("已复制到草稿,执行后才会应用到所选账号")))}async function q(){const ee=ft().wbConfirm?.ask;if(s==="remove"&&!await Promise.resolve(ee?.({title:a("删除选中的账号"),html:a("确定删除选中的 {count} 个账号?此操作不可恢复,账号的登录态会一并移除。",{count:e.length}),okText:a("删除"),okClass:"danger"})??!1))return!1;if(s==="disable"||s==="remove"){const H=new Set(e);if(!Ml().filter(Y=>Y.enabled!==!1&&!H.has(Y.id)).length){const Y=a(s==="remove"?"删除":"禁用");return Promise.resolve(ee?.({title:a("全部启用中的账号将被{what}",{what:Y}),html:a("这会{what}所有启用中的账号,转发将不可用。确定继续?",{what:Y}),okText:Y,okClass:s==="remove"?"danger":"primary"})??!1)}}return s==="limiters"&&g==="replace"?Promise.resolve(ee?.({title:a("替换选中账号的限制规则"),html:a("将用草稿中的 {rules} 条规则替换 {count} 个账号的全部限制规则,原有规则不会保留。确定继续?",{rules:b.length,count:$.length})+(D.length?`

${a("以下 {count} 个账号不支持余额查询,本次会跳过:{names}",{count:D.length,names:Yo(D.map(tf).join(a("、")))})}

`:""),okText:a("替换全部规则"),okClass:"danger"})??!1):s==="limiters"&&g==="clear"?Promise.resolve(ee?.({title:a("清空选中账号的限制规则"),html:a("确定清空 {count} 个账号的全部限制规则?余额与 Token 将不再设限;已禁用的账号不会自动启用。",{count:$.length}),okText:a("清空全部规则"),okClass:"danger"})??!1):!0}async function J(){if(A.current)return;if(!e.length){Ct(a("没有选中的账号"),"err");return}if(!$.length){Ct(a("没有适用于本次操作的账号"),"err");return}const ee={action:s,ids:e};try{if(s==="proxy"&&(ee.proxy=yc(o)),s==="concurrency"){const H=Number(u.trim());if(!u.trim()||!Number.isFinite(H)||H<0)throw new Error(a("并发上限必须是 0~{max} 的整数",{max:Su}));ee.maxConcurrent=Math.min(Su,Math.round(H))}if(s==="usageQuery"){const H=U8(f);if("error"in H)throw new Error(H.error);ee.usageQuery=H.value}if(s==="limiters"&&(ee.limiterMode=g,_)){if(!b.length)throw new Error(a("请至少添加一条限制规则;清空请使用清空操作"));if(b.some(H=>H.conditions.some(G=>G.sourceId!==""&&G.sourceId!=="local"&&G.sourceId!=="account")))throw new Error(a("套餐实例不能跨账号复制,请改用通用额度或本地保护条件"));ee.limiterGroups=structuredClone(b)}}catch(H){T(r.jsx("span",{className:"text-destructive",children:dn(H)})),Ct(dn(H),"err");return}A.current=!0,N(!0),T(""),O(null);try{if(!await q())return;let H;if(s==="refresh")H=await xNe(e,O);else{const ie=ft().workbuddyDesktop;if(!ie?.batchAccounts)throw new Error(a("批量操作接口不可用,请重新打开页面"));H=EI(await ie.batchAccounts(ee),ee)}const G=H.ok||[],Y=s==="remove"?(H.removed||[]).length:s==="refresh"?G.length:G.filter(ie=>ie.changes?.length).length,se=s==="remove"?0:G.length-Y,re=H.failed||[],ne=H.skipped||[],de=s==="refresh"?a("刷新 Token 完成:成功 {ok} 个,跳过 {skip} 个,失败 {fail} 个",{ok:Y,skip:ne.length,fail:re.length}):a("{verb}完成:成功 {ok} 个,未变更 {unchanged} 个,跳过 {skip} 个,失败 {fail} 个",{verb:U,ok:Y,unchanged:se,skip:ne.length,fail:re.length});Ct(de,re.length?"err":"ok"),re.length||ne.length?T(r.jsxs("div",{role:"status",className:"space-y-2",children:[r.jsx("p",{children:de}),ne.length?r.jsxs("p",{children:[a("跳过 {count} 个:",{count:ne.length}),ne.map(ie=>`${tf(_l(String(ie.id)))||ie.name||ie.id}(${ie.reason})`).join(a(";"))]}):null,re.length?r.jsxs("p",{className:"text-destructive",children:[a("失败 {count} 个:",{count:re.length}),re.map(ie=>`${tf(_l(String(ie.id)))||ie.id}(${ie.error})`).join(a(";"))]}):null]})):n();try{await Qo(),await Ig()}catch(ie){Ct(a("批量操作已保存,但列表刷新失败:{error}",{error:dn(ie)}),"err")}}catch(H){T(r.jsx("span",{className:"text-destructive",children:dn(H)})),Ct(a("批量操作失败:{error}",{error:dn(H)}),"err")}finally{A.current=!1,N(!1),O(null)}}return r.jsx(at,{open:!0,onOpenChange:ee=>{ee||S||n()},children:r.jsxs(it,{className:"w-[min(900px,calc(100vw-48px))]",showCloseButton:!S,children:[r.jsx(ot,{children:r.jsx(st,{children:a("批量操作 · 已选 {count} 个账号",{count:e.length})})}),r.jsxs(lt,{children:[r.jsxs(C0e,{disabled:S,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0",children:[r.jsxs(as,{children:[r.jsx("h3",{children:a("将作用于以下账号")}),r.jsx("p",{className:"max-h-[84px] overflow-y-auto",children:$.map(tf).join(a("、"))||a("没有适用于本次操作的账号")}),D.length?r.jsx("p",{className:"max-h-[84px] overflow-y-auto",children:s==="refresh"?r.jsxs(r.Fragment,{children:[a("跳过 {count} 个:",{count:D.length}),D.map(ee=>`${tf(ee)}(${KP(ee)})`).join(a(";"))]}):a("以下 {count} 个账号不支持余额查询,本次会跳过:{names}",{count:D.length,names:D.map(tf).join(a("、"))})}):null,s==="refresh"?r.jsx("p",{children:a("逐个刷新所选账号的 Token,未到期也会尝试刷新;不改变启用状态、代理或转发顺序。")}):s!=="remove"?r.jsx("p",{children:a("只修改本次选择的设置,不影响备注、凭证、转发顺序或其他设置。")}):null]}),r.jsxs(as,{children:[r.jsx("h3",{children:a("操作")}),r.jsx(bg,{value:s,onValueChange:ee=>{i(ee),T("")},disabled:S,className:"flex-row flex-wrap items-center gap-5","aria-label":a("批量动作"),children:$I.map(ee=>r.jsxs(Ae,{className:"inline-flex cursor-pointer items-center gap-2 font-normal",children:[r.jsx(Mh,{value:ee.value}),ee.label()]},ee.value))}),s==="proxy"?r.jsx("div",{className:"mt-2.5",children:r.jsx(pN,{draft:o,onChange:l,idPrefix:"batch-proxy",allowRotate:Q})}):null,s==="concurrency"?r.jsxs("div",{className:"mt-2.5",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:"batch-conc-input",children:a("并发上限")}),r.jsx(ze,{id:"batch-conc-input",type:"number",min:0,max:Su,step:1,className:"max-w-[110px]",placeholder:a("并发上限"),value:u,onChange:ee=>d(ee.currentTarget.value)}),r.jsx("span",{className:"detail",children:a("0 = 不限")})]}),r.jsx("p",{className:"detail mt-2.5",children:K>0?a("并发上限 0~{max};CodeArts 等有默认值的家填 0 即按本家默认;达到上限的账号会被跳过、请求转给其他账号",{max:Su}):a("并发上限 0~{max};达到上限的账号会被跳过、请求转给其他账号",{max:Su})})]}):null,s==="limiters"?r.jsxs("div",{className:"mt-2.5",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:"batch-limiter-mode",children:a("规则操作")}),r.jsxs(Pt,{value:g,onValueChange:ee=>{v(ee),T("")},children:[r.jsx(Mt,{id:"batch-limiter-mode",className:"min-w-[220px]",children:r.jsx(It,{children:zI.find(ee=>ee.value===g).label()})}),r.jsx(_t,{children:zI.map(ee=>r.jsx(Ze,{value:ee.value,children:ee.label()},ee.value))})]})]}),r.jsx("p",{className:"detail mt-2.5",children:a(g==="append"?"保留各账号原有规则,只追加下面的规则;完全相同的规则不会重复添加。":g==="replace"?"用下面的规则统一替换各账号的全部规则,执行前会再次确认。":g==="clear"?"删除各账号的全部限制规则,执行前会再次确认。":"仅统一修改现有规则的开关,保留阈值、动作和重置方式;不改变账号的启用状态。")})]}):null,s==="usageQuery"||_?r.jsxs("div",{className:"mt-2.5",children:[r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{htmlFor:"batch-settings-source",children:a("复制自账号")}),r.jsxs(Pt,{value:V?.id||"",disabled:!F.length,onValueChange:ee=>w(String(ee)),children:[r.jsx(Mt,{id:"batch-settings-source",className:"min-w-0 flex-1",children:r.jsx(It,{children:V?tf(V):a("选择所选账号作为模板(可选)")})}),r.jsx(_t,{children:F.map(ee=>r.jsx(Ze,{value:ee.id,children:tf(ee)},ee.id))})]}),r.jsx(B,{variant:"outline",size:"sm",disabled:!V,onClick:z,children:a("复制当前设置")})]}),s==="usageQuery"?r.jsxs(r.Fragment,{children:[r.jsx(H8,{draft:f,onChange:m,idPrefix:"batch-usage"}),r.jsx("p",{className:"detail mt-2.5",children:a("统一设置自动查询的开关、间隔和失败重试次数;不会复制或覆盖余额查询凭证。")})]}):r.jsx(B8,{draft:b,onChange:y,allowBalance:M.length>0})]}):null,s==="usageQuery"&&!f.enabled?r.jsx("p",{className:"detail mt-2.5",children:a("关闭自动查询后,余额限制器只能使用上次读数;手动查询仍可用。")}):null,s==="limiters"?r.jsx("p",{className:"detail mt-2.5",children:a("Token 规则按每个账号已有的窗口消耗判定,保存不会清零;停用或清空规则不会自动启用账号。")}):null]})]}),P?r.jsx("p",{role:"status",className:"detail",children:a("刷新 Token:已处理 {completed}/{total} 个,当前账号:{name}",P)}):null,r.jsx("div",{className:"detail min-h-[18px]",children:C})]}),r.jsxs(xt,{children:[r.jsx("div",{className:"mr-auto"}),r.jsx(B,{variant:"outline",disabled:S,onClick:n,children:a("取消")}),r.jsx(B,{variant:X?"destructive":"default",disabled:S||!$.length,onClick:()=>{J()},children:S?a("执行中…"):a("执行({action})",{action:U})})]})]})})}const BI=7*864e5;function ONe(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function W8(e){const t=typeof e=="string"?e.trim():"";return zh(t)?"积分":t}function gN(e){const t=ONe(e);return t?W8(t.unit)||(Object.prototype.hasOwnProperty.call(t,"totalLeft")?"积分":""):""}function Y8(e,t,n=Date.now()){if(["snapshot","record","daily","rolling","unlimited"].some(f=>e[f]===!0))return null;const s=Os(e.remain),i=Os(e.total),o=Os(e.used),l=Os(e.remainingPercent);if(i===-1||s!==null&&s<=0||s===null&&(o!==null&&i!==null&&i>0&&o>=i||l!==null&&l<=0))return null;const u=Os(e.startAt);if(u!==null&&u>n)return null;const d=Os(e.expireAt);return d===null||d<=n||d>n+BI||!Number.isFinite(new Date(d).getTime())?null:{expireAt:d,remain:s,unit:W8(e.unit)||t}}function RNe(e,t=Date.now()){const n=gN(e);return BP(e).map(s=>Y8(s,n,t)).filter(s=>s!==null)}function X8(e){const t=new Map;for(const n of e){let s=t.get(n.unit);s||(s={unit:n.unit,sum:null,count:0,unknownCount:0},t.set(n.unit,s)),s.count++,n.remain===null&&s.unknownCount++,n.remain!==null&&n.unit&&n.unit!=="%"&&(s.sum=(s.sum??0)+n.remain)}return[...t.values()]}function xN(e,t=Date.now()){const n=e.filter(o=>o.expireAt>t&&o.expireAt<=t+BI),s=new Date(t);s.setHours(24,0,0,0);const i=n.filter(o=>o.expireAt0&&e<.01?t("不足 {n}",{n:n(.01)}):n(e)}function Z8(e,t,n){return e.map(s=>{if(!s.unit)return t("{count} 份单位未知",{count:s.count});if(s.unit==="%")return t("{count} 份仅提供比例",{count:s.count});const i=mo(s.unit,t);if(s.sum===null)return t("{unit}余量未知({count} 份)",{unit:i,count:s.count});const o=`${Q8(s.sum,t,n)} ${i}`;return s.unknownCount>0?t("{amount},另 {count} 份余量未知",{amount:o,count:s.unknownCount}):o}).join(";")}function vN(e,t,n,s=""){if(!e.count)return{badge:"",group:"",summary:"",today:"",detail:""};const i=e.amounts.length===1?e.amounts[0]:null,o=zh(s)&&i?.unit==="积分"&&i.unknownCount===0&&i.sum!==null?Q8(i.sum,t,n):null,l=t("7 天内到期 {amount}({count} 份)",{amount:Z8(e.amounts,t,n),count:e.count}),u=e.todayCount>0?t("今天到期 {amount}({count} 份)",{amount:Z8(e.todayAmounts,t,n),count:e.todayCount}):"";return{badge:o===null?t("7天 {count}份",{count:e.count}):t("7天 {n}",{n:o}),group:o===null?t("即将到期 {count} 份",{count:e.count}):t("即将过期 {n}",{n:o}),summary:l,today:u,detail:[l,u].filter(Boolean).join(";")}}function J8(e,t,n=Date.now()){const s=new Date(e),i=e-n;if(!Number.isFinite(s.getTime())||i<=0)return"";const o=new Date(n);if(s.getFullYear()===o.getFullYear()&&s.getMonth()===o.getMonth()&&s.getDate()===o.getDate()){if(i<6e4)return t("不到 1 分钟到期");const d=Math.floor(i/36e5);return d<1?t("{minutes} 分钟后到期",{minutes:Math.floor(i/6e4)}):t("{hours} 小时后到期",{hours:d})}const l=d=>Date.UTC(d.getFullYear(),d.getMonth(),d.getDate()),u=Math.round((l(s)-l(o))/864e5);return u===1?t("明天到期"):t("{days} 天后到期",{days:u})}function $l(e){if(e==null||e==="")return null;const t=Number(e);return Number.isFinite(t)?t:null}function $g(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=s=>String(s).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function eG(e){return mo(e,a)}function PNe(e,t=Date.now()){const n=BP(e),s=gN(e);return n.map(i=>{const o=cK(i,a,Ln);if(o){const F=o.daily?a("每日重置"):null;return{name:o.name,view:o.view,tone:o.tone,percent:null,window:F,title:[o.name,o.view,F].filter(Boolean).join(" · "),spent:!1,snapshot:!0,amount:null,expiry:null}}const l=String(i?.name||"").trim()||a("积分包");if(i?.record===!0){const F=$l(i?.amount),V=String(i?.unit||"").trim(),K=$l(i?.at),Q=$l(i?.expireAt),X=F===null?"—":`${F>0?"+":""}${Ln(F)}`,U=V&&X!=="—"?`${X} ${eG(V)}`:X,z=[];K!==null&&K>0&&z.push($g(K)),Q!==null&&Q>0&&z.push(Q<=t?a("已过期"):a("{time} 到期",{time:$g(Q)}));const q=String(i?.remark||"").trim();return{name:l,view:U,tone:F!==null&&F<0?"muted":"ok",percent:null,window:z.length?z.join(" · "):null,title:[l,U,K!==null&&K>0?ki(K):"",Q!==null&&Q>0?a("到期 {time}",{time:ki(Q)}):"",q].filter(Boolean).join(" · "),spent:!1,amount:F,expiry:null}}const u=String(i?.unit||"").trim(),d=$l(i?.total),f=$l(i?.used),m=$l(i?.remain),g=i?.unlimited===!0,v=$l(i?.grantAt),b=$l(i?.startAt),y=$l(i?.expireAt),k=i?.daily===!0,w=i?.rolling===!0,S=$l(i?.resetAt),N=$l(i?.remainingPercent),C=String(i?.grantReason||"").trim(),T=y!==null&&y>0&&y<=t,P=d!==null&&d>0,O=g?a("不限"):m!==null?P?a("剩 {remaining} / {total}",{remaining:Ln(m),total:Ln(d)}):a("剩 {remaining}",{remaining:Ln(m)}):f!==null?a("已用 {used}",{used:Ln(f)}):N!==null?a("剩余 {percent}%",{percent:Math.round(N)}):"—",A=!g&&u&&O!=="—"?`${O} ${eG(u)}`:O,R=P&&m!==null?Math.max(0,Math.min(100,m/d*100)):N===null?null:Math.max(0,Math.min(100,N)),M=m!==null&&m<=0||m===null&&f!==null&&P&&f>=d,_=!g&&!k&&!w&&(M||T),L=[];v!==null&&v>0?L.push(a("{time} 领取",{time:$g(v)})):b!==null&&b>0&&L.push(a("{time} 生效",{time:$g(b)})),k?L.push(a("每日重置")):w&&S!==null&&S>0?L.push(a("重置 {date}",{date:$g(S)})):y!==null&&y>0&&L.push(T?a("已过期"):a("{time} 到期",{time:$g(y)})),C&&L.push(C);const $=T||m===0?"muted":R!==null&&R<20?"warn":m===null&&f===null&&!g?"muted":"ok",D=[l,A,v!==null&&v>0?a("领取 {time}",{time:ki(v)}):b!==null&&b>0?a("生效 {time}",{time:ki(b)}):"",y!==null&&y>0?T?a("已过期({time})",{time:ki(y)}):a("到期 {time}",{time:ki(y)}):"",k?a("每日重置(额度按周期回满,不是作废)"):"",C,R===null&&m!==null?a("上游未给总量,画不出剩余比例"):"",f!==null&&d!==null?a("已用 {used} / 共 {total}",{used:Ln(f),total:Ln(d)}):""].filter(Boolean).join(" · ");return{name:l,view:A,tone:$,percent:R,window:L.length?L.join(" · "):null,title:D,spent:_,amount:null,expiry:Y8(i,s,t)}})}function FI({row:e,now:t}){return r.jsxs("div",{className:"usage-pop-row",title:e.title,children:[r.jsxs("div",{className:"usage-pop-line",children:[r.jsx("span",{className:"usage-pop-name",children:e.name}),e.expiry?r.jsx("span",{className:"usage-pop-soon-tag",children:J8(e.expiry.expireAt,a,t)}):null,r.jsx("span",{className:`usage-pop-view ${e.tone}`,children:e.view})]}),e.window?r.jsx("div",{className:"usage-pop-window",children:e.window}):null,e.percent!==null?r.jsx(kg,{value:e.percent,variant:e.tone==="ok"?"success":e.tone==="warn"?"warning":"muted",className:"mt-1.5",trackClassName:"h-[3px]","aria-label":a("剩余 {percent}%",{percent:Math.round(e.percent)})}):null]})}function UI({rows:e,now:t,expiryUnit:n,subscriptionLine:s,aggregate:i,variant:o,kind:l,title:u,children:d}){const[f,m]=p.useState(!1),[g,v]=p.useState(!1),b=e.filter(R=>!R.spent),y=e.filter(R=>R.spent),k=e.length>0&&e.every(R=>R.snapshot)?a("余额详情"):a("积分明细"),w=b.filter(R=>R.expiry!==null),S=b.filter(R=>R.expiry===null),N=xN(w.flatMap(R=>R.expiry?[R.expiry]:[]),t),C=vN(N,a,Ln,n),T=o==="pool"?`usage-toggle usage-pool-line ${l}`:`usage-toggle ${l}`,P=p.useRef(null),O=p.useCallback(R=>{P.current=R,R&&(R.scrollTop=0)},[]),A=p.useCallback(()=>P.current??null,[]);return p.useLayoutEffect(()=>{if(!g)return;const R=P.current?.querySelector(".usage-pop-spent .usage-pop-row");R instanceof HTMLElement&&R.scrollIntoView({block:"nearest"})},[g]),r.jsxs(ui,{open:f,onOpenChange:m,children:[r.jsxs(wi,{render:r.jsx(B,{size:"default",variant:"ghost",type:"button",className:T,title:u,"aria-label":k}),children:[o==="pool"?d:r.jsx("span",{className:"val",children:d}),o==="sum"&&C.badge?r.jsx("span",{className:"usage-toggle-soon",children:C.badge}):null,r.jsx("span",{className:"caret","aria-hidden":!0,children:"▾"})]}),r.jsx(di,{align:"center",sideOffset:6,className:"w-[320px]",initialFocus:A,children:r.jsxs("div",{className:"usage-pop-credit",ref:O,tabIndex:-1,children:[s?r.jsx("div",{className:"usage-pop-sub",children:s}):null,i?r.jsxs("div",{className:"usage-pop-total",children:[r.jsx("span",{className:"k",children:i.label}),r.jsxs("span",{className:"v",children:[i.unlimited?a("不限"):Ln(i.remaining),!i.unlimited&&i.unit?r.jsxs(r.Fragment,{children:[" ",r.jsx("small",{children:i.unit})]}):null]})]}):null,r.jsx("div",{className:"usage-pop-group",children:k}),N.count>0?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"usage-pop-soon",children:[r.jsx("span",{children:C.summary}),C.today?r.jsx("span",{children:C.today}):null]}),w.map((R,M)=>r.jsx(FI,{row:R,now:t},`soon-${R.name}-${M}`))]}):null,S.map((R,M)=>r.jsx(FI,{row:R,now:t},`${R.name}-${M}`)),y.length>0?r.jsxs("div",{className:"usage-pop-spent",children:[r.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"usage-pop-spent-head","aria-expanded":g,title:a("展开或收起(默认收起)"),onClick:()=>v(R=>!R),children:[r.jsx("span",{className:"caret","aria-hidden":!0}),r.jsx("span",{children:a("已用完 / 已过期")}),r.jsx("span",{className:"n",children:a("{count} 份",{count:y.length})})]}),g?y.map((R,M)=>r.jsx(FI,{row:R,now:t},`spent-${R.name}-${M}`)):null]}):null]})})]})}const INe={workbuddy:"assets/providers/workbuddy.png","workbuddy-intl":"assets/providers/workbuddy.png",raccoon:"assets/providers/raccoon.png",catpaw:"assets/providers/catpaw.png",autoclaw:"assets/providers/autoclaw.png","autoclaw-intl":"assets/providers/autoclaw.png",qoder:"assets/providers/qoder.png","qoder-intl":"assets/providers/qoder.png",cline:"assets/providers/cline.png","cline-free":"assets/providers/cline.png","cline-pass":"assets/providers/cline.png",accio:"assets/providers/accio.png","accio-cn":"assets/providers/accio.png","accio-intl":"assets/providers/accio.png",zcode:"assets/providers/zcode.png","zcode-intl":"assets/providers/zcode.png",codearts:"assets/providers/codearts.png",trae:"assets/providers/trae.png",loomy:"assets/providers/loomy.png",kuku:"assets/providers/kuku.png",monkeycode:"assets/providers/monkeycode.png","monkeycode-intl":"assets/providers/monkeycode.png",commandcode:"assets/providers/commandcode.png",antigravity:"assets/providers/antigravity.png","agy-cli":"assets/providers/antigravity.png",officeace:"assets/providers/officeace.png",orcaterm:"assets/providers/orcaterm.png",chatglm:"assets/providers/chatglm.png","deepseek-web":"assets/providers/deepseek.png",tabbit:"assets/providers/tabbit.png","tabbit-intl":"assets/providers/tabbit.png",modelscope:"assets/providers/modelscope.png","modelscope-intl":"assets/providers/modelscope.png",atomcode:"assets/providers/atomcode.png",lobsterai:"assets/providers/lobsterai.png",doubaowork:"assets/providers/doubaowork.png",cursor:"assets/providers/cursor.svg",kiro:"assets/providers/kiro.svg",astudio:"assets/providers/astudio.png",quwork:"assets/providers/quwork.png",devin:"assets/providers/devin.svg",factory:"assets/providers/factory.svg",zed:"assets/providers/zed.svg",grok:"assets/providers/grok.svg","minimax-code":"assets/providers/minimax-code.svg","minimax-code-global":"assets/providers/minimax-code.svg",qwenwork:"assets/providers/qwenwork.svg","qwenwork-intl":"assets/providers/qwenwork.svg","qwenwork-enterprise":"assets/providers/qwenwork.svg","kimi-work":"assets/providers/kimi-work.svg",opendesign:"assets/providers/opendesign.svg","nous-portal":"assets/providers/nous-portal.svg","claude-subscription":"assets/providers/anthropic.png","codex-subscription":"assets/providers/openai.png","chatgpt-subscription":"assets/providers/openai.png","copilot-subscription":"assets/providers/copilot.svg","gemini-subscription":"assets/providers/gemini-cli.svg"};function tG(e){return typeof e=="string"&&/^\/plugins\/script-icons\/[a-f0-9]{64}\.(png|jpg|gif|webp|ico|svg)$/.test(e)?e:""}function MNe(e,t){return!t||!e||typeof e!="object"||Array.isArray(e)?"":tG(e[t])}function _Ne(...e){const t=e.filter(d=>typeof d=="string"&&d.length>0),n=JSON.stringify(t),[s,i]=p.useState({key:n,sources:[]}),o=s.key===n?s.sources:[],l=t.find(d=>!o.includes(d))||"",u=p.useCallback(()=>{l&&i(d=>({key:n,sources:[...d.key===n?d.sources:[],l]}))},[n,l]);return{src:l,onError:u}}const nG=[{id:"api-base",method:"",path:"/v1"},{id:"api-chat",method:"POST",path:"/v1/chat/completions"},{id:"api-responses",method:"POST",path:"/v1/responses"},{id:"api-messages",method:"POST",path:"/v1/messages"},{id:"api-count-tokens",method:"POST",path:"/v1/messages/count_tokens"},{id:"api-image-generations",method:"POST",path:"/v1/images/generations"},{id:"api-image-edits",method:"POST",path:"/v1/images/edits"},{id:"api-image-files",method:"GET",path:"/v1/images/files/{id}"},{id:"api-models",method:"GET",path:"/v1/models"},{id:"api-health",method:"GET",path:"/health"}];function rG(){const e=Z("对话协议与上下文预算"),t=Z("图片生成与编辑"),n=Z("模型清单与健康检查"),s={"api-base":{name:"Base URL",group:"",note:Z("OpenAI 兼容客户端使用此地址;Anthropic 官方 SDK 使用下方说明中的网关根地址。")},"api-chat":{name:"OpenAI Chat Completions",group:e,note:Z("多数 OpenAI 兼容客户端的默认协议")},"api-responses":{name:"OpenAI Responses",group:e,note:Z("Codex / 新版 OpenAI SDK;无状态转发,历史由客户端携带。")},"api-messages":{name:"Anthropic Messages",group:e,note:Z("Claude Code / Anthropic SDK;模型与账号池和 OpenAI 入口共用。")},"api-count-tokens":{name:Z("Token 数量估算"),group:e,note:Z("本地上下文预算估算,返回 estimated=true;不是上游精确分词。")},"api-image-generations":{name:Z("图片生成"),group:t,note:Z("文本生成图片;JSON 请求,非流式返回 base64 或下载链接。")},"api-image-edits":{name:Z("图片编辑"),group:t,note:Z("参考图编辑;支持 multipart 文件上传或 JSON 图片引用。")},"api-image-files":{name:Z("临时图片下载"),group:t,note:Z("仅用于响应返回的网关临时链接;{id} 必须替换为实际下载令牌。")},"api-models":{name:Z("模型列表"),group:n,note:Z("不强制鉴权;携带有效 Key 可查看该 Key 获准使用的模型。")},"api-health":{name:Z("健康检查"),group:n,note:Z("不强制鉴权;仅用于确认网关可访问,不保证模型或额度可用。")}};return nG.map(i=>({...i,...s[i.id]}))}const sG=3065;function DNe(){if(jc().workbuddyDesktop?.platform!=="web")return null;const e=typeof window>"u"?"":window.location?.origin;return e&&e!=="null"?e:null}function aG(e,t){return DNe()??(e?`http://127.0.0.1:${e}`:t)}function jc(){return window}function bN(e){return e instanceof Error?e.message:String(e)}function zg(e,t){jc().wbApp?.toast?.(e,t)}let Bg={backend:null,gatewayBase:aG(0,`http://127.0.0.1:${sG}`)};const HI=new Set;function yN(){return Bg}function VI(){return p.useSyncExternalStore(iG,yN).gatewayBase}function iG(e){return HI.add(e),()=>{HI.delete(e)}}function LNe(e){Bg=e;for(const t of HI)t()}function oG(){return Bg.gatewayBase.replace(/^https?:\/\//,"")}function $Ne(){return Bg.backend?.ready===!0}function lG(e){const t=(n,s)=>{const i=document.getElementById(n);i&&(i.textContent=s)};for(const n of nG)t(n.id,`${n.method?`${n.method} `:""}${e}${n.path}`)}let qI=!1;async function Xh(){if(!qI){qI=!0;try{const e=jc().workbuddyDesktop;if(!e)throw new Error("后端桥不可用");const t=await e.getBackendStatus(),n=Number(t?.port)||0,s=yN(),i={backend:t??null,gatewayBase:aG(n,s.gatewayBase)};i.gatewayBase!==s.gatewayBase&&lG(i.gatewayBase),LNe(i),jc().wbApp?.renderTopbarStatus?.()}catch(e){console.warn("读取后端状态失败:",bN(e))}finally{qI=!1}}}function zNe(){lG(Bg.gatewayBase),Xh()}async function cG(e){zg(e||a("正在重启…"));try{await jc().workbuddyDesktop?.restartApp()}catch(t){zg(a("重启失败:{reason}",{reason:bN(t)}),"err")}}const BNe={idle:a("结束占用进程"),querying:a("查询中…"),ending:a("结束中…")};function FNe({container:e}){const{backend:t,gatewayBase:n}=p.useSyncExternalStore(iG,yN),[s,i]=p.useState("idle"),o=t?.failure||null,l=oG(),u=t?.ready;let d="muted",f=a("正在检查… · {port}",{port:l});u===!0?(d="success",f=a("网关运行中 · {port}",{port:l})):o?(d="destructive",f=a("{label} · {port}",{label:o.label||a("网关启动失败"),port:l})):u===!1&&(f=a("网关启动中… · {port}",{port:l}));const m=o?o.message??"":u===!0?a("本地网关正在监听 {url},可直接调用 OpenAI 兼容接口",{url:n}):a("正在确认网关是否已就绪");p.useEffect(()=>{Xh()},[]),p.useEffect(()=>{const v=jc().workbuddyDesktop,b=[v?.onBackendError?.(()=>{Xh()}),v?.onBackendReady?.(()=>{Xh()})];return()=>{for(const y of b)typeof y=="function"&&y()}},[]),p.useEffect(()=>{e.title=m},[e,m]);async function g(){if(s!=="idle")return;const v=jc().workbuddyDesktop;if(v){i("querying");try{const b=await v.getPortOccupant(),y=b?.occupant;if(!y){zg(a("端口 {port} 上没有查到监听进程,请改用「更换端口」",{port:b?.port??""}),"err");return}const k=[a("即将结束以下进程:"),"",a("进程名:{name}",{name:String(y.name)}),a("PID:{pid}",{pid:String(y.pid)}),a("路径:{path}",{path:y.path||a("(未知)")}),"",a("结束它会强制退出该程序未保存的数据。确认继续?")],w=jc().wbConfirm?.ask;if(!w||!await w({title:a("结束占用端口的进程"),text:k.join(` +`),okText:a("结束进程"),okClass:"danger"}))return;i("ending"),(await v.endPortOccupant())?.released?(zg(a("已结束进程 {name}(PID {pid}),端口已释放",{name:String(y.name),pid:String(y.pid)})),await w({title:a("重启程序"),text:a("端口已释放。现在重启程序让网关用这个端口启动?"),okText:a("重启")})?await cG(a("重启中…")):await Xh()):(zg(a("进程已结束,但端口仍被占用,建议改用「更换端口」"),"err"),await Xh())}catch(b){zg(a("结束失败:{reason}",{reason:bN(b)}),"err")}finally{i("idle")}}}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"status-line",children:[r.jsx(qa,{variant:d,pulse:u===!0}),r.jsx("span",{className:"txt",children:f})]}),o?.conflict?r.jsxs("div",{className:"status-actions",children:[o.canEndOccupant===!0?r.jsx(B,{size:"sm",disabled:s!=="idle",onClick:()=>{g()},children:BNe[s]}):null,r.jsx(B,{size:"sm",onClick:()=>{VNe()},children:a("更换端口")})]}):null]})}let jN=null,uG=null;function KI(){const e=document.getElementById("sidebar-status");uG!==e&&(jN?.unmount(),jN=null,uG=e,e&&(e.replaceChildren(),jN=zn.createRoot(e),jN.render(r.jsx(FNe,{container:e}))))}window.addEventListener("wb:shell-layout",KI);const UNe={idle:a("保存并重启"),checking:a("校验中…"),saving:a("保存中…")};function HNe({status:e,onClose:t}){const n=Number(e?.port)||sG,[s,i]=p.useState(()=>n<65535?String(n+1):String(n-1)),[o,l]=p.useState("idle"),[u,d]=p.useState(""),[f,m]=p.useState(""),g=p.useRef(!0),v=Number(s)||0,b=e?.failure?.message||a("当前端口 {port},网关运行正常。",{port:n});async function y(){if(o!=="idle")return;const k=jc().workbuddyDesktop;if(!k)return;const w=Number(s)||0;if(!w||w<1024||w>65535){m(a("端口需在 1024-65535 之间"));return}l("checking"),m(""),d("");try{const S=await k.checkPort(w);if(!S?.ok){d(S?.message||a("该端口不可用"));return}if(S.same){d(S.message??"");return}if(l("saving"),(await k.changePort(w))?.changed===!1){d(a("与当前端口相同,无需重启"));return}t(),await cG(a("端口已改为 {port},正在重启…",{port:w}))}catch(S){m(bN(S))}finally{l("idle")}}return r.jsx(at,{open:!0,onOpenChange:k=>{k||t()},children:r.jsxs(it,{children:[r.jsx(ot,{children:r.jsx(st,{children:a("更换网关端口")})}),r.jsxs(lt,{children:[r.jsxs(as,{children:[r.jsx("h3",{children:a("当前状态")}),r.jsx("p",{children:b})]}),r.jsxs(as,{children:[r.jsx("h3",{children:a("新端口")}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[r.jsx(Ae,{htmlFor:"port-input",className:"text-[12.5px] whitespace-nowrap text-subtle",children:a("端口号")}),r.jsx(ze,{id:"port-input",type:"number",min:1024,max:65535,step:1,placeholder:a("例如 3066"),autoComplete:"off",className:"max-w-[130px]",value:s,onChange:k=>{i(k.currentTarget.value)},onKeyDown:k=>{k.key==="Enter"&&y()},autoFocus:!0,onFocus:k=>{g.current&&(g.current=!1,k.currentTarget.select())}})]}),u?r.jsx("p",{children:u}):null,r.jsx("p",{children:a("端口需在 1024-65535 之间。1023 及以下是系统保留范围,普通程序无法监听。")})]}),r.jsxs(as,{children:[r.jsx("h3",{children:a("换端口后要改的地方")}),r.jsxs("p",{children:[a("网关地址会变成 "),r.jsx("code",{children:`http://127.0.0.1:${v||"—"}`}),a("。已经把这个地址填进其它工具(Claude Code、Cherry Studio 等)的,需要一并改成新地址,否则那些工具会连不上。")]})]}),r.jsx("p",{className:"min-h-[18px] text-[11.5px] text-muted-foreground",children:f})]}),r.jsxs(xt,{children:[r.jsx("div",{className:"mr-auto"}),r.jsx(B,{variant:"outline",onClick:t,children:a("取消")}),r.jsx(B,{variant:"default",disabled:o!=="idle",onClick:()=>{y()},children:UNe[o]})]})]})})}let vy=null,Fg=null;function dG(){vy&&(vy.unmount(),vy=null),Fg&&(Fg.remove(),Fg=null)}async function VNe(){let e=yN().backend;e||(e=await jc().workbuddyDesktop?.getBackendStatus().catch(()=>null)??null),dG(),Fg=document.createElement("div"),document.body.append(Fg),vy=zn.createRoot(Fg),vy.render(r.jsx(HNe,{status:e,onClose:dG}))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",KI,{once:!0}):KI(),window.wbPortPanel={render:zNe,sync:Xh,portLabel:oG,isReady:$Ne,gatewayBase:()=>Bg.gatewayBase};function qNe(e){let t;const n=()=>{t?.(),t=window.wbApp?.subscribeRefresh?.(e),e()};return window.addEventListener("wb:app-ready",n),n(),()=>{window.removeEventListener("wb:app-ready",n),t?.()}}function Qh(e,t=INe[e]||""){const n=p.useSyncExternalStore(qNe,()=>MNe(window.wbApp?.getState?.()?.providerIcons,e)),s=VI();return _Ne(n?`${s.replace(/\/+$/,"")}${n}`:"",t)}function GI(e){return e==="credit"?{name:a("积分到期时间"),hint:a("按账号最早到期、且还有剩余的积分包比较"),options:[{value:"soon",label:a("最快到期优先")},{value:"late",label:a("最晚到期优先")}]}:e==="balance"?{name:a("可用余额"),hint:a("按账号总可用余额比较,不重复累加积分明细"),options:[{value:"high",label:a("余额大优先")},{value:"low",label:a("余额小优先")}]}:{name:a("账号添加时间"),hint:a("所有提供商都有这个字段"),options:[{value:"new",label:a("最新添加优先")},{value:"old",label:a("最早添加优先")}]}}function WI(e,t){const n=t||Sn().sorting;return n?.balanceSortStates?n.balanceSortStates[e]!==void 0&&n.balanceSortStates[e]!=="unsupported":n?!1:Ga(e).usage||Ml().some(s=>tn(s)===e&&Si(s))}function zl(e,t,n){return t.filter(s=>s.on&&(s.key==="credit"?Eg(e):s.key==="balance"?WI(e,n):!0))}function wN(e){const t=e.filter(n=>n.on).map(n=>GI(n.key).name);return t.length?a("无法拖动:已启用自动消耗规则({rules})。请先在「消耗顺序」中关闭这些规则,再手动调整。",{rules:t.join("、")}):a("自动消耗排序已启用,请先关闭规则再手动调整")}function YI(e){return e.filter(t=>t.on).map(t=>t.key==="credit"?t.dir==="soon"?a("到期 近→远"):a("到期 远→近"):t.key==="balance"?t.dir==="high"?a("余额大优先"):a("余额小优先"):t.dir==="new"?a("添加 新→旧"):a("添加 旧→新")).join(" · ")}function KNe(e,t){if(t==="upgrade")return a("当前网关不支持余额排序,请先更新网关");if(e.key==="balance"){if(t==="unsupported")return a("这一家没有可用余额查询");if(t==="mixed-units")return a("账号余额单位不一致,暂不按余额排序,继续比较其他规则");if(t==="no-data")return a("暂无可比较余额;查到同单位的数值后自动生效,比例与无限额度不参与")}return t==="unsupported"?a("这一家查不到积分到期时间"):t==="no-data"?e.on?a("暂无数据:先查询一次余额,之后会自动按到期排序"):a("暂无数据:先查询一次余额,可按需启用到期排序"):GI(e.key).hint}function GNe({rule:e,priority:t,isLast:n,state:s,busy:i,onChange:o}){const l=GI(e.key),u=s==="unsupported"||s==="upgrade",d=KNe(e,s),f=!u&&!e.on;return r.jsxs("div",{className:Ne("grid items-center gap-2 rounded-sm px-1.5 py-1.5","grid-cols-[16px_15px_minmax(0,1fr)_132px_16px]","hover:bg-nav-hover",f&&"opacity-[.58]"),children:[r.jsx("span",{className:"text-center text-[10.5px] font-bold text-subtle tabular-nums",children:t}),r.jsx(jr,{checked:e.on&&!u,disabled:u||i,"aria-label":l.name,onCheckedChange:m=>o({on:m===!0})}),r.jsxs("span",{className:"flex min-w-0 flex-col gap-px",children:[r.jsx("span",{className:Ne("text-xs font-medium",u&&"text-subtle",f&&"text-subtle"),children:l.name}),r.jsx("span",{className:Ne("text-[10.5px] leading-relaxed",u||s==="mixed-units"?"text-warning":"text-subtle"),title:d,children:d})]}),u?r.jsx("span",{className:"rounded-xs border border-dashed border-border py-1 text-center text-[10.5px] text-subtle",children:a("不可用")}):r.jsxs(Pt,{value:e.dir,disabled:!e.on||i,onValueChange:m=>o({dir:m}),children:[r.jsx(Mt,{className:"h-[26px] w-full text-[11px]","aria-label":a("{name}的方向",{name:l.name}),children:r.jsx(It,{children:l.options.find(m=>m.value===e.dir)?.label||""})}),r.jsx(_t,{children:l.options.map(m=>r.jsx(Ze,{value:m.value,children:m.label},m.value))})]}),r.jsxs("span",{className:"flex flex-col gap-px",children:[r.jsx(B,{size:"default",variant:"ghost",type:"button",disabled:t<=1||i,className:"h-3 w-4 rounded-[3px] text-subtle hover:bg-nav-hover hover:text-foreground disabled:cursor-default disabled:opacity-30",title:a("提高优先级"),"aria-label":a("提高优先级"),onClick:()=>o({__move:"up"}),children:r.jsx("svg",{viewBox:"0 0 24 24",width:"10",height:"10",className:"mx-auto block",children:r.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",d:"m6 14 6-6 6 6"})})}),r.jsx(B,{size:"default",variant:"ghost",type:"button",disabled:n||i,className:"h-3 w-4 rounded-[3px] text-subtle hover:bg-nav-hover hover:text-foreground disabled:cursor-default disabled:opacity-30",title:a("降低优先级"),"aria-label":a("降低优先级"),onClick:()=>o({__move:"down"}),children:r.jsx("svg",{viewBox:"0 0 24 24",width:"10",height:"10",className:"mx-auto block",children:r.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",d:"m6 10 6 6 6-6"})})})]})]})}function fG({title:e,hint:t,children:n}){return r.jsxs("section",{className:"flex flex-col gap-1 border-t border-hairline pt-3.5 first:border-t-0 first:pt-0",children:[r.jsxs("div",{className:"mb-1 flex items-baseline gap-2",children:[r.jsx("h4",{className:"m-0 text-xs font-bold",children:e}),t?r.jsx("span",{className:"text-[10.5px] text-subtle",children:t}):null]}),n]})}function hG({provider:e,onClose:t,accounts:n,sorting:s,routeContext:i}){p.useSyncExternalStore(Hh,()=>Sn().version);const o=Nu(e),l=ft().wbProviders?.labelOf?.(e)||e,{src:u,onError:d}=Qh(e),f=Eg(e),m=Sn().version,g=s||Sn().sorting,v=(n||Ml()).filter(R=>tn(R)===e),b=p.useMemo(()=>v.some(R=>g?g.creditExpiresAt[R.id]!=null:IK(po(R))!==null),[e,m,n,s,g]),y=f?b?"ready":"no-data":"unsupported",k=g?.balanceSortStates?.[e]||(WI(e,g)?bK(v.map(R=>vK(po(R)))):"unsupported"),w=g&&!g.balanceSortStates?"upgrade":k==="mixedUnits"?"mixed-units":k==="noData"?"no-data":k,S=zl(e,o,g),N=YI(S),C=S.some(R=>R.key==="balance"),T=S.length>0,P=bSe(e),O=Sn().sortBusy,A=(R,M)=>{const _=M.__move,L=o.map(D=>({...D})),$=L.findIndex(D=>D.key===R);if(!($<0)){if(_){const D=_==="up"?$-1:$+1;if(D<0||D>=L.length)return;const[F]=L.splice($,1);L.splice(D,0,F)}else L[$]={...L[$],...M};AI(e,L)}};return r.jsx(at,{open:!0,onOpenChange:R=>{!R&&!O&&t()},children:r.jsxs(it,{className:"w-[min(560px,calc(100vw-48px))]",showCloseButton:!0,children:[r.jsxs(ot,{children:[r.jsx("span",{className:"inline-flex size-[26px] flex-none items-center justify-center",children:u?r.jsx("img",{src:u,alt:"",className:"size-[26px] rounded-md object-contain",loading:"lazy",onError:d}):r.jsx("span",{className:"inline-flex size-[26px] items-center justify-center rounded-md bg-surface-3 text-[13px] font-bold text-muted-foreground",children:String(l||"?").trim().slice(0,1).toUpperCase()})}),r.jsx(st,{children:a("{name} · 分组设置",{name:a(l)})})]}),r.jsxs(lt,{children:[i,r.jsxs(fG,{title:a("消耗顺序"),hint:a("按优先级从上到下比较,勾选的项才参与"),children:[o.map((R,M)=>r.jsx(GNe,{rule:R,priority:M+1,isLast:M===o.length-1,state:R.key==="credit"?y:R.key==="balance"?w:"ready",busy:O,onChange:_=>A(R.key,_)},R.key)),r.jsxs("div",{className:"grid grid-cols-[16px_15px_minmax(0,1fr)] items-center gap-2 px-1.5 py-1.5",children:[r.jsx("span",{className:"text-center text-[10.5px] font-bold text-subtle tabular-nums",children:o.length+1}),r.jsx("span",{className:"inline-flex items-center justify-center text-subtle",title:a("固定兜底,不受开关影响"),children:r.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",children:r.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"4.5",y:"10",width:"15",height:"10.5",rx:"2"}),r.jsx("path",{d:"M8 10V7a4 4 0 0 1 8 0v3"})]})})}),r.jsxs("span",{className:"flex min-w-0 flex-col gap-px",children:[r.jsx("span",{className:"text-xs font-medium",children:a("组内手动顺序")}),r.jsx("span",{className:"text-[10.5px] text-subtle",children:a("上面所有规则都相同时,保持你拖出来的顺序")})]})]}),r.jsxs("p",{className:"m-0 mt-2 rounded-xs bg-surface-inset px-2.5 py-2 text-[10.5px] leading-relaxed text-subtle",children:[a("当前规则:{rules}。",{rules:N||a("仅按手动顺序")})," ",a(T?"已启用自动排序,组内拖动已锁定;关闭全部规则可恢复原手动顺序。":"当前可手动调整组内顺序。")]}),r.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a("上一条规则相同时才比较下一条;想优先按余额消耗,请把可用余额移到第一位。")}),C?r.jsxs("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:[a("使用最近一次成功查询的总余额,随余额刷新调整;查询失败保留上次读数,不额外增加查询频率。")," ",a("只比较同一家、同单位的数值余额;未知、比例和无限额度不作为零余额,有明确余额的账号优先。")]}):null,r.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a("账号页与全局路由共用此消耗顺序,网关按最新余额数据选路,不需要保持页面打开。模型独立顺序会覆盖全局。")}),r.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a("严格按消耗顺序使用账号需选择「顺序优先」;轮询、会话粘性及账号保护仍按原设置生效。")}),r.jsx("p",{className:"m-0 mt-1.5 px-2.5 text-[10.5px] leading-relaxed text-subtle",children:a(f?"默认仅开启最快到期优先;可用余额和账号添加时间默认关闭。":"默认保持手动顺序,可按需开启支持的自动排序规则。")})]}),r.jsx(fG,{title:a("更多设置"),hint:a("后续加入"),children:r.jsx("div",{className:"flex flex-wrap gap-1.5",children:[a("默认展开 / 收起"),a("新账号落到组首 / 组尾"),a("组内并发上限"),a("余额低于阈值时的提示"),a("本组代理")].map(R=>r.jsx("span",{className:"inline-flex h-[22px] items-center rounded-pill border border-dashed border-border px-2.5 text-[10.5px] text-subtle",children:R},R))})})]}),r.jsxs(xt,{children:[r.jsx(B,{variant:"ghost",size:"sm",disabled:!P||O,title:a(P?f?"恢复默认:仅开启最快到期优先":"恢复默认:仅按手动顺序":"当前已经是默认规则"),onClick:()=>{AI(e,null)},children:a("恢复默认")}),r.jsx("span",{className:"mr-auto text-[10.5px] text-subtle",children:a(O?"保存中…":"改动即时生效")}),r.jsx(B,{variant:"default",disabled:O,onClick:t,children:a("完成")})]})]})})}function WNe(e,t){if(!e)return a("读取中…");const n=e.error||e.configError;if(n)return a("读取失败:{error}",{error:n});if(e.required===!1)return a("当前模型请求免人机验证");if(t?.state==="verifying")return a("正在验证…");if(t?.state==="error")return a("验证失败:{error}",{error:t.error});if(t?.state==="paused")return a("已暂停验证,需要时请手动重试");const s=`${Number(e.ready)||0} / ${Number(e.target)||3}`;return Number(e.startPlanAccounts)?Number(e.ready)>0?a("验证码令牌:{counts}",{counts:s}):e.needsTokens===!0?a("套餐池请求需要验证,请主动开始验证后重试请求"):a("没有近期套餐池请求,不生成验证码令牌"):a("未启用套餐池账号,不生成验证码令牌")}function YNe({accountId:e,disabled:t=!1,onBusy:n}){const[s,i]=p.useState(null),[o,l]=p.useState(null),[u,d]=p.useState(""),f=p.useRef(null),m=p.useRef(!0),g=p.useCallback(async()=>{const k=ft().workbuddyDesktop;try{const w=k?.zcodeCaptchaStats?await k.zcodeCaptchaStats():{error:a("验证码令牌池接口不可用")};m.current&&(i(w||null),ft().wbZcodeCaptchaPool?.status&&l(ft().wbZcodeCaptchaPool?.status?.()||null))}catch(w){m.current&&i({error:dn(w)})}},[]);p.useEffect(()=>{m.current=!0,g();const k=window.setInterval(()=>{g()},15e3),w=()=>{l(ft().wbZcodeCaptchaPool?.status?.()||null),g()};return window.addEventListener("zcode-captcha-status",w),()=>{m.current=!1,f.current?.abort(),n?.(!1),window.clearInterval(k),window.removeEventListener("zcode-captcha-status",w)}},[g,n]);async function v(){const k=ft().wbZcodeCaptchaPool;if(f.current||!k?.verify)return;const w=new AbortController;f.current=w,d("preparing"),n?.(!0);try{await k.verify(e,w.signal,S=>{m.current&&d(S)})}catch(S){m.current&&!w.signal.aborted&&S?.name!=="CaptchaCancelledError"&&l({state:"error",error:dn(S)})}finally{f.current===w&&(f.current=null),m.current&&(d(""),n?.(!1),g())}}const b=!!u,y=!!(s?.error||s?.configError||o?.state==="error");return r.jsxs("div",{className:"flex flex-wrap items-center gap-2",title:a("后台只读取状态,不会自动弹出验证码;验证结果一次性使用,短时间内过期。"),children:[r.jsx(qa,{variant:y?"destructive":s?.required===!1?"success":"warning"}),r.jsx("span",{className:Ne("text-[12.5px]",y&&"text-destructive"),children:WNe(s,o)}),r.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[s?.required!==!1&&Number(s?.startPlanAccounts)>0?r.jsx(B,{variant:"outline",size:"xs",disabled:t||b||!!(s?.error||s?.configError)||!ft().wbZcodeCaptchaPool?.verify,onClick:()=>{v()},children:a(b?"正在验证…":"开始验证")}):null,b?r.jsx(B,{variant:"outline",size:"xs",disabled:u==="submitting",onClick:()=>f.current?.abort(),children:a("取消验证")}):null,r.jsx(B,{variant:"ghost",size:"xs",disabled:b||t,onClick:()=>{g()},children:a("刷新")})]})]})}function XNe({plan:e,hasJwt:t,onChange:n}){return r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5",children:[r.jsx(ut,{htmlFor:"account-plan-channel",children:a("使用套餐")}),r.jsxs(Pt,{value:e,onValueChange:s=>n(String(s)),children:[r.jsx(Mt,{id:"account-plan-channel",className:"min-w-[220px]",children:r.jsx(It,{children:sSe(e)})}),r.jsxs(_t,{children:[r.jsx(Ze,{value:PK,children:a("编码套餐(Coding Plan)— 走开放平台端点,消耗开放平台的额度(订阅套餐 / 资源包 / 充值余额)")}),r.jsx(Ze,{value:Uh,children:a("套餐池(Start Plan)— 走 zcode.z.ai 端点,消耗 ZCode 套餐池的额度(新用户体验额度 / 活动领取)")})]})]}),e===Uh&&!t?r.jsx("span",{className:"detail text-destructive",children:a("该账号没有套餐登录态(jwt),套餐池通道会失败:请重新登录该账号")}):null,e===Uh?r.jsx("p",{className:"detail",children:a("需要人机验证时,在该账号的「套餐明细」中主动开始验证。")}):null]})}const QNe={sub2api:{label:"Sub2API",endpoint:"{base}/v1/usage",note:a("用这条账号的 API Key 查询,不需要额外配置。"),fields:[]},new_api:{label:"NewAPI",endpoint:"{base}/api/user/self + /api/status",note:a("用 NewAPI 站点的个人访问令牌查询账户余额(不是这条账号的上游 API Key)。令牌在站点的「个人设置」里生成,只有旧版 / 定制站点才需要额外填用户 ID。"),fields:[{key:"accessToken",label:a("NewAPI 个人访问令牌"),secret:!0,placeholder:a("在 NewAPI 站点「个人设置」里生成的访问令牌"),hint:a("必填;留空 = 不修改,清除用右边的按钮")},{key:"userId",label:a("NewAPI 用户 ID"),placeholder:a("旧版 / 定制站点才需要,新版可留空"),hint:a("可留空:新版请求头只认令牌;旧版会把用户 ID 放进 New-Api-User 头")}]},deepseek:{label:"DeepSeek",endpoint:"{base}/user/balance",note:a("用这条账号的 API Key 查询,不需要额外配置。"),fields:[]},opencode:{label:"OpenCode Go",endpoint:"{base}/v1/usage",note:a("用这条账号的 API Key 查询订阅用量,不需要额外配置;读数展开成 5 小时 / 每周 / 每月三个窗口。"),fields:[]},sensenova:{label:"商汤日日新",endpoint:"platform.sensenova.cn 控制台",note:a("用商汤日日新控制台的账号密码查询(与推理用的 API Key 不是同一套)。网关会自动换取登录票并缓存,过期后自动重登,不需要手动维护。"),fields:[{key:"username",label:a("账号"),placeholder:a("商汤日日新控制台的登录账号"),hint:a("必填")},{key:"password",label:a("密码"),secret:!0,placeholder:a("商汤日日新控制台的登录密码"),hint:a("留空 = 不修改,清除用右边的按钮")}]},zhipu:{label:"智谱",endpoint:"bigmodel.cn 控制台",note:a("用 bigmodel.cn 控制台的访问令牌查询账户余额(人民币元)。令牌是登录后浏览器 Cookie `bigmodel_token_production` 的值:开发者工具 → 应用(Application)→ Cookie 里复制。"),fields:[{key:"token",label:a("访问令牌"),secret:!0,placeholder:a("bigmodel_token_production 的值"),hint:a("必填;留空 = 不修改,清除用右边的按钮")}]},zhipu_zai:{label:"智谱(z.ai 国际)",endpoint:"api.z.ai 控制台",note:a("用这条账号的 API Key 生成签名后查询账户余额(美元),不需要额外配置。要求 API Key 是 z.ai 的「id.secret」形态(控制台生成的 Key 就是)。"),fields:[]}};function by(e){return e?QNe[e]??null:null}function ZNe(e,t){return t.secret?t.key==="accessToken"?e?.hasAccessToken===!0:t.key==="password"?e?.hasPassword===!0:t.key==="token"?e?.hasToken===!0:!1:!1}function JNe(e){const t=String(e?.scheme||"");return t==="new_api"?e?.hasAccessToken===!0:t==="sensenova"?String(e?.username||"").trim()!==""&&e?.hasPassword===!0:t==="zhipu"?e?.hasToken===!0:!0}function eCe(e){return{userId:String(e?.userId||""),username:String(e?.username||""),accessToken:"",password:"",token:""}}function tCe(e,t){const n=by(e);if(!n||!n.fields.length)return null;const s={};for(const i of n.fields){const o=String(t[i.key]??"").trim();if(i.secret){o&&(s[i.key]=o);continue}s[i.key]=o}return Object.keys(s).length?s:null}function nCe({field:e,value:t,configured:n,onValue:s,onClear:i,clearBusy:o,idPrefix:l}){const u=`${l}-${e.key}`;return r.jsxs(ct,{orientation:"horizontal",className:"field-row mt-2.5",children:[r.jsx(ut,{htmlFor:u,children:e.label}),r.jsx(ze,{id:u,className:"min-w-[220px]",type:e.secret?"password":"text",autoComplete:e.secret?"new-password":"off",placeholder:n?a("已配置,留空则不修改"):e.placeholder,title:e.hint,value:t,onChange:d=>s(d.currentTarget.value)}),n&&i?r.jsx(B,{variant:"outline",size:"sm",disabled:o===!0,onClick:i,title:a("清除已配置的 {label}",{label:e.label}),children:a("清除")}):null]})}function rCe({spec:e,values:t,configured:n,onValue:s,onClear:i,clearBusy:o,idPrefix:l}){return r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"detail mt-2.5",children:[a("余额查询方案:{label}",{label:e.label}),r.jsx("span",{className:"ml-1 text-subtle",children:e.endpoint})," — ",e.note]}),e.fields.map(u=>r.jsx(nCe,{field:u,idPrefix:l,value:t[u.key]||"",configured:n[u.key]===!0,onValue:d=>s(u.key,d),onClear:i?()=>i(u.key):void 0,clearBusy:o},u.key))]})}function pr({value:e,onValueChange:t,options:n,placeholder:s="",displayValue:i,searchPlaceholder:o=Z("搜索…"),emptyHint:l=Z("没有匹配的选项"),disabled:u,className:d,id:f,title:m,searchable:g=!0,...v}){const[b,y]=p.useState(""),k=n.find(S=>S.value===e)??null,w=i??k?.label??(e||s);return g?r.jsxs(YV,{items:n,value:k,disabled:u,autoHighlight:!0,inputValue:b,onInputValueChange:y,onOpenChange:()=>y(""),itemToStringLabel:S=>S.label,itemToStringValue:S=>S.value,isItemEqualToValue:(S,N)=>S.value===N.value,filter:(S,N)=>`${S.label} ${S.value} ${S.searchText||""}`.toLowerCase().includes(N.trim().toLowerCase()),onValueChange:S=>{S&&!S.disabled&&t(S.value)},children:[r.jsx(QV,{id:f,className:d,title:m??w,"aria-label":v["aria-label"],children:r.jsx(XV,{children:w})}),r.jsxs(ZV,{children:[r.jsx("div",{className:"shrink-0 border-b border-hairline p-2",children:r.jsx(JV,{placeholder:o,"aria-label":o,autoComplete:"off"})}),r.jsx(nq,{children:l}),r.jsx(eq,{children:S=>r.jsx(tq,{value:S,disabled:S.disabled,title:S.label,children:S.label},S.value)})]})]}):r.jsxs(Pt,{value:e,disabled:u,onValueChange:S=>{typeof S=="string"&&t(S)},children:[r.jsx(Mt,{id:f,className:d,title:m??w,"aria-label":v["aria-label"],children:r.jsx(It,{children:w})}),r.jsx(_t,{children:n.map(S=>r.jsx(Ze,{value:S.value,disabled:S.disabled,children:S.label},S.value))})]})}let Au=null,yy=null;function sCe(){if(Au)return Promise.resolve(Au);if(yy)return yy;const t=window.workbuddyDesktop?.getClientIdentification?.();return t?(yy=t.then(n=>{const s=[];for(const i of n?.builtins||[]){const o=typeof i.id=="string"?i.id:"",l=typeof i.name=="string"?i.name:"",u=typeof i.ua=="string"?i.ua.trim():"";o&&l&&u&&s.push({id:o,name:l,ua:u})}return Au=s,s}).catch(()=>(Au=[],Au)).finally(()=>{yy=null}),yy):(Au=[],Promise.resolve(Au))}function jy(){const[e,t]=p.useState(()=>Au||[]);return p.useEffect(()=>{if(Au)return;let n=!0;return sCe().then(s=>{n&&t(s)}),()=>{n=!1}},[]),e}function wy(e){const t=window,n=t.wbProviders?.all?.()||t.wbApp?.getState?.()?.accounts?.providers;return Array.isArray(n)?n.find(i=>i?.id===e)?.userAgentOverridable!==!1:!0}async function mG(e,t,n){const s=n.trim();if(!s||!e||!wy(t))return;const i=window.__TAURI_INTERNALS__;if(i?.invoke)try{await i.invoke("api_request",{request:{method:"PATCH",path:`/api/accounts/${encodeURIComponent(e)}`,body:{userAgent:s}}})}catch{}}function pG(e){const t=e,n=t?.account?.id;if(typeof n=="string"&&n)return n;for(const s of["accountId","accountUid"]){const i=t?.session?.[s];if(typeof i=="string"&&i)return i}}function Ug({id:e,value:t,onChange:n,presets:s,disabled:i,className:o}){const l=s.find(u=>u.ua===t);return r.jsxs("div",{className:`flex min-w-0 items-center gap-2 ${o||""}`,children:[r.jsx(ze,{id:e,className:"min-w-0 flex-1",type:"text",maxLength:1024,spellCheck:!1,autoComplete:"off",disabled:i,placeholder:a("留空使用该提供商默认值"),value:t,onChange:u=>n(u.currentTarget.value)}),r.jsx(pr,{value:l?.id??"",disabled:i||!s.length,className:"w-[172px] shrink-0","aria-label":a("选择预置客户端"),displayValue:l?.name||a("选择预置客户端"),options:[{value:"",label:a("不使用预置")},...s.map(u=>({value:u.id,label:u.name,searchText:u.ua}))],onValueChange:u=>{if(!u){n("");return}const d=s.find(f=>f.id===u);d&&n(d.ua)}})]})}function ha({name:e,size:t=16}){return r.jsx("span",{className:"acct-dlg-icon","aria-hidden":"true",dangerouslySetInnerHTML:{__html:ft().wbIcons?.icon?.(e,t)||""}})}function wc({title:e,action:t,children:n}){return r.jsxs("section",{className:"acct-dlg-group-wrap",children:[r.jsxs("div",{className:"acct-dlg-group-label",children:[r.jsx("span",{children:e}),t?r.jsx("span",{className:"acct-dlg-label-action",children:t}):null]}),r.jsx("div",{className:"acct-dlg-group",children:n})]})}function aCe({configured:e,value:t,onChange:n,onClear:s,clearBusy:i}){return r.jsx(wc,{title:a("余额查询凭证"),action:r.jsx(Ee,{shape:"tag",variant:e?"success":"secondary",children:a(e?"已配置":"未配置")}),children:r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsxs("div",{className:"acct-dlg-field-head",children:[r.jsx(ut,{htmlFor:"account-balance-token-input",children:a("余额查询凭证")}),e?r.jsx(B,{variant:"ghost",size:"xs",disabled:i,onClick:s,className:"acct-dlg-clear",children:a("清除")}):null]}),r.jsx(ze,{id:"account-balance-token-input",type:"password",autoComplete:"new-password",placeholder:a(e?"已配置,留空则不修改":"一般不用填"),value:t,onChange:o=>n(o.currentTarget.value)}),r.jsx(wr,{children:a("积分查询已复用转发用的登录凭证,这里通常留空即可。只有旧版本填过、或从旧代理导入过凭证时才有值")})]})})}function iCe({hasApiKey:e,noAuth:t,value:n,onValue:s,onToggleNoAuth:i,onClear:o,clearBusy:l}){const[u,d]=p.useState(!1),f=!!n.trim();return r.jsxs(wc,{title:a("账号凭证"),action:r.jsx(Ee,{shape:"tag",variant:t||f?"secondary":e?"success":"warning",children:a(t?"无需鉴权":f?"新密钥待保存":e?"已配置":"未配置凭证")}),children:[r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{children:a("鉴权方式")}),r.jsxs(bg,{value:t?"none":"key",disabled:l,"aria-label":a("鉴权方式"),className:"acct-dlg-choice-grid",onValueChange:m=>i(m==="none"),children:[r.jsxs(Ae,{className:"acct-dlg-choice","data-selected":!t||void 0,children:[r.jsx(Mh,{value:"key"}),r.jsxs("span",{children:[r.jsx("strong",{children:"API Key"}),r.jsx("small",{children:a("使用密钥访问上游")})]})]}),r.jsxs(Ae,{className:"acct-dlg-choice","data-selected":t||void 0,children:[r.jsx(Mh,{value:"none"}),r.jsxs("span",{children:[r.jsx("strong",{children:a("无需鉴权")}),r.jsx("small",{children:a("本地服务或无需凭证的上游")})]})]})]})]}),r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsxs("div",{className:"acct-dlg-field-head",children:[r.jsx(ut,{htmlFor:"account-api-key-input",children:"API Key"}),e&&!t?r.jsx(B,{variant:"ghost",size:"xs",disabled:l,onClick:o,className:"acct-dlg-clear",children:a("清除已存密钥")}):null]}),r.jsxs(zs,{"data-disabled":t||l,children:[r.jsx(Bs,{id:"account-api-key-input",type:u&&!t?"text":"password",autoComplete:"new-password",spellCheck:!1,disabled:t||l,placeholder:e?a("留空保留当前密钥,输入新密钥以替换"):"sk-…",value:n,onChange:m=>s(m.currentTarget.value)}),r.jsx(As,{align:"inline-end",children:r.jsx(Db,{size:"icon-xs",disabled:t||l,"aria-pressed":u,"aria-label":a(u?"隐藏新输入的密钥":"显示新输入的密钥"),onClick:()=>d(m=>!m),children:r.jsx(ha,{name:u?"eyeOff":"eye"})})})]}),r.jsx(wr,{children:a("原密钥不会回显;更换密钥不会改变账号 ID。")})]}),r.jsxs("div",{className:`acct-dlg-inline-note${t||!e&&!f?" warning":""}`,children:[r.jsx(ha,{name:t||!e?"info":"shield",size:14}),r.jsx("span",{children:a(t?"保存后将移除密钥,转发与拉取模型都不发送鉴权头。请确认上游确实无需凭证。":e||f?"留空不修改,替换后点击「保存更改」生效。":"当前没有凭证,转发时会跳过此账号。请填写密钥或选择「无需鉴权」。")})]})]})}const oCe=64;function lCe({provider:e,name:t,protocol:n,baseUrl:s,accountBaseUrl:i,count:o,emulation:l,onName:u,onProtocol:d,onBaseUrl:f,onEmulation:m,onRemove:g,onModels:v,onClearAccountBaseUrl:b,disabled:y}){const[k,w]=p.useState(l==="opencode"),S=ft().wbProviders?.PROTOCOL_OPTIONS||[{value:"chat_completions",label:"OpenAI - Chat Completions"},{value:"responses",label:"OpenAI - Responses"},{value:"anthropic",label:"Anthropic - Messages"}],N=S.find(A=>A.value===n)?.label||n,C=n==="anthropic"?"/v1/messages":n==="responses"?"/responses":"/chat/completions",T=i.trim(),P=T||s.trim(),O=P?`${P.replace(/\/+$/,"")}${C}`:"";return r.jsxs(r.Fragment,{children:[r.jsxs(Fe,{variant:"warning",className:"acct-dlg-scope-notice",role:"note",children:[r.jsx(ha,{name:"accounts"}),r.jsxs("div",{children:[r.jsx("strong",{children:a("正在编辑提供商共用配置")}),r.jsx("p",{children:a("「{name}」名下 {count} 个账号共用;修改协议或地址可能中断正在进行的请求。",{name:e.name||e.id,count:o})})]})]}),r.jsxs(wc,{title:a("连接参数"),children:[r.jsxs("div",{className:"acct-dlg-field-grid",children:[r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{htmlFor:"account-provider-name",children:a("提供商名称")}),r.jsx(ze,{id:"account-provider-name",maxLength:oCe,disabled:y,value:t,onChange:A=>u(A.currentTarget.value)})]}),r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{htmlFor:"account-provider-protocol",children:a("协议")}),r.jsxs(Pt,{value:n,disabled:y,onValueChange:A=>d(String(A)),children:[r.jsx(Mt,{id:"account-provider-protocol",children:r.jsx(It,{children:N})}),r.jsx(_t,{children:S.map(A=>r.jsx(Ze,{value:A.value,children:A.label},A.value))})]})]}),r.jsxs(ct,{className:"acct-dlg-field acct-dlg-field-full",children:[r.jsxs("div",{className:"acct-dlg-field-head",children:[r.jsx(ut,{htmlFor:"account-provider-baseurl",children:"Base URL"}),T?r.jsx(B,{variant:"ghost",size:"xs",disabled:y,className:"acct-dlg-clear",onClick:b,children:a("改回跟随提供商")}):null]}),r.jsx(ze,{id:"account-provider-baseurl",className:"mono",disabled:y,spellCheck:!1,placeholder:a("OpenAI 兼容填到 /v1;Anthropic 填根地址"),value:s,onChange:A=>f(A.currentTarget.value)}),r.jsx(wr,{children:a("填写接口基址,无需追加 {path}。",{path:C})}),T?r.jsxs("div",{className:"acct-dlg-inline-note warning",children:[r.jsx(ha,{name:"info",size:14}),r.jsx("span",{children:a("这个账号单独存了一份地址:{url},转发时优先用它。上面改的是提供商共用地址,不会覆盖它。",{url:T})})]}):null]})]}),O?r.jsxs("div",{className:"acct-dlg-endpoint",children:[r.jsx("span",{children:a("请求端点")}),r.jsx("code",{children:O})]}):null,r.jsxs("div",{className:"acct-dlg-model-link",children:[r.jsx("span",{children:a("模型清单与映射在「模型管理」中维护。")}),r.jsxs(B,{variant:"link",size:"xs",disabled:y,onClick:v,children:[a("模型管理"),r.jsx(ha,{name:"caretRight",size:12})]})]})]}),r.jsx("div",{className:"acct-dlg-group-label",children:a("高级兼容")}),r.jsxs(gs,{open:k,onOpenChange:w,className:"acct-dlg-advanced",children:[r.jsxs(xs,{disabled:y,className:"acct-dlg-advanced-trigger",children:[r.jsx(ha,{name:"sliders"}),r.jsx("span",{children:a("高级兼容")}),r.jsx("small",{children:a(l==="opencode"?"已开启":"默认关闭")}),r.jsx(ha,{name:"caretRight",size:13})]}),r.jsxs(vs,{className:"acct-dlg-advanced-content",children:[r.jsxs(ct,{className:"acct-dlg-toggle-field",children:[r.jsxs("div",{children:[r.jsx(ut,{htmlFor:"account-provider-emulation",children:a("模拟 OpenCode 官方客户端")}),r.jsx(wr,{children:a("仅用于 OpenCode Zen 这类上游,普通提供商请保持关闭。")})]}),r.jsx(St,{id:"account-provider-emulation",checked:l==="opencode",disabled:y,onCheckedChange:A=>m(A?"opencode":"")})]}),r.jsx("p",{className:"detail acct-dlg-advanced-note",children:a("开启后会改写请求体,补齐会话头与占位工具;未填密钥时使用匿名凭证 public。")})]})]}),r.jsxs("div",{className:"acct-dlg-danger",children:[r.jsxs("div",{children:[r.jsx("h3",{children:a("删除提供商")}),r.jsx("p",{children:a("将同时删除名下 {count} 个账号,无法恢复。",{count:o})})]}),r.jsx(B,{variant:"outline",size:"sm",disabled:y,onClick:g,className:"acct-dlg-delete",children:a("删除提供商")})]})]})}function cCe(e,t){const n=tn(e);return t.filter(s=>s.id!==e.id&&tn(s)===n)}function uCe(e){return Ci(e)||e?.id||""}function gG({id:e,onClose:t,initialAccount:n,initialPane:s="basic",routeContext:i}){const[o,l]=p.useState(()=>n||_l(e)),[u,d]=p.useState(o?.enabled!==!1),[f,m]=p.useState(o?.allowRouteSkip!==!1),[g,v]=p.useState(o?.name||""),[b,y]=p.useState(o?.userAgent||""),k=jy(),w=wy(tn(o||{})),[S,N]=p.useState(()=>Lg(o?.proxy)),[C,T]=p.useState(""),[P,O]=p.useState(()=>nI(o)),[A,R]=p.useState(!1),[M,_]=p.useState(""),[L,$]=p.useState(null),[D,F]=p.useState(""),[V,K]=p.useState("chat_completions"),[Q,X]=p.useState(""),[U,z]=p.useState(""),[q,J]=p.useState(""),[ee,H]=p.useState(o?.noAuth===!0),[G,Y]=p.useState(()=>RI(o)),[se,re]=p.useState(()=>eCe(o?.balanceQuery)),[ne,de]=p.useState(()=>F8(o)),[ie,oe]=p.useState(s),[je,te]=p.useState(()=>String(Number(o?.maxConcurrent)||0)),[le,he]=p.useState(!1),ce=p.useRef(!1),ye=p.useRef(null),fe=p.useRef({}),Le=p.useRef({enabled:u,allowRouteSkip:f,name:g,userAgent:b,proxyDraft:S,planChannel:P,usageDraft:G,balanceQueryDraft:se,limiterDraft:ne,concDraft:je,noAuthDraft:ee}),pe=tn(o).startsWith("custom-")?a("凭证设置"):a("凭证与套餐"),xe={basic:{title:a("基本信息"),description:a("设置账号名称、启用状态与转发行为。"),icon:"sliders"},credential:{title:pe,description:a("管理当前账号的凭证与可用套餐。"),icon:"key"},query:{title:a("查询设置"),description:a("配置余额查询凭证、自动刷新间隔与失败重试。"),icon:"refresh"},limiter:{title:a("限制器"),description:a("用明确的规则保护当前账号的额度。"),icon:"shield"},network:{title:a("网络"),description:a("设置当前账号访问上游的出网方式。"),icon:"proxies"},provider:{title:a("连接设置"),description:a("统一管理提供商的协议、地址与兼容选项。"),icon:"agent"}},Se=xe[ie];p.useLayoutEffect(()=>{ye.current&&(ye.current.scrollTop=fe.current[ie]||0)},[ie]);function ge(ke){ye.current&&(fe.current[ie]=ye.current.scrollTop),oe(ke)}if(p.useEffect(()=>{let ke=!0;$(null);const Xe=n||_l(e);return Xe?(Promise.resolve(ft().wbCustomProvidersUi?.find?.(tn(Xe))).then(Qe=>{!ke||!Qe||($(Qe),F(Qe.name||""),K(Qe.protocol||"chat_completions"),X(Qe.baseUrl||""),z(typeof Qe.clientEmulation=="string"?Qe.clientEmulation:""))}).catch(()=>{}),()=>{ke=!1}):()=>{ke=!1}},[e]),!o)return r.jsx(at,{open:!0,onOpenChange:ke=>{ke||t()},children:r.jsxs(it,{children:[r.jsx(ot,{children:r.jsx(st,{children:a("账号设置")})}),r.jsx(lt,{children:r.jsx("p",{className:"detail",children:a("账号不存在,请刷新后重试。")})}),r.jsxs(xt,{children:[r.jsx("div",{className:"mr-auto"}),r.jsx(B,{variant:"outline",onClick:t,children:a("关闭")})]})]})});const ue=o,be=cCe(ue,Ml()),ve=tn(ue)==="catpaw",De=tn(ue).startsWith("custom-"),Ie=wK(L,ue.baseUrl)||S.mode==="rotate",We=by(ue.balanceQuery?.scheme),nt={};for(const ke of We?.fields??[])nt[ke.key]=ZNe(ue.balanceQuery,ke);const kt=!!(We&&We.fields.length)&&!JNe(ue.balanceQuery),Je=be.length+1,on=Le.current,nn=(ke,Xe)=>JSON.stringify(ke)===JSON.stringify(Xe),On={basic:u!==on.enabled||f!==on.allowRouteSkip||(g.trim()||on.name)!==on.name||b.trim()!==on.userAgent||je!==on.concDraft,credential:!!(C.trim()||q.trim())||ee!==on.noAuthDraft||P!==on.planChannel,query:!nn(G,on.usageDraft)||!nn(se,on.balanceQueryDraft),limiter:!nn(ne,on.limiterDraft),network:!nn(S,on.proxyDraft),provider:!!(L&&(D.trim()!==(L.name||"")||V!==(L.protocol||"chat_completions")||Q.trim()!==(L.baseUrl||"")||U!==(L.clientEmulation||"")))},Rn=Object.values(On).filter(Boolean).length,gt=A||le;async function sn(ke,Xe,Qe,Yt=!1){if(ce.current)return!1;ce.current=!0,he(!0);try{const Rt=ft().wbConfirm?.ask;if(!Rt)throw new Error(a("确认弹窗不可用,请重新打开页面"));return await Rt({title:ke,html:Yo(Xe).replace(/\n/g,"
"),okText:Qe,okClass:Yt?"danger":"primary",bodyClass:Yt?"danger-zone":""})}catch(Rt){return Ct(dn(Rt),"err"),!1}finally{ce.current=!1,he(!1)}}async function qe(){gt||ce.current||Rn&&!await sn(a("放弃未保存的修改?"),a("所有分区中尚未保存的修改都会被放弃。已确认的独立清除操作不受影响。"),a("放弃修改"))||t()}async function zt(){if(!(gt||ce.current)&&await sn(a("清除余额查询凭证?"),a("确认后立即生效,不受底部保存按钮控制。通常可继续复用转发用的登录凭证。"),a("清除"),!0)){ce.current=!0,R(!0);try{const ke=await Gh(e,{balanceToken:null});l(ke),T(""),Ct(a("✅ 已清除余额查询凭证"));try{await Qo()}catch(Xe){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Xe)}),"err")}}catch(ke){Ct(a("清除失败:{error}",{error:dn(ke)}),"err")}finally{ce.current=!1,R(!1)}}}async function ht(){if(!(gt||ce.current)&&await sn(a("清除已存 API Key?"),a("确认后立即生效,不受底部保存按钮控制。没有凭证且未开启「无需鉴权」时,此账号将被转发跳过。"),a("清除"),!0)){ce.current=!0,R(!0);try{const ke=await Gh(e,{apiKey:null});l(ke),J(""),Ct(a("✅ 已清除 API Key(该账号现在没有凭证,转发会被跳过)"));try{await Qo()}catch(Xe){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Xe)}),"err")}}catch(ke){Ct(a("清除失败:{error}",{error:dn(ke)}),"err")}finally{ce.current=!1,R(!1)}}}async function Tt(){if(gt||ce.current)return;const ke=Q.trim();if(await sn(a("改回跟随提供商?"),a("这个账号将改用提供商当前保存的 Base URL:{url}。确认后立即生效,不受底部保存按钮控制。",{url:ke||"—"}),a("改回跟随"))){ce.current=!0,R(!0);try{const Xe=await Gh(e,{baseUrl:null});l(Xe),Ct(a("✅ 已改回跟随提供商的 Base URL"));try{await Qo()}catch(Qe){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Qe)}),"err")}}catch(Xe){Ct(a("操作失败:{message}",{message:dn(Xe)}),"err")}finally{ce.current=!1,R(!1)}}}async function Ht(ke){if(!(gt||ce.current)&&await sn(a("清除查询凭证?"),a("确认后立即生效,余额查询可能显示「未配置」。取消账号设置不会恢复已清除的凭证。"),a("清除"),!0)){ce.current=!0,R(!0);try{const Xe=await Gh(e,{balanceQuery:{[ke]:null}});l(Xe),re(Qe=>({...Qe,[ke]:""})),Ct(a("✅ 已清除查询凭证"));try{await Qo()}catch(Qe){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Qe)}),"err")}}catch(Xe){Ct(a("清除失败:{error}",{error:dn(Xe)}),"err")}finally{ce.current=!1,R(!1)}}}function jt(){if(!De)return null;const ke=q.trim(),Xe={};return ee?ue.noAuth!==!0&&(Xe.noAuth=!0):ke?Xe.apiKey=ke:ue.noAuth===!0&&(Xe.noAuth=!1),Object.keys(Xe).length?Xe:null}function an(){if(!L)return null;const ke=D.trim(),Xe=Q.trim();if(!ke)return{error:a("请填写提供商名称")};if(!Xe)return{error:a("请填写提供商的 Base URL")};try{if(!["http:","https:"].includes(new URL(Xe).protocol))throw new Error("invalid protocol")}catch{return{error:a("请填写有效的 HTTP 或 HTTPS 地址")}}const Qe=typeof L.clientEmulation=="string"?L.clientEmulation:"";return L.name===ke&&L.protocol===V&&L.baseUrl===Xe&&Qe===U?null:{id:L.id,name:ke,protocol:V,baseUrl:Xe,clientEmulation:U}}async function Xt(){if(gt||ce.current||!Rn)return;_("");let ke;try{ke=yc(S)}catch(Pn){ge("network"),_(r.jsx("span",{className:"text-destructive",children:dn(Pn)})),Ct(dn(Pn),"err");return}const Xe=an();if(Xe&&"error"in Xe){ge("provider"),_(r.jsx("span",{className:"text-destructive",children:Xe.error}));return}const Qe=Si(ue)?kNe(ue,G):null;if(Qe&&"error"in Qe){ge("query"),_(r.jsx("span",{className:"text-destructive",children:Qe.error}));return}const Yt=yNe(ue,ne),Rt=tCe(ue.balanceQuery?.scheme,se),fn=jt()||{},At=Number(je);if(!Number.isFinite(At)||At<0){ge("basic"),_(r.jsx("span",{className:"text-destructive",children:a("并发上限必须是 0~{max} 的整数",{max:Su})})),Ct(a("并发上限必须是 0~{max} 的整数",{max:Su}),"err");return}const Re=Math.min(Su,Math.round(At)),mt=Number(ue.maxConcurrent)||0,Bt=Re!==mt?{maxConcurrent:Re}:{};if(!(Xe&&!await sn(a("保存提供商共用配置?"),a("「{name}」名下 {count} 个账号共用这些连接设置。修改协议或 Base URL 可能中断正在进行的请求。",{name:L?.name||L?.id||"",count:Je}),a("确认保存")))){ce.current=!0,R(!0);try{const Pn=ve&&C.trim()?{balanceToken:C.trim()}:{},mn=JS(ue)&&P!==nI(ue)?{zcodePlan:P}:{},vn=g.trim()||ue.name,Qn=b.trim(),Ns=await Gh(e,{...vn!==ue.name?{name:vn}:{},...Qn!==(ue.userAgent||"").trim()?{userAgent:Qn}:{},enabled:u,allowRouteSkip:f,proxy:ke,...Pn,...mn,...fn,...Bt,...Rt?{balanceQuery:Rt}:{},...Qe&&"patch"in Qe?Qe.patch:{},...Yt&&"patch"in Yt?Yt.patch:{}});if((vn!==ue.name||ue.nameCustom===!0)&&Ns.nameCustom!==!0)throw new Error(a("账号更新结果未确认,请刷新后核对设置"));if(l(Ns),Xe)try{const Cr=ft().wbCustomProvidersUi?.update;if(!Cr)throw new Error(a("账号更新接口不可用,请重新打开页面"));await Cr(Xe)}catch(Cr){ge("provider"),_(r.jsx("span",{className:"text-destructive",children:a("账号已保存,但提供商未更新:{error}",{error:dn(Cr)})}));try{await Qo()}catch(Qr){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Qr)}),"err")}R(!1);return}t(),Ct(a("✅ 账号设置已保存"));try{await Qo(),await Ig()}catch(Cr){Ct(a("账号已保存,但列表刷新失败:{error}",{error:dn(Cr)}),"err")}}catch(Pn){_(r.jsx("span",{className:"text-destructive",children:dn(Pn)})),Ct(a("保存失败:{error}",{error:dn(Pn)}),"err")}finally{ce.current=!1,R(!1)}}}const gn=Number(Ga(tn(ue)).concurrencyDefault)||0,un=ve||De||JS(ue),lr=["basic",...un?["credential"]:[],...Si(ue)?["query"]:[],"limiter","network"],yn=L?.name||ft().wbProviders?.labelOf?.(tn(ue))||tn(ue);async function xn(){if(!(gt||ce.current||!L)){ce.current=!0,he(!0);try{const ke=ft().wbCustomProvidersUi?.remove;if(!ke)throw new Error(a("账号更新接口不可用,请重新打开页面"));await ke(L.id)&&t()}catch(ke){Ct(a("删除失败:{error}",{error:dn(ke)}),"err")}finally{ce.current=!1,he(!1)}}}async function jn(){gt||ce.current||Rn&&!await sn(a("放弃未保存的修改?"),a("前往模型管理会关闭账号设置,尚未保存的修改不会生效。"),a("前往模型管理"))||(t(),ft().wbApp?.showPage?.("gateway"))}return r.jsx(at,{open:!0,onOpenChange:(ke,Xe)=>{ke||(Xe.cancel(),qe())},children:r.jsxs(it,{className:"acct-settings-dialog",showCloseButton:!gt,children:[r.jsxs(ot,{className:"acct-dlg-header",children:[r.jsx("div",{className:"acct-dlg-avatar",children:r.jsx(ha,{name:De?"agent":"accounts",size:23})}),r.jsxs("div",{className:"acct-dlg-identity",children:[r.jsxs("div",{className:"acct-dlg-title-row",children:[r.jsx(st,{children:a("账号设置")}),De?r.jsx(Ee,{variant:"secondary",shape:"tag",children:a("自定义 API")}):null]}),r.jsxs("p",{children:[r.jsx("span",{children:uCe(o)}),r.jsx("span",{className:"acct-dlg-title-dot",children:"·"}),r.jsxs("span",{className:`acct-dlg-account-state${o.enabled===!1?" off":""}`,children:[r.jsx(Yk,{}),o.enabled===!1?a("已停用"):a("已启用")]})]})]})]}),r.jsx(lt,{className:"acct-dlg-body",children:r.jsxs("div",{className:"acct-dlg",children:[r.jsxs($h,{className:"acct-dlg-rail","aria-label":a("账号设置分组"),children:[r.jsxs(Go,{className:"acct-dlg-nav",children:[r.jsx("div",{className:"acct-dlg-nav-label",children:a("当前账号")}),lr.map(ke=>r.jsx(Ts,{active:ie===ke,title:xe[ke].title,disabled:gt,className:"shadow-none",icon:r.jsx(ha,{name:xe[ke].icon}),trailing:On[ke]?r.jsx("span",{className:"acct-dlg-dirty-dot","aria-label":a("有未保存的修改")}):void 0,onClick:()=>ge(ke),children:xe[ke].title},ke)),L?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"acct-dlg-nav-divider"}),r.jsxs("div",{className:"acct-dlg-nav-label",children:[a("提供商"),r.jsx("span",{children:a("共用")})]}),r.jsx(Ts,{active:ie==="provider",disabled:gt,title:xe.provider.title,icon:r.jsx(ha,{name:xe.provider.icon}),trailing:On.provider?r.jsx("span",{className:"acct-dlg-dirty-dot","aria-label":a("有未保存的修改")}):void 0,onClick:()=>ge("provider"),children:xe.provider.title})]}):null]}),L?r.jsxs("div",{className:"acct-dlg-rail-context",children:[r.jsxs("strong",{children:[r.jsx(ha,{name:"accounts",size:14}),yn]}),r.jsx("p",{children:a("{count} 个账号共用连接配置",{count:Je})})]}):null]}),r.jsxs("div",{className:"acct-dlg-main",children:[r.jsxs("div",{className:"acct-dlg-pane-head",children:[r.jsxs("div",{children:[r.jsx("h3",{children:Se.title}),r.jsx("p",{children:Se.description})]}),r.jsxs("span",{className:`acct-dlg-scope${ie==="provider"?" shared":""}`,children:[r.jsx(ha,{name:"accounts",size:13}),ie==="provider"?a("{count} 个账号共用",{count:Je}):a("仅当前账号")]})]}),r.jsx("div",{ref:ye,className:"acct-dlg-scroll","aria-busy":A,children:r.jsxs("div",{className:"acct-dlg-pane",inert:gt?!0:void 0,children:[ie==="basic"?r.jsxs(r.Fragment,{children:[r.jsxs(wc,{title:a("账号信息"),children:[r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{htmlFor:"account-name-input",children:a("备注名")}),r.jsx(ze,{id:"account-name-input",maxLength:100,placeholder:a("账号显示名称"),value:g,onChange:ke=>v(ke.currentTarget.value)})]}),r.jsxs("div",{className:"acct-dlg-readonly",children:[r.jsx("span",{children:a("账号 ID")}),r.jsx("code",{children:ue.id})]}),r.jsxs(ct,{className:"acct-dlg-toggle-field",children:[r.jsxs("div",{children:[r.jsx(ut,{htmlFor:"account-enabled",children:a("启用账号")}),r.jsx(wr,{children:a("关闭后不参与转发,余额查询不受影响。")})]}),r.jsx(St,{id:"account-enabled",checked:u,onCheckedChange:d})]})]}),r.jsxs(wc,{title:a("转发行为"),children:[r.jsxs(ct,{className:"acct-dlg-toggle-field",children:[r.jsxs("div",{children:[r.jsx(ut,{htmlFor:"account-route-skip",children:a("失败后允许换号")}),r.jsx(wr,{children:a("关闭后,该账号转发失败时返回本次错误,不再顺延其他账号。禁用、无凭证和限制器等保护仍生效。")})]}),r.jsx(St,{id:"account-route-skip",checked:f,onCheckedChange:m})]}),r.jsxs(ct,{className:"acct-dlg-concurrency",children:[r.jsxs("div",{children:[r.jsx(ut,{htmlFor:"account-conc-input",children:a("并发上限")}),r.jsx(wr,{children:a("达到上限后,将请求交给其他账号。")})]}),r.jsx(ze,{id:"account-conc-input",type:"number",min:0,max:Su,step:1,value:je,onChange:ke=>te(ke.currentTarget.value)})]})]}),r.jsx("p",{className:"detail acct-dlg-hint",children:gn>0?a("0 = 按本家默认 {default}",{default:gn}):a("0 = 不限")}),w?r.jsx(wc,{title:a("请求标识"),children:r.jsxs(ct,{className:"acct-dlg-field",children:[r.jsx(ut,{htmlFor:"account-user-agent",children:"User-Agent"}),r.jsx(Ug,{id:"account-user-agent",value:b,onChange:y,presets:k,disabled:gt}),r.jsx(wr,{children:a("用于当前账号的对话、余额查询、模型拉取、模型测试、签到及凭证刷新等上游请求。留空使用提供商默认值;可选预置或直接填写。")})]})}):null,i?r.jsx("div",{className:"acct-dlg-route-context",children:i}):r.jsxs("p",{className:"detail acct-dlg-group-note",children:[r.jsx(ha,{name:"route",size:14}),a("在账号列表中拖动分组或行首把手,调整转发顺序。")]})]}):null,ie==="credential"&&un?r.jsxs(r.Fragment,{children:[ve?r.jsx(aCe,{configured:o.hasBalanceToken===!0,value:C,onChange:T,clearBusy:gt,onClear:()=>{zt()}}):null,De?r.jsx(iCe,{hasApiKey:ue.hasApiKey===!0,noAuth:ee,value:q,clearBusy:gt,onClear:()=>{ht()},onValue:ke=>{J(ke),ke.trim()&&H(!1)},onToggleNoAuth:ke=>{H(ke),ke&&J("")}}):null,JS(ue)?r.jsx(wc,{title:a("使用套餐"),children:r.jsx(XNe,{plan:P,hasJwt:o.canClaim===!0,onChange:O})}):null,L?r.jsxs("div",{className:"acct-dlg-related",children:[r.jsx(ha,{name:"agent",size:18}),r.jsxs("div",{children:[r.jsx("h3",{children:a("要修改连接地址或协议?")}),r.jsx("p",{children:a("{count} 个账号共用提供商的连接配置。",{count:Je})})]}),r.jsxs(B,{variant:"link",size:"xs",onClick:()=>ge("provider"),children:[a("连接设置"),r.jsx(ha,{name:"caretRight",size:12})]})]}):null]}):null,ie==="query"&&Si(ue)?r.jsxs(r.Fragment,{children:[r.jsx(wc,{title:a("余额查询"),children:r.jsx(H8,{draft:G,onChange:Y})}),We?r.jsxs(wc,{title:a("查询凭证"),action:r.jsx(Ee,{variant:"secondary",shape:"tag",children:We.label}),children:[r.jsx(rCe,{spec:We,values:se,configured:nt,onValue:(ke,Xe)=>re(Qe=>({...Qe,[ke]:Xe})),onClear:ke=>{Ht(ke)},clearBusy:gt,idPrefix:"account-balance-query"}),kt?r.jsx("p",{className:"detail acct-dlg-inline-note",children:a("查询凭证还没配齐:填好后余额列才有读数,在此之前会显示「未配置」。")}):null]}):null,r.jsxs("p",{className:"detail acct-dlg-group-note",children:[r.jsx(ha,{name:"info",size:14}),a("余额读数也是限制器余额规则的数据来源。")]})]}):null,ie==="limiter"?r.jsxs(r.Fragment,{children:[r.jsx(B8,{account:ue,draft:ne,onChange:de,allowBalance:Si(ue)}),r.jsxs("p",{className:"detail acct-dlg-group-note",children:[r.jsx(ha,{name:"info",size:14}),a("没有规则或全部停用时不限制;跳过后自动恢复,禁用后需手动启用。")]})]}):null,ie==="network"?r.jsxs(r.Fragment,{children:[r.jsxs(wc,{title:a("出网方式"),children:[r.jsx(pN,{draft:S,onChange:N,idPrefix:"account-proxy",allowRotate:Ie}),o.proxy?.error?r.jsx("p",{className:"detail text-destructive acct-dlg-block",children:a("当前代理不可用:{error}(不会自动改为直连)",{error:o.proxy.error})}):null]}),r.jsxs("p",{className:"detail acct-dlg-group-note",children:[r.jsx(ha,{name:"shield",size:14}),a("代理只作用于当前账号,不改变其他账号的出网方式。")]})]}):null,ie==="provider"&&L?r.jsx(lCe,{provider:L,count:Je,name:D,protocol:V,baseUrl:Q,accountBaseUrl:ue.baseUrl||"",emulation:U,onName:F,onProtocol:K,onBaseUrl:X,onEmulation:z,onClearAccountBaseUrl:()=>{Tt()},disabled:gt,onRemove:()=>{xn()},onModels:()=>{jn()}}):null]})})]})]})}),r.jsxs(xt,{className:"acct-dlg-footer",children:[r.jsxs("div",{className:`acct-dlg-save-state${Rn?" dirty":""}`,role:"status",children:[r.jsx(ha,{name:M?"info":Rn?"timer":"shield",size:16}),r.jsxs("div",{children:[r.jsx("strong",{children:M||(A?a("正在保存…"):Rn?a("{count} 个分区有未保存的更改",{count:Rn}):a("没有未保存的更改"))}),r.jsx("p",{children:On.provider?a("包含提供商共用配置,将影响 {count} 个账号",{count:Je}):a("各分区的更改将统一保存")})]})]}),r.jsxs("div",{className:"acct-dlg-footer-actions",children:[r.jsx(B,{variant:"outline",disabled:gt,onClick:()=>{qe()},children:a("取消")}),r.jsx(B,{variant:"default",disabled:gt||!Rn,onClick:()=>{Xt()},children:a(A?"保存中…":"保存更改")})]})]})]})})}function dCe(){const e=p.useSyncExternalStore(Hh,()=>Sn());return e.dialog?e.dialog.kind==="settings"?r.jsx(gG,{id:e.dialog.id,onClose:xy},e.dialog.id):e.dialog.kind==="group"?r.jsx(hG,{provider:e.dialog.provider,onClose:xy},e.dialog.provider):r.jsx(TNe,{ids:e.dialog.ids,action:e.dialog.action,onClose:xy},e.dialog.ids.join(",")):null}function Zh(e){return!!(e&&["queued","runtime","starting","loading","registering"].includes(e.phase))}function Jh(e){return e?.phase==="failed"||e?.phase==="timeout"}function em(e,t){switch(e?.phase){case"queued":return t("等待加载");case"runtime":return t("准备运行环境");case"starting":return t("正在启动");case"loading":return t("正在加载");case"registering":return t("即将就绪");case"ready":return t("已就绪");case"failed":return t("加载失败");case"timeout":return t("初始化超时");case"blocked":return t("等待运行环境恢复");case"disabled":return t("已停用");default:return t("状态待确认")}}function xG(e,t,n=Date.now()){if(e?.error&&Jh(e))return e.error;switch(e?.phase){case"queued":return t("等待前面的插件完成,不代表加载失败。");case"runtime":return t("正在检查或准备脚本运行环境。");case"starting":return t("正在启动插件,账号将在就绪后自动恢复。");case"loading":return n-e.updatedAt>1e4?t("启动较慢,仍在加载;尚未收到失败结果。"):t("正在初始化插件,尚未收到失败结果。");case"registering":return t("初始化已完成,正在等待校验和登记。");case"ready":return t("插件已就绪,账号列表将自动同步。");case"timeout":return t("本次初始化超过等待时限,已停止;可查看诊断后重试。");case"blocked":return t("共享运行环境尚未就绪,本插件没有明确的加载失败结果。");case"failed":return t("本次加载未完成,请查看诊断。");default:return t("暂未取得明确的加载结果,不能据此判断启动失败。")}}let kc={value:null,error:"",receivedAt:0,unavailable:!1};const XI=new Set,ky=e=>(XI.add(e),()=>{XI.delete(e)}),Bl=()=>kc;function QI(e){kc={...kc,...e},XI.forEach(t=>t())}let kN;function nf(){kN?.()}function fCe(e){let t=!1,n=!1,s=!1,i,o,l=null,u=!1,d="",f=0;QI({value:null,error:"",receivedAt:0,unavailable:!1});const m=()=>{if(l){u=!0;return}l=(async()=>{do{u=!1;try{await e.refresh()}catch{}}while(!t&&u)})().finally(()=>{l=null})},g=async()=>{if(t||document.hidden)return;if(n){s=!0;return}n=!0,o=new AbortController;const y=setTimeout(()=>o?.abort(),8e3);try{const k=await e.read(o.signal);if(t||o.signal.aborted)return;if(!k||typeof k.bootId!="string"||typeof k.revision!="string"||!k.providers||!Array.isArray(k.packs))throw new Error("Invalid plugin startup status");f=0;const w=kc.value?.bootId!==k.bootId||kc.value?.revision!==k.revision;QI({value:k,error:k.error||"",receivedAt:Date.now(),unavailable:!1}),w&&e.onChange?.();const S=`${k.bootId}:${k.availabilityRevision}`,N=e.session();(d&&d!==S||!N||N.bootId!==k.bootId||N.availabilityRevision!==k.availabilityRevision)&&m(),d=S}catch(k){if(t)return;f+=1;const w=k?.status;QI({error:k instanceof Error?k.message:String(k),unavailable:w===404})}finally{if(clearTimeout(y),n=!1,o=void 0,!t){clearTimeout(i);const k=s?0:kc.unavailable?6e4:f?Math.min(3e4,2e3*f):kc.value?.pending||kc.value?.scriptOperation?.active?1500:2e4;s=!1,i=setTimeout(()=>{g()},k)}}},v=()=>{clearTimeout(i),g()},b=()=>{document.hidden?clearTimeout(i):v()};return kN=v,document.addEventListener("visibilitychange",b),v(),()=>{t=!0,clearTimeout(i),o?.abort(),kN===v&&(kN=void 0),document.removeEventListener("visibilitychange",b)}}function ZI(e,t){const n=kc.value?.packs.find(s=>s.id===e)?.startup;return t&&(!n||t.updatedAt>n.updatedAt)?t:n||t}function hCe(e){const t=e.providers.map(n=>{const s=kc.value?.providers[n.id];if(!s||n.startup&&n.startup.updatedAt>s.startup.updatedAt)return n;if(!s.enabled)return{...n,packId:s.packId,startup:s.startup,reason:s.packEnabled?"provider_disabled":"pack_disabled"};const i=s.startup,o=Jh(i)?i.phase==="timeout"?"load_timeout":"load_failed":Zh(i)||s.available?"loading":"not_loaded";return{...n,packId:s.packId,startup:i,reason:o}});return{...e,providers:t}}const SN=e=>e.reason==="load_failed"||e.reason==="load_timeout";function vG(e,t){return t==="all"?!0:t==="loading"?e.reason==="loading"||e.reason==="not_loaded":t==="missing"?e.reason==="not_installed":t==="disabled"?e.reason==="pack_disabled"||e.reason==="provider_disabled":SN(e)}function mCe(e,t){switch(e.reason){case"not_installed":return t("插件未安装");case"pack_disabled":return t("插件包已停用");case"provider_disabled":return t("提供商已停用");case"load_failed":return t("加载失败");case"load_timeout":return t("初始化超时");case"loading":return e.startup?em(e.startup,t):t("正在加载");default:return em(e.startup,t)}}function pCe(e,t,n){switch(e.reason){case"not_installed":return t("重新安装这个插件后自动回来");case"pack_disabled":return t("启用插件包后自动回来");case"provider_disabled":return t("启用这家提供商后自动回来");default:return xG(e.startup,t,n)}}function gCe(e,t){return e.reason==="not_installed"?t("去安装"):e.reason==="pack_disabled"||e.reason==="provider_disabled"?t("去启用"):SN(e)||e.startup?.phase==="blocked"?t("查看原因"):t("查看进度")}let JI=null;const eM=new Set;function Sy(e){JI=e,eM.forEach(t=>t())}function xCe(){const e=JI;return JI=null,e}function vCe(e){return eM.add(e),()=>{eM.delete(e)}}function Ny(e,t){return p.useSyncExternalStore(ky,Bl),ZI(e,t)}function tM({id:e,status:t,t:n}){const s=Ny(e,t),i=Bl(),o=i.value?.now||Date.now(),l=s?.startedAt?Math.max(0,Math.round(((s.finishedAt||o)-s.startedAt)/1e3)):null;return r.jsxs("section",{className:"flex flex-col gap-2 text-xs","aria-label":n("加载状态"),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[Zh(s)?r.jsx(Qt,{className:"size-3.5"}):null,r.jsx(Ee,{variant:Jh(s)?"warning":"outline",shape:"tag",children:em(s,n)}),l!==null?r.jsx("span",{className:"text-muted-foreground",children:n("本次用时 {n} 秒",{n:l})}):null]}),r.jsx("p",{className:"m-0 whitespace-pre-wrap break-words text-muted-foreground",children:xG(s,n,o)}),s?.phase==="blocked"&&s.error?r.jsx("p",{className:"m-0 whitespace-pre-wrap break-words text-muted-foreground",children:s.error}):null,s?.startedAt?r.jsx("p",{className:"m-0 text-muted-foreground",children:n("开始时间:{time}",{time:new Date(s.startedAt).toLocaleString()})}):null,s?.finishedAt?r.jsx("p",{className:"m-0 text-muted-foreground",children:n("完成时间:{time}",{time:new Date(s.finishedAt).toLocaleString()})}):null,s?.steps?.length?r.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-muted-foreground",children:s.steps.map((u,d)=>r.jsxs("span",{children:[em({...s,phase:u.phase},n)," · ",(u.durationMs/1e3).toFixed(1)," s"]},d))}):null,s?.previousError?r.jsxs("details",{className:"text-muted-foreground",children:[r.jsx("summary",{children:n("上次加载记录(非本次故障)")}),r.jsx("p",{className:"whitespace-pre-wrap break-words",children:s.previousError})]}):null,i.error&&!i.unavailable?r.jsx("p",{className:"m-0 text-muted-foreground",children:n("暂时无法获取插件状态,显示上次结果;这不代表插件启动失败。")}):null]})}function bCe({id:e,name:t,status:n,script:s,onClose:i,retry:o,t:l}){const u=Ny(e,n),d=Bl().value?.packs.find(k=>k.id===e)?.name||t,f=Bl().value?.scriptOperation,[m,g]=p.useState(!1),[v,b]=p.useState("");p.useEffect(()=>{nf()},[e]);const y=async()=>{if(!(m||Zh(u)||Bl().error||s&&f?.active)){g(!0),b("");try{await o(),nf()}catch(k){b(k instanceof Error?k.message:String(k))}finally{g(!1)}}};return r.jsx(at,{open:!0,onOpenChange:k=>{!k&&!m&&i()},children:r.jsxs(it,{className:"w-[min(560px,calc(100vw-32px))]",children:[r.jsx(ot,{children:r.jsxs(st,{children:[d," · ",l("加载诊断")]})}),r.jsxs(lt,{children:[r.jsx(tM,{id:e,status:u,t:l}),s?r.jsx("p",{className:"m-0 text-xs text-muted-foreground",children:l("脚本插件共用运行环境;重试会等待当前任务结束,不会删除账号或重新安装插件。")}):null,f?.target?.id===e&&f.error&&!Zh(u)&&u?.phase!=="ready"&&(f.updatedAt||0)>=(u?.startedAt||0)?r.jsx("p",{role:"alert",className:"m-0 text-xs text-destructive",children:f.error}):null,s&&f?.active?r.jsx("p",{className:"m-0 text-xs text-muted-foreground",role:"status",children:l("正在重试…")}):null,v?r.jsx("p",{role:"alert",className:"m-0 text-xs text-destructive",children:v}):null]}),r.jsxs(xt,{children:[r.jsx(B,{variant:"outline",disabled:m,onClick:nf,children:l("刷新状态")}),u&&u.phase!=="ready"&&u.phase!=="disabled"?r.jsx(B,{disabled:m||Zh(u)||!!Bl().error||!!(s&&f?.active),onClick:()=>{y()},children:l(m?"正在重试…":"重新加载")}):null,r.jsx(B,{variant:"ghost",disabled:m,onClick:i,children:l("关闭")})]})]})})}function bG(e){return e.providers.filter(SN).length}function yCe({hidden:e,onOpen:t}){return e.total<=0?null:r.jsxs(B,{id:"btn-hidden-accounts",variant:"outline",className:"acct-hidden-entry",title:a("查看因插件未就绪而暂未显示的账号"),onClick:()=>{nf(),t()},children:[r.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:1.7,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("path",{d:"M2.5 12s3.4-6 9.5-6 9.5 6 9.5 6-3.4 6-9.5 6-9.5-6Z"}),r.jsx("path",{d:"m4 20 16-16"})]}),a("未显示账号"),r.jsx(Ee,{variant:bG(e)?"warning":"outline",shape:"tag",children:e.providers.length})]})}function jCe({hidden:e,open:t,onOpenChange:n}){const[s,i]=p.useState("all");p.useEffect(()=>{t&&nf()},[t]);const o=Bl(),l=m=>e.providers.filter(g=>vG(g,m)).length,u=e.providers.filter(m=>vG(m,s)),d=e.providers.filter(m=>m.reason==="loading").length,f=m=>{m?.packId&&!["not_installed","pack_disabled","provider_disabled"].includes(m.reason)&&Sy(m.packId),n(!1),ft().wbApp?.showPage?.("plugins")};return r.jsx(Qb,{open:t,onOpenChange:m=>{m||n(!1)},children:r.jsxs(Zb,{side:"right",showHandle:!1,className:"w-[min(480px,94vw)]",children:[r.jsx(MS,{children:r.jsx(IS,{children:a("未显示的账号")})}),r.jsxs(_S,{className:"acct-hidden-body",children:[r.jsx("p",{className:"acct-hidden-lead",children:a("{providers} 家提供商、共 {total} 个账号。数据仍在,只是当前没有可用的插件来执行它们。",{providers:e.providers.length,total:e.total})}),d?r.jsx("p",{className:"m-0 text-xs text-muted-foreground",role:"status",children:a("正在加载 · {n} 家提供商的账号暂未显示,就绪后自动恢复。",{n:d})}):null,o.error&&!o.unavailable?r.jsxs("p",{className:"m-0 text-xs text-muted-foreground",role:"status",children:[a("暂时无法获取插件状态,显示上次结果;这不代表插件启动失败。"),r.jsx(B,{variant:"link",size:"xs",onClick:nf,children:a("刷新状态")})]}):null,r.jsx(en,{"aria-label":a("按未显示原因筛选"),value:s,onValueChange:i,options:[{value:"all",label:a("全部"),count:l("all")},{value:"loading",label:a("待就绪"),count:l("loading")},{value:"missing",label:a("未安装"),count:l("missing")},{value:"disabled",label:a("已停用"),count:l("disabled")},{value:"broken",label:a("加载异常"),count:l("broken")}]}),r.jsxs("div",{className:"acct-hidden-rows",children:[u.map(m=>r.jsxs("div",{className:"acct-hidden-row",children:[r.jsx("span",{className:"acct-hidden-avatar","aria-hidden":"true",children:a(m.label).trim().slice(0,1)}),r.jsxs("div",{className:"acct-hidden-info",children:[r.jsxs("div",{className:"acct-hidden-name",children:[r.jsx("span",{className:"truncate",children:a(m.label)}),r.jsx(Ee,{variant:SN(m)?"warning":"outline",shape:"tag",children:mCe(m,a)})]}),r.jsxs("p",{className:"acct-hidden-detail",children:[a("保留 {n} 个账号",{n:m.count})," · ",pCe(m,a,o.value?.now)]})]}),r.jsx(B,{variant:"outline",size:"sm",onClick:()=>f(m),children:gCe(m,a)})]},m.id)),u.length?null:r.jsx("p",{className:"acct-hidden-none",children:a("这一类现在没有账号")})]}),r.jsx("p",{className:"acct-hidden-foot",children:a("这里只影响「显示」:卸载或停用插件不会删除账号;重新安装、启用并成功加载后,这些账号会自动回到列表。")})]}),r.jsxs(vP,{children:[r.jsx(B,{variant:"outline",onClick:()=>n(!1),children:a("知道了")}),r.jsx(B,{onClick:()=>f(),children:a("去「插件」页")})]})]})})}function wCe({hidden:e,onOpen:t}){return r.jsxs("div",{className:"acct-hidden-empty",role:"status",children:[r.jsxs("span",{children:[r.jsx(qa,{variant:bG(e)?"warning":"muted",className:"size-1.5"}),a("共有 {n} 个账号暂未显示",{n:e.total})]}),r.jsx(B,{variant:"outline",size:"sm",onClick:t,children:a("查看")})]})}function yG(e){const t=Math.round(e/6e4);if(t<1)return a("不到 1 分钟");if(t<60)return a("还有 {n} 分钟",{n:t});const n=Math.floor(t/60),s=t%60;return n<24?s?a("还有 {h} 小时 {m} 分",{h:n,m:s}):a("还有 {h} 小时",{h:n}):a("还有 {d} 天",{d:Math.floor(n/24)})}function kCe(e){const t=Date.now();return oI(e).map(n=>{const s=Number(n.resetAt),i=Number(n.at),o=uI(n.resetAt),l=o===cI,u=n.message||(n.status?a("上游返回 {status}",{status:n.status}):""),d=s-i,f=i>0&&Number.isFinite(d)&&d>0?Math.max(0,Math.min(100,(t-i)/d*100)):null,m=l?a("恢复时间未知"):yG(s-t),g=l?"":a("{time} 恢复",{time:o});return{model:n.model,wait:m,tone:l?"muted":"warn",reset:g,reason:u,title:[n.model,m,g,u,a("到恢复时间后自动解除,无需手动操作")].filter(Boolean).join(" · "),progress:f}})}function SCe({accountName:e,rows:t,count:n,cooldown:s,soonest:i,onClear:o}){const[l,u]=p.useState(!1),d=p.useRef(null),f=p.useCallback(v=>{d.current=v,v&&(v.scrollTop=0)},[]),m=p.useCallback(()=>d.current??null,[]),g=i===cI?a("待定"):i;return r.jsxs(r.Fragment,{children:[r.jsxs(ui,{open:l,onOpenChange:u,children:[r.jsxs(wi,{render:r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"usage-toggle warn",title:a(s?"点击查看账号冷却与模型限流明细":"点击查看各模型的限流明细"),"aria-label":a("限流明细")}),children:[r.jsx("span",{className:"val",children:s?a("账号冷却"):a("{n} 个模型",{n})}),r.jsx("span",{className:"caret","aria-hidden":!0,children:"▾"})]}),r.jsx(di,{align:"center",sideOffset:6,className:"w-[320px]",initialFocus:m,children:r.jsxs("div",{className:"usage-pop-limit",ref:f,tabIndex:-1,children:[e?r.jsx("div",{className:"usage-pop-sub",children:e}):null,r.jsx("div",{className:"usage-pop-group",children:a("限流明细")}),s?r.jsxs("div",{className:"usage-pop-row",children:[r.jsxs("div",{className:"usage-pop-line",children:[r.jsx("span",{className:"usage-pop-name",children:a("账号冷却")}),r.jsx("span",{className:"usage-pop-view warn",children:yG(s.resetAt-Date.now())})]}),r.jsx("div",{className:"lp-pop-subline",children:r.jsxs("span",{className:"lp-pop-reason",children:[a("{time} 恢复",{time:i}),s.message?` · ${s.message}`:""]})})]}):null,t.map(v=>r.jsxs("div",{className:"usage-pop-row",title:v.title,children:[r.jsxs("div",{className:"usage-pop-line",children:[r.jsx("span",{className:"usage-pop-name lp-pop-model",children:v.model}),r.jsx("span",{className:`usage-pop-view ${v.tone}`,children:v.wait})]}),r.jsxs("div",{className:"lp-pop-subline",children:[r.jsxs("span",{className:"lp-pop-reason",children:[v.reset?`${v.reset} · `:"",v.reason]}),r.jsx(B,{variant:"ghost",size:"xs",title:a("清掉本机的限流标记,立刻重新尝试该模型(上游若仍在限流会再次被标记)"),onClick:()=>o(v.model),children:a("清除")})]}),v.progress!==null?r.jsx(kg,{value:v.progress,variant:"muted",className:"mt-1.5",trackClassName:"h-[3px]","aria-label":a("冷却进度 {percent}%",{percent:Math.round(v.progress)})}):null]},v.model)),r.jsxs("div",{className:"lp-pop-foot",children:[r.jsx("span",{className:"lp-pop-note",children:s?a("账号全部模型暂时停止转发 · 到恢复时间自动解除"):a("{n} 个模型限流中 · 到恢复时间自动解除",{n})}),r.jsx(B,{variant:"outline",size:"xs",title:a("清除该账号的冷却与全部模型限流标记"),onClick:()=>o(""),children:a("全部清除")})]})]})})]}),r.jsx("span",{className:"lim-sub",title:a(s?"账号冷却":"最早恢复"),children:s?a("{time} 恢复",{time:g}):a("最早 {soonest} 恢复",{soonest:g})})]})}function jG({account:e,onOpen:t}){if(e.enabled===!1||!ay(e))return null;const n=HP(e),s=sy(e),i=s.some((u,d)=>u.action==="skip"&&n[d]?.hit&&n[d]?.account),o=[...new Set(s.flatMap((u,d)=>u.action==="skip"&&n[d]?.hit?n[d].models:[]))],l=i||!o.length?a("限制器 · 账号已跳过"):a("限制器 · {n} 个模型",{n:o.length});return r.jsx(B,{variant:"ghost",size:"xs",className:"h-auto p-0",onClick:t,title:a(i?"账号级条件组已触发;点击查看限制器":"仅跳过命中条件的模型,其他模型仍可转发;点击查看限制器"),children:r.jsx(Ee,{variant:"warning",shape:"tag",children:l})})}const Cy=new Map,tm=new Map;let nM=null;function Ra(e,t,n){const s={selector:t,mount:n,done:!1},i=Cy.get(e);i?i.push(s):Cy.set(e,[s]),nM===e&&kG(e)}function wG(e){if(!(e.done||!document.querySelector(e.selector))){e.done=!0;try{e.mount()}catch(n){console.error("[islands] 页面挂载失败:",e.selector,n)}}}function kG(e){const t=Cy.get(e);if(!t||t.length===0)return;for(const i of t)wG(i);const n=t.filter(i=>!i.done);if(n.length===0){Cy.delete(e),tm.get(e)?.disconnect(),tm.delete(e);return}if(tm.has(e))return;const s=new MutationObserver(()=>{for(const i of n)wG(i);n.every(i=>i.done)&&(s.disconnect(),tm.delete(e),Cy.delete(e))});s.observe(document.body,{childList:!0,subtree:!0}),tm.set(e,s)}function NCe(e){if(e!==nM)for(const[t,n]of tm)t!==e&&(n.disconnect(),tm.delete(t));nM=e,kG(e)}window.addEventListener("wb:page",e=>{const t=e.detail;typeof t=="string"&&t&&NCe(t)});const nm=[20,50,100,200],rM=[20,50,100,200,"all"],Hg=50,SG="workbuddy-desktop-table-size:";function NG(e){return e==="all"?a("全部"):String(e)}function NN(e,t=rM,n=Hg){t.includes(n)||(n=t.includes(Hg)?Hg:t[0]);let s=null;try{s=localStorage.getItem(SG+e)}catch{return n}if(s===null||s.trim()==="")return n;if(s==="all")return t.includes("all")?"all":n;const i=Number(s);return Number.isFinite(i)&&t.includes(i)?i:n}function CN(e,t){try{localStorage.setItem(SG+e,String(t))}catch{}}function Ay(e,t,n={}){const s=n.sizes??rM,i=n.defaultSize??Hg,[o,l]=p.useState(()=>NN(t,s,i)),[u,d]=p.useState(1),f=Math.max(1,o==="all"?1:Math.ceil(e/o)),m=Math.min(Math.max(1,u),f);p.useEffect(()=>{m!==u&&d(m)},[m,u]);const g=p.useCallback(w=>{l(w),CN(t,w),d(1)},[t]),v=p.useCallback(w=>{d(Math.min(Math.max(1,Math.round(w)||1),f))},[f]),b=o==="all"?0:(m-1)*o,y=o==="all"?e:Math.min(e,b+o),k=p.useCallback(w=>o==="all"?w.slice():w.slice(b,y),[o,b,y]);return{size:o,page:m,pageCount:f,rangeStart:e?b+1:0,rangeEnd:e?y:0,paged:o!=="all",setSize:g,goto:v,slice:k}}function rf({total:e,page:t,pageCount:n,size:s,sizes:i=rM,onSizeChange:o,onPageChange:l,range:u=null,disabled:d=!1,leading:f,className:m}){const[g,v]=p.useState(String(t));p.useEffect(()=>v(String(t)),[t]);const b=()=>{const w=g.trim();if(!w){v(String(t));return}const S=Number(w);if(!Number.isFinite(S)){v(String(t));return}const N=Math.min(Math.max(1,Math.round(S)),n);v(String(N)),N!==t&&l(N)},y=n<=1,k=e===0?a("共 0 条"):u?a("共 {total} 条 · 当前第 {start}–{end} 条",{total:e,start:u.start,end:u.end}):a("共 {total} 条(全部显示)",{total:e});return r.jsxs(ju,{className:m?`panel-foot table-foot-bar ${m}`:"panel-foot table-foot-bar",children:[f,r.jsx("div",{className:"spacer"}),r.jsxs("div",{className:"table-foot-ctl",children:[r.jsx("span",{className:"table-foot-count",children:k}),r.jsxs("span",{className:"table-foot-size",children:[a("每页"),r.jsxs(Pt,{value:String(s),onValueChange:w=>o(w==="all"?"all":Number(w)),children:[r.jsx(Mt,{className:"h-[26px] w-[86px]",disabled:d,"aria-label":a("每页条数"),children:r.jsx(It,{children:NG(s)})}),r.jsx(_t,{children:i.map(w=>r.jsx(Ze,{value:String(w),children:NG(w)},String(w)))})]}),a("条")]}),r.jsxs("span",{className:"table-foot-jump",children:[a("跳至"),r.jsx(ze,{className:"h-[26px] w-[52px] px-1 text-center",value:g,disabled:d||y,"aria-label":a("跳转到指定页"),title:y?a("当前只有一页"):a("跳转到第 1–{pageCount} 页",{pageCount:n}),inputMode:"numeric",onChange:w=>v(w.target.value),onKeyDown:w=>{w.key==="Enter"?(w.preventDefault(),b()):w.key==="Escape"&&v(String(t))},onBlur:b}),a("页")]}),r.jsx(xP,{page:t,pageCount:n,onPageChange:l,disabled:d})]})]})}const sM=[{key:"pick",label:a("选择"),align:"center",legacyAlign:"left"},{key:"order",label:a("顺序"),title:a("组内先后:按住左边的把手上下拖动即可调整;整组的先后拖分组带的把手"),align:"center",legacyAlign:"left"},{key:"account",label:a("账号"),align:"center",legacyAlign:"left"},{key:"proxy",label:a("代理"),title:a("该账号出网走的代理(已保存的代理 / 自定义 / 直连);点击可修改"),align:"center"},{key:"connections",label:a("连接数"),title:a("此刻正在使用这个账号的请求数(含还在下发内容的流式请求);为 0 时不显示"),align:"center"},{key:"status",label:a("状态"),align:"center",legacyAlign:"left"},{key:"limits",label:a("限流"),title:a("该账号当前限流中的模型;点徽章看明细"),align:"center",legacyAlign:"left"},{key:"expiry",label:a("有效期"),align:"center",legacyAlign:"left"},{key:"usage",label:a("余额"),align:"center",legacyAlign:"left"},{key:"actions",label:a("操作"),align:"right"}],CG="agent2api-accounts-col-widths",Ey={pick:47,order:84,proxy:186,connections:56,status:80,limits:148,expiry:132,usage:308,actions:200},aM=new Set(["account"]),CCe=300,iM=56,ACe=new Set([...Object.keys(Ey),...aM]),Vg=(()=>{try{const e=JSON.parse(localStorage.getItem(CG)||"{}"),t={};for(const[n,s]of Object.entries(e||{})){const i=Number(s);ACe.has(n)&&Number.isFinite(i)&&i>=iM&&(t[n]=Math.round(i))}return t}catch{return{}}})();function AG(){try{localStorage.setItem(CG,JSON.stringify(Vg))}catch{}}function ECe(){return{...Ey,...Vg}}function TCe(e){let t=0;for(const n of e){const s=Vg[n];s?t+=s:aM.has(n)?t+=CCe:Ey[n]?t+=Ey[n]:t+=iM}return Math.round(t)}function EG(e,t){const n=e?.querySelector(`thead th:nth-child(${t+1})`),s=n?.getAttribute("data-col")||n?.className.match(/cell-([a-z]+)/)?.[1];if(!s)return null;const i=e?.querySelector(`colgroup col[data-col="${CSS.escape(s)}"]`)||e?.querySelectorAll("colgroup col")[t];return i?{key:s,col:i}:null}function OCe(e,t,n){const s=Math.max(iM,Math.round(n));e.style.width=s+"px",aM.has(t)||s!==Ey[t]?Vg[t]=s:delete Vg[t]}let oM=()=>{};function RCe(e,t){if(oM=t,!e)return;let n=null;e.addEventListener("pointerdown",s=>{if(s.button!==0)return;const i=s.target?.closest?.(".col-grip");if(!i)return;s.preventDefault();const o=i.closest("th"),l=o?.closest("table")||null,u=o?.parentElement?[...o.parentElement.children].indexOf(o):-1,d=EG(l,u);if(!d)return;const f=s.clientX,m=d.col.getBoundingClientRect().width;i.classList.add("active"),document.body.classList.add("col-resizing");try{i.setPointerCapture(s.pointerId)}catch{}n={...d,startX:f,startWidth:m,grip:i,pointerId:s.pointerId},window.addEventListener("pointermove",g),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),window.addEventListener("blur",v);function g(b){if(n){if(b.buttons===0){v();return}OCe(n.col,n.key,n.startWidth+b.clientX-n.startX)}}function v(){if(!n)return;const{grip:b,pointerId:y}=n;n=null,b.classList.remove("active"),document.body.classList.remove("col-resizing");try{b.releasePointerCapture(y)}catch{}window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),window.removeEventListener("blur",v),AG(),oM()}}),e.addEventListener("dblclick",s=>{const i=s.target?.closest?.(".col-grip");if(!i)return;const o=i.closest("th"),l=o?.closest("table")||null,u=o?.parentElement?[...o.parentElement.children].indexOf(o):-1,d=EG(l,u);d&&(delete Vg[d.key],AG(),oM())})}let lM=Date.now(),rm=null;const qg=new Set;function Ty(){lM=Date.now();for(const e of qg)e();TG()}function TG(){rm!==null&&clearTimeout(rm),rm=null,!(!qg.size||document.hidden)&&(rm=setTimeout(Ty,6e4-Date.now()%6e4))}function PCe(e){return qg.add(e),qg.size===1&&(lM=Date.now(),document.addEventListener("visibilitychange",Ty),window.addEventListener("focus",Ty),TG()),()=>{qg.delete(e),!qg.size&&(rm!==null&&clearTimeout(rm),rm=null,document.removeEventListener("visibilitychange",Ty),window.removeEventListener("focus",Ty))}}const ICe=()=>lM,MCe=()=>0;function Oy(){return p.useSyncExternalStore(PCe,ICe,MCe),Date.now()}function _Ce(e){switch(e.trim().toLowerCase()){case"5h":return a("{n} 小时",{n:5});case"weekly":return a("每周");case"monthly":return a("每月");case"daily":return a("每日");default:return e.trim()}}function OG(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=Array.isArray(e.windows)?e.windows:[],n=[];for(const[s,i]of t.entries()){if(!i||typeof i!="object"||Array.isArray(i))continue;const o=i,l=oK(o.label,a),u=typeof o.group=="string"?o.group.trim():"",d=typeof o.window=="string"?o.window.trim().toLowerCase():"",f=_Ce(typeof o.window=="string"?o.window:"")||l;if(!u&&!f)continue;const m=Os(o.remainingPercent),g=m===null?null:Math.max(0,Math.min(100,m)),v=o.unlimited===!0,b=Os(o.remaining)===null&&Os(o.limit)===null&&!v,y=Os(o.resetsAt),k=Os(o.expiresAt);n.push({id:`${typeof o.key=="string"?o.key:[u,f].join("-")}-${s}`,group:u,label:l||[u,f].filter(Boolean).join(" · "),window:f,windowCode:d,view:lK(o,a,Ln),percent:g,remaining:Os(o.remaining),percentText:b&&g!==null?`${Ln(g)}%`:"",tone:v?"ok":g===null?"muted":g<20?"warn":"ok",unlimited:v,resetsAt:y!==null&&y>0&&y<=864e13?y:null,expiresAt:k!==null&&k>0&&k<=864e13?k:null,aside:o.aside===!0})}return n}function DCe(e){const t=new Map;for(const n of e){const s=n.group||n.id;let i=t.get(s);i||(i={id:s,name:n.group,rows:[]},t.set(s,i)),i.rows.push(n)}return[...t.values()]}function LCe(e,t){const n=new Set(t.map(l=>l.label)),s=Array.isArray(e.windows)?e.windows:[],i=new Set(s.flatMap(l=>l&&typeof l=="object"&&typeof l.key=="string"&&l.key?[l.key]:[])),o=Array.isArray(e.wallets)?e.wallets.filter(l=>!l||typeof l!="object"||Array.isArray(l)?!1:l.type!=="quota_window"&&!i.has(l.key??l.type)&&!n.has(l.displayName)):[];return FP({...e,wallets:o,subscription:null},a,Ln)}function $Ce({row:e}){const t=e.percentText||e.view,n=e.percent===null?e.view:a("剩余 {percent}%",{percent:Ln(e.percent)});return r.jsxs("span",{className:`usage-window-item ${e.tone}`,title:`${e.label} · ${n}`,children:[r.jsxs("span",{className:"usage-window-line",children:[r.jsx("span",{className:"usage-window-label",title:e.window,children:e.window}),r.jsx("span",{className:"usage-window-value",title:e.view,children:t})]}),e.percent!==null&&!e.unlimited?r.jsx(kg,{value:e.percent,variant:e.tone==="warn"?"warning":"success",className:"mt-1",trackClassName:"h-[3px]",indicatorClassName:e.tone==="ok"?"opacity-75":void 0,"aria-label":`${e.label} · ${n}`}):null]})}function zCe({entry:e,rows:t,updatedAt:n,creditDetail:s,children:i}){const o=e&&typeof e=="object"?e:{},l=o.subscription&&typeof o.subscription=="object"?o.subscription:{},u=typeof l.planName=="string"?l.planName.trim():"",d=DCe(t),f=t.some(O=>O.group),m=!f&&(t.length===1||t.some(O=>O.percent===null||O.view.length>10)),g=WS(o),v=LCe(o,t),b=t.filter(O=>!O.aside&&!O.unlimited),y=b.some(O=>O.percent!==null?O.percent<20:O.remaining!==null&&O.remaining<=0),k=b.some(O=>O.percent===null&&O.remaining===null)||g.length>0,w=b.length===0&&t.every(O=>!O.unlimited),S=a(w?"额度详情":y?"部分窗口偏低":k?"部分读数未知":"额度充足"),N=y?"warn":k||w?"muted":"ok",C=n?r8(n,a,Date.now()):"",T=n?a("上次成功查询:{time}",{time:ki(n)}):"",P=t.every(O=>O.percentText||O.view==="—")?a("剩余比例"):a("分窗口额度");return r.jsx("span",{className:"usage-cell usage-window-cell",children:r.jsxs("span",{className:"usage-window-quota",children:[r.jsxs("span",{className:"usage-window-top",children:[u?r.jsx(Ee,{variant:aI(u)?"secondary":"brand",shape:"tag",className:"usage-window-plan",title:u,children:MK(u)}):null,r.jsxs("span",{className:`usage-window-status ${N}`,title:S,children:[r.jsx(Yk,{}),r.jsx("span",{children:S})]})]}),r.jsx("span",{className:`usage-window-grid${f?" grouped":" ungrouped"}${m?" compact":""}`,style:{"--quota-columns":Math.min(3,d.length)},children:d.map(O=>r.jsxs("span",{className:"usage-window-group",children:[O.name?r.jsx("span",{className:"usage-window-group-name",title:O.name,children:O.name}):null,O.rows.map(A=>r.jsx($Ce,{row:A},A.id))]},O.id))}),r.jsxs("span",{className:"usage-window-foot",children:[r.jsxs("span",{className:"usage-window-updated",title:T,children:[r.jsxs("span",{className:"usage-window-caption",children:[P,C?" · ":""]}),C]}),r.jsxs(ui,{children:[r.jsxs(wi,{render:r.jsx(B,{type:"button",size:"xs",variant:"ghost",className:"usage-window-detail"}),children:[a("额度详情"),r.jsx("span",{"aria-hidden":"true",className:"usage-window-caret",children:"⌄"})]}),r.jsxs(di,{align:"end",sideOffset:6,className:"usage-window-pop",children:[r.jsx(Kwe,{children:r.jsx(lq,{children:a("窗口额度与时间")})}),r.jsxs("div",{className:"usage-window-pop-body",children:[t.map(O=>r.jsxs("div",{className:"usage-window-reset",children:[r.jsxs("div",{className:"usage-window-reset-head",children:[r.jsx("span",{title:O.label,children:O.label}),r.jsx("span",{className:`usage-window-reset-value ${O.tone}`,children:O.percentText||O.view})]}),O.resetsAt!==null?r.jsx("time",{dateTime:new Date(O.resetsAt).toISOString(),children:a("重置 {date}",{date:ki(O.resetsAt)})}):O.expiresAt===null?r.jsx("span",{className:"usage-window-reset-unknown",children:a("未返回重置时间")}):null,O.expiresAt!==null?r.jsx("time",{dateTime:new Date(O.expiresAt).toISOString(),children:a("到期 {date}",{date:ki(O.expiresAt)})}):null]},O.id)),v.length?r.jsx("div",{className:"usage-window-supplementary",children:v.map(O=>r.jsx("p",{children:O},O))}):null,g.map(O=>r.jsx("p",{className:"usage-window-warning",children:a(O)},O)),r.jsx(Gwe,{className:"usage-window-explanation",children:a("各窗口独立限制请求,不相加为总余额。")})]})]})]})]}),s?r.jsx("span",{className:"usage-window-credit",children:s}):null,i]})})}function BCe(e){return e.windowCode==="daily"||e.windowCode==="5h"}function FCe(e,t){const n=e.filter(f=>!f.aside),s=new Set(n.filter(f=>(f.windowCode==="weekly"||f.windowCode==="monthly")&&!f.unlimited&&(f.percent!==null&&f.percent<=0||f.remaining!==null&&f.remaining<=0)).map(f=>f.group));let i=!1;const o=n.map(f=>{const m=BCe(f),g=m&&s.has(f.group);return g&&(f.unlimited||f.percent!==0)&&(i=!0),{label:f.group?`${f.group} · ${f.window}`:f.window,percent:g?0:f.percent,unlimited:!g&&f.unlimited,shortWindow:m}}),l=o.filter(f=>f.shortWindow&&(f.percent!==null||f.unlimited)),u=(l.length?l:o).flatMap(f=>f.unlimited?[100]:f.percent===null?[]:[f.percent]);if(u.length)return{percent:Math.min(...u),hasShortWindow:l.length>0,adjusted:i,windows:o};if(t===null)return null;const d=Math.max(0,Math.min(100,t));return{percent:d,hasShortWindow:!1,adjusted:!1,windows:[{label:"",percent:d,unlimited:!1}]}}function UCe(e,t="group",n=Date.now()){const s={counted:0,total:e.length,sum:null,unlimited:0,unit:"",failed:0,uncountable:0,pending:0,partial:0,scope:t,additive:!0,ratio:null,expiring:xN([],n)},i=[];let o=0,l=null;for(const u of e){const d=po(u);if(d==null){s.pending++;continue}const f=Og(d);if(f){f.notConfigured||s.failed++;continue}if(typeof d!="object"||Array.isArray(d)){s.uncountable++;continue}if((d.statisticsError||WS(d).length>0)&&s.partial++,sI(u)&&i.push(...RNe(d,n)),d.unlimited===!0){s.unlimited++;continue}const m=Object.prototype.hasOwnProperty.call(d,"totalLeft"),g=Os(m?d.totalLeft:d.available),v=FCe(OG(d),g),b=String(d.unit||a("积分")).trim(),y=g===null&&v===null?null:b==="%"||g===null?"ratio":"additive";if(y===null){s.uncountable++;continue}if(l===null&&(l=y),l!==y){s.uncountable++;continue}if(y==="additive"&&s.unit&&b!==s.unit){s.uncountable++;continue}s.unit||(s.unit=b),s.counted++,y==="additive"?g!==null&&(o+=g):v&&(!s.ratio||v.percent[s.label,RG(s)].filter(Boolean).join(" ")).join(" · ")})),e.ratio.adjusted&&t.push(a("每周或每月额度已耗尽,短周期实际可用额度按 0% 计算;账号明细保留原始读数"))),e.pending&&t.push(a("{n} 个还没查到(未查询或正在查询)",{n:e.pending})),e.failed&&t.push(a("{n} 个查询失败",{n:e.failed})),e.uncountable&&t.push(e.additive?a("{n} 个读数没有绝对数(只给比例或无额度),未计入",{n:e.uncountable}):a("{n} 个读数里没有可用比例,未计入",{n:e.uncountable})),e.partial&&t.push(a("{n} 个读数只读到一半(读数可信但不完整)",{n:e.partial}));const n=vN(e.expiring,a,cM,e.unit===a("积分")?"积分":e.unit);return n.detail&&t.push(n.detail),t.join(";")}function VCe({balance:e}){const t=vN(e.expiring,a,cM,e.unit===a("积分")?"积分":e.unit),n=e.failed+e.partial>0,s=e.additive?e.sum===null&&e.unlimited===0:e.ratio===null&&e.unlimited===0,i=!e.additive&&e.ratio?.windows.some(f=>!f.unlimited&&f.percent!==null&&f.percent<20),o=n||i?"warn":s?"muted":"ok",l=e.unlimited>0?"∞":e.sum===null?"—":cM(e.sum),u=e.additive&&e.unit&&e.unit!=="积分"&&e.unit!==a("积分")?mo(e.unit,a):"",d=e.unlimited===0&&e.counted0?r.jsx("b",{className:"v",children:"∞"}):e.ratio?e.ratio.windows.map((f,m)=>r.jsxs(p.Fragment,{children:[m>0?r.jsx("span",{className:"k","aria-hidden":"true",children:"·"}):null,f.label?r.jsx("span",{className:"k",children:f.label}):null,r.jsx("b",{className:f.percent===null&&!f.unlimited?"k":"v",children:RG(f)})]},`${f.label}-${m}`)):r.jsx("b",{className:"v",children:"—"}),d?r.jsx("span",{className:"n",children:d}):null,t.group?r.jsx("span",{className:"n soon",title:t.detail,children:t.group}):null,n?r.jsx("span",{className:"warn-mark","aria-hidden":!0,children:"⚠"}):null]})}const qCe=["codearts"];function uM(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;const t=Number(e),n=Number.isFinite(t)?t<1e11?t*1e3:t:Date.parse(String(e));return Number.isFinite(n)&&n>0?n:null}function KCe(e,t){if(!qCe.includes(String(e.provider??"")))return[];if(e.hasAccessToken!==!0||e.hasRefreshToken!==!0)return[];const n=uM(e.refreshTokenExpiresAt??e.refreshExpiresAt);if(n===null&&e.refreshTokenLongLived!==!0)return[];const s=uM(e.accessTokenExpiresAt)??uM(t);return n!==null&&s!==null&&n===s?[]:[{label:"Access Token",expiresAt:s,longLived:!1},{label:"Refresh Token",expiresAt:n,longLived:n===null&&e.refreshTokenLongLived===!0}]}function GCe(e,t,n=Date.now()){if(e.longLived)return t("长期有效");if(e.expiresAt===null)return"—";const s=e.expiresAt-n;return s<=0?t("已过期"):s<36e5?t("{n} 分钟后",{n:Math.max(1,Math.round(s/6e4))}):s<48*36e5?t("{n} 小时后",{n:Number((s/36e5).toFixed(1))}):t("{n} 天后",{n:Math.floor(s/864e5)})}let dM=!1;async function PG(e){if(dM){Ct(a("账号正在导出,请稍候"));return}const t=ft().workbuddyDesktop;if(!t?.exportAccountFiles){Ct(a("当前客户端不支持逐账号导出,请更新客户端"),"err");return}dM=!0;try{const n=ft().wbConfirm?.ask,s=a("导出文件包含登录凭证,可直接用于登录。请妥善保管,不要外传或上传到公共位置。")+(e.provider?`

${a("本组每个账号会分别保存为一个 JSON 文件,包含被筛选隐藏的账号。")}`:"")+(e.provider&&t.platform==="web"?`

${a("网页端会逐个下载文件;浏览器提示时请允许本网站下载多个文件。")}`:"");if(!(n?await n({title:e.provider?a("导出本组账号"):a("导出账号"),html:s,okText:a("导出")}):window.confirm(a("导出文件包含登录凭证,可直接用于登录。请妥善保管,不要外传或上传到公共位置。"))))return;const o=await t.exportAccountFiles(e);if(o?.canceled)return;if(!o)throw new Error(a("导出未返回结果"));const l=o.count||0,u=o.failed||[];if(u.length){const d=u[0],f=[d.name||d.id,d.error].filter(Boolean).join(":");Ct(a("已导出 {count} 个账号文件,{failed} 个未导出:{reason}",{count:l,failed:u.length,reason:f}),"err")}else l?Ct(o.downloadStarted?a("已发起 {count} 个账号文件的下载,请在浏览器下载列表确认",{count:l}):a("✅ 已导出 {count} 个账号文件",{count:l}),"ok"):Ct(a("没有可导出的账号"))}catch(n){Ct(a("账号导出失败:{reason}",{reason:dn(n)}),"err")}finally{dM=!1}}function Ry(e,t){return ft().wbIcons?.icon?.(e,t)||""}function WCe({account:e,rank:t,sortActive:n}){const s=a("组内第 {rank} 位",{rank:t});return r.jsxs("div",{className:"order-cell",children:[r.jsx("span",{className:`order-grip${n?" locked":""}`,role:"button",tabIndex:-1,"aria-label":a("拖动调整组内顺序"),"aria-disabled":n||void 0,title:n?wN(zl(tn(e),Nu(tn(e)))):a("按住拖动,调整这个账号在本组内的顺序"),dangerouslySetInnerHTML:{__html:Ry("gripVertical",14)}}),r.jsx("span",{className:"order-rank",title:s,children:`#${t}`})]})}function YCe({group:e,ids:t,collapsed:n}){const[s,i]=p.useState(!1),o="w-full justify-start px-2 font-normal";return r.jsxs(ui,{open:s,onOpenChange:i,children:[r.jsx(wi,{render:r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"grp-iconbtn",title:a("本组操作")}),children:"⋯"}),r.jsx(di,{align:"end",sideOffset:4,className:"w-[196px] p-1.5",children:r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("启用这一组里的全部账号(含被筛选隐藏的)"),onClick:()=>{i(!1),M8(t,!0)},children:a("全部启用({n})",{n:t.length})}),r.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("禁用这一组里的全部账号(含被筛选隐藏的)"),onClick:()=>{i(!1),M8(t,!1)},children:a("全部禁用({n})",{n:t.length})}),r.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("打开批量操作弹窗,并预选这一组的账号(改代理等动作在弹窗里挑参数)"),onClick:()=>{i(!1),OI(t,"proxy")},children:a("批量操作本组")}),r.jsx(B,{variant:"ghost",size:"sm",className:o,title:a("导出本组全部账号,每个账号一个 JSON 文件(含被筛选隐藏的)"),onClick:()=>{i(!1),PG({provider:e.provider})},children:a("导出本组账号")}),r.jsx("div",{className:"my-1 h-px bg-hairline"}),r.jsx(B,{variant:"ghost",size:"sm",className:o,onClick:()=>{i(!1),JK(e.provider)},children:a(n?"展开这一组":"折叠这一组")})]})})]})}function XCe({group:e,collapsed:t,colSpan:n}){const s=Oy(),{src:i,onError:o}=Qh(e.provider),l=Sn().groupTotalFiltered,u=l?e.accounts:e.members,f=e.members.length>1&&u.length>0&&u.some(Si)?UCe(u,l?"filtered":"group",s):null,m=v=>{v.target?.closest?.("button, a, input, select, label, .queue-grip")||String(window.getSelection?.()||"").length>0||JK(e.provider)},g=YI(Nu(e.provider));return r.jsx(Jt,{className:"grp-band","data-provider":e.provider,children:r.jsx(Ve,{colSpan:n,onClick:m,children:r.jsxs("div",{className:"grp-band-inner",children:[r.jsx("span",{className:"queue-grip",role:"button",tabIndex:-1,"aria-label":a("拖动调整整组顺序"),title:a("按住拖动,调整这一家的组顺位(整组一起动)"),dangerouslySetInnerHTML:{__html:Ry("gripVertical",14)}}),r.jsx("span",{className:"grp-rank",title:a("组顺位:越小越先用(拖动分组带调整)"),children:a("第 {rank} 顺位",{rank:e.rank})}),r.jsx("span",{className:"grp-logo",children:i?r.jsx("img",{src:i,alt:"",loading:"lazy",onError:o}):r.jsx("span",{className:"grp-logo-txt",children:String(e.label||"?").trim().slice(0,1).toUpperCase()})}),r.jsx("span",{className:"grp-name",children:a(e.label)}),r.jsx("span",{className:"grp-stat",children:a("{total} 个账号 · 启用 {enabled} · 禁用 {disabled}{limited}",{total:e.members.length,enabled:e.enabled,disabled:e.disabled,limited:e.limited>0?a(" · 限流 {n}",{n:e.limited}):""})}),f?r.jsx(VCe,{balance:f}):null,g?r.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"grp-sort-mark",title:a("当前排序规则:{rules}。点击调整",{rules:g}),onClick:()=>E8(e.provider),children:[r.jsx("span",{dangerouslySetInnerHTML:{__html:Ry("sort",10)}}),g]}):null,r.jsx("span",{className:"grp-spacer"}),r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"grp-iconbtn","aria-haspopup":"dialog",title:a("添加 {name} 账号",{name:a(e.label)}),"aria-label":a("添加 {name} 账号",{name:a(e.label)}),onClick:v=>{v.stopPropagation(),ft().wbAddAccountModal?.openProvider?.(e.provider)},children:r.jsx("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",focusable:"false",children:r.jsx("path",{d:"M12 5v14M5 12h14"})})}),r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"grp-iconbtn",title:a("分组设置"),"aria-label":a("分组设置"),onClick:()=>E8(e.provider),dangerouslySetInnerHTML:{__html:Ry("settings",14)}}),r.jsx(YCe,{group:e,ids:e.members.map(v=>v.id),collapsed:t})]})})})}function QCe({account:e}){const t=Ni(e),n=fSe(e);!t&&Jke(e,Wh(e))&&n.push({text:a("Token 限额 · 已禁用"),kind:"bad",title:a("本周期 Token 消耗达到限制器的上限,账号已被自动禁用(窗口重置也不恢复,需手动启用)")});const s=Ci(e)||e.id;return r.jsxs(r.Fragment,{children:[r.jsx(St,{checked:t,"aria-label":a("{action}{who}",{action:a(t?"禁用":"启用"),who:s}),title:a(t?"已启用,点击禁用(不参与转发)":"已禁用,点击启用"),onCheckedChange:i=>{P8(e.id,i)}}),n.length?r.jsx("div",{className:"status-tags",children:n.map(i=>r.jsx(Ee,{shape:"tag",variant:i.kind==="bad"?"destructive":"secondary",title:i.title,children:i.text},i.text))}):null]})}function ZCe({account:e,onClear:t}){const n=oI(e),s=pK(e),i=gK(e);return i?r.jsx(Ee,{variant:"destructive",shape:"tag",title:i,children:a("上游限制 · 已禁用")}):!n.length&&!s?Array.isArray(e.limiterGroups)&&ay(e)?r.jsx(jG,{account:e,onOpen:()=>Mg(e.id)}):eI(e,po(e))?r.jsx(Ee,{variant:"warning",shape:"tag",title:a("余额低于限制器的阈值,转发时会跳过该账号(余额回升自动恢复)"),children:a("余额不足")}):tI(e,Wh(e))?r.jsx(Ee,{variant:"warning",shape:"tag",title:a("本周期 Token 消耗达到限制器的上限,转发时会跳过该账号(窗口重置自动恢复)"),children:a("Token 限额")}):r.jsxs(Ee,{variant:"success",shape:"tag",title:a("当前没有任何模型处于限流中"),children:[r.jsx(Yk,{}),a("正常")]}):r.jsx(SCe,{accountName:Ci(e),rows:kCe(e),count:n.length,cooldown:s,soonest:uI(s?s.resetAt:n[0].resetAt),onClear:t})}function JCe({account:e}){const t=Ga(tn(e)),n=t.edition?SK(e.expiresAt):NK(e),s=KCe(e,n);if(s.length)return r.jsx("div",{className:"flex flex-col items-center gap-1",children:s.map(u=>r.jsx(e1e,{row:u},u.label))});if(t.longLived)return r.jsx("span",{title:a("主凭证没有固定到期时刻,到期由网关自动续期或本来就不会过期"),children:a("长期有效")});if(!n)return r.jsx("span",{className:"muted",title:a("记录里没有过期时间"),children:"—"});const i=n-Date.now();if(i<=0)return r.jsx(Ee,{variant:"destructive",shape:"tag",title:a("凭证已过期;能否续期取决于登录方式,本机引用需由原客户端处理"),children:a("已过期")});const o=i<36e5?a("{n} 分钟后",{n:Math.max(1,Math.round(i/6e4))}):i<48*36e5?a("{n} 小时后",{n:(i/36e5).toFixed(1)}):a("{n} 天后",{n:Math.floor(i/24/36e5)}),l=ki(n);return r.jsx("span",{title:l?a("{text}过期({full})",{text:o,full:l}):a("{text}过期",{text:o}),children:o})}function e1e({row:e}){const t=e.expiresAt!==null&&e.expiresAt<=Date.now(),n=e.expiresAt===null?a("记录里没有过期时间"):ki(e.expiresAt);return r.jsxs("div",{className:"flex items-center justify-center gap-1.5 whitespace-nowrap",title:`${e.label} · ${n}`,children:[r.jsx("span",{className:"text-[9px] text-subtle",translate:"no",children:e.label}),t?r.jsx(Ee,{variant:"destructive",shape:"tag",children:a("已过期")}):r.jsx("span",{className:e.expiresAt===null&&!e.longLived?"muted":void 0,children:GCe(e,a)})]})}function t1e({account:e}){const t=T8(e.id);return t<=0?null:r.jsx("span",{className:"conn-count",title:a("{n} 个请求正在使用该账号(含还在下发内容的流式请求)",{n:t}),children:t})}function n1e(e){return!e||typeof e!="object"||Array.isArray(e)?"":fM(e.subscription)}function fM(e){if(!e||typeof e!="object")return"";const t=e,n=[];t.planName&&n.push(a("套餐 {name}",{name:String(t.planName)})),t.status&&n.push(a("状态 {status}",{status:String(t.status)})),t.state&&String(t.state)!=="active"&&n.push(rI(t.state));const s=t.expireAt;if(s!=null&&s!==""){const i=Number(s),o=Number.isFinite(i)&&i>1e11?ki(i):String(s);o&&n.push(a("到期 {time}",{time:o}))}return Number.isFinite(Number(t.remainQuota))&&n.push(a("余量 {value}",{value:Ln(t.remainQuota)})),Number.isFinite(Number(t.totalQuota))&&n.push(a("总量 {value}",{value:Ln(t.totalQuota)})),n.join(" ")}function r1e(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=e.plans;return Array.isArray(t)?t.filter(n=>n&&typeof n=="object"&&String(n.state||"")==="pending"):[]}function s1e(e){const t=e.map(n=>{const s=String(n.name||n.planId||a("套餐")),i=Number(n.pendingUntil??n.startsAt);return Number.isFinite(i)&&i>0?a("{name}({time} 起生效)",{name:s,time:ki(i*1e3)}):s});return a(`已领到、还没到生效时间的套餐(生效后余额列会按它显示): {lines}`,{lines:t.join(` -`)})}function a1e(e){if(e===void 0)return{text:a("未查询"),kind:"muted",title:a("尚未查询该账号的余额")};if(e===null)return{text:a("查询中…"),kind:"muted",title:a("正在查询")};const t=Og(e);if(t)return t.notConfigured?{text:a("未配置"),kind:"muted",title:a("{message}(去该账号的「设置」里填上查询凭证即可)",{message:t.message})}:{text:a("查询失败"),kind:"bad",title:t.message};if(typeof e!="object"||e===null)return{text:a("无数据"),kind:"muted",title:String(e)};const n=e,s=aq(n,a);if(s)return{text:s.text,kind:"muted",title:s.detail};if(Object.prototype.hasOwnProperty.call(n,"totalLeft")){const i=n.unlimited?"∞":Ln(n.totalLeft);return{text:a("可用 {total}",{total:i}),kind:"ok",title:a("总剩余 {total} · 套餐 {plan} · 奖励 {bonus}",{total:i,plan:Ln(n.planLeft),bonus:Ln(n.bonusLeft)})}}if(Array.isArray(n.windows)&&n.windows.length){const i=n.windows,o=WS(n);return{text:a("分窗口额度"),kind:o.length?"warn":"ok",title:[...new Set([...FP(n,a,Ln),fM(n.subscription),...i.filter(l=>l&&typeof l=="object").map(l=>[oq(l.label,a),lq(l,a,Ln)].filter(Boolean).join(" ")),...o.map(l=>a(l))].filter(Boolean))].join(" · ")}}if(Object.prototype.hasOwnProperty.call(n,"available")||Array.isArray(n.wallets)){const i=mo(String(n.unit||a("积分")),a),o=uq(n)??(Array.isArray(n.wallets)?n.wallets:[]),l=o.filter(w=>!iq(w)).map(w=>`${w?.displayName||w?.type||a("明细")} ${w?.balanceView?String(w.balanceView):Ln(w?.balance)}`).join(" · "),u=Rke(n,a,Ln).map(w=>`${w.name} ${w.view}`).join(" · "),d=fM(n.subscription),f=[];if(o.length===0&&Array.isArray(n.plans)&&n.plans.length>0){const w=IG(n);f.push(w&&MG(w)?a("读数里没有额度桶,这里按套餐权益里的已用 / 总量显示(上游给的数)"):a("上游的余额读数里没有这个套餐的额度桶,剩余量读不到;余额列显示的是套餐发放的权益额度,不是剩余量"))}String(n.walletsFrom||"")==="monitor"&&f.push(a("额度窗口读数来自开放平台监控通道(套餐 JWT 那条通道没有额度桶):读的是每 N 小时 / 每周窗口的剩余比例"));const m=n.available==null?o.find(w=>Jo(w?.balance)!==null):void 0,g=n.availableView?String(n.availableView):m?a("可用 {value} {unit}",{value:Ln(m.balance),unit:mo(String(m.unit||i),a)}):a("可用 {value} {unit}",{value:Ln(n.available),unit:i}),v=[...WS(n).map(w=>a(w)),n.statisticsError?a("订阅统计未读到:{error}",{error:String(n.statisticsError)}):""].filter(Boolean),b=FP(n,a,Ln),y=Jo(n.available)===null&&!m&&!n.availableView,k=y&&b.length?b[0]:g;return{text:k+(v.length?" ⚠":""),kind:v.length?"warn":y?"muted":"ok",title:[...new Set([k,l,u,d,...b,...f,...v].filter(Boolean))].join(" · ")}}return{text:a("无数据"),kind:"muted",title:a("未返回可识别的余额数据")}}function IG(e){const t=Array.isArray(e.plans)?e.plans:[],n=s=>String(s?.state||"");return t.find(s=>n(s)==="active")||t.find(s=>n(s)==="pending")||t[0]||null}function i1e(e){const t=Array.isArray(e.entitlements)?e.entitlements:[];let n=null;for(const s of t){const i=Number(s?.grantUnits);if(!Number.isFinite(i)||i<=0)continue;const o=String(s?.unitType||"").trim();(!n||i>n.units)&&(n={units:i,unit:o})}return n}function MG(e){const t=Array.isArray(e.entitlements)?e.entitlements:[];for(const n of t){const s=Jo(n?.totalUnits);if(s===null||s<=0)continue;const i=Jo(n?.usedUnits),o=Jo(n?.remainingUnits),l=i===null?o===null?null:Math.max(0,s-o):i;if(l!==null)return{used:l,total:s,unit:String(n?.unitType||"").trim()}}return null}function o1e(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e,n=Array.isArray(t.wallets)?t.wallets.filter(m=>!iq(m)):[];let s=null;for(const m of n){const g=Number(m?.total);!Number.isFinite(g)||g<=0||(!s||g>Number(s.total))&&(s=m)}const i=t.subscription&&typeof t.subscription=="object"?t.subscription:{};if(!s){let m=null;for(const k of n){const w=Jo(k?.remainingPercent);w!==null&&(!m||w0?l/u*100:null),f=l!==null&&u!==null&&u>0?a("剩 {remaining} / {total}",{remaining:qg(l),total:qg(u)}):a("可用 {value} {unit}",{value:Ln(s.balance),unit:mo(String(s.unit||""),a)}).trim();return{planName:o,text:String(s.balanceView||f),percent:d===null?null:Math.max(0,Math.min(100,d))}}function Jo(e){if(e==null||e==="")return null;const t=Number(e);return Number.isFinite(t)?t:null}function _G({row:e}){const t=e.percentText||e.view;return r.jsxs("span",{className:`usage-meter ${e.tone}`,title:e.title,children:[r.jsxs("span",{className:"usage-meter-head",children:[e.name?r.jsx("span",{className:"usage-meter-name",children:e.name}):null,e.win?r.jsx("span",{className:"usage-meter-win",children:e.win}):null,r.jsx("span",{className:"usage-meter-val",children:t})]}),e.percent!==null?r.jsx(kg,{value:e.percent,variant:e.over||e.tone==="bad"?"destructive":e.tone==="ok"?"success":e.tone==="warn"?"warning":"muted",className:"mt-1",trackClassName:"h-[3px]","aria-label":a("剩余 {percent}%",{percent:Math.round(e.percent)})}):null]})}function qg(e){const t=Number.isFinite(e)?Number(e.toFixed(2)):e,n=window.wbUnits;return n?.formatTokens?n.formatTokens(t):String(t)}function l1e(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e,n=Array.isArray(t.wallets)?t.wallets:[];if(!n.length)return null;const s=mo(String(t.unit||"积分"),a),i=[];for(const u of n){const d=String(u.displayName||u.type||a("明细")),f=Jo(u.creditRemaining),m=Jo(u.creditTotal);if(!(f===null&&m===null&&u.creditUsed==null)){if(f!==null){const g=m!==null&&m>0,v=g?Math.max(0,Math.min(100,f/m*100)):null;i.push({name:d,view:g?a("剩 {remaining} / {total}",{remaining:Ln(f),total:Ln(m)}):a("剩 {remaining}",{remaining:Ln(f)}),tone:f<=0?"muted":v!==null&&v<20?"warn":"ok",percent:v,over:!1,title:g?void 0:a("上游未给总量,画不出剩余比例")});continue}i.push({name:d,view:u.creditUsed==null?a("总量 {value}",{value:Ln(m)}):a("已用 {used}",{used:Ln(u.creditUsed)}),tone:"muted",percent:null,over:!1})}}const o=t.subscription&&typeof t.subscription=="object"?t.subscription:{},l=[t.statisticsError?a("订阅统计未读到:{error}",{error:String(t.statisticsError)}):""].filter(Boolean);return{credit:i,total:Jo(t.available),unit:s,plan:Mq(o.planName),free:aI(o.planName),resetDate:String(o.resetDate||""),missing:l}}function c1e(e){const t=Wh(e);let n=null;for(const g of Qke(e)){if(g.enabled===!1)continue;const v=JP(g,t);if(!v)continue;const b=g.threshold>0?v.used/g.threshold:0;if(b>=1){n={rule:g,reading:v,ratio:b};break}(!n||b>n.ratio)&&(n={rule:g,reading:v,ratio:b})}if(!n)return null;const{rule:s,reading:i}=n,o=i.used>=s.threshold,l=eSe(s),u=o?"":` · ${Eq(l.remainingMs,l.daily)}`,d=l.daily?a("今日已用"):a("周期 Token"),f=s.reset==="daily"?a("今天(本地 0 点重置)"):a("{period}窗口",{period:tSe(s.period??0)}),m=a("限制器:{window}已用 {used} / {threshold} Token",{window:f,used:Math.round(i.used).toLocaleString("en-US"),threshold:Math.round(s.threshold).toLocaleString("en-US")})+(o?a(",已达到上限"):a(",{countdown}重置",{countdown:Eq(l.remainingMs,l.daily)}));return r.jsxs("span",{className:"usage-token-sub",title:m,children:[d," ",r.jsx("span",{className:o?"hit":void 0,children:Tq(i.used)})," ","/ ",Tq(s.threshold),u]})}function u1e({account:e}){const t=po(e),n=Si(e)?zSe(e):null,s=n&&t&&typeof t=="object"?t.lastUsage:null,i=Sn().usageTasks.get(e.id),o=i?.status==="failed"&&n?"":USe(i,a),l=Tg(e.id)?.stale,u=s&&typeof s=="object"&&!Array.isArray(s)?s:t;return r.jsxs("span",{className:"usage-sum-wrap flex flex-col gap-1",children:[r.jsx(d1e,{account:e,entry:u}),n&&s?r.jsx("span",{className:"text-[11px] text-destructive whitespace-normal leading-snug",title:n.detail,children:n.text}):null,o?r.jsx("span",{className:"text-[11px] text-subtle",role:"status",children:o}):null,l?r.jsx("span",{className:"text-[11px] text-subtle",children:a("历史余额,尚未按新配置验证")}):null]})}function d1e({account:e,entry:t}){const n=Oy();if(!Si(e))return r.jsx("span",{className:"muted",title:e.isGuest===!0?a("访客账号没有积分体系,因此不查询余额(登录账号可以查)"):a("该提供商尚未接入余额查询"),children:"—"});const s=a1e(t),i=sI(e)&&!Og(t)?PNe(t,n):[],o=xN(i.flatMap(w=>w.expiry?[w.expiry]:[]),n),l=vN(o,a,Ln,gN(t)),u=l.detail?{...s,title:[s.title,l.detail].filter(Boolean).join(" · ")}:s,d=Array.isArray(e.limiterGroups)?r.jsx(jG,{account:e,onOpen:()=>Mg(e.id)}):eI(e,t)?r.jsx(Ee,{variant:"warning",shape:"tag",title:a("余额低于限制器的阈值,转发时会跳过该账号(余额回升自动恢复)"),children:a("余额不足 · 已跳过")}):tI(e,Wh(e))?r.jsx(Ee,{variant:"warning",shape:"tag",title:a("本周期 Token 消耗达到限制器的上限,转发时会跳过该账号(窗口重置自动恢复)"),children:a("Token 限额 · 已跳过")}):null,f=c1e(e),m=u.kind==="ok"||u.kind==="warn"?r1e(t):[],g=m.length?r.jsx(Ee,{variant:"warning",shape:"tag",title:s1e(m),children:a("待生效 {n} 份",{n:m.length})}):null,v=i.length?{rows:i,now:n,expiryUnit:gN(t),subscriptionLine:n1e(t),aggregate:Oke(t,a),kind:u.kind,title:u.title}:null,b=u.kind==="ok"||u.kind==="warn"?OG(t):[];if(b.length){const w=v?r.jsx(UI,{variant:"sum",...v,children:a("积分明细")}):null;return r.jsxs(zCe,{entry:t,rows:b,updatedAt:$Se(e),creditDetail:w,children:[d,g,f]})}if(iSe(e)){const S=u.kind==="ok"||u.kind==="warn"?l1e(t):null;return S?r.jsx(f1e,{summary:u,detail:S,blockedBadge:d,tokenSub:f}):r.jsxs("span",{className:"usage-sum-wrap",children:[r.jsx("span",{className:`usage-sum ${u.kind}`,title:u.title,children:u.text}),d,g,f]})}const y=u.kind==="ok"||u.kind==="warn"?o1e(t):null;if(!y)return r.jsxs("span",{className:"usage-sum-wrap",children:[v?r.jsx(UI,{variant:"sum",...v,children:u.text}):r.jsx("span",{className:`usage-sum ${u.kind}`,title:u.title,children:u.text}),d,g,f]});const k={name:y.planName||"",view:y.text,tone:u.kind==="warn"?"warn":"ok",percent:y.percent,over:!1,title:u.title};return r.jsxs("span",{className:"usage-cell",title:u.title,children:[v?r.jsxs(UI,{variant:"pool",...v,children:[r.jsx(_G,{row:k}),l.badge?r.jsx("span",{className:"usage-pool-soon",children:l.badge}):null]}):r.jsx(_G,{row:k}),d,g,f]})}function f1e({summary:e,detail:t,blockedBadge:n,tokenSub:s}){const[i,o]=p.useState(!1),l=e.kind==="ok"||e.kind==="warn";return r.jsxs("span",{className:i?"usage-cell open":"usage-cell",children:[r.jsxs("span",{className:"usage-plan",children:[t.plan?r.jsx(Ee,{variant:t.free?"secondary":"brand",shape:"tag",className:`plan-chip${t.free?" free":""}`,children:t.plan}):null,t.resetDate?r.jsx("span",{className:"plan-sub",title:a("套餐积分的重置日期"),children:a("重置 {date}",{date:t.resetDate})}):null]}),r.jsxs(ui,{open:i,onOpenChange:o,children:[r.jsxs(wi,{render:r.jsx(B,{size:"default",variant:"ghost",type:"button",className:`usage-toggle ${e.kind}`,title:e.title,"aria-label":a("积分明细")}),children:[r.jsx("span",{className:"val",children:e.text}),r.jsx("span",{className:"caret","aria-hidden":!0,children:"▾"})]}),r.jsxs(di,{align:"center",sideOffset:6,className:"usage-pop w-[288px]",children:[t.total!==null?r.jsxs("div",{className:"usage-pop-total",children:[r.jsx("span",{className:"k",children:a("总积分")}),r.jsxs("span",{className:"v",children:[Ln(t.total)," ",r.jsx("small",{children:t.unit})]})]}):null,l&&t.missing.length?t.missing.map(u=>r.jsx("div",{className:"usage-pop-missing",title:u,children:u},u)):null,t.credit.length?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"usage-pop-group",children:a("积分")}),t.credit.map(u=>r.jsx(h1e,{row:u},u.name))]}):null,!t.credit.length&&t.total===null?r.jsx(pt,{className:"usage-pop-empty",children:a("未返回可识别的余额数据")}):null]})]}),n,s]})}function h1e({row:e}){return r.jsxs("div",{className:"usage-pop-row",title:e.title,children:[r.jsxs("div",{className:"usage-pop-line",children:[r.jsx("span",{className:"usage-pop-name",children:e.name}),r.jsx("span",{className:`usage-pop-view ${e.tone}`,children:e.view})]}),e.percent!==null?r.jsx(kg,{value:e.percent,variant:e.over||e.tone==="bad"?"destructive":e.tone==="ok"?"success":e.tone==="warn"?"warning":"muted",className:"mt-1.5",trackClassName:"h-[3px]","aria-label":a("剩余 {percent}%",{percent:Math.round(e.percent)})}):null]})}function m1e({account:e,namesHidden:t}){const n=QS(e),s=Ci(e)||a("未命名账号"),i=String(e.email||"").trim(),o=String(e.nickname||"").trim(),l=String(e.name||"").trim(),u=v=>t?t8(v):v,d=[i&&i!==s?a("邮箱 {email}",{email:u(i)}):"",n?`${Vke(e)||"id"} ${n}`:"",!e.nameCustom&&l&&l!==i&&l!==o?a("备注名 {name}",{name:u(l)}):"",o&&o!==s&&o!==i?a("昵称 {name}",{name:u(o)}):"",oy(e)?a("桌面端实时登录态(凭证每次从客户端登录态文件读取)"):"",e.updatedAt?a("更新于 {time}",{time:ki(e.updatedAt)}):"",e.needsRelogin?iy(e):"",e.source?a("来源 {source}",{source:e.source==="imported"?a("旧数据导入"):a("手动添加")}):""].filter(Boolean),f=i&&i!==s,m=e.proxy?.error,g=d.length?r.jsx(pS,{delay:0,children:r.jsxs(pc,{children:[r.jsx(Ih,{render:r.jsx("div",{className:"acct-name"}),children:r.jsx("span",{className:"name",children:u(s)})}),r.jsxs(gc,{children:[r.jsx(pye,{}),d.map((v,b)=>r.jsx("div",{children:v},b))]})]})}):r.jsx("div",{className:"acct-name",children:r.jsx("span",{className:"name",children:u(s)})});return r.jsxs(r.Fragment,{children:[g,f?r.jsx("div",{className:"acct-sub",children:r.jsx("span",{className:"acct-email",title:a("账号邮箱"),children:u(i)})}):null,e.needsRelogin?r.jsx("div",{className:"acct-note bad",children:iy(e)}):null,m?r.jsx("div",{className:"acct-note bad",title:a("代理不可用:{error}",{error:m}),children:a("代理不可用:{error}",{error:m})}):null]})}function p1e({account:e}){const t=e.proxy,n=t?.config?.source||t?.source,s=t?.label||a(n==="custom"?"自定义代理":"已设置"),i=t?.error,o=h8(),l=Array.isArray(o)?o:[];let u="";n==="pool"&&t?.config?.proxyId?u=`${vc}${t.config.proxyId}`:t&&(u=dN);const d=[{value:"",label:a("直连")}];for(const g of l)d.push({value:`${vc}${g.id}`,label:Ag(g),disabled:g.enabled===!1});if(o===null?d.push({value:"__hint_pool__",label:a("正在读取代理列表…"),disabled:!0}):l.length||d.push({value:"__hint_pool__",label:WSe()?a("代理列表读取失败(重试中)"):a("还没有代理(去「网络代理」页添加)"),disabled:!0}),u===dN){const g=n==="clash"?a("Clash 出口:"):n==="custom"?a("自定义:"):"";d.push({value:dN,label:`${g}${s}${i?a("(不可用)"):""}`})}else n==="pool"&&!l.some(g=>`${vc}${g.id}`===u)&&d.push({value:u,label:`${s}${i?a("(不可用)"):""}`});d.push({value:_8,label:a("自定义代理…")});const f=i?a("代理不可用:{error}(不会自动改为直连);选「自定义代理…」去修改",{error:i}):n==="rotate"?a("当前:{label}(每条请求换一个出口);「自定义代理…」打开完整设置",{label:s}):n==="clash"?a("当前:{label}(Clash Verge 直接引用);可在「网络代理」页同步端点后改选",{label:s}):n==="custom"?a("当前:{label}(未经过代理池 —— 可在「网络代理」页添加相同地址后来这里改选)",{label:s}):a("当前:{label};选项来自「网络代理」页;「自定义代理…」打开完整设置",{label:t?s:a("直连")}),m=d.find(g=>g.value===u);return r.jsxs(Pt,{value:u,onValueChange:g=>{hNe(e.id,g,u)},children:[r.jsx(Mt,{className:Ne("w-full",i&&"border-destructive-bd"),title:f,"aria-label":a("出网代理"),children:r.jsx(It,{children:m?.label||a("直连")})}),r.jsx(_t,{children:d.map(g=>r.jsx(Ze,{value:g.value,disabled:g.disabled,children:g.label},g.value))})]})}function g1e({account:e,atFront:t}){const n=Sn().usageInflight.has(e.id),s=Sn().usageStarting.has(e.id),i=Si(e);return r.jsxs("div",{className:"acct-actions",children:[i?r.jsx(B,{variant:"outline",size:"xs",disabled:s,title:a(n?"停止旧查询,按当前配置重新查询余额":"查询该账号剩余余额(读数显示在余额列)"),onClick:()=>{oNe(e.id)},children:a(s?"启动中…":n?"重查":"余额")}):null,r.jsx(B,{variant:"outline",size:"xs",title:a("备注名 / 启用 / 代理"),onClick:()=>Mg(e.id),children:a("设置")}),r.jsx(x1e,{account:e,atFront:t})]})}function x1e({account:e,atFront:t}){const[n,s]=p.useState(!1),i=Ni(e),o=Nu(tn(e)).some(f=>f.on),l=Number(e.maxConcurrent)||0,u="w-full justify-start px-2 font-normal",d=`${u} text-destructive hover:text-destructive`;return r.jsxs(ui,{open:n,onOpenChange:s,children:[r.jsx(wi,{render:r.jsx(B,{variant:"outline",size:"xs",title:a("更多操作")}),children:"⋯"}),r.jsx(di,{align:"end",sideOffset:4,className:"w-[172px] p-1.5",children:r.jsxs("div",{className:"flex flex-col gap-0.5",children:[Sn().usageInflight.has(e.id)?r.jsx(B,{variant:"ghost",size:"sm",className:u,onClick:()=>{s(!1),l8(e.id)},children:a("取消余额查询")}):null,r.jsx(B,{variant:"ghost",size:"sm",className:d,onClick:()=>{s(!1),P8(e.id,!i)},children:a(i?"禁用":"启用")}),r.jsx(B,{variant:"ghost",size:"sm",className:u,disabled:t||o,title:a(o?"自动消耗排序已启用,请先关闭规则再手动调整":t?"已在全局队列第一位":"仅将优先级调整到全局第一位,不改变启用状态"),onClick:()=>{s(!1),ft().wbApp?.runAccountAction?.("switch",e.id)},children:a("设为首选")}),r.jsx(B,{variant:"ghost",size:"sm",className:u,title:a("在账号设置的「基本」分组里设置该账号同时最多处理的请求数"),onClick:()=>{s(!1),Mg(e.id)},children:a("并发上限:{value}",{value:l>0?l:a("不限")})}),mq(e)?r.jsx(B,{variant:"ghost",size:"sm",className:u,disabled:e.needsRelogin===!0,title:e.needsRelogin?iy(e):void 0,onClick:()=>{s(!1),ft().wbApp?.runAccountAction?.("refresh",e.id)},children:a("刷新 Token")}):null,r.jsx(B,{variant:"ghost",size:"sm",className:u,title:a("将这个账号及其登录凭证保存为单独的 JSON 文件"),onClick:()=>{s(!1),PG({id:e.id})},children:a("导出账号")}),r.jsx("div",{className:"my-1 h-px bg-hairline"}),r.jsx(B,{variant:"ghost",size:"sm",className:d,title:oy(e)?a("删除这条账号记录(不会影响客户端自己的登录态;之后可再点「导入桌面端登录态」加回来)"):void 0,onClick:()=>{s(!1),ft().wbApp?.runAccountAction?.("remove",e.id)},children:a("删除账号")})]})})]})}function v1e({namesHidden:e,allPicked:t,somePicked:n,disabled:s,onToggleAll:i}){const o=r.jsx("span",{className:"col-grip",title:a("拖动调整列宽(双击还原)")});return r.jsx(Qs,{children:r.jsxs(Jt,{children:[r.jsx(tt,{className:"cell-pick","data-col":"pick",children:r.jsx(jr,{id:"acct-select-all",checked:t,indeterminate:!t&&n,disabled:s,"aria-label":a("全选当前筛选结果"),title:a("全选 / 取消全选当前筛选结果(与批量栏同一个选择)"),onCheckedChange:l=>i(l)})}),r.jsxs(tt,{className:"cell-order","data-col":"order",children:[r.jsx("span",{className:"th-label",title:a("组内先后:按住左边的把手上下拖动即可调整;整组的先后拖分组带的把手"),children:a("顺序")}),o]}),r.jsxs(tt,{className:"cell-account","data-col":"account",children:[r.jsxs("span",{className:"th-label",children:[a("账号"),r.jsx(DG,{hidden:e})]}),o]}),r.jsxs(tt,{className:"cell-proxy","data-col":"proxy",children:[r.jsx("span",{className:"th-label",title:a("该账号出网走的代理(已保存的代理 / 自定义 / 直连);点击可修改"),children:a("代理")}),o]}),r.jsxs(tt,{className:"cell-connections","data-col":"connections",children:[r.jsx("span",{className:"th-label",title:a("此刻正在使用这个账号的请求数(含还在下发内容的流式请求);为 0 时不显示"),children:a("连接数")}),o]}),r.jsxs(tt,{className:"cell-status","data-col":"status",children:[r.jsx("span",{className:"th-label",children:a("状态")}),o]}),r.jsxs(tt,{className:"cell-limits","data-col":"limits",children:[r.jsx("span",{className:"th-label",title:a("该账号当前限流中的模型;点徽章看明细"),children:a("限流")}),o]}),r.jsxs(tt,{className:"cell-expiry","data-col":"expiry",children:[r.jsx("span",{className:"th-label",children:a("有效期")}),o]}),r.jsxs(tt,{className:"cell-usage","data-col":"usage",children:[r.jsx("span",{className:"th-label",children:a("余额")}),o]}),r.jsx(tt,{className:"cell-actions","data-col":"actions",children:r.jsx("span",{className:"th-label",children:a("操作")})})]})})}function DG({hidden:e}){const t=a(e?"显示账号名":"隐藏账号名(名字显示为星号)");return r.jsx(B,{size:"default",variant:"ghost",type:"button",className:`name-eye${e?" on":""}`,title:t,"aria-label":t,"aria-pressed":e,onClick:()=>ESe(),dangerouslySetInnerHTML:{__html:Ry(e?"eyeOff":"eye",13)}})}const LG="dragging",Py=["drop-before","drop-after"];let Sc=null;function $G(e){e.querySelectorAll(`.${Py[0]}, .${Py[1]}`).forEach(t=>{t.classList.remove(...Py)})}function b1e(e,t){if(t==="group"){const s=e.parentElement;return s?[...s.children].filter(i=>i.classList.contains("acct-group")):[]}const n=e.parentElement;return n?[...n.children].filter(s=>s.classList.contains("acct-row")):[]}function zG(e,t){for(let n=0;nn!==e.item);$G(e.container),t.length&&(e.index>=t.length?t[t.length-1].classList.add(Py[1]):t[e.index].classList.add(Py[0]))}function BG(e){if(!Sc)return;if(e.buttons===0){AN(!1);return}const t=Sc.items.filter(s=>s!==Sc.item),n=zG(t,e.clientY);n!==Sc.index&&(Sc.index=n,y1e(Sc))}function AN(e){const t=Sc;t&&(Sc=null,window.removeEventListener("pointermove",BG),window.removeEventListener("pointerup",FG),window.removeEventListener("pointercancel",UG),window.removeEventListener("keydown",HG),document.body.classList.remove("queue-dragging"),t.item.classList.remove(LG),$G(t.container),e&&(t.kind==="group"?hM?.onDrop({kind:"group",provider:t.provider,index:t.index}):hM?.onDrop({kind:"row",provider:t.provider,accountId:t.accountId,index:t.index})))}function FG(){AN(!0)}function UG(){AN(!1)}function HG(e){e.key==="Escape"&&AN(!1)}let hM=null;function j1e(e,t){hM=t,e&&e.dataset.queueDragBound!=="1"&&(e.dataset.queueDragBound="1",e.addEventListener("pointerdown",n=>{if(n.button!==0||Sc)return;const s=n.target,i=s?.closest?.(".queue-grip"),o=s?.closest?.(".order-grip");if(!i&&!o)return;if(n.preventDefault(),i&&t.isLocked()){t.onLockedAttempt();return}const l=(i??o).closest("tbody.acct-group, tr.acct-row");if(!l)return;const u=i?"group":"row",d=l.dataset.provider||l.closest("tbody.acct-group")?.dataset.provider||"";if(u==="row"&&d&&t.isRowLocked?.(d)){t.onRowLockedAttempt?.(d);return}const f=l.dataset.id||"";if(u==="row"&&!f)return;const m=b1e(l,u);if(m.length<2)return;const g=m.filter(v=>v!==l);Sc={kind:u,provider:d,accountId:f,item:l,container:l.parentElement||e,items:m,index:zG(g,n.clientY)},l.classList.add(LG),document.body.classList.add("queue-dragging"),window.addEventListener("pointermove",BG),window.addEventListener("pointerup",FG),window.addEventListener("pointercancel",UG),window.addEventListener("keydown",HG)}))}let EN=null,VG=!1,mM=0,TN=null,KG="";function qG(){return EN?EN.apply(sM):sM}function w1e(e){const t=tn(e);return zl(t,Nu(t)).length>0}function GG(){window.wbAccountsView?.render?.()}function k1e(){const e=qG(),t=`${TN?"T":"F"}|${e.map(s=>`${s.key}:${s.align}`).join("|")}`;if(t===KG)return;KG=t,ft().wbColSettings?.syncStaticHead("accounts",TN);const n=[...TN?.querySelectorAll("thead th")||[]];n.forEach((s,i)=>{const o=s.querySelector(".col-grip");o&&(o.style.display=i===n.length-1?"none":"")})}function S1e(){const e=p.useSyncExternalStore(Hh,Sn),t=p.useRef(null),[,n]=p.useReducer(U=>U+1,0),s=!!Wd(),i=Ml();p.useSyncExternalStore(ky,Bl);const o=hCe(xSe()),[l,u]=p.useState(!1),{groups:d,allGroups:f}=vSe(po,Wh),m=ySe(po,Wh),g=[{value:"all",label:a("全部({n})",{n:i.length})}].concat(Yq().map(U=>({value:U.id,label:a("{label}({count})",{label:a(U.label),count:U.count})}))),v=d.flatMap(U=>U.accounts),b=jSe(),y=qG(),k=Ay(v.length,"accounts",{defaultSize:"all"}),w=k.paged?k.slice(v):v,S=e.filter.provider!=="all"||e.filter.q.trim()!==""||e.filter.limit!=="all",N=S||k.paged,C=a(S?"清除筛选":"把每页调回「全部」");p.useEffect(()=>{XSe()}),p.useEffect(()=>GSe(()=>{eN()}),[]),p.useEffect(()=>{SSe()},[e.version]),p.useEffect(()=>{const U=z=>{(z.key===null||z.key===fI)&&OSe()};return window.addEventListener("storage",U),()=>window.removeEventListener("storage",U)},[]),p.useLayoutEffect(()=>{if(!VG){if(!ft().wbColSettings?.register){window.clearTimeout(mM),mM=window.setTimeout(()=>T(U=>U+1),50);return}VG=!0,EN=ft().wbColSettings?.register({id:"accounts",label:a("账号表"),columns:sM.map(U=>({key:U.key,label:U.label,align:U.align,legacyAlign:U.legacyAlign})),mount:()=>document.querySelector("#accounts-col-host"),onChange:GG})||null,EN&&n();return}k1e()});const[,T]=p.useState(0);p.useEffect(()=>()=>window.clearTimeout(mM),[]),p.useEffect(()=>{RCe(t.current,GG)},[]);const P=v.map(U=>U.id),O=P.length>0&&P.every(U=>e.selected.has(U)),A=P.some(U=>e.selected.has(U)),R=[...e.selected].filter(U=>!P.includes(U)).length,M=e.selected.size>0,_=f.length>0&&f.every(U=>e.collapsed.has(U.provider)),[L,$]=p.useState(!1),D=(e.filter.provider!=="all"?1:0)+(String(e.filter.q||"").trim()?1:0)+(e.filter.enabled!=="all"?1:0)+(e.filter.limit!=="all"?1:0),F=new Map;for(const U of d)F.set(U.provider,w.filter(z=>tn(z)===U.provider).map(z=>z.id));const V=p.useRef({displayed:d,all:f,renderedRows:F});p.useEffect(()=>{V.current={displayed:d,all:f,renderedRows:F}});const q=p.useRef({locked:!1,lockReason:"",onDrop:U=>{}}),Q=p.useCallback(U=>{const{displayed:z,all:K}=V.current;if(U.kind==="group"){if(q.current.locked)return;const te=K.findIndex(ge=>ge.provider===U.provider),le=z.findIndex(ge=>ge.provider===U.provider);if(te<0||le<0)return;const he=z.filter(ge=>ge.provider!==U.provider);if(!he.length||U.index<0||U.index>he.length||U.index===le)return;const ce=K[te],ye=K.filter((ge,ue)=>ue!==te),fe=he[U.index]||he[he.length-1],Le=ye.findIndex(ge=>ge.provider===fe.provider);if(Le<0)return;const pe=Le+(U.index===he.length?1:0);if(pe===te)return;const Se=[...ye.slice(0,pe),ce,...ye.slice(pe)].flatMap(ge=>ge.queueMembers.map(ue=>ue.id));I8(Se,a("{name} 移到第 {rank} 顺位",{name:ce.label,rank:pe+1}));return}const J=zl(U.provider,Nu(U.provider));if(J.length>0){Ct(wN(J),"err");return}const ee=K.find(te=>te.provider===U.provider);if(!ee)return;const H=ee.queueMembers.findIndex(te=>te.id===U.accountId);if(H<0)return;const G=ee.queueMembers[H],Y=ee.queueMembers.filter((te,le)=>le!==H),se=V.current.renderedRows.get(U.provider)||[],re=U.indexte.id===re),de=re===null||ne<0?Y.length:ne;if(de===H)return;const ie=[...Y.slice(0,de),G,...Y.slice(de)],je=K.map(te=>te.provider===U.provider?{...te,members:ie,queueMembers:ie}:te).flatMap(te=>te.queueMembers.map(le=>le.id));I8(je,a("{name} 移到 {group} 组内第 {rank} 位",{name:String(G.name||G.id),group:a(ee.label),rank:de+1}))},[]);p.useEffect(()=>{q.current={locked:N,lockReason:C,onDrop:Q}}),p.useEffect(()=>{j1e(t.current,{isLocked:()=>q.current.locked,onLockedAttempt:()=>Ct(a("当前视图不能调整组顺位:{reason} 之后再拖动",{reason:q.current.lockReason}),"err"),isRowLocked:U=>zl(U,Nu(U)).length>0,onRowLockedAttempt:U=>Ct(wN(zl(U,Nu(U))),"err"),onDrop:U=>q.current.onDrop(U)})},[]);function X(U,z,K){switch(U){case"pick":return r.jsx(jr,{checked:K.picked,"data-pick":z.id,title:a("勾选后可批量操作"),"aria-label":a("勾选后可批量操作"),onCheckedChange:J=>ASe(z.id,J)});case"order":return r.jsx(WCe,{account:z,rank:K.rank,sortActive:w1e(z)});case"account":return r.jsx(m1e,{account:z,namesHidden:e.namesHidden});case"proxy":return r.jsx(p1e,{account:z});case"connections":return r.jsx(t1e,{account:z});case"status":return r.jsx(QCe,{account:z});case"limits":return r.jsx(ZCe,{account:z,onClear:J=>{fNe(z.id,J)}});case"expiry":return r.jsx(JCe,{account:z});case"usage":return r.jsx(u1e,{account:z});case"actions":return r.jsx(g1e,{account:z,atFront:K.seat.position<=1});default:return null}}return r.jsxs(r.Fragment,{children:[r.jsxs(et,{render:r.jsx("section",{}),className:"panel account-table",children:[r.jsxs("div",{className:"toolbar",children:[r.jsxs(B,{size:"default",variant:"ghost",type:"button",className:"acct-filter-open hidden max-[767px]:inline-flex",onClick:()=>$(!0),"aria-label":a("打开筛选"),children:[a("筛选"),D>0?r.jsx(Ee,{variant:"brand",shape:"tag",className:"acct-filter-badge",children:D}):null]}),r.jsxs(DS,{open:L,onOpenChange:$,title:a("筛选"),inlineClassName:"contents",bodyClassName:"acct-filter-body",actions:r.jsx(B,{variant:"ghost",size:"sm",disabled:D===0,onClick:()=>pI(),children:a("清空")}),children:[r.jsxs("div",{className:"group","data-provider-group":"1",children:[r.jsx("span",{className:"label",children:a("提供商")}),r.jsxs(YV,{items:g,value:g.find(U=>U.value===e.filter.provider)??g[0],onValueChange:U=>{U&&kSe(U.value)},isItemEqualToValue:(U,z)=>U.value===z.value,autoHighlight:!0,children:[r.jsx(QV,{className:"max-w-none min-w-0 w-full min-[768px]:max-w-[200px] min-[768px]:min-w-[130px] min-[768px]:w-auto","aria-label":a("按提供商筛选账号"),children:r.jsx(XV,{children:g.find(U=>U.value===e.filter.provider)?.label||a("全部")})}),r.jsxs(ZV,{children:[r.jsx("div",{className:"shrink-0 border-b border-hairline p-2",children:r.jsx(JV,{placeholder:a("搜索提供商…"),"aria-label":a("搜索提供商")})}),r.jsx(nK,{children:a("没有匹配的选项")}),r.jsx(eK,{children:U=>r.jsx(tK,{value:U,children:U.label},U.value)})]})]})]}),r.jsx("div",{className:"divider","data-provider-divider":"1"}),r.jsxs("div",{className:"group",children:[r.jsx("span",{className:"label",children:a("搜索")}),r.jsx(ze,{className:"acct-search",type:"search",value:e.filter.q,placeholder:a("账号名 / 邮箱 / 备注"),"aria-label":a("搜索账号"),onChange:U=>wSe(U.currentTarget.value)})]}),r.jsx("div",{className:"divider"}),r.jsxs("div",{className:"group",children:[r.jsx("span",{className:"label",children:a("状态")}),r.jsx(en,{options:[{value:"all",label:a("全部"),count:m.enabledAll??0},{value:"enabled",label:a("启用"),count:m.enabled??0},{value:"disabled",label:a("禁用"),count:m.disabled??0}],value:e.filter.enabled,onValueChange:U=>Xq("enabled",U),"aria-label":a("启用状态")})]}),r.jsxs("div",{className:"group",children:[r.jsx("span",{className:"label",children:a("限额")}),r.jsx(en,{options:[{value:"all",label:a("全部"),count:m.limitAll??0},{value:"normal",label:a("正常"),count:m.normal??0,disabled:e.filter.enabled==="disabled"},{value:"limited",label:a("已限流"),count:m.limited??0,disabled:e.filter.enabled==="disabled"}],value:e.filter.limit,onValueChange:U=>Xq("limit",U),"aria-label":a("限额状态")})]})]}),r.jsxs("div",{className:"actions",children:[r.jsx(B,{id:"btn-refresh-accounts",variant:"outline",disabled:e.listBusy,title:a("重新读取账号列表和插件状态,不刷新 Token 或查询余额"),onClick:()=>{x8({feedback:!0})},children:e.listBusy?a("刷新中…"):a("刷新")}),r.jsx(B,{id:"btn-add-account-2",variant:"default",title:a("登录 / 导入一个新账号"),onClick:()=>{ft().wbAddAccountModal?.open?.(),ft().wbAccountAddForms?.syncAddProvider?.()},children:a("添加账号")}),r.jsx(B,{id:"btn-query-usage",variant:"outline",disabled:e.usageStarting.has("*")||!i.some(Si),title:a("查询全部账号的余额(含已禁用账号 —— 禁用只表示不参与转发)"),onClick:()=>{A8()},children:e.usageStarting.has("*")?a("启动中…"):e.usageBusy?a("重新查询"):a("查询余额")}),e.usageBusy?r.jsx(B,{variant:"outline",onClick:()=>{qSe()},children:a("取消查询")}):null]})]}),e.listError?r.jsx(Fe,{variant:"destructive",className:"acct-load-error",role:"alert",children:s?a("刷新账号列表失败,当前仍显示上一次成功读取的数据:{message}",{message:e.listError}):a("账号列表加载失败,请点击「刷新」重试:{message}",{message:e.listError})}):null,r.jsxs("div",{className:Ne("batch-bar",M&&"active"),id:"batch-bar",children:[r.jsxs(Ae,{className:"batch-select-all",children:[r.jsx(jr,{id:"batch-select-all",checked:O,indeterminate:!O&&A,disabled:!P.length,"aria-label":a("全选当前筛选结果"),onCheckedChange:U=>e8(P,U)}),r.jsx("span",{id:"batch-select-label",children:P.length?a("全选当前筛选结果({n} 个)",{n:P.length}):a("没有可全选的账号")})]}),r.jsxs("span",{className:"batch-count",children:[a("已选")," ",r.jsx("b",{id:"batch-count",children:e.selected.size})," ",a("个 · 共")," ",r.jsx("b",{id:"accounts-count",children:i.length})," ",a("个")]}),r.jsx("span",{className:"batch-summary",id:"accounts-group-summary",children:d.length?a("{groups} 家 · 显示 {rows} 行",{groups:d.length,rows:P.length}):""}),N?r.jsx("span",{className:"batch-hidden",title:C,children:a("组顺位已锁定")}):null,Qq()?r.jsx(B,{id:"btn-clear-filter",variant:"ghost",size:"xs",title:a("清空搜索与三个筛选档位,回到全部账号"),onClick:()=>pI(),children:a("清除筛选")}):null,R?r.jsx("span",{className:"batch-hidden",id:"batch-hidden-hint",children:a("另有 {n} 个已勾选账号被当前筛选隐藏,仍会参与操作",{n:R})}):null,r.jsxs("div",{className:"batch-actions",children:[r.jsx(yCe,{hidden:o,onOpen:()=>u(!0)}),r.jsx(B,{id:"btn-fold-groups",variant:"outline",disabled:!f.length,title:a(_?"展开全部分组":"折叠全部分组(只留组头)"),onClick:()=>NSe(f.map(U=>U.provider),!_),children:a(_?"展开":"折叠")}),r.jsx("span",{className:"batch-col-host",id:"accounts-col-host"}),M?r.jsx(B,{id:"btn-batch-open",variant:"default",onClick:()=>OI([...e.selected],"enable"),children:a("批量操作")}):null]})]}),r.jsx("div",{className:"acct-scroll",id:"account-list",ref:t,children:s?i.length?v.length?r.jsxs(ps,{container:!1,className:"acct-table",ref:N1e,style:{minWidth:`${TCe(y.map(U=>U.key))}px`},children:[r.jsx(C1e,{}),r.jsx(v1e,{namesHidden:e.namesHidden,allPicked:O,somePicked:A,disabled:!P.length,onToggleAll:U=>e8(P,U)}),d.map(U=>{const z=e.collapsed.has(U.provider),K=w.filter(J=>tn(J)===U.provider);return r.jsxs(Es,{className:"acct-group","data-provider":U.provider,children:[r.jsx(XCe,{group:U,collapsed:z,colSpan:y.length}),z?null:K.map(J=>{const ee=U.members.findIndex(G=>G.id===J.id)+1,H=mNe(J,b,ee>0?ee:1);return r.jsx(p.Fragment,{children:r.jsx(Jt,{className:Ne("acct-row",!Ni(J)&&"disabled",H.picked&&"selected"),"data-id":J.id,"data-provider":U.provider,"data-desktop":oy(J)?"1":void 0,children:y.map(G=>r.jsx(Ve,{className:`cell-${G.key} ta-${G.align}`,children:X(G.key,J,H)},G.key))})},J.id)})]},U.provider)})]}):r.jsxs(pt,{className:"empty",children:[a("当前筛选条件下没有账号"),Qq()?r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"link-btn",onClick:()=>pI(),children:a("清除筛选")}):null]}):o.total>0?r.jsx(wCe,{hidden:o,onOpen:()=>u(!0)}):r.jsx(pt,{className:"empty",children:a("暂无账号,请点击右上角「添加账号」")}):r.jsx(pt,{className:"empty",children:e.listError?a("账号列表加载失败,请点击「刷新」重试"):r.jsxs(r.Fragment,{children:[r.jsx(Qt,{}),a("正在加载…")]})})}),r.jsx(rf,{total:v.length,range:k.paged?{start:k.rangeStart,end:k.rangeEnd}:null,page:k.page,pageCount:k.pageCount,size:k.size,onSizeChange:k.setSize,onPageChange:k.goto})]}),r.jsx(dCe,{}),r.jsx(jCe,{hidden:o,open:l,onOpenChange:u})]})}function N1e(e){TN=e}function C1e(){const e=ECe(),t=n=>r.jsx("col",{"data-col":n,style:e[n]?{width:`${e[n]}px`}:void 0},n);return r.jsxs("colgroup",{children:[t("pick"),t("order"),t("account"),t("proxy"),t("connections"),t("status"),t("limits"),t("expiry"),t("usage"),t("actions")]})}const WG='.page[data-page="accounts"]';let pM=null;function A1e(){if(pM)return;const e=document.querySelector(WG);e&&(e.replaceChildren(),pM=zn.createRoot(e),xr.flushSync(()=>{pM.render(r.jsx(S1e,{}))}))}gNe(),dNe(),Ra("accounts",WG,A1e);function ma({label:e,action:t,hidden:n,onClick:s,children:i}){return r.jsxs("section",{className:"add-group",hidden:n,onClick:s,children:[r.jsxs("div",{className:"add-group-label",children:[r.jsx("span",{children:e}),t?r.jsx("span",{className:"label-action",children:t}):null]}),r.jsx("div",{className:"add-group-box",children:i})]})}function el({host:e,note:t,active:n=!0,children:s}){const i=r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"acct-add-foot-note",children:t}),r.jsx("div",{className:"acct-add-foot-buttons",children:s})]});return e?xr.createPortal(r.jsx("div",{className:"acct-add-foot-slot",hidden:!n,children:i}),e):r.jsx("div",{className:"acct-add-foot-inline",children:i})}const E1e={provider:"doubaowork",label:a("豆包工作"),desktop:!0,webLogin:{noteHtml:a("在豆包官方页面完成登录,窗口会自动读取完整 Cookie 并加入账号列表;不需要安装豆包工作客户端。"),button:a("打开网页登录"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待"),busyText:a("等待豆包工作登录完成…"),webHint:a("浏览器面板无法读取其它站点的 Cookie,请登录 www.doubao.com 后,使用「填写凭证」粘贴完整 Cookie。")},manualTitle:a("粘贴 Cookie"),manualNote:a("粘贴 www.doubao.com 的完整 Cookie(必须含 sessionid),也支持 Cookie JSON 数组或对象。复用豆包工作账号的额度;Cookie 失效后需重新登录,没有自动续期。"),fields:[{key:"cookie",label:"Cookie",rows:5,placeholder:"sessionid=…; sessionid_ss=…; ttwid=…"},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用账号昵称")}],desktopNote:a("读取本机已登录豆包工作客户端的 Cookie,每次请求实时读取;客户端需使用 --remote-debugging-port=9342 启动。本软件不修改、关闭或重启客户端。"),desktopHint:a("未开启客户端调试端口时,请使用网页登录或粘贴 Cookie。"),fileImport:{accept:".json,application/json",note:a("选择包含 Cookie 的 JSON 对象,或本软件导出的单账号 JSON 文件。导入后可独立使用,不需要持续运行豆包工作客户端。")}},T1e={provider:"deepseek-web",label:a("DeepSeek 网页"),desktop:!1,manualTitle:a("粘贴网页访问令牌"),manualNote:a("在 chat.deepseek.com 登录本人账号后,从浏览器开发者工具的 Application → Local Storage 复制 userToken 的 value。Cookie 可选,需补充时粘贴该站点请求里的完整 Cookie;登录态失效或要求人机验证时,请回官方网页手动登录后更新。这里不接受收费 API Key。"),fields:[{key:"accessToken",label:a("网页访问令牌"),rows:3,placeholder:a("chat.deepseek.com 的 userToken.value,不是收费 API Key")},{key:"cookie",label:a("网页 Cookie"),rows:3,optional:!0,placeholder:a("官方网页正常登录后的 Cookie;风控时请手动更新")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空自动生成")}],fileImport:{accept:".json,application/json",note:a("选择包含该提供商凭证的 JSON 文件,或本软件导出的单账号 JSON 文件。导入后凭证保存在网关,可独立使用。")}};function YG(e,t,n){return{provider:e,label:t,desktop:!1,webLogin:{desktopOnly:!0,noteHtml:a("在所选站点的 MonkeyCode 官方页面完成登录和验证码,成功后自动读取登录态并加入账号列表,无需手动复制 Cookie。"),button:a("打开网页登录"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待"),busyText:a("等待 MonkeyCode 登录完成…"),webHint:a("MonkeyCode 自动网页登录仅限桌面端;浏览器面板请登录对应官网后粘贴 session。")},manualTitle:a("粘贴 session cookie"),manualNoteHtml:a("粘贴网页登录态 cookie monkeycode_ai_session 的值(在浏览器里复制整段 Cookie 直接粘贴也行,网关会自己剥出值)。
{siteNote}
MonkeyCode 没有续期接口:session 有效期约 30 天(硬限制),过期后重新登录网页、再粘贴一次即可。",{siteNote:n}),fields:[{key:"session",label:"session",rows:3,placeholder:a("monkeycode_ai_session 的值(也可直接粘贴整段 Cookie)")},{key:"imageId",label:a("任务镜像 id"),optional:!0,placeholder:a("可选:发起对话必需,留空则由网关从该账号已有任务里自动发现,发现不到时之后手动补")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用上游返回的账号名或账号 id")}]}}const O1e=YG("monkeycode",a("MonkeyCode"),a("这里填国内站(monkeycode-ai.com)的账号:请粘贴国内站的 session。国际站(monkeycode-ai.net)是另一家 provider、另一套账号,两边的凭证不通用。")),R1e=YG("monkeycode-intl",a("MonkeyCode 国际版"),a("这里填国际站(monkeycode-ai.net)的账号:请粘贴国际站的 session。国内站(monkeycode-ai.com)是另一家 provider、另一套账号,两边的凭证不通用。")),P1e={provider:"tabbit",label:a("Tabbit 国内版"),desktop:!1,smsLogin:{noteHtml:a("用绑定的手机号登录:点「获取验证码」,收到短信后填入下方并点「登录并添加」。这是国内站官方唯一的登录方式。")},manualTitle:a("粘贴网页登录凭证"),manualNote:a("在 web.tabbit.com 登录后,从开发者工具 Application → Cookies 复制 token 与 user_id,或直接粘贴该站点请求的 Copy as cURL 整段。登录态有效期约 7 天,上游没有续期接口,过期后重新导入即可。Cookie 与 JWT 至少填一项。"),fields:[{key:"cookie",label:a("网页 Cookie"),rows:3,optional:!0,placeholder:a("token=…; user_id=…(也可粘贴 Copy as cURL 整段)")},{key:"token",label:a("登录 JWT"),rows:3,optional:!0,placeholder:a("只拿到 JWT 时填这里;Cookie 里有 token 可留空")},{key:"unlockPro",label:a("解锁 Premium"),optional:!0,placeholder:a("默认开启;填 0 关闭(发送「已设为默认浏览器」标记)")},{key:"clientVersion",label:a("客户端版本"),optional:!0,placeholder:a("留空使用 1.17.16(10117016)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空自动生成")}],fileImport:{accept:".json,.txt,text/plain,application/json",note:a("选择包含 Tabbit Cookie / JWT 的 JSON 或文本文件;也可以直接粘贴到上方表单。")}},I1e={provider:"tabbit-intl",label:a("Tabbit 国际版"),desktop:!1,manualTitle:a("粘贴网页登录凭证"),manualNote:a("在 web.tabbit.ai 登录后,从开发者工具 Application → Cookies 复制 token 与 user_id,或直接粘贴该站点请求的 Copy as cURL 整段。国际站没有可复刻的网页授权回调,手机号登录也处在上游灰度里,所以只能导入已有登录态。登录态有效期约 7 天,过期后重新导入。Cookie 与 JWT 至少填一项。"),fields:[{key:"cookie",label:a("网页 Cookie"),rows:3,optional:!0,placeholder:a("token=…; user_id=…(也可粘贴 Copy as cURL 整段)")},{key:"token",label:a("登录 JWT"),rows:3,optional:!0,placeholder:a("只拿到 JWT 时填这里;Cookie 里有 token 可留空")},{key:"unlockPro",label:a("解锁 Premium"),optional:!0,placeholder:a("默认开启;填 0 关闭(发送「已设为默认浏览器」标记)")},{key:"clientVersion",label:a("客户端版本"),optional:!0,placeholder:a("留空使用 1.17.16(10117016)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空自动生成")}],fileImport:{accept:".json,.txt,text/plain,application/json",note:a("选择包含 Tabbit Cookie / JWT 的 JSON 或文本文件;也可以直接粘贴到上方表单。")}},Fl=a("将在新标签页中打开授权页;完成后自动加入账号列表。"),gM=a("将在新标签页中打开授权页;完成后自动加入账号列表。若页面跳回本机地址后账号没有出现,按提示把地址栏里的完整回调地址粘贴回来即可。"),ON=100,M1e=256,_1e=e=>e.key==="name"?ON:M1e,Nc={accept:".json,application/json",note:a("选择包含该提供商凭证的 JSON 文件,或本软件导出的单账号 JSON 文件。导入后凭证保存在网关,可独立使用。")},D1e={provider:"raccoon",label:"小浣熊",addButton:a("添加小浣熊账号"),webLogin:{noteHtml:a("在打开的官方登录页里完成登录,成功后自动加入账号列表。"),button:a("打开网页登录"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待"),busyText:a("等待小浣熊登录完成…"),webHint:Fl},manualTitle:a("粘贴 token / refreshToken"),manualNoteHtml:a('refreshToken 可选,填了到期可自动续期;两者都能从小浣熊客户端登录态文件里取到。'),fields:[{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用凭证里的账号名")},{key:"token",label:"token",rows:3,placeholder:a("粘贴 access_token(一长串 JWT)")},{key:"refreshToken",inputKey:"refresh",label:"refreshToken",rows:2,optional:!0,placeholder:a("可选")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。客户端重新登录后点「刷新 Token」同步。"),fileImport:{accept:".json,application/json",note:a("选择小浣熊客户端的登录态文件 auth.json(Windows:C:\\Users\\<你的用户名>\\.box-agent\\config\\auth.json;macOS / Linux:~/.box-agent/config/auth.json)。导入后凭证直接落在网关、可独立转发,不再依赖本机客户端。")}},L1e={provider:"catpaw",label:"CatPaw",webLogin:{noteHtml:a("用 CatPaw 账号完成登录(美团 passport),成功后自动加入账号列表。"),button:a("打开 CatPaw 网页登录"),busyText:a("等待 CatPaw 登录完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录的美团账号);完成后自动加入列表")}]},manualNote:a("token 是登录态 Cookie;CatPaw 没有刷新机制,过期后需在客户端重新登录。"),fields:[{key:"token",label:"token",rows:3,placeholder:a("CatPaw 的 X-Passport-Token(登录态 Cookie)")},{key:"uid",label:"uid",placeholder:a("必填,CatPaw 账号标识")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用登录名或 uid")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。客户端重新登录后重新导入即可。"),desktopHint:a("读取 ~/.meituan-catpaw/auth.json,需已在 CatPaw 客户端登录"),fileImport:{accept:".json,application/json",note:a("选择 CatPaw 客户端的登录态文件 auth.json(Windows:C:\\Users\\<你的用户名>\\.meituan-catpaw\\auth.json;macOS / Linux:~/.meituan-catpaw/auth.json)。导入后凭证直接落在网关、可独立转发,不再依赖本机客户端。")}},$1e={provider:"autoclaw",label:a("AutoClaw 国内版"),fileImport:Nc,manualNote:a("token 支持 enc: 前缀(Windows 上自动解密)。未填 refreshToken 无法自动续期。"),smsLogin:{noteHtml:a("用绑定的手机号登录:点「获取验证码」后填入即可。这是国内版官方唯一的登录方式。")},fields:[{key:"token",label:"token",rows:3,placeholder:a("明文 JWT 或 auth.json 里的 enc: 加密值(自动解密)")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("没有则无法自动续期")},{key:"deviceId",label:"deviceId",optional:!0,placeholder:a("可选,续期时带上")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用 userId")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。"),desktopHint:a("读取 %APPDATA%/AutoClaw/auth.json 并解密,仅 Windows"),desktopWindowsOnly:!0},z1e={provider:"autoclaw-intl",label:a("AutoClaw 国际版"),fileImport:Nc,manualNote:a("国际版与国内版账号体系独立,请填国际版的凭证。未填 refreshToken 无法自动续期。"),oauthLogin:{title:a("网页登录(Zai / Google)"),noteHtml:a("点按钮后先过一次滑块验证(官方风控),随后打开登录页,登录完成即自动添加账号。
这是国际版官方唯一的登录方式;已在客户端登录过的,用「导入桌面端登录态」更快。"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口打开;关窗即取消等待(Google 账号被拒时改用系统浏览器)")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录的 Zai / Google 账号);完成后自动加入列表")}],webHint:Fl},fields:[{key:"token",label:"token",rows:3,placeholder:a("明文 JWT(国际版账号的 access token)")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("没有则无法自动续期")},{key:"deviceId",label:"deviceId",optional:!0,placeholder:a("可选,续期时带上")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用 userId")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。用 Zai / Google 登录客户端的用户走这一条。"),desktopHint:a("读取 %APPDATA%/AutoClaw/auth.json 并解密,仅 Windows"),desktopWindowsOnly:!0};function XG(e){const{provider:t,label:n,siteNote:s}=e;return{provider:t,label:n,desktop:!1,webLogin:{noteHtml:a("打开官方授权页完成设备码授权,登录的是{label}({site})的账号。",{label:n,site:s}),button:a("打开 Qoder 网页登录"),busyText:a("等待 Qoder 授权完成…"),edition:t==="qoder"?"cn":"global",modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口用全新环境,多账号互不影响;关窗即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录账号);完成后自动加入列表")}]},manualTitle:a("使用个人访问令牌(PAT)"),manualNote:a("在{label}的 Qoder 账号设置 → Integrations 生成 PAT(别填 Google / GitHub 的令牌)。两个地区的账号与凭证不通用。",{label:n}),fields:[{key:"pat",label:"Qoder PAT",rows:3,placeholder:a("粘贴 Qoder 个人访问令牌(pt-…)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空使用账号昵称或邮箱")}]}}const B1e=XG({provider:"qoder",label:a("中国版"),siteNote:"qoder.com.cn"}),F1e=XG({provider:"qoder-intl",label:a("国际版"),siteNote:"qoder.com"});function QG(e){const{provider:t,label:n,siteNote:s,loginable:i}=e;return{provider:t,label:n,desktop:!1,webLogin:{noteHtml:i?a("在打开的页面里登录千问办公{label}({site})的账号,登录完成后会自动加入列表。两版的账号与凭证不通用。",{label:n,site:s}):a("千问办公{label}暂时无法登录:上游只接受它自己的官方回调地址,不论证码到本机。",{label:n}),button:a(i?"打开千问办公网页登录":"暂时无法登录"),busyText:a("等待千问办公登录完成…"),edition:t==="qwenwork"?"cn":"global",modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口用全新环境,多账号互不影响;关窗即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录账号);完成后自动加入列表")}]},fields:[{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空使用账号名或邮箱")}]}}const U1e=QG({provider:"qwenwork",label:a("国内版"),siteNote:"qwenwork.cn",loginable:!0}),H1e=QG({provider:"qwenwork-intl",label:a("国际版"),siteNote:"qwenwork.ai",loginable:!1});function ZG(e){const{provider:t,label:n,poolNote:s}=e;return{provider:t,label:n,desktop:!0,webLogin:{noteHtml:a("打开授权页完成确认,账号自动加入 {label}{note}",{label:n,note:s}),button:a("打开 Cline 授权页"),busyText:a("等待 Cline 授权确认…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录的 Cline 账号);完成后自动加入列表")}]},manualTitle:a("填写凭证"),manualNote:a("refreshToken 可选,填了可自动续期;两者都能从客户端登录态文件取到。同一个 Cline 账号两个池都能用,这里归入 {label}。",{label:n}),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("粘贴 workos:… 开头的令牌(不带前缀也会自动补上)")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("可选,没有则无法自动续期")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空使用账号姓名、邮箱或令牌指纹")}],desktopNote:a("读本机客户端当前登录态,每次实时读取(删掉这条记录不影响客户端登录态)。这一条归入 {label}。",{label:n}),desktopHint:a("读取 ~/.cline/data/settings/providers.json,需已在 Cline 客户端登录"),fileImport:{accept:".json,application/json",note:a("选择 Cline 客户端的登录态文件 providers.json(Windows:C:\\Users\\<你的用户名>\\.cline\\data\\settings\\providers.json;macOS / Linux:~/.cline/data/settings/providers.json)。导入后凭证直接落在网关、可独立转发,不再依赖本机客户端;这一条归入 {label}。",{label:n})}}}function JG(e){const{provider:t,label:n,site:s,siteNote:i}=e;return{provider:t,label:n,webLogin:{noteHtml:a("打开 Accio {label}的官方登录页({site})并用你的 Accio 账号登录:登录成功后官方页面会跳回本机;同机自动完成,Docker / 远程面板按提示粘贴回调地址即可(授权码只在本机传给网关,界面不显示明文 token)。",{label:n,site:s}),button:a("打开 Accio {label}登录页",{label:n}),busyText:a("等待 Accio {label}登录完成…",{label:n}),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;登录完成后自动加入账号列表。关掉窗口即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开登录页(会复用浏览器里已登录的 Accio 账号);完成登录后自动加入账号列表,关掉弹窗即取消等待")}],webHint:gM},manualTitle:a("填写凭证"),manualNoteHtml:a("accessToken 是 Accio 的登录凭证(一长串不透明 token,不是 JWT);refreshToken 可选,填了之后到期能自动续期。请填写 {label}账号的凭证 —— {siteNote}(最容易拿到的办法:直接用上方的「网页登录」,不需要手工找 token。)",{label:n,siteNote:i}),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("粘贴 Accio 的 accessToken")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("可选,没有则无法自动续期")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空使用账号昵称或邮箱")}]}}function e7(e){const{provider:t,label:n,site:s,planNote:i}=e;return{provider:t,label:n,fileImport:Nc,desktop:!1,webLogin:{noteHtml:a("打开 ZCode {label}的官方授权页并用你的账号登录。授权结果由 ZCode 服务端记录,网关在后台自动取回凭证并加入账号列表。",{label:n}),button:a("打开 ZCode {label}授权页",{label:n}),busyText:a("等待 ZCode {label}授权完成…",{label:n}),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;授权完成后自动加入账号列表。关掉窗口即取消等待。授权页最后可能提示无法打开 zcode:// 链接,这是正常的 —— 结果已由服务端记下")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开授权页(会复用浏览器里已登录的 ZCode 账号);授权完成后自动加入账号列表。页面最后可能提示无法打开 zcode:// 链接,属正常现象")}]},manualTitle:a("填写凭证"),manualNoteHtml:a("本家有两个**互不替代**的凭证,按你要用的功能填,至少填一个:编码套餐 API Key 用于转发推理(打 {site})与查询窗口限额(每 N 小时 / 每周的剩余比例);jwt 用于领取套餐与查询余额(打 zcode.z.ai 的 billing 网关,官方叫 Coding Plan JWT,是一串三段点分的字符串)。余额两把都能查、但读到的东西不同:jwt 读到余额桶与套餐到期,API Key 读到窗口限额;而领取只认 jwt、转发只认 API Key。请填写 {label}账号的凭证 —— {plan}(最容易拿到的办法:直接用上方的「网页登录」—— 它会替你把这个 API Key 换好,两个凭证一起拿到。)",{site:s,label:n,plan:i}),fields:[{key:"accessToken",label:a("编码套餐 API Key"),rows:3,optional:!0,placeholder:a("用于转发;形如 apiKey.secret 两段点分(不填则这个账号不能转发)")},{key:"jwt",label:"Coding Plan JWT",inputKey:"jwt",rows:3,optional:!0,placeholder:a("用于领取套餐与查询余额;不填则这个账号不能领取与查余额")},{key:"userId",label:a("用户 ID"),optional:!0,placeholder:a("可选;用于生成账号 id 与展示名")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空自动生成")}]}}const V1e={provider:"codearts",label:"CodeArts",desktop:!1,webLogin:{noteHtml:a("打开华为云 CodeArts 的官方授权页登录:登录完成后官方页面会把浏览器带回网关自己的 /oauth/callback,网关用一次性授权码换取临时凭据并加入账号列表。
网关跑在另一台机器上时,网页端会提示把地址栏中的最终回调地址直接粘贴回面板。"),button:a("打开 CodeArts 授权页"),busyText:a("等待 CodeArts 登录完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;登录完成后自动加入账号列表。关掉窗口即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开授权页(会复用浏览器里已登录的华为云账号);浏览器与网关不在同一台机器时,按上方说明把最终回调地址粘贴回面板")}],webHint:gM},manualTitle:a("粘贴登录凭据"),manualNoteHtml:a('整份粘贴官方插件 / CLIProxyAPI 落盘的凭据 JSON(形如 {"codearts_provider_credential":{…}},铺平的也行)。
必填:access_key_id、secret_access_key、security_token。要能自动续期,必须连 refresh_token 与 oauth_context 一起粘 —— 临时凭据约一小时到期,缺这半块就续不回来,只能重新登录。'),fields:[{key:"credentialJson",label:a("凭据 JSON"),rows:8,jsonExpand:!0,placeholder:'{"codearts_provider_credential":{"access_key_id":"HSTA…","secret_access_key":"…","security_token":"…","expires_at":"2026-09-27T16:17:00.327Z","domain_id":"…","user_id":"…","user_name":"…","refresh_token":"eyJ…","oauth_context":{…}}}'},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空使用凭据里的 user_name")}]},K1e={provider:"trae",label:"Trae",desktop:!1,webLogin:{noteHtml:a("打开 Trae 的官方授权页(trae.cn)并用你的 Trae 账号登录:授权完成后官方页面会跳回本机的一个临时端口;同机部署自动接收,Docker / 远程面板请按提示复制地址栏回调地址。"),button:a("打开 Trae 授权页"),busyText:a("等待 Trae 授权完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;授权完成后自动加入账号列表。远程面板可粘贴回调地址。关掉窗口即取消等待。链接 5 分钟内有效,超时或未点就会作废(可重新发起)")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开授权页(会复用浏览器里已登录的 Trae 账号);同机完成后自动加入,Docker / 远程面板按提示粘贴地址栏回调地址。")}],webHint:gM},manualTitle:a("填写凭证"),manualNoteHtml:a("accessToken 是 Trae 的 Cloud-IDE-JWT(三段点分),refreshToken 用于到期自动续期(本家 refreshToken 一次一换:换发一次旧的即作废,所以两份程序别同时刷同一个账号)。
手工粘贴时请连 machineId / deviceId 一起填:上游把它们与登录时上传的设备公钥绑在一起判设备,凭空换一对会撞 2xxxx 那族设备绑定拒绝。
没有这三样时的正路是用上方的「网页登录」;容器 / 远程部署形态按提示粘贴地址栏回调地址即可。"),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("Cloud-IDE-JWT(三段点分)")},{key:"refreshToken",label:"refreshToken",rows:2,optional:!0,placeholder:a("可选;填了才能到期自动续期")},{key:"uid",label:a("用户 ID"),optional:!0,placeholder:a("可选;用于去重与展示名(留空时网关会问一次上游)")},{key:"machineId",label:"machineId",optional:!0,placeholder:a("可选;UUID 形态,与凭据同生共死")},{key:"deviceId",label:"deviceId",optional:!0,placeholder:a("可选;纯数字串(上游只收 8–24 位数字)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空自动用昵称")}]},q1e={provider:"loomy",label:"Loomy",fileImport:Nc,smsLogin:{noteHtml:a("用 Loomy 账号绑定的手机号登录:点「获取验证码」后填入即可。这是本家最省事的入口。")},manualNote:a("粘贴的是登录 session(同时是模型网关的 token)。Loomy 没有续期接口,session 有效期约 14 天,过期后重新登录即可。"),fields:[{key:"session",label:"session",rows:3,placeholder:a("登录 session(一长串)")},{key:"userId",label:"userId",optional:!0,placeholder:a("可选,讯飞侧 userid")},{key:"phone",label:a("手机号"),optional:!0,placeholder:a("可选,展示用")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用脱敏手机号或 userId")}],desktop:!1},G1e={provider:"kuku",label:"KukuAI",webLogin:{noteHtml:a("在打开的登录页里用百度账号登录 KukuAI 主站(手机验证码 / 扫码均可),登录成功后自动加入账号列表。网关会向百度换发 KukuAI 业务会话令牌(依赖本机已安装库库AI 客户端)。"),button:a("打开网页登录"),busyText:a("等待 KukuAI 登录完成…"),webHint:Fl},manualTitle:a("粘贴 Cookie"),manualNote:a("BDUSS 必填;请粘贴**完整 Cookie**(Cookie 编辑器一键导出即可)—— 其中 **PTOKEN 必须保留**,网关要用它向百度换发 KukuAI 业务会话令牌,缺了它模型刷新会报「未登录」。支持整段 Cookie 头、Cookie 编辑器导出的 JSON 数组,或 {BDUSS, STOKEN} 对象。KukuAI 没有刷新机制,登录态过期后重新粘贴即可。"),fields:[{key:"cookie",label:"Cookie",rows:3,placeholder:a("BDUSS=…; STOKEN=…(或 Cookie 编辑器导出的 JSON)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用账号 uk")}],desktop:!0,desktopHint:a("读取本机 KukuAI 客户端登录态(%APPDATA%\\baidugenflowpro\\Network\\Cookies),需已在 KukuAI 客户端登录"),desktopNote:a("读本机客户端当前登录态(明文 Cookie,无需解密)。客户端运行时 Cookies 文件被独占占用,导入前请先关闭 KukuAI 客户端。"),fileImport:{binary:!0,accept:"",note:a("选择 KukuAI 客户端的 Cookies 文件(%APPDATA%\\baidugenflowpro\\Network\\Cookies):它是**二进制** SQLite 数据库(无扩展名,不是 JSON)。导入时读的是你选中文件的副本、不和运行中的客户端抢占用,因此**无需先关闭客户端**。导入后凭证直接落在网关、可独立转发。")}},W1e={provider:"commandcode",label:a("Command Code"),fileImport:Nc,desktop:!1,manualTitle:a("粘贴 API Key"),manualNote:a("粘贴 Command Code 的 API Key(user_ 开头;从官方 CLI 的 ~/.commandcode/auth.json 或网页 studio 获取)。整行 / 带引号 / 带 Bearer 前缀地粘都行,网关会自己剥成裸 key。key 不过期、也没有续期接口,失效后重新获取即可;添加时网关会做一次轻量探活,失败不影响添加。"),fields:[{key:"apiKey",label:"apiKey",rows:3,placeholder:a("user_ 开头的 API Key(也可直接粘贴 Authorization: Bearer … 整行)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用 key 尾号")}]},Y1e={provider:"antigravity",label:a("Antigravity"),desktop:!1,webLogin:{noteHtml:a("在打开的登录页里登录 Google 账号(Antigravity 的授权页),授权完成后自动加入账号列表。"),button:a("打开 Antigravity 网页登录"),busyText:a("等待 Google 授权完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("系统浏览器打开(复用已登录的 Google 账号);完成后自动加入列表")}]},manualTitle:a("粘贴 Google refresh token"),manualNoteHtml:a("粘贴 Antigravity 的 Google refresh token(以 1// 开头;直接粘贴含 refresh_token= 的整行也行)。
这是网页登录之外的手工入口(例如从已登录的官方 IDE 里导出)。refresh token 不会过期,access token 到期由网关自动续期;令牌丢了只能重新走 Google 授权,请妥善保存。"),fields:[{key:"refreshToken",label:"refreshToken",rows:2,placeholder:a("1// 开头的 Google refresh token(也可直接粘贴 refresh_token=… 整行)")},{key:"projectId",label:"projectId",optional:!0,placeholder:a("可选(cloudaicompanionProject):留空由网关自动发现")},{key:"email",label:"email",optional:!0,placeholder:a("可选:账号邮箱,用于展示与身份识别(换新令牌也能认回同一账号)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用邮箱或令牌尾号")}]},X1e={provider:"officeace",label:a("OfficeAce 果办"),fileImport:Nc,desktop:!1,webLogin:{noteHtml:a("打开华为云授权页登录:登录完成后网关会自动轮询云端取回授权码并加入账号列表(不需要装 OfficeAce 桌面端,也无需手工回填回调地址)。"),button:a("打开授权页"),busyText:a("等待 OfficeAce 登录完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;登录完成后自动加入账号列表。关掉窗口即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开授权页(会复用浏览器里已登录的华为云账号);授权码由网关轮询云端取回,与浏览器跑在哪台机器无关,完成后自动加入账号列表")}],webHint:Fl},manualTitle:a("粘贴网关凭据"),manualNoteHtml:a("从别的机器(或 OfficeAce 桌面端 models.json)取三项贴进来:模型网关基址(baseUrl,形如 https://modelgw-…/v2)与 modelAppKey / modelAppSecret。这三项就能转发(网关凭据不过期);控制面临时凭据(accessKeyId 等)可选,留空则额度/自动续期不可用,但不影响转发。"),fields:[{key:"baseUrl",label:a("模型网关基址"),placeholder:"https://modelgw-…huaweicloud-agentarts.com/v2"},{key:"modelAppKey",label:a("网关 Key"),placeholder:"model_app_key"},{key:"modelAppSecret",label:a("网关 Secret"),placeholder:"model_app_secret"},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空用「OfficeAce 果办」")}]},Q1e={provider:"orcaterm",label:"OrcaTerm",fileImport:{...Nc,accept:".json,.bin,application/json"},webLogin:{noteHtml:a("在打开的官方授权页里用微信扫码登录(页面会直接显示二维码)。扫码成功后自动加入账号列表。"),button:a("打开网页登录"),hint:a("内嵌窗口打开;扫码完成后自动加入列表,关窗即取消等待"),busyText:a("等待 OrcaTerm 登录完成…"),webHint:Fl},desktop:!0,desktopHint:a("读取本机 OrcaTerm 客户端登录态(%APPDATA%\\com.orcaterm-desktop.app\\data.bin),需已在 OrcaTerm 客户端登录"),desktopNote:a("读本机客户端当前登录的 OAuth 令牌(明文 JSON,无需解密)。导入后由网关自动续期,无需跟随客户端的 2 小时时效手动换令牌。"),manualTitle:a("粘贴 accessToken"),manualNoteHtml:a("粘贴 OrcaTerm 的 OAuth accessToken(JWT,三段点分;从桌面客户端 data.bin 或 Web 版 Cookie ot_session 获取)。直接粘贴含 Bearer / ot_session= 的整行也行,网关会自己剥成裸 token。添加后由网关自动续期(上游有续期接口),无需跟随 2 小时时效手动更换。"),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("JWT(三段点分;也可直接粘贴 Bearer 整行或 data.bin 内容)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用账号昵称或 userId")}]},Z1e={provider:"chatglm",label:"智谱清言",fileImport:Nc,guestLogin:{noteHtml:a("不需要登录:点下面的按钮,网关会直接在智谱清言换发一份访客凭证并加入账号列表(也可以先填个备注名)。访客凭证可以直接用来对话,免费额度由上游按设备发放。

注意:访客账号没有积分体系 —— 它与「会员积分」「每日登录积分」「活动领取」相关的接口一律需要登录,因此那些能力对访客会如实跳过(账号页的积分、签到中心都不显示读数)。想要积分就用「填写凭证」粘一个已登录账号的令牌,或「导入桌面端登录态」。"),button:a("添加访客账号"),busyText:a("正在换发访客凭证…"),namePlaceholder:a("可选,给这个访客账号起个备注名")},desktop:!0,desktopWindowsOnly:!0,desktopHint:a("读取本机智谱清言客户端登录态(%APPDATA%\\chatglm\\Network\\Cookies),需已在客户端登录"),desktopNote:a("读本机客户端当前的登录态。客户端的 Cookies 是 DPAPI 加密的(Chromium os_crypt),因此仅 Windows 可用;客户端正在运行时可能读不到该文件,先退出客户端再试即可(也可改用「填写凭证」粘贴令牌)。"),manualTitle:a("粘贴访问令牌"),manualNoteHtml:a("粘贴智谱清言的访问令牌(JWT,三段点分)。获取方式:浏览器打开 chatglm.cn 并登录后,在开发者工具的 Application → Cookies 里复制 chatglm_token 的值(也可以直接粘 chatglm_token=…; 整行)。粘贴后会先向上游校验一次,校验通过才落账号;登录账号的积分、签到能力都能用,之后由网关自动续期(上游有续期接口)。"),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("JWT(三段点分;也可直接粘贴 chatglm_token=… 整行)")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用账号昵称")}]};function t7(e){const{provider:t,label:n,site:s,siteNote:i}=e;return{provider:t,label:n,fileImport:Nc,desktop:!1,manualTitle:a("粘贴 API 令牌"),manualNoteHtml:a("粘贴 ModelScope 的 API 令牌(ms- 开头,在 {site} 的「访问令牌」页获取)。
{siteNote}
这枚令牌两用:网关既用它调推理,也用它读账号身份、魔粒余额与每日签到。令牌长期有效、没有续期接口,失效后重新获取再粘一次即可。",{site:s,siteNote:i}),fields:[{key:"accessToken",label:"accessToken",rows:3,placeholder:a("ms- 开头的 API 令牌")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空则用上游账号昵称")}]}}const J1e=t7({provider:"modelscope",label:a("ModelScope 国内版"),site:"modelscope.cn",siteNote:a("这里填国内站(modelscope.cn)的账号:请粘贴国内站的令牌。国际站(modelscope.ai)是另一家 provider、另一套账号,两边的令牌不通用。")}),eAe=t7({provider:"modelscope-intl",label:a("ModelScope 国际版"),site:"modelscope.ai",siteNote:a("这里填国际站(modelscope.ai)的账号:请粘贴国际站的令牌。国内站(modelscope.cn)是另一家 provider、另一套账号,两边的令牌不通用。")}),tAe={provider:"atomcode",label:a("AtomCode"),fileImport:Nc,desktop:!1,webLogin:{noteHtml:a("打开 AtomGit 授权页登录:登录完成后网关会自动轮询代理取回令牌并加入账号列表(授权回调由代理终结,不回到本机,因此无需手工回填回调地址)。"),button:a("打开授权页"),busyText:a("等待 AtomCode 登录完成…")},manualTitle:a("粘贴令牌对"),manualNoteHtml:a("在 AtomGit 的 AtomCode 页面登出后取得两项贴进来:accessToken 与 refreshToken。续期令牌建议填写——本家令牌不是 JWT(约 7 天到期,读不到过期时间),没有它账号无法自动续期,到期只能重新登录。"),fields:[{key:"accessToken",label:a("访问令牌"),placeholder:"access_token"},{key:"refreshToken",label:a("续期令牌"),optional:!0,placeholder:"refresh_token"},{key:"userId",label:a("用户 ID"),optional:!0,placeholder:a("可选,用于生成账号标识")},{key:"name",label:a("备注名"),optional:!0,placeholder:a("可选,留空用「AtomCode」")}]},nAe={provider:"lobsterai",label:a("LobsterAI"),desktop:!1,webLogin:{noteHtml:a("打开 LobsterAI(有道龙虾)的官方登录页(lobsterai.youdao.com)并用你的 LobsterAI 账号登录:登录成功后官方页面会跳回本机并自动加入账号列表 —— 回调落在网关自己的端口上,所以浏览器要与网关在同一台机器上;授权码只在本机传给网关,界面不显示明文 token。"),button:a("打开 LobsterAI 登录页"),busyText:a("等待 LobsterAI 登录完成…"),modes:[{value:"embedded",label:a("内嵌窗口(推荐)"),hint:a("将打开内嵌窗口;登录完成后自动加入账号列表。关掉窗口即取消等待")},{value:"external",label:a("系统浏览器"),hint:a("将用系统默认浏览器打开登录页(会复用浏览器里已登录的 LobsterAI 账号);完成登录后自动加入账号列表,关掉弹窗即取消等待")}],webHint:Fl},fields:[]},n7=[D1e,L1e,$1e,z1e,B1e,F1e,U1e,H1e,ZG({provider:"cline-free",label:"Cline Free",poolNote:a("(免费额度池,模型名带 cline-free/ 前缀)。")}),ZG({provider:"cline-pass",label:"Cline Pass",poolNote:a("(订阅池,模型名带 cline-pass/ 前缀,需要账号有对应订阅)。")}),JG({provider:"accio",label:a("国际版"),site:"www.accio.com",siteNote:a("国际版与国内版是**两套独立的账号**(同一账号体系的两个站点),凭证不通用。")}),JG({provider:"accio-cn",label:a("国内版"),site:"www.accio-ai.com",siteNote:a("国内版的登录站点是 www.accio-ai.com,与国际版不是同一站。")}),e7({provider:"zcode",label:a("国内版"),site:"open.bigmodel.cn",planNote:a("国内版与**国际版是两套独立的账号与套餐**,凭证与领取的套餐都不通用。")}),e7({provider:"zcode-intl",label:a("国际版"),site:"api.z.ai",planNote:a("国际版的推理站点是 api.z.ai,与国内版不是同一站;套餐也各自独立。")}),V1e,K1e,q1e,G1e,O1e,R1e,W1e,Y1e,X1e,Q1e,Z1e,J1e,eAe,tAe,nAe,E1e,T1e,P1e,I1e],RN="workbuddy",Gg="custom",r7="WorkBuddy";function s7(e){return n7.find(t=>t.provider===e)}const a7=[{id:"guest",label:a("访客模式(免登录)")},{id:"oauth",label:a("网页登录(Zai / Google)")},{id:"sms",label:a("手机验证码登录")},{id:"web",label:a("网页登录")},{id:"manual",label:a("填写凭证")},{id:"file",label:a("导入凭证文件")},{id:"desktop",label:a("导入桌面端登录态")}],Wg=()=>Wt().workbuddyDesktop?.platform||"";function i7(e){if(e.desktop===!1)return!1;const t=Wg();return!(t==="web"||e.desktopWindowsOnly&&t!=="windows")}function o7(e,t){return a7.filter(n=>n.id==="guest"?!!e.guestLogin:n.id==="oauth"?!!e.oauthLogin:n.id==="sms"?!!e.smsLogin:n.id==="web"?!!e.webLogin&&(!e.webLogin?.region||t===e.webLogin.region):n.id==="file"?!!e.fileImport:n.id==="desktop"?i7(e):!0).map(n=>n.id)}const rAe=e=>e.manualTitle||a("填写凭证添加"),sAe=e=>e.manualNoteHtml?{html:e.manualNoteHtml}:{text:e.manualNote||""},aAe=e=>e.addButton||a("添加 {name} 账号",{name:e.label}),PN=(e,t)=>`${e.provider}-${t.inputKey||t.key}-input`;function iAe({providers:e,onCreate:t,onExisting:n,onClose:s}){return r.jsx(at,{open:!0,onOpenChange:i=>{i||s()},children:r.jsxs(it,{overlayForceRender:!0,className:"w-[min(560px,calc(100vw-48px))]",children:[r.jsx(ot,{children:r.jsx(st,{children:a("该地址已有提供商")})}),r.jsxs(lt,{children:[r.jsx("p",{className:"mb-3 text-sm text-subtle",children:a("相同协议和地址的提供商已经存在。可以继续新建独立提供商,或明确选择已有提供商添加账号。")}),r.jsx("div",{className:"space-y-2",children:e.map(i=>r.jsxs(Dh,{variant:"outline",children:[r.jsxs(kK,{children:[r.jsx(SK,{children:i.name||i.id}),r.jsx(NK,{children:i.baseUrl})]}),r.jsx(B,{variant:"outline",onClick:()=>n(i),children:a("添加到此提供商")})]},i.id))})]}),r.jsxs(xt,{children:[r.jsx(B,{variant:"outline",onClick:s,children:a("取消")}),r.jsx(B,{onClick:t,children:a("继续新建独立提供商")})]})]})})}function l7(e){const t=e?.presetKey||"";return t&&Wt().wbPresetProviders?.presetOf?.(t)||null}function c7(e){const t=e?.presetKey||"";return t&&Wt().wbPresetProviders?.iconOf?.(t)||""}function oAe(e){const t=(Wt().wbProviders?.customList?.()||[]).find(n=>n.id===e);return c7(t)}function lAe(e){if(!e)return"";try{const t=new URL(e);return t.host+t.pathname.replace(/\/+$/,"")}catch{return e}}function u7(e,t,n){if(e.protocol!==t)return!1;const s=i=>new URL(i.trim()).href.replace(/\/+$/,"");try{return s(e.baseUrl||"")===s(n)}catch{return!1}}const d7=p.createContext(null);function cAe({children:e}){const[t,n]=p.useState(()=>Lg(void 0)),[s,i]=p.useState(!1),o=p.useRef(t),l=p.useRef(!1),u=p.useCallback(m=>{o.current=m,l.current=!0,n(m)},[]),d=p.useCallback(()=>yc(o.current),[]),f=p.useCallback(()=>l.current?{proxy:d()}:{},[d]);return r.jsx(d7.Provider,{value:{draft:t,change:u,read:d,importFields:f,busy:s,setBusy:i},children:e})}function vo(){const e=p.useContext(d7);if(!e)throw new Error("Account proxy context is unavailable");return e}function sm(){const{busy:e,setBusy:t}=vo();return[e,t]}function f7({draft:e,onChange:t,idPrefix:n,disabled:s=!1,onSystemImportBusy:i}){return r.jsxs(ma,{label:a("账号 / 登录出网代理"),children:[r.jsx("div",{inert:s,children:r.jsx(pN,{draft:e,onChange:t,idPrefix:n,allowSystemImport:!0,onSystemImportBusy:i})}),r.jsx("p",{className:"detail",children:a("所选代理会保存到账号设置,后续请求继续使用。")})]})}function h7({idPrefix:e}){const t=vo();return r.jsx(f7,{draft:t.draft,onChange:t.change,idPrefix:e,disabled:t.busy,onSystemImportBusy:t.setBusy})}const uAe=64,dAe=100,fAe=a("OpenAI 兼容填到 /v1;Anthropic 填根地址"),hAe=a("Anthropic 协议填根地址,不要带 /v1"),mAe="https://open.bigmodel.cn/api/paas/v4",pAe="https://api.anthropic.com",gAe=[{value:"chat_completions",label:"OpenAI - Chat Completions"},{value:"responses",label:"OpenAI - Responses"},{value:"anthropic",label:"Anthropic - Messages"}],Yg="custom-protocol-select",Xg="custom-name-input",Qg="custom-baseurl-input",Iy="custom-apikey-input",My="custom-noauth-check",_y="custom-existing-apikey-input",Dy="custom-existing-noauth-check",Ly="custom-existing-name-input",am="custom-user-agent-input",im="custom-existing-user-agent-input",IN={[am]:"",[im]:""};function MN(e,t){IN[e]=t,ef(e,t)}function m7(e){return(IN[e]||"").trim()}const xAe="custom-create-button",vAe="custom-existing-button",bAe="custom-existing-remove";let xM=!1;const p7=()=>Wt().wbProviders?.PROTOCOL_OPTIONS||gAe,Zg=()=>Wt().wbProviders?.customList?.()||[],vM="custom-balance",bM="custom-existing-balance",$y=(e,t)=>`${e}-${t}-input`;function g7(e){if(!e)return"";const t=Wt().wbPresetProviders?.presetOf?.(e);return String(t?.balance?.scheme||"")}function x7(e,t){const n=by(e);if(!n||!n.fields.length)return null;const s={};for(const i of n.fields){const o=Zo($y(t,i.key));o&&(s[i.key]=o)}return Object.keys(s).length?s:null}function v7(e,t){const n=by(e);if(n)for(const s of n.fields)ef($y(t,s.key),"")}function b7({scheme:e,prefix:t}){const n=by(e);return n?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{children:a("余额查询")}),r.jsxs("div",{className:"col-start-2 row-start-1 flex h-[30px] items-center",children:[r.jsx("span",{className:"text-xs text-subtle",children:a("方案:{label}",{label:n.label})}),r.jsx("span",{className:"ml-1.5 text-xs text-subtle",children:n.endpoint})]}),r.jsx("span",{className:"hint",children:n.note})]}),n.fields.map(s=>r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{htmlFor:$y(t,s.key),children:s.label}),r.jsx(ze,{id:$y(t,s.key),type:s.secret?"password":"text",autoComplete:s.secret?"new-password":"off",placeholder:s.placeholder,...xo($y(t,s.key))}),r.jsx("span",{className:"hint",children:s.hint})]},s.key))]}):null}async function yM(e,t){if(!xM){xM=!0,e(!0);try{await t()}finally{xM=!1,e(!1)}}}async function y7(e){Wt().wbAddAccountModal?.close?.(),await Wt().wbProviders?.refreshCustom?.(),await Wt().wbApp?.refresh?.(),cr(e)}function zy(e,t){ef(e,t?"1":"")}function _N(e){return Zo(e)==="1"}function j7({checked:e,note:t,onChange:n}){return r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{children:a("鉴权")}),r.jsx("div",{className:"col-start-2 row-start-1 flex h-[30px] items-center",children:r.jsxs(Ae,{className:"inline-flex cursor-pointer items-center gap-2.5",children:[r.jsx(jr,{checked:e,"aria-label":a("该上游无需鉴权"),onCheckedChange:s=>n(s===!0)}),r.jsx("span",{className:"text-xs text-subtle",children:a("该上游无需鉴权(不发送鉴权头)")})]})}),r.jsx("span",{className:"hint",children:t})]})}function yAe({mode:e,providerHint:t,presetKey:n,showToken:s,version:i}){const o=p7(),[l,u]=p.useState(()=>Zo(Yg)||o[0].value),[d,f]=p.useState(""),[m,g]=p.useState(""),[v,b]=p.useState(()=>_N(My)),[y,k]=p.useState(()=>_N(Dy)),[w,S]=p.useState(()=>IN[am]||""),[N,C]=p.useState(()=>IN[im]||""),T=jy(),P=p.useMemo(()=>Zg(),[i]),O=P.find(Q=>Q.id===t),A=O?.id||"",R=O?.name||a("该提供商"),M=e==="create"&&!!n&&!Wt().wbPresetProviders?.presetOf?.(n)?.baseUrl;p.useEffect(()=>{if(e!=="create"||!n)return;const Q=Wt().wbPresetProviders?.presetOf?.(n);if(!Q)return;const X=Q.account?.noAuth===!0;ef(Xg,Q.baseUrl?Q.name:""),ef(Qg,Q.baseUrl||""),Q.protocol&&(u(Q.protocol),ef(Yg,Q.protocol)),b(X),zy(My,X),f(Q.hint||""),g(Q.placeholder||"")},[e,n,t,s]);const _=O?.presetKey||"";p.useEffect(()=>{if(e!=="existing")return;const Q=l7(O)?.account?.noAuth===!0;k(Q),zy(Dy,Q)},[e,t,_,s]);const L=l==="anthropic",$=d||(L?hAe:fAe),D=m||(L?pAe:mAe),F=e==="create"?g7(n):"",V=e==="existing"?String(P.find(Q=>Q.id===A)?.balanceScheme||""):"",q=(Q,X)=>U=>{X(U),zy(Q,U)};return r.jsxs(r.Fragment,{children:[r.jsxs(as,{hidden:e!=="create",children:[r.jsxs("div",{className:"add-panel-head",children:[r.jsx("h3",{children:a("上游信息")}),r.jsx("span",{children:a("创建这个提供商,并同时建立它的第一个账号。")})]}),r.jsxs("div",{className:"add-form",children:[r.jsxs("div",{className:"add-field",children:[r.jsxs(Ae,{htmlFor:Xg,children:[a(M?"站点名称":"名称"),r.jsx("i",{className:"req","aria-hidden":"true",children:"*"})]}),r.jsx(ze,{id:Xg,type:"text",maxLength:uAe,"aria-required":"true",placeholder:a(M?"如:公司中转站、个人备用站":"如:智谱 GLM"),...xo(Xg)}),r.jsx("span",{className:"hint",children:a(M?"填写具体站点名称;模板类型不会作为站点身份":"1~64 个字符,账号列表里按它分组显示")})]}),r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{htmlFor:Yg,children:a("协议")}),r.jsxs(Pt,{value:l,onValueChange:Q=>{const X=String(Q);u(X),ef(Yg,X),f("")},children:[r.jsx(Mt,{id:Yg,className:"col-start-2 row-start-1 w-full",children:r.jsx(It,{children:o.find(Q=>Q.value===l)?.label||l})}),r.jsx(_t,{children:o.map(Q=>r.jsx(Ze,{value:Q.value,children:Q.label},Q.value))})]})]}),r.jsxs("div",{className:"add-field",children:[r.jsxs(Ae,{htmlFor:Qg,children:["Base URL",r.jsx("i",{className:"req","aria-hidden":"true",children:"*"})]}),r.jsx(ze,{id:Qg,type:"text","aria-required":"true",placeholder:D,...xo(Qg)}),r.jsx("span",{className:"hint",id:"custom-baseurl-hint",children:$})]}),r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{htmlFor:Iy,children:"API Key"}),r.jsx(ze,{id:Iy,type:"password",autoComplete:"new-password",placeholder:"sk-…",disabled:v,...xo(Iy)}),r.jsx("span",{className:"hint",children:a(v?"不需要 Key:转发与拉取模型都不发送鉴权头":"上游不要鉴权时留空,并勾选下面一项(留空又不勾会被当成未配置凭证)")})]}),r.jsx(j7,{checked:v,note:a(v?"已声明无需鉴权:账号会被正常选路,出网时不带任何鉴权头":"本地 Ollama、OpenCode Zen 免费档这类上游要勾上,否则账号不可用"),onChange:q(My,b)}),r.jsx(b7,{scheme:F,prefix:vM}),r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{htmlFor:am,children:a("User-Agent(可选)")}),r.jsx(Ug,{id:am,value:w,onChange:Q=>{S(Q),MN(am,Q)},presets:T,className:"col-start-2 row-start-1"}),r.jsx("span",{className:"hint",children:a("留空使用默认的 User-Agent;可从预置里选一个内置客户端,也可以直接填写。")})]})]})]}),r.jsxs(as,{hidden:e!=="existing",children:[r.jsxs("div",{className:"add-panel-head",children:[r.jsx("h3",{children:a("账号信息")}),r.jsxs("span",{children:[a("添加到 "),r.jsx("b",{children:R}),a(" 同一家可以放多把 key,按优先级轮换。")]})]}),r.jsxs("div",{className:"add-form",children:[r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{children:a("提供商")}),r.jsx(ze,{readOnly:!0,value:O?R:a("该提供商已不存在(可能已被删除),请刷新后重试")}),r.jsx("span",{className:"hint",children:a("要添加到其他站点,请返回「已建 API」重新选择")})]}),r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{children:"Base URL"}),r.jsx(ze,{readOnly:!0,value:O?.baseUrl||""})]}),r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{htmlFor:_y,children:"API Key"}),r.jsx(ze,{id:_y,type:"password",autoComplete:"new-password",placeholder:"sk-…",disabled:y,...xo(_y)}),r.jsx("span",{className:"hint",children:a(y?"不需要 Key:转发与拉取模型都不发送鉴权头":"上游不要鉴权时留空,并勾选下面一项(留空又不勾会被当成未配置凭证)")})]}),r.jsx(j7,{checked:y,note:a(y?"已声明无需鉴权:账号会被正常选路,出网时不带任何鉴权头":"同一家可以混着放:有 Key 的账号与无鉴权账号各按各的规则走;无需鉴权的账号也能并存多条(各自可配不同的出网代理)"),onChange:q(Dy,k)}),r.jsx(b7,{scheme:V,prefix:bM}),r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{htmlFor:Ly,children:a("备注名")}),r.jsx(ze,{id:Ly,type:"text",maxLength:dAe,placeholder:a("可选"),...xo(Ly)}),r.jsx("span",{className:"hint",children:a("留空则用提供商名称")})]}),r.jsxs("div",{className:"add-field",children:[r.jsx(Ae,{htmlFor:im,children:a("User-Agent(可选)")}),r.jsx(Ug,{id:im,value:N,onChange:Q=>{C(Q),MN(im,Q)},presets:T,className:"col-start-2 row-start-1"}),r.jsx("span",{className:"hint",children:a("留空使用默认的 User-Agent;可从预置里选一个内置客户端,也可以直接填写。")})]})]})]})]})}function w7(e,t){const n=Oa(t);cr(a("添加失败:{reason}",{reason:n}),"err"),e.setHint(n)}async function jM(e,t=!1,n){const s=Zo(Xg),i=Zo(Yg)||p7()[0].value,o=Zo(Qg),l=Zo(Iy),u=_N(My);if(!s){cr(a("请填写名称"),"err");return}if(!o){cr(a("请填写 Base URL"),"err");return}await yM(e.setBusy,async()=>{if(!t){await Wt().wbProviders?.refreshCustom?.();const b=Zg().filter(y=>u7(y,i,o));if(b.length){e.setDuplicates(b);return}}if(e.setDuplicates([]),n&&!Zg().some(b=>b.id===n.id&&u7(b,i,o))){cr(a("该提供商已不存在或地址已变更,请重新选择"),"err");return}const d=n?{provider:n.id}:{name:s,protocol:i,baseUrl:o},f=e.presetKey?Wt().wbPresetProviders?.presetOf?.(e.presetKey):null,m=g7(e.presetKey);if(!n){f&&(d.presetKey=f.key);const b=f?.quirks||{};b.urlSuffix&&(d.urlSuffix=b.urlSuffix),b.headers&&Object.keys(b.headers).length&&(d.headers={...b.headers}),b.anthropicToolType&&(d.anthropicToolType=b.anthropicToolType),f?.clientEmulation&&(d.clientEmulation=f.clientEmulation),m&&(d.balanceScheme=m)}const g=!n||n.balanceScheme===m?x7(m,vM):null;g&&(d.balanceQuery=g),u?d.noAuth=!0:l&&(d.apiKey=l);const v=m7(am);v&&(d.userAgent=v),e.setHint("");try{d.proxy=e.readProxy();const b=await Wt().wbProviders?.customRequest?.("POST",n?"/api/accounts":"/api/custom-providers",d);_I([Xg,Qg,Iy]),v7(m,vM),MN(am,""),zy(My,!1);const y=n?k7(b?.account?.name||n.name||"",b?.created):a("✅ 已创建自定义提供商「{name}」并添加账号",{name:b?.provider?.name||s});await y7(y)}catch(b){w7(e,b)}})}function k7(e,t){const n=e?`:${e}`:"";return t!==!1?a("✅ {label}账号已添加{name}",{label:"",name:n}):a("✅ 已更新已有账号{name}(同一提供商内,同一把 API Key 只保留一条)",{name:n})}async function jAe(e){const t=e.providerId;if(!t||!Zg().some(l=>l.id===t)){cr(a("该提供商已不存在(可能已被删除),请刷新后重试"),"err");return}const n=Zo(_y),s=_N(Dy),i=Zo(Ly),o=String(Zg().find(l=>l.id===t)?.balanceScheme||"");await yM(e.setBusy,async()=>{const l={provider:t};s?l.noAuth=!0:n&&(l.apiKey=n),i&&(l.name=i);const u=m7(im);u&&(l.userAgent=u);const d=x7(o,bM);d&&(l.balanceQuery=d),e.setHint("");try{l.proxy=e.readProxy();const f=await Wt().wbProviders?.customRequest?.("POST","/api/accounts",l);_I([_y,Ly]),v7(o,bM),MN(im,""),zy(Dy,!1);const m=f?.account?.name||Zg().find(g=>g.id===t)?.name||"";await y7(k7(m,f?.created))}catch(f){w7(e,f)}})}async function wAe(e){if(!e){cr(a("请先选择一个自定义提供商"),"err");return}const t=Wt().wbCustomProvidersUi?.remove;if(typeof t!="function"){cr(a("删除功能不可用(脚本未就绪)"),"err");return}await yM(()=>{},async()=>{await t(e)&&Wt().wbAddAccountModal?.close?.()})}function kAe({mode:e,presetKey:t,providerId:n}){const[s,i]=sm(),o=vo(),[l,u]=p.useState(""),[d,f]=p.useState([]),m={presetKey:t,providerId:n,setBusy:i,setHint:u,setDuplicates:f,readProxy:o.read};return r.jsxs(r.Fragment,{children:[d.length?r.jsx(iAe,{providers:d,onClose:()=>f([]),onCreate:()=>{jM(m,!0)},onExisting:g=>{jM(m,!0,g)}}):null,r.jsx("span",{className:`add-foot-hint${l?" err":""}`,id:"add-form-foot-hint",children:l}),r.jsxs("span",{className:"add-foot-actions",id:"add-form-foot-actions",children:[e==="existing"?r.jsx(B,{id:bAe,variant:"destructive",title:a("级联删除名下全部账号,不可恢复"),onClick:()=>{wAe(n)},children:a("删除此提供商")}):null,r.jsx(B,{id:xAe,hidden:e!=="create",disabled:s,onClick:()=>{jM(m)},children:a(s&&e==="create"?"提交中…":"创建并添加账号")}),r.jsx(B,{id:vAe,hidden:e!=="existing",disabled:s,onClick:()=>{jAe(m)},children:a(s&&e==="existing"?"提交中…":"添加账号")})]})]})}const By="antigravity",sf="agy-cli";function S7(e){return e===By||e===sf}function SAe(e){return[By,sf].flatMap(t=>e.find(n=>n.id===t&&n.loginAvailable!==!1)||[])}function NAe(e){const t=SAe(e),n=t[0];return e.flatMap(s=>S7(s.id||"")?s.id!==n?.id?[]:[{...s,label:"Antigravity",count:t.reduce((i,o)=>i+(Number(o.count)||0),0)}]:[s])}const Cc="all",af="proxy",Ul="web",of="preset",Ac="custom",N7="import",C7=[af,Ul,of,Ac],Fy="preset:",wM="__new__";function CAe(e){return e===Cc?Cc:e===of||e===Ac||e===Ul?e:af}function Jg(e){return e===Cc?a("全部"):e===Ul?"Web":e===of?a("API 模板"):e===Ac?a("已建 API"):e===N7?a("导入"):"Agent"}const AAe=new Set(["cline-pass"]);function DN(e){const t=Wt().wbProviders;if(e===of)return(Wt().wbPresetProviders?.list||[]).map(d=>({id:Fy+d.key,label:d.name,count:0,preset:!0}));if(e===Ac)return(t?.customList?.()||[]).map(d=>({id:d.id,label:d.name||d.id,count:ANe(d.id),custom:!0,icon:c7(d),site:lAe(d.baseUrl),template:l7(d)?.name}));const n=(t?.all?.()||[]).filter(d=>!CNe(String(d?.id||""))&&d.loginAvailable!==!1).filter(d=>d.category==="web"==(e===Ul)).filter(d=>e===Ul||!AAe.has(String(d?.id||""))),s=(d,f)=>d==="minimax-code"?a("MiniMax Code 国内版"):d==="minimax-code-global"?a("MiniMax Code 国际版"):d==="qwenwork"?a("千问办公 国内版"):d==="qwenwork-intl"?a("千问办公 国际版"):d==="qwenwork-enterprise"?a("QwenWork 千问办公企业版"):d===RN?r7:a(Wt().wbProviders?.labelOf?.(d)||f),i=n.map(d=>{const f=String(d.id||"");return{id:f,label:s(f,String(d.label||d.id||"")),count:Number(d.count)||0}}),o=NAe(i.filter(d=>d.id!=="workbuddy-intl")),l=o.findIndex(d=>d.id==="autoclaw-intl"),u=o.findIndex(d=>d.id==="autoclaw");return u>=0&&l>u&&o.splice(u+1,0,o.splice(l,1)[0]),o}function EAe({item:e}){const t=e.id.startsWith(Fy)?Wt().wbPresetProviders?.iconOf?.(e.id.slice(Fy.length))||"":e.icon,{src:n,onError:s}=Qh(e.id,t);if(n)return r.jsx("span",{className:"add-provider-logo has-icon",children:r.jsx("img",{src:n,alt:"",loading:"lazy",onError:s})});const i=String(e.label||"?").trim().slice(0,1).toUpperCase()||"?";return r.jsx("span",{className:"add-provider-logo",children:i})}function TAe(e){return e.preset?a("使用模板新建提供商"):e.custom?e.count?a("{n} 个账号,点击添加",{n:e.count}):a("点击添加账号"):e.count?a("{n} 个账号",{n:e.count}):a("还没有账号")}function OAe({item:e,onPick:t}){return r.jsxs(Dh,{render:r.jsx(B,{variant:"outline"}),variant:"outline",className:"add-provider-card h-auto whitespace-normal text-left","data-provider":e.id,title:[e.label,e.site,e.template].filter(Boolean).join(" · "),role:"option",onClick:()=>t(e.id),children:[r.jsx(EAe,{item:e}),r.jsxs("span",{className:"add-provider-info",children:[r.jsx("span",{className:"add-provider-name",children:e.label}),e.site?r.jsx("span",{className:"add-provider-meta",children:[e.site,e.template].filter(Boolean).join(" · ")}):null,r.jsx("span",{className:"add-provider-meta",children:TAe(e)})]}),r.jsx("span",{className:"add-provider-go",children:"›"})]})}function RAe({onPick:e}){return r.jsxs(Dh,{render:r.jsx(B,{variant:"dashed"}),variant:"outline",className:"add-provider-card is-new h-auto whitespace-normal text-left","data-provider":wM,role:"option",onClick:()=>e(wM),children:[r.jsx("span",{className:"add-provider-logo is-new",children:"+"}),r.jsxs("span",{className:"add-provider-info",children:[r.jsx("span",{className:"add-provider-name",children:a("新建自定义提供商")}),r.jsx("span",{className:"add-provider-meta",children:a("接入一个兼容上游")})]}),r.jsx("span",{className:"add-provider-go",children:"›"})]})}function PAe({accountType:e,onAccountTypeChange:t,search:n,onSearchChange:s,onPick:i,version:o,importing:l,importPanel:u}){const d=p.useMemo(()=>DN(af).length>0,[o]),f=p.useMemo(()=>DN(Ul).length>0,[o]),g=e===af&&!d||e===Ul&&!f?f?Ul:of:e,v=n.trim().toLowerCase(),b=O=>!v||[O.label,O.site,O.template].filter(Boolean).join(" ").toLowerCase().includes(v),y=!v&&(g===Ac||g===Cc),k=g===Cc,S=(k?C7:[g]).map(O=>({type:O,label:Jg(O),items:DN(O).filter(b)})).filter(O=>O.items.length>0||O.type===Ac&&y),N=S.flatMap(O=>O.items),C=new Map(C7.map(O=>[O,DN(O).filter(b).length])),T=[...C.values()].reduce((O,A)=>O+A,0),P=v&&!k&&!N.length?T:0;return r.jsxs(ma,{label:a("选择提供商"),children:[r.jsxs("div",{className:"add-pick-row",style:l?{display:"none"}:void 0,children:[r.jsx(en,{"aria-label":a("账号类型"),className:Xd,options:[{value:Cc,label:Jg(Cc),count:T},...d?[{value:af,label:Jg(af),count:C.get(af)}]:[],...f?[{value:Ul,label:Jg(Ul),count:C.get(Ul)}]:[],{value:of,label:Jg(of),count:C.get(of)},{value:Ac,label:Jg(Ac),count:C.get(Ac)}],value:g,onValueChange:O=>t(CAe(O))}),r.jsx("span",{id:"add-search-wrap",className:"add-provider-search ml-auto max-w-[340px] min-w-0 flex-[1_1_200px]",children:r.jsxs(zs,{children:[r.jsx(As,{children:"⌕"}),r.jsx(Bs,{id:"add-provider-search",type:"search",placeholder:a("搜索提供商…"),autoComplete:"off","aria-label":a("搜索提供商"),value:n,onChange:O=>s(O.currentTarget.value)})]})})]}),P>0?r.jsxs(Fe,{className:"flex items-center gap-3",children:[r.jsx("span",{children:a("当前分类里没有「{keyword}」,其它分类有 {n} 个匹配",{keyword:n.trim(),n:P})}),r.jsx(B,{size:"sm",variant:"outline",type:"button",className:"add-provider-hint-go",onClick:()=>t(Cc),children:a("看全部匹配")})]}):null,u,r.jsxs("div",{className:"add-provider-grid",id:"add-provider-grid",role:"listbox","aria-label":a("选择要添加账号的提供商"),style:l?{display:"none"}:void 0,children:[S.map(O=>r.jsxs(p.Fragment,{children:[k?r.jsxs("div",{className:"add-provider-band",role:"group","aria-label":O.label,children:[r.jsx("span",{className:"add-provider-band-name",children:O.label}),O.items.length?r.jsx("span",{className:"add-provider-band-stat",children:a("{count} 家",{count:O.items.length})}):null,r.jsx("span",{className:"add-provider-band-fill"}),r.jsx(B,{size:"xs",variant:"ghost",type:"button",className:"add-provider-band-only",onClick:()=>t(O.type),children:a("只看这一类")})]}):null,y&&O.type===Ac?r.jsx(RAe,{onPick:i}):null,O.items.map(A=>r.jsx(OAe,{item:A,onPick:i},A.id))]},O.type)),!N.length&&v?r.jsx(pt,{className:"add-provider-empty",children:a("没有匹配「{keyword}」的提供商",{keyword:n.trim()})}):null,!N.length&&!y&&!v&&(g===af||g===Cc)?r.jsxs(pt,{className:"add-provider-empty",children:[r.jsx("p",{className:"mb-2",children:a("请安装并启用对应的提供商插件;列表为空时请刷新后重试。")}),r.jsx(B,{size:"default",variant:"ghost",type:"button",className:"text-primary underline underline-offset-2",onClick:()=>Wt().wbApp?.showPage?.("plugins"),children:a("去安装提供商插件包")})]}):null]})]})}let kM=!1;async function ex(e,t){if(!kM){kM=!0,e(!0);try{await t()}finally{kM=!1,e(!1)}}}function lf({html:e,text:t}){return e?r.jsx("p",{dangerouslySetInnerHTML:{__html:e}}):r.jsx("p",{children:t||""})}function IAe(e,t){return new Promise((n,s)=>{const i=new FileReader;i.onload=()=>n(String(i.result||"")),i.onerror=()=>s(new Error(t)),i.onabort=()=>s(new DOMException(t,"AbortError")),i.readAsDataURL(e)})}const MAe="agent2api-account";function tx(e){return!!(e&&typeof e=="object"&&!Array.isArray(e)&&e.format===MAe)}function SM(e,t,n){if(e.provider!==t)throw new Error(a("账号文件的提供商与当前选择不一致,请选择对应的提供商后再导入"));const s={...e,provider:t};return n&&(s.name=n),s}function _Ae(e){return tx(e)?e.provider==="workbuddy"?"cn":e.provider==="workbuddy-intl"?"intl":null:null}function DAe(e){const t=e.indexOf(",");return t>=0?e.slice(t+1):e}function LAe({config:e,visible:t,footerHost:n,userAgent:s=""}){const[i,o]=sm(),l=vo(),[u,d]=p.useState(""),f=p.useRef(null),m=e.fileImport,g=`${e.provider}-file-name`;if(!m)return null;async function v(b){const y=e.fileImport;y&&await ex(o,async()=>{try{const k=Zo(g),w={provider:e.provider,authFileName:b.name};if(y.binary)if((await b.slice(0,64).text()).trimStart().startsWith("{")){const C=JSON.parse(await b.text());if(!tx(C))throw new Error(a("请选择客户端凭证文件,或本软件导出的单账号 JSON 文件"));Object.assign(w,SM(C,e.provider,k))}else w.authFileB64=DAe(await IAe(b,a("文件读取失败")));else{const N=await b.text();let C;try{C=JSON.parse(N)}catch{cr(a("选择的文件不是合法 JSON"),"err");return}if(!C||typeof C!="object"||Array.isArray(C)){cr(a("不是有效的凭证文件:内容要是一个 JSON 对象"),"err");return}tx(C)?Object.assign(w,SM(C,e.provider,k)):w.authFileContent=N}k&&(w.name=k),s.trim()&&w.userAgent===void 0&&(w.userAgent=s.trim()),Object.assign(w,tx(w)?l.importFields():{proxy:l.read()});const S=await Qd(w);d(""),await Ll(Jd(S?.account),e.label,S)}catch(k){cr(a("导入失败:{reason}",{reason:Oa(k)}),"err")}})}return r.jsxs(ma,{label:a("导入凭证文件"),hidden:!t,children:[r.jsx(lf,{text:m.note}),r.jsx("p",{className:"detail",children:a("也支持本软件导出的单账号 JSON 文件,保留账号凭证与附加信息。")}),r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{className:"lb-inline",htmlFor:g,children:a("备注名")}),r.jsx(ze,{id:g,type:"text",maxLength:ON,placeholder:a("可选,留空则用文件里的昵称"),...xo(g)})]}),r.jsx(ze,{ref:f,type:"file",accept:m.accept,hidden:!0,onChange:b=>{const y=b.target.files?.[0];b.target.value="",y&&(d(y.name),v(y))}}),r.jsx(el,{host:n,active:t,note:r.jsx("span",{className:"detail",children:u}),children:r.jsx(B,{onClick:()=>f.current?.click(),disabled:i,children:a(i?"导入中…":"选择凭证文件导入")})})]})}const $Ae=a("登录态文件路径:~/.box-agent/config/auth.json(Windows:C:\\Users\\<你的用户名>\\.box-agent\\config\\auth.json)");function zAe(e,t,n){let s;try{s=JSON.parse(t)}catch(i){return cr(a("{name} 不是合法 JSON:{reason}",{name:e.label,reason:Oa(i)}),"err"),!1}return!s||typeof s!="object"||Array.isArray(s)?(cr(a("{name}要粘一个 JSON 对象(形如 {sample})",{name:e.label,sample:'{"codearts_provider_credential":{…}}'}),"err"),!1):(Object.assign(n,s),!0)}function BAe({config:e,region:t,visible:n,footerHost:s,userAgent:i,onUserAgent:o}){const l=e.provider,[u,d]=sm(),[f,m]=p.useState(""),g=jy(),v=vo(),b=sAe(e),y=e.fields.map(N=>PN(e,N)),k=`${l}-user-agent`,w=wy(e.provider);async function S(){const N={provider:e.provider};e.regionOptions?.length&&(N.mode=t),i.trim()&&(N.userAgent=i.trim());for(const C of e.fields){const T=Zo(PN(e,C));if(!C.optional&&!T){cr(a("请填写 {label}",{label:C.label}),"err");return}if(T){if(C.jsonExpand){if(!zAe(C,T,N))return;continue}N[C.key]=T}}try{N.proxy=v.read()}catch(C){cr(a("添加失败:{reason}",{reason:Oa(C)}),"err");return}await ex(d,async()=>{try{const C=await Qd(N);_I(y),o(""),m(""),await Ll(Jd(C?.account),e.label)}catch(C){cr(a("添加失败:{reason}",{reason:Oa(C)}),"err")}})}return r.jsxs(ma,{label:rAe(e),hidden:!n,onClick:N=>{N.target.closest("[data-raccoon-hint]")&&(N.preventDefault(),m($Ae))},children:[r.jsx(lf,{...b}),e.fields.map(N=>{const C=PN(e,N),T=N.optional?"":a("(必填)");return r.jsxs("div",{className:`field-row${N.rows?" stack":""}`,children:[r.jsxs(Ae,{htmlFor:C,children:[N.label,T]}),N.rows?r.jsx(Xs,{id:C,rows:N.rows,placeholder:N.placeholder,...xo(C)}):r.jsx(ze,{id:C,type:"text",maxLength:_1e(N),placeholder:N.placeholder,...xo(C)})]},C)}),w?r.jsxs("div",{className:"field-row",children:[r.jsx(Ae,{htmlFor:k,children:a("User-Agent(可选)")}),r.jsx(Ug,{id:k,value:i,onChange:o,presets:g,disabled:u})]}):null,r.jsx(el,{host:s,active:n,note:r.jsx("span",{className:"detail",id:`${l}-add-hint`,children:f}),children:r.jsx(B,{id:`${l}-add-button`,onClick:()=>{S()},disabled:u,children:u?a("添加中…"):aAe(e)})})]})}function FAe({config:e,visible:t,footerHost:n}){const s=e.provider,[i,o]=sm(),l=vo();if(!i7(e)||!e.desktopNote)return null;async function u(){await ex(o,async()=>{try{const d=await Qd({provider:e.provider,importDesktop:!0,proxy:l.read()});await Ll(d?.account?.name||"",e.label)}catch(d){cr(a("导入失败:{reason}",{reason:Oa(d)}),"err")}})}return r.jsxs(ma,{label:a("从本机导入桌面端登录态"),hidden:!t,children:[r.jsx("p",{children:e.desktopNote}),r.jsx(el,{host:n,active:t,children:r.jsx(B,{id:`${s}-desktop-button`,title:e.desktopHint,onClick:()=>{u()},disabled:i,children:a(i?"导入中…":"从本机导入桌面端登录态")})})]})}function UAe({config:e,visible:t,footerHost:n}){const s=e.guestLogin,[i,o]=sm(),l=vo();if(!s)return null;const u=PN(e,{key:"name"});async function d(){await ex(o,async()=>{const m=document.getElementById(u)?.value.trim()||"";try{const g=await Qd({provider:e.provider,guest:!0,proxy:l.read(),...m?{name:m}:{}});await Ll(g?.account?.name||"",e.label)}catch(g){cr(a("添加失败:{reason}",{reason:Oa(g)}),"err")}})}return r.jsxs(ma,{label:a("访客模式"),hidden:!t,children:[s.noteHtml?r.jsx(lf,{html:s.noteHtml}):null,r.jsxs("div",{className:"form-field",children:[r.jsx(Ae,{htmlFor:u,children:a("备注名")}),r.jsx(ze,{id:u,type:"text",maxLength:ON,placeholder:s.namePlaceholder||a("可选"),...xo(u)})]}),r.jsx(el,{host:n,active:t,children:r.jsx(B,{id:`${e.provider}-guest-button`,onClick:()=>{d()},disabled:i,children:i?s.busyText||a("正在添加…"):s.button})})]})}function HAe({config:e,mode:t,onModeChange:n,region:s,visible:i,footerHost:o,userAgentRef:l,userAgent:u,onUserAgent:d}){const f=e.webLogin,m=e.provider,g=jy(),v=wy(e.provider),b=p.useRef(t),y=p.useRef(s),k=p.useRef(null),w=vo();b.current=t,y.current=s;const S=Wg()==="web",[N,C]=p.useState(()=>({label:f?.button||"",hint:S?f?.webHint||Fl:f?.hint||f?.modes?.[0]?.hint||"",disabled:!1,waiting:!1}));return p.useEffect(()=>{const T=Wt().wbWebLogin;if(!T||!f)return;const P=f.modes;return k.current=T.create({provider:m,buttonId:`${m}-web-button`,cancelId:`${m}-web-cancel`,hintId:`${m}-web-hint`,busyText:f.busyText,onStateChange:O=>{C(O),w.setBusy(O.disabled)},texts:()=>{const O=P?.find(A=>A.value===b.current);return{button:f.button,hint:S?f.webHint||Fl:O?.hint||f.hint||""}},start:()=>mN(m,f.edition||y.current||"cn",b.current||"embedded",void 0,{proxy:w.read()}),onSuccess:async O=>{await mG(pG(O),e.provider,l.current??""),MI(),await Wt().wbApp?.refresh?.();const A=O?.warning;A?cr(a("账号已添加,但请留意:{warning}",{warning:A}),"err"):cr(a("✅ {label}账号已添加",{label:e.label}))}})??null,()=>{k.current?.dispose(),k.current=null}},[]),p.useEffect(()=>{k.current?.syncTexts()},[t]),f?r.jsxs(ma,{label:a("网页登录"),hidden:!i,children:[r.jsx(lf,{html:f.noteHtml}),f.modes?.length&&!S?r.jsxs("div",{className:"flex flex-col gap-2.5 border-l-2 border-border pl-[11px]",children:[r.jsx("span",{className:"text-[12.5px] text-subtle",children:a("打开方式")}),r.jsx(en,{"aria-label":a("{label} 网页登录的打开方式",{label:e.label}),options:f.modes,value:t,onValueChange:n})]}):null,v?r.jsxs("div",{className:"field-row",children:[r.jsx(Ae,{htmlFor:`${m}-web-user-agent`,children:a("User-Agent(可选)")}),r.jsx(Ug,{id:`${m}-web-user-agent`,value:u,onChange:d,presets:g,disabled:N.waiting})]}):null,r.jsxs(el,{host:o,active:i,note:r.jsx("span",{className:"detail",id:`${m}-web-hint`,children:N.hint}),children:[r.jsxs(B,{id:`${m}-web-button`,disabled:N.disabled||S&&(f.desktopOnly||e.provider==="doubaowork"),onClick:()=>k.current?.start(),children:[N.waiting&&r.jsx(Qt,{}),N.label]}),r.jsx(B,{id:`${m}-web-cancel`,variant:"outline",hidden:!N.waiting,onClick:()=>k.current?.cancel(),children:a("取消等待")})]})]}):null}function VAe({config:e,visible:t,footerHost:n}){const s=e.smsLogin,i=e.provider,o=vo();return p.useEffect(()=>{s&&Wt().wbSmsLogin?.create({provider:i,proxy:o.read,onBusyChange:o.setBusy,onSuccess:l=>Ll(Jd(l?.account),e.label)})},[]),s?r.jsxs(ma,{label:a("手机验证码登录"),hidden:!t,children:[r.jsx(lf,{html:s.noteHtml,text:a("用 AutoClaw 账号绑定的手机号登录:点击「获取验证码」,收到短信后填入下方并登录。验证码由本机直接提交给官方接口,界面不显示 token。")}),r.jsxs("div",{className:"sms-form",children:[r.jsxs("div",{className:"sms-field",children:[r.jsxs(Ae,{className:"lb",htmlFor:`${i}-sms-phone`,children:[a("手机号"),r.jsx("i",{className:"req",children:"*"})]}),r.jsxs(zs,{children:[r.jsx(Bs,{id:`${i}-sms-phone`,type:"text",maxLength:11,placeholder:a("11 位大陆手机号"),...xo(`${i}-sms-phone`)}),r.jsx(As,{align:"inline-end",children:r.jsx(Db,{id:`${i}-sms-send`,className:"text-primary-fg",children:a("获取验证码")})})]})]}),r.jsxs("div",{className:"sms-field",children:[r.jsxs(Ae,{className:"lb",htmlFor:`${i}-sms-code`,children:[a("验证码"),r.jsx("i",{className:"req",children:"*"})]}),r.jsxs("div",{className:"sms-pair",children:[r.jsx(ze,{id:`${i}-sms-code`,className:"sms-code",type:"text",maxLength:6,placeholder:a("6 位数字")}),r.jsx(Ae,{className:"lb-inline",htmlFor:`${i}-sms-name`,children:a("备注名")}),r.jsx(ze,{id:`${i}-sms-name`,className:"sms-name",type:"text",placeholder:a("可选,留空则用脱敏手机号"),...xo(`${i}-sms-name`)})]})]}),r.jsx(el,{host:n,active:t,note:r.jsx("span",{className:"detail sms-hint",id:`${i}-sms-hint`}),children:r.jsx(B,{id:`${i}-sms-submit`,children:a("登录并添加")})})]})]}):null}function KAe({config:e,mode:t,onModeChange:n,visible:s,footerHost:i}){const o=e.oauthLogin,l=e.provider,u=vo(),d=p.useRef(t),f=p.useRef(null);d.current=t;const m=Wg()==="web",g=()=>m?o?.webHint||Fl:o?.modes?.find(v=>v.value===d.current)?.hint||o?.hint||"";return p.useEffect(()=>{const v=Wt().wbAutoclawOauth;!v||!o||(f.current=v.create({provider:l,mode:()=>d.current||"embedded",hint:g,proxy:u.read,onBusyChange:u.setBusy,cancelId:`${l}-oauth-cancel`,onSuccess:()=>Ll("",e.label)})??null)},[]),p.useEffect(()=>{f.current?.syncTexts()},[t]),o?r.jsxs(ma,{label:o.title||a("网页登录"),hidden:!s,children:[r.jsx(lf,{html:o.noteHtml}),o.modes?.length&&!m?r.jsxs("div",{className:"flex flex-col gap-2.5 border-l-2 border-border pl-[11px]",children:[r.jsx("span",{className:"text-[12.5px] text-subtle",children:a("打开方式")}),r.jsx(en,{"aria-label":a("{label} 网页登录的打开方式",{label:e.label}),options:o.modes,value:t,onValueChange:n})]}):null,r.jsxs(el,{host:i,active:s,note:r.jsx("span",{className:"detail",id:`${l}-oauth-hint`,children:g()}),children:[r.jsx(B,{id:`${l}-oauth-zai`,children:a("使用 Zai 账号登录")}),r.jsx(B,{id:`${l}-oauth-google`,variant:"outline",children:a("使用 Google 账号登录")}),r.jsx(B,{id:`${l}-oauth-cancel`,variant:"outline",hidden:!0,children:a("取消")})]})]}):null}function A7({config:e,active:t,footerHost:n,selectedMethod:s,hideMethodPicker:i=!1}){const o=e.regionOptions?.[0]?.value??"",[l,u]=p.useState(o),[d,f]=p.useState(()=>o7(e,o)[0]),[m,g]=p.useState(e.webLogin?.modes?.[0]?.value??""),[v,b]=p.useState(e.oauthLogin?.modes?.[0]?.value??""),[y,k]=p.useState(""),w=p.useRef(y);w.current=y;const S=o7(e,l),N=s??(S.includes(d)?d:S[0]),C=p.useMemo(()=>a7.filter(T=>S.includes(T.id)).map(T=>({value:T.id,label:T.label})),[S.join(",")]);return r.jsxs("div",{className:"add-provider-block",hidden:!t,children:[e.regionOptions?.length?r.jsx(ma,{label:a("地区"),children:r.jsx(en,{"aria-label":a("{label} 账号地区",{label:e.label}),className:Xd,options:e.regionOptions,value:l,onValueChange:u})}):null,r.jsx(ma,{label:a("添加方式"),hidden:i,children:r.jsx(en,{"aria-label":a("{label} 账号的添加方式",{label:e.label}),className:Xd,options:C,value:N,onValueChange:T=>f(T)})}),r.jsx(UAe,{config:e,visible:t&&N==="guest",footerHost:n}),r.jsx(KAe,{config:e,mode:v,onModeChange:b,visible:t&&N==="oauth",footerHost:n}),r.jsx(VAe,{config:e,visible:t&&N==="sms",footerHost:n}),r.jsx(HAe,{config:e,mode:m,onModeChange:g,region:l,visible:t&&N==="web",footerHost:n,userAgentRef:w,userAgent:y,onUserAgent:k}),r.jsx(BAe,{config:e,region:l,visible:t&&N==="manual",footerHost:n,userAgent:y,onUserAgent:k}),r.jsx(LAe,{config:e,visible:t&&N==="file",footerHost:n,userAgent:y}),r.jsx(FAe,{config:e,visible:t&&N==="desktop",footerHost:n})]})}const qAe=a("官方客户端凭证目录:Windows 是 C:\\Users\\<你的用户名>\\AppData\\Local\\CodeBuddyExtension\\Data\\Public\\auth,macOS 是 ~/Library/Application Support/CodeBuddyExtension/Data/Public/auth"),LN="workbuddy-file-name";function NM(e,t,n){const s=e[n],i=[];s&&typeof s=="object"&&!Array.isArray(s)&&i.push(s),i.push(e);for(const o of i)for(const l of t){const u=o[l];if(typeof u=="string"&&u.trim())return u.trim()}return""}function GAe(e){const t=NM(e,["domain"],"auth");return/workbuddy\.ai/i.test(t)?"intl":/workbuddy\.cn|codebuddy\.cn/i.test(t)?"cn":null}function WAe({edition:e,visible:t,footerHost:n}){const[s,i]=sm(),o=vo(),[l,u]=p.useState(""),d=p.useRef(null);async function f(m){await ex(i,async()=>{try{let g;try{g=JSON.parse(await m.text())}catch{cr(a("选择的文件不是合法 JSON"),"err");return}if(!g||typeof g!="object"||Array.isArray(g)){cr(a("不是有效的凭证文件:内容要是一个 JSON 对象"),"err");return}const v=g,b=NM(v,["accessToken","token","access_token"],"auth"),y=NM(v,["uid"],"account");if(!b||!y){cr(a("不是有效的凭证文件:需要包含 accessToken 与 uid"),"err");return}const k=_Ae(v)??GAe(v),w=k??e;k&&k!==e&&cr(a("文件是{edition}凭证,已按该版本导入",{edition:a(k==="intl"?"国际版":"国内版")}),"warn");const S=Zo(LN),N=tx(g)?SM(v,Uy(w),S):{...v,provider:Uy(w)};S&&(N.name=S),Object.assign(N,tx(N)?o.importFields():{proxy:o.read()});const C=await Qd(N);u(""),await Ll(Jd(C?.account),w==="intl"?"WorkBuddy AI":"WorkBuddy")}catch(g){cr(a("导入失败:{reason}",{reason:Oa(g)}),"err")}})}return r.jsxs(ma,{label:a("导入凭证文件"),hidden:!t,children:[r.jsx(lf,{text:a("选择官方客户端的登录态凭证文件(workbuddy-desktop.info / workbuddy-desktop-ai.info)或 wb2api 导出的账号 JSON(嵌套 / 扁平形均可)。")}),r.jsx("p",{className:"detail",children:a("也支持本软件导出的单账号 JSON 文件,保留账号凭证与附加信息。")}),r.jsx("p",{className:"detail",children:r.jsx("a",{href:"#",onClick:m=>{m.preventDefault(),u(qAe)},children:a("凭证文件在哪?")})}),r.jsxs(ct,{orientation:"horizontal",className:"field-row",children:[r.jsx(ut,{className:"lb-inline",htmlFor:LN,children:a("备注名")}),r.jsx(ze,{id:LN,type:"text",maxLength:100,placeholder:a("可选,留空则用文件里的昵称"),...xo(LN)})]}),r.jsx(ze,{ref:d,type:"file",accept:".info,.json,application/json",hidden:!0,onChange:m=>{const g=m.target.files?.[0];m.target.value="",g&&f(g)}}),r.jsx(el,{host:n,active:t,note:r.jsx("span",{className:"detail",children:l}),children:r.jsx(B,{onClick:()=>d.current?.click(),disabled:s,children:a(s?"导入中…":"选择凭证文件导入")})})]})}function YAe({edition:e,visible:t,footerHost:n}){const[s,i]=sm(),o=vo();async function l(){await ex(i,async()=>{try{const u=await Qd({provider:Uy(e),importDesktop:!0,proxy:o.read()});await Ll(Jd(u?.account),e==="intl"?"WorkBuddy AI":"WorkBuddy")}catch(u){cr(a("导入失败:{reason}",{reason:Oa(u)}),"err")}})}return r.jsxs(ma,{label:a("从本机导入桌面端登录态"),hidden:!t,children:[r.jsx(lf,{text:a("读本机官方客户端(Tencent WorkBuddy / WorkBuddy AI)当前登录的账号:自动定位其凭证目录里最新的登录态文件(需已在本机官方客户端登录)。导入后由网关自动续期,无需跟随 2 小时时效手动换令牌。")}),r.jsx(el,{host:n,active:t,children:r.jsx(B,{onClick:()=>{l()},disabled:s,children:a(s?"导入中…":"从本机导入桌面端登录态")})})]})}function Uy(e){return e==="intl"?"workbuddy-intl":"workbuddy"}function XAe({active:e,footerHost:t,initialEdition:n}){const s=vo(),[i,o]=p.useState(n??Yh.edition),[l,u]=p.useState(n?n==="intl"?"external":"embedded":Yh.loginMode),[d,f]=p.useState(Yh.socialRestore),m=Wg()==="web",[g,v]=p.useState(()=>({label:a("打开网页登录"),hint:m?Fl:a("内嵌窗口打开;完成后自动加入列表,关窗即取消等待"),disabled:!1,waiting:!1})),[b,y]=p.useState("web"),k=p.useRef(i),w=p.useRef(l),S=p.useRef(d),N=p.useRef(null);k.current=i,w.current=l,S.current=d,p.useEffect(()=>{const A=Wt().wbWebLogin;if(A)return N.current=A.create({get provider(){return Uy(k.current)},buttonId:"web-login-button",cancelId:"web-login-cancel",hintId:"web-login-hint",busyText:a("等待网页登录…"),onStateChange:R=>{v(R),s.setBusy(R.disabled)},texts:()=>{if(m)return{button:a("打开网页登录"),hint:Fl};const R=w.current==="external";return{button:a(R?"在浏览器中打开登录页":"打开网页登录"),hint:a(R?"系统浏览器打开(复用已登录账号);完成后自动加入列表":"内嵌窗口打开;完成后自动加入列表,关窗即取消等待")}},start:()=>mN(Uy(k.current),k.current,w.current,S.current,{proxy:s.read()}),onSuccess:async R=>{const M=k.current==="intl"?a("国际版"):a("国内版");MI(),await Wt().wbApp?.refresh?.(),cr(a("✅ 登录成功,{edition}账号已加入列表",{edition:M}));const _=R?.warning;_&&cr(a("账号已添加,但请留意:{warning}",{warning:_}),"warn")}})??null,()=>{N.current?.dispose(),N.current=null}},[]),p.useEffect(()=>{N.current?.syncTexts()},[i,l]);function C(A){const R=A==="intl"?"external":"embedded";o(A),Yh.edition=A,u(R),Yh.loginMode=R}function T(A){const R=A==="external"?"external":"embedded";u(R),Yh.loginMode=R}const P=i==="intl"&&l==="embedded",O=b==="desktop"&&Wg()==="web"?"web":b;return r.jsxs("div",{className:"add-provider-block",hidden:!e,children:[r.jsxs(ma,{label:a("账号版本"),children:[r.jsx("p",{children:a("两版账号可同时保存,各自一份模型清单(国内版与国际版是两家提供商,可分别启用与映射)。")}),r.jsx(en,{"aria-label":a("账号版本"),className:Xd,options:[{value:"cn",label:a("国内版(WorkBuddy)")},{value:"intl",label:a("国际版(WorkBuddy AI)")}],value:i,onValueChange:A=>C(A)})]}),r.jsx(ma,{label:a("添加方式"),children:r.jsx(en,{"aria-label":a("{label} 账号的添加方式",{label:"WorkBuddy"}),className:Xd,options:[{value:"web",label:a("网页登录")},{value:"file",label:a("导入凭证文件")},...Wg()!=="web"?[{value:"desktop",label:a("导入桌面端登录态")}]:[]],value:O,onValueChange:A=>y(A)})}),r.jsxs(ma,{label:a("网页登录"),hidden:O!=="web",children:[r.jsx("p",{children:a("完成登录后自动加入账号列表,昵称取自上游。")}),m?null:r.jsxs(r.Fragment,{children:[r.jsxs(Lh,{orientation:"horizontal",className:"add-login-setting-row",children:[r.jsx("span",{className:"text-[12.5px] whitespace-nowrap text-subtle",children:a("打开方式")}),r.jsx(en,{"aria-label":a("网页登录的打开方式"),className:Xd,options:[{value:"embedded",label:a("内嵌窗口")},{value:"external",label:a("系统默认浏览器")}],value:l,onValueChange:T})]}),P?r.jsxs(Ae,{className:"add-login-setting-row",title:a("国际版登录页默认只显示邮箱登录,勾选后恢复 Google / GitHub / X 入口"),children:[r.jsx("span",{className:"text-[12.5px] text-subtle",children:a("恢复 Google / GitHub 入口")}),r.jsx(St,{checked:d,onCheckedChange:A=>{f(A),Yh.socialRestore=A}})]}):null,r.jsx("p",{children:a("系统浏览器可复用已有登录态(国际版推荐);内嵌窗口更干净。")})]}),r.jsxs(el,{host:t,active:e&&O==="web",note:r.jsx("span",{className:"detail",id:"web-login-hint",children:g.hint}),children:[r.jsxs(B,{id:"web-login-button",disabled:g.disabled,onClick:()=>N.current?.start(),children:[g.waiting&&r.jsx(Qt,{}),g.label]}),r.jsx(B,{id:"web-login-cancel",variant:"outline",hidden:!g.waiting,onClick:()=>N.current?.cancel(),children:a("取消等待")})]})]}),r.jsx(WAe,{edition:i,visible:e&&O==="file",footerHost:t}),r.jsx(YAe,{edition:i,visible:e&&O==="desktop",footerHost:t})]})}function E7(e,t){switch(e.reason){case"windows_setup_required":return t("当前 Windows 服务尚未接入一键更新。请解压新版服务端包,以管理员身份运行一次 install-service.ps1,原有账号、目录、端口和配置会保留。");case"windows_update_permissions":return t("Windows 服务升级权限或目录保护不符合要求。请以管理员身份重跑新版 install-service.ps1;自定义服务账号或外部托管环境请按原方式升级。");case"disabled":return t("管理员已关闭面板一键更新,请使用手动升级方式。");case"helper_missing":return t("当前安装尚未接入一键更新。请下载新版服务端包,执行一次 sudo bash install.sh --upgrade;之后即可在面板更新。");case"helper_unavailable":return t("一键更新组件不可用或权限配置不正确。请使用新版安装包执行 sudo bash install.sh --upgrade 修复。");case"custom_installation":return t("检测到自定义程序或界面路径,一键更新不会覆盖这些位置。请按原部署方式升级。");case"unsupported_arch":return t("当前系统或架构暂不支持面板自动安装,请查看发布页。");case"windows_service":return t("Windows 服务部署需要手动升级。请解压新版服务端包,以管理员身份运行 install-service.ps1;账号与配置会保留。");default:return t("当前为直接运行的服务端,请停止程序后替换服务端包,再重新启动。")}}function QAe(e,t,n){if(e?.filteredBySource)return n("发布页上的文件被更新源的访问方式过滤掉了,请检查「更新设置」里的 GitHub 访问方式");if(e?.assetsTotal===0)return n("这一版还没有上传任何文件(构建可能失败,或仍在打包上传)");const s=(e?.suffixes||[]).filter(Boolean).slice(0,6),i=t.serverPackage||t.selfUpdate,o=i?String(e?.expectedName||""):(e?.expectedSuffixes??[t.fallbackSuffix||""]).filter(Boolean).join(" / ");return s.length&&o?n("未找到适用的更新包。需要:{wanted};发布页包含的文件类型:{seen}。",{seen:s.join(" / "),wanted:o}):i?o?n("发布页上没有 {wanted} 这个文件",{wanted:o}):n("发布页上没有对应本机架构的服务端更新包"):o?n("这一版没有发布本机需要的安装包({wanted})",{wanted:o}):n("这一版没有为当前平台提供安装包")}function ZAe(e,t,n,s=Date.now()){if(!e.rateLimited&&!e.rateLimits?.length)return CM(e.reason,t,n);const i=(e.rateLimits||[]).filter(f=>f.retryAt>s);if(!i.length)return t("上次 GitHub 限流的等待时间已结束,可重新检查");const o=i.reduce((f,m)=>f.retryAt<=m.retryAt?f:m),u={source:[...new Set(i.map(f=>f.source==="official"?t("官方源"):f.label))].join(" / "),seconds:Math.ceil((o.retryAt-s)/1e3)},d=o.retrySource==="fallback"?t("GitHub 源「{source}」限流,{seconds} 秒后可重试(上游未提供恢复时间)",u):t("GitHub 源「{source}」限流,请在 {seconds} 秒后重试",u);return e.canRetry?t("{message};其他线路可重新检查",{message:d}):d}function CM(e,t,n){const s=e instanceof Error?e.message:String(e??""),i=/^GitHub 源「(.+)」限流,(?:请在 )?(\d+) 秒后(?:重试|可重试)((上游未提供恢复时间))?(;其他线路可重新检查)?$/.exec(s);if(i){const l={source:i[1]==="官方源"?t("官方源"):i[1],seconds:i[2]},u=i[3]?t("GitHub 源「{source}」限流,{seconds} 秒后可重试(上游未提供恢复时间)",l):t("GitHub 源「{source}」限流,请在 {seconds} 秒后重试",l);return i[4]?t("{message};其他线路可重新检查",{message:u}):u}if(s==="上次 GitHub 限流的等待时间已结束,可重新检查")return t("上次 GitHub 限流的等待时间已结束,可重新检查");if(s==="GitHub 接口限流中,请在「更新设置」的「GitHub 令牌」中填写凭证,以提高请求限额。"||s==="GitHub 接口限流中,请在「插件设置」的「GitHub 令牌」中填写凭证,以提高请求限额。")return t(n==="plugin"?"GitHub 接口限流中,请在「插件设置」的「GitHub 令牌」中填写凭证,以提高请求限额。":"GitHub 接口限流中,请在「更新设置」的「GitHub 令牌」中填写凭证,以提高请求限额。");const o=/^GitHub 接口限流中,请在 (\d+) 秒后重试$/.exec(s);return o?t("GitHub 接口限流中,请在 {seconds} 秒后重试",{seconds:o[1]}):s==="GitHub 接口限流中,请稍后重试"?t("GitHub 接口限流中,请稍后重试"):s}function Hi(e){return e?.updateCapability?e.updateCapability.mode==="docker":e?.selfUpdate===!0}function AM(e){return e?.updateCapability?.mode==="systemd"||e?.updateCapability?.mode==="windows-service"}function Eu(e){return e?.serviceTask??e?.systemdTask??null}function nx(e){return e?.updateCapability?.installSupported===!1}function EM(e){if(!e?.updateCapability)return"";const t=E7(e.updateCapability,a);return e.updateCapability.deployment==="docker"?`${t} ${a("在宿主机执行 docker compose pull && docker compose up -d 即可升级。")}`:t}function om(e){return e?e.updateCapability?.packageKind==="server"||Hi(e)?e.serverAsset??null:e.asset??null:null}function JAe(e){switch(String(e?.installerKind||"")){case"dmg":return".dmg";case"deb":return".deb";case"appimage":return".AppImage";case"nsis":return".exe";default:return""}}function $N(e){return QAe(e?.assetProbe,{selfUpdate:Hi(e),serverPackage:e?.updateCapability?.packageKind==="server",fallbackSuffix:JAe(e)},a)}function An(){return window}function Zs(e,t){An().wbApp?.toast?.(e,t)}function Js(e){return CM(e,a,"update")}function TM(e){const t=String(e||"").trim();return/^https?:\/\//i.test(t)?t:""}async function Hl(e){const t=TM(e);if(!t){Zs(a("链接地址不受支持"),"err");return}try{await An().workbuddyDesktop?.openReleasePage(t)}catch(n){Zs(a("打开链接失败:{error}",{error:Js(n)}),"err")}}const eEe=[{no:"1127656296",nearlyFull:!0},{no:"1130894674",nearlyFull:!0},{no:"1108276647",nearlyFull:!1},{no:"1054072416",nearlyFull:!1}],tEe=[{id:"telegram",url:"https://t.me/+9gM8YPvgRL02NGRl"}];function OM(e){return An().wbMarkdown?.render?.(e)||""}function Hy(e){const n=e.target?.closest?.("[data-external]");n&&(e.preventDefault(),Hl(n.dataset.external||""))}async function T7(){try{const e=await An().workbuddyDesktop?.getUpdateStatus?.();e&&(e.checked!==!1||e.channelChanged)&&An().wbApp?.updateUpdateBadge?.(e)}catch(e){console.warn("读取版本检查结果失败:",Js(e))}}const zN="__proxy_other__",O7={proxyChoice:null,proxyLoaded:!1,pool:null,poolError:""};async function R7(){const e=An().workbuddyDesktop,t={...O7};if(!e?.getUpdateProxy)return t;try{const n=await e.getUpdateProxy();if(!n||!Object.prototype.hasOwnProperty.call(n,"proxy"))throw new Error("更新线路响应异常");t.proxyChoice=n.proxy??null,t.proxyLoaded=!0}catch{}try{if(typeof e.getProxyPool!="function")throw new Error("桥未提供代理池方法");const s=(await e.getProxyPool())?.items;if(!Array.isArray(s))throw new Error("代理池响应异常");t.pool=s,m8(s)}catch(n){t.pool=[],t.poolError=Js(n)}return t}async function nEe(e){if(e===zN)return null;const t=An().workbuddyDesktop;if(!t?.setUpdateProxy)return null;const n=e===""?null:{source:"pool",proxyId:e.slice(vc.length)};try{const s=await t.setUpdateProxy({proxy:n}),i=s?.proxy??null,o=s?.saved!==!1;return o?Zs(i?a("✅ 更新出网已切换为 {label}",{label:i.label||a("指定代理")}):a("✅ 更新出网已切换为直连")):Zs(a("出网线路已切换,但写入磁盘失败(重启后会恢复原线路)"),"err"),{choice:i,saved:o}}catch(s){return Zs(a("保存失败:{error}",{error:Js(s)}),"err"),null}}function rEe(e){const t=e.proxyChoice,n=t?.config?.source||t?.source,s=t?.label||a(n==="custom"?"自定义代理":"已设置"),i=Array.isArray(e.pool)?e.pool:[],o=!!t?.error;let l="";n==="pool"&&t?.config?.proxyId?l=`${vc}${t.config.proxyId}`:t&&(l=zN);const u=[{value:"",label:a("直连")}];for(const d of i)u.push({value:`${vc}${d.id}`,label:Ag(d),disabled:d.enabled===!1});if(e.pool===null?u.push({value:"__hint_pool__",label:a("正在读取代理列表…"),disabled:!0}):i.length||u.push({value:"__hint_pool__",label:e.poolError?a("代理列表读取失败"):a("还没有代理(去「网络代理」页添加)"),disabled:!0}),l===zN){const d=n==="clash"?a("Clash 出口:"):n==="custom"?a("自定义:"):"";u.push({value:zN,label:`${d}${s}${o?a("(不可用)"):""}`})}else n==="pool"&&!i.some(d=>`${vc}${d.id}`===l)&&u.push({value:l,label:`${s}${o?a("(不可用)"):""}`});return{current:l,items:u,selected:u.find(d=>d.value===l),broken:o,title:o?a("当前线路不可用:{error};请重新选择代理或切回直连",{error:String(t?.error||"")}):a("检查更新与下载安装包使用所选线路;未选择代理时先直连,失败后尝试 Clash Verge 混合端口;指定代理不可用时不会自动改走直连。")}}function sEe({config:e,onChange:t,t:n}){const s=p.useRef(null),[i,o]=p.useState(!1),l=p.useId();p.useEffect(()=>{const f=m=>{m.source!==s.current?.contentWindow||m.origin!=="null"||m.data?.nonce!==l||(m.data?.type==="verified"?t(m.data.value):m.data?.type==="reset"&&t(null))};return window.addEventListener("message",f),()=>{window.removeEventListener("message",f),t(null)}},[l,t]);const d=`