@cjhyy/code-shell-web 0.9.36 → 0.9.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))a(u);new MutationObserver(u=>{for(const d of u)if(d.type==="childList")for(const c of d.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function r(u){const d={};return u.integrity&&(d.integrity=u.integrity),u.referrerPolicy&&(d.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?d.credentials="include":u.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function a(u){if(u.ep)return;u.ep=!0;const d=r(u);fetch(u.href,d)}})();function jo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hc={exports:{}},ha={};var Mg;function j1(){if(Mg)return ha;Mg=1;var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function r(a,u,d){var c=null;if(d!==void 0&&(c=""+d),u.key!==void 0&&(c=""+u.key),"key"in u){d={};for(var h in u)h!=="key"&&(d[h]=u[h])}else d=u;return u=d.ref,{$$typeof:t,type:a,key:c,ref:u!==void 0?u:null,props:d}}return ha.Fragment=i,ha.jsx=r,ha.jsxs=r,ha}var Og;function k1(){return Og||(Og=1,Hc.exports=j1()),Hc.exports}var s=k1(),Gc={exports:{}},Ve={};var Lg;function C1(){if(Lg)return Ve;Lg=1;var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function x(O){return O===null||typeof O!="object"?null:(O=v&&O[v]||O["@@iterator"],typeof O=="function"?O:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,C={};function T(O,le,E){this.props=O,this.context=le,this.refs=C,this.updater=E||j}T.prototype.isReactComponent={},T.prototype.setState=function(O,le){if(typeof O!="object"&&typeof O!="function"&&O!=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,O,le,"setState")},T.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function _(){}_.prototype=T.prototype;function D(O,le,E){this.props=O,this.context=le,this.refs=C,this.updater=E||j}var q=D.prototype=new _;q.constructor=D,R(q,T.prototype),q.isPureReactComponent=!0;var se=Array.isArray;function N(){}var U={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function H(O,le,E){var J=E.ref;return{$$typeof:t,type:O,key:le,ref:J!==void 0?J:null,props:E}}function A(O,le){return H(O.type,le,O.props)}function I(O){return typeof O=="object"&&O!==null&&O.$$typeof===t}function L(O){var le={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(E){return le[E]})}var P=/\/+/g;function W(O,le){return typeof O=="object"&&O!==null&&O.key!=null?L(""+O.key):le.toString(36)}function ee(O){switch(O.status){case"fulfilled":return O.value;case"rejected":throw O.reason;default:switch(typeof O.status=="string"?O.then(N,N):(O.status="pending",O.then(function(le){O.status==="pending"&&(O.status="fulfilled",O.value=le)},function(le){O.status==="pending"&&(O.status="rejected",O.reason=le)})),O.status){case"fulfilled":return O.value;case"rejected":throw O.reason}}throw O}function G(O,le,E,J,be){var Z=typeof O;(Z==="undefined"||Z==="boolean")&&(O=null);var ne=!1;if(O===null)ne=!0;else switch(Z){case"bigint":case"string":case"number":ne=!0;break;case"object":switch(O.$$typeof){case t:case i:ne=!0;break;case y:return ne=O._init,G(ne(O._payload),le,E,J,be)}}if(ne)return be=be(O),ne=J===""?"."+W(O,0):J,se(be)?(E="",ne!=null&&(E=ne.replace(P,"$&/")+"/"),G(be,le,E,"",function(ve){return ve})):be!=null&&(I(be)&&(be=A(be,E+(be.key==null||O&&O.key===be.key?"":(""+be.key).replace(P,"$&/")+"/")+ne)),le.push(be)),1;ne=0;var ge=J===""?".":J+":";if(se(O))for(var Y=0;Y<O.length;Y++)J=O[Y],Z=ge+W(J,Y),ne+=G(J,le,E,Z,be);else if(Y=x(O),typeof Y=="function")for(O=Y.call(O),Y=0;!(J=O.next()).done;)J=J.value,Z=ge+W(J,Y++),ne+=G(J,le,E,Z,be);else if(Z==="object"){if(typeof O.then=="function")return G(ee(O),le,E,J,be);throw le=String(O),Error("Objects are not valid as a React child (found: "+(le==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":le)+"). If you meant to render a collection of children, use an array instead.")}return ne}function B(O,le,E){if(O==null)return O;var J=[],be=0;return G(O,J,"","",function(Z){return le.call(E,Z,be++)}),J}function Q(O){if(O._status===-1){var le=O._result;le=le(),le.then(function(E){(O._status===0||O._status===-1)&&(O._status=1,O._result=E)},function(E){(O._status===0||O._status===-1)&&(O._status=2,O._result=E)}),O._status===-1&&(O._status=0,O._result=le)}if(O._status===1)return O._result.default;throw O._result}var fe=typeof reportError=="function"?reportError:function(O){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var le=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof O=="object"&&O!==null&&typeof O.message=="string"?String(O.message):String(O),error:O});if(!window.dispatchEvent(le))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",O);return}console.error(O)},k={map:B,forEach:function(O,le,E){B(O,function(){le.apply(this,arguments)},E)},count:function(O){var le=0;return B(O,function(){le++}),le},toArray:function(O){return B(O,function(le){return le})||[]},only:function(O){if(!I(O))throw Error("React.Children.only expected to receive a single React element child.");return O}};return Ve.Activity=b,Ve.Children=k,Ve.Component=T,Ve.Fragment=r,Ve.Profiler=u,Ve.PureComponent=D,Ve.StrictMode=a,Ve.Suspense=p,Ve.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=U,Ve.__COMPILER_RUNTIME={__proto__:null,c:function(O){return U.H.useMemoCache(O)}},Ve.cache=function(O){return function(){return O.apply(null,arguments)}},Ve.cacheSignal=function(){return null},Ve.cloneElement=function(O,le,E){if(O==null)throw Error("The argument must be a React element, but you passed "+O+".");var J=R({},O.props),be=O.key;if(le!=null)for(Z in le.key!==void 0&&(be=""+le.key),le)!X.call(le,Z)||Z==="key"||Z==="__self"||Z==="__source"||Z==="ref"&&le.ref===void 0||(J[Z]=le[Z]);var Z=arguments.length-2;if(Z===1)J.children=E;else if(1<Z){for(var ne=Array(Z),ge=0;ge<Z;ge++)ne[ge]=arguments[ge+2];J.children=ne}return H(O.type,be,J)},Ve.createContext=function(O){return O={$$typeof:c,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null},O.Provider=O,O.Consumer={$$typeof:d,_context:O},O},Ve.createElement=function(O,le,E){var J,be={},Z=null;if(le!=null)for(J in le.key!==void 0&&(Z=""+le.key),le)X.call(le,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(be[J]=le[J]);var ne=arguments.length-2;if(ne===1)be.children=E;else if(1<ne){for(var ge=Array(ne),Y=0;Y<ne;Y++)ge[Y]=arguments[Y+2];be.children=ge}if(O&&O.defaultProps)for(J in ne=O.defaultProps,ne)be[J]===void 0&&(be[J]=ne[J]);return H(O,Z,be)},Ve.createRef=function(){return{current:null}},Ve.forwardRef=function(O){return{$$typeof:h,render:O}},Ve.isValidElement=I,Ve.lazy=function(O){return{$$typeof:y,_payload:{_status:-1,_result:O},_init:Q}},Ve.memo=function(O,le){return{$$typeof:m,type:O,compare:le===void 0?null:le}},Ve.startTransition=function(O){var le=U.T,E={};U.T=E;try{var J=O(),be=U.S;be!==null&&be(E,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(N,fe)}catch(Z){fe(Z)}finally{le!==null&&E.types!==null&&(le.types=E.types),U.T=le}},Ve.unstable_useCacheRefresh=function(){return U.H.useCacheRefresh()},Ve.use=function(O){return U.H.use(O)},Ve.useActionState=function(O,le,E){return U.H.useActionState(O,le,E)},Ve.useCallback=function(O,le){return U.H.useCallback(O,le)},Ve.useContext=function(O){return U.H.useContext(O)},Ve.useDebugValue=function(){},Ve.useDeferredValue=function(O,le){return U.H.useDeferredValue(O,le)},Ve.useEffect=function(O,le){return U.H.useEffect(O,le)},Ve.useEffectEvent=function(O){return U.H.useEffectEvent(O)},Ve.useId=function(){return U.H.useId()},Ve.useImperativeHandle=function(O,le,E){return U.H.useImperativeHandle(O,le,E)},Ve.useInsertionEffect=function(O,le){return U.H.useInsertionEffect(O,le)},Ve.useLayoutEffect=function(O,le){return U.H.useLayoutEffect(O,le)},Ve.useMemo=function(O,le){return U.H.useMemo(O,le)},Ve.useOptimistic=function(O,le){return U.H.useOptimistic(O,le)},Ve.useReducer=function(O,le,E){return U.H.useReducer(O,le,E)},Ve.useRef=function(O){return U.H.useRef(O)},Ve.useState=function(O){return U.H.useState(O)},Ve.useSyncExternalStore=function(O,le,E){return U.H.useSyncExternalStore(O,le,E)},Ve.useTransition=function(){return U.H.useTransition()},Ve.version="19.2.6",Ve}var Bg;function hf(){return Bg||(Bg=1,Gc.exports=C1()),Gc.exports}var E1=hf();const S=jo(E1);let za,ko=null;const N1=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Db=/^\/p\/([0-9a-f-]{36})(\/.*)$/;function vl(t){return typeof t=="string"&&N1.test(t)}function Ks(t){if(t!==null&&!vl(t))throw new Error("项目标识无效。");ko=t}function Na(){return ko}function po(){return{workspace:za??"",projectId:ko}}function Zs(t){za=void 0}function mo(){return za}function Ug(t=za){return t?{"X-CodeShell-Workspace":encodeURIComponent(t)}:{}}function Mb(t){return/^\/api\/v1\/(?:auth|projects|environment)(?:\/|\?|$)/.test(t)||/^\/api\/v1\/cloud-browser\/environment(?:\?|$)/.test(t)||/^\/api\/v1\/desktop\/session(?:\?|$)/.test(t)}function A1(t){const i=Db.exec(t);return!!i&&vl(i[1])}function xt(t,i=za,r=ko){const a=Db.exec(t),u=a?a[2]:t;if(a&&!vl(a[1])||!u.startsWith("/api/v1/")&&u!=="/ws"||/[\\\r\n]/.test(t))throw new Error("Workspace URLs must use the local API");const d=new URL(u,"http://codeshell.invalid");if(d.pathname!==u.split(/[?#]/,1)[0])throw new Error("Workspace URLs must use the local API");if(Mb(u))return u;if(a)return t;if(r!==null&&!vl(r))throw new Error("项目标识无效。");return i&&u.startsWith("/api/v1/")&&d.searchParams.set("workspace",i),`${r?`/p/${r}`:""}${d.pathname}${d.search}${d.hash}`}class Xe extends Error{constructor(i,r,a,u){super(i),this.status=r,this.code=a,this.retryAfterMs=u}status;code;retryAfterMs}class Ob extends Error{constructor(){super("服务端返回了无效的登录状态,请稍后重试。")}}async function Ue(t,i={},r){const a=r?Ug(r.workspace):Ug(),u={...i};if(Object.keys(a).length&&!Mb(t)&&!A1(t)&&!t.includes("workspace=")){const h=new Headers(i.headers);for(const[p,m]of Object.entries(a))h.has(p)||h.set(p,m);u.headers=h}const d=await fetch(r?xt(t,r.workspace,r.projectId):xt(t,""),{...u,credentials:"same-origin",cache:"no-store"}),c=await d.json().catch(()=>({}));if(!d.ok){const h=typeof c.error=="string"?c.error:c.error?.message;throw new Xe(h??c.message??`请求失败(${d.status})`,d.status,typeof c.code=="string"?c.code:void 0,typeof c.retryAfterMs=="number"?c.retryAfterMs:void 0)}return c}function Vd(t,i={}){return Ue(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async function T1(){try{const t=await Ue("/api/v1/auth/status"),i=()=>new Ob;if(!t||typeof t.initialized!="boolean"||typeof t.authenticated!="boolean"||t.mode!==void 0&&t.mode!=="cloud-account")throw i();if(t.mode==="cloud-account"){if(!t.initialized||!t.authenticated&&t.session!==void 0)throw i();let r;if(t.authenticated){const a=t.session,u=/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/,d=c=>{if(typeof c!="string")return!1;try{const h=new URL(c);return h.origin===c&&!h.username&&!h.password&&(h.protocol==="https:"||h.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(h.hostname))}catch{return!1}};if(!a||Array.isArray(a)||a.kind!=="cloud-management"||![a.id,a.installationId,a.accountId,a.managementEpoch].every(c=>typeof c=="string"&&u.test(c))||!d(a.audience)||!d(a.accountOrigin)||typeof window<"u"&&a.audience!==window.location.origin||!Number.isSafeInteger(a.expiresAt)||a.expiresAt<=Date.now())throw i();r={id:a.id,kind:"cloud-management",audience:a.audience,installationId:a.installationId,accountOrigin:a.accountOrigin,accountId:a.accountId,managementEpoch:a.managementEpoch,expiresAt:a.expiresAt}}return{initialized:!0,authenticated:t.authenticated,mode:"cloud-account",...r?{cloudSession:r}:{}}}return{initialized:t.initialized,authenticated:t.authenticated,...t.host==="hub"||t.host==="desktop"?{host:t.host}:{},...t.session?{session:t.session}:{}}}catch(t){if(t instanceof Xe&&t.status===404)return null;throw t}}function R1(t,i){const r=new URLSearchParams(t.hash.replace(/^#/,"")),a=r.get("setup")??"";if(r.has("setup")){r.delete("setup");const u=r.toString();i.replaceState(i.state,"",`${t.pathname}${t.search}${u?`#${u}`:""}`)}return a}function _a(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=crypto.getRandomValues(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;const i=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}async function z1(t,i={}){const r=i.scope??po();return Ue(xt(`/api/v1/uploads/${_a()}`,r.workspace,r.projectId),{method:"PUT",headers:{"Content-Type":t.type||"application/octet-stream","X-File-Name":encodeURIComponent(t.name)},body:t,signal:i.signal})}function _1(t){try{const i=new URL(t??"");return(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))&&!i.username&&!i.password?i.href:void 0}catch{return}}function Vc(t,i){const r=t.authModes?.filter(a=>a.available&&(!i||a.methodId===i));return r?.find(a=>a.preferred)??r?.[0]}function ki(t){if(t.state==="pending"){if(t.step)return t.step;if(t.redirect)return{id:t.id,kind:"redirect",...t.redirect};if(t.prompt)return{id:t.id,kind:"device-code",...t.prompt}}}const D1=new Set(["redirect","device-code","qr-code","credential-input","local-session","consent","processing"]);function M1(t,i){if(typeof t.id!="string"||!t.id||i&&t.id!==i)throw new Error("授权响应与当前连接不匹配。");if(!["pending","connected","failed","cancelled"].includes(t.state))throw new Error("无法识别授权状态,请更新客户端。");if(t.state==="connected"&&!t.connection)throw new Error("服务尚未确认连接已保存,请刷新后重试。");if(t.state==="connected"&&(t.connection?.providerId!==t.providerId||t.methodId&&t.connection.methodId!==t.methodId))throw new Error("保存的连接与当前授权不匹配。");const r=ki(t);if(t.state==="pending"&&(!r||!D1.has(r.kind)))throw new Error("当前客户端不支持这个授权步骤,请更新客户端。");if(r&&(!r.id||!Number.isFinite(Date.parse(r.expiresAt))))throw new Error("授权步骤缺少有效期限,请重新连接。");if(t.expiresAt&&(!Number.isFinite(Date.parse(t.expiresAt))||r&&Date.parse(r.expiresAt)>Date.parse(t.expiresAt)))throw new Error("授权任务的有效期限无效,请重新连接。")}class O1{constructor(i,r={}){this.transport=i,this.options=r}transport;options;value={busy:!1};listeners=new Set;timer;generation=0;disposed=!1;binding;getSnapshot=()=>this.value;subscribe=i=>(this.listeners.add(i),()=>this.listeners.delete(i));publish(i){if(!this.disposed){this.value=i;for(const r of this.listeners)r()}}stop(){return clearTimeout(this.timer),++this.generation}current(i){return!this.disposed&&i===this.generation}deadline(i){const r=ki(i);return Math.min(i.expiresAt?Date.parse(i.expiresAt):1/0,r?Date.parse(r.expiresAt):1/0)}accept(i,r,a){if(this.current(r)){if(M1(i,a),this.binding&&(i.providerId!==this.binding.providerId||i.methodId&&i.methodId!==this.binding.methodId))throw new Error("授权响应与当前服务不匹配。");this.publish({authorization:i,busy:!1}),i.state==="pending"&&this.schedule(r)}}schedule(i,r=this.options.pollIntervalMs??2e3){const a=this.value.authorization;if(!this.current(i)||a?.state!=="pending")return;const u=this.deadline(a)-Date.now();if(u<=0){this.stop(),this.publish({busy:!1,authorization:{...a,state:"failed",step:void 0,prompt:void 0,redirect:void 0,errorCode:"authorization_expired"}}),this.transport.cancel(a.id).catch(()=>{});return}const d=ki(a),c=d&&["credential-input","local-session","consent"].includes(d.kind);this.timer=setTimeout(()=>{c?this.schedule(i):this.poll(i)},Math.min(r,u))}async poll(i){const r=this.value.authorization;if(!(!this.current(i)||r?.state!=="pending")){if(this.deadline(r)<=Date.now()){this.schedule(i);return}try{const a=await this.transport.status(r.id);this.accept(a,i,r.id)}catch(a){if(!this.current(i))return;this.publish({...this.value,busy:!1,error:Js(a)});const u=a?.status;u!==401&&u!==404&&this.schedule(i,this.options.retryIntervalMs??4e3)}}}async begin(i,r){if(this.disposed||this.value.busy||this.value.authorization?.state==="pending")return;const a=this.stop();this.binding=i,this.publish({busy:!0});try{const u=await this.transport.begin(i,r);if(!this.current(a)){u.state==="pending"&&this.transport.cancel(u.id).catch(()=>{});return}try{this.accept(u,a)}catch(d){throw u.state==="pending"&&this.transport.cancel(u.id).catch(()=>{}),d}return u}catch(u){this.current(a)&&this.publish({busy:!1,error:Js(u)})}}async respond(i){const r=this.value.authorization,a=r&&ki(r);if(this.disposed||this.value.busy||r?.state!=="pending"||!a||a.id!==i.stepId)return;if(this.deadline(r)<=Date.now()){this.schedule(this.generation);return}const u=this.stop();this.publish({authorization:r,busy:!0});try{const d=await this.transport.respond(r.id,i);return this.accept(d,u,r.id),this.current(u)?d:void 0}catch(d){this.current(u)&&(this.publish({authorization:r,busy:!1,error:Js(d)}),this.timer=setTimeout(()=>{this.poll(u)},this.options.retryIntervalMs??4e3))}}async cancel(){const i=this.value.authorization,r=this.stop();if(i?.state!=="pending"){this.publish({busy:!1});return}this.publish({authorization:i,busy:!0});try{const a=await this.transport.cancel(i.id);if(!this.current(r))return;this.publish({busy:!1,authorization:a??{...i,state:"cancelled",step:void 0,prompt:void 0,redirect:void 0}})}catch(a){this.current(r)&&(this.publish({authorization:i,busy:!1,error:Js(a)}),this.schedule(r,this.options.retryIntervalMs??4e3))}}clearError(){this.publish({...this.value,error:void 0})}reset(){this.value.busy||this.value.authorization?.state==="pending"||(this.stop(),this.publish({busy:!1}))}dispose(){const i=this.value.authorization;this.stop(),this.disposed=!0,this.listeners.clear(),i?.state==="pending"&&this.transport.cancel(i.id).catch(()=>{})}}function Js(t){return t instanceof Error?t:new Error("连接操作失败,请重试。")}const $d="codeshell.remote-link.authorization.v1",pf="/api/v1/links/authorizations/",Yd="[a-f0-9-]{36}",L1=new RegExp(`^(?:/p/${Yd})?${pf}${Yd}$`);function mf(t){return t==="/link/callback"?"/":t==="/mobile/link/callback"?"/mobile/":void 0}function B1(t,i){const r=new URL(t),a=new URL(i);if(r.origin!==a.origin||r.pathname!=="/oauth/authorize"||r.username||r.password||r.hash||r.protocol!=="https:"&&!(r.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(r.hostname)))throw new Error("授权地址无效,请检查 Link 服务配置。");return r}function U1(t,i,r,a=window.location.origin,u=window.sessionStorage){const d=ki(t);if(d?.kind!=="redirect"||!new RegExp(`^${Yd}$`).test(t.id))throw new Error("授权请求无效。");const c=B1(d.authorizationUrl,i),h=c.searchParams.get("state"),p=c.searchParams.get("redirect_uri"),m=Date.parse(d.expiresAt),y=p?mf(new URL(p,a).pathname):void 0;if(!h||!p||!y||p!==`${a}${y}link/callback`||y==="/mobile/"&&r.projectId!==null||c.searchParams.getAll("state").length!==1||c.searchParams.getAll("redirect_uri").length!==1||!Number.isFinite(m)||m<=Date.now())throw new Error("授权回调地址或有效期无效,请检查服务配置。");const b=xt(pf+t.id,r.workspace,r.projectId),v=new URLSearchParams({view:"links",...r.projectId?{project:r.projectId}:{},...y==="/mobile/"?{workspace:r.workspace}:{}});return u.setItem($d,JSON.stringify({target:b,state:h,redirectUri:p,returnUrl:`${y}?${v}`,expiresAt:m,providerId:t.providerId})),c.href}function I1(t,i,r){const a=mf(t.pathname);if(!a)return;const u=t.href;i.replaceState(i.state,"",t.pathname);try{const d=r.getItem($d);r.removeItem($d);const c=JSON.parse(d??"null");if(!c||!Number.isFinite(c.expiresAt)||c.expiresAt<=Date.now())throw new Error;const h=new URL(u),p=new URL(c.target,t.origin),m=new URL(c.returnUrl,t.origin);if(c.redirectUri!==`${t.origin}${t.pathname}`||h.origin!==t.origin||h.hash||h.searchParams.getAll("state").length!==1||h.searchParams.get("state")!==c.state||p.origin!==t.origin||!L1.test(p.pathname)||p.hash||p.username||p.password||[...p.searchParams.keys()].some(y=>y!=="workspace")||p.searchParams.getAll("workspace").length>1||m.origin!==t.origin||m.pathname!==a||m.username||m.password||m.hash||[...m.searchParams.keys()].some(y=>!(a==="/mobile/"?["workspace","view"]:["project","view"]).includes(y))||m.searchParams.getAll("view").length!==1||m.searchParams.get("view")!=="links"||a==="/mobile/"&&(!p.pathname.startsWith(pf)||m.searchParams.getAll("workspace").length!==1||m.searchParams.get("workspace")!==(p.searchParams.get("workspace")??"")))throw new Error;return{callbackUrl:u,pending:c,denied:h.searchParams.has("error")}}catch{return{error:"找不到匹配的授权,或授权已过期。请返回原项目重新连接。",home:a}}}async function q1(t){const i=new URL(t.pending.target,window.location.origin),r=Lb(i);return t.denied?(await Ue(t.pending.target,{method:"DELETE"},r),{id:"",providerId:t.pending.providerId??"",state:"cancelled"}):(i.pathname+="/complete",Ue(i.pathname+i.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:t.callbackUrl})},r))}function Lb(t){return{workspace:t.searchParams.get("workspace")??"",projectId:/^\/p\/([a-f0-9-]{36})\//.exec(t.pathname)?.[1]??null}}function H1(t){const i=new URL(t.pending.target,window.location.origin);return Ue(t.pending.target,{},Lb(i))}function G1(){const t=mf(window.location.pathname);if(t)try{return I1(window.location,window.history,window.sessionStorage)}catch{return window.history.replaceState(window.history.state,"",window.location.pathname),{error:"浏览器无法读取原授权记录。请允许此站点保存临时数据后重新连接。",home:t}}}function V1({callback:t}){const i=S.useRef(void 0),[r,a]=S.useState(),[u,d]=S.useState("error"in t?t.error:""),[c,h]=S.useState(!1),p=b=>d(b instanceof Xe&&b.status===401?"原登录已失效。请返回工作台登录,并重新发起授权。":b instanceof Error?b.message:"无法确认授权结果,请检查结果或返回项目重新连接。"),m=b=>{if(b.state==="connected"&&!b.connection){p(new Error("服务尚未确认连接已保存,请检查授权结果。"));return}a(b),d("")};S.useEffect(()=>{if("error"in t)return;let b=!0;return i.current??=q1(t),i.current.then(v=>{b&&m(v)},v=>{b&&p(v)}),()=>{b=!1}},[t]);const y=!r&&!u;return s.jsx("main",{className:"auth-page",children:s.jsxs("section",{className:"auth-card",children:[s.jsx("h1",{children:"Link 授权"}),y&&s.jsx("p",{role:"status",children:"正在确认授权并保存到原项目…"}),r?.state==="connected"&&s.jsxs("p",{role:"status",children:["已连接 ",r.connection?.account?.label??r.connection?.providerId,",授权已保存到原项目。"]}),r?.previousGrantRevocationPending&&s.jsx("p",{role:"alert",children:"新连接已保存。有遗留授权等待撤销,项目所在环境将自动重试,重启后仍会继续;也可在 Link 服务中撤销。"}),r?.state==="cancelled"&&s.jsx("p",{role:"status",children:"授权已取消,没有新增连接。"}),r?.state==="failed"&&s.jsx("p",{role:"alert",children:"授权未完成。请返回原项目重新连接。"}),r?.state==="pending"&&s.jsx("p",{role:"status",children:"服务端尚未确认完成。可以稍后检查结果,或返回项目重新发起授权。"}),u&&s.jsx("p",{className:"form-error",role:"alert",children:u}),!("error"in t)&&(u||r?.state==="pending")&&s.jsx("button",{disabled:c,onClick:()=>{c||(h(!0),H1(t).then(m,p).finally(()=>h(!1)))},children:c?"正在查询…":"检查授权结果"}),!y&&s.jsx("a",{href:"error"in t?t.home??"/":t.pending.returnUrl,children:"返回原项目"})]})})}var $c={exports:{}},pa={},Yc={exports:{}},Fc={};var Ig;function $1(){return Ig||(Ig=1,(function(t){function i(G,B){var Q=G.length;G.push(B);e:for(;0<Q;){var fe=Q-1>>>1,k=G[fe];if(0<u(k,B))G[fe]=B,G[Q]=k,Q=fe;else break e}}function r(G){return G.length===0?null:G[0]}function a(G){if(G.length===0)return null;var B=G[0],Q=G.pop();if(Q!==B){G[0]=Q;e:for(var fe=0,k=G.length,O=k>>>1;fe<O;){var le=2*(fe+1)-1,E=G[le],J=le+1,be=G[J];if(0>u(E,Q))J<k&&0>u(be,E)?(G[fe]=be,G[J]=Q,fe=J):(G[fe]=E,G[le]=Q,fe=le);else if(J<k&&0>u(be,Q))G[fe]=be,G[J]=Q,fe=J;else break e}}return B}function u(G,B){var Q=G.sortIndex-B.sortIndex;return Q!==0?Q:G.id-B.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;t.unstable_now=function(){return d.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],m=[],y=1,b=null,v=3,x=!1,j=!1,R=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function q(G){for(var B=r(m);B!==null;){if(B.callback===null)a(m);else if(B.startTime<=G)a(m),B.sortIndex=B.expirationTime,i(p,B);else break;B=r(m)}}function se(G){if(R=!1,q(G),!j)if(r(p)!==null)j=!0,N||(N=!0,L());else{var B=r(m);B!==null&&ee(se,B.startTime-G)}}var N=!1,U=-1,X=5,H=-1;function A(){return C?!0:!(t.unstable_now()-H<X)}function I(){if(C=!1,N){var G=t.unstable_now();H=G;var B=!0;try{e:{j=!1,R&&(R=!1,_(U),U=-1),x=!0;var Q=v;try{t:{for(q(G),b=r(p);b!==null&&!(b.expirationTime>G&&A());){var fe=b.callback;if(typeof fe=="function"){b.callback=null,v=b.priorityLevel;var k=fe(b.expirationTime<=G);if(G=t.unstable_now(),typeof k=="function"){b.callback=k,q(G),B=!0;break t}b===r(p)&&a(p),q(G)}else a(p);b=r(p)}if(b!==null)B=!0;else{var O=r(m);O!==null&&ee(se,O.startTime-G),B=!1}}break e}finally{b=null,v=Q,x=!1}B=void 0}}finally{B?L():N=!1}}}var L;if(typeof D=="function")L=function(){D(I)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,W=P.port2;P.port1.onmessage=I,L=function(){W.postMessage(null)}}else L=function(){T(I,0)};function ee(G,B){U=T(function(){G(t.unstable_now())},B)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(G){G.callback=null},t.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<G?Math.floor(1e3/G):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_next=function(G){switch(v){case 1:case 2:case 3:var B=3;break;default:B=v}var Q=v;v=B;try{return G()}finally{v=Q}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(G,B){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var Q=v;v=G;try{return B()}finally{v=Q}},t.unstable_scheduleCallback=function(G,B,Q){var fe=t.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?fe+Q:fe):Q=fe,G){case 1:var k=-1;break;case 2:k=250;break;case 5:k=1073741823;break;case 4:k=1e4;break;default:k=5e3}return k=Q+k,G={id:y++,callback:B,priorityLevel:G,startTime:Q,expirationTime:k,sortIndex:-1},Q>fe?(G.sortIndex=Q,i(m,G),r(p)===null&&G===r(m)&&(R?(_(U),U=-1):R=!0,ee(se,Q-fe))):(G.sortIndex=k,i(p,G),j||x||(j=!0,N||(N=!0,L()))),G},t.unstable_shouldYield=A,t.unstable_wrapCallback=function(G){var B=v;return function(){var Q=v;v=B;try{return G.apply(this,arguments)}finally{v=Q}}}})(Fc)),Fc}var qg;function Y1(){return qg||(qg=1,Yc.exports=$1()),Yc.exports}var Pc={exports:{}},ln={};var Hg;function F1(){if(Hg)return ln;Hg=1;var t=hf();function i(p){var m="https://react.dev/errors/"+p;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+p+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var a={d:{f:r,r:function(){throw Error(i(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},u=Symbol.for("react.portal");function d(p,m,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u,key:b==null?null:""+b,children:p,containerInfo:m,implementation:y}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(p,m){if(p==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return ln.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,ln.createPortal=function(p,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(i(299));return d(p,m,null,y)},ln.flushSync=function(p){var m=c.T,y=a.p;try{if(c.T=null,a.p=2,p)return p()}finally{c.T=m,a.p=y,a.d.f()}},ln.preconnect=function(p,m){typeof p=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,a.d.C(p,m))},ln.prefetchDNS=function(p){typeof p=="string"&&a.d.D(p)},ln.preinit=function(p,m){if(typeof p=="string"&&m&&typeof m.as=="string"){var y=m.as,b=h(y,m.crossOrigin),v=typeof m.integrity=="string"?m.integrity:void 0,x=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?a.d.S(p,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:b,integrity:v,fetchPriority:x}):y==="script"&&a.d.X(p,{crossOrigin:b,integrity:v,fetchPriority:x,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},ln.preinitModule=function(p,m){if(typeof p=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=h(m.as,m.crossOrigin);a.d.M(p,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&a.d.M(p)},ln.preload=function(p,m){if(typeof p=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,b=h(y,m.crossOrigin);a.d.L(p,y,{crossOrigin:b,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},ln.preloadModule=function(p,m){if(typeof p=="string")if(m){var y=h(m.as,m.crossOrigin);a.d.m(p,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else a.d.m(p)},ln.requestFormReset=function(p){a.d.r(p)},ln.unstable_batchedUpdates=function(p,m){return p(m)},ln.useFormState=function(p,m,y){return c.H.useFormState(p,m,y)},ln.useFormStatus=function(){return c.H.useHostTransitionStatus()},ln.version="19.2.6",ln}var Gg;function Bb(){if(Gg)return Pc.exports;Gg=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(i){console.error(i)}}return t(),Pc.exports=F1(),Pc.exports}var Vg;function P1(){if(Vg)return pa;Vg=1;var t=Y1(),i=hf(),r=Bb();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function c(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function p(e){if(d(e)!==e)throw Error(a(188))}function m(e){var n=e.alternate;if(!n){if(n=d(e),n===null)throw Error(a(188));return n!==e?null:e}for(var l=e,o=n;;){var f=l.return;if(f===null)break;var g=f.alternate;if(g===null){if(o=f.return,o!==null){l=o;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===l)return p(f),e;if(g===o)return p(f),n;g=g.sibling}throw Error(a(188))}if(l.return!==o.return)l=f,o=g;else{for(var w=!1,z=f.child;z;){if(z===l){w=!0,l=f,o=g;break}if(z===o){w=!0,o=f,l=g;break}z=z.sibling}if(!w){for(z=g.child;z;){if(z===l){w=!0,l=g,o=f;break}if(z===o){w=!0,o=g,l=f;break}z=z.sibling}if(!w)throw Error(a(189))}}if(l.alternate!==o)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?e:n}function y(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=y(e),n!==null)return n;e=e.sibling}return null}var b=Object.assign,v=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),D=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),H=Symbol.for("react.activity"),A=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function L(e){return e===null||typeof e!="object"?null:(e=I&&e[I]||e["@@iterator"],typeof e=="function"?e:null)}var P=Symbol.for("react.client.reference");function W(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===P?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case T:return"Profiler";case C:return"StrictMode";case se:return"Suspense";case N:return"SuspenseList";case H:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case D:return e.displayName||"Context";case _:return(e._context.displayName||"Context")+".Consumer";case q:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U:return n=e.displayName||null,n!==null?n:W(e.type)||"Memo";case X:n=e._payload,e=e._init;try{return W(e(n))}catch{}}return null}var ee=Array.isArray,G=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},fe=[],k=-1;function O(e){return{current:e}}function le(e){0>k||(e.current=fe[k],fe[k]=null,k--)}function E(e,n){k++,fe[k]=e.current,e.current=n}var J=O(null),be=O(null),Z=O(null),ne=O(null);function ge(e,n){switch(E(Z,n),E(be,e),E(J,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?ig(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=ig(n),e=rg(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}le(J),E(J,e)}function Y(){le(J),le(be),le(Z)}function ve(e){e.memoizedState!==null&&E(ne,e);var n=J.current,l=rg(n,e.type);n!==l&&(E(be,e),E(J,l))}function De(e){be.current===e&&(le(J),le(be)),ne.current===e&&(le(ne),ua._currentValue=Q)}var ze,_e;function qe(e){if(ze===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);ze=n&&n[1]||"",_e=-1<l.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+ze+e+_e}var ot=!1;function $e(e,n){if(!e||ot)return"";ot=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(n){var me=function(){throw Error()};if(Object.defineProperty(me.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(me,[])}catch(ce){var ue=ce}Reflect.construct(e,[],me)}else{try{me.call()}catch(ce){ue=ce}e.call(me.prototype)}}else{try{throw Error()}catch(ce){ue=ce}(me=e())&&typeof me.catch=="function"&&me.catch(function(){})}}catch(ce){if(ce&&ue&&typeof ce.stack=="string")return[ce.stack,ue.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=o.DetermineComponentFrameRoot(),w=g[0],z=g[1];if(w&&z){var $=w.split(`
|
|
4
|
+
`),oe=z.split(`
|
|
5
|
+
`);for(f=o=0;o<$.length&&!$[o].includes("DetermineComponentFrameRoot");)o++;for(;f<oe.length&&!oe[f].includes("DetermineComponentFrameRoot");)f++;if(o===$.length||f===oe.length)for(o=$.length-1,f=oe.length-1;1<=o&&0<=f&&$[o]!==oe[f];)f--;for(;1<=o&&0<=f;o--,f--)if($[o]!==oe[f]){if(o!==1||f!==1)do if(o--,f--,0>f||$[o]!==oe[f]){var he=`
|
|
6
|
+
`+$[o].replace(" at new "," at ");return e.displayName&&he.includes("<anonymous>")&&(he=he.replace("<anonymous>",e.displayName)),he}while(1<=o&&0<=f);break}}}finally{ot=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?qe(l):""}function At(e,n){switch(e.tag){case 26:case 27:case 5:return qe(e.type);case 16:return qe("Lazy");case 13:return e.child!==n&&n!==null?qe("Suspense Fallback"):qe("Suspense");case 19:return qe("SuspenseList");case 0:case 15:return $e(e.type,!1);case 11:return $e(e.type.render,!1);case 1:return $e(e.type,!0);case 31:return qe("Activity");default:return""}}function ut(e){try{var n="",l=null;do n+=At(e,l),l=e,e=e.return;while(e);return n}catch(o){return`
|
|
7
|
+
Error generating stack: `+o.message+`
|
|
8
|
+
`+o.stack}}var Ie=Object.prototype.hasOwnProperty,Lt=t.unstable_scheduleCallback,Ye=t.unstable_cancelCallback,rt=t.unstable_shouldYield,Tt=t.unstable_requestPaint,He=t.unstable_now,ct=t.unstable_getCurrentPriorityLevel,M=t.unstable_ImmediatePriority,ie=t.unstable_UserBlockingPriority,ye=t.unstable_NormalPriority,xe=t.unstable_LowPriority,Ne=t.unstable_IdlePriority,Te=t.log,Fe=t.unstable_setDisableYieldValue,mt=null,dt=null;function ft(e){if(typeof Te=="function"&&Fe(e),dt&&typeof dt.setStrictMode=="function")try{dt.setStrictMode(mt,e)}catch{}}var tt=Math.clz32?Math.clz32:K,Bt=Math.log,yt=Math.LN2;function K(e){return e>>>=0,e===0?32:31-(Bt(e)/yt|0)|0}var je=256,Ee=262144,re=4194304;function we(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Me(e,n,l){var o=e.pendingLanes;if(o===0)return 0;var f=0,g=e.suspendedLanes,w=e.pingedLanes;e=e.warmLanes;var z=o&134217727;return z!==0?(o=z&~g,o!==0?f=we(o):(w&=z,w!==0?f=we(w):l||(l=z&~e,l!==0&&(f=we(l))))):(z=o&~g,z!==0?f=we(z):w!==0?f=we(w):l||(l=o&~e,l!==0&&(f=we(l)))),f===0?0:n!==0&&n!==f&&(n&g)===0&&(g=f&-f,l=n&-n,g>=l||g===32&&(l&4194048)!==0)?n:f}function Ce(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function V(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function de(){var e=re;return re<<=1,(re&62914560)===0&&(re=4194304),e}function ke(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function Ke(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function at(e,n,l,o,f,g){var w=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var z=e.entanglements,$=e.expirationTimes,oe=e.hiddenUpdates;for(l=w&~l;0<l;){var he=31-tt(l),me=1<<he;z[he]=0,$[he]=-1;var ue=oe[he];if(ue!==null)for(oe[he]=null,he=0;he<ue.length;he++){var ce=ue[he];ce!==null&&(ce.lane&=-536870913)}l&=~me}o!==0&&Rt(e,o,0),g!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=g&~(w&~n))}function Rt(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var o=31-tt(n);e.entangledLanes|=n,e.entanglements[o]=e.entanglements[o]|1073741824|l&261930}function kt(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var o=31-tt(l),f=1<<o;f&n|e[o]&n&&(e[o]|=n),l&=~f}}function ni(e,n){var l=n&-n;return l=(l&42)!==0?1:Vt(l),(l&(e.suspendedLanes|n))!==0?0:l}function Vt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Nr(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Ba(){var e=B.p;return e!==0?e:(e=window.event,e===void 0?32:Ng(e.type))}function Wi(e,n){var l=B.p;try{return B.p=e,n()}finally{B.p=l}}var Nn=Math.random().toString(36).slice(2),Ut="__reactFiber$"+Nn,Wt="__reactProps$"+Nn,Yn="__reactContainer$"+Nn,Fn="__reactEvents$"+Nn,fx="__reactListeners$"+Nn,hx="__reactHandles$"+Nn,$f="__reactResources$"+Nn,kl="__reactMarker$"+Nn;function Do(e){delete e[Ut],delete e[Wt],delete e[Fn],delete e[fx],delete e[hx]}function Ar(e){var n=e[Ut];if(n)return n;for(var l=e.parentNode;l;){if(n=l[Yn]||l[Ut]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=dg(e);e!==null;){if(l=e[Ut])return l;e=dg(e)}return n}e=l,l=e.parentNode}return null}function Tr(e){if(e=e[Ut]||e[Yn]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Cl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(a(33))}function Rr(e){var n=e[$f];return n||(n=e[$f]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Kt(e){e[kl]=!0}var Yf=new Set,Ff={};function er(e,n){zr(e,n),zr(e+"Capture",n)}function zr(e,n){for(Ff[e]=n,e=0;e<n.length;e++)Yf.add(n[e])}var px=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Pf={},Qf={};function mx(e){return Ie.call(Qf,e)?!0:Ie.call(Pf,e)?!1:px.test(e)?Qf[e]=!0:(Pf[e]=!0,!1)}function Ua(e,n,l){if(mx(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var o=n.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function Ia(e,n,l){if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+l)}}function ii(e,n,l,o){if(o===null)e.removeAttribute(l);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+o)}}function An(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Xf(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function gx(e,n,l){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var f=o.get,g=o.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(w){l=""+w,g.call(this,w)}}),Object.defineProperty(e,n,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(w){l=""+w},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Mo(e){if(!e._valueTracker){var n=Xf(e)?"checked":"value";e._valueTracker=gx(e,n,""+e[n])}}function Kf(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),o="";return e&&(o=Xf(e)?e.checked?"true":"false":e.value),e=o,e!==l?(n.setValue(e),!0):!1}function qa(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var yx=/[\n"\\]/g;function Tn(e){return e.replace(yx,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Oo(e,n,l,o,f,g,w,z){e.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?e.type=w:e.removeAttribute("type"),n!=null?w==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+An(n)):e.value!==""+An(n)&&(e.value=""+An(n)):w!=="submit"&&w!=="reset"||e.removeAttribute("value"),n!=null?Lo(e,w,An(n)):l!=null?Lo(e,w,An(l)):o!=null&&e.removeAttribute("value"),f==null&&g!=null&&(e.defaultChecked=!!g),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),z!=null&&typeof z!="function"&&typeof z!="symbol"&&typeof z!="boolean"?e.name=""+An(z):e.removeAttribute("name")}function Zf(e,n,l,o,f,g,w,z){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){Mo(e);return}l=l!=null?""+An(l):"",n=n!=null?""+An(n):l,z||n===e.value||(e.value=n),e.defaultValue=n}o=o??f,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=z?e.checked:!!o,e.defaultChecked=!!o,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(e.name=w),Mo(e)}function Lo(e,n,l){n==="number"&&qa(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function _r(e,n,l,o){if(e=e.options,n){n={};for(var f=0;f<l.length;f++)n["$"+l[f]]=!0;for(l=0;l<e.length;l++)f=n.hasOwnProperty("$"+e[l].value),e[l].selected!==f&&(e[l].selected=f),f&&o&&(e[l].defaultSelected=!0)}else{for(l=""+An(l),n=null,f=0;f<e.length;f++){if(e[f].value===l){e[f].selected=!0,o&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function Jf(e,n,l){if(n!=null&&(n=""+An(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+An(l):""}function Wf(e,n,l,o){if(n==null){if(o!=null){if(l!=null)throw Error(a(92));if(ee(o)){if(1<o.length)throw Error(a(93));o=o[0]}l=o}l==null&&(l=""),n=l}l=An(n),e.defaultValue=l,o=e.textContent,o===l&&o!==""&&o!==null&&(e.value=o),Mo(e)}function Dr(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var bx=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function eh(e,n,l){var o=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?o?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":o?e.setProperty(n,l):typeof l!="number"||l===0||bx.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function th(e,n,l){if(n!=null&&typeof n!="object")throw Error(a(62));if(e=e.style,l!=null){for(var o in l)!l.hasOwnProperty(o)||n!=null&&n.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var f in n)o=n[f],n.hasOwnProperty(f)&&l[f]!==o&&eh(e,f,o)}else for(var g in n)n.hasOwnProperty(g)&&eh(e,g,n[g])}function Bo(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var vx=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),xx=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ha(e){return xx.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function ri(){}var Uo=null;function Io(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Mr=null,Or=null;function nh(e){var n=Tr(e);if(n&&(e=n.stateNode)){var l=e[Wt]||null;e:switch(e=n.stateNode,n.type){case"input":if(Oo(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),n=l.name,l.type==="radio"&&n!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+Tn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var o=l[n];if(o!==e&&o.form===e.form){var f=o[Wt]||null;if(!f)throw Error(a(90));Oo(o,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<l.length;n++)o=l[n],o.form===e.form&&Kf(o)}break e;case"textarea":Jf(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&_r(e,!!l.multiple,n,!1)}}}var qo=!1;function ih(e,n,l){if(qo)return e(n,l);qo=!0;try{var o=e(n);return o}finally{if(qo=!1,(Mr!==null||Or!==null)&&(As(),Mr&&(n=Mr,e=Or,Or=Mr=null,nh(n),e)))for(n=0;n<e.length;n++)nh(e[n])}}function El(e,n){var l=e.stateNode;if(l===null)return null;var o=l[Wt]||null;if(o===null)return null;l=o[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(a(231,n,typeof l));return l}var li=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ho=!1;if(li)try{var Nl={};Object.defineProperty(Nl,"passive",{get:function(){Ho=!0}}),window.addEventListener("test",Nl,Nl),window.removeEventListener("test",Nl,Nl)}catch{Ho=!1}var Ei=null,Go=null,Ga=null;function rh(){if(Ga)return Ga;var e,n=Go,l=n.length,o,f="value"in Ei?Ei.value:Ei.textContent,g=f.length;for(e=0;e<l&&n[e]===f[e];e++);var w=l-e;for(o=1;o<=w&&n[l-o]===f[g-o];o++);return Ga=f.slice(e,1<o?1-o:void 0)}function Va(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function $a(){return!0}function lh(){return!1}function cn(e){function n(l,o,f,g,w){this._reactName=l,this._targetInst=f,this.type=o,this.nativeEvent=g,this.target=w,this.currentTarget=null;for(var z in e)e.hasOwnProperty(z)&&(l=e[z],this[z]=l?l(g):g[z]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?$a:lh,this.isPropagationStopped=lh,this}return b(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=$a)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=$a)},persist:function(){},isPersistent:$a}),n}var tr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ya=cn(tr),Al=b({},tr,{view:0,detail:0}),wx=cn(Al),Vo,$o,Tl,Fa=b({},Al,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Fo,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Tl&&(Tl&&e.type==="mousemove"?(Vo=e.screenX-Tl.screenX,$o=e.screenY-Tl.screenY):$o=Vo=0,Tl=e),Vo)},movementY:function(e){return"movementY"in e?e.movementY:$o}}),ah=cn(Fa),Sx=b({},Fa,{dataTransfer:0}),jx=cn(Sx),kx=b({},Al,{relatedTarget:0}),Yo=cn(kx),Cx=b({},tr,{animationName:0,elapsedTime:0,pseudoElement:0}),Ex=cn(Cx),Nx=b({},tr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Ax=cn(Nx),Tx=b({},tr,{data:0}),sh=cn(Tx),Rx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},zx={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},_x={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Dx(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=_x[e])?!!n[e]:!1}function Fo(){return Dx}var Mx=b({},Al,{key:function(e){if(e.key){var n=Rx[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=Va(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?zx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Fo,charCode:function(e){return e.type==="keypress"?Va(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Va(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ox=cn(Mx),Lx=b({},Fa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),oh=cn(Lx),Bx=b({},Al,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Fo}),Ux=cn(Bx),Ix=b({},tr,{propertyName:0,elapsedTime:0,pseudoElement:0}),qx=cn(Ix),Hx=b({},Fa,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Gx=cn(Hx),Vx=b({},tr,{newState:0,oldState:0}),$x=cn(Vx),Yx=[9,13,27,32],Po=li&&"CompositionEvent"in window,Rl=null;li&&"documentMode"in document&&(Rl=document.documentMode);var Fx=li&&"TextEvent"in window&&!Rl,uh=li&&(!Po||Rl&&8<Rl&&11>=Rl),ch=" ",dh=!1;function fh(e,n){switch(e){case"keyup":return Yx.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function hh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Lr=!1;function Px(e,n){switch(e){case"compositionend":return hh(n);case"keypress":return n.which!==32?null:(dh=!0,ch);case"textInput":return e=n.data,e===ch&&dh?null:e;default:return null}}function Qx(e,n){if(Lr)return e==="compositionend"||!Po&&fh(e,n)?(e=rh(),Ga=Go=Ei=null,Lr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return uh&&n.locale!=="ko"?null:n.data;default:return null}}var Xx={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ph(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Xx[e.type]:n==="textarea"}function mh(e,n,l,o){Mr?Or?Or.push(o):Or=[o]:Mr=o,n=Os(n,"onChange"),0<n.length&&(l=new Ya("onChange","change",null,l,o),e.push({event:l,listeners:n}))}var zl=null,_l=null;function Kx(e){Zm(e,0)}function Pa(e){var n=Cl(e);if(Kf(n))return e}function gh(e,n){if(e==="change")return n}var yh=!1;if(li){var Qo;if(li){var Xo="oninput"in document;if(!Xo){var bh=document.createElement("div");bh.setAttribute("oninput","return;"),Xo=typeof bh.oninput=="function"}Qo=Xo}else Qo=!1;yh=Qo&&(!document.documentMode||9<document.documentMode)}function vh(){zl&&(zl.detachEvent("onpropertychange",xh),_l=zl=null)}function xh(e){if(e.propertyName==="value"&&Pa(_l)){var n=[];mh(n,_l,e,Io(e)),ih(Kx,n)}}function Zx(e,n,l){e==="focusin"?(vh(),zl=n,_l=l,zl.attachEvent("onpropertychange",xh)):e==="focusout"&&vh()}function Jx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Pa(_l)}function Wx(e,n){if(e==="click")return Pa(n)}function e0(e,n){if(e==="input"||e==="change")return Pa(n)}function t0(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var bn=typeof Object.is=="function"?Object.is:t0;function Dl(e,n){if(bn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),o=Object.keys(n);if(l.length!==o.length)return!1;for(o=0;o<l.length;o++){var f=l[o];if(!Ie.call(n,f)||!bn(e[f],n[f]))return!1}return!0}function wh(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Sh(e,n){var l=wh(e);e=0;for(var o;l;){if(l.nodeType===3){if(o=e+l.textContent.length,e<=n&&o>=n)return{node:l,offset:n-e};e=o}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=wh(l)}}function jh(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?jh(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function kh(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=qa(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=qa(e.document)}return n}function Ko(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var n0=li&&"documentMode"in document&&11>=document.documentMode,Br=null,Zo=null,Ml=null,Jo=!1;function Ch(e,n,l){var o=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Jo||Br==null||Br!==qa(o)||(o=Br,"selectionStart"in o&&Ko(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Ml&&Dl(Ml,o)||(Ml=o,o=Os(Zo,"onSelect"),0<o.length&&(n=new Ya("onSelect","select",null,n,l),e.push({event:n,listeners:o}),n.target=Br)))}function nr(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var Ur={animationend:nr("Animation","AnimationEnd"),animationiteration:nr("Animation","AnimationIteration"),animationstart:nr("Animation","AnimationStart"),transitionrun:nr("Transition","TransitionRun"),transitionstart:nr("Transition","TransitionStart"),transitioncancel:nr("Transition","TransitionCancel"),transitionend:nr("Transition","TransitionEnd")},Wo={},Eh={};li&&(Eh=document.createElement("div").style,"AnimationEvent"in window||(delete Ur.animationend.animation,delete Ur.animationiteration.animation,delete Ur.animationstart.animation),"TransitionEvent"in window||delete Ur.transitionend.transition);function ir(e){if(Wo[e])return Wo[e];if(!Ur[e])return e;var n=Ur[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in Eh)return Wo[e]=n[l];return e}var Nh=ir("animationend"),Ah=ir("animationiteration"),Th=ir("animationstart"),i0=ir("transitionrun"),r0=ir("transitionstart"),l0=ir("transitioncancel"),Rh=ir("transitionend"),zh=new Map,eu="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");eu.push("scrollEnd");function In(e,n){zh.set(e,n),er(n,[e])}var Qa=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Rn=[],Ir=0,tu=0;function Xa(){for(var e=Ir,n=tu=Ir=0;n<e;){var l=Rn[n];Rn[n++]=null;var o=Rn[n];Rn[n++]=null;var f=Rn[n];Rn[n++]=null;var g=Rn[n];if(Rn[n++]=null,o!==null&&f!==null){var w=o.pending;w===null?f.next=f:(f.next=w.next,w.next=f),o.pending=f}g!==0&&_h(l,f,g)}}function Ka(e,n,l,o){Rn[Ir++]=e,Rn[Ir++]=n,Rn[Ir++]=l,Rn[Ir++]=o,tu|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function nu(e,n,l,o){return Ka(e,n,l,o),Za(e)}function rr(e,n){return Ka(e,null,null,n),Za(e)}function _h(e,n,l){e.lanes|=l;var o=e.alternate;o!==null&&(o.lanes|=l);for(var f=!1,g=e.return;g!==null;)g.childLanes|=l,o=g.alternate,o!==null&&(o.childLanes|=l),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(f=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,f&&n!==null&&(f=31-tt(l),e=g.hiddenUpdates,o=e[f],o===null?e[f]=[n]:o.push(n),n.lane=l|536870912),g):null}function Za(e){if(50<na)throw na=0,dc=null,Error(a(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var qr={};function a0(e,n,l,o){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vn(e,n,l,o){return new a0(e,n,l,o)}function iu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ai(e,n){var l=e.alternate;return l===null?(l=vn(e.tag,n,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=n,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&65011712,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,n=e.dependencies,l.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function Dh(e,n){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,n=l.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function Ja(e,n,l,o,f,g){var w=0;if(o=e,typeof e=="function")iu(e)&&(w=1);else if(typeof e=="string")w=d1(e,l,J.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case H:return e=vn(31,l,n,f),e.elementType=H,e.lanes=g,e;case R:return lr(l.children,f,g,n);case C:w=8,f|=24;break;case T:return e=vn(12,l,n,f|2),e.elementType=T,e.lanes=g,e;case se:return e=vn(13,l,n,f),e.elementType=se,e.lanes=g,e;case N:return e=vn(19,l,n,f),e.elementType=N,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case D:w=10;break e;case _:w=9;break e;case q:w=11;break e;case U:w=14;break e;case X:w=16,o=null;break e}w=29,l=Error(a(130,e===null?"null":typeof e,"")),o=null}return n=vn(w,l,n,f),n.elementType=e,n.type=o,n.lanes=g,n}function lr(e,n,l,o){return e=vn(7,e,o,n),e.lanes=l,e}function ru(e,n,l){return e=vn(6,e,null,n),e.lanes=l,e}function Mh(e){var n=vn(18,null,null,0);return n.stateNode=e,n}function lu(e,n,l){return n=vn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Oh=new WeakMap;function zn(e,n){if(typeof e=="object"&&e!==null){var l=Oh.get(e);return l!==void 0?l:(n={value:e,source:n,stack:ut(n)},Oh.set(e,n),n)}return{value:e,source:n,stack:ut(n)}}var Hr=[],Gr=0,Wa=null,Ol=0,_n=[],Dn=0,Ni=null,Pn=1,Qn="";function si(e,n){Hr[Gr++]=Ol,Hr[Gr++]=Wa,Wa=e,Ol=n}function Lh(e,n,l){_n[Dn++]=Pn,_n[Dn++]=Qn,_n[Dn++]=Ni,Ni=e;var o=Pn;e=Qn;var f=32-tt(o)-1;o&=~(1<<f),l+=1;var g=32-tt(n)+f;if(30<g){var w=f-f%5;g=(o&(1<<w)-1).toString(32),o>>=w,f-=w,Pn=1<<32-tt(n)+f|l<<f|o,Qn=g+e}else Pn=1<<g|l<<f|o,Qn=e}function au(e){e.return!==null&&(si(e,1),Lh(e,1,0))}function su(e){for(;e===Wa;)Wa=Hr[--Gr],Hr[Gr]=null,Ol=Hr[--Gr],Hr[Gr]=null;for(;e===Ni;)Ni=_n[--Dn],_n[Dn]=null,Qn=_n[--Dn],_n[Dn]=null,Pn=_n[--Dn],_n[Dn]=null}function Bh(e,n){_n[Dn++]=Pn,_n[Dn++]=Qn,_n[Dn++]=Ni,Pn=n.id,Qn=n.overflow,Ni=e}var en=null,zt=null,lt=!1,Ai=null,Mn=!1,ou=Error(a(519));function Ti(e){var n=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ll(zn(n,e)),ou}function Uh(e){var n=e.stateNode,l=e.type,o=e.memoizedProps;switch(n[Ut]=e,n[Wt]=o,l){case"dialog":We("cancel",n),We("close",n);break;case"iframe":case"object":case"embed":We("load",n);break;case"video":case"audio":for(l=0;l<ra.length;l++)We(ra[l],n);break;case"source":We("error",n);break;case"img":case"image":case"link":We("error",n),We("load",n);break;case"details":We("toggle",n);break;case"input":We("invalid",n),Zf(n,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":We("invalid",n);break;case"textarea":We("invalid",n),Wf(n,o.value,o.defaultValue,o.children)}l=o.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||o.suppressHydrationWarning===!0||tg(n.textContent,l)?(o.popover!=null&&(We("beforetoggle",n),We("toggle",n)),o.onScroll!=null&&We("scroll",n),o.onScrollEnd!=null&&We("scrollend",n),o.onClick!=null&&(n.onclick=ri),n=!0):n=!1,n||Ti(e,!0)}function Ih(e){for(en=e.return;en;)switch(en.tag){case 5:case 31:case 13:Mn=!1;return;case 27:case 3:Mn=!0;return;default:en=en.return}}function Vr(e){if(e!==en)return!1;if(!lt)return Ih(e),lt=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||Ec(e.type,e.memoizedProps)),l=!l),l&&zt&&Ti(e),Ih(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));zt=cg(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));zt=cg(e)}else n===27?(n=zt,Vi(e.type)?(e=zc,zc=null,zt=e):zt=n):zt=en?Ln(e.stateNode.nextSibling):null;return!0}function ar(){zt=en=null,lt=!1}function uu(){var e=Ai;return e!==null&&(pn===null?pn=e:pn.push.apply(pn,e),Ai=null),e}function Ll(e){Ai===null?Ai=[e]:Ai.push(e)}var cu=O(null),sr=null,oi=null;function Ri(e,n,l){E(cu,n._currentValue),n._currentValue=l}function ui(e){e._currentValue=cu.current,le(cu)}function du(e,n,l){for(;e!==null;){var o=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,o!==null&&(o.childLanes|=n)):o!==null&&(o.childLanes&n)!==n&&(o.childLanes|=n),e===l)break;e=e.return}}function fu(e,n,l,o){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var g=f.dependencies;if(g!==null){var w=f.child;g=g.firstContext;e:for(;g!==null;){var z=g;g=f;for(var $=0;$<n.length;$++)if(z.context===n[$]){g.lanes|=l,z=g.alternate,z!==null&&(z.lanes|=l),du(g.return,l,e),o||(w=null);break e}g=z.next}}else if(f.tag===18){if(w=f.return,w===null)throw Error(a(341));w.lanes|=l,g=w.alternate,g!==null&&(g.lanes|=l),du(w,l,e),w=null}else w=f.child;if(w!==null)w.return=f;else for(w=f;w!==null;){if(w===e){w=null;break}if(f=w.sibling,f!==null){f.return=w.return,w=f;break}w=w.return}f=w}}function $r(e,n,l,o){e=null;for(var f=n,g=!1;f!==null;){if(!g){if((f.flags&524288)!==0)g=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var w=f.alternate;if(w===null)throw Error(a(387));if(w=w.memoizedProps,w!==null){var z=f.type;bn(f.pendingProps.value,w.value)||(e!==null?e.push(z):e=[z])}}else if(f===ne.current){if(w=f.alternate,w===null)throw Error(a(387));w.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(ua):e=[ua])}f=f.return}e!==null&&fu(n,e,l,o),n.flags|=262144}function es(e){for(e=e.firstContext;e!==null;){if(!bn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function or(e){sr=e,oi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function tn(e){return qh(sr,e)}function ts(e,n){return sr===null&&or(e),qh(e,n)}function qh(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},oi===null){if(e===null)throw Error(a(308));oi=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else oi=oi.next=n;return l}var s0=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,o){e.push(o)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},o0=t.unstable_scheduleCallback,u0=t.unstable_NormalPriority,$t={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function hu(){return{controller:new s0,data:new Map,refCount:0}}function Bl(e){e.refCount--,e.refCount===0&&o0(u0,function(){e.controller.abort()})}var Ul=null,pu=0,Yr=0,Fr=null;function c0(e,n){if(Ul===null){var l=Ul=[];pu=0,Yr=yc(),Fr={status:"pending",value:void 0,then:function(o){l.push(o)}}}return pu++,n.then(Hh,Hh),n}function Hh(){if(--pu===0&&Ul!==null){Fr!==null&&(Fr.status="fulfilled");var e=Ul;Ul=null,Yr=0,Fr=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function d0(e,n){var l=[],o={status:"pending",value:null,reason:null,then:function(f){l.push(f)}};return e.then(function(){o.status="fulfilled",o.value=n;for(var f=0;f<l.length;f++)(0,l[f])(n)},function(f){for(o.status="rejected",o.reason=f,f=0;f<l.length;f++)(0,l[f])(void 0)}),o}var Gh=G.S;G.S=function(e,n){Cm=He(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&c0(e,n),Gh!==null&&Gh(e,n)};var ur=O(null);function mu(){var e=ur.current;return e!==null?e:Ct.pooledCache}function ns(e,n){n===null?E(ur,ur.current):E(ur,n.pool)}function Vh(){var e=mu();return e===null?null:{parent:$t._currentValue,pool:e}}var Pr=Error(a(460)),gu=Error(a(474)),is=Error(a(542)),rs={then:function(){}};function $h(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Yh(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(ri,ri),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Ph(e),e;default:if(typeof n.status=="string")n.then(ri,ri);else{if(e=Ct,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=n,e.status="pending",e.then(function(o){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=o}},function(o){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=o}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Ph(e),e}throw dr=n,Pr}}function cr(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(dr=l,Pr):l}}var dr=null;function Fh(){if(dr===null)throw Error(a(459));var e=dr;return dr=null,e}function Ph(e){if(e===Pr||e===is)throw Error(a(483))}var Qr=null,Il=0;function ls(e){var n=Il;return Il+=1,Qr===null&&(Qr=[]),Yh(Qr,e,n)}function ql(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function as(e,n){throw n.$$typeof===v?Error(a(525)):(e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Qh(e){function n(te,F){if(e){var ae=te.deletions;ae===null?(te.deletions=[F],te.flags|=16):ae.push(F)}}function l(te,F){if(!e)return null;for(;F!==null;)n(te,F),F=F.sibling;return null}function o(te){for(var F=new Map;te!==null;)te.key!==null?F.set(te.key,te):F.set(te.index,te),te=te.sibling;return F}function f(te,F){return te=ai(te,F),te.index=0,te.sibling=null,te}function g(te,F,ae){return te.index=ae,e?(ae=te.alternate,ae!==null?(ae=ae.index,ae<F?(te.flags|=67108866,F):ae):(te.flags|=67108866,F)):(te.flags|=1048576,F)}function w(te){return e&&te.alternate===null&&(te.flags|=67108866),te}function z(te,F,ae,pe){return F===null||F.tag!==6?(F=ru(ae,te.mode,pe),F.return=te,F):(F=f(F,ae),F.return=te,F)}function $(te,F,ae,pe){var Oe=ae.type;return Oe===R?he(te,F,ae.props.children,pe,ae.key):F!==null&&(F.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===X&&cr(Oe)===F.type)?(F=f(F,ae.props),ql(F,ae),F.return=te,F):(F=Ja(ae.type,ae.key,ae.props,null,te.mode,pe),ql(F,ae),F.return=te,F)}function oe(te,F,ae,pe){return F===null||F.tag!==4||F.stateNode.containerInfo!==ae.containerInfo||F.stateNode.implementation!==ae.implementation?(F=lu(ae,te.mode,pe),F.return=te,F):(F=f(F,ae.children||[]),F.return=te,F)}function he(te,F,ae,pe,Oe){return F===null||F.tag!==7?(F=lr(ae,te.mode,pe,Oe),F.return=te,F):(F=f(F,ae),F.return=te,F)}function me(te,F,ae){if(typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint")return F=ru(""+F,te.mode,ae),F.return=te,F;if(typeof F=="object"&&F!==null){switch(F.$$typeof){case x:return ae=Ja(F.type,F.key,F.props,null,te.mode,ae),ql(ae,F),ae.return=te,ae;case j:return F=lu(F,te.mode,ae),F.return=te,F;case X:return F=cr(F),me(te,F,ae)}if(ee(F)||L(F))return F=lr(F,te.mode,ae,null),F.return=te,F;if(typeof F.then=="function")return me(te,ls(F),ae);if(F.$$typeof===D)return me(te,ts(te,F),ae);as(te,F)}return null}function ue(te,F,ae,pe){var Oe=F!==null?F.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint")return Oe!==null?null:z(te,F,""+ae,pe);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case x:return ae.key===Oe?$(te,F,ae,pe):null;case j:return ae.key===Oe?oe(te,F,ae,pe):null;case X:return ae=cr(ae),ue(te,F,ae,pe)}if(ee(ae)||L(ae))return Oe!==null?null:he(te,F,ae,pe,null);if(typeof ae.then=="function")return ue(te,F,ls(ae),pe);if(ae.$$typeof===D)return ue(te,F,ts(te,ae),pe);as(te,ae)}return null}function ce(te,F,ae,pe,Oe){if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return te=te.get(ae)||null,z(F,te,""+pe,Oe);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case x:return te=te.get(pe.key===null?ae:pe.key)||null,$(F,te,pe,Oe);case j:return te=te.get(pe.key===null?ae:pe.key)||null,oe(F,te,pe,Oe);case X:return pe=cr(pe),ce(te,F,ae,pe,Oe)}if(ee(pe)||L(pe))return te=te.get(ae)||null,he(F,te,pe,Oe,null);if(typeof pe.then=="function")return ce(te,F,ae,ls(pe),Oe);if(pe.$$typeof===D)return ce(te,F,ae,ts(F,pe),Oe);as(F,pe)}return null}function Ae(te,F,ae,pe){for(var Oe=null,ht=null,Re=F,Qe=F=0,it=null;Re!==null&&Qe<ae.length;Qe++){Re.index>Qe?(it=Re,Re=null):it=Re.sibling;var pt=ue(te,Re,ae[Qe],pe);if(pt===null){Re===null&&(Re=it);break}e&&Re&&pt.alternate===null&&n(te,Re),F=g(pt,F,Qe),ht===null?Oe=pt:ht.sibling=pt,ht=pt,Re=it}if(Qe===ae.length)return l(te,Re),lt&&si(te,Qe),Oe;if(Re===null){for(;Qe<ae.length;Qe++)Re=me(te,ae[Qe],pe),Re!==null&&(F=g(Re,F,Qe),ht===null?Oe=Re:ht.sibling=Re,ht=Re);return lt&&si(te,Qe),Oe}for(Re=o(Re);Qe<ae.length;Qe++)it=ce(Re,te,Qe,ae[Qe],pe),it!==null&&(e&&it.alternate!==null&&Re.delete(it.key===null?Qe:it.key),F=g(it,F,Qe),ht===null?Oe=it:ht.sibling=it,ht=it);return e&&Re.forEach(function(Qi){return n(te,Qi)}),lt&&si(te,Qe),Oe}function Be(te,F,ae,pe){if(ae==null)throw Error(a(151));for(var Oe=null,ht=null,Re=F,Qe=F=0,it=null,pt=ae.next();Re!==null&&!pt.done;Qe++,pt=ae.next()){Re.index>Qe?(it=Re,Re=null):it=Re.sibling;var Qi=ue(te,Re,pt.value,pe);if(Qi===null){Re===null&&(Re=it);break}e&&Re&&Qi.alternate===null&&n(te,Re),F=g(Qi,F,Qe),ht===null?Oe=Qi:ht.sibling=Qi,ht=Qi,Re=it}if(pt.done)return l(te,Re),lt&&si(te,Qe),Oe;if(Re===null){for(;!pt.done;Qe++,pt=ae.next())pt=me(te,pt.value,pe),pt!==null&&(F=g(pt,F,Qe),ht===null?Oe=pt:ht.sibling=pt,ht=pt);return lt&&si(te,Qe),Oe}for(Re=o(Re);!pt.done;Qe++,pt=ae.next())pt=ce(Re,te,Qe,pt.value,pe),pt!==null&&(e&&pt.alternate!==null&&Re.delete(pt.key===null?Qe:pt.key),F=g(pt,F,Qe),ht===null?Oe=pt:ht.sibling=pt,ht=pt);return e&&Re.forEach(function(S1){return n(te,S1)}),lt&&si(te,Qe),Oe}function jt(te,F,ae,pe){if(typeof ae=="object"&&ae!==null&&ae.type===R&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case x:e:{for(var Oe=ae.key;F!==null;){if(F.key===Oe){if(Oe=ae.type,Oe===R){if(F.tag===7){l(te,F.sibling),pe=f(F,ae.props.children),pe.return=te,te=pe;break e}}else if(F.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===X&&cr(Oe)===F.type){l(te,F.sibling),pe=f(F,ae.props),ql(pe,ae),pe.return=te,te=pe;break e}l(te,F);break}else n(te,F);F=F.sibling}ae.type===R?(pe=lr(ae.props.children,te.mode,pe,ae.key),pe.return=te,te=pe):(pe=Ja(ae.type,ae.key,ae.props,null,te.mode,pe),ql(pe,ae),pe.return=te,te=pe)}return w(te);case j:e:{for(Oe=ae.key;F!==null;){if(F.key===Oe)if(F.tag===4&&F.stateNode.containerInfo===ae.containerInfo&&F.stateNode.implementation===ae.implementation){l(te,F.sibling),pe=f(F,ae.children||[]),pe.return=te,te=pe;break e}else{l(te,F);break}else n(te,F);F=F.sibling}pe=lu(ae,te.mode,pe),pe.return=te,te=pe}return w(te);case X:return ae=cr(ae),jt(te,F,ae,pe)}if(ee(ae))return Ae(te,F,ae,pe);if(L(ae)){if(Oe=L(ae),typeof Oe!="function")throw Error(a(150));return ae=Oe.call(ae),Be(te,F,ae,pe)}if(typeof ae.then=="function")return jt(te,F,ls(ae),pe);if(ae.$$typeof===D)return jt(te,F,ts(te,ae),pe);as(te,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint"?(ae=""+ae,F!==null&&F.tag===6?(l(te,F.sibling),pe=f(F,ae),pe.return=te,te=pe):(l(te,F),pe=ru(ae,te.mode,pe),pe.return=te,te=pe),w(te)):l(te,F)}return function(te,F,ae,pe){try{Il=0;var Oe=jt(te,F,ae,pe);return Qr=null,Oe}catch(Re){if(Re===Pr||Re===is)throw Re;var ht=vn(29,Re,null,te.mode);return ht.lanes=pe,ht.return=te,ht}}}var fr=Qh(!0),Xh=Qh(!1),zi=!1;function yu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bu(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function _i(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Di(e,n,l){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(gt&2)!==0){var f=o.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),o.pending=n,n=Za(e),_h(e,null,l),n}return Ka(e,o,n,l),Za(e)}function Hl(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var o=n.lanes;o&=e.pendingLanes,l|=o,n.lanes=l,kt(e,l)}}function vu(e,n){var l=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,l===o)){var f=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var w={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?f=g=w:g=g.next=w,l=l.next}while(l!==null);g===null?f=g=n:g=g.next=n}else f=g=n;l={baseState:o.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:o.shared,callbacks:o.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var xu=!1;function Gl(){if(xu){var e=Fr;if(e!==null)throw e}}function Vl(e,n,l,o){xu=!1;var f=e.updateQueue;zi=!1;var g=f.firstBaseUpdate,w=f.lastBaseUpdate,z=f.shared.pending;if(z!==null){f.shared.pending=null;var $=z,oe=$.next;$.next=null,w===null?g=oe:w.next=oe,w=$;var he=e.alternate;he!==null&&(he=he.updateQueue,z=he.lastBaseUpdate,z!==w&&(z===null?he.firstBaseUpdate=oe:z.next=oe,he.lastBaseUpdate=$))}if(g!==null){var me=f.baseState;w=0,he=oe=$=null,z=g;do{var ue=z.lane&-536870913,ce=ue!==z.lane;if(ce?(nt&ue)===ue:(o&ue)===ue){ue!==0&&ue===Yr&&(xu=!0),he!==null&&(he=he.next={lane:0,tag:z.tag,payload:z.payload,callback:null,next:null});e:{var Ae=e,Be=z;ue=n;var jt=l;switch(Be.tag){case 1:if(Ae=Be.payload,typeof Ae=="function"){me=Ae.call(jt,me,ue);break e}me=Ae;break e;case 3:Ae.flags=Ae.flags&-65537|128;case 0:if(Ae=Be.payload,ue=typeof Ae=="function"?Ae.call(jt,me,ue):Ae,ue==null)break e;me=b({},me,ue);break e;case 2:zi=!0}}ue=z.callback,ue!==null&&(e.flags|=64,ce&&(e.flags|=8192),ce=f.callbacks,ce===null?f.callbacks=[ue]:ce.push(ue))}else ce={lane:ue,tag:z.tag,payload:z.payload,callback:z.callback,next:null},he===null?(oe=he=ce,$=me):he=he.next=ce,w|=ue;if(z=z.next,z===null){if(z=f.shared.pending,z===null)break;ce=z,z=ce.next,ce.next=null,f.lastBaseUpdate=ce,f.shared.pending=null}}while(!0);he===null&&($=me),f.baseState=$,f.firstBaseUpdate=oe,f.lastBaseUpdate=he,g===null&&(f.shared.lanes=0),Ui|=w,e.lanes=w,e.memoizedState=me}}function Kh(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function Zh(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)Kh(l[e],n)}var Xr=O(null),ss=O(0);function Jh(e,n){e=bi,E(ss,e),E(Xr,n),bi=e|n.baseLanes}function wu(){E(ss,bi),E(Xr,Xr.current)}function Su(){bi=ss.current,le(Xr),le(ss)}var xn=O(null),On=null;function Mi(e){var n=e.alternate;E(Ht,Ht.current&1),E(xn,e),On===null&&(n===null||Xr.current!==null||n.memoizedState!==null)&&(On=e)}function ju(e){E(Ht,Ht.current),E(xn,e),On===null&&(On=e)}function Wh(e){e.tag===22?(E(Ht,Ht.current),E(xn,e),On===null&&(On=e)):Oi()}function Oi(){E(Ht,Ht.current),E(xn,xn.current)}function wn(e){le(xn),On===e&&(On=null),le(Ht)}var Ht=O(0);function os(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Tc(l)||Rc(l)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var ci=0,Pe=null,wt=null,Yt=null,us=!1,Kr=!1,hr=!1,cs=0,$l=0,Zr=null,f0=0;function It(){throw Error(a(321))}function ku(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!bn(e[l],n[l]))return!1;return!0}function Cu(e,n,l,o,f,g){return ci=g,Pe=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,G.H=e===null||e.memoizedState===null?Lp:qu,hr=!1,g=l(o,f),hr=!1,Kr&&(g=tp(n,l,o,f)),ep(e),g}function ep(e){G.H=Pl;var n=wt!==null&&wt.next!==null;if(ci=0,Yt=wt=Pe=null,us=!1,$l=0,Zr=null,n)throw Error(a(300));e===null||Ft||(e=e.dependencies,e!==null&&es(e)&&(Ft=!0))}function tp(e,n,l,o){Pe=e;var f=0;do{if(Kr&&(Zr=null),$l=0,Kr=!1,25<=f)throw Error(a(301));if(f+=1,Yt=wt=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}G.H=Bp,g=n(l,o)}while(Kr);return g}function h0(){var e=G.H,n=e.useState()[0];return n=typeof n.then=="function"?Yl(n):n,e=e.useState()[0],(wt!==null?wt.memoizedState:null)!==e&&(Pe.flags|=1024),n}function Eu(){var e=cs!==0;return cs=0,e}function Nu(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function Au(e){if(us){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}us=!1}ci=0,Yt=wt=Pe=null,Kr=!1,$l=cs=0,Zr=null}function on(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Yt===null?Pe.memoizedState=Yt=e:Yt=Yt.next=e,Yt}function Gt(){if(wt===null){var e=Pe.alternate;e=e!==null?e.memoizedState:null}else e=wt.next;var n=Yt===null?Pe.memoizedState:Yt.next;if(n!==null)Yt=n,wt=e;else{if(e===null)throw Pe.alternate===null?Error(a(467)):Error(a(310));wt=e,e={memoizedState:wt.memoizedState,baseState:wt.baseState,baseQueue:wt.baseQueue,queue:wt.queue,next:null},Yt===null?Pe.memoizedState=Yt=e:Yt=Yt.next=e}return Yt}function ds(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Yl(e){var n=$l;return $l+=1,Zr===null&&(Zr=[]),e=Yh(Zr,e,n),n=Pe,(Yt===null?n.memoizedState:Yt.next)===null&&(n=n.alternate,G.H=n===null||n.memoizedState===null?Lp:qu),e}function fs(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Yl(e);if(e.$$typeof===D)return tn(e)}throw Error(a(438,String(e)))}function Tu(e){var n=null,l=Pe.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var o=Pe.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(n={data:o.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=ds(),Pe.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),o=0;o<e;o++)l[o]=A;return n.index++,l}function di(e,n){return typeof n=="function"?n(e):n}function hs(e){var n=Gt();return Ru(n,wt,e)}function Ru(e,n,l){var o=e.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=l;var f=e.baseQueue,g=o.pending;if(g!==null){if(f!==null){var w=f.next;f.next=g.next,g.next=w}n.baseQueue=f=g,o.pending=null}if(g=e.baseState,f===null)e.memoizedState=g;else{n=f.next;var z=w=null,$=null,oe=n,he=!1;do{var me=oe.lane&-536870913;if(me!==oe.lane?(nt&me)===me:(ci&me)===me){var ue=oe.revertLane;if(ue===0)$!==null&&($=$.next={lane:0,revertLane:0,gesture:null,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null}),me===Yr&&(he=!0);else if((ci&ue)===ue){oe=oe.next,ue===Yr&&(he=!0);continue}else me={lane:0,revertLane:oe.revertLane,gesture:null,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null},$===null?(z=$=me,w=g):$=$.next=me,Pe.lanes|=ue,Ui|=ue;me=oe.action,hr&&l(g,me),g=oe.hasEagerState?oe.eagerState:l(g,me)}else ue={lane:me,revertLane:oe.revertLane,gesture:oe.gesture,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null},$===null?(z=$=ue,w=g):$=$.next=ue,Pe.lanes|=me,Ui|=me;oe=oe.next}while(oe!==null&&oe!==n);if($===null?w=g:$.next=z,!bn(g,e.memoizedState)&&(Ft=!0,he&&(l=Fr,l!==null)))throw l;e.memoizedState=g,e.baseState=w,e.baseQueue=$,o.lastRenderedState=g}return f===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function zu(e){var n=Gt(),l=n.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=e;var o=l.dispatch,f=l.pending,g=n.memoizedState;if(f!==null){l.pending=null;var w=f=f.next;do g=e(g,w.action),w=w.next;while(w!==f);bn(g,n.memoizedState)||(Ft=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),l.lastRenderedState=g}return[g,o]}function np(e,n,l){var o=Pe,f=Gt(),g=lt;if(g){if(l===void 0)throw Error(a(407));l=l()}else l=n();var w=!bn((wt||f).memoizedState,l);if(w&&(f.memoizedState=l,Ft=!0),f=f.queue,Mu(lp.bind(null,o,f,e),[e]),f.getSnapshot!==n||w||Yt!==null&&Yt.memoizedState.tag&1){if(o.flags|=2048,Jr(9,{destroy:void 0},rp.bind(null,o,f,l,n),null),Ct===null)throw Error(a(349));g||(ci&127)!==0||ip(o,n,l)}return l}function ip(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=Pe.updateQueue,n===null?(n=ds(),Pe.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function rp(e,n,l,o){n.value=l,n.getSnapshot=o,ap(n)&&sp(e)}function lp(e,n,l){return l(function(){ap(n)&&sp(e)})}function ap(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!bn(e,l)}catch{return!0}}function sp(e){var n=rr(e,2);n!==null&&mn(n,e,2)}function _u(e){var n=on();if(typeof e=="function"){var l=e;if(e=l(),hr){ft(!0);try{l()}finally{ft(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:di,lastRenderedState:e},n}function op(e,n,l,o){return e.baseState=l,Ru(e,wt,typeof o=="function"?o:di)}function p0(e,n,l,o,f){if(gs(e))throw Error(a(485));if(e=n.action,e!==null){var g={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(w){g.listeners.push(w)}};G.T!==null?l(!0):g.isTransition=!1,o(g),l=n.pending,l===null?(g.next=n.pending=g,up(n,g)):(g.next=l.next,n.pending=l.next=g)}}function up(e,n){var l=n.action,o=n.payload,f=e.state;if(n.isTransition){var g=G.T,w={};G.T=w;try{var z=l(f,o),$=G.S;$!==null&&$(w,z),cp(e,n,z)}catch(oe){Du(e,n,oe)}finally{g!==null&&w.types!==null&&(g.types=w.types),G.T=g}}else try{g=l(f,o),cp(e,n,g)}catch(oe){Du(e,n,oe)}}function cp(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(o){dp(e,n,o)},function(o){return Du(e,n,o)}):dp(e,n,l)}function dp(e,n,l){n.status="fulfilled",n.value=l,fp(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,up(e,l)))}function Du(e,n,l){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do n.status="rejected",n.reason=l,fp(n),n=n.next;while(n!==o)}e.action=null}function fp(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function hp(e,n){return n}function pp(e,n){if(lt){var l=Ct.formState;if(l!==null){e:{var o=Pe;if(lt){if(zt){t:{for(var f=zt,g=Mn;f.nodeType!==8;){if(!g){f=null;break t}if(f=Ln(f.nextSibling),f===null){f=null;break t}}g=f.data,f=g==="F!"||g==="F"?f:null}if(f){zt=Ln(f.nextSibling),o=f.data==="F!";break e}}Ti(o)}o=!1}o&&(n=l[0])}}return l=on(),l.memoizedState=l.baseState=n,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:hp,lastRenderedState:n},l.queue=o,l=Dp.bind(null,Pe,o),o.dispatch=l,o=_u(!1),g=Iu.bind(null,Pe,!1,o.queue),o=on(),f={state:n,dispatch:null,action:e,pending:null},o.queue=f,l=p0.bind(null,Pe,f,g,l),f.dispatch=l,o.memoizedState=e,[n,l,!1]}function mp(e){var n=Gt();return gp(n,wt,e)}function gp(e,n,l){if(n=Ru(e,n,hp)[0],e=hs(di)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var o=Yl(n)}catch(w){throw w===Pr?is:w}else o=n;n=Gt();var f=n.queue,g=f.dispatch;return l!==n.memoizedState&&(Pe.flags|=2048,Jr(9,{destroy:void 0},m0.bind(null,f,l),null)),[o,g,e]}function m0(e,n){e.action=n}function yp(e){var n=Gt(),l=wt;if(l!==null)return gp(n,l,e);Gt(),n=n.memoizedState,l=Gt();var o=l.queue.dispatch;return l.memoizedState=e,[n,o,!1]}function Jr(e,n,l,o){return e={tag:e,create:l,deps:o,inst:n,next:null},n=Pe.updateQueue,n===null&&(n=ds(),Pe.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(o=l.next,l.next=e,e.next=o,n.lastEffect=e),e}function bp(){return Gt().memoizedState}function ps(e,n,l,o){var f=on();Pe.flags|=e,f.memoizedState=Jr(1|n,{destroy:void 0},l,o===void 0?null:o)}function ms(e,n,l,o){var f=Gt();o=o===void 0?null:o;var g=f.memoizedState.inst;wt!==null&&o!==null&&ku(o,wt.memoizedState.deps)?f.memoizedState=Jr(n,g,l,o):(Pe.flags|=e,f.memoizedState=Jr(1|n,g,l,o))}function vp(e,n){ps(8390656,8,e,n)}function Mu(e,n){ms(2048,8,e,n)}function g0(e){Pe.flags|=4;var n=Pe.updateQueue;if(n===null)n=ds(),Pe.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function xp(e){var n=Gt().memoizedState;return g0({ref:n,nextImpl:e}),function(){if((gt&2)!==0)throw Error(a(440));return n.impl.apply(void 0,arguments)}}function wp(e,n){return ms(4,2,e,n)}function Sp(e,n){return ms(4,4,e,n)}function jp(e,n){if(typeof n=="function"){e=e();var l=n(e);return function(){typeof l=="function"?l():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function kp(e,n,l){l=l!=null?l.concat([e]):null,ms(4,4,jp.bind(null,n,e),l)}function Ou(){}function Cp(e,n){var l=Gt();n=n===void 0?null:n;var o=l.memoizedState;return n!==null&&ku(n,o[1])?o[0]:(l.memoizedState=[e,n],e)}function Ep(e,n){var l=Gt();n=n===void 0?null:n;var o=l.memoizedState;if(n!==null&&ku(n,o[1]))return o[0];if(o=e(),hr){ft(!0);try{e()}finally{ft(!1)}}return l.memoizedState=[o,n],o}function Lu(e,n,l){return l===void 0||(ci&1073741824)!==0&&(nt&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=Nm(),Pe.lanes|=e,Ui|=e,l)}function Np(e,n,l,o){return bn(l,n)?l:Xr.current!==null?(e=Lu(e,l,o),bn(e,n)||(Ft=!0),e):(ci&42)===0||(ci&1073741824)!==0&&(nt&261930)===0?(Ft=!0,e.memoizedState=l):(e=Nm(),Pe.lanes|=e,Ui|=e,n)}function Ap(e,n,l,o,f){var g=B.p;B.p=g!==0&&8>g?g:8;var w=G.T,z={};G.T=z,Iu(e,!1,n,l);try{var $=f(),oe=G.S;if(oe!==null&&oe(z,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var he=d0($,o);Fl(e,n,he,kn(e))}else Fl(e,n,o,kn(e))}catch(me){Fl(e,n,{then:function(){},status:"rejected",reason:me},kn())}finally{B.p=g,w!==null&&z.types!==null&&(w.types=z.types),G.T=w}}function y0(){}function Bu(e,n,l,o){if(e.tag!==5)throw Error(a(476));var f=Tp(e).queue;Ap(e,f,n,Q,l===null?y0:function(){return Rp(e),l(o)})}function Tp(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:di,lastRenderedState:Q},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:di,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function Rp(e){var n=Tp(e);n.next===null&&(n=e.alternate.memoizedState),Fl(e,n.next.queue,{},kn())}function Uu(){return tn(ua)}function zp(){return Gt().memoizedState}function _p(){return Gt().memoizedState}function b0(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=kn();e=_i(l);var o=Di(n,e,l);o!==null&&(mn(o,n,l),Hl(o,n,l)),n={cache:hu()},e.payload=n;return}n=n.return}}function v0(e,n,l){var o=kn();l={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},gs(e)?Mp(n,l):(l=nu(e,n,l,o),l!==null&&(mn(l,e,o),Op(l,n,o)))}function Dp(e,n,l){var o=kn();Fl(e,n,l,o)}function Fl(e,n,l,o){var f={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(gs(e))Mp(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var w=n.lastRenderedState,z=g(w,l);if(f.hasEagerState=!0,f.eagerState=z,bn(z,w))return Ka(e,n,f,0),Ct===null&&Xa(),!1}catch{}if(l=nu(e,n,f,o),l!==null)return mn(l,e,o),Op(l,n,o),!0}return!1}function Iu(e,n,l,o){if(o={lane:2,revertLane:yc(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},gs(e)){if(n)throw Error(a(479))}else n=nu(e,l,o,2),n!==null&&mn(n,e,2)}function gs(e){var n=e.alternate;return e===Pe||n!==null&&n===Pe}function Mp(e,n){Kr=us=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Op(e,n,l){if((l&4194048)!==0){var o=n.lanes;o&=e.pendingLanes,l|=o,n.lanes=l,kt(e,l)}}var Pl={readContext:tn,use:fs,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useLayoutEffect:It,useInsertionEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useSyncExternalStore:It,useId:It,useHostTransitionStatus:It,useFormState:It,useActionState:It,useOptimistic:It,useMemoCache:It,useCacheRefresh:It};Pl.useEffectEvent=It;var Lp={readContext:tn,use:fs,useCallback:function(e,n){return on().memoizedState=[e,n===void 0?null:n],e},useContext:tn,useEffect:vp,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,ps(4194308,4,jp.bind(null,n,e),l)},useLayoutEffect:function(e,n){return ps(4194308,4,e,n)},useInsertionEffect:function(e,n){ps(4,2,e,n)},useMemo:function(e,n){var l=on();n=n===void 0?null:n;var o=e();if(hr){ft(!0);try{e()}finally{ft(!1)}}return l.memoizedState=[o,n],o},useReducer:function(e,n,l){var o=on();if(l!==void 0){var f=l(n);if(hr){ft(!0);try{l(n)}finally{ft(!1)}}}else f=n;return o.memoizedState=o.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},o.queue=e,e=e.dispatch=v0.bind(null,Pe,e),[o.memoizedState,e]},useRef:function(e){var n=on();return e={current:e},n.memoizedState=e},useState:function(e){e=_u(e);var n=e.queue,l=Dp.bind(null,Pe,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:Ou,useDeferredValue:function(e,n){var l=on();return Lu(l,e,n)},useTransition:function(){var e=_u(!1);return e=Ap.bind(null,Pe,e.queue,!0,!1),on().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var o=Pe,f=on();if(lt){if(l===void 0)throw Error(a(407));l=l()}else{if(l=n(),Ct===null)throw Error(a(349));(nt&127)!==0||ip(o,n,l)}f.memoizedState=l;var g={value:l,getSnapshot:n};return f.queue=g,vp(lp.bind(null,o,g,e),[e]),o.flags|=2048,Jr(9,{destroy:void 0},rp.bind(null,o,g,l,n),null),l},useId:function(){var e=on(),n=Ct.identifierPrefix;if(lt){var l=Qn,o=Pn;l=(o&~(1<<32-tt(o)-1)).toString(32)+l,n="_"+n+"R_"+l,l=cs++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=f0++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:Uu,useFormState:pp,useActionState:pp,useOptimistic:function(e){var n=on();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=Iu.bind(null,Pe,!0,l),l.dispatch=n,[e,n]},useMemoCache:Tu,useCacheRefresh:function(){return on().memoizedState=b0.bind(null,Pe)},useEffectEvent:function(e){var n=on(),l={impl:e};return n.memoizedState=l,function(){if((gt&2)!==0)throw Error(a(440));return l.impl.apply(void 0,arguments)}}},qu={readContext:tn,use:fs,useCallback:Cp,useContext:tn,useEffect:Mu,useImperativeHandle:kp,useInsertionEffect:wp,useLayoutEffect:Sp,useMemo:Ep,useReducer:hs,useRef:bp,useState:function(){return hs(di)},useDebugValue:Ou,useDeferredValue:function(e,n){var l=Gt();return Np(l,wt.memoizedState,e,n)},useTransition:function(){var e=hs(di)[0],n=Gt().memoizedState;return[typeof e=="boolean"?e:Yl(e),n]},useSyncExternalStore:np,useId:zp,useHostTransitionStatus:Uu,useFormState:mp,useActionState:mp,useOptimistic:function(e,n){var l=Gt();return op(l,wt,e,n)},useMemoCache:Tu,useCacheRefresh:_p};qu.useEffectEvent=xp;var Bp={readContext:tn,use:fs,useCallback:Cp,useContext:tn,useEffect:Mu,useImperativeHandle:kp,useInsertionEffect:wp,useLayoutEffect:Sp,useMemo:Ep,useReducer:zu,useRef:bp,useState:function(){return zu(di)},useDebugValue:Ou,useDeferredValue:function(e,n){var l=Gt();return wt===null?Lu(l,e,n):Np(l,wt.memoizedState,e,n)},useTransition:function(){var e=zu(di)[0],n=Gt().memoizedState;return[typeof e=="boolean"?e:Yl(e),n]},useSyncExternalStore:np,useId:zp,useHostTransitionStatus:Uu,useFormState:yp,useActionState:yp,useOptimistic:function(e,n){var l=Gt();return wt!==null?op(l,wt,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:Tu,useCacheRefresh:_p};Bp.useEffectEvent=xp;function Hu(e,n,l,o){n=e.memoizedState,l=l(o,n),l=l==null?n:b({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var Gu={enqueueSetState:function(e,n,l){e=e._reactInternals;var o=kn(),f=_i(o);f.payload=n,l!=null&&(f.callback=l),n=Di(e,f,o),n!==null&&(mn(n,e,o),Hl(n,e,o))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var o=kn(),f=_i(o);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=Di(e,f,o),n!==null&&(mn(n,e,o),Hl(n,e,o))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=kn(),o=_i(l);o.tag=2,n!=null&&(o.callback=n),n=Di(e,o,l),n!==null&&(mn(n,e,l),Hl(n,e,l))}};function Up(e,n,l,o,f,g,w){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,g,w):n.prototype&&n.prototype.isPureReactComponent?!Dl(l,o)||!Dl(f,g):!0}function Ip(e,n,l,o){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,o),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,o),n.state!==e&&Gu.enqueueReplaceState(n,n.state,null)}function pr(e,n){var l=n;if("ref"in n){l={};for(var o in n)o!=="ref"&&(l[o]=n[o])}if(e=e.defaultProps){l===n&&(l=b({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function qp(e){Qa(e)}function Hp(e){console.error(e)}function Gp(e){Qa(e)}function ys(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(o){setTimeout(function(){throw o})}}function Vp(e,n,l){try{var o=e.onCaughtError;o(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Vu(e,n,l){return l=_i(l),l.tag=3,l.payload={element:null},l.callback=function(){ys(e,n)},l}function $p(e){return e=_i(e),e.tag=3,e}function Yp(e,n,l,o){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var g=o.value;e.payload=function(){return f(g)},e.callback=function(){Vp(n,l,o)}}var w=l.stateNode;w!==null&&typeof w.componentDidCatch=="function"&&(e.callback=function(){Vp(n,l,o),typeof f!="function"&&(Ii===null?Ii=new Set([this]):Ii.add(this));var z=o.stack;this.componentDidCatch(o.value,{componentStack:z!==null?z:""})})}function x0(e,n,l,o,f){if(l.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(n=l.alternate,n!==null&&$r(n,l,f,!0),l=xn.current,l!==null){switch(l.tag){case 31:case 13:return On===null?Ts():l.alternate===null&&qt===0&&(qt=3),l.flags&=-257,l.flags|=65536,l.lanes=f,o===rs?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([o]):n.add(o),pc(e,o,f)),!1;case 22:return l.flags|=65536,o===rs?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([o])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([o]):l.add(o)),pc(e,o,f)),!1}throw Error(a(435,l.tag))}return pc(e,o,f),Ts(),!1}if(lt)return n=xn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,o!==ou&&(e=Error(a(422),{cause:o}),Ll(zn(e,l)))):(o!==ou&&(n=Error(a(423),{cause:o}),Ll(zn(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,o=zn(o,l),f=Vu(e.stateNode,o,f),vu(e,f),qt!==4&&(qt=2)),!1;var g=Error(a(520),{cause:o});if(g=zn(g,l),ta===null?ta=[g]:ta.push(g),qt!==4&&(qt=2),n===null)return!0;o=zn(o,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=Vu(l.stateNode,o,e),vu(l,e),!1;case 1:if(n=l.type,g=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Ii===null||!Ii.has(g))))return l.flags|=65536,f&=-f,l.lanes|=f,f=$p(f),Yp(f,e,l,o),vu(l,f),!1}l=l.return}while(l!==null);return!1}var $u=Error(a(461)),Ft=!1;function nn(e,n,l,o){n.child=e===null?Xh(n,null,l,o):fr(n,e.child,l,o)}function Fp(e,n,l,o,f){l=l.render;var g=n.ref;if("ref"in o){var w={};for(var z in o)z!=="ref"&&(w[z]=o[z])}else w=o;return or(n),o=Cu(e,n,l,w,g,f),z=Eu(),e!==null&&!Ft?(Nu(e,n,f),fi(e,n,f)):(lt&&z&&au(n),n.flags|=1,nn(e,n,o,f),n.child)}function Pp(e,n,l,o,f){if(e===null){var g=l.type;return typeof g=="function"&&!iu(g)&&g.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=g,Qp(e,n,g,o,f)):(e=Ja(l.type,null,o,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Ju(e,f)){var w=g.memoizedProps;if(l=l.compare,l=l!==null?l:Dl,l(w,o)&&e.ref===n.ref)return fi(e,n,f)}return n.flags|=1,e=ai(g,o),e.ref=n.ref,e.return=n,n.child=e}function Qp(e,n,l,o,f){if(e!==null){var g=e.memoizedProps;if(Dl(g,o)&&e.ref===n.ref)if(Ft=!1,n.pendingProps=o=g,Ju(e,f))(e.flags&131072)!==0&&(Ft=!0);else return n.lanes=e.lanes,fi(e,n,f)}return Yu(e,n,l,o,f)}function Xp(e,n,l,o){var f=o.children,g=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((n.flags&128)!==0){if(g=g!==null?g.baseLanes|l:l,e!==null){for(o=n.child=e.child,f=0;o!==null;)f=f|o.lanes|o.childLanes,o=o.sibling;o=f&~g}else o=0,n.child=null;return Kp(e,n,g,l,o)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&ns(n,g!==null?g.cachePool:null),g!==null?Jh(n,g):wu(),Wh(n);else return o=n.lanes=536870912,Kp(e,n,g!==null?g.baseLanes|l:l,l,o)}else g!==null?(ns(n,g.cachePool),Jh(n,g),Oi(),n.memoizedState=null):(e!==null&&ns(n,null),wu(),Oi());return nn(e,n,f,l),n.child}function Ql(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Kp(e,n,l,o,f){var g=mu();return g=g===null?null:{parent:$t._currentValue,pool:g},n.memoizedState={baseLanes:l,cachePool:g},e!==null&&ns(n,null),wu(),Wh(n),e!==null&&$r(e,n,o,!0),n.childLanes=f,null}function bs(e,n){return n=xs({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Zp(e,n,l){return fr(n,e.child,null,l),e=bs(n,n.pendingProps),e.flags|=2,wn(n),n.memoizedState=null,e}function w0(e,n,l){var o=n.pendingProps,f=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(lt){if(o.mode==="hidden")return e=bs(n,o),n.lanes=536870912,Ql(null,e);if(ju(n),(e=zt)?(e=ug(e,Mn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Ni!==null?{id:Pn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},l=Mh(e),l.return=n,n.child=l,en=n,zt=null)):e=null,e===null)throw Ti(n);return n.lanes=536870912,null}return bs(n,o)}var g=e.memoizedState;if(g!==null){var w=g.dehydrated;if(ju(n),f)if(n.flags&256)n.flags&=-257,n=Zp(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(a(558));else if(Ft||$r(e,n,l,!1),f=(l&e.childLanes)!==0,Ft||f){if(o=Ct,o!==null&&(w=ni(o,l),w!==0&&w!==g.retryLane))throw g.retryLane=w,rr(e,w),mn(o,e,w),$u;Ts(),n=Zp(e,n,l)}else e=g.treeContext,zt=Ln(w.nextSibling),en=n,lt=!0,Ai=null,Mn=!1,e!==null&&Bh(n,e),n=bs(n,o),n.flags|=4096;return n}return e=ai(e.child,{mode:o.mode,children:o.children}),e.ref=n.ref,n.child=e,e.return=n,e}function vs(e,n){var l=n.ref;if(l===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(a(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function Yu(e,n,l,o,f){return or(n),l=Cu(e,n,l,o,void 0,f),o=Eu(),e!==null&&!Ft?(Nu(e,n,f),fi(e,n,f)):(lt&&o&&au(n),n.flags|=1,nn(e,n,l,f),n.child)}function Jp(e,n,l,o,f,g){return or(n),n.updateQueue=null,l=tp(n,o,l,f),ep(e),o=Eu(),e!==null&&!Ft?(Nu(e,n,g),fi(e,n,g)):(lt&&o&&au(n),n.flags|=1,nn(e,n,l,g),n.child)}function Wp(e,n,l,o,f){if(or(n),n.stateNode===null){var g=qr,w=l.contextType;typeof w=="object"&&w!==null&&(g=tn(w)),g=new l(o,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Gu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=o,g.state=n.memoizedState,g.refs={},yu(n),w=l.contextType,g.context=typeof w=="object"&&w!==null?tn(w):qr,g.state=n.memoizedState,w=l.getDerivedStateFromProps,typeof w=="function"&&(Hu(n,l,w,o),g.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(w=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),w!==g.state&&Gu.enqueueReplaceState(g,g.state,null),Vl(n,o,g,f),Gl(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!0}else if(e===null){g=n.stateNode;var z=n.memoizedProps,$=pr(l,z);g.props=$;var oe=g.context,he=l.contextType;w=qr,typeof he=="object"&&he!==null&&(w=tn(he));var me=l.getDerivedStateFromProps;he=typeof me=="function"||typeof g.getSnapshotBeforeUpdate=="function",z=n.pendingProps!==z,he||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(z||oe!==w)&&Ip(n,g,o,w),zi=!1;var ue=n.memoizedState;g.state=ue,Vl(n,o,g,f),Gl(),oe=n.memoizedState,z||ue!==oe||zi?(typeof me=="function"&&(Hu(n,l,me,o),oe=n.memoizedState),($=zi||Up(n,l,$,o,ue,oe,w))?(he||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(n.flags|=4194308)):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=o,n.memoizedState=oe),g.props=o,g.state=oe,g.context=w,o=$):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{g=n.stateNode,bu(e,n),w=n.memoizedProps,he=pr(l,w),g.props=he,me=n.pendingProps,ue=g.context,oe=l.contextType,$=qr,typeof oe=="object"&&oe!==null&&($=tn(oe)),z=l.getDerivedStateFromProps,(oe=typeof z=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(w!==me||ue!==$)&&Ip(n,g,o,$),zi=!1,ue=n.memoizedState,g.state=ue,Vl(n,o,g,f),Gl();var ce=n.memoizedState;w!==me||ue!==ce||zi||e!==null&&e.dependencies!==null&&es(e.dependencies)?(typeof z=="function"&&(Hu(n,l,z,o),ce=n.memoizedState),(he=zi||Up(n,l,he,o,ue,ce,$)||e!==null&&e.dependencies!==null&&es(e.dependencies))?(oe||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(o,ce,$),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(o,ce,$)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||w===e.memoizedProps&&ue===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||w===e.memoizedProps&&ue===e.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=ce),g.props=o,g.state=ce,g.context=$,o=he):(typeof g.componentDidUpdate!="function"||w===e.memoizedProps&&ue===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||w===e.memoizedProps&&ue===e.memoizedState||(n.flags|=1024),o=!1)}return g=o,vs(e,n),o=(n.flags&128)!==0,g||o?(g=n.stateNode,l=o&&typeof l.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&o?(n.child=fr(n,e.child,null,f),n.child=fr(n,null,l,f)):nn(e,n,l,f),n.memoizedState=g.state,e=n.child):e=fi(e,n,f),e}function em(e,n,l,o){return ar(),n.flags|=256,nn(e,n,l,o),n.child}var Fu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Pu(e){return{baseLanes:e,cachePool:Vh()}}function Qu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=jn),e}function tm(e,n,l){var o=n.pendingProps,f=!1,g=(n.flags&128)!==0,w;if((w=g)||(w=e!==null&&e.memoizedState===null?!1:(Ht.current&2)!==0),w&&(f=!0,n.flags&=-129),w=(n.flags&32)!==0,n.flags&=-33,e===null){if(lt){if(f?Mi(n):Oi(),(e=zt)?(e=ug(e,Mn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Ni!==null?{id:Pn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},l=Mh(e),l.return=n,n.child=l,en=n,zt=null)):e=null,e===null)throw Ti(n);return Rc(e)?n.lanes=32:n.lanes=536870912,null}var z=o.children;return o=o.fallback,f?(Oi(),f=n.mode,z=xs({mode:"hidden",children:z},f),o=lr(o,f,l,null),z.return=n,o.return=n,z.sibling=o,n.child=z,o=n.child,o.memoizedState=Pu(l),o.childLanes=Qu(e,w,l),n.memoizedState=Fu,Ql(null,o)):(Mi(n),Xu(n,z))}var $=e.memoizedState;if($!==null&&(z=$.dehydrated,z!==null)){if(g)n.flags&256?(Mi(n),n.flags&=-257,n=Ku(e,n,l)):n.memoizedState!==null?(Oi(),n.child=e.child,n.flags|=128,n=null):(Oi(),z=o.fallback,f=n.mode,o=xs({mode:"visible",children:o.children},f),z=lr(z,f,l,null),z.flags|=2,o.return=n,z.return=n,o.sibling=z,n.child=o,fr(n,e.child,null,l),o=n.child,o.memoizedState=Pu(l),o.childLanes=Qu(e,w,l),n.memoizedState=Fu,n=Ql(null,o));else if(Mi(n),Rc(z)){if(w=z.nextSibling&&z.nextSibling.dataset,w)var oe=w.dgst;w=oe,o=Error(a(419)),o.stack="",o.digest=w,Ll({value:o,source:null,stack:null}),n=Ku(e,n,l)}else if(Ft||$r(e,n,l,!1),w=(l&e.childLanes)!==0,Ft||w){if(w=Ct,w!==null&&(o=ni(w,l),o!==0&&o!==$.retryLane))throw $.retryLane=o,rr(e,o),mn(w,e,o),$u;Tc(z)||Ts(),n=Ku(e,n,l)}else Tc(z)?(n.flags|=192,n.child=e.child,n=null):(e=$.treeContext,zt=Ln(z.nextSibling),en=n,lt=!0,Ai=null,Mn=!1,e!==null&&Bh(n,e),n=Xu(n,o.children),n.flags|=4096);return n}return f?(Oi(),z=o.fallback,f=n.mode,$=e.child,oe=$.sibling,o=ai($,{mode:"hidden",children:o.children}),o.subtreeFlags=$.subtreeFlags&65011712,oe!==null?z=ai(oe,z):(z=lr(z,f,l,null),z.flags|=2),z.return=n,o.return=n,o.sibling=z,n.child=o,Ql(null,o),o=n.child,z=e.child.memoizedState,z===null?z=Pu(l):(f=z.cachePool,f!==null?($=$t._currentValue,f=f.parent!==$?{parent:$,pool:$}:f):f=Vh(),z={baseLanes:z.baseLanes|l,cachePool:f}),o.memoizedState=z,o.childLanes=Qu(e,w,l),n.memoizedState=Fu,Ql(e.child,o)):(Mi(n),l=e.child,e=l.sibling,l=ai(l,{mode:"visible",children:o.children}),l.return=n,l.sibling=null,e!==null&&(w=n.deletions,w===null?(n.deletions=[e],n.flags|=16):w.push(e)),n.child=l,n.memoizedState=null,l)}function Xu(e,n){return n=xs({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function xs(e,n){return e=vn(22,e,null,n),e.lanes=0,e}function Ku(e,n,l){return fr(n,e.child,null,l),e=Xu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function nm(e,n,l){e.lanes|=n;var o=e.alternate;o!==null&&(o.lanes|=n),du(e.return,n,l)}function Zu(e,n,l,o,f,g){var w=e.memoizedState;w===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:l,tailMode:f,treeForkCount:g}:(w.isBackwards=n,w.rendering=null,w.renderingStartTime=0,w.last=o,w.tail=l,w.tailMode=f,w.treeForkCount=g)}function im(e,n,l){var o=n.pendingProps,f=o.revealOrder,g=o.tail;o=o.children;var w=Ht.current,z=(w&2)!==0;if(z?(w=w&1|2,n.flags|=128):w&=1,E(Ht,w),nn(e,n,o,l),o=lt?Ol:0,!z&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&nm(e,l,n);else if(e.tag===19)nm(e,l,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(l=n.child,f=null;l!==null;)e=l.alternate,e!==null&&os(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),Zu(n,!1,f,l,g,o);break;case"backwards":case"unstable_legacy-backwards":for(l=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&os(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}Zu(n,!0,l,null,g,o);break;case"together":Zu(n,!1,null,null,void 0,o);break;default:n.memoizedState=null}return n.child}function fi(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),Ui|=n.lanes,(l&n.childLanes)===0)if(e!==null){if($r(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,l=ai(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=ai(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function Ju(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&es(e)))}function S0(e,n,l){switch(n.tag){case 3:ge(n,n.stateNode.containerInfo),Ri(n,$t,e.memoizedState.cache),ar();break;case 27:case 5:ve(n);break;case 4:ge(n,n.stateNode.containerInfo);break;case 10:Ri(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,ju(n),null;break;case 13:var o=n.memoizedState;if(o!==null)return o.dehydrated!==null?(Mi(n),n.flags|=128,null):(l&n.child.childLanes)!==0?tm(e,n,l):(Mi(n),e=fi(e,n,l),e!==null?e.sibling:null);Mi(n);break;case 19:var f=(e.flags&128)!==0;if(o=(l&n.childLanes)!==0,o||($r(e,n,l,!1),o=(l&n.childLanes)!==0),f){if(o)return im(e,n,l);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),E(Ht,Ht.current),o)break;return null;case 22:return n.lanes=0,Xp(e,n,l,n.pendingProps);case 24:Ri(n,$t,e.memoizedState.cache)}return fi(e,n,l)}function rm(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Ft=!0;else{if(!Ju(e,l)&&(n.flags&128)===0)return Ft=!1,S0(e,n,l);Ft=(e.flags&131072)!==0}else Ft=!1,lt&&(n.flags&1048576)!==0&&Lh(n,Ol,n.index);switch(n.lanes=0,n.tag){case 16:e:{var o=n.pendingProps;if(e=cr(n.elementType),n.type=e,typeof e=="function")iu(e)?(o=pr(e,o),n.tag=1,n=Wp(null,n,e,o,l)):(n.tag=0,n=Yu(null,n,e,o,l));else{if(e!=null){var f=e.$$typeof;if(f===q){n.tag=11,n=Fp(null,n,e,o,l);break e}else if(f===U){n.tag=14,n=Pp(null,n,e,o,l);break e}}throw n=W(e)||e,Error(a(306,n,""))}}return n;case 0:return Yu(e,n,n.type,n.pendingProps,l);case 1:return o=n.type,f=pr(o,n.pendingProps),Wp(e,n,o,f,l);case 3:e:{if(ge(n,n.stateNode.containerInfo),e===null)throw Error(a(387));o=n.pendingProps;var g=n.memoizedState;f=g.element,bu(e,n),Vl(n,o,null,l);var w=n.memoizedState;if(o=w.cache,Ri(n,$t,o),o!==g.cache&&fu(n,[$t],l,!0),Gl(),o=w.element,g.isDehydrated)if(g={element:o,isDehydrated:!1,cache:w.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=em(e,n,o,l);break e}else if(o!==f){f=zn(Error(a(424)),n),Ll(f),n=em(e,n,o,l);break e}else for(e=n.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,zt=Ln(e.firstChild),en=n,lt=!0,Ai=null,Mn=!0,l=Xh(n,null,o,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(ar(),o===f){n=fi(e,n,l);break e}nn(e,n,o,l)}n=n.child}return n;case 26:return vs(e,n),e===null?(l=mg(n.type,null,n.pendingProps,null))?n.memoizedState=l:lt||(l=n.type,e=n.pendingProps,o=Ls(Z.current).createElement(l),o[Ut]=n,o[Wt]=e,rn(o,l,e),Kt(o),n.stateNode=o):n.memoizedState=mg(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return ve(n),e===null&<&&(o=n.stateNode=fg(n.type,n.pendingProps,Z.current),en=n,Mn=!0,f=zt,Vi(n.type)?(zc=f,zt=Ln(o.firstChild)):zt=f),nn(e,n,n.pendingProps.children,l),vs(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&<&&((f=o=zt)&&(o=J0(o,n.type,n.pendingProps,Mn),o!==null?(n.stateNode=o,en=n,zt=Ln(o.firstChild),Mn=!1,f=!0):f=!1),f||Ti(n)),ve(n),f=n.type,g=n.pendingProps,w=e!==null?e.memoizedProps:null,o=g.children,Ec(f,g)?o=null:w!==null&&Ec(f,w)&&(n.flags|=32),n.memoizedState!==null&&(f=Cu(e,n,h0,null,null,l),ua._currentValue=f),vs(e,n),nn(e,n,o,l),n.child;case 6:return e===null&<&&((e=l=zt)&&(l=W0(l,n.pendingProps,Mn),l!==null?(n.stateNode=l,en=n,zt=null,e=!0):e=!1),e||Ti(n)),null;case 13:return tm(e,n,l);case 4:return ge(n,n.stateNode.containerInfo),o=n.pendingProps,e===null?n.child=fr(n,null,o,l):nn(e,n,o,l),n.child;case 11:return Fp(e,n,n.type,n.pendingProps,l);case 7:return nn(e,n,n.pendingProps,l),n.child;case 8:return nn(e,n,n.pendingProps.children,l),n.child;case 12:return nn(e,n,n.pendingProps.children,l),n.child;case 10:return o=n.pendingProps,Ri(n,n.type,o.value),nn(e,n,o.children,l),n.child;case 9:return f=n.type._context,o=n.pendingProps.children,or(n),f=tn(f),o=o(f),n.flags|=1,nn(e,n,o,l),n.child;case 14:return Pp(e,n,n.type,n.pendingProps,l);case 15:return Qp(e,n,n.type,n.pendingProps,l);case 19:return im(e,n,l);case 31:return w0(e,n,l);case 22:return Xp(e,n,l,n.pendingProps);case 24:return or(n),o=tn($t),e===null?(f=mu(),f===null&&(f=Ct,g=hu(),f.pooledCache=g,g.refCount++,g!==null&&(f.pooledCacheLanes|=l),f=g),n.memoizedState={parent:o,cache:f},yu(n),Ri(n,$t,f)):((e.lanes&l)!==0&&(bu(e,n),Vl(n,null,null,l),Gl()),f=e.memoizedState,g=n.memoizedState,f.parent!==o?(f={parent:o,cache:o},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Ri(n,$t,o)):(o=g.cache,Ri(n,$t,o),o!==f.cache&&fu(n,[$t],l,!0))),nn(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(a(156,n.tag))}function hi(e){e.flags|=4}function Wu(e,n,l,o,f){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(zm())e.flags|=8192;else throw dr=rs,gu}else e.flags&=-16777217}function lm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!xg(n))if(zm())e.flags|=8192;else throw dr=rs,gu}function ws(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?de():536870912,e.lanes|=n,nl|=n)}function Xl(e,n){if(!lt)switch(e.tailMode){case"hidden":n=e.tail;for(var l=null;n!==null;)n.alternate!==null&&(l=n),n=n.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var o=null;l!==null;)l.alternate!==null&&(o=l),l=l.sibling;o===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function _t(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,o=0;if(n)for(var f=e.child;f!==null;)l|=f.lanes|f.childLanes,o|=f.subtreeFlags&65011712,o|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)l|=f.lanes|f.childLanes,o|=f.subtreeFlags,o|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=o,e.childLanes=l,n}function j0(e,n,l){var o=n.pendingProps;switch(su(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _t(n),null;case 1:return _t(n),null;case 3:return l=n.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),ui($t),Y(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Vr(n)?hi(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,uu())),_t(n),null;case 26:var f=n.type,g=n.memoizedState;return e===null?(hi(n),g!==null?(_t(n),lm(n,g)):(_t(n),Wu(n,f,null,o,l))):g?g!==e.memoizedState?(hi(n),_t(n),lm(n,g)):(_t(n),n.flags&=-16777217):(e=e.memoizedProps,e!==o&&hi(n),_t(n),Wu(n,f,e,o,l)),null;case 27:if(De(n),l=Z.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&hi(n);else{if(!o){if(n.stateNode===null)throw Error(a(166));return _t(n),null}e=J.current,Vr(n)?Uh(n):(e=fg(f,o,l),n.stateNode=e,hi(n))}return _t(n),null;case 5:if(De(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&hi(n);else{if(!o){if(n.stateNode===null)throw Error(a(166));return _t(n),null}if(g=J.current,Vr(n))Uh(n);else{var w=Ls(Z.current);switch(g){case 1:g=w.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:g=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":g=w.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":g=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":g=w.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof o.is=="string"?w.createElement("select",{is:o.is}):w.createElement("select"),o.multiple?g.multiple=!0:o.size&&(g.size=o.size);break;default:g=typeof o.is=="string"?w.createElement(f,{is:o.is}):w.createElement(f)}}g[Ut]=n,g[Wt]=o;e:for(w=n.child;w!==null;){if(w.tag===5||w.tag===6)g.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===n)break e;for(;w.sibling===null;){if(w.return===null||w.return===n)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}n.stateNode=g;e:switch(rn(g,f,o),f){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&hi(n)}}return _t(n),Wu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==o&&hi(n);else{if(typeof o!="string"&&n.stateNode===null)throw Error(a(166));if(e=Z.current,Vr(n)){if(e=n.stateNode,l=n.memoizedProps,o=null,f=en,f!==null)switch(f.tag){case 27:case 5:o=f.memoizedProps}e[Ut]=n,e=!!(e.nodeValue===l||o!==null&&o.suppressHydrationWarning===!0||tg(e.nodeValue,l)),e||Ti(n,!0)}else e=Ls(e).createTextNode(o),e[Ut]=n,n.stateNode=e}return _t(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(o=Vr(n),l!==null){if(e===null){if(!o)throw Error(a(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(557));e[Ut]=n}else ar(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;_t(n),e=!1}else l=uu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(wn(n),n):(wn(n),null);if((n.flags&128)!==0)throw Error(a(558))}return _t(n),null;case 13:if(o=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=Vr(n),o!==null&&o.dehydrated!==null){if(e===null){if(!f)throw Error(a(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(a(317));f[Ut]=n}else ar(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;_t(n),f=!1}else f=uu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(wn(n),n):(wn(n),null)}return wn(n),(n.flags&128)!==0?(n.lanes=l,n):(l=o!==null,e=e!==null&&e.memoizedState!==null,l&&(o=n.child,f=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(f=o.alternate.memoizedState.cachePool.pool),g=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),g!==f&&(o.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),ws(n,n.updateQueue),_t(n),null);case 4:return Y(),e===null&&wc(n.stateNode.containerInfo),_t(n),null;case 10:return ui(n.type),_t(n),null;case 19:if(le(Ht),o=n.memoizedState,o===null)return _t(n),null;if(f=(n.flags&128)!==0,g=o.rendering,g===null)if(f)Xl(o,!1);else{if(qt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=os(e),g!==null){for(n.flags|=128,Xl(o,!1),e=g.updateQueue,n.updateQueue=e,ws(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Dh(l,e),l=l.sibling;return E(Ht,Ht.current&1|2),lt&&si(n,o.treeForkCount),n.child}e=e.sibling}o.tail!==null&&He()>Es&&(n.flags|=128,f=!0,Xl(o,!1),n.lanes=4194304)}else{if(!f)if(e=os(g),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,ws(n,e),Xl(o,!0),o.tail===null&&o.tailMode==="hidden"&&!g.alternate&&!lt)return _t(n),null}else 2*He()-o.renderingStartTime>Es&&l!==536870912&&(n.flags|=128,f=!0,Xl(o,!1),n.lanes=4194304);o.isBackwards?(g.sibling=n.child,n.child=g):(e=o.last,e!==null?e.sibling=g:n.child=g,o.last=g)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=He(),e.sibling=null,l=Ht.current,E(Ht,f?l&1|2:l&1),lt&&si(n,o.treeForkCount),e):(_t(n),null);case 22:case 23:return wn(n),Su(),o=n.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(n.flags|=8192):o&&(n.flags|=8192),o?(l&536870912)!==0&&(n.flags&128)===0&&(_t(n),n.subtreeFlags&6&&(n.flags|=8192)):_t(n),l=n.updateQueue,l!==null&&ws(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==l&&(n.flags|=2048),e!==null&&le(ur),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),ui($t),_t(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function k0(e,n){switch(su(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ui($t),Y(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return De(n),null;case 31:if(n.memoizedState!==null){if(wn(n),n.alternate===null)throw Error(a(340));ar()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(wn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));ar()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return le(Ht),null;case 4:return Y(),null;case 10:return ui(n.type),null;case 22:case 23:return wn(n),Su(),e!==null&&le(ur),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return ui($t),null;case 25:return null;default:return null}}function am(e,n){switch(su(n),n.tag){case 3:ui($t),Y();break;case 26:case 27:case 5:De(n);break;case 4:Y();break;case 31:n.memoizedState!==null&&wn(n);break;case 13:wn(n);break;case 19:le(Ht);break;case 10:ui(n.type);break;case 22:case 23:wn(n),Su(),e!==null&&le(ur);break;case 24:ui($t)}}function Kl(e,n){try{var l=n.updateQueue,o=l!==null?l.lastEffect:null;if(o!==null){var f=o.next;l=f;do{if((l.tag&e)===e){o=void 0;var g=l.create,w=l.inst;o=g(),w.destroy=o}l=l.next}while(l!==f)}}catch(z){vt(n,n.return,z)}}function Li(e,n,l){try{var o=n.updateQueue,f=o!==null?o.lastEffect:null;if(f!==null){var g=f.next;o=g;do{if((o.tag&e)===e){var w=o.inst,z=w.destroy;if(z!==void 0){w.destroy=void 0,f=n;var $=l,oe=z;try{oe()}catch(he){vt(f,$,he)}}}o=o.next}while(o!==g)}}catch(he){vt(n,n.return,he)}}function sm(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Zh(n,l)}catch(o){vt(e,e.return,o)}}}function om(e,n,l){l.props=pr(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(o){vt(e,n,o)}}function Zl(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof l=="function"?e.refCleanup=l(o):l.current=o}}catch(f){vt(e,n,f)}}function Xn(e,n){var l=e.ref,o=e.refCleanup;if(l!==null)if(typeof o=="function")try{o()}catch(f){vt(e,n,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(f){vt(e,n,f)}else l.current=null}function um(e){var n=e.type,l=e.memoizedProps,o=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&o.focus();break e;case"img":l.src?o.src=l.src:l.srcSet&&(o.srcset=l.srcSet)}}catch(f){vt(e,e.return,f)}}function ec(e,n,l){try{var o=e.stateNode;F0(o,e.type,l,n),o[Wt]=n}catch(f){vt(e,e.return,f)}}function cm(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Vi(e.type)||e.tag===4}function tc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||cm(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Vi(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function nc(e,n,l){var o=e.tag;if(o===5||o===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=ri));else if(o!==4&&(o===27&&Vi(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(nc(e,n,l),e=e.sibling;e!==null;)nc(e,n,l),e=e.sibling}function Ss(e,n,l){var o=e.tag;if(o===5||o===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(o!==4&&(o===27&&Vi(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Ss(e,n,l),e=e.sibling;e!==null;)Ss(e,n,l),e=e.sibling}function dm(e){var n=e.stateNode,l=e.memoizedProps;try{for(var o=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);rn(n,o,l),n[Ut]=e,n[Wt]=l}catch(g){vt(e,e.return,g)}}var pi=!1,Pt=!1,ic=!1,fm=typeof WeakSet=="function"?WeakSet:Set,Zt=null;function C0(e,n){if(e=e.containerInfo,kc=Vs,e=kh(e),Ko(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var o=l.getSelection&&l.getSelection();if(o&&o.rangeCount!==0){l=o.anchorNode;var f=o.anchorOffset,g=o.focusNode;o=o.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var w=0,z=-1,$=-1,oe=0,he=0,me=e,ue=null;t:for(;;){for(var ce;me!==l||f!==0&&me.nodeType!==3||(z=w+f),me!==g||o!==0&&me.nodeType!==3||($=w+o),me.nodeType===3&&(w+=me.nodeValue.length),(ce=me.firstChild)!==null;)ue=me,me=ce;for(;;){if(me===e)break t;if(ue===l&&++oe===f&&(z=w),ue===g&&++he===o&&($=w),(ce=me.nextSibling)!==null)break;me=ue,ue=me.parentNode}me=ce}l=z===-1||$===-1?null:{start:z,end:$}}else l=null}l=l||{start:0,end:0}}else l=null;for(Cc={focusedElem:e,selectionRange:l},Vs=!1,Zt=n;Zt!==null;)if(n=Zt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Zt=e;else for(;Zt!==null;){switch(n=Zt,g=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)f=e[l],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&g!==null){e=void 0,l=n,f=g.memoizedProps,g=g.memoizedState,o=l.stateNode;try{var Ae=pr(l.type,f);e=o.getSnapshotBeforeUpdate(Ae,g),o.__reactInternalSnapshotBeforeUpdate=e}catch(Be){vt(l,l.return,Be)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)Ac(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ac(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(a(163))}if(e=n.sibling,e!==null){e.return=n.return,Zt=e;break}Zt=n.return}}function hm(e,n,l){var o=l.flags;switch(l.tag){case 0:case 11:case 15:gi(e,l),o&4&&Kl(5,l);break;case 1:if(gi(e,l),o&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(w){vt(l,l.return,w)}else{var f=pr(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(w){vt(l,l.return,w)}}o&64&&sm(l),o&512&&Zl(l,l.return);break;case 3:if(gi(e,l),o&64&&(e=l.updateQueue,e!==null)){if(n=null,l.child!==null)switch(l.child.tag){case 27:case 5:n=l.child.stateNode;break;case 1:n=l.child.stateNode}try{Zh(e,n)}catch(w){vt(l,l.return,w)}}break;case 27:n===null&&o&4&&dm(l);case 26:case 5:gi(e,l),n===null&&o&4&&um(l),o&512&&Zl(l,l.return);break;case 12:gi(e,l);break;case 31:gi(e,l),o&4&&gm(e,l);break;case 13:gi(e,l),o&4&&ym(e,l),o&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=M0.bind(null,l),e1(e,l))));break;case 22:if(o=l.memoizedState!==null||pi,!o){n=n!==null&&n.memoizedState!==null||Pt,f=pi;var g=Pt;pi=o,(Pt=n)&&!g?yi(e,l,(l.subtreeFlags&8772)!==0):gi(e,l),pi=f,Pt=g}break;case 30:break;default:gi(e,l)}}function pm(e){var n=e.alternate;n!==null&&(e.alternate=null,pm(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&Do(n)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Dt=null,dn=!1;function mi(e,n,l){for(l=l.child;l!==null;)mm(e,n,l),l=l.sibling}function mm(e,n,l){if(dt&&typeof dt.onCommitFiberUnmount=="function")try{dt.onCommitFiberUnmount(mt,l)}catch{}switch(l.tag){case 26:Pt||Xn(l,n),mi(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Pt||Xn(l,n);var o=Dt,f=dn;Vi(l.type)&&(Dt=l.stateNode,dn=!1),mi(e,n,l),aa(l.stateNode),Dt=o,dn=f;break;case 5:Pt||Xn(l,n);case 6:if(o=Dt,f=dn,Dt=null,mi(e,n,l),Dt=o,dn=f,Dt!==null)if(dn)try{(Dt.nodeType===9?Dt.body:Dt.nodeName==="HTML"?Dt.ownerDocument.body:Dt).removeChild(l.stateNode)}catch(g){vt(l,n,g)}else try{Dt.removeChild(l.stateNode)}catch(g){vt(l,n,g)}break;case 18:Dt!==null&&(dn?(e=Dt,sg(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),cl(e)):sg(Dt,l.stateNode));break;case 4:o=Dt,f=dn,Dt=l.stateNode.containerInfo,dn=!0,mi(e,n,l),Dt=o,dn=f;break;case 0:case 11:case 14:case 15:Li(2,l,n),Pt||Li(4,l,n),mi(e,n,l);break;case 1:Pt||(Xn(l,n),o=l.stateNode,typeof o.componentWillUnmount=="function"&&om(l,n,o)),mi(e,n,l);break;case 21:mi(e,n,l);break;case 22:Pt=(o=Pt)||l.memoizedState!==null,mi(e,n,l),Pt=o;break;default:mi(e,n,l)}}function gm(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{cl(e)}catch(l){vt(n,n.return,l)}}}function ym(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{cl(e)}catch(l){vt(n,n.return,l)}}function E0(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new fm),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new fm),n;default:throw Error(a(435,e.tag))}}function js(e,n){var l=E0(e);n.forEach(function(o){if(!l.has(o)){l.add(o);var f=O0.bind(null,e,o);o.then(f,f)}})}function fn(e,n){var l=n.deletions;if(l!==null)for(var o=0;o<l.length;o++){var f=l[o],g=e,w=n,z=w;e:for(;z!==null;){switch(z.tag){case 27:if(Vi(z.type)){Dt=z.stateNode,dn=!1;break e}break;case 5:Dt=z.stateNode,dn=!1;break e;case 3:case 4:Dt=z.stateNode.containerInfo,dn=!0;break e}z=z.return}if(Dt===null)throw Error(a(160));mm(g,w,f),Dt=null,dn=!1,g=f.alternate,g!==null&&(g.return=null),f.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)bm(n,e),n=n.sibling}var qn=null;function bm(e,n){var l=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:fn(n,e),hn(e),o&4&&(Li(3,e,e.return),Kl(3,e),Li(5,e,e.return));break;case 1:fn(n,e),hn(e),o&512&&(Pt||l===null||Xn(l,l.return)),o&64&&pi&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?o:l.concat(o))));break;case 26:var f=qn;if(fn(n,e),hn(e),o&512&&(Pt||l===null||Xn(l,l.return)),o&4){var g=l!==null?l.memoizedState:null;if(o=e.memoizedState,l===null)if(o===null)if(e.stateNode===null){e:{o=e.type,l=e.memoizedProps,f=f.ownerDocument||f;t:switch(o){case"title":g=f.getElementsByTagName("title")[0],(!g||g[kl]||g[Ut]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=f.createElement(o),f.head.insertBefore(g,f.querySelector("head > title"))),rn(g,o,l),g[Ut]=e,Kt(g),o=g;break e;case"link":var w=bg("link","href",f).get(o+(l.href||""));if(w){for(var z=0;z<w.length;z++)if(g=w[z],g.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&g.getAttribute("rel")===(l.rel==null?null:l.rel)&&g.getAttribute("title")===(l.title==null?null:l.title)&&g.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){w.splice(z,1);break t}}g=f.createElement(o),rn(g,o,l),f.head.appendChild(g);break;case"meta":if(w=bg("meta","content",f).get(o+(l.content||""))){for(z=0;z<w.length;z++)if(g=w[z],g.getAttribute("content")===(l.content==null?null:""+l.content)&&g.getAttribute("name")===(l.name==null?null:l.name)&&g.getAttribute("property")===(l.property==null?null:l.property)&&g.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&g.getAttribute("charset")===(l.charSet==null?null:l.charSet)){w.splice(z,1);break t}}g=f.createElement(o),rn(g,o,l),f.head.appendChild(g);break;default:throw Error(a(468,o))}g[Ut]=e,Kt(g),o=g}e.stateNode=o}else vg(f,e.type,e.stateNode);else e.stateNode=yg(f,o,e.memoizedProps);else g!==o?(g===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):g.count--,o===null?vg(f,e.type,e.stateNode):yg(f,o,e.memoizedProps)):o===null&&e.stateNode!==null&&ec(e,e.memoizedProps,l.memoizedProps)}break;case 27:fn(n,e),hn(e),o&512&&(Pt||l===null||Xn(l,l.return)),l!==null&&o&4&&ec(e,e.memoizedProps,l.memoizedProps);break;case 5:if(fn(n,e),hn(e),o&512&&(Pt||l===null||Xn(l,l.return)),e.flags&32){f=e.stateNode;try{Dr(f,"")}catch(Ae){vt(e,e.return,Ae)}}o&4&&e.stateNode!=null&&(f=e.memoizedProps,ec(e,f,l!==null?l.memoizedProps:f)),o&1024&&(ic=!0);break;case 6:if(fn(n,e),hn(e),o&4){if(e.stateNode===null)throw Error(a(162));o=e.memoizedProps,l=e.stateNode;try{l.nodeValue=o}catch(Ae){vt(e,e.return,Ae)}}break;case 3:if(Is=null,f=qn,qn=Bs(n.containerInfo),fn(n,e),qn=f,hn(e),o&4&&l!==null&&l.memoizedState.isDehydrated)try{cl(n.containerInfo)}catch(Ae){vt(e,e.return,Ae)}ic&&(ic=!1,vm(e));break;case 4:o=qn,qn=Bs(e.stateNode.containerInfo),fn(n,e),hn(e),qn=o;break;case 12:fn(n,e),hn(e);break;case 31:fn(n,e),hn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,js(e,o)));break;case 13:fn(n,e),hn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Cs=He()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,js(e,o)));break;case 22:f=e.memoizedState!==null;var $=l!==null&&l.memoizedState!==null,oe=pi,he=Pt;if(pi=oe||f,Pt=he||$,fn(n,e),Pt=he,pi=oe,hn(e),o&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||$||pi||Pt||mr(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){$=l=n;try{if(g=$.stateNode,f)w=g.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none";else{z=$.stateNode;var me=$.memoizedProps.style,ue=me!=null&&me.hasOwnProperty("display")?me.display:null;z.style.display=ue==null||typeof ue=="boolean"?"":(""+ue).trim()}}catch(Ae){vt($,$.return,Ae)}}}else if(n.tag===6){if(l===null){$=n;try{$.stateNode.nodeValue=f?"":$.memoizedProps}catch(Ae){vt($,$.return,Ae)}}}else if(n.tag===18){if(l===null){$=n;try{var ce=$.stateNode;f?og(ce,!0):og($.stateNode,!1)}catch(Ae){vt($,$.return,Ae)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;l===n&&(l=null),n=n.return}l===n&&(l=null),n.sibling.return=n.return,n=n.sibling}o&4&&(o=e.updateQueue,o!==null&&(l=o.retryQueue,l!==null&&(o.retryQueue=null,js(e,l))));break;case 19:fn(n,e),hn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,js(e,o)));break;case 30:break;case 21:break;default:fn(n,e),hn(e)}}function hn(e){var n=e.flags;if(n&2){try{for(var l,o=e.return;o!==null;){if(cm(o)){l=o;break}o=o.return}if(l==null)throw Error(a(160));switch(l.tag){case 27:var f=l.stateNode,g=tc(e);Ss(e,g,f);break;case 5:var w=l.stateNode;l.flags&32&&(Dr(w,""),l.flags&=-33);var z=tc(e);Ss(e,z,w);break;case 3:case 4:var $=l.stateNode.containerInfo,oe=tc(e);nc(e,oe,$);break;default:throw Error(a(161))}}catch(he){vt(e,e.return,he)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function vm(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;vm(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function gi(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)hm(e,n.alternate,n),n=n.sibling}function mr(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Li(4,n,n.return),mr(n);break;case 1:Xn(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&om(n,n.return,l),mr(n);break;case 27:aa(n.stateNode);case 26:case 5:Xn(n,n.return),mr(n);break;case 22:n.memoizedState===null&&mr(n);break;case 30:mr(n);break;default:mr(n)}e=e.sibling}}function yi(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var o=n.alternate,f=e,g=n,w=g.flags;switch(g.tag){case 0:case 11:case 15:yi(f,g,l),Kl(4,g);break;case 1:if(yi(f,g,l),o=g,f=o.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(oe){vt(o,o.return,oe)}if(o=g,f=o.updateQueue,f!==null){var z=o.stateNode;try{var $=f.shared.hiddenCallbacks;if($!==null)for(f.shared.hiddenCallbacks=null,f=0;f<$.length;f++)Kh($[f],z)}catch(oe){vt(o,o.return,oe)}}l&&w&64&&sm(g),Zl(g,g.return);break;case 27:dm(g);case 26:case 5:yi(f,g,l),l&&o===null&&w&4&&um(g),Zl(g,g.return);break;case 12:yi(f,g,l);break;case 31:yi(f,g,l),l&&w&4&&gm(f,g);break;case 13:yi(f,g,l),l&&w&4&&ym(f,g);break;case 22:g.memoizedState===null&&yi(f,g,l),Zl(g,g.return);break;case 30:break;default:yi(f,g,l)}n=n.sibling}}function rc(e,n){var l=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==l&&(e!=null&&e.refCount++,l!=null&&Bl(l))}function lc(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Bl(e))}function Hn(e,n,l,o){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)xm(e,n,l,o),n=n.sibling}function xm(e,n,l,o){var f=n.flags;switch(n.tag){case 0:case 11:case 15:Hn(e,n,l,o),f&2048&&Kl(9,n);break;case 1:Hn(e,n,l,o);break;case 3:Hn(e,n,l,o),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Bl(e)));break;case 12:if(f&2048){Hn(e,n,l,o),e=n.stateNode;try{var g=n.memoizedProps,w=g.id,z=g.onPostCommit;typeof z=="function"&&z(w,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch($){vt(n,n.return,$)}}else Hn(e,n,l,o);break;case 31:Hn(e,n,l,o);break;case 13:Hn(e,n,l,o);break;case 23:break;case 22:g=n.stateNode,w=n.alternate,n.memoizedState!==null?g._visibility&2?Hn(e,n,l,o):Jl(e,n):g._visibility&2?Hn(e,n,l,o):(g._visibility|=2,Wr(e,n,l,o,(n.subtreeFlags&10256)!==0||!1)),f&2048&&rc(w,n);break;case 24:Hn(e,n,l,o),f&2048&&lc(n.alternate,n);break;default:Hn(e,n,l,o)}}function Wr(e,n,l,o,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,w=n,z=l,$=o,oe=w.flags;switch(w.tag){case 0:case 11:case 15:Wr(g,w,z,$,f),Kl(8,w);break;case 23:break;case 22:var he=w.stateNode;w.memoizedState!==null?he._visibility&2?Wr(g,w,z,$,f):Jl(g,w):(he._visibility|=2,Wr(g,w,z,$,f)),f&&oe&2048&&rc(w.alternate,w);break;case 24:Wr(g,w,z,$,f),f&&oe&2048&&lc(w.alternate,w);break;default:Wr(g,w,z,$,f)}n=n.sibling}}function Jl(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,o=n,f=o.flags;switch(o.tag){case 22:Jl(l,o),f&2048&&rc(o.alternate,o);break;case 24:Jl(l,o),f&2048&&lc(o.alternate,o);break;default:Jl(l,o)}n=n.sibling}}var Wl=8192;function el(e,n,l){if(e.subtreeFlags&Wl)for(e=e.child;e!==null;)wm(e,n,l),e=e.sibling}function wm(e,n,l){switch(e.tag){case 26:el(e,n,l),e.flags&Wl&&e.memoizedState!==null&&f1(l,qn,e.memoizedState,e.memoizedProps);break;case 5:el(e,n,l);break;case 3:case 4:var o=qn;qn=Bs(e.stateNode.containerInfo),el(e,n,l),qn=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Wl,Wl=16777216,el(e,n,l),Wl=o):el(e,n,l));break;default:el(e,n,l)}}function Sm(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function ea(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var o=n[l];Zt=o,km(o,e)}Sm(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)jm(e),e=e.sibling}function jm(e){switch(e.tag){case 0:case 11:case 15:ea(e),e.flags&2048&&Li(9,e,e.return);break;case 3:ea(e);break;case 12:ea(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,ks(e)):ea(e);break;default:ea(e)}}function ks(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var o=n[l];Zt=o,km(o,e)}Sm(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Li(8,n,n.return),ks(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,ks(n));break;default:ks(n)}e=e.sibling}}function km(e,n){for(;Zt!==null;){var l=Zt;switch(l.tag){case 0:case 11:case 15:Li(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var o=l.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Bl(l.memoizedState.cache)}if(o=l.child,o!==null)o.return=l,Zt=o;else e:for(l=e;Zt!==null;){o=Zt;var f=o.sibling,g=o.return;if(pm(o),o===l){Zt=null;break e}if(f!==null){f.return=g,Zt=f;break e}Zt=g}}}var N0={getCacheForType:function(e){var n=tn($t),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return tn($t).controller.signal}},A0=typeof WeakMap=="function"?WeakMap:Map,gt=0,Ct=null,Je=null,nt=0,bt=0,Sn=null,Bi=!1,tl=!1,ac=!1,bi=0,qt=0,Ui=0,gr=0,sc=0,jn=0,nl=0,ta=null,pn=null,oc=!1,Cs=0,Cm=0,Es=1/0,Ns=null,Ii=null,Xt=0,qi=null,il=null,vi=0,uc=0,cc=null,Em=null,na=0,dc=null;function kn(){return(gt&2)!==0&&nt!==0?nt&-nt:G.T!==null?yc():Ba()}function Nm(){if(jn===0)if((nt&536870912)===0||lt){var e=Ee;Ee<<=1,(Ee&3932160)===0&&(Ee=262144),jn=e}else jn=536870912;return e=xn.current,e!==null&&(e.flags|=32),jn}function mn(e,n,l){(e===Ct&&(bt===2||bt===9)||e.cancelPendingCommit!==null)&&(rl(e,0),Hi(e,nt,jn,!1)),Ke(e,l),((gt&2)===0||e!==Ct)&&(e===Ct&&((gt&2)===0&&(gr|=l),qt===4&&Hi(e,nt,jn,!1)),Kn(e))}function Am(e,n,l){if((gt&6)!==0)throw Error(a(327));var o=!l&&(n&127)===0&&(n&e.expiredLanes)===0||Ce(e,n),f=o?z0(e,n):hc(e,n,!0),g=o;do{if(f===0){tl&&!o&&Hi(e,n,0,!1);break}else{if(l=e.current.alternate,g&&!T0(l)){f=hc(e,n,!1),g=!1;continue}if(f===2){if(g=n,e.errorRecoveryDisabledLanes&g)var w=0;else w=e.pendingLanes&-536870913,w=w!==0?w:w&536870912?536870912:0;if(w!==0){n=w;e:{var z=e;f=ta;var $=z.current.memoizedState.isDehydrated;if($&&(rl(z,w).flags|=256),w=hc(z,w,!1),w!==2){if(ac&&!$){z.errorRecoveryDisabledLanes|=g,gr|=g,f=4;break e}g=pn,pn=f,g!==null&&(pn===null?pn=g:pn.push.apply(pn,g))}f=w}if(g=!1,f!==2)continue}}if(f===1){rl(e,0),Hi(e,n,0,!0);break}e:{switch(o=e,g=f,g){case 0:case 1:throw Error(a(345));case 4:if((n&4194048)!==n)break;case 6:Hi(o,n,jn,!Bi);break e;case 2:pn=null;break;case 3:case 5:break;default:throw Error(a(329))}if((n&62914560)===n&&(f=Cs+300-He(),10<f)){if(Hi(o,n,jn,!Bi),Me(o,0,!0)!==0)break e;vi=n,o.timeoutHandle=lg(Tm.bind(null,o,l,pn,Ns,oc,n,jn,gr,nl,Bi,g,"Throttled",-0,0),f);break e}Tm(o,l,pn,Ns,oc,n,jn,gr,nl,Bi,g,null,-0,0)}}break}while(!0);Kn(e)}function Tm(e,n,l,o,f,g,w,z,$,oe,he,me,ue,ce){if(e.timeoutHandle=-1,me=n.subtreeFlags,me&8192||(me&16785408)===16785408){me={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ri},wm(n,g,me);var Ae=(g&62914560)===g?Cs-He():(g&4194048)===g?Cm-He():0;if(Ae=h1(me,Ae),Ae!==null){vi=g,e.cancelPendingCommit=Ae(Bm.bind(null,e,n,g,l,o,f,w,z,$,he,me,null,ue,ce)),Hi(e,g,w,!oe);return}}Bm(e,n,g,l,o,f,w,z,$)}function T0(e){for(var n=e;;){var l=n.tag;if((l===0||l===11||l===15)&&n.flags&16384&&(l=n.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var o=0;o<l.length;o++){var f=l[o],g=f.getSnapshot;f=f.value;try{if(!bn(g(),f))return!1}catch{return!1}}if(l=n.child,n.subtreeFlags&16384&&l!==null)l.return=n,n=l;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Hi(e,n,l,o){n&=~sc,n&=~gr,e.suspendedLanes|=n,e.pingedLanes&=~n,o&&(e.warmLanes|=n),o=e.expirationTimes;for(var f=n;0<f;){var g=31-tt(f),w=1<<g;o[g]=-1,f&=~w}l!==0&&Rt(e,l,n)}function As(){return(gt&6)===0?(ia(0),!1):!0}function fc(){if(Je!==null){if(bt===0)var e=Je.return;else e=Je,oi=sr=null,Au(e),Qr=null,Il=0,e=Je;for(;e!==null;)am(e.alternate,e),e=e.return;Je=null}}function rl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,X0(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),vi=0,fc(),Ct=e,Je=l=ai(e.current,null),nt=n,bt=0,Sn=null,Bi=!1,tl=Ce(e,n),ac=!1,nl=jn=sc=gr=Ui=qt=0,pn=ta=null,oc=!1,(n&8)!==0&&(n|=n&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=n;0<o;){var f=31-tt(o),g=1<<f;n|=e[f],o&=~g}return bi=n,Xa(),l}function Rm(e,n){Pe=null,G.H=Pl,n===Pr||n===is?(n=Fh(),bt=3):n===gu?(n=Fh(),bt=4):bt=n===$u?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Sn=n,Je===null&&(qt=1,ys(e,zn(n,e.current)))}function zm(){var e=xn.current;return e===null?!0:(nt&4194048)===nt?On===null:(nt&62914560)===nt||(nt&536870912)!==0?e===On:!1}function _m(){var e=G.H;return G.H=Pl,e===null?Pl:e}function Dm(){var e=G.A;return G.A=N0,e}function Ts(){qt=4,Bi||(nt&4194048)!==nt&&xn.current!==null||(tl=!0),(Ui&134217727)===0&&(gr&134217727)===0||Ct===null||Hi(Ct,nt,jn,!1)}function hc(e,n,l){var o=gt;gt|=2;var f=_m(),g=Dm();(Ct!==e||nt!==n)&&(Ns=null,rl(e,n)),n=!1;var w=qt;e:do try{if(bt!==0&&Je!==null){var z=Je,$=Sn;switch(bt){case 8:fc(),w=6;break e;case 3:case 2:case 9:case 6:xn.current===null&&(n=!0);var oe=bt;if(bt=0,Sn=null,ll(e,z,$,oe),l&&tl){w=0;break e}break;default:oe=bt,bt=0,Sn=null,ll(e,z,$,oe)}}R0(),w=qt;break}catch(he){Rm(e,he)}while(!0);return n&&e.shellSuspendCounter++,oi=sr=null,gt=o,G.H=f,G.A=g,Je===null&&(Ct=null,nt=0,Xa()),w}function R0(){for(;Je!==null;)Mm(Je)}function z0(e,n){var l=gt;gt|=2;var o=_m(),f=Dm();Ct!==e||nt!==n?(Ns=null,Es=He()+500,rl(e,n)):tl=Ce(e,n);e:do try{if(bt!==0&&Je!==null){n=Je;var g=Sn;t:switch(bt){case 1:bt=0,Sn=null,ll(e,n,g,1);break;case 2:case 9:if($h(g)){bt=0,Sn=null,Om(n);break}n=function(){bt!==2&&bt!==9||Ct!==e||(bt=7),Kn(e)},g.then(n,n);break e;case 3:bt=7;break e;case 4:bt=5;break e;case 7:$h(g)?(bt=0,Sn=null,Om(n)):(bt=0,Sn=null,ll(e,n,g,7));break;case 5:var w=null;switch(Je.tag){case 26:w=Je.memoizedState;case 5:case 27:var z=Je;if(w?xg(w):z.stateNode.complete){bt=0,Sn=null;var $=z.sibling;if($!==null)Je=$;else{var oe=z.return;oe!==null?(Je=oe,Rs(oe)):Je=null}break t}}bt=0,Sn=null,ll(e,n,g,5);break;case 6:bt=0,Sn=null,ll(e,n,g,6);break;case 8:fc(),qt=6;break e;default:throw Error(a(462))}}_0();break}catch(he){Rm(e,he)}while(!0);return oi=sr=null,G.H=o,G.A=f,gt=l,Je!==null?0:(Ct=null,nt=0,Xa(),qt)}function _0(){for(;Je!==null&&!rt();)Mm(Je)}function Mm(e){var n=rm(e.alternate,e,bi);e.memoizedProps=e.pendingProps,n===null?Rs(e):Je=n}function Om(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=Jp(l,n,n.pendingProps,n.type,void 0,nt);break;case 11:n=Jp(l,n,n.pendingProps,n.type.render,n.ref,nt);break;case 5:Au(n);default:am(l,n),n=Je=Dh(n,bi),n=rm(l,n,bi)}e.memoizedProps=e.pendingProps,n===null?Rs(e):Je=n}function ll(e,n,l,o){oi=sr=null,Au(n),Qr=null,Il=0;var f=n.return;try{if(x0(e,f,n,l,nt)){qt=1,ys(e,zn(l,e.current)),Je=null;return}}catch(g){if(f!==null)throw Je=f,g;qt=1,ys(e,zn(l,e.current)),Je=null;return}n.flags&32768?(lt||o===1?e=!0:tl||(nt&536870912)!==0?e=!1:(Bi=e=!0,(o===2||o===9||o===3||o===6)&&(o=xn.current,o!==null&&o.tag===13&&(o.flags|=16384))),Lm(n,e)):Rs(n)}function Rs(e){var n=e;do{if((n.flags&32768)!==0){Lm(n,Bi);return}e=n.return;var l=j0(n.alternate,n,bi);if(l!==null){Je=l;return}if(n=n.sibling,n!==null){Je=n;return}Je=n=e}while(n!==null);qt===0&&(qt=5)}function Lm(e,n){do{var l=k0(e.alternate,e);if(l!==null){l.flags&=32767,Je=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){Je=e;return}Je=e=l}while(e!==null);qt=6,Je=null}function Bm(e,n,l,o,f,g,w,z,$){e.cancelPendingCommit=null;do zs();while(Xt!==0);if((gt&6)!==0)throw Error(a(327));if(n!==null){if(n===e.current)throw Error(a(177));if(g=n.lanes|n.childLanes,g|=tu,at(e,l,g,w,z,$),e===Ct&&(Je=Ct=null,nt=0),il=n,qi=e,vi=l,uc=g,cc=f,Em=o,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,L0(ye,function(){return Gm(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||o){o=G.T,G.T=null,f=B.p,B.p=2,w=gt,gt|=4;try{C0(e,n,l)}finally{gt=w,B.p=f,G.T=o}}Xt=1,Um(),Im(),qm()}}function Um(){if(Xt===1){Xt=0;var e=qi,n=il,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=G.T,G.T=null;var o=B.p;B.p=2;var f=gt;gt|=4;try{bm(n,e);var g=Cc,w=kh(e.containerInfo),z=g.focusedElem,$=g.selectionRange;if(w!==z&&z&&z.ownerDocument&&jh(z.ownerDocument.documentElement,z)){if($!==null&&Ko(z)){var oe=$.start,he=$.end;if(he===void 0&&(he=oe),"selectionStart"in z)z.selectionStart=oe,z.selectionEnd=Math.min(he,z.value.length);else{var me=z.ownerDocument||document,ue=me&&me.defaultView||window;if(ue.getSelection){var ce=ue.getSelection(),Ae=z.textContent.length,Be=Math.min($.start,Ae),jt=$.end===void 0?Be:Math.min($.end,Ae);!ce.extend&&Be>jt&&(w=jt,jt=Be,Be=w);var te=Sh(z,Be),F=Sh(z,jt);if(te&&F&&(ce.rangeCount!==1||ce.anchorNode!==te.node||ce.anchorOffset!==te.offset||ce.focusNode!==F.node||ce.focusOffset!==F.offset)){var ae=me.createRange();ae.setStart(te.node,te.offset),ce.removeAllRanges(),Be>jt?(ce.addRange(ae),ce.extend(F.node,F.offset)):(ae.setEnd(F.node,F.offset),ce.addRange(ae))}}}}for(me=[],ce=z;ce=ce.parentNode;)ce.nodeType===1&&me.push({element:ce,left:ce.scrollLeft,top:ce.scrollTop});for(typeof z.focus=="function"&&z.focus(),z=0;z<me.length;z++){var pe=me[z];pe.element.scrollLeft=pe.left,pe.element.scrollTop=pe.top}}Vs=!!kc,Cc=kc=null}finally{gt=f,B.p=o,G.T=l}}e.current=n,Xt=2}}function Im(){if(Xt===2){Xt=0;var e=qi,n=il,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=G.T,G.T=null;var o=B.p;B.p=2;var f=gt;gt|=4;try{hm(e,n.alternate,n)}finally{gt=f,B.p=o,G.T=l}}Xt=3}}function qm(){if(Xt===4||Xt===3){Xt=0,Tt();var e=qi,n=il,l=vi,o=Em;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Xt=5:(Xt=0,il=qi=null,Hm(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Ii=null),Nr(l),n=n.stateNode,dt&&typeof dt.onCommitFiberRoot=="function")try{dt.onCommitFiberRoot(mt,n,void 0,(n.current.flags&128)===128)}catch{}if(o!==null){n=G.T,f=B.p,B.p=2,G.T=null;try{for(var g=e.onRecoverableError,w=0;w<o.length;w++){var z=o[w];g(z.value,{componentStack:z.stack})}}finally{G.T=n,B.p=f}}(vi&3)!==0&&zs(),Kn(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===dc?na++:(na=0,dc=e):na=0,ia(0)}}function Hm(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,Bl(n)))}function zs(){return Um(),Im(),qm(),Gm()}function Gm(){if(Xt!==5)return!1;var e=qi,n=uc;uc=0;var l=Nr(vi),o=G.T,f=B.p;try{B.p=32>l?32:l,G.T=null,l=cc,cc=null;var g=qi,w=vi;if(Xt=0,il=qi=null,vi=0,(gt&6)!==0)throw Error(a(331));var z=gt;if(gt|=4,jm(g.current),xm(g,g.current,w,l),gt=z,ia(0,!1),dt&&typeof dt.onPostCommitFiberRoot=="function")try{dt.onPostCommitFiberRoot(mt,g)}catch{}return!0}finally{B.p=f,G.T=o,Hm(e,n)}}function Vm(e,n,l){n=zn(l,n),n=Vu(e.stateNode,n,2),e=Di(e,n,2),e!==null&&(Ke(e,2),Kn(e))}function vt(e,n,l){if(e.tag===3)Vm(e,e,l);else for(;n!==null;){if(n.tag===3){Vm(n,e,l);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Ii===null||!Ii.has(o))){e=zn(l,e),l=$p(2),o=Di(n,l,2),o!==null&&(Yp(l,o,n,e),Ke(o,2),Kn(o));break}}n=n.return}}function pc(e,n,l){var o=e.pingCache;if(o===null){o=e.pingCache=new A0;var f=new Set;o.set(n,f)}else f=o.get(n),f===void 0&&(f=new Set,o.set(n,f));f.has(l)||(ac=!0,f.add(l),e=D0.bind(null,e,n,l),n.then(e,e))}function D0(e,n,l){var o=e.pingCache;o!==null&&o.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,Ct===e&&(nt&l)===l&&(qt===4||qt===3&&(nt&62914560)===nt&&300>He()-Cs?(gt&2)===0&&rl(e,0):sc|=l,nl===nt&&(nl=0)),Kn(e)}function $m(e,n){n===0&&(n=de()),e=rr(e,n),e!==null&&(Ke(e,n),Kn(e))}function M0(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),$m(e,l)}function O0(e,n){var l=0;switch(e.tag){case 31:case 13:var o=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(a(314))}o!==null&&o.delete(n),$m(e,l)}function L0(e,n){return Lt(e,n)}var _s=null,al=null,mc=!1,Ds=!1,gc=!1,Gi=0;function Kn(e){e!==al&&e.next===null&&(al===null?_s=al=e:al=al.next=e),Ds=!0,mc||(mc=!0,U0())}function ia(e,n){if(!gc&&Ds){gc=!0;do for(var l=!1,o=_s;o!==null;){if(e!==0){var f=o.pendingLanes;if(f===0)var g=0;else{var w=o.suspendedLanes,z=o.pingedLanes;g=(1<<31-tt(42|e)+1)-1,g&=f&~(w&~z),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,Qm(o,g))}else g=nt,g=Me(o,o===Ct?g:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(g&3)===0||Ce(o,g)||(l=!0,Qm(o,g));o=o.next}while(l);gc=!1}}function B0(){Ym()}function Ym(){Ds=mc=!1;var e=0;Gi!==0&&Q0()&&(e=Gi);for(var n=He(),l=null,o=_s;o!==null;){var f=o.next,g=Fm(o,n);g===0?(o.next=null,l===null?_s=f:l.next=f,f===null&&(al=l)):(l=o,(e!==0||(g&3)!==0)&&(Ds=!0)),o=f}Xt!==0&&Xt!==5||ia(e),Gi!==0&&(Gi=0)}function Fm(e,n){for(var l=e.suspendedLanes,o=e.pingedLanes,f=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var w=31-tt(g),z=1<<w,$=f[w];$===-1?((z&l)===0||(z&o)!==0)&&(f[w]=V(z,n)):$<=n&&(e.expiredLanes|=z),g&=~z}if(n=Ct,l=nt,l=Me(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,l===0||e===n&&(bt===2||bt===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&Ye(o),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||Ce(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(o!==null&&Ye(o),Nr(l)){case 2:case 8:l=ie;break;case 32:l=ye;break;case 268435456:l=Ne;break;default:l=ye}return o=Pm.bind(null,e),l=Lt(l,o),e.callbackPriority=n,e.callbackNode=l,n}return o!==null&&o!==null&&Ye(o),e.callbackPriority=2,e.callbackNode=null,2}function Pm(e,n){if(Xt!==0&&Xt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(zs()&&e.callbackNode!==l)return null;var o=nt;return o=Me(e,e===Ct?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Am(e,o,n),Fm(e,He()),e.callbackNode!=null&&e.callbackNode===l?Pm.bind(null,e):null)}function Qm(e,n){if(zs())return null;Am(e,n,!0)}function U0(){K0(function(){(gt&6)!==0?Lt(M,B0):Ym()})}function yc(){if(Gi===0){var e=Yr;e===0&&(e=je,je<<=1,(je&261888)===0&&(je=256)),Gi=e}return Gi}function Xm(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ha(""+e)}function Km(e,n){var l=n.ownerDocument.createElement("input");return l.name=n.name,l.value=n.value,e.id&&l.setAttribute("form",e.id),n.parentNode.insertBefore(l,n),e=new FormData(e),l.parentNode.removeChild(l),e}function I0(e,n,l,o,f){if(n==="submit"&&l&&l.stateNode===f){var g=Xm((f[Wt]||null).action),w=o.submitter;w&&(n=(n=w[Wt]||null)?Xm(n.formAction):w.getAttribute("formAction"),n!==null&&(g=n,w=null));var z=new Ya("action","action",null,o,f);e.push({event:z,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Gi!==0){var $=w?Km(f,w):new FormData(f);Bu(l,{pending:!0,data:$,method:f.method,action:g},null,$)}}else typeof g=="function"&&(z.preventDefault(),$=w?Km(f,w):new FormData(f),Bu(l,{pending:!0,data:$,method:f.method,action:g},g,$))},currentTarget:f}]})}}for(var bc=0;bc<eu.length;bc++){var vc=eu[bc],q0=vc.toLowerCase(),H0=vc[0].toUpperCase()+vc.slice(1);In(q0,"on"+H0)}In(Nh,"onAnimationEnd"),In(Ah,"onAnimationIteration"),In(Th,"onAnimationStart"),In("dblclick","onDoubleClick"),In("focusin","onFocus"),In("focusout","onBlur"),In(i0,"onTransitionRun"),In(r0,"onTransitionStart"),In(l0,"onTransitionCancel"),In(Rh,"onTransitionEnd"),zr("onMouseEnter",["mouseout","mouseover"]),zr("onMouseLeave",["mouseout","mouseover"]),zr("onPointerEnter",["pointerout","pointerover"]),zr("onPointerLeave",["pointerout","pointerover"]),er("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),er("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),er("onBeforeInput",["compositionend","keypress","textInput","paste"]),er("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),er("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),er("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ra="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),G0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ra));function Zm(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var o=e[l],f=o.event;o=o.listeners;e:{var g=void 0;if(n)for(var w=o.length-1;0<=w;w--){var z=o[w],$=z.instance,oe=z.currentTarget;if(z=z.listener,$!==g&&f.isPropagationStopped())break e;g=z,f.currentTarget=oe;try{g(f)}catch(he){Qa(he)}f.currentTarget=null,g=$}else for(w=0;w<o.length;w++){if(z=o[w],$=z.instance,oe=z.currentTarget,z=z.listener,$!==g&&f.isPropagationStopped())break e;g=z,f.currentTarget=oe;try{g(f)}catch(he){Qa(he)}f.currentTarget=null,g=$}}}}function We(e,n){var l=n[Fn];l===void 0&&(l=n[Fn]=new Set);var o=e+"__bubble";l.has(o)||(Jm(n,e,2,!1),l.add(o))}function xc(e,n,l){var o=0;n&&(o|=4),Jm(l,e,o,n)}var Ms="_reactListening"+Math.random().toString(36).slice(2);function wc(e){if(!e[Ms]){e[Ms]=!0,Yf.forEach(function(l){l!=="selectionchange"&&(G0.has(l)||xc(l,!1,e),xc(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[Ms]||(n[Ms]=!0,xc("selectionchange",!1,n))}}function Jm(e,n,l,o){switch(Ng(n)){case 2:var f=g1;break;case 8:f=y1;break;default:f=Lc}l=f.bind(null,n,l,e),f=void 0,!Ho||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),o?f!==void 0?e.addEventListener(n,l,{capture:!0,passive:f}):e.addEventListener(n,l,!0):f!==void 0?e.addEventListener(n,l,{passive:f}):e.addEventListener(n,l,!1)}function Sc(e,n,l,o,f){var g=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var w=o.tag;if(w===3||w===4){var z=o.stateNode.containerInfo;if(z===f)break;if(w===4)for(w=o.return;w!==null;){var $=w.tag;if(($===3||$===4)&&w.stateNode.containerInfo===f)return;w=w.return}for(;z!==null;){if(w=Ar(z),w===null)return;if($=w.tag,$===5||$===6||$===26||$===27){o=g=w;continue e}z=z.parentNode}}o=o.return}ih(function(){var oe=g,he=Io(l),me=[];e:{var ue=zh.get(e);if(ue!==void 0){var ce=Ya,Ae=e;switch(e){case"keypress":if(Va(l)===0)break e;case"keydown":case"keyup":ce=Ox;break;case"focusin":Ae="focus",ce=Yo;break;case"focusout":Ae="blur",ce=Yo;break;case"beforeblur":case"afterblur":ce=Yo;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ce=ah;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ce=jx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ce=Ux;break;case Nh:case Ah:case Th:ce=Ex;break;case Rh:ce=qx;break;case"scroll":case"scrollend":ce=wx;break;case"wheel":ce=Gx;break;case"copy":case"cut":case"paste":ce=Ax;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ce=oh;break;case"toggle":case"beforetoggle":ce=$x}var Be=(n&4)!==0,jt=!Be&&(e==="scroll"||e==="scrollend"),te=Be?ue!==null?ue+"Capture":null:ue;Be=[];for(var F=oe,ae;F!==null;){var pe=F;if(ae=pe.stateNode,pe=pe.tag,pe!==5&&pe!==26&&pe!==27||ae===null||te===null||(pe=El(F,te),pe!=null&&Be.push(la(F,pe,ae))),jt)break;F=F.return}0<Be.length&&(ue=new ce(ue,Ae,null,l,he),me.push({event:ue,listeners:Be}))}}if((n&7)===0){e:{if(ue=e==="mouseover"||e==="pointerover",ce=e==="mouseout"||e==="pointerout",ue&&l!==Uo&&(Ae=l.relatedTarget||l.fromElement)&&(Ar(Ae)||Ae[Yn]))break e;if((ce||ue)&&(ue=he.window===he?he:(ue=he.ownerDocument)?ue.defaultView||ue.parentWindow:window,ce?(Ae=l.relatedTarget||l.toElement,ce=oe,Ae=Ae?Ar(Ae):null,Ae!==null&&(jt=d(Ae),Be=Ae.tag,Ae!==jt||Be!==5&&Be!==27&&Be!==6)&&(Ae=null)):(ce=null,Ae=oe),ce!==Ae)){if(Be=ah,pe="onMouseLeave",te="onMouseEnter",F="mouse",(e==="pointerout"||e==="pointerover")&&(Be=oh,pe="onPointerLeave",te="onPointerEnter",F="pointer"),jt=ce==null?ue:Cl(ce),ae=Ae==null?ue:Cl(Ae),ue=new Be(pe,F+"leave",ce,l,he),ue.target=jt,ue.relatedTarget=ae,pe=null,Ar(he)===oe&&(Be=new Be(te,F+"enter",Ae,l,he),Be.target=ae,Be.relatedTarget=jt,pe=Be),jt=pe,ce&&Ae)t:{for(Be=V0,te=ce,F=Ae,ae=0,pe=te;pe;pe=Be(pe))ae++;pe=0;for(var Oe=F;Oe;Oe=Be(Oe))pe++;for(;0<ae-pe;)te=Be(te),ae--;for(;0<pe-ae;)F=Be(F),pe--;for(;ae--;){if(te===F||F!==null&&te===F.alternate){Be=te;break t}te=Be(te),F=Be(F)}Be=null}else Be=null;ce!==null&&Wm(me,ue,ce,Be,!1),Ae!==null&&jt!==null&&Wm(me,jt,Ae,Be,!0)}}e:{if(ue=oe?Cl(oe):window,ce=ue.nodeName&&ue.nodeName.toLowerCase(),ce==="select"||ce==="input"&&ue.type==="file")var ht=gh;else if(ph(ue))if(yh)ht=e0;else{ht=Jx;var Re=Zx}else ce=ue.nodeName,!ce||ce.toLowerCase()!=="input"||ue.type!=="checkbox"&&ue.type!=="radio"?oe&&Bo(oe.elementType)&&(ht=gh):ht=Wx;if(ht&&(ht=ht(e,oe))){mh(me,ht,l,he);break e}Re&&Re(e,ue,oe),e==="focusout"&&oe&&ue.type==="number"&&oe.memoizedProps.value!=null&&Lo(ue,"number",ue.value)}switch(Re=oe?Cl(oe):window,e){case"focusin":(ph(Re)||Re.contentEditable==="true")&&(Br=Re,Zo=oe,Ml=null);break;case"focusout":Ml=Zo=Br=null;break;case"mousedown":Jo=!0;break;case"contextmenu":case"mouseup":case"dragend":Jo=!1,Ch(me,l,he);break;case"selectionchange":if(n0)break;case"keydown":case"keyup":Ch(me,l,he)}var Qe;if(Po)e:{switch(e){case"compositionstart":var it="onCompositionStart";break e;case"compositionend":it="onCompositionEnd";break e;case"compositionupdate":it="onCompositionUpdate";break e}it=void 0}else Lr?fh(e,l)&&(it="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(it="onCompositionStart");it&&(uh&&l.locale!=="ko"&&(Lr||it!=="onCompositionStart"?it==="onCompositionEnd"&&Lr&&(Qe=rh()):(Ei=he,Go="value"in Ei?Ei.value:Ei.textContent,Lr=!0)),Re=Os(oe,it),0<Re.length&&(it=new sh(it,e,null,l,he),me.push({event:it,listeners:Re}),Qe?it.data=Qe:(Qe=hh(l),Qe!==null&&(it.data=Qe)))),(Qe=Fx?Px(e,l):Qx(e,l))&&(it=Os(oe,"onBeforeInput"),0<it.length&&(Re=new sh("onBeforeInput","beforeinput",null,l,he),me.push({event:Re,listeners:it}),Re.data=Qe)),I0(me,e,oe,l,he)}Zm(me,n)})}function la(e,n,l){return{instance:e,listener:n,currentTarget:l}}function Os(e,n){for(var l=n+"Capture",o=[];e!==null;){var f=e,g=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||g===null||(f=El(e,l),f!=null&&o.unshift(la(e,f,g)),f=El(e,n),f!=null&&o.push(la(e,f,g))),e.tag===3)return o;e=e.return}return[]}function V0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Wm(e,n,l,o,f){for(var g=n._reactName,w=[];l!==null&&l!==o;){var z=l,$=z.alternate,oe=z.stateNode;if(z=z.tag,$!==null&&$===o)break;z!==5&&z!==26&&z!==27||oe===null||($=oe,f?(oe=El(l,g),oe!=null&&w.unshift(la(l,oe,$))):f||(oe=El(l,g),oe!=null&&w.push(la(l,oe,$)))),l=l.return}w.length!==0&&e.push({event:n,listeners:w})}var $0=/\r\n?/g,Y0=/\u0000|\uFFFD/g;function eg(e){return(typeof e=="string"?e:""+e).replace($0,`
|
|
9
|
+
`).replace(Y0,"")}function tg(e,n){return n=eg(n),eg(e)===n}function St(e,n,l,o,f,g){switch(l){case"children":typeof o=="string"?n==="body"||n==="textarea"&&o===""||Dr(e,o):(typeof o=="number"||typeof o=="bigint")&&n!=="body"&&Dr(e,""+o);break;case"className":Ia(e,"class",o);break;case"tabIndex":Ia(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Ia(e,l,o);break;case"style":th(e,o,g);break;case"data":if(n!=="object"){Ia(e,"data",o);break}case"src":case"href":if(o===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=Ha(""+o),e.setAttribute(l,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof g=="function"&&(l==="formAction"?(n!=="input"&&St(e,n,"name",f.name,f,null),St(e,n,"formEncType",f.formEncType,f,null),St(e,n,"formMethod",f.formMethod,f,null),St(e,n,"formTarget",f.formTarget,f,null)):(St(e,n,"encType",f.encType,f,null),St(e,n,"method",f.method,f,null),St(e,n,"target",f.target,f,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=Ha(""+o),e.setAttribute(l,o);break;case"onClick":o!=null&&(e.onclick=ri);break;case"onScroll":o!=null&&We("scroll",e);break;case"onScrollEnd":o!=null&&We("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(a(61));if(l=o.__html,l!=null){if(f.children!=null)throw Error(a(60));e.innerHTML=l}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}l=Ha(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,""+o):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":o===!0?e.setAttribute(l,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,o):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(l,o):e.removeAttribute(l);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(l):e.setAttribute(l,o);break;case"popover":We("beforetoggle",e),We("toggle",e),Ua(e,"popover",o);break;case"xlinkActuate":ii(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":ii(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":ii(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":ii(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":ii(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":ii(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":ii(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":ii(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":ii(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Ua(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=vx.get(l)||l,Ua(e,l,o))}}function jc(e,n,l,o,f,g){switch(l){case"style":th(e,o,g);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(a(61));if(l=o.__html,l!=null){if(f.children!=null)throw Error(a(60));e.innerHTML=l}}break;case"children":typeof o=="string"?Dr(e,o):(typeof o=="number"||typeof o=="bigint")&&Dr(e,""+o);break;case"onScroll":o!=null&&We("scroll",e);break;case"onScrollEnd":o!=null&&We("scrollend",e);break;case"onClick":o!=null&&(e.onclick=ri);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ff.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),n=l.slice(2,f?l.length-7:void 0),g=e[Wt]||null,g=g!=null?g[l]:null,typeof g=="function"&&e.removeEventListener(n,g,f),typeof o=="function")){typeof g!="function"&&g!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,o,f);break e}l in e?e[l]=o:o===!0?e.setAttribute(l,""):Ua(e,l,o)}}}function rn(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":We("error",e),We("load",e);var o=!1,f=!1,g;for(g in l)if(l.hasOwnProperty(g)){var w=l[g];if(w!=null)switch(g){case"src":o=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:St(e,n,g,w,l,null)}}f&&St(e,n,"srcSet",l.srcSet,l,null),o&&St(e,n,"src",l.src,l,null);return;case"input":We("invalid",e);var z=g=w=f=null,$=null,oe=null;for(o in l)if(l.hasOwnProperty(o)){var he=l[o];if(he!=null)switch(o){case"name":f=he;break;case"type":w=he;break;case"checked":$=he;break;case"defaultChecked":oe=he;break;case"value":g=he;break;case"defaultValue":z=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(a(137,n));break;default:St(e,n,o,he,l,null)}}Zf(e,g,z,$,oe,w,f,!1);return;case"select":We("invalid",e),o=w=g=null;for(f in l)if(l.hasOwnProperty(f)&&(z=l[f],z!=null))switch(f){case"value":g=z;break;case"defaultValue":w=z;break;case"multiple":o=z;default:St(e,n,f,z,l,null)}n=g,l=w,e.multiple=!!o,n!=null?_r(e,!!o,n,!1):l!=null&&_r(e,!!o,l,!0);return;case"textarea":We("invalid",e),g=f=o=null;for(w in l)if(l.hasOwnProperty(w)&&(z=l[w],z!=null))switch(w){case"value":o=z;break;case"defaultValue":f=z;break;case"children":g=z;break;case"dangerouslySetInnerHTML":if(z!=null)throw Error(a(91));break;default:St(e,n,w,z,l,null)}Wf(e,o,f,g);return;case"option":for($ in l)l.hasOwnProperty($)&&(o=l[$],o!=null)&&($==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":St(e,n,$,o,l,null));return;case"dialog":We("beforetoggle",e),We("toggle",e),We("cancel",e),We("close",e);break;case"iframe":case"object":We("load",e);break;case"video":case"audio":for(o=0;o<ra.length;o++)We(ra[o],e);break;case"image":We("error",e),We("load",e);break;case"details":We("toggle",e);break;case"embed":case"source":case"link":We("error",e),We("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(oe in l)if(l.hasOwnProperty(oe)&&(o=l[oe],o!=null))switch(oe){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:St(e,n,oe,o,l,null)}return;default:if(Bo(n)){for(he in l)l.hasOwnProperty(he)&&(o=l[he],o!==void 0&&jc(e,n,he,o,l,void 0));return}}for(z in l)l.hasOwnProperty(z)&&(o=l[z],o!=null&&St(e,n,z,o,l,null))}function F0(e,n,l,o){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,g=null,w=null,z=null,$=null,oe=null,he=null;for(ce in l){var me=l[ce];if(l.hasOwnProperty(ce)&&me!=null)switch(ce){case"checked":break;case"value":break;case"defaultValue":$=me;default:o.hasOwnProperty(ce)||St(e,n,ce,null,o,me)}}for(var ue in o){var ce=o[ue];if(me=l[ue],o.hasOwnProperty(ue)&&(ce!=null||me!=null))switch(ue){case"type":g=ce;break;case"name":f=ce;break;case"checked":oe=ce;break;case"defaultChecked":he=ce;break;case"value":w=ce;break;case"defaultValue":z=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(a(137,n));break;default:ce!==me&&St(e,n,ue,ce,o,me)}}Oo(e,w,z,$,oe,he,g,f);return;case"select":ce=w=z=ue=null;for(g in l)if($=l[g],l.hasOwnProperty(g)&&$!=null)switch(g){case"value":break;case"multiple":ce=$;default:o.hasOwnProperty(g)||St(e,n,g,null,o,$)}for(f in o)if(g=o[f],$=l[f],o.hasOwnProperty(f)&&(g!=null||$!=null))switch(f){case"value":ue=g;break;case"defaultValue":z=g;break;case"multiple":w=g;default:g!==$&&St(e,n,f,g,o,$)}n=z,l=w,o=ce,ue!=null?_r(e,!!l,ue,!1):!!o!=!!l&&(n!=null?_r(e,!!l,n,!0):_r(e,!!l,l?[]:"",!1));return;case"textarea":ce=ue=null;for(z in l)if(f=l[z],l.hasOwnProperty(z)&&f!=null&&!o.hasOwnProperty(z))switch(z){case"value":break;case"children":break;default:St(e,n,z,null,o,f)}for(w in o)if(f=o[w],g=l[w],o.hasOwnProperty(w)&&(f!=null||g!=null))switch(w){case"value":ue=f;break;case"defaultValue":ce=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(a(91));break;default:f!==g&&St(e,n,w,f,o,g)}Jf(e,ue,ce);return;case"option":for(var Ae in l)ue=l[Ae],l.hasOwnProperty(Ae)&&ue!=null&&!o.hasOwnProperty(Ae)&&(Ae==="selected"?e.selected=!1:St(e,n,Ae,null,o,ue));for($ in o)ue=o[$],ce=l[$],o.hasOwnProperty($)&&ue!==ce&&(ue!=null||ce!=null)&&($==="selected"?e.selected=ue&&typeof ue!="function"&&typeof ue!="symbol":St(e,n,$,ue,o,ce));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Be in l)ue=l[Be],l.hasOwnProperty(Be)&&ue!=null&&!o.hasOwnProperty(Be)&&St(e,n,Be,null,o,ue);for(oe in o)if(ue=o[oe],ce=l[oe],o.hasOwnProperty(oe)&&ue!==ce&&(ue!=null||ce!=null))switch(oe){case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(a(137,n));break;default:St(e,n,oe,ue,o,ce)}return;default:if(Bo(n)){for(var jt in l)ue=l[jt],l.hasOwnProperty(jt)&&ue!==void 0&&!o.hasOwnProperty(jt)&&jc(e,n,jt,void 0,o,ue);for(he in o)ue=o[he],ce=l[he],!o.hasOwnProperty(he)||ue===ce||ue===void 0&&ce===void 0||jc(e,n,he,ue,o,ce);return}}for(var te in l)ue=l[te],l.hasOwnProperty(te)&&ue!=null&&!o.hasOwnProperty(te)&&St(e,n,te,null,o,ue);for(me in o)ue=o[me],ce=l[me],!o.hasOwnProperty(me)||ue===ce||ue==null&&ce==null||St(e,n,me,ue,o,ce)}function ng(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function P0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),o=0;o<l.length;o++){var f=l[o],g=f.transferSize,w=f.initiatorType,z=f.duration;if(g&&z&&ng(w)){for(w=0,z=f.responseEnd,o+=1;o<l.length;o++){var $=l[o],oe=$.startTime;if(oe>z)break;var he=$.transferSize,me=$.initiatorType;he&&ng(me)&&($=$.responseEnd,w+=he*($<z?1:(z-oe)/($-oe)))}if(--o,n+=8*(g+w)/(f.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var kc=null,Cc=null;function Ls(e){return e.nodeType===9?e:e.ownerDocument}function ig(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function rg(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function Ec(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Nc=null;function Q0(){var e=window.event;return e&&e.type==="popstate"?e===Nc?!1:(Nc=e,!0):(Nc=null,!1)}var lg=typeof setTimeout=="function"?setTimeout:void 0,X0=typeof clearTimeout=="function"?clearTimeout:void 0,ag=typeof Promise=="function"?Promise:void 0,K0=typeof queueMicrotask=="function"?queueMicrotask:typeof ag<"u"?function(e){return ag.resolve(null).then(e).catch(Z0)}:lg;function Z0(e){setTimeout(function(){throw e})}function Vi(e){return e==="head"}function sg(e,n){var l=n,o=0;do{var f=l.nextSibling;if(e.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"||l==="/&"){if(o===0){e.removeChild(f),cl(n);return}o--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")o++;else if(l==="html")aa(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,aa(l);for(var g=l.firstChild;g;){var w=g.nextSibling,z=g.nodeName;g[kl]||z==="SCRIPT"||z==="STYLE"||z==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=w}}else l==="body"&&aa(e.ownerDocument.body);l=f}while(l);cl(n)}function og(e,n){var l=e;e=0;do{var o=l.nextSibling;if(l.nodeType===1?n?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(n?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),o&&o.nodeType===8)if(l=o.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=o}while(l)}function Ac(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var l=n;switch(n=n.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Ac(l),Do(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function J0(e,n,l,o){for(;e.nodeType===1;){var f=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[kl])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(g=e.getAttribute("rel"),g==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(g!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(g=e.getAttribute("src"),(g!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=Ln(e.nextSibling),e===null)break}return null}function W0(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Ln(e.nextSibling),e===null))return null;return e}function ug(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Ln(e.nextSibling),e===null))return null;return e}function Tc(e){return e.data==="$?"||e.data==="$~"}function Rc(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function e1(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var o=function(){n(),l.removeEventListener("DOMContentLoaded",o)};l.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Ln(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var zc=null;function cg(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return Ln(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function dg(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(n===0)return e;n--}else l!=="/$"&&l!=="/&"||n++}e=e.previousSibling}return null}function fg(e,n,l){switch(n=Ls(l),e){case"html":if(e=n.documentElement,!e)throw Error(a(452));return e;case"head":if(e=n.head,!e)throw Error(a(453));return e;case"body":if(e=n.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function aa(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Do(e)}var Bn=new Map,hg=new Set;function Bs(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var xi=B.d;B.d={f:t1,r:n1,D:i1,C:r1,L:l1,m:a1,X:o1,S:s1,M:u1};function t1(){var e=xi.f(),n=As();return e||n}function n1(e){var n=Tr(e);n!==null&&n.tag===5&&n.type==="form"?Rp(n):xi.r(e)}var sl=typeof document>"u"?null:document;function pg(e,n,l){var o=sl;if(o&&typeof n=="string"&&n){var f=Tn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),hg.has(f)||(hg.add(f),e={rel:e,crossOrigin:l,href:n},o.querySelector(f)===null&&(n=o.createElement("link"),rn(n,"link",e),Kt(n),o.head.appendChild(n)))}}function i1(e){xi.D(e),pg("dns-prefetch",e,null)}function r1(e,n){xi.C(e,n),pg("preconnect",e,n)}function l1(e,n,l){xi.L(e,n,l);var o=sl;if(o&&e&&n){var f='link[rel="preload"][as="'+Tn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+Tn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+Tn(l.imageSizes)+'"]')):f+='[href="'+Tn(e)+'"]';var g=f;switch(n){case"style":g=ol(e);break;case"script":g=ul(e)}Bn.has(g)||(e=b({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),Bn.set(g,e),o.querySelector(f)!==null||n==="style"&&o.querySelector(sa(g))||n==="script"&&o.querySelector(oa(g))||(n=o.createElement("link"),rn(n,"link",e),Kt(n),o.head.appendChild(n)))}}function a1(e,n){xi.m(e,n);var l=sl;if(l&&e){var o=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+Tn(o)+'"][href="'+Tn(e)+'"]',g=f;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=ul(e)}if(!Bn.has(g)&&(e=b({rel:"modulepreload",href:e},n),Bn.set(g,e),l.querySelector(f)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(oa(g)))return}o=l.createElement("link"),rn(o,"link",e),Kt(o),l.head.appendChild(o)}}}function s1(e,n,l){xi.S(e,n,l);var o=sl;if(o&&e){var f=Rr(o).hoistableStyles,g=ol(e);n=n||"default";var w=f.get(g);if(!w){var z={loading:0,preload:null};if(w=o.querySelector(sa(g)))z.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":n},l),(l=Bn.get(g))&&_c(e,l);var $=w=o.createElement("link");Kt($),rn($,"link",e),$._p=new Promise(function(oe,he){$.onload=oe,$.onerror=he}),$.addEventListener("load",function(){z.loading|=1}),$.addEventListener("error",function(){z.loading|=2}),z.loading|=4,Us(w,n,o)}w={type:"stylesheet",instance:w,count:1,state:z},f.set(g,w)}}}function o1(e,n){xi.X(e,n);var l=sl;if(l&&e){var o=Rr(l).hoistableScripts,f=ul(e),g=o.get(f);g||(g=l.querySelector(oa(f)),g||(e=b({src:e,async:!0},n),(n=Bn.get(f))&&Dc(e,n),g=l.createElement("script"),Kt(g),rn(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},o.set(f,g))}}function u1(e,n){xi.M(e,n);var l=sl;if(l&&e){var o=Rr(l).hoistableScripts,f=ul(e),g=o.get(f);g||(g=l.querySelector(oa(f)),g||(e=b({src:e,async:!0,type:"module"},n),(n=Bn.get(f))&&Dc(e,n),g=l.createElement("script"),Kt(g),rn(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},o.set(f,g))}}function mg(e,n,l,o){var f=(f=Z.current)?Bs(f):null;if(!f)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=ol(l.href),l=Rr(f).hoistableStyles,o=l.get(n),o||(o={type:"style",instance:null,count:0,state:null},l.set(n,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=ol(l.href);var g=Rr(f).hoistableStyles,w=g.get(e);if(w||(f=f.ownerDocument||f,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,w),(g=f.querySelector(sa(e)))&&!g._p&&(w.instance=g,w.state.loading=5),Bn.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Bn.set(e,l),g||c1(f,e,l,w.state))),n&&o===null)throw Error(a(528,""));return w}if(n&&o!==null)throw Error(a(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=ul(l),l=Rr(f).hoistableScripts,o=l.get(n),o||(o={type:"script",instance:null,count:0,state:null},l.set(n,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function ol(e){return'href="'+Tn(e)+'"'}function sa(e){return'link[rel="stylesheet"]['+e+"]"}function gg(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function c1(e,n,l,o){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?o.loading=1:(n=e.createElement("link"),o.preload=n,n.addEventListener("load",function(){return o.loading|=1}),n.addEventListener("error",function(){return o.loading|=2}),rn(n,"link",l),Kt(n),e.head.appendChild(n))}function ul(e){return'[src="'+Tn(e)+'"]'}function oa(e){return"script[async]"+e}function yg(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var o=e.querySelector('style[data-href~="'+Tn(l.href)+'"]');if(o)return n.instance=o,Kt(o),o;var f=b({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Kt(o),rn(o,"style",f),Us(o,l.precedence,e),n.instance=o;case"stylesheet":f=ol(l.href);var g=e.querySelector(sa(f));if(g)return n.state.loading|=4,n.instance=g,Kt(g),g;o=gg(l),(f=Bn.get(f))&&_c(o,f),g=(e.ownerDocument||e).createElement("link"),Kt(g);var w=g;return w._p=new Promise(function(z,$){w.onload=z,w.onerror=$}),rn(g,"link",o),n.state.loading|=4,Us(g,l.precedence,e),n.instance=g;case"script":return g=ul(l.src),(f=e.querySelector(oa(g)))?(n.instance=f,Kt(f),f):(o=l,(f=Bn.get(g))&&(o=b({},l),Dc(o,f)),e=e.ownerDocument||e,f=e.createElement("script"),Kt(f),rn(f,"link",o),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(o=n.instance,n.state.loading|=4,Us(o,l.precedence,e));return n.instance}function Us(e,n,l){for(var o=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=o.length?o[o.length-1]:null,g=f,w=0;w<o.length;w++){var z=o[w];if(z.dataset.precedence===n)g=z;else if(g!==f)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function _c(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function Dc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var Is=null;function bg(e,n,l){if(Is===null){var o=new Map,f=Is=new Map;f.set(l,o)}else f=Is,o=f.get(l),o||(o=new Map,f.set(l,o));if(o.has(e))return o;for(o.set(e,null),l=l.getElementsByTagName(e),f=0;f<l.length;f++){var g=l[f];if(!(g[kl]||g[Ut]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var w=g.getAttribute(n)||"";w=e+w;var z=o.get(w);z?z.push(g):o.set(w,[g])}}return o}function vg(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function d1(e,n,l){if(l===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(e=n.disabled,typeof n.precedence=="string"&&e==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function xg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function f1(e,n,l,o){if(l.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=ol(o.href),g=n.querySelector(sa(f));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=qs.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=g,Kt(g);return}g=n.ownerDocument||n,o=gg(o),(f=Bn.get(f))&&_c(o,f),g=g.createElement("link"),Kt(g);var w=g;w._p=new Promise(function(z,$){w.onload=z,w.onerror=$}),rn(g,"link",o),l.instance=g}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=qs.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var Mc=0;function h1(e,n){return e.stylesheets&&e.count===0&&Gs(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var o=setTimeout(function(){if(e.stylesheets&&Gs(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&Mc===0&&(Mc=62500*P0());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Gs(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>Mc?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(f)}}:null}function qs(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Gs(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Hs=null;function Gs(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Hs=new Map,n.forEach(p1,e),Hs=null,qs.call(e))}function p1(e,n){if(!(n.state.loading&4)){var l=Hs.get(e);if(l)var o=l.get(null);else{l=new Map,Hs.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<f.length;g++){var w=f[g];(w.nodeName==="LINK"||w.getAttribute("media")!=="not all")&&(l.set(w.dataset.precedence,w),o=w)}o&&l.set(null,o)}f=n.instance,w=f.getAttribute("data-precedence"),g=l.get(w)||o,g===o&&l.set(null,f),l.set(w,f),this.count++,o=qs.bind(this),f.addEventListener("load",o),f.addEventListener("error",o),g?g.parentNode.insertBefore(f,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var ua={$$typeof:D,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function m1(e,n,l,o,f,g,w,z,$){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ke(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ke(0),this.hiddenUpdates=ke(null),this.identifierPrefix=o,this.onUncaughtError=f,this.onCaughtError=g,this.onRecoverableError=w,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=$,this.incompleteTransitions=new Map}function wg(e,n,l,o,f,g,w,z,$,oe,he,me){return e=new m1(e,n,l,w,$,oe,he,me,z),n=1,g===!0&&(n|=24),g=vn(3,null,null,n),e.current=g,g.stateNode=e,n=hu(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:o,isDehydrated:l,cache:n},yu(g),e}function Sg(e){return e?(e=qr,e):qr}function jg(e,n,l,o,f,g){f=Sg(f),o.context===null?o.context=f:o.pendingContext=f,o=_i(n),o.payload={element:l},g=g===void 0?null:g,g!==null&&(o.callback=g),l=Di(e,o,n),l!==null&&(mn(l,e,n),Hl(l,e,n))}function kg(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function Oc(e,n){kg(e,n),(e=e.alternate)&&kg(e,n)}function Cg(e){if(e.tag===13||e.tag===31){var n=rr(e,67108864);n!==null&&mn(n,e,67108864),Oc(e,67108864)}}function Eg(e){if(e.tag===13||e.tag===31){var n=kn();n=Vt(n);var l=rr(e,n);l!==null&&mn(l,e,n),Oc(e,n)}}var Vs=!0;function g1(e,n,l,o){var f=G.T;G.T=null;var g=B.p;try{B.p=2,Lc(e,n,l,o)}finally{B.p=g,G.T=f}}function y1(e,n,l,o){var f=G.T;G.T=null;var g=B.p;try{B.p=8,Lc(e,n,l,o)}finally{B.p=g,G.T=f}}function Lc(e,n,l,o){if(Vs){var f=Bc(o);if(f===null)Sc(e,n,o,$s,l),Ag(e,o);else if(v1(f,e,n,l,o))o.stopPropagation();else if(Ag(e,o),n&4&&-1<b1.indexOf(e)){for(;f!==null;){var g=Tr(f);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var w=we(g.pendingLanes);if(w!==0){var z=g;for(z.pendingLanes|=2,z.entangledLanes|=2;w;){var $=1<<31-tt(w);z.entanglements[1]|=$,w&=~$}Kn(g),(gt&6)===0&&(Es=He()+500,ia(0))}}break;case 31:case 13:z=rr(g,2),z!==null&&mn(z,g,2),As(),Oc(g,2)}if(g=Bc(o),g===null&&Sc(e,n,o,$s,l),g===f)break;f=g}f!==null&&o.stopPropagation()}else Sc(e,n,o,null,l)}}function Bc(e){return e=Io(e),Uc(e)}var $s=null;function Uc(e){if($s=null,e=Ar(e),e!==null){var n=d(e);if(n===null)e=null;else{var l=n.tag;if(l===13){if(e=c(n),e!==null)return e;e=null}else if(l===31){if(e=h(n),e!==null)return e;e=null}else if(l===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return $s=e,null}function Ng(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ct()){case M:return 2;case ie:return 8;case ye:case xe:return 32;case Ne:return 268435456;default:return 32}default:return 32}}var Ic=!1,$i=null,Yi=null,Fi=null,ca=new Map,da=new Map,Pi=[],b1="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Ag(e,n){switch(e){case"focusin":case"focusout":$i=null;break;case"dragenter":case"dragleave":Yi=null;break;case"mouseover":case"mouseout":Fi=null;break;case"pointerover":case"pointerout":ca.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":da.delete(n.pointerId)}}function fa(e,n,l,o,f,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:l,eventSystemFlags:o,nativeEvent:g,targetContainers:[f]},n!==null&&(n=Tr(n),n!==null&&Cg(n)),e):(e.eventSystemFlags|=o,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function v1(e,n,l,o,f){switch(n){case"focusin":return $i=fa($i,e,n,l,o,f),!0;case"dragenter":return Yi=fa(Yi,e,n,l,o,f),!0;case"mouseover":return Fi=fa(Fi,e,n,l,o,f),!0;case"pointerover":var g=f.pointerId;return ca.set(g,fa(ca.get(g)||null,e,n,l,o,f)),!0;case"gotpointercapture":return g=f.pointerId,da.set(g,fa(da.get(g)||null,e,n,l,o,f)),!0}return!1}function Tg(e){var n=Ar(e.target);if(n!==null){var l=d(n);if(l!==null){if(n=l.tag,n===13){if(n=c(l),n!==null){e.blockedOn=n,Wi(e.priority,function(){Eg(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,Wi(e.priority,function(){Eg(l)});return}}else if(n===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ys(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=Bc(e.nativeEvent);if(l===null){l=e.nativeEvent;var o=new l.constructor(l.type,l);Uo=o,l.target.dispatchEvent(o),Uo=null}else return n=Tr(l),n!==null&&Cg(n),e.blockedOn=l,!1;n.shift()}return!0}function Rg(e,n,l){Ys(e)&&l.delete(n)}function x1(){Ic=!1,$i!==null&&Ys($i)&&($i=null),Yi!==null&&Ys(Yi)&&(Yi=null),Fi!==null&&Ys(Fi)&&(Fi=null),ca.forEach(Rg),da.forEach(Rg)}function Fs(e,n){e.blockedOn===n&&(e.blockedOn=null,Ic||(Ic=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,x1)))}var Ps=null;function zg(e){Ps!==e&&(Ps=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Ps===e&&(Ps=null);for(var n=0;n<e.length;n+=3){var l=e[n],o=e[n+1],f=e[n+2];if(typeof o!="function"){if(Uc(o||l)===null)continue;break}var g=Tr(l);g!==null&&(e.splice(n,3),n-=3,Bu(g,{pending:!0,data:f,method:l.method,action:o},o,f))}}))}function cl(e){function n($){return Fs($,e)}$i!==null&&Fs($i,e),Yi!==null&&Fs(Yi,e),Fi!==null&&Fs(Fi,e),ca.forEach(n),da.forEach(n);for(var l=0;l<Pi.length;l++){var o=Pi[l];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Pi.length&&(l=Pi[0],l.blockedOn===null);)Tg(l),l.blockedOn===null&&Pi.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(o=0;o<l.length;o+=3){var f=l[o],g=l[o+1],w=f[Wt]||null;if(typeof g=="function")w||zg(l);else if(w){var z=null;if(g&&g.hasAttribute("formAction")){if(f=g,w=g[Wt]||null)z=w.formAction;else if(Uc(f)!==null)continue}else z=w.action;typeof z=="function"?l[o+1]=z:(l.splice(o,3),o-=3),zg(l)}}}function _g(){function e(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(w){return f=w})},focusReset:"manual",scroll:"manual"})}function n(){f!==null&&(f(),f=null),o||setTimeout(l,20)}function l(){if(!o&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),f!==null&&(f(),f=null)}}}function qc(e){this._internalRoot=e}Qs.prototype.render=qc.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));var l=n.current,o=kn();jg(l,o,e,n,null,null)},Qs.prototype.unmount=qc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;jg(e.current,2,null,e,null,null),As(),n[Yn]=null}};function Qs(e){this._internalRoot=e}Qs.prototype.unstable_scheduleHydration=function(e){if(e){var n=Ba();e={blockedOn:null,target:e,priority:n};for(var l=0;l<Pi.length&&n!==0&&n<Pi[l].priority;l++);Pi.splice(l,0,e),l===0&&Tg(e)}};var Dg=i.version;if(Dg!=="19.2.6")throw Error(a(527,Dg,"19.2.6"));B.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=m(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var w1={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:G,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Xs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xs.isDisabled&&Xs.supportsFiber)try{mt=Xs.inject(w1),dt=Xs}catch{}}return pa.createRoot=function(e,n){if(!u(e))throw Error(a(299));var l=!1,o="",f=qp,g=Hp,w=Gp;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(w=n.onRecoverableError)),n=wg(e,1,!1,null,null,l,o,null,f,g,w,_g),e[Yn]=n.current,wc(e),new qc(n)},pa.hydrateRoot=function(e,n,l){if(!u(e))throw Error(a(299));var o=!1,f="",g=qp,w=Hp,z=Gp,$=null;return l!=null&&(l.unstable_strictMode===!0&&(o=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(w=l.onCaughtError),l.onRecoverableError!==void 0&&(z=l.onRecoverableError),l.formState!==void 0&&($=l.formState)),n=wg(e,1,!0,n,l??null,o,f,$,g,w,z,_g),n.context=Sg(null),l=n.current,o=kn(),o=Vt(o),f=_i(o),f.callback=null,Di(l,f,o),l=o,n.current.lanes=l,Ke(n,l),Kn(n),e[Yn]=n.current,wc(e),new Qs(n)},pa.version="19.2.6",pa}var $g;function Q1(){if($g)return $c.exports;$g=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(i){console.error(i)}}return t(),$c.exports=P1(),$c.exports}var X1=Q1();const K1=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;function Ub(t){if(!t||typeof t!="object")return!1;const i=t;return i.version===1&&typeof i.id=="string"&&K1.test(i.id)&&typeof i.name=="string"&&i.name.trim().length>0&&i.name.length<=128&&!/[\u0000-\u001f\u007f]/.test(i.name)&&["desktop","hub","project-host"].includes(i.kind)&&i.entryPath===(i.kind==="desktop"?"/mobile":"/")}const gf="codeshell.environments.v1",Ib=32;function yf(t){if(t.length>2048||/[\\\u0000-\u0020\u007f]/.test(t))throw new Error("请输入完整的工作台地址。");const i=new URL(t);if(!["https:","http:"].includes(i.protocol)||i.username||i.password||i.search||i.hash)throw new Error("请使用不含密码、配对令牌或查询参数的工作台地址。");if(!["/","/mobile","/mobile/"].includes(i.pathname))throw new Error("请填写工作台首页或桌面 /mobile 地址。");return i.origin+(i.pathname.startsWith("/mobile")?"/mobile":"/")}function qb(t){if(!t||typeof t!="object")throw new Error("无效的连接记录。");const i=t;if(typeof i.address!="string"||typeof i.name!="string"||!i.name.trim()||i.name.length>80||/[\u0000-\u001f\u007f]/.test(i.name))throw new Error("连接名称需为 1–80 个字符。");if(i.environmentId!==void 0&&!Ub({version:1,id:i.environmentId,name:"Host",kind:"hub",entryPath:"/"}))throw new Error("无效的环境身份。");return{address:yf(i.address),name:i.name.trim(),...i.environmentId?{environmentId:i.environmentId}:{}}}function go(t){const i=t.getItem(gf);if(i===null)return[];if(i.length>1e5)throw new Error("连接记录过大,请清理当前工作台的连接记录。");const r=JSON.parse(i);if(!Array.isArray(r)||r.length>Ib)throw new Error("连接记录格式无效。");return r.map(qb)}function Yg(t,i){const r=qb(i),a=go(t),u=a.find(c=>c.address===r.address);if(u?.environmentId&&r.environmentId&&u.environmentId!==r.environmentId)throw new Error("这个地址的环境身份已变化。请确认目标后,删除旧连接再添加。");const d=[...a.filter(c=>c.address!==r.address),{...r,...u?.environmentId?{environmentId:u.environmentId}:{}}];if(d.length>Ib)throw new Error("最多保存 32 个环境,请先移除不再使用的连接。");return t.setItem(gf,JSON.stringify(d)),d}function Z1(t,i){const r=go(t).filter(a=>a.address!==yf(i));return t.setItem(gf,JSON.stringify(r)),r}function J1(t,i,r){const a=t.find(u=>u.address===i+r.entryPath);if(a?.environmentId&&a.environmentId!==r.id)throw new Error("当前地址对应的环境已变化,请核对项目后重新保存连接。")}const Hb=S.createContext("/api/v1/environment");function bf({discover:t=!0,navigate:i}){const r=S.useContext(Hb),[a,u]=S.useState(!1),[d,c]=S.useState(),[h,p]=S.useState([]),[m,y]=S.useState(""),[b,v]=S.useState(""),[x,j]=S.useState(""),R=S.useRef(null),C=S.useRef(null);S.useEffect(()=>{try{p(go(window.localStorage))}catch{j("无法读取连接记录。当前项目仍可使用。")}},[]),S.useEffect(()=>{if(!t)return;const D=new AbortController;return Ue(r,{signal:D.signal}).then(q=>{if(!D.signal.aborted){if(!Ub(q))throw new Error("环境信息无效,请更新工作台后重试。");c(q),J1(go(window.localStorage),window.location.origin,q)}}).catch(q=>{D.signal.aborted||q instanceof Xe&&[401,404].includes(q.status)||j(q instanceof Error?q.message:"无法读取环境信息。")}),()=>D.abort()},[t,r]),S.useEffect(()=>{a&&(R.current?.showModal(),C.current?.focus())},[a]);const T=D=>{try{p(D()),j("")}catch(q){j(q instanceof Error?q.message:"保存连接失败。")}},_=D=>{const q=yf(D);u(!1),i?i(q):window.location.assign(q)};return s.jsxs("div",{className:"environment-switcher",children:[s.jsxs("button",{type:"button",className:"ghost environment-trigger",onClick:()=>u(!0),children:[d?.name??"连接环境",s.jsx("span",{"aria-hidden":"true",children:" ▾"})]}),a?s.jsxs("dialog",{ref:R,className:"environment-dialog","aria-labelledby":"environment-title",onCancel:()=>u(!1),onClose:()=>u(!1),children:[s.jsxs("header",{children:[s.jsx("h2",{id:"environment-title",children:"电脑与云端"}),s.jsx("button",{ref:C,type:"button",className:"ghost",onClick:()=>u(!1),children:"关闭"})]}),s.jsx("p",{children:"打开目标环境后选择项目。切换入口不会移动文件或正在运行的任务。"}),s.jsxs("p",{className:"environment-location",children:["当前地址:",window.location.origin]}),x?s.jsx("p",{role:"alert",className:"form-error",children:x}):null,d?s.jsx("button",{type:"button",className:"library-button",onClick:()=>T(()=>Yg(window.localStorage,{name:d.name,address:window.location.origin+d.entryPath,environmentId:d.id})),children:"保存当前环境"}):null,s.jsx("ul",{className:"environment-list",children:h.map(D=>s.jsxs("li",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:D.name}),s.jsx("small",{children:D.address})]}),s.jsx("button",{type:"button",className:"library-button",onClick:()=>_(D.address),children:"打开"}),s.jsx("button",{type:"button",className:"ghost","aria-label":`移除 ${D.name}`,onClick:()=>T(()=>Z1(window.localStorage,D.address)),children:"移除"})]},D.address))}),s.jsxs("form",{onSubmit:D=>{D.preventDefault(),T(()=>Yg(window.localStorage,{name:m,address:b.trim()}))},children:[s.jsxs("label",{children:["连接名称",s.jsx("input",{required:!0,maxLength:80,value:m,onChange:D=>y(D.target.value),placeholder:"例如:家里的电脑"})]}),s.jsxs("label",{children:["工作台地址",s.jsx("input",{required:!0,type:"url",maxLength:2048,value:b,onChange:D=>v(D.target.value),placeholder:"https://example.com/"})]}),s.jsx("button",{type:"submit",className:"library-button primary",children:"添加连接"})]}),s.jsx("p",{className:"environment-hint",children:"连接记录保存在当前工作台的浏览器存储中。目标环境需要单独登录或配对,请勿保存带配对令牌的地址。未连接的环境不会显示为在线。"})]}):null]})}function W1({session:t,onClose:i,onAuthLost:r}){const[a,u]=S.useState([]),[d,c]=S.useState(""),[h,p]=S.useState("loading"),m=S.useRef(null),y=S.useCallback(x=>{x instanceof Xe&&x.status===401?r():c(x instanceof Error?x.message:"操作失败,请重试。")},[r]);S.useEffect(()=>{let x=!0;return m.current?.showModal(),Ue("/api/v1/auth/sessions").then(j=>{x&&u(j.sessions)}).catch(j=>{x&&y(j)}).finally(()=>{x&&p(null)}),()=>{x=!1}},[y]);const b=async x=>{p(x.id),c("");try{await Ue(`/api/v1/auth/sessions/${encodeURIComponent(x.id)}`,{method:"DELETE"}),x.current?r():u(j=>j.filter(R=>R.id!==x.id))}catch(j){y(j)}finally{p(null)}},v=async()=>{p("logout"),c("");try{await Vd("/api/v1/auth/logout"),r()}catch(x){y(x)}finally{p(null)}};return s.jsxs("dialog",{className:"devices-dialog",ref:m,onCancel:i,"aria-labelledby":"devices-title",children:[s.jsxs("div",{className:"dialog-head",children:[s.jsx("h2",{id:"devices-title",children:"账号与设备"}),s.jsx("button",{className:"ghost",onClick:i,"aria-label":"关闭",children:"×"})]}),s.jsxs("p",{className:"muted",children:[t?.username," · ",t?.deviceName||"当前设备"]}),d?s.jsx("p",{className:"form-error",role:"alert",children:d}):null,h==="loading"?s.jsx("p",{role:"status",children:"正在读取设备…"}):null,s.jsx("ul",{className:"device-list",children:a.map(x=>s.jsxs("li",{children:[s.jsxs("div",{children:[s.jsxs("strong",{children:[x.deviceName||"未命名设备",x.current?"(当前)":""]}),s.jsxs("span",{children:["最近活动 ",new Date(x.lastSeenAt).toLocaleString()]})]}),s.jsx("button",{className:"ghost",disabled:h!==null,onClick:()=>{b(x)},children:h===x.id?"处理中…":"撤销登录"})]},x.id))}),s.jsx("button",{className:"stop",disabled:h!==null,onClick:()=>{v()},children:"退出当前设备"})]})}function ew(t){if(!(!t||t.length>2048))try{const i=new URL(t);return i.origin!==t||i.username||i.password||i.pathname!=="/"||i.search||i.hash||i.protocol!=="https:"&&!(i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))?void 0:`${i.origin}/api/v1/account/manage`}catch{return}}function Gb({pending:t,error:i,onLogout:r,accountOrigin:a}){const u=ew(a);return s.jsxs("div",{className:"cloud-account-controls",children:[s.jsx("span",{children:"Cloud 工作台"}),u?s.jsx("a",{className:"library-button",href:u,target:"_blank",rel:"noopener noreferrer",children:"账号资料"}):s.jsx("button",{className:"library-button",disabled:!0,title:"此工作台尚未提供账号服务地址",children:"账号资料"}),s.jsx("button",{className:"library-button",disabled:t,onClick:r,children:t?"正在退出…":"退出此 Cloud 工作台"}),i?s.jsx("p",{className:"form-error",role:"alert",children:i}):null]})}function Qc(t){return{expectedRevision:t?t.revision:null,id:t?.id??"",catalogId:t?.catalogId??"",model:t?.model??"",baseUrl:t?.baseUrl??"",apiKey:""}}function tw(t){const i={id:t.id.trim(),catalogId:t.catalogId,model:t.model.trim(),baseUrl:t.baseUrl.trim()};return t.expectedRevision!==void 0&&(i.expectedRevision=t.expectedRevision),t.apiKey.trim()&&(i.apiKey=t.apiKey.trim()),i}function vf(t){if(!t||typeof t.workspace?.path!="string"||!t.defaults||!Array.isArray(t.connections)||!Array.isArray(t.catalog)||!Array.isArray(t.skills)||!Array.isArray(t.mcpServers)||!Array.isArray(t.workspace.skillDirectories))throw new Error("服务端返回了无效的设置,请刷新后重试。");return t}async function Vb(t){return vf(await Ue("/api/v1/configuration",{signal:t}))}async function xf(t,i,r){return vf(await Ue(`/api/v1/configuration/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:r}))}function nw(t,i){return xf("connections",tw(t),i)}function iw(t,i){return xf("defaults",t,i)}function rw(t,i,r){return xf("skills",{name:t,enabled:i},r)}function $b(t){const i=t instanceof Error?t.message:"设置更新失败,请重试。",r={"provide an API key when changing the endpoint origin":"更换服务地址时,请同时填写该服务使用的 API Key。现有密钥不会自动发送到新的服务地址。","baseUrl must be an HTTP(S) URL without credentials, query or fragment":"请填写 HTTP 或 HTTPS 服务地址,不要在地址中包含账号、密码、查询参数或片段。","enable the owning plugin on the server first":"请先在服务器上启用这个 Skill 所属的插件。","select an existing text connection":"这个模型连接已不可用,请刷新后重新选择。","configuration request failed":"配置操作未完成,请刷新设置确认当前状态后重试。","too many model connections":"模型连接数量已达上限,请先删除不用的连接。","skill not found":"这个 Skill 已不在服务器上,请刷新列表。","unknown text provider":"这个模型服务商不可用,请刷新设置后重新选择。","existing connection provider cannot be changed":"已有连接的服务商不能直接更换,请创建新连接。"};return r[i]?r[i]:/^(id|catalogId|model|text|auxText|apiKey) is invalid$/.exec(i)?"配置字段无效,请检查名称、模型与密钥后重试。":i}async function lw(t,i,r,a){return vf(await Ue("/api/v1/configuration/connections",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,...i?{replacementText:i}:{},...a?{expectedRevision:a}:{}}),signal:r}))}async function aw(t,i){const r=_a(),a=xt("/api/v1/configuration/connections/probe"),u=xt("/api/v1/configuration/connections/probe/cancel");let d;try{d=await Ue(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,requestId:r}),signal:i})}catch(c){throw i?.aborted&&await Ue(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:r}),signal:AbortSignal.timeout(2e3)}).catch(()=>{}),c}if(!d||d.connectionId!==t||typeof d.ok!="boolean"||typeof d.message!="string"||typeof d.code!="string"||!Number.isFinite(d.latencyMs))throw new Error("服务端返回了无效的测试结果,请重试。");return d}const wf="/api/v1/skills";async function Fg(t){const i=await Ue(wf,{signal:t});if(!i||!Array.isArray(i.skills)||!Array.isArray(i.directories))throw new Error("Skills 列表读取失败,请刷新重试。");return i}async function sw(t,i){const r=await Ue(`${wf}/detail?name=${encodeURIComponent(t)}`,{signal:i});if(r.name!==t||typeof r.content!="string"||typeof r.revision!="string")throw new Error("Skill 内容读取失败,请重试。");return r}function jr(t,i,r,a){return Ue(`${wf}${t}`,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:a})}const ow=(t,i,r)=>jr("/local","POST",{name:t,content:i},r),uw=(t,i,r,a)=>jr("/local","PUT",{name:t,content:i,revision:r},a),cw=(t,i,r)=>jr("/local","DELETE",{name:t,revision:i},r),dw=(t,i)=>jr("/github/preview","POST",{url:t.trim()},i),fw=(t,i,r,a)=>jr("/github/install","POST",{reviewToken:t,pathInRepo:i,name:r.trim()},a),hw=(t,i,r)=>jr("/github/update-preview","POST",{name:t,revision:i},r),pw=(t,i)=>jr("/github/update","POST",{reviewToken:t},i);function Ws(t){return`---
|
|
10
|
+
name: ${t||"my-skill"}
|
|
11
|
+
description: 描述这个 Skill 适合处理什么任务
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# 工作方式
|
|
15
|
+
|
|
16
|
+
在这里写下具体步骤、输入要求和完成标准。
|
|
17
|
+
`}function Fd(t){return/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(t)&&!t.includes("..")}function mw(t,i,r){const a=i.trim().toLocaleLowerCase();return t.filter(u=>(r==="all"||u.source===r)&&(!a||`${u.name} ${u.description}`.toLocaleLowerCase().includes(a)))}const Pg={project:"工作区",user:"用户级",plugin:"插件","panel-app":"Panel App"};function gw({onAuthLost:t,onChanged:i,onDirtyChange:r,configurationVersion:a=0}){const[u,d]=S.useState(null),[c,h]=S.useState(null),[p,m]=S.useState(""),[y,b]=S.useState("all"),[v,x]=S.useState(""),[j,R]=S.useState(""),[C,T]=S.useState(""),[_,D]=S.useState(0),[q,se]=S.useState(!1),[N,U]=S.useState(!1),X=S.useRef(null),H=S.useRef(null),A=S.useRef(!1),I=S.useRef({onAuthLost:t,onChanged:i});I.current={onAuthLost:t,onChanged:i};const L=S.useRef(null),P=S.useRef(null),W=S.useCallback(k=>{k instanceof Xe&&k.status===401?I.current.onAuthLost():R(k instanceof Error?k.message:"操作失败,请重试。")},[]);S.useEffect(()=>()=>{X.current?.abort(),H.current?.abort()},[]),S.useEffect(()=>{if(X.current){A.current=!0;return}const k=new AbortController;return H.current=k,Fg(k.signal).then(O=>{k.signal.aborted||d(O)}).catch(O=>{k.signal.aborted||W(O)}),()=>k.abort()},[_,a,W]),S.useEffect(()=>{c&&L.current?.focus()},[c?.kind]);const ee=k=>{P.current=document.activeElement,R(""),T(""),se(!1),U(!1),h(k)},G=()=>{h(null),se(!1),U(!1),R(""),P.current?.focus()},B=()=>{if(!X.current){if(q){U(!0);return}G()}},Q=async(k,O,le=!1)=>{if(X.current)return;H.current?.abort();const E=new AbortController;X.current=E,x(k),R(""),T("");try{const J=await O(E.signal);if(E.signal.aborted)return;if(le){try{const be=await Fg(E.signal);E.signal.aborted||d(be)}catch(be){if(be instanceof Xe&&be.status===401)throw be;E.signal.aborted||R("操作已完成,但列表刷新失败。请点击刷新查看最新状态。")}if(E.signal.aborted)return;T(J.message||"设置已保存,下次任务生效。"),I.current.onChanged?.()}return J}catch(J){E.signal.aborted||W(J);return}finally{X.current===E&&(X.current=null),E.signal.aborted||(x(""),A.current&&(A.current=!1,D(J=>J+1)))}};S.useEffect(()=>(r?.(q||!!v),()=>r?.(!1)),[q,v,r]);const fe=mw(u?.skills??[],p,y);return s.jsxs("section",{className:"hub-skills","aria-labelledby":"skills-title",onKeyDown:k=>{k.key==="Escape"&&c&&!v&&(k.preventDefault(),B())},children:[s.jsxs("header",{className:"skills-heading",children:[s.jsxs("div",{children:[s.jsx("span",{className:"skills-eyebrow",children:"工作区能力"}),s.jsx("h1",{id:"skills-title",children:"Skills"}),s.jsx("p",{children:"创建工作说明,导入社区技能,把常用流程留在工作区。"})]}),s.jsxs("div",{className:"skills-actions",children:[s.jsx("button",{className:"config-button",disabled:!!v||!!c,onClick:()=>ee({kind:"import"}),children:"从 GitHub 导入"}),s.jsx("button",{className:"config-button config-button-primary",disabled:!!v||!!c,onClick:()=>ee({kind:"create"}),children:"+ 创建 Skill"})]})]}),j&&s.jsx("div",{className:"config-message config-error",role:"alert",children:j}),C&&s.jsx("div",{className:"config-message config-success",role:"status",children:C}),v&&s.jsxs("p",{className:"skills-progress",role:"status",children:[v,"…"]}),c&&s.jsxs("section",{className:"skills-workspace-panel","aria-labelledby":"skills-panel-title",children:[s.jsxs("header",{children:[s.jsx("h2",{id:"skills-panel-title",ref:L,tabIndex:-1,children:c.kind==="create"?"创建 Skill":c.kind==="detail"?c.detail.editable?`编辑 ${c.detail.name}`:c.detail.name:c.kind==="import"?"从 GitHub 导入":c.kind==="update"?`更新 ${c.preview.name}`:`移除 ${c.skill.name}`}),s.jsx("button",{className:"config-button config-button-quiet",disabled:!!v,onClick:B,children:"关闭"})]}),N&&s.jsxs("div",{className:"skills-discard-confirm",role:"alert",children:[s.jsx("p",{children:"还有未保存的修改。关闭会丢弃这些修改。"}),s.jsxs("div",{className:"skills-actions",children:[s.jsx("button",{className:"config-button",onClick:()=>U(!1),children:"继续编辑"}),s.jsx("button",{className:"config-button skills-danger",onClick:G,children:"放弃修改并关闭"})]})]}),(c.kind==="create"||c.kind==="detail")&&s.jsx(yw,{detail:c.kind==="detail"?c.detail:void 0,busy:!!v,run:Q,onSaved:G,onDirtyChange:se},c.kind==="detail"?c.detail.name+c.detail.revision:"create"),c.kind==="import"&&s.jsx(bw,{preview:c.preview,busy:!!v,run:Q,onPreview:k=>h({kind:"import",preview:k}),onInstalled:G},c.preview?.reviewToken??"url"),c.kind==="update"&&s.jsx(vw,{preview:c.preview,busy:!!v,run:Q,onUpdated:G}),c.kind==="remove"&&s.jsxs("div",{className:"skills-remove-confirm",children:[s.jsxs("p",{children:["确认从当前工作区移除 ",s.jsx("strong",{children:c.skill.name}),"?它的 SKILL.md、脚本和资源文件都会移除。"]}),s.jsx("p",{className:"config-help",children:"已保存的对话会保留。其他设备下一次运行任务时将不再使用这个工作区 Skill。"}),s.jsxs("div",{className:"skills-actions",children:[s.jsx("button",{className:"config-button",disabled:!!v,onClick:B,children:"取消"}),s.jsx("button",{className:"config-button skills-danger",disabled:!!v,onClick:()=>{Q("正在移除 Skill",k=>cw(c.skill.name,c.skill.revision,k),!0).then(k=>{k&&G()})},children:"确认移除"})]})]})]}),s.jsxs("div",{className:"skills-filter",children:[s.jsxs("label",{children:[s.jsx("span",{className:"config-sr-only",children:"搜索 Skills"}),s.jsx("input",{type:"search","aria-label":"搜索 Skills",value:p,onChange:k=>m(k.target.value),placeholder:"搜索名称或用途…"})]}),s.jsxs("select",{"aria-label":"Skill 来源",value:y,onChange:k=>b(k.target.value),children:[s.jsx("option",{value:"all",children:"全部来源"}),Object.entries(Pg).map(([k,O])=>s.jsx("option",{value:k,children:O},k))]}),s.jsx("button",{className:"config-button config-button-quiet",disabled:!!v,onClick:()=>{R(""),D(k=>k+1)},children:"刷新"})]}),!u&&!j?s.jsx("p",{className:"config-help",children:"正在读取 Skills…"}):u?s.jsxs("p",{className:"skills-count",children:[fe.length===u.skills.length?`${fe.length} 个 Skill`:`显示 ${fe.length} / ${u.skills.length} 个 Skill`," · ",u.skills.filter(k=>k.enabled).length," 个已启用"]}):null,u&&!fe.length&&s.jsxs("div",{className:"skills-empty",children:[s.jsx("h2",{children:p||y!=="all"?"没有匹配的 Skills":"从一个常用流程开始"}),s.jsx("p",{children:p||y!=="all"?"调整搜索词或来源筛选。":"创建自己的 Skill,或粘贴 GitHub 地址导入完整的社区技能。"})]}),s.jsx("div",{className:"skills-list",children:fe.map(k=>s.jsxs("article",{className:"skills-card",children:[s.jsxs("div",{className:"skills-card-heading",children:[s.jsxs("div",{children:[s.jsx("h2",{children:k.name}),s.jsx("span",{className:"config-badge",children:Pg[k.source]}),k.origin&&s.jsx("span",{className:"config-badge",children:"GitHub"})]}),s.jsx("button",{className:"config-switch",role:"switch","aria-checked":k.enabled,"aria-label":`${k.enabled?"停用":"启用"} ${k.name}`,disabled:!!v||!!k.disabledReason,title:k.disabledReason,onClick:()=>{Q("正在更新 Skill",async O=>(await rw(k.name,!k.enabled,O),{ok:!0,name:k.name,message:k.enabled?"Skill 已停用,下次任务生效。":"Skill 已启用,下次任务生效。"}),!0)},children:s.jsx("span",{})})]}),s.jsx("p",{children:k.description||"暂未填写用途描述。"}),k.origin&&s.jsxs("p",{className:"skills-source",children:[k.origin.url.replace("https://github.com/","")," · ",k.origin.ref," ·"," ",k.origin.commit.slice(0,8)]}),k.readOnlyReason&&s.jsx("p",{className:"config-help",children:k.readOnlyReason}),k.disabledReason&&s.jsx("p",{className:"config-help",children:k.disabledReason}),s.jsxs("footer",{className:"skills-actions",children:[s.jsx("button",{className:"config-button config-button-quiet",disabled:!!v||!!c,onClick:()=>{P.current=document.activeElement,Q("正在读取 Skill",O=>sw(k.name,O)).then(O=>{O&&ee({kind:"detail",detail:O})})},children:k.editable?"查看与编辑":"查看说明"}),k.editable&&k.origin&&s.jsx("button",{className:"config-button config-button-quiet",disabled:!!v||!!c,onClick:()=>{Q("正在检查来源更新",O=>hw(k.name,k.revision,O)).then(O=>{O?.changed?ee({kind:"update",preview:O}):O&&T(`${k.name} 已是最新版本。`)})},children:"检查更新"}),k.removable&&s.jsx("button",{className:"config-button config-button-quiet skills-remove",disabled:!!v||!!c,onClick:()=>ee({kind:"remove",skill:k}),children:"移除"})]})]},k.name))}),u&&s.jsxs("details",{className:"skills-directories",children:[s.jsx("summary",{children:"Skills 存在哪里"}),s.jsx("p",{children:"这里管理当前工作区。用户级、插件和 Panel App 的 Skills 可以查看和启停,安装内容由各自来源管理。"}),s.jsx("ul",{children:u.directories.map(k=>s.jsx("li",{children:s.jsx("code",{children:k})},k))})]})]})}function yw({detail:t,busy:i,run:r,onSaved:a,onDirtyChange:u}){const[d,c]=S.useState(t?.name??"my-skill"),[h,p]=S.useState(t?.content??Ws("my-skill")),m=h!==t?.content,y=!t||t.editable;return S.useEffect(()=>{u(y&&(t?h!==t.content:d!=="my-skill"||h!==Ws("my-skill")))},[h,d,t,y,u]),s.jsx("form",{className:"skills-editor",onSubmit:b=>{b.preventDefault(),r(t?"正在保存 Skill":"正在创建 Skill",v=>t?uw(t.name,h,t.revision,v):ow(d.trim(),h,v),!0).then(v=>{v&&a()})},children:s.jsxs("fieldset",{disabled:i,children:[!t&&s.jsxs("label",{children:[s.jsx("span",{children:"名称"}),s.jsx("input",{required:!0,value:d,maxLength:128,onChange:b=>{const v=b.target.value;h===Ws(d)&&p(Ws(v)),c(v)},"aria-describedby":"skill-name-help","aria-label":"Skill 名称"}),s.jsx("small",{id:"skill-name-help",children:"字母、数字、短横线、下划线或点;创建后名称保持不变。"}),!Fd(d)&&s.jsx("span",{className:"skills-field-error",children:"请输入有效名称。"})]}),s.jsxs("label",{children:[s.jsxs("span",{children:[y?"SKILL.md":"说明",t&&y&&m&&s.jsx("small",{className:"skills-unsaved",children:"未保存"})]}),s.jsx("textarea",{value:h,readOnly:!y,onChange:b=>p(b.target.value),rows:18,spellCheck:!1,"aria-label":"SKILL.md 内容"})]}),t?.origin&&y&&s.jsx("p",{className:"config-help",children:"手动编辑会保留 GitHub 来源;以后更新来源时,会预览将替换的完整内容。"}),y&&s.jsxs("div",{className:"skills-actions",children:[s.jsx("span",{className:"config-help",children:"支持 Markdown 和 YAML Frontmatter。变更在下一次任务中生效。"}),s.jsx("button",{className:"config-button config-button-primary",type:"submit",disabled:!h.trim()||!t&&!Fd(d)||!!t&&!m,children:t?"保存修改":"创建 Skill"})]})]})})}function bw({preview:t,busy:i,run:r,onPreview:a,onInstalled:u}){const[d,c]=S.useState(""),[h,p]=S.useState(t?.skills[0]?.pathInRepo??""),[m,y]=S.useState(t?.skills[0]?.name??"");return t?s.jsxs("form",{className:"skills-import-preview",onSubmit:b=>{b.preventDefault(),r("正在导入 Skill 与资源",v=>fw(t.reviewToken,h,m,v),!0).then(v=>{v&&u()})},children:[s.jsxs("p",{children:[s.jsx("a",{href:t.repoUrl,target:"_blank",rel:"noreferrer",children:t.repoUrl.replace("https://github.com/","")})," ",s.jsx("span",{className:"config-badge",children:t.commit.slice(0,8)})]}),t.warning&&s.jsx("p",{className:"config-help",children:t.warning}),s.jsxs("fieldset",{disabled:i,children:[s.jsx("legend",{children:"选择一个 Skill"}),s.jsx("div",{className:"skills-source-choices",children:t.skills.map(b=>s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"github-skill",checked:h===b.pathInRepo,onChange:()=>{p(b.pathInRepo),y(b.name)}}),s.jsxs("span",{children:[s.jsx("strong",{children:b.name}),s.jsx("small",{children:b.description||b.pathInRepo}),b.alreadyInstalled&&s.jsx("small",{children:"已有同名 Skill,可修改安装名称。"})]})]},b.pathInRepo))}),!!t.skills.length&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{children:[s.jsx("span",{children:"安装到工作区时使用的名称"}),s.jsx("input",{required:!0,maxLength:128,value:m,onChange:b=>y(b.target.value)})]}),s.jsx("p",{className:"config-help",children:"将导入预览时的确定版本。不会执行其中的脚本。"}),s.jsx("button",{className:"config-button config-button-primary",disabled:!h||!Fd(m),type:"submit",children:"确认导入到工作区"})]})]})]}):s.jsxs("form",{className:"skills-import-url",onSubmit:b=>{b.preventDefault(),r("正在检查 GitHub 来源",v=>dw(d,v)).then(v=>{v&&a(v)})},children:[s.jsxs("label",{children:[s.jsx("span",{children:"GitHub 仓库或 Skill 目录地址"}),s.jsx("input",{type:"url",required:!0,value:d,onChange:b=>c(b.target.value),placeholder:"https://github.com/owner/repository/tree/main/skills/example",disabled:i})]}),s.jsx("p",{className:"config-help",children:"先查看可导入的技能,再确认安装。脚本和资源文件会一起保留。"}),s.jsx("button",{className:"config-button config-button-primary",disabled:i||!d.trim(),children:"预览来源"})]})}function vw({preview:t,busy:i,run:r,onUpdated:a}){return s.jsxs("div",{className:"skills-update-preview",children:[s.jsxs("p",{children:["来源版本 ",s.jsx("code",{children:t.currentCommit.slice(0,8)})," →"," ",s.jsx("code",{children:t.latestCommit.slice(0,8)})]}),s.jsx("p",{children:"确认后会用下方版本替换此 Skill 的说明、脚本和资源,包括你在其中做过的本地修改。"}),s.jsxs("details",{children:[s.jsxs("summary",{children:["查看将导入的 ",t.files?.length??0," 个文件"]}),s.jsx("ul",{children:t.files?.map(u=>s.jsxs("li",{children:[s.jsx("code",{children:u.path}),s.jsxs("span",{children:[Math.ceil(u.size/1024)," KB",u.executable?" · 可执行脚本":""]})]},u.path))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"新的 SKILL.md"}),s.jsx("textarea",{value:t.content??"",readOnly:!0,rows:16,"aria-label":"更新后的 SKILL.md"})]}),s.jsx("button",{className:"config-button config-button-primary",disabled:i||!t.reviewToken,onClick:()=>{r("正在更新 Skill",u=>pw(t.reviewToken,u),!0).then(u=>{u&&a()})},children:"确认更新到预览版本"})]})}function xw(t){const i=r=>r.map((a,u)=>({id:`stored-${u}`,name:a,value:"",stored:!0,removed:!1}));return{name:t?.name??"",transport:t?.transport??"stdio",command:t?.command??"",args:"",clearArgs:!1,url:t?.url??"",env:i(t?.envKeys??[]),headers:i(t?.headerKeys??[]),envHeaders:Object.entries(t?.envHeaders??{}).map(([r,a],u)=>({id:`stored-${u}`,name:r,value:a,initialValue:a,stored:!0,removed:!1})),envVars:(t?.envVars??[]).join(`
|
|
18
|
+
`),bearerTokenEnvVar:t?.bearerTokenEnvVar??"",credentialRef:t?.credentialRef??"",enabled:t?.enabled??!0,restrictTools:t?.allowedTools!==void 0,allowedTools:(t?.allowedTools??[]).join(`
|
|
19
|
+
`),disabledTools:(t?.disabledTools??[]).join(`
|
|
20
|
+
`),reuseStoredSecrets:!1}}function Xc(t){return t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean)}function ww(t,i){const r={},a=new Set;for(const u of t){if(!u.stored&&u.removed)continue;const d=u.name.trim();if(["__proto__","prototype","constructor"].includes(d))throw new Error(`${i}名称无效。`);if(!d&&!u.value&&!u.stored)continue;if(!d||!u.stored&&!u.value)throw new Error(`请完整填写${i}的名称和值,或移除空行。`);const c=i==="环境变量"?d:d.toLowerCase();if(a.has(c))throw new Error(`${i}名称不能重复。`);a.add(c),u.removed?r[d]=null:u.value&&u.value!==u.initialValue&&(r[d]=u.value)}return r}function Qg(t){try{return new URL(t).origin}catch{return""}}function Sw(t,i){if(!i)return!1;const r=i.envKeys.length||i.headerKeys.length||i.envVars.length||Object.keys(i.envHeaders).length||i.credentialRef||i.bearerTokenEnvVar||i.argsCount,a=t.transport!==i.transport||(t.transport==="stdio"?t.command.trim()!==i.command||!!t.args.trim()||t.clearArgs:Qg(t.url)!==Qg(i.url??""));return!!r&&a}function jw(t,i){const r={name:t.name.trim()};(!i||t.transport!==i.transport)&&(r.transport=t.transport),(!i||t.enabled!==i.enabled)&&(r.enabled=t.enabled),t.transport==="stdio"?((!i||t.command.trim()!==i.command)&&(r.command=t.command.trim()),t.clearArgs?r.args=[]:t.args.trim()&&(r.args=t.args.split(/\r?\n/).filter(c=>c.length>0))):(!i||t.url.trim()!==i.url)&&(r.url=t.url.trim());for(const[c,h]of[["env","环境变量"],["headers","请求头"],["envHeaders","环境变量请求头"]]){const p=ww(t[c],h);Object.keys(p).length&&(r[c]=p)}const a=Xc(t.envVars);(!i||JSON.stringify(a)!==JSON.stringify(i.envVars))&&(r.envVars=a);for(const c of["bearerTokenEnvVar","credentialRef"])(!i||t[c].trim()!==(i[c]??""))&&(r[c]=t[c].trim()||null);const u=t.restrictTools?Xc(t.allowedTools):void 0;(!i||JSON.stringify(u)!==JSON.stringify(i.allowedTools))&&(r.allowedTools=u??null);const d=Xc(t.disabledTools);return(!i||JSON.stringify(d)!==JSON.stringify(i.disabledTools))&&(r.disabledTools=d),t.reuseStoredSecrets&&(r.reuseStoredSecrets=!0),r}function Yb(t){if(!t||typeof t.workspacePath!="string"||!Array.isArray(t.servers)||!Array.isArray(t.removed))throw new Error("服务端返回了无效的 MCP 配置,请刷新重试。");return t}const wl=(t,i="")=>`/api/v1/mcp/servers/${encodeURIComponent(t)}${i}`;async function kw(t){return Yb(await Ue("/api/v1/mcp",{signal:t}))}async function Co(t,i,r,a){return Yb(await Ue(t,{method:i,headers:{"Content-Type":"application/json"},...r===void 0?{}:{body:JSON.stringify(r)},signal:a}))}function Cw(t,i,r){return Co(i?wl(i.name):"/api/v1/mcp/servers",i?"PUT":"POST",jw(t,i),r)}function Ew(t,i,r){return Co(wl(t,"/enabled"),"PUT",{enabled:i},r)}function Nw(t,i){return Co(wl(t),"DELETE",void 0,i)}function Xg(t,i){return Co(wl(t,"/inherit"),"POST",{},i)}async function Aw(t,i){const r=await Ue(wl(t,"/probe"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",signal:i});if(r.name!==t||!["ok","error","cancelled"].includes(r.status))throw new Error("服务端返回了无效的连接测试结果。");return r}function Kg(t,i,r){return Ue(xt(wl(t,"/cancel-probe"),i,r),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",keepalive:!0})}const Tw={local:"工作区本地",project:"工作区配置",user:"用户级",managed:"启动配置",plugin:"插件提供"};function Rw({onAuthLost:t,onConfigurationChange:i,configurationVersion:r=0,onDirtyChange:a}){const[u,d]=S.useState(null),[c,h]=S.useState(!0),[p,m]=S.useState(!1),[y,b]=S.useState(!1),[v,x]=S.useState(""),[j,R]=S.useState(""),[C,T]=S.useState(null),[_,D]=S.useState(null),[q,se]=S.useState(""),[N,U]=S.useState({}),[X,H]=S.useState(null),[A,I]=S.useState(0),L=S.useRef({onAuthLost:t,onConfigurationChange:i,onDirtyChange:a});L.current={onAuthLost:t,onConfigurationChange:i,onDirtyChange:a};const P=S.useRef(!1),W=S.useRef(null),ee=S.useRef(null),G=S.useRef(null),B=S.useRef(0),Q=S.useRef(!1),fe=S.useRef(r);S.useEffect(()=>{L.current.onDirtyChange?.(y||p)},[y,p]);const k=S.useCallback(Y=>{Y instanceof Xe&&Y.status===401?L.current.onAuthLost():x(Y instanceof Error?Y.message:"MCP 操作失败,请重试。")},[]);S.useEffect(()=>(P.current=!0,()=>{P.current=!1,L.current.onDirtyChange?.(!1),ee.current?.abort();const Y=G.current;Y&&(Y.controller.abort(),Kg(Y.name,Y.workspace,Y.projectId).catch(()=>{}))}),[]),S.useEffect(()=>{fe.current!==r&&(fe.current=r,ee.current?Q.current=!0:I(Y=>Y+1))},[r]),S.useEffect(()=>{const Y=new AbortController;W.current=Y;const ve=Date.now(),De=++B.current;return h(!0),x(""),kw(Y.signal).then(ze=>{!Y.signal.aborted&&De===B.current&&(d(ze),U(_e=>Object.fromEntries(Object.entries(_e).filter(([,qe])=>Date.parse(qe.checkedAt)>=ve))))}).catch(ze=>{!Y.signal.aborted&&De===B.current&&k(ze)}).finally(()=>{!Y.signal.aborted&&De===B.current&&h(!1)}),()=>Y.abort()},[A,k]);const O=async(Y,ve="MCP 设置已保存,任务进程会加载新的配置。")=>{if(ee.current||G.current)return!1;W.current?.abort();const De=++B.current,ze=new AbortController;ee.current=ze,m(!0),h(!1),x(""),R("");try{const _e=await Y(ze.signal);return!P.current||ze.signal.aborted||De!==B.current?!1:(d(_e),U({}),R(ve),L.current.onConfigurationChange?.(),!0)}catch(_e){return P.current&&!ze.signal.aborted&&k(_e),!1}finally{ee.current===ze&&(ee.current=null),P.current&&!ze.signal.aborted&&(m(!1),Q.current&&(Q.current=!1,I(_e=>_e+1)))}},le=async Y=>{if(G.current||ee.current)return;const ve=new AbortController;G.current={name:Y,controller:ve,workspace:mo()??"",projectId:Na()},H(Y),x(""),R(""),U(De=>{const ze={...De};return delete ze[Y],ze});try{const De=await Aw(Y,ve.signal);P.current&&!ve.signal.aborted&&U(ze=>({...ze,[Y]:De}))}catch(De){P.current&&!ve.signal.aborted&&k(De)}finally{G.current?.controller===ve&&(G.current=null),P.current&&H(null)}},E=async()=>{const Y=G.current;if(Y)try{await Kg(Y.name,Y.workspace,Y.projectId)}catch(ve){P.current&&k(ve)}finally{Y.controller.abort(),G.current===Y&&(G.current=null),P.current&&(H(null),U(ve=>({...ve,[Y.name]:{name:Y.name,status:"cancelled",checkedAt:new Date().toISOString(),durationMs:0,error:{code:"cancelled",message:"测试已取消。"}}})))}},J=p||c||X!==null,be=q.trim().toLocaleLowerCase(),Z=[...u?.servers??[]];C?.kind==="edit"&&!Z.some(Y=>Y.name===C.name)&&Z.push(C.original);const ne=Z.filter(Y=>!be||Y.name.toLocaleLowerCase().includes(be)||C?.kind==="edit"&&C.name===Y.name),ge=C?.kind==="edit"?Z.find(Y=>Y.name===C.name):void 0;return s.jsxs("div",{className:"hub-mcp",children:[s.jsxs("div",{className:"config-section-heading hub-mcp-toolbar",children:[s.jsxs("label",{className:"config-search",children:[s.jsx("span",{"aria-hidden":"true",children:"⌕"}),s.jsx("input",{type:"search",value:q,onChange:Y=>se(Y.target.value),placeholder:"搜索 MCP 服务…","aria-label":"搜索 MCP 服务"})]}),s.jsxs("div",{className:"hub-mcp-toolbar-actions",children:[s.jsx("button",{className:"config-button config-button-quiet",disabled:J,onClick:()=>I(Y=>Y+1),children:"刷新 MCP"}),s.jsx("button",{className:"config-button",disabled:J||C!==null,onClick:()=>T({kind:"new"}),children:"+ 添加服务"})]})]}),v&&s.jsx("p",{className:"config-message config-error",role:"alert",children:v}),j&&s.jsx("p",{className:"config-message config-success",role:"status",children:j}),p&&s.jsx("p",{className:"config-help",role:"status",children:"正在保存 MCP 配置…"}),c&&!u&&s.jsx("p",{className:"config-help",role:"status",children:"正在读取 MCP 配置…"}),C?.kind==="new"&&s.jsxs("div",{className:"config-card hub-mcp-editor-card",children:[s.jsx("h2",{children:"添加 MCP 服务"}),s.jsx(Zg,{disabled:J,save:O,onDone:()=>T(null),onProbe:Y=>{le(Y)},onDirtyChange:b})]}),!ne.length&&u&&C?.kind!=="new"&&s.jsxs("div",{className:"config-empty",children:[s.jsx("span",{"aria-hidden":"true",children:"⌘"}),s.jsx("h3",{children:be?"没有匹配的服务":"连接你的工具与数据"}),s.jsx("p",{children:be?"试试其他服务名称。":"添加运行 CodeShell 的设备上的命令,或连接提供 MCP 接口的 HTTP 服务。"})]}),s.jsx("div",{className:"hub-mcp-list",children:ne.map(Y=>s.jsxs("article",{className:"config-card hub-mcp-card",children:[s.jsxs("div",{className:"hub-mcp-card-head",children:[s.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:"⌘"}),s.jsxs("div",{className:"config-row-copy",children:[s.jsx("strong",{children:Y.name}),s.jsxs("span",{children:[Y.transport==="stdio"?"本地命令":Y.transport==="inprocess"?"内置工具":"HTTP 服务"," ","· ",Tw[Y.scope]]})]}),s.jsx("button",{className:"config-switch",type:"button",role:"switch","aria-checked":Y.enabled,"aria-label":`${Y.enabled?"停用":"启用"} MCP ${Y.name}`,disabled:J||Y.pluginDisabled,onClick:()=>{O(ve=>Ew(Y.name,!Y.enabled,ve))},children:s.jsx("span",{})})]}),C?.kind==="edit"&&C.name===Y.name&&ge?s.jsx(Zg,{server:ge,disabled:J,save:O,onDone:()=>T(null),onProbe:ve=>{le(ve)},onDirtyChange:b},Y.name):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"hub-mcp-endpoint",children:[s.jsx("code",{children:Y.transport==="stdio"?Y.command:Y.url||"由任务进程提供"}),Y.argsCount>0&&s.jsxs("span",{children:[Y.argsCount," 个已保存参数"]})]}),s.jsxs("div",{className:"hub-mcp-metadata",children:[s.jsx("span",{className:`config-badge${Y.enabled?" config-badge-accent":""}`,children:Y.enabled?"配置启用":"配置停用"}),Y.envKeys.length>0&&s.jsxs("span",{children:[Y.envKeys.length," 个环境变量"]}),(Y.headerKeys.length>0||Y.credentialRef||Y.bearerTokenEnvVar||Object.keys(Y.envHeaders).length>0)&&s.jsx("span",{children:"已配置认证"}),Y.hasLocalOverride&&s.jsx("span",{children:"本地覆盖"})]}),Y.source==="plugin"&&s.jsx("p",{className:"config-help",children:Y.pluginDisabled?"所属插件已停用。启用插件后,才能启用或测试这个服务。":"连接命令与地址由插件提供,可在此启停或测试。"}),s.jsxs("div",{className:"hub-mcp-card-actions",children:[X===Y.name?s.jsx("button",{className:"config-button",onClick:()=>{E()},children:"取消测试"}):s.jsx("button",{className:"config-button",disabled:J||Y.pluginDisabled||Y.transport==="inprocess",onClick:()=>{le(Y.name)},children:"测试连接"}),Y.editable&&s.jsx("button",{className:"config-button config-button-quiet",disabled:J||C!==null,onClick:()=>{D(null),T({kind:"edit",name:Y.name,original:Y})},children:"编辑"}),Y.hasLocalOverride&&s.jsx("button",{className:"config-button config-button-quiet",disabled:J,onClick:()=>{O(ve=>Xg(Y.name,ve),"已移除本地覆盖,恢复继承配置。")},children:"恢复继承"}),Y.deletable&&s.jsx("button",{className:"config-button config-button-quiet hub-mcp-remove",disabled:J||C!==null,onClick:()=>D(Y.name),children:"移除"})]}),_===Y.name&&s.jsxs("div",{className:"hub-mcp-delete",role:"alert",children:[s.jsxs("span",{children:["从当前工作区移除 ",Y.name,"?其他工作区的配置不受影响。"]}),s.jsxs("div",{children:[s.jsx("button",{className:"config-button config-button-quiet",disabled:J,onClick:()=>D(null),children:"取消"}),s.jsx("button",{className:"config-button hub-mcp-remove",disabled:J,onClick:async()=>{await O(ve=>Nw(Y.name,ve),"已从当前工作区移除服务。")&&D(null)},children:"确认移除"})]})]}),X===Y.name&&s.jsx("p",{className:"hub-mcp-probing",role:"status",children:"正在建立测试连接并读取工具列表…"}),N[Y.name]&&s.jsx(zw,{result:N[Y.name]})]})]},Y.name))}),!!u?.removed.length&&s.jsxs("details",{className:"hub-mcp-removed",children:[s.jsxs("summary",{children:["已在当前工作区移除(",u.removed.length,")"]}),u.removed.map(Y=>s.jsxs("div",{className:"hub-mcp-removed-row",children:[s.jsx("span",{children:Y.name}),s.jsx("button",{className:"config-button config-button-quiet",disabled:J,onClick:()=>{O(ve=>Xg(Y.name,ve),"已恢复继承的 MCP 配置。")},children:"恢复继承"})]},Y.name))]}),s.jsx("p",{className:"config-help hub-mcp-explanation",children:"连接使用运行 CodeShell 的设备上的网络、环境和凭据。测试只建立一次短连接并读取工具列表,完成后关闭;不会调用工具或改变启用状态。"})]})}function Zg({server:t,disabled:i,save:r,onDone:a,onProbe:u,onDirtyChange:d}){const c=S.useRef(t).current,[h,p]=S.useState(()=>xw(c)),m=S.useRef(JSON.stringify(h)).current,y=JSON.stringify(h)!==m;S.useEffect(()=>{d(y)},[y,d]),S.useEffect(()=>()=>d(!1),[d]);const[b,v]=S.useState(""),x=(C,T)=>p(_=>({..._,[C]:T})),j=Sw(h,c),R=h.transport==="stdio";return s.jsx("form",{className:"hub-mcp-editor",onSubmit:async C=>{C.preventDefault(),v("");const T=C.nativeEvent.submitter?.getAttribute("data-probe")==="true";try{await r(_=>Cw(h,c,_))&&(a(),T&&u(h.name.trim()))}catch(_){v(_ instanceof Error?_.message:"请检查填写内容。")}},children:s.jsxs("fieldset",{disabled:i,children:[s.jsx("legend",{className:"config-sr-only",children:c?`编辑 MCP ${c.name}`:"新 MCP 服务"}),s.jsxs("div",{className:"config-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"服务名称"}),s.jsx("input",{required:!0,readOnly:!!c,maxLength:128,pattern:"[A-Za-z0-9][A-Za-z0-9._:\\-]*",value:h.name,onChange:C=>x("name",C.target.value),placeholder:"例如 workspace-tools"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"连接方式"}),s.jsxs("select",{"aria-label":"连接方式",value:h.transport,onChange:C=>x("transport",C.target.value),children:[s.jsx("option",{value:"stdio",children:"本地命令(stdio)"}),s.jsx("option",{value:"streamable-http",children:"HTTP(Streamable HTTP)"}),c?.transport==="sse"&&s.jsx("option",{value:"sse",children:"HTTP(已有 SSE 配置)"})]})]}),R?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"启动命令"}),s.jsx("input",{required:!0,"aria-label":"启动命令",value:h.command,onChange:C=>x("command",C.target.value),placeholder:"例如 node、uvx 或可执行文件路径"}),s.jsx("small",{children:"在当前工作区执行。命令与参数分别填写。"})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"命令参数"}),s.jsx("textarea",{"aria-label":"命令参数",rows:3,disabled:h.clearArgs,value:h.args,onChange:C=>x("args",C.target.value),placeholder:c?.argsCount?`已有 ${c.argsCount} 个参数,留空保留。填写后将完整替换。`:"每行一个参数,不需要额外添加引号",autoComplete:"off",spellCheck:!1}),s.jsx("small",{children:"参数可能含密钥,因此不会读回已有值。每一行会作为一个完整参数。"})]}),!!c?.argsCount&&s.jsxs("label",{className:"hub-mcp-check config-full-width",children:[s.jsx("input",{type:"checkbox",checked:h.clearArgs,onChange:C=>x("clearArgs",C.target.checked)}),s.jsx("span",{children:"清空已保存的所有参数"})]})]}):s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"MCP 接口地址"}),s.jsx("input",{type:"url","aria-label":"MCP 接口地址",required:!0,value:h.url,onChange:C=>x("url",C.target.value),placeholder:"https://example.com/mcp"}),c?.urlHasHiddenParts&&s.jsx("small",{children:"已有地址的查询参数已隐藏;不修改地址时会保留。"})]})]}),R?s.jsx(Kc,{title:"环境变量",rows:h.env,onChange:C=>x("env",C)}):s.jsx(Kc,{title:"请求头",rows:h.headers,onChange:C=>x("headers",C)}),s.jsxs("details",{className:"hub-mcp-advanced",children:[s.jsx("summary",{children:"高级配置"}),s.jsx("div",{className:"config-form-grid",children:R?s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"转发运行环境变量"}),s.jsx("textarea",{"aria-label":"转发运行环境变量",rows:2,value:h.envVars,onChange:C=>x("envVars",C.target.value),placeholder:"每行一个环境变量名称,例如 GITHUB_TOKEN"}),s.jsx("small",{children:"只填写名称,实际值在连接时从CodeShell 的启动环境读取。"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{children:[s.jsx("span",{children:"Bearer Token 环境变量"}),s.jsx("input",{"aria-label":"Bearer Token 环境变量",value:h.bearerTokenEnvVar,onChange:C=>x("bearerTokenEnvVar",C.target.value),placeholder:"例如 MCP_ACCESS_TOKEN",autoComplete:"off"}),s.jsx("small",{children:"填写运行环境中的变量名称。"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"已存储的凭据 ID"}),s.jsx("input",{"aria-label":"已存储的凭据 ID",value:h.credentialRef,onChange:C=>x("credentialRef",C.target.value),placeholder:"可选",autoComplete:"off"}),s.jsx("small",{children:"引用已有凭据;优先于 Bearer 环境变量。"})]})]})}),!R&&s.jsx(Kc,{title:"环境变量请求头",rows:h.envHeaders,onChange:C=>x("envHeaders",C),visibleValues:!0}),s.jsxs("label",{className:"hub-mcp-check",children:[s.jsx("input",{type:"checkbox",checked:h.restrictTools,onChange:C=>x("restrictTools",C.target.checked)}),s.jsx("span",{children:"只允许指定工具"})]}),s.jsxs("div",{className:"config-form-grid",children:[h.restrictTools&&s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"允许的工具名称"}),s.jsx("textarea",{rows:2,value:h.allowedTools,onChange:C=>x("allowedTools",C.target.value),placeholder:"每行一个精确工具名称;留空则不开放任何工具"})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"停用的工具名称"}),s.jsx("textarea",{rows:2,value:h.disabledTools,onChange:C=>x("disabledTools",C.target.value),placeholder:"每行一个精确工具名称,可留空"})]})]})]}),s.jsxs("label",{className:"hub-mcp-check",children:[s.jsx("input",{type:"checkbox",checked:h.enabled,onChange:C=>x("enabled",C.target.checked)}),s.jsx("span",{children:"启用服务,让任务可以使用这些工具"})]}),j&&s.jsxs("label",{className:"hub-mcp-check hub-mcp-reuse",children:[s.jsx("input",{type:"checkbox",required:!0,checked:h.reuseStoredSecrets,onChange:C=>x("reuseStoredSecrets",C.target.checked)}),s.jsx("span",{children:"允许新的启动方式或服务地址使用已保存的参数、环境变量和认证配置。"})]}),b&&s.jsx("p",{className:"config-error config-message",role:"alert",children:b}),s.jsxs("div",{className:"config-form-actions",children:[s.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:a,children:"取消"}),s.jsx("button",{type:"submit","data-probe":"true",className:"config-button",children:"保存并测试"}),s.jsx("button",{type:"submit",className:"config-button config-button-primary",children:"保存配置"})]})]})})}function Kc({title:t,rows:i,onChange:r,visibleValues:a=!1}){const u=(d,c)=>r(i.map(h=>h.id===d?{...h,...c}:h));return s.jsxs("div",{className:"hub-mcp-keys",children:[s.jsxs("div",{className:"hub-mcp-key-heading",children:[s.jsx("h3",{children:t}),s.jsxs("button",{className:"config-text-button",type:"button",onClick:()=>r([...i,{id:_a(),name:"",value:"",stored:!1,removed:!1}]),children:["+ 添加",t]})]}),!i.length&&s.jsx("p",{className:"config-help",children:a?"可按请求头名称引用运行环境变量。":"无需此项时可以留空。"}),i.map(d=>s.jsxs("div",{className:`hub-mcp-key-row${d.removed?" hub-mcp-key-removed":""}`,children:[s.jsxs("label",{children:[s.jsxs("span",{className:"config-sr-only",children:[t,"名称"]}),s.jsx("input",{"aria-label":`${t}名称`,value:d.name,readOnly:d.stored,disabled:d.removed,onChange:c=>u(d.id,{name:c.target.value}),placeholder:t==="环境变量"?"例如 API_KEY":"例如 Authorization",autoComplete:"off"})]}),s.jsxs("label",{children:[s.jsxs("span",{className:"config-sr-only",children:[t,"值"]}),s.jsx("input",{"aria-label":`${t} ${d.name||"新条目"} 的值`,type:a?"text":"password",value:d.value,disabled:d.removed,onChange:c=>u(d.id,{value:c.target.value}),placeholder:d.removed?"保存时移除":a?"运行环境变量名称":d.stored?"已配置 · 留空保留":"输入值",autoComplete:a?"off":"new-password",spellCheck:!1})]}),s.jsx("button",{className:"config-button config-button-quiet",type:"button",onClick:()=>d.stored?u(d.id,{removed:!d.removed}):r(i.filter(c=>c.id!==d.id)),children:d.removed?"撤销移除":"移除"})]},d.id)),!!i.length&&!a&&s.jsx("p",{className:"config-help",children:"已有值保留在运行 CodeShell 的设备上;留空保留,填写新值替换,点击“移除”后保存才能删除。"})]})}function zw({result:t}){return s.jsxs("div",{className:`hub-mcp-probe-result hub-mcp-probe-${t.status}`,role:"status",children:[s.jsxs("div",{className:"hub-mcp-probe-summary",children:[s.jsx("strong",{children:t.status==="ok"?"测试连接成功":t.status==="cancelled"?"测试已取消":"连接测试失败"}),s.jsxs("span",{children:[new Date(t.checkedAt).toLocaleTimeString()," ·"," ",t.durationMs<1e3?`${t.durationMs} ms`:`${(t.durationMs/1e3).toFixed(1)} 秒`]})]}),t.error&&s.jsx("p",{children:t.error.message}),t.status==="ok"&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["发现 ",t.toolCount??0," 个工具",t.truncated?"(列表已截取)":"","。测试连接现已关闭。"]}),!!t.tools?.length&&s.jsxs("details",{children:[s.jsx("summary",{children:"查看工具列表"}),s.jsx("ul",{children:t.tools.map((i,r)=>s.jsxs("li",{children:[s.jsxs("div",{children:[s.jsx("code",{children:i.name}),!i.allowed&&s.jsx("span",{className:"config-badge",children:"被工具策略停用"})]}),i.description&&s.jsx("p",{children:i.description})]},`${i.name}-${r}`))})]})]})]})}const _w={overview:{title:"设置",description:"管理当前工作区的模型、Skills 和工具连接。"},models:{title:"模型与连接",description:"选择默认模型,管理工作区使用的服务商连接与凭据。"},skills:{title:"Skills",description:"让 CodeShell 按照你熟悉的工作方式完成任务。"},mcp:{title:"MCP 工具",description:"管理工具连接,测试连接并查看可用工具。"}};function Dw(t){return t.section==="skills"?s.jsx(gw,{onAuthLost:t.onAuthLost,onDirtyChange:t.onDirtyChange,onChanged:t.onConfigurationChange,configurationVersion:t.configurationVersion}):s.jsx(Mw,{...t})}function Mw({host:t="hub",section:i,onSectionChange:r,onAuthLost:a,onDirtyChange:u,onConfigurationChange:d,configurationVersion:c=0}){const[h,p]=S.useState(null),[m,y]=S.useState(!0),[b,v]=S.useState(""),[x,j]=S.useState(""),[R,C]=S.useState(null),[T,_]=S.useState(0),D=S.useRef({onAuthLost:a,onConfigurationChange:d});D.current={onAuthLost:a,onConfigurationChange:d};const q=S.useRef(!1),se=S.useRef(0),N=S.useRef(null),U=S.useRef(null),X=S.useRef(!1),H=S.useRef(c),A=S.useCallback(P=>{P instanceof Xe&&P.status===401?D.current.onAuthLost():v($b(P))},[]);S.useEffect(()=>{c!==H.current&&(H.current=c,U.current?X.current=!0:_(P=>P+1))},[c]),S.useEffect(()=>(q.current=!0,()=>{q.current=!1,U.current?.abort()}),[]),S.useEffect(()=>{const P=new AbortController;N.current=P;const W=++se.current;return y(!0),v(""),Vb(P.signal).then(ee=>{!P.signal.aborted&&W===se.current&&p(ee)}).catch(ee=>{!P.signal.aborted&&W===se.current&&A(ee)}).finally(()=>{!P.signal.aborted&&W===se.current&&y(!1)}),()=>P.abort()},[T,A]);const I=async(P,W)=>{if(U.current)return!1;N.current?.abort();const ee=++se.current,G=new AbortController;U.current=G,y(!1),C(P),v(""),j("");try{const B=await W(G.signal);return!q.current||G.signal.aborted||ee!==se.current?!1:(p(B),j(B.restartRequired?"设置已保存,重启服务后生效。":"设置已保存,下次运行任务时生效。"),D.current.onConfigurationChange?.(),!0)}catch(B){return B instanceof Xe&&B.status===409&&(X.current=!0),q.current&&!G.signal.aborted&&A(B),!1}finally{U.current===G&&(U.current=null),q.current&&!G.signal.aborted&&(C(null),X.current&&(X.current=!1,_(B=>B+1)))}},L=_w[i];return s.jsxs("section",{className:"hub-settings","aria-labelledby":"hub-settings-title",children:[s.jsxs("div",{className:"hub-settings-heading",children:[s.jsxs("div",{children:[s.jsx("span",{className:"hub-settings-eyebrow",children:t==="desktop"?"桌面工作区":"服务端工作区"}),s.jsx("h1",{id:"hub-settings-title",children:L.title}),s.jsx("p",{children:L.description})]}),s.jsx("button",{className:"config-button config-button-quiet",disabled:m||R!==null,onClick:()=>{j(""),_(P=>P+1)},children:m?"读取中…":"刷新"})]}),b&&s.jsx("div",{className:"config-message config-error",role:"alert",children:b}),x&&s.jsx("div",{className:"config-message config-success",role:"status",children:x}),R&&s.jsxs("p",{className:"config-loading",role:"status",children:["正在保存",R,"…"]}),!h&&m?s.jsx("p",{className:"config-loading",role:"status",children:"正在读取工作区设置…"}):null,h&&s.jsxs(s.Fragment,{children:[i==="overview"&&s.jsx(Ow,{host:t,configuration:h,onSectionChange:r}),i==="models"&&s.jsx(Lw,{configuration:h,disabled:R!==null||m,saving:R!==null,save:I,onDirtyChange:u,onAuthLost:a}),i==="mcp"&&s.jsx(Rw,{onAuthLost:a,onDirtyChange:u,onConfigurationChange:d,configurationVersion:c}),s.jsx("p",{className:"config-scope-note",children:"配置作用于当前工作区,所有连接到这里的设备共用。"})]})]})}function Ow({host:t,configuration:i,onSectionChange:r}){const a=i.connections.find(c=>c.id===i.defaults.text),u=i.skills.filter(c=>c.enabled).length,d=[{section:"models",title:"模型与连接",summary:a?`${a.id} · ${a.model}`:"尚未设置默认模型",icon:"◈"},{section:"skills",title:"Skills",summary:`${i.skills.length} 个可用 · ${u} 个已启用`,icon:"✧"},{section:"mcp",title:"MCP 工具",summary:`${i.mcpServers.length} 个已配置的工具服务`,icon:"⌘"}];return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"config-workspace-card",children:[s.jsx("span",{className:"config-workspace-icon","aria-hidden":"true",children:"▱"}),s.jsxs("div",{children:[s.jsx("strong",{children:"当前工作区"}),s.jsx("code",{children:i.workspace.path}),s.jsx("p",{children:t==="desktop"?"对话、文件操作和工具都由已连接的桌面端执行。":"对话、文件操作和工具都在服务端运行。"})]}),s.jsx("span",{className:"config-badge",children:t==="desktop"?"桌面工作区":"服务端工作区"})]}),s.jsx("h2",{className:"config-section-title",children:"工作区配置"}),s.jsx("div",{className:"config-card config-overview-list",children:d.map(c=>{const h=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:c.icon}),s.jsxs("span",{className:"config-row-copy",children:[s.jsx("strong",{children:c.title}),s.jsx("span",{children:c.summary})]}),r&&s.jsx("span",{className:"config-chevron","aria-hidden":"true",children:"›"})]});return r?s.jsx("button",{className:"config-overview-row",onClick:()=>r(c.section),children:h},c.section):s.jsx("div",{className:"config-overview-row",children:h},c.section)})}),s.jsxs("div",{className:"config-explanation",children:[s.jsx("h2",{children:"工作区与执行位置"}),s.jsx("p",{children:t==="desktop"?"这里直接使用桌面端的任务、模型、Skills 和工具连接。修改配置后,桌面窗口和已配对的网页共同使用。":"这里使用服务端的任务、模型、Skills 和工具连接。修改配置后,连接到这个服务端的网页共同使用。"}),s.jsx("p",{children:t==="desktop"?"切换项目会切换对应的文件、历史和工作区设置;无需复制桌面配置。":"独立部署使用自己的运行环境。部署到另一台机器时,需要迁移配置和数据,或在这里重新设置。"})]})]})}function Lw({configuration:t,disabled:i,saving:r,save:a,onDirtyChange:u,onAuthLost:d}){const[c,h]=S.useState(null),[p,m]=S.useState(null),[y,b]=S.useState(""),[v,x]=S.useState(!1),[j,R]=S.useState(!1),[C,T]=S.useState(null),[_,D]=S.useState({}),q=S.useRef(null),se=t.connections.filter(A=>A.tag==="text"),N=t.connections.length-se.length,U=i||!!C;S.useEffect(()=>{p&&!t.connections.some(A=>A.id===p.id)&&m(null)},[t.connections,p]),S.useEffect(()=>()=>q.current?.abort(),[]);const X=S.useRef(new Map);S.useEffect(()=>{const A=new Map(t.connections.map(L=>[L.id,L.revision??JSON.stringify(L)])),I=new Set([...X.current].filter(([L,P])=>A.get(L)!==P).map(([L])=>L));X.current=A,C&&I.has(C)&&q.current?.abort(),I.size&&D(L=>Object.fromEntries(Object.entries(L).filter(([P])=>!I.has(P))))},[t,C]),S.useEffect(()=>(u?.(v||j||r||!!C),()=>u?.(!1)),[v,j,r,C,u]);const H=async A=>{if(q.current)return;const I=new AbortController;q.current=I,T(A.id),D(L=>({...L,[A.id]:"正在发送一条简短测试请求…"}));try{const L=await aw(A.id,I.signal);I.signal.aborted||D(P=>({...P,[A.id]:L}))}catch(L){I.signal.aborted||(L instanceof Xe&&L.status===401?d():D(P=>({...P,[A.id]:$b(L)})))}finally{q.current===I&&(q.current=null,T(null))}};return s.jsxs(s.Fragment,{children:[s.jsx(Bw,{configuration:t,disabled:U,save:a,onDirtyChange:R}),s.jsxs("div",{className:"config-section-heading",children:[s.jsxs("h2",{children:["文字模型连接 ",s.jsx("span",{className:"config-count",children:se.length})]}),s.jsxs("button",{className:"config-button",disabled:U||c!==null||p!==null||!t.catalog.length,onClick:()=>h("__new__"),children:[s.jsx("span",{"aria-hidden":"true",children:"+"})," 添加连接"]})]}),c!==null&&s.jsxs("div",{className:"config-card config-editor-card",children:[s.jsx("h3",{children:c==="__new__"?"添加模型连接":`编辑 ${c.id}`}),s.jsx(Uw,{connection:c==="__new__"?void 0:c,configuration:t,disabled:U,save:a,onDone:()=>h(null),onDirtyChange:x},c==="__new__"?"new":c.id)]}),!se.length&&c!=="__new__"&&s.jsx(Iw,{title:"还没有文字模型连接",description:"添加服务商地址、模型名称和 API Key,再选择一个默认模型。"}),s.jsx("div",{className:"config-connection-list",children:se.map(A=>{const I=t.catalog.find(G=>G.id===A.catalogId),L=p?.id===A.id,P=L&&p?.revision!==A.revision,W=t.defaults.text===A.id&&se.length>1,ee=_[A.id];return s.jsxs("article",{className:"config-card config-connection-card",children:[s.jsxs("div",{className:"config-connection-head",children:[s.jsx("span",{className:"config-model-icon","aria-hidden":"true",children:"◈"}),s.jsxs("div",{className:"config-row-copy",children:[s.jsx("strong",{children:A.id}),s.jsx("span",{children:I?.displayName??A.catalogId})]}),t.defaults.text===A.id&&s.jsx("span",{className:"config-badge config-badge-accent",children:"默认"}),s.jsx("button",{className:"config-button config-button-quiet",disabled:U||c!==null||p!==null,onClick:()=>h(A),children:"编辑"})]}),s.jsxs("dl",{className:"config-connection-facts",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"模型"}),s.jsx("dd",{children:A.model||"未填写"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"服务地址"}),s.jsx("dd",{children:A.baseUrl||I?.defaultBaseUrl||"服务商默认地址"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"API Key"}),s.jsx("dd",{children:A.hasApiKey?"•••••••• · 已配置":A.needsKey?"未配置":"无需 API Key"})]})]}),s.jsxs("div",{className:"config-model-actions",children:[C===A.id?s.jsx("button",{className:"config-button",onClick:()=>{q.current?.abort(),D(G=>({...G,[A.id]:"已取消连接测试。"}))},children:"取消测试"}):s.jsx("button",{className:"config-button",disabled:U||c!==null||p!==null,onClick:()=>{H(A)},children:"测试连接"}),s.jsx("span",{className:"config-help",children:"发送一条简短请求,服务商可能计费。"}),s.jsx("button",{className:"config-button config-button-quiet config-remove-connection",disabled:U||c!==null||p!==null,onClick:()=>{m(A),b("")},children:"删除"})]}),ee&&s.jsxs("div",{className:`config-probe-result ${typeof ee!="string"&&ee.ok?"is-success":""}`,role:"status",children:[s.jsx("span",{children:typeof ee=="string"?ee:ee.message}),typeof ee!="string"&&s.jsxs("small",{children:[Math.max(.01,ee.latencyMs/1e3).toFixed(2)," 秒 ·"," ",new Date(ee.checkedAt).toLocaleTimeString()]})]}),L&&s.jsxs("div",{className:"config-remove-confirm",children:[s.jsxs("h3",{children:["删除连接 ",A.id,"?"]}),s.jsx("p",{children:"连接会从当前工作区移除,已有对话记录会保留。"}),P&&s.jsx("p",{role:"alert",children:"连接已被其他设备更新,请取消后重新检查再删除。"}),se.length===1&&s.jsx("p",{children:"这是最后一个文字模型连接。删除后需重新添加连接才能继续对话。"}),W&&s.jsxs("label",{children:[s.jsx("span",{children:"替代默认模型"}),s.jsxs("select",{"aria-label":"替代默认模型",value:y,onChange:G=>b(G.target.value),disabled:U,children:[s.jsx("option",{value:"",children:"请选择其他连接"}),se.filter(G=>G.id!==A.id).map(G=>s.jsxs("option",{value:G.id,children:[G.id," · ",G.model]},G.id))]})]}),s.jsxs("div",{className:"config-form-actions",children:[s.jsx("button",{className:"config-button",disabled:U,onClick:()=>m(null),children:"取消删除"}),s.jsx("button",{className:"config-button config-button-danger",disabled:U||P||W&&!y,onClick:()=>{a("删除连接",G=>lw(A.id,y||void 0,G,p?.revision)).then(G=>{G&&m(null)})},children:"确认删除连接"})]})]})]},A.id)})}),N>0&&s.jsxs("p",{className:"config-help",children:["另有 ",N," 个其他类型的模型连接,保留在工作区配置中。目前此处提供文字模型编辑。"]})]})}function Bw({configuration:t,disabled:i,save:r,onDirtyChange:a}){const[u,d]=S.useState(t.defaults.text??""),[c,h]=S.useState(t.defaults.auxText??""),p=S.useRef(t.defaults);S.useEffect(()=>{const b=p.current;p.current=t.defaults,d(v=>v===(b.text??"")?t.defaults.text??"":v),h(v=>v===(b.auxText??"")?t.defaults.auxText??"":v)},[t.defaults]);const m=t.connections.filter(b=>b.tag==="text"),y=u!==(t.defaults.text??"")||c!==(t.defaults.auxText??"");return S.useEffect(()=>(a(y),()=>a(!1)),[y,a]),s.jsx("form",{className:"config-card config-defaults",onSubmit:b=>{b.preventDefault(),r("默认模型",v=>iw({text:u,auxText:c||null},v))},children:s.jsxs("fieldset",{disabled:i||!m.length,children:[s.jsx("legend",{children:"默认模型"}),s.jsxs("div",{className:"config-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"对话模型"}),s.jsxs("select",{required:!0,value:u,onChange:b=>d(b.target.value),"aria-label":"默认对话模型",children:[s.jsx("option",{value:"",disabled:!0,children:"选择模型连接"}),u&&!m.some(b=>b.id===u)&&s.jsxs("option",{value:u,disabled:!0,children:[u,"(连接不可用)"]}),m.map(b=>s.jsxs("option",{value:b.id,children:[b.id," · ",b.model]},b.id))]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"辅助模型"}),s.jsxs("select",{value:c,onChange:b=>h(b.target.value),"aria-label":"默认辅助模型",children:[s.jsx("option",{value:"",children:"跟随对话模型"}),c&&!m.some(b=>b.id===c)&&s.jsxs("option",{value:c,disabled:!0,children:[c,"(连接不可用)"]}),m.map(b=>s.jsxs("option",{value:b.id,children:[b.id," · ",b.model]},b.id))]})]})]}),s.jsxs("div",{className:"config-form-footer",children:[s.jsx("p",{className:"config-help",children:"辅助模型用于标题生成等轻量任务。"}),s.jsx("button",{className:"config-button",disabled:!y||!u,type:"submit",children:"保存默认模型"})]})]})})}function Uw({connection:t,configuration:i,disabled:r,save:a,onDone:u,onDirtyChange:d}){const[c,h]=S.useState(()=>{const _=Qc(t);return t||(_.catalogId=i.catalog[0]?.id??""),_}),p=S.useRef(c),m=JSON.stringify(c)!==JSON.stringify(p.current),[y,b]=S.useState(!1),v=t?i.connections.find(_=>_.id===t.id):void 0,x=!!t&&(!v||c.expectedRevision!==v.revision);S.useEffect(()=>{if(!m&&v&&c.expectedRevision!==v.revision){const _=Qc(v);p.current=_,h(_)}},[m,v,c.expectedRevision]);const j=()=>{if(!v)return;const _=Qc(v);p.current=_,h(_),b(!1)};S.useEffect(()=>(d(m),()=>d(!1)),[m,d]);const R=i.catalog.find(_=>_.id===c.catalogId),C=!t&&i.connections.some(_=>_.id===c.id.trim()),T=(_,D)=>h(q=>({...q,[_]:D}));return s.jsx("form",{className:"config-connection-editor",onSubmit:async _=>{_.preventDefault(),!x&&await a("模型连接",D=>nw(c,D))&&u()},children:s.jsxs("fieldset",{disabled:r,children:[s.jsx("legend",{className:"config-sr-only",children:t?`编辑 ${t.id}`:"新模型连接"}),x&&s.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[s.jsx("p",{children:v?"其他设备已更新这个连接。你的草稿已保留,请检查最新设置后再保存。":"这个连接已被其他设备删除。草稿仍保留,你可以复制内容后关闭编辑。"}),v&&s.jsx("button",{className:"config-button",type:"button",onClick:j,children:"放弃草稿并载入最新设置"})]}),s.jsxs("div",{className:"config-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"连接名称"}),s.jsx("input",{required:!0,maxLength:120,value:c.id,readOnly:!!t,onChange:_=>T("id",_.target.value),placeholder:"例如 work-model",autoComplete:"off"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"服务商"}),s.jsxs("select",{required:!0,disabled:!!t,"aria-label":"服务商",value:c.catalogId,onChange:_=>T("catalogId",_.target.value),children:[t&&!R&&s.jsx("option",{value:c.catalogId,children:c.catalogId}),i.catalog.map(_=>s.jsx("option",{value:_.id,children:_.displayName},_.id))]})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"模型名称"}),s.jsx("input",{required:!0,maxLength:240,value:c.model,onChange:_=>T("model",_.target.value),placeholder:"服务商提供的模型 ID",autoComplete:"off"})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"服务地址"}),s.jsx("input",{type:"url","aria-label":"服务地址",value:c.baseUrl,onChange:_=>T("baseUrl",_.target.value),placeholder:R?.defaultBaseUrl||"使用服务商默认地址",autoComplete:"off"}),s.jsx("small",{children:"留空使用服务商默认地址,支持兼容接口。"})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsxs("span",{children:["API Key ",t?.hasApiKey&&s.jsx("span",{className:"config-field-meta",children:"已配置"})]}),s.jsx("input",{type:"password","aria-label":"API Key",required:R?.needsKey&&!t?.hasApiKey,value:c.apiKey,onChange:_=>T("apiKey",_.target.value),placeholder:t?.hasApiKey?"留空保留现有 API Key":R?.needsKey?"输入 API Key":"可选",autoComplete:"new-password",spellCheck:!1}),s.jsx("small",{children:t?.hasApiKey?"现有密钥保留在运行 CodeShell 的设备上,输入新值可替换。":"密钥保存在当前工作区配置中。"})]})]}),C&&s.jsx("p",{className:"config-error config-message",role:"alert",children:"连接名称已存在,请使用其他名称或编辑现有连接。"}),s.jsx("p",{className:"config-help",children:"保存后可在连接卡片中测试实际连接。"}),y&&s.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[s.jsx("p",{children:"还有未保存的修改,确定放弃?"}),s.jsxs("div",{className:"config-form-actions",children:[s.jsx("button",{type:"button",className:"config-button",onClick:()=>b(!1),children:"继续编辑"}),s.jsx("button",{type:"button",className:"config-button config-button-danger",onClick:u,children:"放弃修改"})]})]}),s.jsxs("div",{className:"config-form-actions",children:[s.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:()=>m?b(!0):u(),children:"取消"}),s.jsx("button",{type:"submit",className:"config-button config-button-primary",disabled:C||x,children:"保存连接"})]})]})})}function Iw({title:t,description:i}){return s.jsxs("div",{className:"config-empty",children:[s.jsx("span",{"aria-hidden":"true",children:"◇"}),s.jsx("h3",{children:t}),s.jsx("p",{children:i})]})}function Zc(t,i=!1){return xt(`/api/v1/files/content?path=${encodeURIComponent(t)}${i?"&inline=true":""}`)}function Jg(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function qw({initialPath:t,openVersion:i=0,onAuthLost:r}){const[a,u]=S.useState(""),[d,c]=S.useState(null),[h,p]=S.useState(null),[m,y]=S.useState(!1),[b,v]=S.useState(!1),[x,j]=S.useState(""),[R,C]=S.useState(0),[T,_]=S.useState(""),D=S.useRef(null),q=S.useRef(r);q.current=r;const se=S.useCallback(H=>{H instanceof Xe&&H.status===401?q.current():j(H instanceof Error?H.message:"文件读取失败,请重试。")},[]);S.useEffect(()=>{const H=new AbortController;return y(!0),j(""),Ue(`/api/v1/files?path=${encodeURIComponent(a)}`,{signal:H.signal}).then(A=>{H.signal.aborted||c(A)}).catch(A=>{H.signal.aborted||se(A)}).finally(()=>{H.signal.aborted||y(!1)}),()=>H.abort()},[a,R,se]);const N=S.useCallback((H,A=!1)=>{D.current?.abort();const I=new AbortController;D.current=I,p(null),v(!0),j(""),Ue(`${Zc(H)}&preview=true`,{signal:I.signal}).then(L=>{I.signal.aborted||(A&&u(L.path.split("/").slice(0,-1).join("/")),p(L))}).catch(L=>{I.signal.aborted||se(L)}).finally(()=>{I.signal.aborted||v(!1)})},[se]);S.useEffect(()=>{t&&N(t,!0)},[t,i,N]),S.useEffect(()=>()=>D.current?.abort(),[]);const U=H=>{D.current?.abort(),v(!1),p(null),u(H),_("")},X=d?.files.filter(H=>H.name.toLocaleLowerCase().includes(T.toLocaleLowerCase()))??[];return s.jsxs("section",{className:"hub-library hub-files","aria-labelledby":"hub-files-heading",children:[s.jsxs("header",{className:"library-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{id:"hub-files-heading",children:"工作区文件"}),s.jsx("p",{children:"查看任务生成的内容,下载到当前设备。"})]}),s.jsx("button",{className:"library-button",onClick:()=>{C(H=>H+1),h&&N(h.path)},children:"刷新"})]}),x?s.jsx("div",{className:"library-error",role:"alert",children:x}):null,s.jsxs("nav",{className:"file-breadcrumbs","aria-label":"文件位置",children:[s.jsx("button",{onClick:()=>U(""),children:"工作区"}),(d?.path??a).split("/").filter(Boolean).map((H,A,I)=>s.jsxs(S.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:"/"}),s.jsx("button",{onClick:()=>U(I.slice(0,A+1).join("/")),children:H})]},A))]}),s.jsxs("div",{className:`file-columns${h||b?" has-preview":""}`,children:[s.jsxs("div",{className:"file-directory",children:[s.jsxs("label",{className:"library-search",children:[s.jsx("span",{className:"sr-only",children:"筛选当前文件夹"}),s.jsx("input",{type:"search",placeholder:"筛选当前文件夹…",value:T,onChange:H=>_(H.target.value)})]}),s.jsx("div",{className:"file-entries","aria-busy":m,children:m?s.jsx("p",{className:"library-empty",role:"status",children:"正在读取文件…"}):X.length===0?s.jsx("p",{className:"library-empty",children:T?"没有匹配的文件。":"这个文件夹还没有文件。"}):X.map(H=>s.jsxs("button",{className:`file-entry${h?.path===H.path?" selected":""}`,onClick:()=>H.kind==="directory"?U(H.path):N(H.path),children:[s.jsx("span",{className:"file-glyph","aria-hidden":"true",children:H.kind==="directory"?"▱":"▤"}),s.jsx("span",{className:"file-entry-name",children:H.name}),s.jsx("span",{className:"file-entry-size",children:H.kind==="directory"?"文件夹":Jg(H.size)})]},H.path))}),d?.truncated?s.jsx("p",{className:"library-hint",children:"这里只显示前 500 项。可以进入子文件夹继续查看。"}):null]}),b||h?s.jsxs("article",{className:"file-preview","aria-label":"文件预览",children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:h?.name??"正在打开…"}),h?s.jsx("span",{children:Jg(h.size)}):null]}),s.jsxs("div",{className:"library-actions",children:[h?s.jsx("a",{className:"library-button",href:Zc(h.path),download:!0,children:"下载"}):null,s.jsx("button",{className:"library-button",onClick:()=>{D.current?.abort(),v(!1),p(null)},children:"关闭预览"})]})]}),b?s.jsx("p",{className:"library-empty",role:"status",children:"正在读取内容…"}):h?.kind==="text"?s.jsxs(s.Fragment,{children:[s.jsx("pre",{tabIndex:0,children:h.content}),h.truncated?s.jsx("p",{className:"library-hint",children:"预览显示前 512 KB,下载可获取完整内容。"}):null]}):h?.kind==="image"?s.jsx("img",{src:Zc(h.path,!0),alt:h.name,onError:()=>j("图片无法预览,可以下载后打开。")}):s.jsx("div",{className:"library-empty",children:"这个文件暂不支持直接预览,可以下载后打开。"})]}):null]})]})}async function Pd(t={}){const i=new URLSearchParams({archived:t.archived??"false",limit:"50"});return t.query&&i.set("query",t.query),t.cursor&&i.set("cursor",t.cursor),Ue(`/api/v1/sessions?${i}`,{signal:t.signal})}function Wg(t,i="markdown"){return xt(`/api/v1/sessions/${encodeURIComponent(t)}/export?format=${i}`)}function Hw({onAuthLost:t,onOpen:i,onChanged:r,version:a=0,onDirtyChange:u}){const[d,c]=S.useState(""),[h,p]=S.useState(""),[m,y]=S.useState("false"),[b,v]=S.useState([]),[x,j]=S.useState(null),[R,C]=S.useState(!0),[T,_]=S.useState(!1),[D,q]=S.useState(""),[se,N]=S.useState(""),[U,X]=S.useState(0),[H,A]=S.useState(""),[I,L]=S.useState(null),P=S.useRef(null),W=S.useRef(null),ee=S.useRef(null),G=S.useRef(null);S.useEffect(()=>{I?.id&&P.current?.focus()},[I?.id]),S.useEffect(()=>{I?.error&&W.current?.focus()},[I?.error]);const B=()=>{L(null),requestAnimationFrame(()=>{ee.current?.isConnected?ee.current.focus():G.current?.focus()})};S.useEffect(()=>{u?.(!!I||!!H)},[I,H,u]),S.useEffect(()=>()=>u?.(!1),[u]);const Q=S.useRef(null),fe=S.useRef(null),k=S.useRef({onAuthLost:t,onChanged:r,onOpen:i});k.current={onAuthLost:t,onChanged:r,onOpen:i};const O=S.useCallback(Z=>{Z instanceof Xe&&Z.status===401?k.current.onAuthLost():q(Z instanceof Error?Z.message:"会话操作失败,请重试。")},[]);S.useEffect(()=>{const Z=setTimeout(()=>p(d.trim()),200);return()=>clearTimeout(Z)},[d]),S.useEffect(()=>{Q.current?.abort();const Z=new AbortController;return Q.current=Z,C(!0),_(!1),q(""),Pd({query:h,archived:m,signal:Z.signal}).then(ne=>{Z.signal.aborted||(v(ne.sessions),j(ne.nextCursor))}).catch(ne=>{Z.signal.aborted||O(ne)}).finally(()=>{Z.signal.aborted||C(!1)}),()=>Z.abort()},[h,m,a,U,O]),S.useEffect(()=>()=>{Q.current?.abort(),fe.current?.abort()},[]);const le=()=>{if(!x||T||R)return;const Z=new AbortController;Q.current?.abort(),Q.current=Z,_(!0),Pd({query:h,archived:m,cursor:x,signal:Z.signal}).then(ne=>{Z.signal.aborted||(v(ge=>{const Y=new Set(ge.map(ve=>ve.sessionId));return[...ge,...ne.sessions.filter(ve=>!Y.has(ve.sessionId))]}),j(ne.nextCursor))}).catch(ne=>{Z.signal.aborted||O(ne)}).finally(()=>{Z.signal.aborted||_(!1)})},E=async(Z,ne,ge=!1)=>{if(fe.current)return;const Y=new AbortController;fe.current=Y,A(Z),q(""),N(""),"title"in ne&&L(ve=>ve&&{...ve,error:""});try{if(await Ue(`/api/v1/sessions/${encodeURIComponent(Z)}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(ne),signal:Y.signal}),Y.signal.aborted)return;"title"in ne?(B(),N(ne.title?"标题已保存。":"已恢复自动标题。")):N(ne.archived?"对话已归档,可以在“已归档”中恢复。":"对话已恢复。"),X(ve=>ve+1),k.current.onChanged?.(),ge&&k.current.onOpen(Z)}catch(ve){Y.signal.aborted||("title"in ne&&!(ve instanceof Xe&&ve.status===401)?L(De=>De?.id===Z?{...De,error:ve instanceof Error?ve.message:"标题保存失败,请重试。",conflict:ve instanceof Xe&&ve.status===409,unavailable:ve instanceof Xe&&ve.status===404}:De):O(ve))}finally{fe.current===Y&&(fe.current=null),Y.signal.aborted||A("")}},J=async()=>{if(!I||fe.current)return;const Z=I.id,ne=new AbortController;fe.current=ne,A(Z),L(ge=>ge&&{...ge,error:""});try{const ge=await Ue(`/api/v1/sessions/${encodeURIComponent(Z)}`,{signal:ne.signal});if(ne.signal.aborted)return;L(Y=>Y?.id===Z?{...Y,expectedTitle:ge.customTitle,reviewedTitle:ge.title,conflict:!1,unavailable:!1,error:""}:Y),P.current?.focus()}catch(ge){ne.signal.aborted||(ge instanceof Xe&&ge.status===401?O(ge):L(Y=>Y?.id===Z?{...Y,error:ge instanceof Error?ge.message:"无法读取最新标题,请重试。",unavailable:ge instanceof Xe&&ge.status===404}:Y))}finally{fe.current===ne&&(fe.current=null),ne.signal.aborted||A("")}},be=Z=>Z.archivedAt?void E(Z.sessionId,{archived:!1},!0):k.current.onOpen(Z.sessionId);return s.jsxs("section",{className:"hub-library hub-sessions","aria-labelledby":"hub-history-heading",children:[s.jsxs("header",{className:"library-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{id:"hub-history-heading",children:"历史对话"}),s.jsx("p",{children:"查找、整理并导出当前工作区的对话。"})]}),s.jsx("button",{className:"library-button",onClick:()=>X(Z=>Z+1),children:"刷新"})]}),D?s.jsx("div",{className:"library-error",role:"alert",children:D}):null,se?s.jsx("p",{className:"library-hint",role:"status",children:se}):null,s.jsxs("div",{className:"session-toolbar",children:[s.jsxs("label",{className:"library-search",children:[s.jsx("span",{className:"sr-only",children:"搜索对话标题"}),s.jsx("input",{ref:G,type:"search",placeholder:"搜索对话标题…",value:d,onChange:Z=>c(Z.target.value)})]}),s.jsxs("label",{children:[s.jsx("span",{className:"sr-only",children:"对话范围"}),s.jsxs("select",{value:m,onChange:Z=>y(Z.target.value),children:[s.jsx("option",{value:"false",children:"当前对话"}),s.jsx("option",{value:"true",children:"已归档"}),s.jsx("option",{value:"all",children:"全部对话"})]})]})]}),I?s.jsxs("form",{className:"session-history-editor","aria-labelledby":"session-title-editor-heading",onSubmit:Z=>{Z.preventDefault(),!H&&!I.conflict&&!I.unavailable&&E(I.id,{title:I.title,expectedTitle:I.expectedTitle})},children:[s.jsxs("div",{children:[s.jsx("h2",{id:"session-title-editor-heading",children:"重命名对话"}),s.jsxs("p",{className:"library-hint",children:["正在编辑:",I.originalTitle]}),!R&&!b.some(Z=>Z.sessionId===I.id)?s.jsx("p",{className:"library-hint",children:"此对话已不在当前列表中,标题草稿仍保留在这里。"}):null]}),I.error?s.jsx("div",{className:"library-error",id:"session-title-error",role:"alert",tabIndex:-1,ref:W,children:I.error}):null,I.reviewedTitle?s.jsxs("p",{className:"session-title-review",role:"status",children:["最新标题:",s.jsx("strong",{children:I.reviewedTitle}),"。你的草稿仍保留,请核对后再保存。"]}):null,s.jsxs("label",{children:[s.jsx("span",{children:"对话标题"}),s.jsx("input",{ref:P,className:"library-title-input",value:I.title,maxLength:1024,"aria-describedby":I.error?"session-title-error":void 0,onChange:Z=>{const ne=Z.target.value;L(ge=>ge&&{...ge,title:ne})},readOnly:!!H})]}),s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{type:"submit",className:"library-button primary",disabled:!!H||I.conflict||I.unavailable,children:H?"处理中…":I.reviewedTitle?"确认保存我的标题":"保存标题"}),I.conflict||I.unavailable?s.jsx("button",{type:"button",className:"library-button",disabled:!!H,onClick:()=>{J()},children:"读取最新标题"}):null,s.jsx("button",{type:"button",className:"library-button",disabled:!!H,onClick:B,children:"取消"}),I.expectedTitle?s.jsx("button",{type:"button",className:"library-button",disabled:!!H||I.conflict||I.unavailable,onClick:()=>{E(I.id,{title:"",expectedTitle:I.expectedTitle})},children:"使用自动标题"}):null]})]}):null,s.jsx("div",{className:"session-history-list","aria-busy":R,children:R?s.jsx("p",{className:"library-empty",role:"status",children:"正在读取对话…"}):b.length===0?s.jsx("p",{className:"library-empty",children:h?"没有找到匹配的对话。":m==="true"?"还没有归档的对话。":"还没有保存的对话,开始一条新对话后会显示在这里。"}):b.map(Z=>s.jsxs("article",{className:"session-history-row",children:[s.jsxs("div",{className:"session-history-info",children:[s.jsx("button",{className:"session-history-title",onClick:()=>be(Z),children:Z.title}),Z.preview&&Z.preview!==Z.title?s.jsx("p",{children:Z.preview.slice(0,150)}):null,s.jsxs("div",{className:"session-history-meta",children:[s.jsx("span",{children:new Date(Z.lastActiveAt||Z.startedAt).toLocaleString()}),s.jsxs("span",{children:[Z.turnCount," 轮"]}),Z.running?s.jsx("span",{children:"正在运行"}):Z.archivedAt?s.jsx("span",{children:"已归档"}):null]})]}),s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{className:"library-button",disabled:!!H||!!I,onClick:ne=>{ee.current=ne.currentTarget,N(""),L({id:Z.sessionId,title:Z.title,originalTitle:Z.title,expectedTitle:Z.customTitle})},children:I?.id===Z.sessionId?"正在编辑":"重命名"}),s.jsx("button",{className:"library-button",disabled:!!H||Z.running,onClick:()=>{E(Z.sessionId,{archived:!Z.archivedAt})},children:H===Z.sessionId?"处理中…":Z.archivedAt?"恢复":"归档"}),Z.running?s.jsx("button",{className:"library-button",disabled:!0,children:"运行结束后导出"}):s.jsxs("details",{className:"session-export",children:[s.jsx("summary",{className:"library-button",children:"导出"}),s.jsxs("div",{children:[s.jsx("a",{href:Wg(Z.sessionId),download:!0,children:"Markdown 文档"}),s.jsx("a",{href:Wg(Z.sessionId,"json"),download:!0,children:"完整 JSON 记录"})]})]})]})]},Z.sessionId))}),x&&!R?s.jsx("div",{className:"session-load-more",children:s.jsx("button",{className:"library-button",disabled:T,onClick:le,children:T?"读取中…":"加载更多"})}):null]})}var Gw=Bb();function yo(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function oo(t){return typeof t=="string"?t:""}function Fb(t){return Array.isArray(t)?t.map(yo).filter(i=>i!==void 0):[]}function Vw(t){return typeof t=="string"?t:Fb(t).filter(i=>i.type==="text").map(i=>oo(i.text)).join("")}function ma(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function Jc(t){const i=t.replace(/\\/g,"/").split("/").filter(Boolean).pop()||"附件";return t.includes(".code-shell/attachments/")?i.replace(/^[a-f0-9]{16}-/,""):i}function Wc(t){const i=typeof t=="number"?t:Number(t);return Number.isSafeInteger(i)&&i>=0?i:0}function Pb(t,i={}){const r=[],a=p=>/^(?:[a-zA-Z]:[\\/]|[\\/])/.test(p)||!i.cwd?p:`${i.cwd.replace(/[\\/]$/,"")}/${p}`,u=[];let d=Vw(t.content);d=d.replace(/<attached-file\s+path="([^"]*)">\s*([\s\S]*?)<\/attached-file>/g,(p,m,y)=>{if(!/^absolutePath:\s*.+$/m.test(y)||!/^origin:\s*.+$/m.test(y))return p;const b=y.match(/^mime:\s*(.+)$/m)?.[1]?.trim();return r.push({name:Jc(ma(m)),path:ma(m),...i.includeAbsolutePaths?{absPath:y.match(/^absolutePath:\s*(.+)$/m)[1].trim()}:{},size:Wc(y.match(/^size:\s*(\d+)\s*$/m)?.[1]),...b?{mime:b}:{}}),""}),d=d.replace(/<attached-directory\s+path="([^"]*)"[^>]*>[\s\S]*?<\/attached-directory>/g,(p,m)=>(r.push({name:`${Jc(ma(m))}/`,path:ma(m),...i.includeAbsolutePaths?{absPath:a(ma(m))}:{},size:0}),"")),d=d.replace(/<attached-image-paths>\s*([\s\S]*?)<\/attached-image-paths>\s*(?:\(上面附带的图片在工作区的真实路径[^\n]*\))?/g,(p,m)=>(u.push(...m.split(`
|
|
21
|
+
`).map(y=>y.trim()).filter(Boolean)),""));const c=Fb(t.content).filter(p=>p.type==="image");for(let p=0;p<Math.max(c.length,u.length);p++){const m=yo(c[p]?.source),y=oo(m?.data).replace(/\s/g,"");r.push({name:u[p]?Jc(u[p]):`图片 ${p+1}`,...u[p]?{path:u[p]}:{},...i.includeAbsolutePaths&&u[p]?{absPath:a(u[p])}:{},size:y?Math.max(0,Math.floor(y.length*3/4)-(y.match(/=+$/)?.[0].length??0)):Wc(m?.byteLength),...typeof m?.media_type=="string"?{mime:m.media_type}:{}})}const h=Array.isArray(t.attachments)?t.attachments.flatMap(p=>{const m=yo(p),y=oo(m?.name)||oo(m?.originalName);return y?[{name:y,size:Wc(m?.size),...typeof m?.mime=="string"?{mime:m.mime}:{},...typeof m?.path=="string"?{path:m.path}:{}}]:[]}):[];return{text:typeof t.displayText=="string"?t.displayText:d.trim(),attachments:h.length?h:r}}function Qb(t){if(t.type!=="session_user_message"&&t.type!=="steer_injected")return t;const i=yo(t.transcriptMessage);return i?{...t,...Pb(i,{includeAbsolutePaths:!0,...typeof i.cwd=="string"?{cwd:i.cwd}:{}})}:t}function ey(t){return t.replace(/<system-reminder>[\s\S]*?<\/system-reminder>\s*/g,"")}function uo(){return{items:[],run:"idle",seq:0,liveByAgent:{}}}function ga(t){return t.agentId??""}function eo(t,i,r=!1){const a=i.goalId;if(t.goalId!==a&&!(r&&t.goalId===void 0&&a!==void 0))return!0;const u=i.revision;return t.goalRevision!==void 0&&(u===void 0||u<t.goalRevision)}function $w(t){switch(t){case"aborted_streaming":case"aborted_tools":return"idle";case"prompt_too_long":case"model_error":case"image_error":case"replay_incomplete":case"unverified_write":return"error";default:return"completed"}}function Yw(t){if(!t||typeof t!="object")return null;const i=t;if(i.method==="agent/streamEvent"&&i.params&&typeof i.params=="object"){const r=i.params;if(r.event&&typeof r.event=="object")return{event:r.event,sessionId:typeof r.sessionId=="string"?r.sessionId:void 0}}return typeof i.type=="string"?{event:i}:null}function vr(t,i){const r=Yw(i);if(!r)return t;const{sessionId:a}=r,u=Qb(r.event),d=u.type;let c=t;a&&a!==c.sessionId&&(c={...c,sessionId:a});const h=p=>{const m=c.seq+1;return[`${p}-${m}`,{...c,seq:m}]};switch(d){case"stream_request_start":{const p=ga(u),[m,y]=h("a"),b={kind:"assistant",id:m,text:"",reasoning:"",done:!1,agentId:u.agentId,...typeof u.messageId=="string"?{messageId:u.messageId}:{}};return{...y,items:[...y.items,b],liveByAgent:{...y.liveByAgent,[p]:m},run:"running"}}case"text_delta":{const p=u.text??"",m=ga(u),y=c.liveByAgent[m];if(y&&c.items.find(R=>R.id===y&&R.kind==="assistant"))return{...c,run:"running",items:c.items.map(R=>R.id===y&&R.kind==="assistant"?{...R,text:R.text+p}:R)};const[v,x]=h("a"),j={kind:"assistant",id:v,text:p,reasoning:"",done:!1,agentId:u.agentId};return{...x,items:[...x.items,j],liveByAgent:{...x.liveByAgent,[m]:v},run:"running"}}case"thinking_delta":{const p=u.text??"",m=ga(u),y=c.liveByAgent[m];if(y&&c.items.some(j=>j.id===y&&j.kind==="assistant"))return{...c,run:"running",items:c.items.map(j=>j.id===y&&j.kind==="assistant"?{...j,reasoning:j.reasoning+p}:j)};const[b,v]=h("a"),x={kind:"assistant",id:b,text:"",reasoning:p,done:!1,agentId:u.agentId};return{...v,items:[...v.items,x],liveByAgent:{...v.liveByAgent,[m]:b},run:"running"}}case"tool_use_start":{const p=u.toolCall;if(!p||c.items.some(v=>v.kind==="tool"&&v.id===p.id))return c;const m=c.orphanResults?.[p.id],y={kind:"tool",id:p.id,name:p.toolName,args:p.args,summary:p.summary,done:!!m,result:m?.result,error:m?.error,agentId:u.agentId};let b=c.orphanResults;if(m){const{[p.id]:v,...x}=c.orphanResults;b=Object.keys(x).length>0?x:void 0}return{...c,run:"running",items:[...c.items,y],orphanResults:b}}case"tool_use_args_delta":{const p=u.toolCallId,m=u.args;return!p||!m?c:{...c,items:c.items.map(y=>y.kind==="tool"&&y.id===p?{...y,args:{...y.args??{},...m}}:y)}}case"tool_result":{const p=u.result;return p?c.items.some(y=>y.kind==="tool"&&y.id===p.id)?{...c,items:c.items.map(y=>y.kind==="tool"&&y.id===p.id?{...y,done:!0,result:ey(p.result??p.error??""),error:!!(p.isError||p.error)}:y)}:{...c,orphanResults:{...c.orphanResults??{},[p.id]:{result:p.result??p.error??"",error:!!(p.isError||p.error)}}}:c}case"room_tool_result":{const p=u.summary??"",m=ey(p),y=!!u.isError;let b=-1;for(let j=c.items.length-1;j>=0;j--)if(c.items[j].kind==="tool"&&!c.items[j].done){b=j;break}if(b===-1)return c;const v=c.items.slice(),x=v[b];return v[b]={...x,done:!0,result:m,summary:m||x.summary,error:y},{...c,items:v}}case"tool_summary":{const p=u.summary??"",m=Array.isArray(u.toolCallIds)?u.toolCallIds.filter(R=>typeof R=="string"):[],b=m.length>0?m[m.length-1]:void 0,v=u.agentId;if(b){let R=!1;const C=c.items.map(T=>T.kind!=="tool"||T.id!==b||T.agentId!==v?T:(R=!0,{...T,summary:p}));return R?{...c,items:C}:c}if(v){let R=-1;for(let T=c.items.length-1;T>=0;T--){const _=c.items[T];if(_.kind==="tool"&&_.agentId===v){R=T;break}}if(R===-1)return c;const C=c.items.slice();return C[R]={...C[R],summary:p},{...c,items:C}}let x=-1;for(let R=c.items.length-1;R>=0;R--){const C=c.items[R];if(C.kind==="tool"&&C.agentId===void 0){x=R;break}}if(x===-1)return c;const j=c.items.slice();return j[x]={...j[x],summary:p},{...c,items:j}}case"tombstone":{if(typeof u.messageId!="string")return c;const p=new Set(c.items.filter(m=>m.kind==="assistant"&&m.messageId===u.messageId||m.kind==="tool"&&m.id===u.messageId).map(m=>m.id));return p.size?{...c,items:c.items.filter(m=>!p.has(m.id)),liveByAgent:Object.fromEntries(Object.entries(c.liveByAgent).filter(([,m])=>!p.has(m)))}:c}case"assistant_message":{const p=ga(u);if(!(p in c.liveByAgent))return c;const{[p]:m,...y}=c.liveByAgent,b=c.items.map(v=>v.kind==="assistant"&&!v.done&&(v.agentId??"")===p?{...v,done:!0}:v);return{...c,liveByAgent:y,items:b}}case"turn_complete":{const p=u.reason??"completed",m=ga(u),{[m]:y,...b}=c.liveByAgent,v=c.items.map(x=>x.kind==="assistant"&&!x.done&&(x.agentId??"")===m?{...x,done:!0}:x);return u.agentId?{...c,liveByAgent:b,items:v}:{...c,liveByAgent:b,items:v,run:$w(p)}}case"goal_set":{const p=u.objective??"",m=!!u.paused;return c.goal&&c.goalId===u.goalId&&eo(c,u)?c:{...c,goal:p?`◎ ${p}${m?" (已暂停)":""}`:"◎ 目标",goalId:u.goalId,goalPaused:m,goalRevision:u.revision}}case"goal_updated":{if(c.goal&&eo(c,u,!0))return c;const p=u.goalId,m=u.objective??"",y=!!u.paused;return{...c,goal:m?`◎ ${m}${y?" (已暂停)":""}`:c.goal,goalId:p??c.goalId,goalPaused:y,goalRevision:u.revision??c.goalRevision}}case"goal_cleared":return c.goal&&eo(c,u)?c:{...c,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};case"goal_progress":{if(c.goal&&eo(c,u))return c;const p=u.status??"";if(p==="met"||p==="exhausted")return{...c,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};const m=u.round,y=m?`目标 · 第 ${m} 轮 (${p})`:`目标 (${p})`;return{...c,goal:y,goalRevision:u.revision??c.goalRevision}}case"task_update":{const p=u.agentId;if(!p)return c;const m=u.tasks??[],y=m.filter(j=>j.status==="completed").length,b=`任务 ${y}/${m.length}`,v=c.items.findIndex(j=>j.kind==="subagent"&&j.agentId===p),x={kind:"subagent",id:`sub-${p}`,agentId:p,label:b,status:m.length>0&&y===m.length?"completed":"running"};if(v>=0){const j=c.items.slice();return j[v]=x,{...c,items:j}}return{...c,items:[...c.items,x]}}case"agent_start":{const p=u.agentId;if(!p)return c;const m={kind:"subagent",id:`sub-${p}`,agentId:p,label:u.name||u.description||"子代理",status:u.status==="recorded"?"recorded":"running"};return c.items.some(y=>y.kind==="subagent"&&y.agentId===p)?c:{...c,items:[...c.items,m]}}case"agent_end":{const p=u.agentId;return{...c,items:c.items.map(m=>m.kind==="subagent"&&m.agentId===p?{...m,status:u.error?"error":"completed"}:m)}}case"background_agent_completed":{const p=typeof u.agentId=="string"?u.agentId:"",m=u.status==="failed",y=m?"error":u.status==="cancelled"?"cancelled":"completed",b=typeof u.name=="string"?u.name:"后台任务",v=m?u.error??u.description:u.finalText??u.description,x=`${b} · ${y}${typeof v=="string"&&v.trim()?`: ${v.trim().slice(0,240)}`:""}`,[j,R]=h("bg-done");return{...R,items:[...c.items.map(C=>C.kind==="subagent"&&C.agentId===p?{...C,status:y}:C),{kind:"system",id:j,text:x}]}}case"error":{const[p,m]=h("err");return{...m,run:"error",liveByAgent:{},items:[...m.items,{kind:"system_error",id:p,text:u.error||"运行出错"}]}}case"session_title":return{...c,title:u.title};case"session_user_message":case"steer_injected":case"user_message":{if(u.agentId||u.injected===!0||u.authority==="agent"||u.authority==="system"||u.authority==="policy")return c;const p=typeof u.clientMessageId=="string"?u.clientMessageId:void 0,m=Array.isArray(u.attachments)?u.attachments.map(v=>v).filter(v=>!!v&&typeof v.name=="string"&&typeof v.size=="number"&&Number.isFinite(v.size)&&v.size>=0).map(v=>({name:v.name,size:v.size,...typeof v.mime=="string"?{mime:v.mime}:{},...typeof v.path=="string"?{path:v.path}:{}})):void 0;if(p&&c.items.some(v=>v.kind==="user"&&v.clientMessageId===p))return m?.length?{...c,items:c.items.map(v=>v.kind==="user"&&v.clientMessageId===p?{...v,attachments:m.map((x,j)=>{const R=v.attachments?.[j];return R?.name===x.name?{...R,...x}:x})}:v)}:c;const[y,b]=h("u");return{...b,items:[...b.items,{kind:"user",id:y,text:u.text??"",...m?.length?{attachments:m}:{},...p?{clientMessageId:p}:{}}]}}case"assistant_text":{const[p,m]=h("a");return{...m,run:"running",items:[...m.items,{kind:"assistant",id:p,text:u.text??"",reasoning:"",done:!0,agentId:u.agentId}]}}default:return c}}function Fw(t,i,r,a){const u=`u-${t.seq+1}`;return{...t,seq:t.seq+1,items:[...t.items,{kind:"user",id:u,text:i,...r?.length?{attachments:r}:{},...a?{clientMessageId:a}:{}}]}}const Pw="codeshell.uiLanguage";function Qw(){try{const t=globalThis.localStorage?.getItem(Pw);if(t==="zh"||t==="en")return t}catch{}return"zh"}const Xw={zh:{mobile:{app:{extendGoal:"延长目标",clearGoal:"清除目标",loadingCcSession:"正在加载 CC 会话…",loadingSession:"正在加载会话…",conversationFallback:"对话",desktopSession:"桌面会话",newSession:"新会话",openSessionsAria:"打开会话",leaveSessionAria:"退出会话",deviceFallback:"设备",logoutAria:"退出登录",permission:"权限",ccRoomObserving:"此会话当前为只读查看;请在桌面端明确接管后再发送消息。"},approval:{risk:{low:"低风险",medium:"中风险",high:"高风险"},readSourceSummary:"读取数据源 {source} / {scope} / {resource}",question:"问题",customPlaceholder:"或输入自定义回答…",sendCustom:"发送自定义回答",rememberScope:"记住范围",scope:{once:"仅本次",session:"本会话",project:"本项目"},pathScopeLabel:"路径范围",pathScope:{file:"此文件",dir:"此目录",tool:"此工具"},allow:"允许",reject:"拒绝"},cc:{title:"CC 会话",subtitle:"外部 {label} 会话",selectProjectFirst:"先选择一个项目。",probingCli:"正在检测 {label} CLI…",cliMissing:"未检测到 {label} CLI(需在桌面端机器的 PATH 中)。",loadingSessions:"正在加载 cc 会话…",empty:"该项目下没有 {label} 会话。",messageCount:"{count} 条"},sidePane:{localTab:"会话",ccTab:"CC 会话"},composer:{disconnected:"未连接",placeholder:"发消息…",stop:"停止",send:"发送",chooseImages:"从相册选择图片",takePhoto:"拍照",removeImage:"移除图片",uploading:"上传中…",tooManyImages:"每条消息最多发送 4 张图片",unsupportedImage:"不支持此图片格式",sendFailed:"图片发送失败,请重试"},connection:{connectingTitle:"正在连接…",connectingBody:"与 CodeShell 建立通道",authenticatingTitle:"认证中…",authenticatingBody:"正在校验设备身份",unpairedTitle:"未配对",unpairedBody:"请在 CodeShell 桌面端打开「设置 → 远程」,扫码或打开配对链接。",offlineTitle:"连接断开",offlineBody:"正在自动重连…"},format:{noProject:"无项目",justNow:"刚刚",minutesAgo:"{n} 分钟前",hoursAgo:"{n} 小时前",daysAgo:"{n} 天前",monthsAgo:"{n} 个月前",yearsAgo:"{n} 年前"},notice:{roomMissing:"会话不存在或未就绪",roomError:"会话错误",sessionRecoveryIncomplete:"当前回复的开头尚未恢复,请重新打开会话以读取已保存的内容。",sessionRecoveryHistoryOnly:"已恢复保存的聊天记录。当前回复的实时部分暂时无法接续,请稍后重新打开会话。",goalExtendFailed:"延长目标失败",ccRoomOpenFailed:"cc 会话无法打开",ccRoomObserving:"此 CC 会话当前为只读查看,消息未发送",attachmentSendFailed:"图片发送失败:{error}"},permissionMode:{default:"默认",acceptEdits:"自动改",bypassPermissions:"全放行",defaultDesc:"每个工具调用都要你确认",acceptEditsDesc:"自动放行文件编辑,其余仍确认",bypassDesc:"跳过所有权限确认(危险)",title:"选择权限模式",confirmBypass:"全放行模式会跳过所有权限确认。确定吗?"},sessionList:{title:"会话",takeoverCount:"{count} 个可接管",refreshAria:"刷新会话",new:"新建",createHint:"新会话默认使用当前目录",currentProject:"当前项目 · {name}",noProjectConversation:"无项目对话",desktopCwd:"当前桌面目录",unboundRepo:"不绑定 repo",followsDesktopCwd:"跟随桌面当前 cwd",otherProjects:"其他项目",loading:"正在加载会话…",empty:"还没有会话。点「新建」开一个,或在桌面端开始。",automation:"自动",noProjectPath:"无项目路径",unreadAria:"有新内容",primaryRoot:"主目录",secondaryRoot:"次目录"},status:{conn:{connecting:"连接中…",authenticating:"认证中…",unpaired:"未配对",online:"在线",offline:"已断开"},run:{idle:"空闲",running:"运行中",waiting:"待审批",completed:"已完成",error:"出错"}},storage:{browserDevice:"{platform} 浏览器"},stream:{showReasoning:"显示思考",hideReasoning:"隐藏思考",subagent:"子代理",loading:"正在加载…",generating:"正在生成回复",emptyHint:"发个任务试试,或在侧栏打开一个 Claude Code 会话。"},tool:{running:"运行中",failed:"失败",completed:"完成",fallbackName:"操作",truncated:"… (已截断)"}}},en:{mobile:{app:{extendGoal:"Extend goal",clearGoal:"Clear goal",loadingCcSession:"Loading CC session…",loadingSession:"Loading conversation…",conversationFallback:"Conversation",desktopSession:"Desktop session",newSession:"New session",openSessionsAria:"Open sessions",leaveSessionAria:"Leave session",deviceFallback:"Device",logoutAria:"Log out",permission:"Permission",ccRoomObserving:"This session is read-only. Take it over explicitly on desktop before sending messages."},approval:{risk:{low:"Low risk",medium:"Medium risk",high:"High risk"},readSourceSummary:"Read data source {source} / {scope} / {resource}",question:"Question",customPlaceholder:"Or enter a custom answer…",sendCustom:"Send custom answer",rememberScope:"Remember scope",scope:{once:"Once",session:"This session",project:"This project"},pathScopeLabel:"Path scope",pathScope:{file:"This file",dir:"This directory",tool:"This tool"},allow:"Allow",reject:"Deny"},cc:{title:"CC sessions",subtitle:"External {label} sessions",selectProjectFirst:"Select a project first.",probingCli:"Checking {label} CLI…",cliMissing:"{label} CLI was not found (it must be in PATH on the desktop machine).",loadingSessions:"Loading cc sessions…",empty:"No {label} sessions in this project.",messageCount:"{count} messages"},sidePane:{localTab:"Sessions",ccTab:"CC"},composer:{disconnected:"Disconnected",placeholder:"Message…",stop:"Stop",send:"Send",chooseImages:"Choose images",takePhoto:"Take photo",removeImage:"Remove image",uploading:"Uploading…",tooManyImages:"Up to 4 images can be sent per message",unsupportedImage:"This image format is not supported",sendFailed:"Could not send images; try again"},connection:{connectingTitle:"Connecting…",connectingBody:"Opening a channel to CodeShell",authenticatingTitle:"Authenticating…",authenticatingBody:"Verifying this device",unpairedTitle:"Not paired",unpairedBody:"Open Settings → Remote in CodeShell desktop, then scan the QR code or open the pairing link.",offlineTitle:"Disconnected",offlineBody:"Reconnecting automatically…"},format:{noProject:"No project",justNow:"Just now",minutesAgo:"{n} min ago",hoursAgo:"{n} hr ago",daysAgo:"{n} days ago",monthsAgo:"{n} mo ago",yearsAgo:"{n} yr ago"},notice:{roomMissing:"Session does not exist or is not ready",roomError:"Session error",sessionRecoveryIncomplete:"The beginning of this reply could not be restored. Reopen the conversation to read its saved content.",sessionRecoveryHistoryOnly:"Saved chat history has been restored. Reopen the conversation later to see the rest of this reply.",goalExtendFailed:"Failed to extend goal",ccRoomOpenFailed:"Could not open cc session",ccRoomObserving:"This CC session is read-only; the message was not sent",attachmentSendFailed:"Could not send images: {error}"},permissionMode:{default:"Default",acceptEdits:"Auto-edit",bypassPermissions:"Allow all",defaultDesc:"Confirm every tool call",acceptEditsDesc:"Allow file edits automatically; confirm everything else",bypassDesc:"Skip all permission confirmations (dangerous)",title:"Choose permission mode",confirmBypass:"Allow all mode skips every permission confirmation. Continue?"},sessionList:{title:"Sessions",takeoverCount:"{count} available",refreshAria:"Refresh sessions",new:"New",createHint:"New sessions default to the current directory",currentProject:"Current project · {name}",noProjectConversation:"No-project conversation",desktopCwd:"Current desktop directory",unboundRepo:"Do not bind a repo",followsDesktopCwd:"Follow desktop current cwd",otherProjects:"Other projects",loading:"Loading sessions…",empty:"No sessions yet. Tap “New” to start one, or start from desktop.",automation:"Automation",noProjectPath:"No project path",unreadAria:"New content",primaryRoot:"Primary",secondaryRoot:"Secondary"},status:{conn:{connecting:"Connecting…",authenticating:"Authenticating…",unpaired:"Not paired",online:"Online",offline:"Disconnected"},run:{idle:"Idle",running:"Running",waiting:"Awaiting approval",completed:"Completed",error:"Error"}},storage:{browserDevice:"{platform} browser"},stream:{showReasoning:"Show reasoning",hideReasoning:"Hide reasoning",subagent:"Subagent",loading:"Loading…",generating:"Generating response",emptyHint:"Send a task, or open a Claude Code session from the sidebar."},tool:{running:"Running",failed:"Failed",completed:"Completed",fallbackName:"Operation",truncated:"… (truncated)"}}}},ty=Xw;function ny(t,i){let r=t;for(const a of i.split(".")){if(r==null||typeof r!="object")return;r=r[a]}return typeof r=="string"?r:void 0}function Kw(t,i){return i?t.replace(/\{(\w+)\}/g,(r,a)=>a in i?String(i[a]):r):t}function Zw(t,i,r){const a=ny(ty[t],i)??ny(ty.zh,i)??i;return Kw(a,r)}function Jw(t,i){return Zw(Qw(),t,i)}const Ww=["command","file_path","path","url","pattern","query"];function eS(t,i,r){let a="";const u=t?.source,d=t?.scope,c=t?.resource;if(r==="ReadSource"&&typeof u=="string"&&u.length>0&&typeof d=="string"&&d.length>0&&typeof c=="string"&&c.length>0)a=Jw("mobile.approval.readSourceSummary",{source:u,scope:d,resource:c});else for(const p of Ww){const m=t?.[p];if(typeof m=="string"&&m.length>0){a=m;break}}a||(a=JSON.stringify(t??{}));let h;return i==="low"||i==="medium"||i==="high"?h=i:i===void 0||i===""?h="medium":h="high",{summary:a,risk:h}}const tS=16*1024*1024;function br(t){if(typeof t!="string"||t.length>2048||!/^[A-Za-z0-9_-]+$/.test(t))throw new Error("Invalid output cursor");const i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));if(typeof i.identity!="string"||!Number.isSafeInteger(i.sequence)||i.sequence<0||!Number.isSafeInteger(i.offset)||i.offset<0)throw new Error("Invalid output cursor");return i}function nS(t){if(t.length>Math.ceil(64*1024/3)*4||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))throw new Error("Invalid output fragment");const i=atob(t);return Uint8Array.from(i,r=>r.charCodeAt(0))}function ja(t,i){try{const r=br(t),a=br(i);return r.identity===a.identity?Math.sign(r.sequence-a.sequence):void 0}catch{return}}function iS(t,i,r){if(t.incomplete)return!1;try{if(i.version!==1||i.status!=="ok"||!i.from||!i.through||!i.next||!i.coverageStart||!Array.isArray(i.frames)||i.frames.length>512||new TextEncoder().encode(JSON.stringify(i)).length>1024*1024+16*1024)throw new Error("Output recovery is incomplete");if((t.cursor??i.coverageStart)!==i.from||t.through&&t.through!==i.through||t.coverageStart&&t.coverageStart!==i.coverageStart||t.legacyBaseThroughEventId!==void 0&&t.legacyBaseThroughEventId!==i.legacyBaseThroughEventId)throw new Error("Output recovery page changed its snapshot");let a=br(i.from);const u=br(i.through),d=br(i.coverageStart);if(d.sequence!==0||d.identity!==a.identity||u.identity!==a.identity||a.sequence>u.sequence)throw new Error("Output recovery cursor domain changed");let c=t.pending?{...t.pending,chunks:t.pending.chunks.slice()}:void 0,h=t.appliedCursor??i.from;const p=[];for(const y of i.frames){const b=br(y.cursor);if(b.identity!==a.identity||b.sequence!==a.sequence+1||y.sequence!==b.sequence||b.offset<=a.offset||b.sequence>u.sequence||!!y.event==!!y.fragment)throw new Error("Output recovery has a gap");let v=y.event;if(y.fragment){const x=y.fragment;if(!c){if(x.index!==0||!Number.isSafeInteger(x.total)||x.total<2||x.total>256)throw new Error("Output fragment has no beginning");c={id:x.id,total:x.total,next:0,bytes:0,chunks:[]}}if(x.id!==c.id||x.total!==c.total||x.index!==c.next)throw new Error("Output fragment has a gap");const j=nS(x.data);if(c.bytes+=j.length,c.bytes>tS)throw new Error("Output fragment exceeds its budget");if(c.chunks.push(j),c.next++,c.next===c.total){const R=new Uint8Array(c.bytes);let C=0;for(const T of c.chunks)R.set(T,C),C+=T.length;v=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(R)),c=void 0}}else if(c)throw new Error("Output fragment was interrupted");if(v){if(typeof v!="object"||typeof v.type!="string"||v.outputRecovery==="incomplete")throw new Error("Invalid output event");p.push({...Qb(v),outputCursor:y.cursor}),h=y.cursor}a=b}const m=br(i.next);if(m.identity!==a.identity||m.sequence!==a.sequence||m.offset!==a.offset||(i.frames.at(-1)?.cursor??i.from)!==i.next||i.complete!==(i.next===i.through)||i.complete&&c||!i.complete&&!i.frames.length)throw new Error("Output recovery page did not establish coverage");t.cursor=i.next,t.appliedCursor=h,t.through=i.through,t.coverageStart=i.coverageStart,t.legacyBaseThroughEventId=i.legacyBaseThroughEventId,t.pending=c;for(const y of p)r(y);return i.complete}catch{return t.incomplete=!0,t.pending=void 0,!1}}const rS=new Set(["session_started","stream_request_start","text_delta","thinking_delta","tool_use_start","tool_use_args_delta","tool_result","room_tool_result","tool_summary","tombstone","assistant_message","turn_complete","goal_set","goal_updated","goal_cleared","goal_progress","task_update","agent_start","agent_end","background_agent_completed","context_compact","error","session_user_message","steer_injected","user_message","assistant_text"]);function lS(t){if(typeof t!="string"||t.length>2048||!/^[A-Za-z0-9_-]+$/.test(t))return!1;try{const i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));return typeof i.identity=="string"&&typeof i.hash=="string"&&/^[a-f0-9]{64}$/.test(i.identity)&&/^[a-f0-9]{64}$/.test(i.hash)&&Number.isSafeInteger(i.sequence)&&i.sequence>0&&Number.isSafeInteger(i.offset)&&i.offset>0}catch{return!1}}class Sf{lastCursor;blocked=!1;overflowed=!1;inputs=new Set;copy(){const i=new Sf;i.lastCursor=this.lastCursor,i.blocked=this.blocked,i.overflowed=this.overflowed;for(const r of this.inputs)i.inputs.add(r);return i}observe(i){if(this.overflowed)return;const r=i;if(r){if(r.outputCursor!==void 0){const a=lS(r.outputCursor)?this.lastCursor?ja(r.outputCursor,this.lastCursor):1:void 0;if(a===void 0||a<=0){this.discardProof();return}this.lastCursor=r.outputCursor;return}if(!(!r.type||!rS.has(r.type))&&!(["session_user_message","steer_injected","user_message"].includes(r.type)&&(r.agentId||r.injected===!0||["agent","system","policy"].includes(String(r.authority)))))if(r.type==="session_user_message"){const a=r.clientMessageId;typeof a!="string"||!a.trim()||a.length>512?this.blocked=!0:this.inputs.add(a),(this.inputIds.length>128||this.memoryBytes>32*1024)&&this.discardProof()}else this.blocked=!0}}acknowledgeInputs(i){for(const r of i)this.inputs.delete(r)}get inputIds(){return[...this.inputs]}get incomplete(){return this.blocked||this.overflowed}get memoryBytes(){return this.inputIds.reduce((i,r)=>i+new TextEncoder().encode(r).length,0)}discardProof(){this.overflowed=!0,this.inputs.clear()}}function ya(t,i,r,a={}){if(t.unpaired)throw new Error("Output recovery contains unpaired visible output");if(i.coverageIdentity!==void 0&&a.requireIdentity!==!1&&(t.incarnation===void 0||t.journalIdentity===void 0))throw new Error("Output recovery Session incarnation proof is unavailable");if(t.incarnation!==void 0&&t.incarnation!==i.coverageIdentity)throw new Error("Output recovery Session incarnation changed");if(t.journalIdentity!==void 0){let d;try{d=JSON.parse(atob((i.coverageStart??"").replace(/-/g,"+").replace(/_/g,"/"))).hash}catch{throw new Error("Output recovery journal pin is unpaired")}if(d!==t.journalIdentity)throw new Error("Output recovery journal pin changed")}const u=t.inputIds??[];if(!Array.isArray(u)||u.length>128||new Set(u).size!==u.length||u.some(d=>typeof d!="string"||!d.trim()||d.length>512)||u.reduce((d,c)=>d+new TextEncoder().encode(c).length,0)>32*1024)throw new Error("Output recovery input identities are unpaired");if(u.some(d=>!r(d)))throw new Error("Output recovery input has no recorded anchor")}function wi(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ot(t){return typeof t=="string"?t:""}function Qd(t){return Array.isArray(t)?t.map(wi).filter(i=>i!==void 0):[]}function iy(t){return typeof t=="string"?t:Qd(t).filter(i=>i.type==="text").map(i=>Ot(i.text)).join("")}function ry(t){return wi(t.data)??wi(t.message)??t}function aS(t){const i=[],r=new Set,a=new Set,u=new Map;for(const h of t){const p=wi(h);if(!p)continue;const m=ry(p);p.type==="tool_use"&&Ot(m.toolCallId)&&u.set(Ot(m.toolCallId),{name:Ot(m.toolName)||"工具",args:wi(m.args)??{}});for(const y of Qd(m.content))y.type==="tool_use"&&Ot(y.id)&&u.set(Ot(y.id),{name:Ot(y.name)||"工具",args:wi(y.input)??{}})}const d=(h,p,m,y)=>{h&&(a.has(h)?i.push({type:"tool_use_args_delta",toolCallId:h,args:m,...y?{agentId:y}:{}}):(a.add(h),i.push({type:"tool_use_start",toolCall:{id:h,toolName:p||"工具",args:m},...y?{agentId:y}:{}})))},c=(h,p,m)=>{if(!h)return;const y=u.get(h);a.has(h)||d(h,y?.name||Ot(p.toolName)||"工具",y?.args??{},m);const b=typeof p.result=="string"?p.result:iy(p.content??p.contentBlocks),v=Ot(p.error);i.push({type:"tool_result",result:{id:h,result:b||v,...v?{error:v}:{},isError:p.isError===!0||p.is_error===!0||!!v},...m?{agentId:m}:{}})};for(const h of t){const p=wi(h);if(!p)continue;const m=Ot(p.id);if(m&&r.has(m))continue;m&&r.add(m);const y=ry(p),b=Ot(y.agentId)||void 0;switch(typeof p.type=="string"?p.type:typeof y.role=="string"?"message":""){case"message":{const x=Qd(y.content);if(y.role==="user"){if(y.injected===!0||y.authority==="agent"||y.authority==="system"||y.authority==="policy")break;const j=Pb(y);if(j.text.startsWith("<system-reminder>"))break;(j.text||j.attachments.length)&&i.push({type:"user_message",...j,...typeof y.clientMessageId=="string"?{clientMessageId:y.clientMessageId}:{}});for(const R of x)R.type==="tool_result"&&c(Ot(R.tool_use_id),R,b)}else if(y.role==="assistant"){const j=iy(y.content),R=x.filter(C=>C.type==="reasoning").map(C=>Ot(C.reasoningContent)||Ot(C.text)).join("");if(j||R){const C=b?{agentId:b}:{};i.push({type:"stream_request_start",...C}),R&&i.push({type:"thinking_delta",text:R,...C}),j&&i.push({type:"text_delta",text:j,...C}),i.push({type:"assistant_message",...C})}for(const C of x)C.type==="tool_use"&&d(Ot(C.id),Ot(C.name),wi(C.input)??{},b)}else y.role==="tool"&&c(Ot(y.tool_call_id),y,b);break}case"tool_use":d(Ot(y.toolCallId),Ot(y.toolName),wi(y.args)??{},b);break;case"tool_result":c(Ot(y.toolCallId),y,b);break;case"subagent":b&&i.push({type:"agent_start",agentId:b,name:Ot(y.name),description:Ot(y.description),status:"recorded"});break;case"error":Ot(y.error)&&i.push({type:"error",error:y.error});break;case"turn_stopped":i.push({type:"turn_complete",reason:"aborted_tools"});break;case"session_meta":Ot(y.sessionId)&&i.push({type:"session_started",sessionId:y.sessionId});break}}return i}function Xb(t){let i=uo();for(const r of aS(t))i=vr(i,r);return{...i,run:i.run==="error"?"error":"idle",liveByAgent:{}}}var dl={},ed,ly;function sS(){return ly||(ly=1,ed=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ed}var td={},Xi={},ay;function kr(){if(ay)return Xi;ay=1;let t;const i=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Xi.getSymbolSize=function(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},Xi.getSymbolTotalCodewords=function(a){return i[a]},Xi.getBCHDigit=function(r){let a=0;for(;r!==0;)a++,r>>>=1;return a},Xi.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');t=a},Xi.isKanjiModeEnabled=function(){return typeof t<"u"},Xi.toSJIS=function(a){return t(a)},Xi}var nd={},sy;function jf(){return sy||(sy=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function i(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+r)}}t.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},t.from=function(a,u){if(t.isValid(a))return a;try{return i(a)}catch{return u}}})(nd)),nd}var id,oy;function oS(){if(oy)return id;oy=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(i){const r=Math.floor(i/8);return(this.buffer[r]>>>7-i%8&1)===1},put:function(i,r){for(let a=0;a<r;a++)this.putBit((i>>>r-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(i){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),i&&(this.buffer[r]|=128>>>this.length%8),this.length++}},id=t,id}var rd,uy;function uS(){if(uy)return rd;uy=1;function t(i){if(!i||i<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=i,this.data=new Uint8Array(i*i),this.reservedBit=new Uint8Array(i*i)}return t.prototype.set=function(i,r,a,u){const d=i*this.size+r;this.data[d]=a,u&&(this.reservedBit[d]=!0)},t.prototype.get=function(i,r){return this.data[i*this.size+r]},t.prototype.xor=function(i,r,a){this.data[i*this.size+r]^=a},t.prototype.isReserved=function(i,r){return this.reservedBit[i*this.size+r]},rd=t,rd}var ld={},cy;function cS(){return cy||(cy=1,(function(t){const i=kr().getSymbolSize;t.getRowColCoords=function(a){if(a===1)return[];const u=Math.floor(a/7)+2,d=i(a),c=d===145?26:Math.ceil((d-13)/(2*u-2))*2,h=[d-7];for(let p=1;p<u-1;p++)h[p]=h[p-1]-c;return h.push(6),h.reverse()},t.getPositions=function(a){const u=[],d=t.getRowColCoords(a),c=d.length;for(let h=0;h<c;h++)for(let p=0;p<c;p++)h===0&&p===0||h===0&&p===c-1||h===c-1&&p===0||u.push([d[h],d[p]]);return u}})(ld)),ld}var ad={},dy;function dS(){if(dy)return ad;dy=1;const t=kr().getSymbolSize,i=7;return ad.getPositions=function(a){const u=t(a);return[[0,0],[u-i,0],[0,u-i]]},ad}var sd={},fy;function fS(){return fy||(fy=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const i={N1:3,N2:3,N3:40,N4:10};t.isValid=function(u){return u!=null&&u!==""&&!isNaN(u)&&u>=0&&u<=7},t.from=function(u){return t.isValid(u)?parseInt(u,10):void 0},t.getPenaltyN1=function(u){const d=u.size;let c=0,h=0,p=0,m=null,y=null;for(let b=0;b<d;b++){h=p=0,m=y=null;for(let v=0;v<d;v++){let x=u.get(b,v);x===m?h++:(h>=5&&(c+=i.N1+(h-5)),m=x,h=1),x=u.get(v,b),x===y?p++:(p>=5&&(c+=i.N1+(p-5)),y=x,p=1)}h>=5&&(c+=i.N1+(h-5)),p>=5&&(c+=i.N1+(p-5))}return c},t.getPenaltyN2=function(u){const d=u.size;let c=0;for(let h=0;h<d-1;h++)for(let p=0;p<d-1;p++){const m=u.get(h,p)+u.get(h,p+1)+u.get(h+1,p)+u.get(h+1,p+1);(m===4||m===0)&&c++}return c*i.N2},t.getPenaltyN3=function(u){const d=u.size;let c=0,h=0,p=0;for(let m=0;m<d;m++){h=p=0;for(let y=0;y<d;y++)h=h<<1&2047|u.get(m,y),y>=10&&(h===1488||h===93)&&c++,p=p<<1&2047|u.get(y,m),y>=10&&(p===1488||p===93)&&c++}return c*i.N3},t.getPenaltyN4=function(u){let d=0;const c=u.data.length;for(let p=0;p<c;p++)d+=u.data[p];return Math.abs(Math.ceil(d*100/c/5)-10)*i.N4};function r(a,u,d){switch(a){case t.Patterns.PATTERN000:return(u+d)%2===0;case t.Patterns.PATTERN001:return u%2===0;case t.Patterns.PATTERN010:return d%3===0;case t.Patterns.PATTERN011:return(u+d)%3===0;case t.Patterns.PATTERN100:return(Math.floor(u/2)+Math.floor(d/3))%2===0;case t.Patterns.PATTERN101:return u*d%2+u*d%3===0;case t.Patterns.PATTERN110:return(u*d%2+u*d%3)%2===0;case t.Patterns.PATTERN111:return(u*d%3+(u+d)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}t.applyMask=function(u,d){const c=d.size;for(let h=0;h<c;h++)for(let p=0;p<c;p++)d.isReserved(p,h)||d.xor(p,h,r(u,p,h))},t.getBestMask=function(u,d){const c=Object.keys(t.Patterns).length;let h=0,p=1/0;for(let m=0;m<c;m++){d(m),t.applyMask(m,u);const y=t.getPenaltyN1(u)+t.getPenaltyN2(u)+t.getPenaltyN3(u)+t.getPenaltyN4(u);t.applyMask(m,u),y<p&&(p=y,h=m)}return h}})(sd)),sd}var to={},hy;function Kb(){if(hy)return to;hy=1;const t=jf(),i=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return to.getBlocksCount=function(u,d){switch(d){case t.L:return i[(u-1)*4+0];case t.M:return i[(u-1)*4+1];case t.Q:return i[(u-1)*4+2];case t.H:return i[(u-1)*4+3];default:return}},to.getTotalCodewordsCount=function(u,d){switch(d){case t.L:return r[(u-1)*4+0];case t.M:return r[(u-1)*4+1];case t.Q:return r[(u-1)*4+2];case t.H:return r[(u-1)*4+3];default:return}},to}var od={},ba={},py;function hS(){if(py)return ba;py=1;const t=new Uint8Array(512),i=new Uint8Array(256);return(function(){let a=1;for(let u=0;u<255;u++)t[u]=a,i[a]=u,a<<=1,a&256&&(a^=285);for(let u=255;u<512;u++)t[u]=t[u-255]})(),ba.log=function(a){if(a<1)throw new Error("log("+a+")");return i[a]},ba.exp=function(a){return t[a]},ba.mul=function(a,u){return a===0||u===0?0:t[i[a]+i[u]]},ba}var my;function pS(){return my||(my=1,(function(t){const i=hS();t.mul=function(a,u){const d=new Uint8Array(a.length+u.length-1);for(let c=0;c<a.length;c++)for(let h=0;h<u.length;h++)d[c+h]^=i.mul(a[c],u[h]);return d},t.mod=function(a,u){let d=new Uint8Array(a);for(;d.length-u.length>=0;){const c=d[0];for(let p=0;p<u.length;p++)d[p]^=i.mul(u[p],c);let h=0;for(;h<d.length&&d[h]===0;)h++;d=d.slice(h)}return d},t.generateECPolynomial=function(a){let u=new Uint8Array([1]);for(let d=0;d<a;d++)u=t.mul(u,new Uint8Array([1,i.exp(d)]));return u}})(od)),od}var ud,gy;function mS(){if(gy)return ud;gy=1;const t=pS();function i(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return i.prototype.initialize=function(a){this.degree=a,this.genPoly=t.generateECPolynomial(this.degree)},i.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const u=new Uint8Array(a.length+this.degree);u.set(a);const d=t.mod(u,this.genPoly),c=this.degree-d.length;if(c>0){const h=new Uint8Array(this.degree);return h.set(d,c),h}return d},ud=i,ud}var cd={},dd={},fd={},yy;function Zb(){return yy||(yy=1,fd.isValid=function(i){return!isNaN(i)&&i>=1&&i<=40}),fd}var Zn={},by;function Jb(){if(by)return Zn;by=1;const t="[0-9]+",i="[A-Z $%*+\\-./:]+";let r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";r=r.replace(/u/g,"\\u");const a="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
|
|
22
|
+
]))+`;Zn.KANJI=new RegExp(r,"g"),Zn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Zn.BYTE=new RegExp(a,"g"),Zn.NUMERIC=new RegExp(t,"g"),Zn.ALPHANUMERIC=new RegExp(i,"g");const u=new RegExp("^"+r+"$"),d=new RegExp("^"+t+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Zn.testKanji=function(p){return u.test(p)},Zn.testNumeric=function(p){return d.test(p)},Zn.testAlphanumeric=function(p){return c.test(p)},Zn}var vy;function Cr(){return vy||(vy=1,(function(t){const i=Zb(),r=Jb();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(d,c){if(!d.ccBits)throw new Error("Invalid mode: "+d);if(!i.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?d.ccBits[0]:c<27?d.ccBits[1]:d.ccBits[2]},t.getBestModeForData=function(d){return r.testNumeric(d)?t.NUMERIC:r.testAlphanumeric(d)?t.ALPHANUMERIC:r.testKanji(d)?t.KANJI:t.BYTE},t.toString=function(d){if(d&&d.id)return d.id;throw new Error("Invalid mode")},t.isValid=function(d){return d&&d.bit&&d.ccBits};function a(u){if(typeof u!="string")throw new Error("Param is not a string");switch(u.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+u)}}t.from=function(d,c){if(t.isValid(d))return d;try{return a(d)}catch{return c}}})(dd)),dd}var xy;function gS(){return xy||(xy=1,(function(t){const i=kr(),r=Kb(),a=jf(),u=Cr(),d=Zb(),c=7973,h=i.getBCHDigit(c);function p(v,x,j){for(let R=1;R<=40;R++)if(x<=t.getCapacity(R,j,v))return R}function m(v,x){return u.getCharCountIndicator(v,x)+4}function y(v,x){let j=0;return v.forEach(function(R){const C=m(R.mode,x);j+=C+R.getBitsLength()}),j}function b(v,x){for(let j=1;j<=40;j++)if(y(v,j)<=t.getCapacity(j,x,u.MIXED))return j}t.from=function(x,j){return d.isValid(x)?parseInt(x,10):j},t.getCapacity=function(x,j,R){if(!d.isValid(x))throw new Error("Invalid QR Code version");typeof R>"u"&&(R=u.BYTE);const C=i.getSymbolTotalCodewords(x),T=r.getTotalCodewordsCount(x,j),_=(C-T)*8;if(R===u.MIXED)return _;const D=_-m(R,x);switch(R){case u.NUMERIC:return Math.floor(D/10*3);case u.ALPHANUMERIC:return Math.floor(D/11*2);case u.KANJI:return Math.floor(D/13);case u.BYTE:default:return Math.floor(D/8)}},t.getBestVersionForData=function(x,j){let R;const C=a.from(j,a.M);if(Array.isArray(x)){if(x.length>1)return b(x,C);if(x.length===0)return 1;R=x[0]}else R=x;return p(R.mode,R.getLength(),C)},t.getEncodedBits=function(x){if(!d.isValid(x)||x<7)throw new Error("Invalid QR Code version");let j=x<<12;for(;i.getBCHDigit(j)-h>=0;)j^=c<<i.getBCHDigit(j)-h;return x<<12|j}})(cd)),cd}var hd={},wy;function yS(){if(wy)return hd;wy=1;const t=kr(),i=1335,r=21522,a=t.getBCHDigit(i);return hd.getEncodedBits=function(d,c){const h=d.bit<<3|c;let p=h<<10;for(;t.getBCHDigit(p)-a>=0;)p^=i<<t.getBCHDigit(p)-a;return(h<<10|p)^r},hd}var pd={},md,Sy;function bS(){if(Sy)return md;Sy=1;const t=Cr();function i(r){this.mode=t.NUMERIC,this.data=r.toString()}return i.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(a){let u,d,c;for(u=0;u+3<=this.data.length;u+=3)d=this.data.substr(u,3),c=parseInt(d,10),a.put(c,10);const h=this.data.length-u;h>0&&(d=this.data.substr(u),c=parseInt(d,10),a.put(c,h*3+1))},md=i,md}var gd,jy;function vS(){if(jy)return gd;jy=1;const t=Cr(),i=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function r(a){this.mode=t.ALPHANUMERIC,this.data=a}return r.getBitsLength=function(u){return 11*Math.floor(u/2)+6*(u%2)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(u){let d;for(d=0;d+2<=this.data.length;d+=2){let c=i.indexOf(this.data[d])*45;c+=i.indexOf(this.data[d+1]),u.put(c,11)}this.data.length%2&&u.put(i.indexOf(this.data[d]),6)},gd=r,gd}var yd,ky;function xS(){if(ky)return yd;ky=1;const t=Cr();function i(r){this.mode=t.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}return i.getBitsLength=function(a){return a*8},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(r){for(let a=0,u=this.data.length;a<u;a++)r.put(this.data[a],8)},yd=i,yd}var bd,Cy;function wS(){if(Cy)return bd;Cy=1;const t=Cr(),i=kr();function r(a){this.mode=t.KANJI,this.data=a}return r.getBitsLength=function(u){return u*13},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(a){let u;for(u=0;u<this.data.length;u++){let d=i.toSJIS(this.data[u]);if(d>=33088&&d<=40956)d-=33088;else if(d>=57408&&d<=60351)d-=49472;else throw new Error("Invalid SJIS character: "+this.data[u]+`
|
|
23
|
+
Make sure your charset is UTF-8`);d=(d>>>8&255)*192+(d&255),a.put(d,13)}},bd=r,bd}var vd={exports:{}},Ey;function SS(){return Ey||(Ey=1,(function(t){var i={single_source_shortest_paths:function(r,a,u){var d={},c={};c[a]=0;var h=i.PriorityQueue.make();h.push(a,0);for(var p,m,y,b,v,x,j,R,C;!h.empty();){p=h.pop(),m=p.value,b=p.cost,v=r[m]||{};for(y in v)v.hasOwnProperty(y)&&(x=v[y],j=b+x,R=c[y],C=typeof c[y]>"u",(C||R>j)&&(c[y]=j,h.push(y,j),d[y]=m))}if(typeof u<"u"&&typeof c[u]>"u"){var T=["Could not find a path from ",a," to ",u,"."].join("");throw new Error(T)}return d},extract_shortest_path_from_predecessor_list:function(r,a){for(var u=[],d=a;d;)u.push(d),r[d],d=r[d];return u.reverse(),u},find_path:function(r,a,u){var d=i.single_source_shortest_paths(r,a,u);return i.extract_shortest_path_from_predecessor_list(d,u)},PriorityQueue:{make:function(r){var a=i.PriorityQueue,u={},d;r=r||{};for(d in a)a.hasOwnProperty(d)&&(u[d]=a[d]);return u.queue=[],u.sorter=r.sorter||a.default_sorter,u},default_sorter:function(r,a){return r.cost-a.cost},push:function(r,a){var u={value:r,cost:a};this.queue.push(u),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=i})(vd)),vd.exports}var Ny;function jS(){return Ny||(Ny=1,(function(t){const i=Cr(),r=bS(),a=vS(),u=xS(),d=wS(),c=Jb(),h=kr(),p=SS();function m(T){return unescape(encodeURIComponent(T)).length}function y(T,_,D){const q=[];let se;for(;(se=T.exec(D))!==null;)q.push({data:se[0],index:se.index,mode:_,length:se[0].length});return q}function b(T){const _=y(c.NUMERIC,i.NUMERIC,T),D=y(c.ALPHANUMERIC,i.ALPHANUMERIC,T);let q,se;return h.isKanjiModeEnabled()?(q=y(c.BYTE,i.BYTE,T),se=y(c.KANJI,i.KANJI,T)):(q=y(c.BYTE_KANJI,i.BYTE,T),se=[]),_.concat(D,q,se).sort(function(U,X){return U.index-X.index}).map(function(U){return{data:U.data,mode:U.mode,length:U.length}})}function v(T,_){switch(_){case i.NUMERIC:return r.getBitsLength(T);case i.ALPHANUMERIC:return a.getBitsLength(T);case i.KANJI:return d.getBitsLength(T);case i.BYTE:return u.getBitsLength(T)}}function x(T){return T.reduce(function(_,D){const q=_.length-1>=0?_[_.length-1]:null;return q&&q.mode===D.mode?(_[_.length-1].data+=D.data,_):(_.push(D),_)},[])}function j(T){const _=[];for(let D=0;D<T.length;D++){const q=T[D];switch(q.mode){case i.NUMERIC:_.push([q,{data:q.data,mode:i.ALPHANUMERIC,length:q.length},{data:q.data,mode:i.BYTE,length:q.length}]);break;case i.ALPHANUMERIC:_.push([q,{data:q.data,mode:i.BYTE,length:q.length}]);break;case i.KANJI:_.push([q,{data:q.data,mode:i.BYTE,length:m(q.data)}]);break;case i.BYTE:_.push([{data:q.data,mode:i.BYTE,length:m(q.data)}])}}return _}function R(T,_){const D={},q={start:{}};let se=["start"];for(let N=0;N<T.length;N++){const U=T[N],X=[];for(let H=0;H<U.length;H++){const A=U[H],I=""+N+H;X.push(I),D[I]={node:A,lastCount:0},q[I]={};for(let L=0;L<se.length;L++){const P=se[L];D[P]&&D[P].node.mode===A.mode?(q[P][I]=v(D[P].lastCount+A.length,A.mode)-v(D[P].lastCount,A.mode),D[P].lastCount+=A.length):(D[P]&&(D[P].lastCount=A.length),q[P][I]=v(A.length,A.mode)+4+i.getCharCountIndicator(A.mode,_))}}se=X}for(let N=0;N<se.length;N++)q[se[N]].end=0;return{map:q,table:D}}function C(T,_){let D;const q=i.getBestModeForData(T);if(D=i.from(_,q),D!==i.BYTE&&D.bit<q.bit)throw new Error('"'+T+'" cannot be encoded with mode '+i.toString(D)+`.
|
|
24
|
+
Suggested mode is: `+i.toString(q));switch(D===i.KANJI&&!h.isKanjiModeEnabled()&&(D=i.BYTE),D){case i.NUMERIC:return new r(T);case i.ALPHANUMERIC:return new a(T);case i.KANJI:return new d(T);case i.BYTE:return new u(T)}}t.fromArray=function(_){return _.reduce(function(D,q){return typeof q=="string"?D.push(C(q,null)):q.data&&D.push(C(q.data,q.mode)),D},[])},t.fromString=function(_,D){const q=b(_,h.isKanjiModeEnabled()),se=j(q),N=R(se,D),U=p.find_path(N.map,"start","end"),X=[];for(let H=1;H<U.length-1;H++)X.push(N.table[U[H]].node);return t.fromArray(x(X))},t.rawSplit=function(_){return t.fromArray(b(_,h.isKanjiModeEnabled()))}})(pd)),pd}var Ay;function kS(){if(Ay)return td;Ay=1;const t=kr(),i=jf(),r=oS(),a=uS(),u=cS(),d=dS(),c=fS(),h=Kb(),p=mS(),m=gS(),y=yS(),b=Cr(),v=jS();function x(N,U){const X=N.size,H=d.getPositions(U);for(let A=0;A<H.length;A++){const I=H[A][0],L=H[A][1];for(let P=-1;P<=7;P++)if(!(I+P<=-1||X<=I+P))for(let W=-1;W<=7;W++)L+W<=-1||X<=L+W||(P>=0&&P<=6&&(W===0||W===6)||W>=0&&W<=6&&(P===0||P===6)||P>=2&&P<=4&&W>=2&&W<=4?N.set(I+P,L+W,!0,!0):N.set(I+P,L+W,!1,!0))}}function j(N){const U=N.size;for(let X=8;X<U-8;X++){const H=X%2===0;N.set(X,6,H,!0),N.set(6,X,H,!0)}}function R(N,U){const X=u.getPositions(U);for(let H=0;H<X.length;H++){const A=X[H][0],I=X[H][1];for(let L=-2;L<=2;L++)for(let P=-2;P<=2;P++)L===-2||L===2||P===-2||P===2||L===0&&P===0?N.set(A+L,I+P,!0,!0):N.set(A+L,I+P,!1,!0)}}function C(N,U){const X=N.size,H=m.getEncodedBits(U);let A,I,L;for(let P=0;P<18;P++)A=Math.floor(P/3),I=P%3+X-8-3,L=(H>>P&1)===1,N.set(A,I,L,!0),N.set(I,A,L,!0)}function T(N,U,X){const H=N.size,A=y.getEncodedBits(U,X);let I,L;for(I=0;I<15;I++)L=(A>>I&1)===1,I<6?N.set(I,8,L,!0):I<8?N.set(I+1,8,L,!0):N.set(H-15+I,8,L,!0),I<8?N.set(8,H-I-1,L,!0):I<9?N.set(8,15-I-1+1,L,!0):N.set(8,15-I-1,L,!0);N.set(H-8,8,1,!0)}function _(N,U){const X=N.size;let H=-1,A=X-1,I=7,L=0;for(let P=X-1;P>0;P-=2)for(P===6&&P--;;){for(let W=0;W<2;W++)if(!N.isReserved(A,P-W)){let ee=!1;L<U.length&&(ee=(U[L]>>>I&1)===1),N.set(A,P-W,ee),I--,I===-1&&(L++,I=7)}if(A+=H,A<0||X<=A){A-=H,H=-H;break}}}function D(N,U,X){const H=new r;X.forEach(function(W){H.put(W.mode.bit,4),H.put(W.getLength(),b.getCharCountIndicator(W.mode,N)),W.write(H)});const A=t.getSymbolTotalCodewords(N),I=h.getTotalCodewordsCount(N,U),L=(A-I)*8;for(H.getLengthInBits()+4<=L&&H.put(0,4);H.getLengthInBits()%8!==0;)H.putBit(0);const P=(L-H.getLengthInBits())/8;for(let W=0;W<P;W++)H.put(W%2?17:236,8);return q(H,N,U)}function q(N,U,X){const H=t.getSymbolTotalCodewords(U),A=h.getTotalCodewordsCount(U,X),I=H-A,L=h.getBlocksCount(U,X),P=H%L,W=L-P,ee=Math.floor(H/L),G=Math.floor(I/L),B=G+1,Q=ee-G,fe=new p(Q);let k=0;const O=new Array(L),le=new Array(L);let E=0;const J=new Uint8Array(N.buffer);for(let Y=0;Y<L;Y++){const ve=Y<W?G:B;O[Y]=J.slice(k,k+ve),le[Y]=fe.encode(O[Y]),k+=ve,E=Math.max(E,ve)}const be=new Uint8Array(H);let Z=0,ne,ge;for(ne=0;ne<E;ne++)for(ge=0;ge<L;ge++)ne<O[ge].length&&(be[Z++]=O[ge][ne]);for(ne=0;ne<Q;ne++)for(ge=0;ge<L;ge++)be[Z++]=le[ge][ne];return be}function se(N,U,X,H){let A;if(Array.isArray(N))A=v.fromArray(N);else if(typeof N=="string"){let ee=U;if(!ee){const G=v.rawSplit(N);ee=m.getBestVersionForData(G,X)}A=v.fromString(N,ee||40)}else throw new Error("Invalid data");const I=m.getBestVersionForData(A,X);if(!I)throw new Error("The amount of data is too big to be stored in a QR Code");if(!U)U=I;else if(U<I)throw new Error(`
|
|
25
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
26
|
+
Minimum version required to store current data is: `+I+`.
|
|
27
|
+
`);const L=D(U,X,A),P=t.getSymbolSize(U),W=new a(P);return x(W,U),j(W),R(W,U),T(W,X,0),U>=7&&C(W,U),_(W,L),isNaN(H)&&(H=c.getBestMask(W,T.bind(null,W,X))),c.applyMask(H,W),T(W,X,H),{modules:W,version:U,errorCorrectionLevel:X,maskPattern:H,segments:A}}return td.create=function(U,X){if(typeof U>"u"||U==="")throw new Error("No input text");let H=i.M,A,I;return typeof X<"u"&&(H=i.from(X.errorCorrectionLevel,i.M),A=m.from(X.version),I=c.from(X.maskPattern),X.toSJISFunc&&t.setToSJISFunction(X.toSJISFunc)),se(U,A,H,I)},td}var xd={},wd={},Ty;function Wb(){return Ty||(Ty=1,(function(t){function i(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let a=r.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+r);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(d){return[d,d]}))),a.length===6&&a.push("F","F");const u=parseInt(a.join(""),16);return{r:u>>24&255,g:u>>16&255,b:u>>8&255,a:u&255,hex:"#"+a.slice(0,6).join("")}}t.getOptions=function(a){a||(a={}),a.color||(a.color={});const u=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,d=a.width&&a.width>=21?a.width:void 0,c=a.scale||4;return{width:d,scale:d?4:c,margin:u,color:{dark:i(a.color.dark||"#000000ff"),light:i(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},t.getScale=function(a,u){return u.width&&u.width>=a+u.margin*2?u.width/(a+u.margin*2):u.scale},t.getImageWidth=function(a,u){const d=t.getScale(a,u);return Math.floor((a+u.margin*2)*d)},t.qrToImageData=function(a,u,d){const c=u.modules.size,h=u.modules.data,p=t.getScale(c,d),m=Math.floor((c+d.margin*2)*p),y=d.margin*p,b=[d.color.light,d.color.dark];for(let v=0;v<m;v++)for(let x=0;x<m;x++){let j=(v*m+x)*4,R=d.color.light;if(v>=y&&x>=y&&v<m-y&&x<m-y){const C=Math.floor((v-y)/p),T=Math.floor((x-y)/p);R=b[h[C*c+T]?1:0]}a[j++]=R.r,a[j++]=R.g,a[j++]=R.b,a[j]=R.a}}})(wd)),wd}var Ry;function CS(){return Ry||(Ry=1,(function(t){const i=Wb();function r(u,d,c){u.clearRect(0,0,d.width,d.height),d.style||(d.style={}),d.height=c,d.width=c,d.style.height=c+"px",d.style.width=c+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(d,c,h){let p=h,m=c;typeof p>"u"&&(!c||!c.getContext)&&(p=c,c=void 0),c||(m=a()),p=i.getOptions(p);const y=i.getImageWidth(d.modules.size,p),b=m.getContext("2d"),v=b.createImageData(y,y);return i.qrToImageData(v.data,d,p),r(b,m,y),b.putImageData(v,0,0),m},t.renderToDataURL=function(d,c,h){let p=h;typeof p>"u"&&(!c||!c.getContext)&&(p=c,c=void 0),p||(p={});const m=t.render(d,c,p),y=p.type||"image/png",b=p.rendererOpts||{};return m.toDataURL(y,b.quality)}})(xd)),xd}var Sd={},zy;function ES(){if(zy)return Sd;zy=1;const t=Wb();function i(u,d){const c=u.a/255,h=d+'="'+u.hex+'"';return c<1?h+" "+d+'-opacity="'+c.toFixed(2).slice(1)+'"':h}function r(u,d,c){let h=u+d;return typeof c<"u"&&(h+=" "+c),h}function a(u,d,c){let h="",p=0,m=!1,y=0;for(let b=0;b<u.length;b++){const v=Math.floor(b%d),x=Math.floor(b/d);!v&&!m&&(m=!0),u[b]?(y++,b>0&&v>0&&u[b-1]||(h+=m?r("M",v+c,.5+x+c):r("m",p,0),p=0,m=!1),v+1<d&&u[b+1]||(h+=r("h",y),y=0)):p++}return h}return Sd.render=function(d,c,h){const p=t.getOptions(c),m=d.modules.size,y=d.modules.data,b=m+p.margin*2,v=p.color.light.a?"<path "+i(p.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",x="<path "+i(p.color.dark,"stroke")+' d="'+a(y,m,p.margin)+'"/>',j='viewBox="0 0 '+b+" "+b+'"',C='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+j+' shape-rendering="crispEdges">'+v+x+`</svg>
|
|
28
|
+
`;return typeof h=="function"&&h(null,C),C},Sd}var _y;function NS(){if(_y)return dl;_y=1;const t=sS(),i=kS(),r=CS(),a=ES();function u(d,c,h,p,m){const y=[].slice.call(arguments,1),b=y.length,v=typeof y[b-1]=="function";if(!v&&!t())throw new Error("Callback required as last argument");if(v){if(b<2)throw new Error("Too few arguments provided");b===2?(m=h,h=c,c=p=void 0):b===3&&(c.getContext&&typeof m>"u"?(m=p,p=void 0):(m=p,p=h,h=c,c=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(h=c,c=p=void 0):b===2&&!c.getContext&&(p=h,h=c,c=void 0),new Promise(function(x,j){try{const R=i.create(h,p);x(d(R,c,p))}catch(R){j(R)}})}try{const x=i.create(h,p);m(null,d(x,c,p))}catch(x){m(x)}}return dl.create=i.create,dl.toCanvas=u.bind(null,r.render),dl.toDataURL=u.bind(null,r.renderToDataURL),dl.toString=u.bind(null,function(d,c,h){return a.render(d,h)}),dl}var AS=NS();const TS=jo(AS),RS={openPage:"打开授权页面",waitingBrowser:"在服务商页面完成授权,返回后会自动确认连接。",deviceInstruction:"在授权页面输入此验证码:",copy:"复制验证码",submit:"验证并保存",verifyCode:"输入服务商提供的验证码",secondFactor:"完成服务商要求的追加验证",detectSession:"检查登录状态",bindSession:"使用这个账号",loginSession:"登录账号",notInstalled:"此环境尚未安装对应 CLI。",notAuthenticated:"请先在当前环境登录对应 CLI,再检查状态。",authenticated:"已登录",processing:"正在确认并保存连接…",connected:"连接已保存。",cancelled:"授权已取消。",failed:"授权未完成,请重新连接。",expired:"授权已过期,请重新连接。",unsupported:"当前客户端不支持这个授权步骤,请更新客户端。",invalidUrl:"授权地址无效,请检查服务配置。",scan:"使用服务商的手机应用扫描二维码。",confirmOnPhone:"已扫码,请在手机上确认。",qrExpired:"二维码已过期。",refreshQr:"刷新二维码",qrError:"无法显示二维码,请重试。",qrAlt:"服务商授权二维码",confirm:"确认授权",resourcesTruncated:"此列表仅显示部分资源,请缩小选择范围后继续。",expiresAt:"有效期至",rejected:"服务商未接受此凭据,请检查后重试。",cliUnavailable:"此环境没有可用的 CLI 登录,请检查登录状态或选择其他方式。"};function zS(t){const i={...RS,...t.labels},r=ki(t.authorization),[a,u]=S.useState({}),[d,c]=S.useState({}),[h,p]=S.useState(),[m,y]=S.useState(!1),[b,v]=S.useState(Date.now()),x=Math.min(t.authorization.expiresAt?Date.parse(t.authorization.expiresAt):1/0,r?Date.parse(r.expiresAt):1/0),j=r?.kind==="qr-code"&&r.qr?Date.parse(r.qr.challengeExpiresAt):1/0,R=r?.kind==="qr-code"&&r.phase!=="expired"?r.qr?.payload:void 0;if(S.useEffect(()=>{u({}),c({})},[t.authorization.id,r?.id]),S.useEffect(()=>{v(Date.now());const N=[x,j].filter(U=>Number.isFinite(U)&&U>Date.now()).map(U=>setTimeout(()=>v(Date.now()),U-Date.now()+1));return()=>{for(const U of N)clearTimeout(U)}},[x,j]),S.useEffect(()=>{let N=!0;if(p(void 0),y(!1),!R||R.length>4096||j<=Date.now()){R&&R.length>4096&&y(!0);return}return TS.toDataURL(R,{width:220,margin:2,errorCorrectionLevel:"M"}).then(U=>{N&&p(U)}).catch(()=>{N&&y(!0)}),()=>{N=!1}},[R,j]),t.authorization.state!=="pending"){const N=t.authorization.state==="connected"?t.authorization.connection?i.connected:i.processing:t.authorization.state==="cancelled"?i.cancelled:t.authorization.errorCode==="authorization_expired"?i.expired:i.failed;return s.jsx("p",{className:"link-authorization-status",role:"status",children:N})}if(!r)return s.jsx("p",{role:"alert",children:i.unsupported});if(!Number.isFinite(x)||x<=b)return s.jsx("p",{className:"link-authorization-status",role:"status",children:i.expired});const C=!!t.busy,T=(N,U)=>t.onRespond({stepId:r.id,operation:N,...U?{input:U}:{}}),_=N=>{if(t.canOpenUrl===!1)return null;const U=_1(N);return U?s.jsxs("button",{type:"button",disabled:C,onClick:()=>t.onOpenUrl(U),children:[i.openPage," ↗"]}):s.jsx("p",{role:"alert",children:i.invalidUrl})},D=s.jsxs("p",{className:"link-authorization-expires",children:[i.expiresAt," ",new Date(x).toLocaleTimeString()]}),q=t.authorization.errorCode?s.jsx("p",{className:"link-authorization-error",role:"alert",children:t.authorization.errorCode==="provider_rejected"?i.rejected:t.authorization.errorCode==="cli_unavailable"?i.cliUnavailable:i.failed}):null,se=()=>{switch(r.kind){case"redirect":return s.jsxs("div",{className:"link-authorization-step",role:"status",children:[s.jsx("p",{children:i.waitingBrowser}),_(r.authorizationUrl),D]});case"device-code":return s.jsxs("div",{className:"link-authorization-step link-authorization-device",children:[s.jsx("p",{children:i.deviceInstruction}),s.jsx("strong",{className:"link-authorization-code",children:r.userCode}),s.jsxs("div",{className:"link-authorization-actions",children:[t.onCopy&&s.jsx("button",{type:"button",onClick:()=>t.onCopy?.(r.userCode),children:i.copy}),_(r.verificationUriComplete??r.verificationUri)]}),D]});case"qr-code":{const N=r.phase==="expired"||j<=b;return s.jsxs("div",{className:"link-authorization-step link-authorization-qr",children:[s.jsx("p",{role:"status",children:N?i.qrExpired:r.phase==="awaiting-confirmation"?i.confirmOnPhone:i.scan}),!N&&h&&s.jsx("img",{width:220,height:220,src:h,alt:i.qrAlt}),!N&&m&&s.jsx("p",{role:"alert",children:i.qrError}),!N&&r.qr?.instructions.map((U,X)=>s.jsx("p",{children:U},X)),r.canRefresh&&s.jsx("button",{type:"button",disabled:C,onClick:()=>T("refresh-qr"),children:i.refreshQr}),D]})}case"credential-input":return s.jsxs("form",{className:"link-authorization-step link-authorization-fields",onSubmit:N=>{if(N.preventDefault(),C)return;const U={};for(const X of r.fields)U[X.id]=a[X.id]??"";u({}),T("submit",U)},children:[r.purpose!=="credential"&&s.jsx("p",{children:r.purpose==="verification-code"?i.verifyCode:i.secondFactor}),r.fields.map(N=>s.jsxs("label",{children:[N.label,s.jsx("input",{name:N.id,type:N.secret?"password":"text",autoComplete:"off",spellCheck:!1,value:a[N.id]??"",placeholder:N.placeholder,maxLength:Math.min(N.maxLength??16384,16384),required:N.required,disabled:C,onChange:U=>u(X=>({...X,[N.id]:U.target.value}))})]},N.id)),s.jsx("button",{type:"submit",disabled:C||r.fields.some(N=>N.required&&!a[N.id]?.trim()),children:i.submit}),D]});case"local-session":return s.jsxs("div",{className:"link-authorization-step",children:[s.jsx("p",{role:"status",children:r.session.authenticated?`${i.authenticated}${r.session.account?`:${r.session.account}`:""}`:r.session.installed?i.notAuthenticated:i.notInstalled}),r.session.message&&s.jsx("p",{children:r.session.message}),s.jsxs("div",{className:"link-authorization-actions",children:[s.jsx("button",{type:"button",disabled:C,onClick:()=>T("detect-session"),children:i.detectSession}),!r.session.authenticated&&r.session.canLogin&&s.jsx("button",{type:"button",disabled:C,onClick:()=>T("login-session"),children:i.loginSession}),r.session.authenticated&&s.jsx("button",{type:"button",disabled:C,onClick:()=>T("bind-session"),children:i.bindSession})]}),D]});case"consent":{const N=d.permissions??r.permissions.filter(H=>H.required).map(H=>H.id),U=(H,A,I,L)=>c(P=>({...P,[H]:I?[...new Set([...L,A])]:L.filter(W=>W!==A)})),X=r.resourceGroups.some(H=>{const A=(d[H.id]??[]).length;return A<(H.minSelected??0)||A>(H.maxSelected??1/0)||H.truncated});return s.jsxs("form",{className:"link-authorization-step link-authorization-consent",onSubmit:H=>{H.preventDefault(),!C&&!X&&T("confirm",{...d,permissions:N})},children:[s.jsx("p",{children:s.jsx("strong",{children:r.account.label})}),s.jsx("div",{children:r.permissions.map(H=>s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:H.required||N.includes(H.id),disabled:C||H.required,onChange:A=>U("permissions",H.id,A.target.checked,N)}),H.label,H.description&&s.jsx("small",{children:H.description})]},H.id))}),r.resourceGroups.map(H=>s.jsxs("fieldset",{children:[s.jsx("legend",{children:H.label}),H.items.map(A=>s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:(d[H.id]??[]).includes(A.id),disabled:C,onChange:I=>U(H.id,A.id,I.target.checked,d[H.id]??[])}),A.label,A.description&&s.jsx("small",{children:A.description})]},A.id)),H.truncated&&s.jsx("p",{children:i.resourcesTruncated})]},H.id)),s.jsx("button",{type:"submit",disabled:C||X,children:i.confirm}),D]})}case"processing":return s.jsx("p",{className:"link-authorization-status",role:"status",children:i.processing});default:return s.jsx("p",{role:"alert",children:i.unsupported})}};return s.jsxs(s.Fragment,{children:[q,se()]})}const Gn="/api/v1/links",_S={connected:"已连接",expired:"授权已过期",invalid:"需要重新连接",unavailable:"凭据不可用"};function fl(t){try{const i=new URL(t??"");return i.protocol==="https:"&&!i.username&&!i.password?i.href:void 0}catch{return}}function DS({onAuthLost:t,onDirtyChange:i,hostLabel:r="服务端",configurationVersion:a=0}){const[u,d]=S.useState(),[c,h]=S.useState(),[p,m]=S.useState(""),[y,b]=S.useState(""),[v,x]=S.useState(""),[j,R]=S.useState(!0),[C,T]=S.useState(!1),[_,D]=S.useState(),[q,se]=S.useState(),[N,U]=S.useState(),[X,H]=S.useState(),A=S.useRef(new Map),I=S.useRef(new Set),[L,P]=S.useState(),W=S.useMemo(()=>new O1({begin:async(M,ie)=>{const ye=po(),{workspace:xe,projectId:Ne}=ye,Te=await Ue(xt(`${Gn}/authorizations`,xe,Ne),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M,authModeId:ie})},ye);return A.current.set(Te.id,{target:xt(`${Gn}/authorizations/${encodeURIComponent(Te.id)}`,xe,Ne),scope:ye}),Te},status:M=>{const ie=A.current.get(M);return Ue(ie.target,{},ie.scope)},respond:(M,ie)=>{const ye=A.current.get(M),xe=new URL(ye.target,window.location.origin);return xe.pathname+="/responses",Ue(xe.pathname+xe.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)},ye.scope)},cancel:async M=>{if(I.current.has(M))return;const ie=A.current.get(M);ie&&(await Ue(ie.target,{method:"DELETE",keepalive:!0},ie.scope),A.current.delete(M))}}),[]),ee=S.useSyncExternalStore(W.subscribe,W.getSnapshot),G=u?.capabilities.authorizationSteps===1&&!!c?.provider.authModes,B=G&&ee.authorization?.state==="pending",[Q,fe]=S.useState(0),k=S.useRef(!1),O=S.useRef(0),le=S.useRef(null),E=S.useRef(void 0),J=S.useRef(void 0),be=S.useRef(void 0),Z=S.useRef(void 0),ne=S.useRef({onAuthLost:t,onDirtyChange:i});ne.current={onAuthLost:t,onDirtyChange:i};const ge=C||ee.busy||B||N?.state==="pending"||!!(c&&(c.token||c.label!==(c.original?.label??c.provider.displayName))),Y=S.useCallback(M=>{M instanceof Xe&&M.status===401?ne.current.onAuthLost():b(M instanceof Error?M.message:"连接操作失败,请重试。")},[]);S.useEffect(()=>{if(!c)return;const M=document.activeElement;return le.current?.querySelector("input:not(:disabled), button:not(:disabled)")?.focus(),()=>M?.focus?.()},[!!c]),S.useEffect(()=>{ne.current.onDirtyChange?.(ge)},[ge]),S.useEffect(()=>{k.current=!0;const M=++O.current;return()=>{k.current=!1,ne.current.onDirtyChange?.(!1),E.current?.abort(),queueMicrotask(()=>{O.current===M&&W.dispose()}),J.current&&Ue(J.current,{method:"DELETE",keepalive:!0},be.current).catch(()=>{})}},[W]),S.useEffect(()=>{const M=new AbortController;return Z.current=M,R(!0),Ue(Gn,{signal:M.signal}).then(ie=>{M.signal.aborted||d(ie)}).catch(ie=>{M.signal.aborted||Y(ie)}).finally(()=>{M.signal.aborted||R(!1)}),()=>M.abort()},[Q,a,Y]),S.useEffect(()=>{G&&(ee.error&&Y(ee.error),ee.authorization?.state==="connected"&&ee.authorization.connection&&(h(void 0),x("授权完成,连接已保存。"),fe(M=>M+1)))},[G,ee.authorization,ee.error,Y]),S.useEffect(()=>{if(!u?.remoteCleanupPending)return;const M=setInterval(()=>fe(ie=>ie+1),3e4);return()=>clearInterval(M)},[u?.remoteCleanupPending]),S.useEffect(()=>{if(N?.state!=="pending"||!J.current)return;const M=J.current,ie=be.current,ye=new AbortController;let xe;const Ne=async()=>{try{const Te=await Ue(M,{signal:ye.signal},ie);if(ye.signal.aborted||J.current!==M)return;U(Te),Te.state==="connected"?(J.current=void 0,h(void 0),x("授权完成,连接已保存。"),fe(Fe=>Fe+1)):Te.state!=="pending"?(J.current=void 0,b(Te.state==="cancelled"?"授权已取消。":"授权未完成或已过期,请重新开始。")):xe=setTimeout(()=>{Ne()},2e3)}catch(Te){if(ye.signal.aborted||J.current!==M)return;Y(Te),Te instanceof Xe&&[401,404].includes(Te.status)?(J.current=void 0,U(Fe=>Fe?{...Fe,state:"failed"}:void 0)):xe=setTimeout(()=>{Ne()},4e3)}};return xe=setTimeout(()=>{Ne()},1e3),()=>{ye.abort(),clearTimeout(xe)}},[N?.id,N?.state,Y]);async function ve(M,ie){if(E.current)return;const ye=new AbortController;E.current=ye,Z.current?.abort(),T(!0),R(!1),b(""),x("");try{const xe=await M(ye.signal);k.current&&!ye.signal.aborted&&ie(xe)}catch(xe){k.current&&!ye.signal.aborted&&(Y(xe),xe instanceof Xe&&[409,503].includes(xe.status)&&fe(Ne=>Ne+1))}finally{E.current===ye&&(E.current=void 0),k.current&&T(!1)}}function De(M,ie,ye,xe,Ne){return Ue(M,{method:ie,headers:{"Content-Type":"application/json"},body:JSON.stringify(ye),signal:xe},Ne)}function ze(){return{providerId:c.provider.id,methodId:c.methodId,label:c.label.trim(),expectedRevision:c.original?.revision??null,...c.original?{connectionId:c.original.id}:{}}}function _e(){h(void 0),se(void 0),x("连接已保存。"),fe(M=>M+1)}function qe(M,ie){if(C||ee.busy||B||N?.state==="pending"||ge&&!window.confirm("放弃当前未保存的连接修改?"))return;W.reset();const ye=ie?Vc(M,ie.methodId):Vc(M),xe=ie?M.connectionMethods.find(Te=>Te.id===ie.methodId):M.connectionMethods.find(Te=>Te.id===ye?.methodId)??M.connectionMethods.find(Te=>Te.executionRuntime==="local"&&Te.availability==="available");if(!xe){b("当前环境未提供此连接的授权方式,请检查服务器连接设置。");return}const Ne={provider:M,original:ie,methodId:xe.id,label:ie?.label??M.displayName,token:""};h(Ne),se(void 0),U(void 0),H(ye?.id),b(""),x(""),!ie&&u?.capabilities.authorizationSteps===1&&ye&&ot(Ne,ye)}async function ot(M,ie){if(!ie.available||!M.label.trim()||W.getSnapshot().authorization?.state==="pending"&&(await W.cancel(),W.getSnapshot().authorization?.state==="pending"))return;b(""),H(ie.id),h({...M,methodId:ie.methodId});const ye={workspace:mo()??"",projectId:Na()},xe=await W.begin({providerId:M.provider.id,methodId:ie.methodId,label:M.label.trim(),expectedRevision:M.original?.revision??null,...M.original?{connectionId:M.original.id}:{}},ie.id);if(!(xe?.state!=="pending"||ki(xe)?.kind!=="redirect"))try{if(u?.capabilities.browserHandoff===1){const Fe=A.current.get(xe.id),mt=new URL(Fe.target,window.location.origin);mt.pathname+="/browser";const dt=await Ue(mt.pathname+mt.search,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},Fe.scope),ft=new URL(dt.launchUrl);if(ft.origin!==window.location.origin||ft.pathname!=="/link/authorize"||ft.username||ft.password||ft.hash||ft.searchParams.size!==1||!/^[A-Za-z0-9_-]{43}$/.test(ft.searchParams.get("ticket")??""))throw new Error("授权浏览器入口无效,请重新连接。");W.getSnapshot().authorization?.id===xe.id&&W.getSnapshot().authorization?.state==="pending"&&P({id:xe.id,url:ft.href});return}const Ne=u?.remoteServer?.issuer;if(!Ne)throw new Error("当前 Host 尚未配置授权服务。");const Te=U1(xe,Ne,ye);I.current.add(xe.id),Gw.flushSync(()=>{h(void 0),ne.current.onDirtyChange?.(!1)}),window.location.assign(Te)}catch(Ne){await W.cancel(),Y(Ne)}}async function $e(){if(B){await W.cancel(),W.getSnapshot().authorization?.state==="cancelled"&&x("授权已取消。");return}if(!J.current)return;const M=J.current,ie=be.current;await ve(ye=>Ue(M,{method:"DELETE",signal:ye},ie),()=>{J.current=void 0,U(void 0),x("授权已取消。")})}function At(){G?W.cancel().then(()=>{W.getSnapshot().authorization?.state!=="pending"&&h(void 0)}):!Ye&&(!ge||window.confirm("放弃未保存的连接修改?"))&&h(void 0)}function ut(M,ie=po()){if(G&&W.getSnapshot().authorization?.state==="pending"&&c?.original?.id===M.id){W.cancel().then(()=>{W.getSnapshot().authorization?.state!=="pending"&&ut(M,ie)});return}const ye=c?.original?.id===M.id&&N?.state==="pending"?J.current:void 0,xe=xt(`${Gn}/connections/${encodeURIComponent(M.id)}`,ie.workspace,ie.projectId),Ne=be.current;ve(async Te=>{if(ye){try{await Ue(ye,{method:"DELETE",signal:Te},Ne)}catch(Fe){if(!(Fe instanceof Xe&&Fe.status===404))throw Fe}k.current&&!Te.aborted&&J.current===ye&&(J.current=void 0,U(void 0))}return De(xe,"DELETE",{expectedRevision:M.revision},Te,ie)},()=>{c?.original?.id===M.id&&h(void 0),D(void 0),fe(Te=>Te+1),x("连接已断开。")})}const Ie=c?.provider.connectionMethods.find(M=>M.id===c.methodId),Lt=N?.state==="pending",Ye=C||ee.busy||Lt||B,rt=p.trim().toLowerCase(),Tt=(u?.providers??[]).filter(M=>(u?.capabilities.authorizationSteps!==1||M.authModes?.some(ie=>ie.available))&&`${M.displayName} ${M.description.zh}`.toLowerCase().includes(rt)),He=c&&u?.connections.find(M=>c.original?M.id===c.original.id:M.id===`link-${c.provider.id}-${c.methodId}`&&M.providerId===c.provider.id&&M.methodId===c.methodId),ct=c&&u&&(c.original?He?.revision!==c.original.revision:!!He);return s.jsxs("section",{className:"hub-links",children:[s.jsxs("header",{className:"links-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{children:"Link"}),s.jsx("p",{children:"连接你的工具与账号,让任务访问已授权的服务。"})]}),s.jsx("button",{onClick:()=>{b(""),fe(M=>M+1)},disabled:C||j,children:"刷新"})]}),!!u?.remoteCleanupPending&&s.jsxs("p",{role:"status",className:"links-muted",children:["有 ",u.remoteCleanupPending," 项遗留授权等待撤销。项目所在环境 会自动重试,重启后仍会继续;也可在 Link 服务中撤销。"]}),s.jsxs("p",{className:"links-host",children:["连接由当前项目所属的",r,"管理,授权后只访问你允许的服务与资源。"]}),y&&s.jsx("p",{className:"form-error",role:"alert",children:y}),v&&s.jsx("p",{className:"links-notice",role:"status",children:v}),j&&!u&&s.jsx("p",{role:"status",children:"正在加载连接…"}),s.jsx("h2",{children:"已连接"}),u&&u.connections.length===0&&s.jsx("p",{className:"links-muted",children:"还没有连接。选择下面的服务开始。"}),s.jsx("div",{className:"links-connections",children:u?.connections.map(M=>{const ie=u.providers.find(ye=>ye.id===M.providerId);return s.jsxs("article",{className:"links-connection",children:[s.jsxs("div",{children:[s.jsx("strong",{children:M.label}),s.jsxs("p",{children:[ie?.displayName??M.providerId," ·"," ",M.account?.label??M.account?.id??"已授权账号"]}),s.jsx("span",{className:`links-state ${M.status==="connected"?"ready":""}`,children:_S[M.status]}),s.jsxs("small",{children:[M.authSource==="remote-link"?"独立 Link 授权":M.authSource==="cli-session"?"CLI 登录":M.authSource==="browser-oauth"?"浏览器授权":"Token",M.expiresAt?` · 到期 ${new Date(M.expiresAt).toLocaleString()}`:""]}),M.account?.resources.length?s.jsx("p",{children:M.account.resources.join("、")}):null]}),s.jsx("div",{className:"links-actions",children:M.editable?s.jsxs(s.Fragment,{children:[s.jsx("button",{disabled:Ye||!ie,onClick:()=>ie&&qe(ie,M),children:"管理连接"}),s.jsx("button",{disabled:C,onClick:()=>D(M),children:"断开"})]}):s.jsx("small",{children:"项目配置管理"})})]},M.id)})}),_&&s.jsxs("div",{className:"links-confirm",role:"alertdialog","aria-label":"断开连接",children:[s.jsxs("p",{children:["断开「",_.label,"」后,后续任务将无法使用这个连接,正在执行的请求会尝试停止。"]}),s.jsx("button",{disabled:C,onClick:()=>ut(_),children:"确认断开"}),s.jsx("button",{disabled:C,onClick:()=>D(void 0),children:"取消"})]}),c&&Ie&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"links-editor-backdrop","aria-hidden":"true"}),s.jsxs("section",{className:"links-editor",ref:le,onKeyDown:M=>{if(M.key==="Escape"&&(M.preventDefault(),At()),M.key!=="Tab")return;const ie=le.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), a[href], summary");if(!ie?.length)return;const ye=ie[0],xe=ie[ie.length-1];M.shiftKey&&document.activeElement===ye?(M.preventDefault(),xe.focus()):!M.shiftKey&&document.activeElement===xe&&(M.preventDefault(),ye.focus())},role:"dialog","aria-modal":"true","aria-label":`${c.provider.displayName} 连接设置`,children:[s.jsxs("div",{className:"links-heading",children:[s.jsxs("h2",{children:[c.provider.displayName," · ",c.original?"管理连接":"添加连接"]}),s.jsx("button",{disabled:!G&&Ye,onClick:At,children:"关闭"})]}),s.jsxs("label",{children:["连接名称",s.jsx("input",{maxLength:100,value:c.label,disabled:Ye,onChange:M=>h({...c,label:M.target.value})})]}),ct&&s.jsxs("div",{className:"links-conflict",role:"alert",children:[s.jsx("p",{children:"这个连接已在其他设备创建、修改或删除。你的输入仍然保留,请先载入最新版本。"}),s.jsx("button",{disabled:Ye,onClick:()=>h({...c,original:He||void 0}),children:"载入最新版本,保留输入"})]}),G?s.jsxs("div",{className:"links-authorization",children:[s.jsx("p",{className:"links-muted",children:Ie.executionRuntime==="server"?"由 Link 服务保存授权并访问已选择的资源。":`连接保存到当前项目所属的${r}。`}),ee.authorization?s.jsx(zS,{authorization:ee.authorization,busy:ee.busy||!!ct||u?.capabilities.browserHandoff===1&&ki(ee.authorization)?.kind==="redirect"&&L?.id!==ee.authorization.id,onRespond:M=>{W.respond(M)},onOpenUrl:M=>{const ye=u?.capabilities.browserHandoff===1&&ki(ee.authorization)?.kind==="redirect"?L&&L.id===ee.authorization?.id?L.url:void 0:M;ye&&window.open(ye,"_blank","noopener,noreferrer")},onCopy:M=>{navigator.clipboard?.writeText(M).catch(Y)}}):s.jsx("button",{disabled:ee.busy||!!ct||!c.label.trim(),onClick:()=>{const M=c.provider.authModes?.find(ie=>ie.id===X&&ie.available)??Vc(c.provider,c.methodId);M&&ot(c,M)},children:ee.busy?"正在连接…":c.original?"重新连接":"开始连接"}),s.jsxs("div",{className:"links-actions",children:[B&&s.jsx("button",{disabled:ee.busy,onClick:()=>{$e()},children:"取消授权"}),ee.authorization&&ee.authorization.state!=="pending"&&s.jsx("button",{disabled:ee.busy||!!ct||!c.label.trim(),onClick:()=>{const M=c.provider.authModes?.find(ie=>ie.id===X&&ie.available);M&&ot(c,M)},children:"重新连接"})]}),s.jsxs("details",{className:"links-other-methods",children:[s.jsx("summary",{children:"其他连接方式"}),s.jsx("div",{className:"links-methods",children:c.provider.authModes?.map(M=>s.jsxs("button",{disabled:ee.busy||!M.available||!!ct||!c.label.trim(),title:M.unavailableReason,onClick:()=>{ot(c,M)},children:[M.label,M.id===X?" · 当前":""]},M.id))})]}),c.original&&s.jsx("button",{disabled:Ye||!!ct||!c.label.trim(),onClick:()=>{ve(M=>De(`${Gn}/connections/${encodeURIComponent(c.original.id)}`,"PATCH",{label:c.label.trim(),expectedRevision:c.original.revision},M),_e)},children:"保存名称"})]}):s.jsxs(s.Fragment,{children:[Ie.browserAuth&&s.jsxs("div",{className:"links-auth-option",children:[s.jsx("h3",{children:"浏览器授权"}),c.provider.deviceAuth?.configured?s.jsx("button",{disabled:Ye||!c.label.trim()||!!ct,onClick:()=>{const M=mo()??"",ie=Na(),ye={workspace:M,projectId:ie},xe=xt(`${Gn}/authorizations/device`,M,ie);ve(Ne=>De(xe,"POST",ze(),Ne,ye),Ne=>{J.current=xt(`${Gn}/authorizations/${encodeURIComponent(Ne.id)}`,M,ie),be.current=ye,U(Ne)})},children:"开始授权"}):s.jsxs("p",{className:"links-muted",children:["这台",r,"尚未配置此服务的浏览器授权,可使用下面的连接方式。"]}),Lt&&N.prompt&&s.jsxs("div",{className:"links-device-code",role:"status",children:[s.jsx("p",{children:"在服务商页面输入验证码:"}),s.jsx("strong",{children:N.prompt.userCode}),s.jsx("p",{children:fl(N.prompt.verificationUriComplete??N.prompt.verificationUri)&&s.jsx("a",{href:fl(N.prompt.verificationUriComplete??N.prompt.verificationUri),target:"_blank",rel:"noreferrer",children:"打开授权页面 ↗"})}),s.jsxs("p",{children:["完成后会自动保存。有效期至"," ",new Date(N.prompt.expiresAt).toLocaleTimeString(),"。"]}),s.jsx("button",{disabled:C,onClick:()=>{$e()},children:"取消授权"})]})]}),Ie.quickAuth&&s.jsxs("div",{className:"links-auth-option",children:[s.jsx("h3",{children:"使用已登录的 CLI"}),s.jsxs("p",{children:[r,"需要已安装并登录 ",Ie.quickAuth.command,"。"]}),s.jsx("button",{disabled:Ye,onClick:()=>{ve(M=>Ue(`${Gn}/providers/${encodeURIComponent(c.provider.id)}/cli`,{signal:M}),se)},children:"检查登录状态"}),q&&s.jsx("p",{role:"status",children:q.authenticated?`已登录${q.account?`:${q.account}`:""}`:q.installed?"已安装,尚未登录。请在运行服务的机器上登录。":"尚未安装。"}),q?.authenticated&&s.jsx("button",{disabled:Ye||!c.label.trim()||!!ct,onClick:()=>{ve(M=>De(`${Gn}/connections/cli`,"POST",ze(),M),_e)},children:"绑定这个登录"})]}),Ie.authKind==="token"&&s.jsxs("form",{className:"links-auth-option",onSubmit:M=>{M.preventDefault(),!(Ye||ct)&&ve(ie=>c.original&&!c.token.trim()?De(`${Gn}/connections/${encodeURIComponent(c.original.id)}`,"PATCH",{label:c.label.trim(),expectedRevision:c.original.revision},ie):De(`${Gn}/connections/token`,"POST",{...ze(),token:c.token.trim()},ie),_e)},children:[s.jsx("h3",{children:c.original?"名称与 Token":"使用 Token"}),Ie.authGuide&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:Ie.authGuide.summary.zh}),s.jsxs("div",{className:"links-actions",children:[fl(Ie.authGuide.createCredentialUrl)&&s.jsx("a",{href:fl(Ie.authGuide.createCredentialUrl),target:"_blank",rel:"noreferrer",children:"创建凭据 ↗"}),fl(Ie.authGuide.docsUrl)&&s.jsx("a",{href:fl(Ie.authGuide.docsUrl),target:"_blank",rel:"noreferrer",children:"授权说明 ↗"})]}),s.jsxs("details",{children:[s.jsx("summary",{children:"所需权限与设置步骤"}),s.jsx("ul",{children:Ie.authGuide.permissions.map(M=>s.jsxs("li",{children:[M.label,"(",M.level==="required"?"必需":"可选",")",M.description?`:${M.description.zh}`:""]},M.id))}),s.jsx("ol",{children:Ie.authGuide.steps.map((M,ie)=>s.jsx("li",{children:M.zh},ie))})]})]}),s.jsxs("label",{children:[Ie.tokenLabel??c.provider.tokenLabel,s.jsx("input",{type:"password",autoComplete:"off",value:c.token,disabled:Ye,placeholder:c.original?"留空保留当前授权,仅修改名称":Ie.tokenPlaceholder??c.provider.tokenPlaceholder,onChange:M=>h({...c,token:M.target.value}),required:!c.original,maxLength:16384})]}),s.jsx("button",{type:"submit",className:"send",disabled:Ye||!!ct||!c.label.trim(),children:C?"正在验证并保存…":c.token.trim()||!c.original?"验证并保存":"保存名称"})]})]}),s.jsxs("details",{children:[s.jsxs("summary",{children:[G?"服务支持的操作":"可用操作","(",c.provider.actions.length,")"]}),G&&s.jsx("p",{className:"links-muted",children:"此连接实际可用的操作以授权时确认的权限为准。"}),s.jsx("ul",{children:c.provider.actions.map(M=>s.jsxs("li",{children:[s.jsx("strong",{children:M.title}),M.risk==="write"?" · 执行前需要确认":"",s.jsx("p",{children:M.description})]},M.id))})]})]})]}),s.jsxs("div",{className:"links-heading",children:[s.jsx("h2",{children:"添加服务"}),s.jsx("input",{type:"search","aria-label":"搜索 Link 服务",placeholder:"搜索服务",value:p,onChange:M=>m(M.target.value)})]}),s.jsx("div",{className:"links-providers",children:Tt.map(M=>{const ie=u?.connections.find(ye=>ye.providerId===M.id);return s.jsxs("article",{className:"links-provider",children:[s.jsx("div",{className:`links-brand accent-${M.accent}`,"aria-hidden":"true",children:M.brandText}),s.jsx("h3",{children:M.displayName}),s.jsx("p",{children:M.description.zh}),s.jsxs("small",{children:[M.actions.length," 项操作"]}),s.jsx("button",{disabled:Ye||u?.capabilities.authorizationSteps!==1&&!!(ie&&!ie.editable),onClick:()=>qe(M,u?.capabilities.authorizationSteps===1?void 0:ie),children:u?.capabilities.authorizationSteps===1?"添加连接":ie?ie.editable?"管理连接":"项目配置管理":"添加连接"})]},M.id)})}),u&&Tt.length===0&&s.jsx("p",{className:"links-muted",children:"没有匹配的服务。"})]})}const jd="/api/v1/panels",Dy="https://github.com/cjhyy/codeshell-panel-apps.git",My={"context.session":"读取当前对话信息","context.workspace":"读取当前工作区信息",storage:"保存面板自己的数据","external.open":"打开外部网页","agent.submitPrompt":"向当前对话提交任务","agent.task":"创建和管理 Agent 任务","workspace.info":"查看工作区信息","workspace.read":"读取工作区文件","workspace.write":"修改工作区文件","notifications.send":"发送通知","audio.transcribe":"将音频转成文字","credentials.cookies":"使用宿主授权的浏览器 Cookie","automations.manage":"管理自动化任务",process:"在宿主运行命令和进程",media:"处理宿主上的音视频文件","media.capture":"使用麦克风、摄像头或屏幕录制"};function Vn(t){return t["zh-CN"]||t.default}function no({value:t}){return t.supported&&t.reasons.length===0?null:s.jsxs("div",{className:"panels-warning",children:[s.jsx("strong",{children:t.supported?"部分功能可用":"当前 Web 工作台暂不支持此面板"}),t.supported&&s.jsx("p",{children:"可以打开面板,以下功能当前不可用或需要额外配置。"}),t.reasons.length>0&&s.jsx("ul",{children:t.reasons.map(i=>s.jsx("li",{children:i},i))})]})}function MS({onAuthLost:t,onDirtyChange:i,onChanged:r,onOpen:a,hostLabel:u="服务端",configurationVersion:d=0}){const[c,h]=S.useState(),[p,m]=S.useState(""),[y,b]=S.useState(""),[v,x]=S.useState(""),[j,R]=S.useState(""),[C,T]=S.useState(),[_,D]=S.useState(),[q,se]=S.useState(),[N,U]=S.useState(),[X,H]=S.useState(!1),[A,I]=S.useState(),[L,P]=S.useState(),[W,ee]=S.useState(!1),[G,B]=S.useState(!0),[Q,fe]=S.useState(!1),[k,O]=S.useState(),[le,E]=S.useState(!0),[J,be]=S.useState(""),[Z,ne]=S.useState(""),[ge,Y]=S.useState(""),[ve,De]=S.useState(0),ze=S.useRef(!1),_e=S.useRef(void 0),qe=S.useRef(void 0),ot=S.useRef(!1),$e=S.useRef(void 0),At=S.useRef(null),ut=S.useRef({onAuthLost:t,onDirtyChange:i,onChanged:r,onOpen:a});ut.current={onAuthLost:t,onDirtyChange:i,onChanged:r,onOpen:a};function Ie(V){fetch(V.target,{method:"DELETE",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviewToken:V.token}),keepalive:!0,signal:AbortSignal.timeout(5e3)}).catch(()=>{})}const Lt=!!(J||_||q||L||k||p.trim()||y.trim()||v.trim()),Ye=S.useCallback(V=>{V instanceof Xe&&V.status===401?ut.current.onAuthLost():ne(V instanceof Error?V.message:"面板操作失败,请重试。")},[]);S.useEffect(()=>(ze.current=!0,()=>{ze.current=!1,_e.current?.abort(),qe.current?.abort(),$e.current&&(Ie($e.current),$e.current=void 0),ut.current.onDirtyChange?.(!1)}),[]),S.useEffect(()=>{ut.current.onDirtyChange?.(Lt)},[Lt]),S.useEffect(()=>{if(_e.current){ot.current=!0;return}const V=new AbortController;return qe.current=V,E(!0),Ue(xt(jd),{signal:V.signal}).then(de=>{V.signal.aborted||h(de)}).catch(de=>{V.signal.aborted||Ye(de)}).finally(()=>{V.signal.aborted||E(!1)}),()=>V.abort()},[ve,d,Ye]),S.useEffect(()=>{_&&At.current?.focus()},[_?.reviewToken]);async function rt(V,de,ke,Ke,at=!1,Rt){if(_e.current||!ze.current)return;const kt=new AbortController;_e.current=kt,qe.current?.abort(),E(!1),be(V),ne(""),Y("");const ni=xt(`${jd}${de}`);try{const Vt=await Ue(ni,{method:ke,headers:{"Content-Type":"application/json"},body:JSON.stringify(Ke),signal:kt.signal});if(kt.signal.aborted||!ze.current){Rt?.(Vt);return}return at&&(ot.current=!0,ut.current.onChanged?.()),Vt}catch(Vt){if(kt.signal.aborted||!ze.current)return;Vt instanceof Xe&&(Vt.status===409||Vt.status===410)&&(_&&ee(!0),N&&H(!0),ot.current=!0),Ye(Vt);return}finally{_e.current===kt&&(_e.current=void 0),ze.current&&!kt.signal.aborted&&(be(""),ot.current&&(ot.current=!1,De(Vt=>Vt+1)))}}const Tt=async V=>{if(!await Fe())return;se(void 0),U(void 0),P(void 0),D(void 0),O(void 0),T(void 0);const de=await rt("正在读取仓库…","/github/discover","POST",{url:V.url,...V.ref?{ref:V.ref}:{},...V.subdir?{subdir:V.subdir}:{}});de&&T(de)},He=async V=>{if(!await Fe())return;se(void 0),U(void 0);const de=await rt("正在准备安装审阅…","/preview","POST",{source:V});de&&(O(void 0),I(V),D(de),ee(!1),fe(!1),B(!!c?.hasProject&&de.compatibility.supported))},ct=async V=>{if(!await Fe())return;se(void 0),U(void 0);const de=await rt("正在检查更新…",`/${encodeURIComponent(V.id)}/update-preview`,"POST",{expectedRevision:V.revision});de&&(O(void 0),I(void 0),D(de),ee(!1),fe(V.bound),B(V.bound&&de.compatibility.supported))},M=()=>{if(_)if(_.kind==="update"){const V=c?.panels.find(de=>de.id===_.preview.id);V?ct(V):(ne("此面板已被卸载,请重新从 GitHub 选择安装。"),D(void 0))}else A&&He(A)},ie=()=>{P(void 0),T(void 0),m(""),b(""),x("")},ye=async()=>{if(D(void 0),!L||L.position+1>=L.candidates.length){ie();return}const V=L.position+1;P({...L,position:V}),await He(L.candidates[V].source)},xe=async V=>{V.length&&(P({candidates:V,position:0}),await He(V[0].source))},Ne=async()=>{if(!_||W)return;if(_.expiresAt<=Date.now()){ee(!0),ne("安装审阅已过期,请重新审阅后继续。");return}await rt(_.kind==="update"?"正在更新面板…":"正在安装面板…","/install","POST",{reviewToken:_.reviewToken,bind:G},!0)&&(Y(`${Vn(_.preview.title)} 已${_.kind==="update"?"更新":"安装"}${G?"并绑定当前工作区":""}。`),D(void 0),L?await ye():ie())},Te=async V=>{const de=await rt(V.bound?"正在解除绑定…":"正在绑定工作区…",`/${encodeURIComponent(V.id)}/binding`,"PATCH",{bound:!V.bound,expectedRevision:V.revision},!0);de&&(h(de),Y(`${Vn(V.title)} 已${V.bound?"解除当前工作区绑定":"绑定当前工作区"}。`))},Fe=async()=>N?(await rt("正在关闭版本审阅…","/restore/review","DELETE",{reviewToken:N.reviewToken}))?.cancelled?($e.current=void 0,U(void 0),!0):!1:!0,mt=async()=>{await Fe()&&se(void 0)},dt=async V=>{if(!await Fe())return;D(void 0),O(void 0),U(void 0),se(void 0);const de=await rt("正在检查保留版本…",`/${encodeURIComponent(V.id)}/versions`,"POST",{expectedRevision:V.revision});de&&(se(de),H(!1))},ft=async V=>{if(!q||!await Fe())return;const de=xt(`${jd}/restore/review`),ke=await rt("正在审阅项目版本…",`/${encodeURIComponent(q.appId)}/restore-preview`,"POST",{packageDigest:V,expectedRevision:q.expectedRevision},!1,Ke=>Ie({target:de,token:Ke.reviewToken}));if(ke){if(!ze.current){Ie({target:de,token:ke.reviewToken});return}$e.current={target:de,token:ke.reviewToken},U(ke),H(!1)}},tt=async()=>{if(!N||Ce)return;if(N.expiresAt<=Date.now()){H(!0),ne("版本审阅已过期,请重新选择版本。");return}await rt("正在恢复项目版本…","/restore","POST",{reviewToken:N.reviewToken},!0)&&($e.current=void 0,Y(`${Vn(N.title)} 的项目版本已恢复为 v${N.version}。`),se(void 0),U(void 0))},Bt=async()=>{if(!k||c?.panels.find(de=>de.id===k.id)?.revision!==k.revision)return;(await rt("正在卸载面板…",`/${encodeURIComponent(k.id)}`,"DELETE",{expectedRevision:k.revision},!0))?.removed&&(Y(`${Vn(k.title)} 已卸载。`),O(void 0))},yt=!!J||!c||!!L,K=j.trim().toLowerCase(),je=(c?.panels??[]).filter(V=>[Vn(V.title),V.id,V.description??"",V.source.label].join(" ").toLowerCase().includes(K)),Ee=C?.panels.filter(V=>!c?.panels.some(de=>de.id===V.id)&&!c?.issues?.some(de=>de.id===V.id)&&C.panels.filter(de=>de.id===V.id).length===1)??[],re=k&&c?.panels.find(V=>V.id===k.id),we=!!k&&re?.revision!==k.revision,Me=_?.kind==="update"?c?.panels.find(V=>V.id===_.preview.id):void 0,Ce=X||!!q&&(c?.panels.find(V=>V.id===q.appId)?.revision??c?.issues?.find(V=>V.id===q.appId)?.revision)!==q.expectedRevision;return s.jsxs("section",{className:"hub-panels",children:[s.jsxs("header",{className:"panels-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{children:"面板"}),s.jsx("p",{children:"从 GitHub 安装工具面板,绑定工作区后直接在工作台中打开。"})]}),s.jsx("button",{disabled:!!J||le,onClick:()=>De(V=>V+1),children:le?"正在刷新…":"刷新"})]}),s.jsxs("p",{className:"panels-muted",children:["面板安装在",u,"上,文件和任务操作使用当前工作区。"]}),c&&!c.hasProject&&s.jsx("div",{className:"panels-warning",children:"请先选择一个项目,才能绑定和打开面板。"}),Z&&s.jsx("p",{role:"alert",className:"error",children:Z}),ge&&s.jsx("p",{role:"status",className:"panels-notice",children:ge}),J&&s.jsx("p",{role:"status",className:"panels-muted",children:J}),c?.issues?.filter(V=>V.id.toLowerCase().includes(K)).map(V=>s.jsxs("section",{className:"panels-warning","aria-label":"需要修复的面板",children:[s.jsx("h2",{children:V.id}),s.jsxs("p",{children:["项目记录版本:",V.version??"未记录","。安装包缺失或无法校验,面板暂不可用。"]}),s.jsx("p",{children:"项目数据和任务记录仍保留。可检查宿主保留的版本,审阅权限后恢复。"}),s.jsx("button",{disabled:!!J||!V.bound||!c.canRestorePackages,onClick:()=>{dt(V)},children:"检查可用版本"})]},V.id)),q&&s.jsxs("section",{className:"panels-review","aria-label":"项目保留版本",children:[s.jsxs("header",{className:"panels-heading",children:[s.jsxs("div",{children:[s.jsxs("h2",{children:[Vn(q.title)," · 项目版本"]}),s.jsxs("p",{children:["项目记录版本:",q.current.version]})]}),s.jsx("button",{disabled:!!J,onClick:()=>{mt()},children:"关闭版本记录"})]}),s.jsx("p",{children:"选择宿主已保留的程序版本,仅切换当前项目。其他项目继续使用各自版本。"}),s.jsx("p",{className:"panels-warning",children:"切换程序版本不会恢复旧数据。请先备份项目,确认该版本支持当前文档格式;任务与产物记录会保留。"}),q.current.unavailable&&s.jsx("p",{role:"status",children:"当前安装包不可用,无法读取原权限;恢复前需重新审阅目标版本的全部权限。"}),q.unavailablePackages>0&&s.jsxs("p",{role:"status",children:["有 ",q.unavailablePackages," 个保留包无法校验,暂不能选择。"]}),!q.versions.length&&s.jsx("p",{children:"没有可用的保留版本。"}),s.jsx("div",{className:"panels-grid",children:q.versions.map(V=>s.jsxs("article",{className:"panels-card",children:[s.jsxs("h3",{children:["v",V.version]}),s.jsxs("small",{children:["内容编号 ",V.packageDigest.slice(0,12)]}),s.jsx(no,{value:V.compatibility}),s.jsx("button",{disabled:!!J||!V.compatibility.supported||V.packageDigest===q.current.packageDigest,onClick:()=>{ft(V.packageDigest)},children:V.packageDigest===q.current.packageDigest?"当前项目版本":`审阅 v${V.version}`})]},V.packageDigest))}),N&&s.jsxs("section",{className:"panels-confirm","aria-label":"确认恢复项目版本",children:[s.jsxs("h3",{children:["v",N.current.version," → v",N.version]}),s.jsx("h4",{children:"此版本请求的权限"}),!N.permissions.length&&s.jsx("p",{children:"未申请宿主权限。"}),N.permissions.map(V=>s.jsxs("div",{className:"panels-permission",children:[s.jsx("span",{children:My[V]??V}),N.addedPermissions.includes(V)&&s.jsx("strong",{children:N.current.unavailable?"需重新确认":"新增权限"})]},V)),s.jsx(no,{value:N.compatibility}),Ce&&s.jsx("p",{role:"alert",children:"项目或审阅已变化,请关闭版本记录并重新读取。"}),s.jsx("button",{disabled:!!J||Ce||!N.compatibility.supported,onClick:()=>{tt()},children:"确认权限并恢复项目版本"})]})]}),L&&s.jsxs("section",{className:"panels-confirm","aria-label":"逐个审阅面板",children:[s.jsxs("p",{children:["正在审阅第 ",L.position+1," / ",L.candidates.length," 个面板:",Vn(L.candidates[L.position].title),"。每个面板都需要单独确认安装。"]}),s.jsxs("div",{className:"panels-actions",children:[!_&&s.jsx("button",{disabled:!!J,onClick:()=>{He(L.candidates[L.position].source)},children:"重新读取此面板"}),s.jsx("button",{disabled:!!J,onClick:()=>{ye()},children:"跳过此面板"}),s.jsx("button",{disabled:!!J,onClick:()=>{P(void 0),D(void 0),ne("")},children:"取消逐个审阅"})]})]}),_&&s.jsxs("section",{className:"panels-review","aria-labelledby":"panel-review-heading",children:[s.jsxs("header",{className:"panels-heading",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"panel-review-heading",ref:At,tabIndex:-1,children:_.kind==="update"?"审阅面板更新":"审阅面板安装"}),s.jsxs("p",{children:[Vn(_.preview.title)," · ",_.preview.id," · v",_.preview.version]})]}),s.jsx("button",{disabled:!!J,onClick:()=>{P(void 0),D(void 0),ne("")},children:"取消审阅"})]}),_.preview.description&&s.jsx("p",{children:_.preview.description}),Me&&s.jsxs("p",{className:"panels-warning",children:["当前版本 v",Me.version," → 更新后 v",_.preview.version,Me.source.commit&&s.jsxs(s.Fragment,{children:[s.jsx("br",{}),"当前提交 ",s.jsx("code",{children:Me.source.commit.slice(0,12)})," → 更新提交"," ",s.jsx("code",{children:_.source.commit.slice(0,12)})]})]}),s.jsxs("section",{children:[s.jsx("h3",{children:"安装来源"}),s.jsxs("dl",{children:[s.jsx("dt",{children:"仓库"}),s.jsx("dd",{children:_.source.url}),s.jsx("dt",{children:"分支 / 标签"}),s.jsx("dd",{children:_.source.ref}),s.jsx("dt",{children:"已锁定提交"}),s.jsx("dd",{children:s.jsx("code",{children:_.source.commit})}),s.jsx("dt",{children:"面板目录"}),s.jsx("dd",{children:_.source.subdir||"仓库根目录"}),s.jsx("dt",{children:"界面入口"}),s.jsx("dd",{children:s.jsx("code",{children:_.preview.entry})})]})]}),s.jsxs("section",{children:[s.jsx("h3",{children:"面板请求的权限"}),_.preview.permissions.length===0?s.jsx("p",{className:"panels-muted",children:"未申请宿主权限。"}):_.preview.permissions.map(V=>s.jsxs("div",{className:"panels-permission",children:[s.jsx("span",{children:My[V]??V}),s.jsx("small",{children:V})]},V))]}),s.jsxs("section",{children:[s.jsx("h3",{children:"随面板安装的工具与 Skills"}),_.preview.agent?.tools.length||_.preview.agent?.skills.length?s.jsxs("div",{className:"panels-badges",children:[_.preview.agent?.tools.map(V=>s.jsxs("span",{className:"panels-badge",title:V.description,children:[V.name," · ",V.readOnly?"只读":"可修改数据"]},V.name)),_.preview.agent?.skills.map(V=>s.jsxs("span",{className:"panels-badge",children:["Skill · ",V.split("/").at(-2)??V]},V))]}):s.jsx("p",{className:"panels-muted",children:"此面板没有额外的 Agent 工具或 Skills。"})]}),s.jsx(no,{value:_.compatibility}),_.preview.warnings.length>0&&s.jsx("div",{className:"panels-warning",children:s.jsx("ul",{children:_.preview.warnings.map(V=>s.jsx("li",{children:V},V))})}),s.jsxs("footer",{children:[!_.compatibility.supported&&s.jsxs("p",{className:"panels-muted",children:["可以安装到",u,",但当前 Web 工作台无法绑定或打开它。"]}),Q?s.jsx("p",{className:"panels-muted",children:"已绑定当前工作区,更新将保留绑定。"}):s.jsxs("label",{className:"panels-check",children:[s.jsx("input",{type:"checkbox",checked:G,disabled:!!J||!c?.hasProject||!_.compatibility.supported,onChange:V=>B(V.target.checked)}),"绑定当前工作区"]}),W?s.jsxs("div",{className:"panels-actions",children:[s.jsx("span",{className:"panels-muted",children:"安装内容或本地版本已变化,请重新审阅。"}),s.jsx("button",{disabled:!!J,onClick:M,children:"重新审阅"})]}):s.jsx("button",{className:"panels-primary",disabled:!!J,onClick:()=>{Ne()},children:_.kind==="update"?"确认更新":"确认安装"})]})]}),s.jsxs("section",{className:"panels-section","aria-labelledby":"installed-panels-heading",children:[s.jsxs("div",{className:"panels-heading",children:[s.jsxs("h2",{id:"installed-panels-heading",children:["已安装面板",c?` · ${c.panels.length+(c.issues?.length??0)}`:""]}),s.jsx("input",{type:"search","aria-label":"搜索已安装面板",placeholder:"搜索已安装面板",value:j,onChange:V=>R(V.target.value)})]}),!c&&s.jsx("p",{className:"panels-muted",children:le?"正在读取面板…":"暂时无法读取面板,请刷新重试。"}),c&&je.length===0&&!c.issues?.some(V=>V.id.toLowerCase().includes(K))&&s.jsxs("div",{className:"panels-empty",children:[s.jsx("strong",{children:c.panels.length||c.issues?.length?"没有匹配的面板":"还没有安装面板"}),s.jsx("p",{className:"panels-muted",children:c.panels.length||c.issues?.length?"试试其他名称或清除搜索。":"在下方粘贴 GitHub 仓库地址,或浏览官方面板仓库。"})]}),s.jsx("div",{className:"panels-grid",children:je.map(V=>s.jsxs("article",{className:"panels-card",children:[s.jsxs("div",{className:"panels-card-heading",children:[s.jsx("h3",{children:Vn(V.title)}),s.jsxs("span",{className:"panels-badge",children:["v",V.version]})]}),s.jsx("small",{children:V.id}),V.description&&s.jsx("p",{children:V.description}),s.jsx("div",{className:"panels-badges",children:s.jsx("span",{className:`panels-badge ${V.enabled&&V.compatibility.supported?"panels-badge-ready":""}`,children:V.globalDisabled?"已全局停用":V.bound?"已绑定当前工作区":"未绑定当前工作区"})}),s.jsxs("dl",{children:[s.jsx("dt",{children:"来源"}),s.jsx("dd",{children:V.source.label}),V.source.ref&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"分支 / 标签"}),s.jsx("dd",{children:V.source.ref})]})]}),s.jsx(no,{value:V.compatibility}),V.globalDisabled&&s.jsx("p",{className:"panels-muted",children:"请在宿主配置中启用此面板后使用。"}),s.jsxs("div",{className:"panels-actions",children:[s.jsx("button",{className:"panels-primary",disabled:yt||!V.enabled||!V.compatibility.supported,onClick:()=>ut.current.onOpen(V),children:"打开面板"}),s.jsx("button",{disabled:yt||!c?.hasProject||!V.bound&&(V.globalDisabled||!V.compatibility.supported),onClick:()=>{Te(V)},children:V.bound?"解除绑定":"绑定工作区"}),V.updatable&&s.jsx("button",{disabled:yt,onClick:()=>{ct(V)},children:"检查更新"}),c?.canRestorePackages&&V.bound&&s.jsx("button",{disabled:yt,onClick:()=>{dt(V)},children:"项目版本"}),s.jsx("button",{className:"panels-danger",disabled:yt,onClick:async()=>{!await Fe()||!ze.current||(O(V),D(void 0),se(void 0),U(void 0),ne(""),Y(""))},children:"卸载"})]})]},V.id))}),k&&s.jsxs("section",{className:"panels-confirm","aria-label":"确认卸载面板",children:[s.jsxs("p",{children:["卸载「",Vn(k.title),"」v",k.version,"?面板将从",u,"移除,其他工作区也将无法打开它。"]}),s.jsxs("div",{className:"panels-actions",children:[s.jsx("button",{disabled:!!J,onClick:()=>O(void 0),children:"取消卸载"}),we&&s.jsx("span",{className:"panels-muted",children:re?"面板已被其他设备修改,请查看最新版本后重新确认。":"此面板已被其他设备卸载。"}),we&&re&&s.jsx("button",{disabled:!!J||le,onClick:()=>{O(re),ne("")},children:"查看最新版本"}),s.jsx("button",{className:"panels-danger",disabled:!!J||le||we,onClick:()=>{Bt()},children:"确认卸载"})]})]})]}),s.jsxs("section",{className:"panels-import panels-section","aria-labelledby":"github-panels-heading",children:[s.jsxs("div",{className:"panels-heading",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"github-panels-heading",children:"从 GitHub 安装"}),s.jsx("p",{children:"先读取仓库并选择面板,再查看安装内容和所需权限。"})]}),s.jsx("button",{disabled:yt,onClick:()=>{m(Dy),b(""),x(""),Tt({url:Dy})},children:"浏览官方仓库"})]}),s.jsxs("form",{onSubmit:V=>{V.preventDefault(),p.trim()&&Tt({url:p.trim(),...y.trim()?{ref:y.trim()}:{},...v.trim()?{subdir:v.trim()}:{}})},children:[s.jsxs("label",{children:["GitHub 仓库地址",s.jsx("input",{type:"url",placeholder:"https://github.com/owner/repository",value:p,required:!0,disabled:!!J||!!L,onChange:V=>{m(V.target.value),T(void 0)}})]}),s.jsxs("details",{children:[s.jsx("summary",{children:"指定分支或子目录"}),s.jsxs("div",{className:"panels-source-fields",children:[s.jsxs("label",{children:["分支 / 标签(可选)",s.jsx("input",{value:y,placeholder:"使用默认分支",disabled:!!J||!!L,onChange:V=>{b(V.target.value),T(void 0)}})]}),s.jsxs("label",{children:["子目录(可选)",s.jsx("input",{value:v,placeholder:"例如 apps/my-panel",disabled:!!J||!!L,onChange:V=>{x(V.target.value),T(void 0)}})]})]})]}),s.jsxs("div",{className:"panels-actions",children:[s.jsx("button",{type:"submit",disabled:yt||!p.trim(),children:"读取仓库"}),(p||y||v||C)&&s.jsx("button",{type:"button",disabled:!!J,onClick:()=>{ie(),D(void 0)},children:"清除"})]})]}),C&&s.jsxs("div",{className:"panels-candidates",children:[s.jsxs("h3",{children:["找到 ",C.panels.length," 个面板"]}),s.jsxs("p",{className:"panels-muted",children:[C.source.url," · ",C.source.ref," ·"," ",s.jsx("code",{children:C.source.commit.slice(0,12)})]}),C.panels.length===0&&s.jsx("p",{className:"panels-muted",children:"仓库中没有找到可安装的面板。请检查地址和子目录。"}),Ee.length>1&&s.jsxs("div",{className:"panels-actions panels-batch-start",children:[s.jsxs("button",{disabled:yt,onClick:()=>{xe(Ee)},children:["逐个审阅未安装面板(",Ee.length,")"]}),s.jsx("small",{children:"按顺序确认,可随时跳过或停止。"})]}),s.jsx("div",{className:"panels-grid",children:C.panels.map(V=>{const de=c?.panels.find(ke=>ke.id===V.id);return s.jsxs("article",{className:"panels-card",children:[s.jsxs("div",{className:"panels-card-heading",children:[s.jsx("h3",{children:Vn(V.title)}),s.jsxs("span",{className:"panels-badge",children:["v",V.version]})]}),V.description&&s.jsx("p",{children:V.description}),s.jsx("small",{children:V.subdir==="."?"仓库根目录":V.subdir}),s.jsx("div",{className:"panels-actions",children:s.jsx("button",{disabled:yt||!!(de&&!de.updatable),onClick:()=>de?void ct(de):void He(V.source),children:de?de.updatable?"已安装 · 检查更新":"已从其他来源安装":"审阅安装"})})]},`${V.id}:${V.subdir}`)})}),C.issues.length>0&&s.jsxs("div",{className:"panels-warning",children:[s.jsx("strong",{children:"部分目录无法作为面板安装"}),s.jsx("ul",{children:C.issues.map(V=>s.jsxs("li",{children:[V.subdir,":",V.error]},V.subdir))})]})]})]})]})}function OS(t){const i=t.projectId===void 0?Na():t.projectId,r=`/api/v1/panels/runtime/${encodeURIComponent(t.instanceId)}`,a=new Set,u=new Set;let d=!1,c=t.expiresAt,h=c-6e4,p,m=0,y=0,b=0,v,x;const j=(A,I)=>{const L=setTimeout(()=>{a.delete(L),d||A()},Math.max(0,Math.min(I,2147483647)));return a.add(L),L},R=A=>{A!==void 0&&(clearTimeout(A),a.delete(A))},C=()=>{if(!d){d=!0;for(const A of a)clearTimeout(A);a.clear();for(const A of u)A.abort();u.clear()}},T=A=>{d||(C(),t.onTerminal(A))},_=()=>T(new Error("面板连接已到期,请重新打开继续使用。")),D=A=>A instanceof Xe&&[401,403,410].includes(A.status),q=()=>{d||t.onStatus(m||y?"面板连接暂时中断,正在重试;当前内容会保留。":"")},se=async(A,I="GET")=>{const L=new AbortController;u.add(L);const P=j(()=>L.abort(),8e3);try{return await Ue(xt(`${r}${A}`,t.workspace,i),{method:I,...I==="POST"?{headers:{"Content-Type":"application/json"},body:"{}"}:{},signal:L.signal})}finally{R(P),u.delete(L)}},N=()=>{R(v),v=j(()=>{Date.now()>=c?_():N()},c-Date.now())},U=()=>{R(x),m<5&&(x=j(X,h-Date.now()))};function X(){if(!d){if(Date.now()>=c){_();return}p||m>=5||Date.now()<h||(p=(async()=>{try{const A=await se("/renew","POST");if(d)return;if(!A||typeof A!="object"||!("expiresAt"in A)||typeof A.expiresAt!="number"||!Number.isFinite(A.expiresAt)||A.expiresAt<=Date.now()+6e4)throw new Error("面板续期响应无效。");c=A.expiresAt,h=c-6e4,m=0,N(),q()}catch(A){if(d)return;if(D(A)){T(A);return}m++,h=Date.now()+Math.min(5e3*2**(m-1),3e4),q()}finally{p=void 0,d||U()}})())}}async function H(){try{const A=await se(`/events?after=${b}`);if(d)return;if(!A||typeof A!="object"||!("cursor"in A)||!("events"in A))throw new Error("面板事件响应无效。");if(!Number.isSafeInteger(A.cursor)||A.cursor<b||!Array.isArray(A.events)||A.events.length>2048)throw new Error("面板事件响应无效。");const I=[];let L=b;for(const P of A.events){if(!P||typeof P!="object"||!Number.isSafeInteger(P.id)||P.id<=L||P.id>A.cursor||typeof P.event!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,100}$/.test(P.event))throw new Error("面板事件响应无效。");L=P.id,I.push(P)}t.onEvents(I),b=A.cursor,y=0,q()}catch(A){if(d)return;if(D(A)){T(A);return}y++,q()}finally{d||j(()=>{H()},Math.min(1e3*2**y,5e3))}}return N(),U(),H(),{stop:C,refresh:X}}function LS(t){if(!Number.isInteger(t.maxDurationSeconds)||t.maxDurationSeconds<1||t.maxDurationSeconds>600||!Number.isInteger(t.maxBytes)||t.maxBytes<1||t.maxBytes>25*1024*1024)throw new Error("录音限制无效。");let i={phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"},r=0,a,u,d,c=[],h=0,p="",m=t.signal.aborted;const y=j=>{i={...i,...j},m||t.onChange({...i})},b=()=>{a?.getTracks().forEach(j=>j.stop()),a=void 0,d&&clearInterval(d),d=void 0},v=()=>{try{u?.state!=="inactive"&&u?.stop()}finally{b()}},x=()=>{if(!m){m=!0,r++,u&&(u.ondataavailable=null,u.onstop=null,u.onerror=null);try{v()}finally{b()}c=[],i={phase:"closed",elapsedSeconds:0,message:"录音已关闭。"},t.signal.removeEventListener("abort",x)}};return m?i={phase:"closed",elapsedSeconds:0,message:"录音授权已结束。"}:t.signal.addEventListener("abort",x,{once:!0}),{snapshot:()=>({...i}),async start(){if(m||t.signal.aborted)throw new Error("录音授权已结束。");if(["requesting","recording"].includes(i.phase))throw new Error("已有录音正在进行。");const j=++r,R=()=>!m&&j===r&&!t.signal.aborted;c=[],h=0,p="",y({phase:"requesting",elapsedSeconds:0,blob:void 0,message:"正在等待麦克风授权…"});try{const C=await(t.getStream?t.getStream():navigator.mediaDevices.getUserMedia({audio:!0,video:!1}));if(!R()){C.getTracks().forEach(q=>q.stop());return}a=C;const T=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(q=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(q));u=t.makeRecorder?t.makeRecorder(a):new MediaRecorder(a,{...T?{mimeType:T}:{},audioBitsPerSecond:128e3});const _=u;_.ondataavailable=q=>{!R()||!q.data.size||(c.push(q.data),h+=q.data.size,h>t.maxBytes&&(p="录音超过大小限制;可以下载备份,或重新录制较短的音频。",v()))},_.onerror=()=>{if(R()){p="录音设备发生错误;请检查麦克风后重新录制。";try{v()}catch{b()}y({phase:"error",message:p})}},_.onstop=()=>{if(!R())return;b();const q=new Blob(c,{type:_.mimeType.split(";")[0]||"audio/webm"});c=[],y({phase:q.size&&!p?"review":"error",blob:q.size?q:void 0,message:p||(q.size?"录音已停止。可以试听,再保存到当前项目。":"没有录到声音,请重新录制。")})};const D=Date.now();_.start(250),y({phase:"recording",message:"正在使用这台设备的麦克风录音。"}),d=setInterval(()=>{if(!R())return;const q=Math.floor((Date.now()-D)/1e3);y({elapsedSeconds:q}),q>=t.maxDurationSeconds&&v()},250)}catch(C){if(b(),!R())return;y({phase:"error",message:C instanceof Error&&["NotAllowedError","SecurityError"].includes(C.name)?"麦克风未获授权,请检查浏览器和系统的麦克风权限。":"无法启动录音,请确认安全连接、麦克风和浏览器录音支持。"})}},stop:v,close:x}}function ev(t){const i=new Blob([t.blob],{type:t.blob.type.split(";")[0].trim().toLowerCase()}),r=[],a=t.timing?.now??Date.now,u=t.timing?.sleep??((v,x)=>new Promise((j,R)=>{const C=()=>{clearTimeout(T),R(x.reason)},T=setTimeout(()=>{x.removeEventListener("abort",C),j()},v);x.addEventListener("abort",C,{once:!0}),x.aborted&&C()})),d=async()=>{const v=t.transferBudget;if(!(!v||!Number.isSafeInteger(v.rateWindowMs)||v.rateWindowMs<1||!Number.isSafeInteger(v.maxTransferCallsPerWindow)||v.maxTransferCallsPerWindow<1))for(;;){t.signal.throwIfAborted();const x=a();for(;r.length&&r[0]<=x-v.rateWindowMs;)r.shift();if(r.length<v.maxTransferCallsPerWindow){r.push(x);return}await u(Math.max(1,r[0]+v.rateWindowMs-x),t.signal)}};let c,h=!1,p;const m=()=>t.signal.throwIfAborted(),y=async(v,x)=>{m();const j=await t.call(v,x);return m(),j},b=v=>{const x=v;if(!x||typeof x.sessionId!="string"||!/^upload-[a-f0-9-]{36}$/.test(x.sessionId)||c&&c!==x.sessionId||x.mimeType!==i.type||!["uploading","finished"].includes(String(x.state))||!Number.isSafeInteger(x.receivedBytes)||Number(x.receivedBytes)<0||Number(x.receivedBytes)>i.size||!Number.isSafeInteger(x.nextSequence)||Number(x.nextSequence)<0||!Number.isSafeInteger(x.maxChunkBytes)||Number(x.maxChunkBytes)<1||Number(x.maxChunkBytes)>32768)throw new Error("文件上传状态无效,请保留本机备份后重新打开面板。");return x};return{async save(){if(m(),h)throw new Error("文件正在保存,请稍候。");if(!i.size||i.size>t.maxBytes||!t.mimeTypes.includes(i.type))throw new Error("文件格式或大小无效。");h=!0;try{if(!p){const j=await i.arrayBuffer();m(),p=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",j)),R=>R.toString(16).padStart(2,"0")).join(""),m()}let v=b(c?await y("resources.upload.get",{sessionId:c}):await y("resources.upload.begin",{name:t.name,mimeType:i.type,expectedBytes:i.size,expectedSha256:p}));for(c=v.sessionId,t.onProgress(v.receivedBytes);v.receivedBytes<i.size;){if(v.state!=="uploading")throw new Error("文件上传已结束,文件大小不匹配。");const j=v.receivedBytes,R=new Uint8Array(await i.slice(j,j+v.maxChunkBytes).arrayBuffer());m(),await d(),m();const C=b(await y("resources.upload.write",{sessionId:c,sequence:v.nextSequence,offset:j,dataBase64:btoa(String.fromCharCode(...R))}));if(C.receivedBytes!==j+R.length||C.nextSequence!==v.nextSequence+1)throw new Error("文件上传进度不匹配,请重试保存以核对服务端状态。");v=C,t.onProgress(v.receivedBytes)}const x=await y("resources.upload.finish",{sessionId:c});if(!x?.asset||x.asset.id!==`asset-${p}`||x.asset.bytes!==i.size||x.asset.mimeType!==i.type)throw new Error("文件保存回执不匹配,请保留本机备份并重试。");return x}finally{h=!1}}}}function BS(t){return ev({...t,maxBytes:25*1024*1024,mimeTypes:["audio/webm","audio/mp4","audio/ogg","audio/wav"]})}function US({request:t}){const[i,r]=S.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"}),[a,u]=S.useState(""),[d,c]=S.useState(!1),[h,p]=S.useState(0),[m,y]=S.useState(""),b=S.useRef(null),v=S.useRef(void 0),x=S.useRef(void 0),j=S.useRef(void 0);S.useEffect(()=>{const T=new AbortController;j.current=T;const _=AbortSignal.any([t.signal,T.signal]);return v.current=LS({...t,signal:_,onChange:r}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{T.abort(),v.current?.close(),v.current=void 0,x.current=void 0}},[t]),S.useEffect(()=>{if(!i.blob){y("");return}const T=URL.createObjectURL(i.blob);return y(T),()=>URL.revokeObjectURL(T)},[i.blob]);const R=i.blob?.type==="audio/mp4"?"m4a":i.blob?.type==="audio/ogg"?"ogg":"webm",C=async()=>{const T=i.blob,_=j.current;if(!T||!_||d||i.phase!=="review")return;const D=AbortSignal.any([t.signal,_.signal]);c(!0),u("");try{x.current?.blob!==T&&(x.current={blob:T,transfer:BS({blob:T,name:`recording.${R}`,signal:D,call:(se,N)=>t.call(se,N,D),onProgress:p})});const q=await x.current.transfer.save();D.throwIfAborted(),t.finish(q)}catch(q){D.aborted||u(`${q instanceof Error?q.message:"保存失败。"} 录音仍保留在本页,可重试保存或下载备份。`)}finally{D.aborted||c(!1)}};return s.jsxs("section",{className:"panel-host-audio panel-host-preview","aria-label":"录音",tabIndex:-1,ref:b,children:[s.jsxs("header",{children:[s.jsx("h2",{children:"录音并保存到当前项目"}),s.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录音"})]}),s.jsxs("p",{children:["使用当前设备的麦克风;最长 ",t.maxDurationSeconds," ","秒。停止后可试听,点击保存才会上传到当前项目。关闭面板会丢弃未保存录音。"]}),s.jsxs("p",{role:"status",children:[i.message," ",i.elapsedSeconds>0&&`${i.elapsedSeconds} 秒`]}),m&&s.jsx("audio",{controls:!0,src:m}),a&&s.jsx("p",{role:"alert",children:a}),d&&s.jsxs("p",{role:"status",children:["正在保存录音:",Math.round(h/(i.blob?.size||1)*100),"%"]}),s.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(i.phase)&&!i.blob&&s.jsx("button",{onClick:()=>{u(""),v.current?.start().catch(T=>u(String(T)))},children:"开始录音"}),i.phase==="recording"&&s.jsx("button",{onClick:()=>v.current?.stop(),children:"停止录音"}),i.phase==="review"&&s.jsx("button",{disabled:d,className:"panel-host-primary",onClick:()=>{C()},children:d?"正在保存…":"保存到当前项目"}),m&&s.jsx("button",{disabled:d,onClick:()=>{u(""),x.current=void 0,v.current?.start().catch(T=>u(String(T)))},children:"丢弃并重新录制"}),m&&s.jsx("a",{href:m,download:`recording.${R}`,children:"下载本机备份"})]})]})}const yl=Object.freeze({maxDurationSeconds:1200,maxBytes:200*1024*1024,defaultDurationSeconds:300,defaultBytes:64*1024*1024});function tv(t){const i=t;if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).some(u=>!["source","microphone","systemAudio","maxDurationSeconds","maxBytes"].includes(u))||i.source!=="camera"&&i.source!=="screen"||i.microphone!==void 0&&typeof i.microphone!="boolean"||i.systemAudio!==void 0&&typeof i.systemAudio!="boolean"||i.source!=="screen"&&i.systemAudio===!0)throw new Error("视频录制请求无效。");const r=i.maxDurationSeconds??yl.defaultDurationSeconds,a=i.maxBytes??yl.defaultBytes;if(!Number.isSafeInteger(r)||Number(r)<1||Number(r)>yl.maxDurationSeconds||!Number.isSafeInteger(a)||Number(a)<1||Number(a)>yl.maxBytes)throw new Error("视频录制限制无效。");return{source:i.source,microphone:i.microphone!==!1,systemAudio:i.systemAudio===!0,maxDurationSeconds:Number(r),maxBytes:Number(a)}}const IS=["video/webm;codecs=vp8,opus","video/webm;codecs=vp9,opus","video/webm","video/mp4"];function nv(){try{return IS.find(t=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(t))}catch{return}}function kd(){const t=typeof navigator>"u"?void 0:navigator.mediaDevices,i=typeof window<"u"&&window.isSecureContext===!0&&!!nv(),r=i&&typeof t?.getUserMedia=="function",a=i&&typeof t?.getDisplayMedia=="function";return{camera:r,screen:a,microphone:r,systemAudio:a,maxDurationSeconds:yl.maxDurationSeconds,maxBytes:yl.maxBytes}}function qS(t){const i=tv({source:t.source,microphone:t.microphone,systemAudio:t.systemAudio,maxDurationSeconds:t.maxDurationSeconds,maxBytes:t.maxBytes});let r={phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:i.source,microphone:!1,systemAudio:!1}},a=0,u=t.signal.aborted,d,c,h,p=[],m=0,y="";const b=new Set,v=C=>{r={...r,...C},u||t.onChange({...r})},x=()=>{h&&clearInterval(h),h=void 0;for(const C of new Set([...b].flatMap(T=>T.getTracks())))C.onended=null,C.stop();b.clear(),c&&c.state!=="closed"&&c.close().catch(()=>{}),c=void 0},j=()=>{try{d?.state!=="inactive"&&d?.stop()}finally{x()}},R=()=>{if(!u){u=!0,a++,d&&(d.ondataavailable=null,d.onstop=null,d.onerror=null);try{j()}finally{x()}p=[],r={...r,phase:"closed",stream:void 0,blob:void 0},t.signal.removeEventListener("abort",R)}};return u?r.phase="closed":t.signal.addEventListener("abort",R,{once:!0}),{snapshot:()=>({...r}),async start(){if(u||t.signal.aborted)throw new Error("录制授权已结束。");if(["requesting","recording"].includes(r.phase))throw new Error("已有录制正在进行。");const C=++a,T=()=>!u&&a===C&&!t.signal.aborted,_=D=>{if(!T())throw D.getTracks().forEach(q=>q.stop()),new Error("录制授权已结束。");b.add(D);for(const q of D.getTracks()){if(q.readyState==="ended")throw new Error("所选采集来源已经停止,请重新连接。");q.onended=()=>{T()&&(r.phase==="recording"?j():(a++,x(),v({phase:"error",stream:void 0,message:"采集来源已停止,请重新连接。"})))}}return D};x(),p=[],m=0,y="",v({phase:"requesting",elapsedSeconds:0,stream:void 0,blob:void 0,message:"正在等待设备授权…"});try{const D=t.devices??navigator.mediaDevices;if(!D)throw new Error("录制需要安全连接和浏览器设备支持。");const q=_(await(i.source==="screen"?D.getDisplayMedia({video:!0,audio:i.systemAudio}):D.getUserMedia({video:!0,audio:i.microphone})));if(!q.getVideoTracks().length)throw new Error("没有获得可录制的画面。");const se=i.source==="screen"&&i.microphone?_(await D.getUserMedia({audio:!0,video:!1})):void 0,N=i.microphone?(i.source==="camera"?q:se)?.getAudioTracks()??[]:[];if(i.microphone&&!N.length)throw new Error("没有获得麦克风音轨。");const U=i.source==="screen"&&i.systemAudio?q.getAudioTracks():[];let X=_(new MediaStream([...q.getVideoTracks(),...N,...U]));if(N.length&&i.source==="screen")if(U.length){c=t.makeAudioContext?t.makeAudioContext():new AudioContext;const L=c,P=L.createMediaStreamDestination();_(P.stream);for(const ee of[N,U])L.createMediaStreamSource(new MediaStream(ee)).connect(P);let W;try{await Promise.race([L.resume(),new Promise((ee,G)=>{W=setTimeout(()=>G(new Error("声音混合未能启动,请重新录制。")),2e3)})])}finally{W&&clearTimeout(W)}t.signal.throwIfAborted(),X=_(new MediaStream([...q.getVideoTracks(),...P.stream.getAudioTracks()]))}else X=_(new MediaStream([...q.getVideoTracks(),...N]));if(!T()){x();return}const H=nv();if(!H)throw new Error("此浏览器不支持视频录制编码。");d=t.makeRecorder?t.makeRecorder(X,H):new MediaRecorder(X,{mimeType:H});const A=d;A.ondataavailable=L=>{!T()||!L.data.size||(p.push(L.data),m+=L.data.size,m>i.maxBytes&&(y="录制超过大小限制;可以下载备份或重新录制较短的视频。",j()))},A.onerror=()=>{if(T()){y="录制设备或编码器发生错误,请保留备份后重试。";try{j()}catch{x()}v({phase:"error",stream:void 0,message:y})}},A.onstop=()=>{if(!T())return;x();const L=new Blob(p,{type:A.mimeType.split(";")[0]||H.split(";")[0]});p=[],v({phase:L.size&&!y?"review":"error",stream:void 0,blob:L.size?L:void 0,message:y||(L.size?"录制已停止。可以预览,再保存到当前项目。":"没有录到内容,请重新录制。")})};const I=Date.now();A.start(250),v({phase:"recording",stream:X,capture:{source:i.source,microphone:N.length>0,systemAudio:U.length>0},message:"正在使用这台设备录制;停止后可以预览和保存。"}),h=setInterval(()=>{if(!T())return;const L=Math.floor((Date.now()-I)/1e3);v({elapsedSeconds:L}),L>=i.maxDurationSeconds&&j()},250)}catch(D){if(x(),!T())return;v({phase:"error",stream:void 0,message:D instanceof Error&&["NotAllowedError","SecurityError"].includes(D.name)?"设备未获授权或屏幕选择已取消,请检查浏览器和系统权限后重试。":D instanceof Error?D.message:"无法启动录制,请检查设备和浏览器支持。"})}},stop:j,close:R}}function HS({request:t}){const[i,r]=S.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:t.source,microphone:!1,systemAudio:!1}}),[a,u]=S.useState(""),[d,c]=S.useState(!1),[h,p]=S.useState(0),[m,y]=S.useState(""),b=S.useRef(null),v=S.useRef(null),x=S.useRef(void 0),j=S.useRef(void 0),R=S.useRef(void 0);S.useEffect(()=>{const D=new AbortController;R.current=D;const q=AbortSignal.any([t.signal,D.signal]);x.current=qS({...t,signal:q,onChange:r});const se=()=>{D.abort(),t.finish({cancelled:!0})};return window.addEventListener("pagehide",se,{once:!0}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{window.removeEventListener("pagehide",se),D.abort(),x.current?.close(),x.current=void 0,j.current=void 0}},[t]),S.useEffect(()=>{const D=v.current;if(D)return D.srcObject=i.stream??null,i.stream&&D.play().catch(()=>{}),()=>{D.srcObject=null}},[i.stream]),S.useEffect(()=>{if(!i.blob){y("");return}const D=URL.createObjectURL(i.blob);return y(D),()=>URL.revokeObjectURL(D)},[i.blob]);const C=i.blob?.type==="video/mp4"?"mp4":"webm",T=()=>{u(""),j.current=void 0,x.current?.start().catch(D=>u(String(D)))},_=async()=>{const D=i.blob,q=R.current;if(!D||!q||d||i.phase!=="review")return;const se=AbortSignal.any([t.signal,q.signal]);c(!0),u("");try{j.current?.blob!==D&&(j.current={blob:D,transfer:ev({blob:D,name:`recording.${C}`,signal:se,maxBytes:t.maxBytes,mimeTypes:["video/webm","video/mp4"],transferBudget:t.transferBudget,call:(U,X)=>t.call(U,X,se),onProgress:p})});const N=await j.current.transfer.save();se.throwIfAborted(),t.finish({...N,capture:i.capture})}catch(N){se.aborted||u(`${N instanceof Error?N.message:"保存失败。"} 视频仍保留在本页,可重试保存或下载备份。若已保存但未收到回复,重开面板后可从项目资源找回。`)}finally{se.aborted||c(!1)}};return s.jsxs("section",{className:"panel-host-video panel-host-preview","aria-label":"视频录制",tabIndex:-1,ref:b,children:[s.jsxs("header",{children:[s.jsxs("h2",{children:[t.source==="camera"?"摄像头录制":"屏幕录制","并保存到当前项目"]}),s.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录制"})]}),s.jsxs("p",{children:["使用当前设备;最长 ",t.maxDurationSeconds," 秒,最多"," ",Math.ceil(t.maxBytes/1024/1024)," MiB。",t.microphone?"使用麦克风。":"不使用麦克风。",t.systemAudio&&"屏幕声音取决于浏览器和你选择的共享来源,可能没有声音音轨。","停止后可预览,点击保存才会上传。关闭面板会丢弃未保存录制。"]}),s.jsxs("p",{role:"status",children:[i.message," ",i.elapsedSeconds>0&&`${i.elapsedSeconds} 秒`]}),i.stream&&s.jsx("video",{ref:v,muted:!0,playsInline:!0,"aria-label":"实时录制预览"}),m&&s.jsx("video",{controls:!0,playsInline:!0,src:m,"aria-label":"录制预览"}),i.phase==="recording"&&s.jsxs("p",{children:["麦克风:",i.capture.microphone?"已采集":"未采集",";屏幕声音:",i.capture.systemAudio?"已采集":"未采集"]}),a&&s.jsx("p",{role:"alert",children:a}),d&&s.jsxs("p",{role:"status",children:["正在保存视频:",Math.round(h/(i.blob?.size||1)*100),"%"]}),s.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(i.phase)&&!i.blob&&s.jsx("button",{onClick:T,children:"开始录制"}),i.phase==="recording"&&s.jsx("button",{onClick:()=>x.current?.stop(),children:"停止录制"}),i.phase==="review"&&s.jsx("button",{disabled:d,className:"panel-host-primary",onClick:()=>{_()},children:d?"正在保存…":"保存到当前项目"}),m&&s.jsx("button",{disabled:d,onClick:T,children:"丢弃并重新录制"}),m&&s.jsx("a",{href:m,download:`recording.${C}`,children:"下载本机备份"})]})]})}const Zi="/api/v1/panels/runtime";function Jt(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function GS(t){try{if(typeof t!="string"||t.length>2048)return;const i=new URL(t);if(i.protocol==="https:"&&!i.username&&!i.password)return i.href}catch{}}function VS(t,i){const r=`${Zi}/${i}/directory/`;return typeof t=="string"&&t.startsWith(r)&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.slice(r.length))}function $S(t,i,r){if(!Jt(t)||t.effect!=="resources.open"||!Jt(t.asset))return;const a=t.asset;if(typeof a.id!="string"||!/^(?:asset|external)-[a-f0-9]{64}$/.test(a.id)||a.id!==r||t.url!==`${Zi}/${i}/resources/${a.id}`||typeof a.name!="string"||!a.name||a.name.length>1024||typeof a.mimeType!="string"||!Number.isSafeInteger(a.bytes)||Number(a.bytes)<0)return;const u=["video/mp4","video/webm","video/ogg","video/quicktime"].includes(a.mimeType)?"video":["audio/mpeg","audio/mp4","audio/ogg","audio/wav","audio/webm","audio/flac","audio/aac"].includes(a.mimeType)?"audio":["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp"].includes(a.mimeType)?"image":"file";return{name:a.name,url:t.url,kind:u}}function YS(t){if(typeof t!="string"||!/^\/api\/v1\/panel-assets\/[A-Za-z0-9_-]{20,128}\/[A-Za-z0-9_%./-]+$/.test(t))return!1;try{return t.split("/").slice(5).every(i=>{const r=decodeURIComponent(i);return!!r&&!r.startsWith(".")&&!/[\\/:\u0000-\u001f\u007f]/.test(r)})}catch{return!1}}function FS(t){return Jt(t)?typeof t.instanceId=="string"&&/^[A-Za-z0-9_-]{20,128}$/.test(t.instanceId)&&YS(t.src)&&typeof t.expiresAt=="number"&&Number.isFinite(t.expiresAt)&&Jt(t.context)&&Array.isArray(t.limitations)&&t.limitations.every(i=>typeof i=="string"):!1}function PS({panel:t,sessionId:i,busy:r,onClose:a,onAuthLost:u,onDirtyChange:d,onSubmitPrompt:c}){const h=S.useRef(null),[p,m]=S.useState(),[y,b]=S.useState(!0),[v,x]=S.useState(""),[j,R]=S.useState(""),[C,T]=S.useState(),[_,D]=S.useState(),[q,se]=S.useState(!1),N=S.useRef(null);S.useEffect(()=>{_&&(N.current?.focus(),N.current?.scrollIntoView?.({block:"nearest"}))},[_]);const[U,X]=S.useState(""),[H,A]=S.useState(""),[I,L]=S.useState(),[P,W]=S.useState(),ee=S.useRef(void 0),[G,B]=S.useState(),[Q,fe]=S.useState(!1),[k,O]=S.useState(0),le=S.useRef({onClose:a,onAuthLost:u,onDirtyChange:d,onSubmitPrompt:c,busy:r});le.current={onClose:a,onAuthLost:u,onDirtyChange:d,onSubmitPrompt:c,busy:r};const E=S.useRef(!1),J=S.useRef(void 0),be=S.useRef(void 0),Z=S.useRef(null);return S.useEffect(()=>{le.current.onDirtyChange?.(!!I||Q||!!P||!!G),I&&(Z.current?.focus(),Z.current?.scrollIntoView?.({block:"nearest"}))},[I,Q,P,G]),S.useEffect(()=>{const ne=mo()??"",ge=Na(),Y={workspace:ne,grant:void 0},ve=new AbortController,De=new Set,ze=new Set;let _e=!1,qe;const ot=[],$e=[],At=new Set,ut=new Set;let Ie,Lt=!1,Ye=!1,rt=!1,Tt=!1;const He=()=>{const K=h.current?.contentWindow;if(!(_e||!Y.grant||!K||!Tt))for(const je of ot.splice(0))je.event==="tools.invoke"&&Jt(je.payload)&&typeof je.payload.requestId=="string"&&/^[A-Za-z0-9_-]{1,128}$/.test(je.payload.requestId)&&ut.add(je.payload.requestId),K.postMessage({type:"codeshell-panel:event",instanceId:Y.grant.instanceId,event:je.event,payload:je.payload},"*")},ct=()=>{_e||!rt||!Tt||!Y.grant||(Ie&&clearTimeout(Ie),b(!1),He())},M={loaded:()=>{rt=!0,ct()}};be.current=M,m(void 0),b(!0),x(""),R(""),T(void 0),D(void 0),se(!1),X(""),A(""),L(void 0),fe(!1),W(void 0),B(void 0);const ie=K=>{Lt||(Lt=!0,Ue(xt(`${Zi}/${encodeURIComponent(K.instanceId)}`,ne,ge),{method:"DELETE",keepalive:!0}).catch(()=>{}))},ye=K=>{_e||(K instanceof Xe&&K.status===401&&!E.current&&(E.current=!0,le.current.onAuthLost()),x(K instanceof Error?K.message:"面板连接失败,请重新打开。"))},xe=K=>{if(_e||!Y.grant)return;const je=Y.grant;Y.grant=void 0,qe?.stop(),J.current?.cancel(),$e.length=0,ot.length=0,ie(je);for(const Ee of De)Ee.abort();Ie&&clearTimeout(Ie),m(void 0),T(void 0),D(void 0),b(!1),fe(!1),X(""),ye(K)},Ne=K=>{const je=kd();return{...K,...Array.isArray(K.availableMethods)?{availableMethods:K.availableMethods.filter(Ee=>Ee!=="resources.recordVideo"||je.camera||je.screen)}:{},...typeof K.sessionId=="string"?{busy:le.current.busy}:{}}},Te=(K,je,Ee,re,we)=>{_e||!Y.grant||K!==h.current?.contentWindow||K.postMessage({type:"codeshell-panel:response",instanceId:Y.grant.instanceId,requestId:je,...re?{error:re,...we?.code?{code:we.code}:{},...we?.retryAfterMs!==void 0?{retryAfterMs:we.retryAfterMs}:{}}:{result:Ee}},"*")},Fe=()=>{if(_e||!Y.grant||J.current||ee.current||Ye)return;const K=$e.shift();if(!K)return;if(K.expiresAt<=Date.now()){Fe();return}let je=!1;const Ee={effect:K,cancel:()=>{J.current===Ee&&(clearTimeout(re),J.current=void 0,_e||(L(void 0),A(""),fe(!1)))},finish:we=>{if(_e||!Y.grant||J.current!==Ee||je)return;je=!0,fe(!0),A("");const Me=new AbortController;De.add(Me);const Ce=setTimeout(()=>Me.abort(),8e3);Ue(xt(`${Zi}/${Y.grant.instanceId}/confirm`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:K.requestId,allowed:we}),signal:Me.signal}).then(V=>{if(!(_e||J.current!==Ee)){if(typeof V.allowed!="boolean")throw new Error("确认响应无效。");we&&V.allowed===!1&&R("此确认已超时或被取消,操作未获准执行,请在面板中重新发起。"),!we&&V.allowed===!0&&R("该操作此前已获准执行,请在面板中查看进度或停止。"),Ee.cancel(),Fe()}}).catch(V=>{if(!(_e||J.current!==Ee)){if(V instanceof Xe&&[401,403,410].includes(V.status)){xe(V);return}if(V instanceof Xe&&V.status===409){Ee.cancel(),R("面板操作确认已失效,请在面板中重新发起。"),Fe();return}A("暂未收到确认结果。可以重试本次确认,或取消尚未执行的请求。")}}).finally(()=>{clearTimeout(Ce),De.delete(Me),je=!1,!_e&&J.current===Ee&&fe(!1)})}},re=setTimeout(()=>{Ee.cancel(),!_e&&Y.grant&&(R("面板操作确认已超时,请在面板中重新发起。"),Fe())},K.expiresAt-Date.now());J.current=Ee,L(Ee),A("")},mt=K=>{for(const je of K){if(je.event!=="host.confirm"){ot.push(je);continue}const Ee=je.payload;if(!Jt(Ee)||typeof Ee.requestId!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(Ee.requestId)||typeof Ee.title!="string"||Ee.title.length>500||typeof Ee.body!="string"||Ee.body.length>3e4)throw new Error("面板操作确认格式无效。");At.has(Ee.requestId)||(At.add(Ee.requestId),$e.push({effect:"host.confirm",requestId:Ee.requestId,title:Ee.title,body:Ee.body,expiresAt:Date.now()+5e4}))}if(ot.length>2048||$e.length>32){xe(new Error("面板状态积压过多,请重新打开面板。"));return}Fe(),He()},dt=K=>new Promise(je=>{if(J.current||ee.current||Ye){je(!1);return}const Ee={effect:K,finish:we=>{J.current===Ee&&(clearTimeout(re),J.current=void 0,_e||L(void 0),je(we),queueMicrotask(Fe))},cancel:()=>Ee.finish(!1)},re=setTimeout(()=>Ee.finish(!1),55e3);J.current=Ee,L(Ee)}),ft=async K=>{const je=h.current?.contentWindow,Ee=Y.grant,re=K.data;if(_e||!je||K.source!==je||K.origin!=="null"||!Ee||!Jt(re)||re.instanceId!==Ee.instanceId)return;if(re.type==="codeshell-panel:ready"){Tt=!0,ct();return}if(re.type==="codeshell-panel:tool-result"){if(typeof re.requestId!="string"||!ut.has(re.requestId)||De.size>=32)return;let de;try{if(de=JSON.stringify({requestId:re.requestId,...typeof re.error=="string"?{error:re.error}:{result:re.result}}),new TextEncoder().encode(de).length>512*1024)return}catch{return}ut.delete(re.requestId);const ke=new AbortController;De.add(ke);const Ke=setTimeout(()=>ke.abort(),8e3);try{await Ue(xt(`${Zi}/${Ee.instanceId}/tool-results`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:de,signal:ke.signal})}catch(at){!_e&&Y.grant&&(at instanceof Xe&&[401,410].includes(at.status)?xe(at):R("面板工具结果未能送达,请在对话中重新发起操作。"))}finally{clearTimeout(Ke),De.delete(ke)}return}if(re.type!=="codeshell-panel:call"||typeof re.requestId!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(re.requestId))return;const we=re.requestId;if(ze.has(we)){Te(je,we,void 0,"此请求已经处理,请重新发起。");return}if(ze.size>=8192||De.size>=32){Te(je,we,void 0,"面板请求过于频繁,请稍后重试。");return}if(ze.add(we),typeof re.method!="string"||!/^[A-Za-z][A-Za-z0-9.]{0,63}$/.test(re.method)){Te(je,we,void 0,"面板方法无效。");return}let Me;try{if(Me=JSON.stringify({method:re.method,params:re.params}),new TextEncoder().encode(Me).length>3*1024*1024)throw new Error("too large")}catch{Te(je,we,void 0,"面板请求内容过大或格式无效。");return}const Ce=new AbortController;let V=!1;De.add(Ce);try{const de=await Ue(xt(`${Zi}/${Ee.instanceId}/call`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:Me,signal:Ce.signal});if(_e||Ce.signal.aborted)return;if(re.method==="context.get"&&(Tt=!0,ct()),re.method==="external.open"){const ke=Jt(de)&&de.effect===re.method?GS(de.url):void 0;if(!ke)throw new Error("面板返回的外部链接无效。");if(!await dt({effect:"external.open",url:ke}))throw new Error("你取消了打开链接,或确认已超时。");Te(je,we,{opened:!0})}else if(re.method==="agent.submitPrompt"){if(!Jt(de)||de.effect!==re.method||typeof de.prompt!="string"||!de.prompt.trim()||de.prompt.length>2e4||de.sessionId!==i)throw new Error("面板任务与当前对话不匹配,请重新打开面板。");if(!await dt({effect:"agent.submitPrompt",prompt:de.prompt,sessionId:i}))throw new Error("你取消了发送任务,或确认已超时。");if(_e||Ce.signal.aborted)return;V=!0,Ye=!0,fe(!0);const ke=await le.current.onSubmitPrompt({prompt:de.prompt,sessionId:i});if(_e||Ce.signal.aborted)return;R("面板任务已提交到当前对话,可切换到对话查看进度。"),Te(je,we,ke)}else if(re.method==="resources.recordVideo.capabilities"){if(!Jt(de)||de.effect!==re.method)throw new Error("视频录制能力响应无效。");Te(je,we,kd())}else if(re.method==="resources.recordAudio"||re.method==="resources.recordVideo"){const ke=re.method==="resources.recordVideo";if(!Jt(de)||de.effect!==re.method)throw new Error("录制请求无效。");const Ke=ke?tv(Object.fromEntries(Object.entries(de).filter(([Rt])=>Rt!=="effect"))):void 0;if(Ke){const Rt=kd();if(!Rt[Ke.source]||Ke.microphone&&!Rt.microphone)throw new Error("当前浏览器不支持所选视频录制方式,请检查安全连接和设备支持。")}if(!ke&&(!Jt(de)||de.effect!==re.method||!Number.isInteger(de.maxDurationSeconds)||Number(de.maxDurationSeconds)<1||Number(de.maxDurationSeconds)>600||!Number.isInteger(de.maxBytes)||Number(de.maxBytes)<1||Number(de.maxBytes)>25*1024*1024))throw new Error("录音请求无效。");if(ee.current||J.current||Ye)throw new Error("请先完成当前的录制或确认操作。");const at=await new Promise((Rt,kt)=>{let ni=!1;const Vt=(Nn,Ut)=>{ni||(ni=!0,clearTimeout(Ba),Ce.signal.removeEventListener("abort",Nr),ee.current===Wi&&(ee.current=void 0,_e||(W(void 0),B(void 0))),Ut?kt(Ut):Rt(Nn),Fe())},Nr=()=>Vt(void 0,new Error("录制已关闭或授权已结束。")),Ba=setTimeout(()=>Vt(void 0,new Error("录制操作已超时,请重新打开。")),25*6e4),Wi={signal:Ce.signal,maxDurationSeconds:Number(de.maxDurationSeconds),maxBytes:Number(de.maxBytes),...Ke?{...Ke,transferBudget:Jt(Ee.context.capabilities)&&Jt(Ee.context.capabilities.bridge)?Ee.context.capabilities.bridge:void 0}:{},call:async(Nn,Ut,Wt)=>{const Yn=Wt?AbortSignal.any([Ce.signal,Wt]):Ce.signal;if(Yn.throwIfAborted(),_e||Y.grant!==Ee)throw new Error("当前项目授权已结束。");try{const Fn=await Ue(xt(`${Zi}/${Ee.instanceId}/call`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:Nn,params:Ut}),signal:Yn});if(Yn.throwIfAborted(),_e||Y.grant!==Ee)throw new Error("当前项目授权已结束。");return Fn}catch(Fn){throw Fn instanceof Xe&&[401,403,410].includes(Fn.status)&&xe(Fn),Fn}},finish:Vt};ee.current=Wi,Ce.signal.addEventListener("abort",Nr,{once:!0}),ke?B(Wi):W(Wi)});Te(je,we,at)}else if(re.method==="resources.open"){D(void 0),se(!1);const ke=$S(de,Ee.instanceId,Jt(re.params)?re.params.assetId:void 0);if(!ke)throw new Error("面板文件预览链接无效,请重新打开文件。");D({...ke,url:xt(ke.url,ne,ge),downloadUrl:xt(`${ke.url}?download=1`,ne,ge)}),Te(je,we,{opened:!0})}else if(re.method==="filesystem.openDirectory"){if(T(void 0),!Jt(de)||de.effect!==re.method||typeof de.path!="string")throw new Error("面板目录信息无效。");if(de.url!==void 0&&!VS(de.url,Ee.instanceId))throw new Error("面板目录链接无效,请重新打开目录。");T({path:de.path,...typeof de.url=="string"?{url:xt(de.url,ne,ge)}:{}}),Te(je,we,{opened:!1,path:de.path})}else if(re.method==="notifications.send"){if(!Jt(de)||de.effect!==re.method||typeof de.title!="string"||de.title.length>160||typeof de.body!="string"||de.body.length>2e3)throw new Error("面板通知格式无效。");R(`${de.title}${de.body?`:${de.body}`:""}`),Te(je,we,{sent:!0})}else Te(je,we,re.method==="context.get"&&Jt(de)?Ne(de):de)}catch(de){!_e&&!Ce.signal.aborted&&(de instanceof Xe&&[401,410].includes(de.status)&&xe(de),(re.method==="agent.submitPrompt"||re.method==="external.open")&&R(de instanceof Error?de.message:"面板操作未完成。"),Te(je,we,void 0,de instanceof Error?de.message:"面板请求失败。",de instanceof Xe?{code:de.code,retryAfterMs:de.retryAfterMs}:void 0))}finally{De.delete(Ce),V&&(Ye=!1,_e||fe(!1),Fe())}},tt=K=>{ft(K)};window.addEventListener("message",tt);const Bt=()=>qe?.refresh(),yt=()=>{document.visibilityState==="visible"&&Bt()};return window.addEventListener("focus",Bt),window.addEventListener("online",Bt),document.addEventListener("visibilitychange",yt),Ue(xt(`${Zi}/prepare`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:t.id,revision:t.revision,...i?{sessionId:i}:{},theme:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",locale:"zh-CN"}),signal:ve.signal}).then(K=>{if(!FS(K))throw new Error("面板启动信息无效,请刷新面板列表后重试。");if(_e||ve.signal.aborted){ie(K);return}if(K.expiresAt<=Date.now())throw ie(K),new Error("面板授权已过期,请重新打开。");Y.grant=K,m({...K,context:Ne(K.context),src:xt(K.src,ne,ge)}),Ie=setTimeout(()=>{xe(new Error("面板未能完成加载,请重新打开。若仍无法加载,可检查面板文件或使用桌面客户端。"))},45e3),qe=OS({instanceId:K.instanceId,expiresAt:K.expiresAt,workspace:ne,projectId:ge,onEvents:mt,onTerminal:xe,onStatus:X})}).catch(K=>{!_e&&!ve.signal.aborted&&(b(!1),ye(K))}),()=>{_e=!0,J.current?.cancel(),window.removeEventListener("message",tt),window.removeEventListener("focus",Bt),window.removeEventListener("online",Bt),document.removeEventListener("visibilitychange",yt),qe?.stop(),ve.abort();for(const K of De)K.abort();Ie&&clearTimeout(Ie),Y.grant&&ie(Y.grant),le.current.onDirtyChange?.(!1),be.current===M&&(be.current=void 0)}},[t.id,t.revision,i,k]),S.useEffect(()=>{!p||!h.current?.contentWindow||h.current.contentWindow.postMessage({type:"codeshell-panel:event",instanceId:p.instanceId,event:"context.changed",payload:{...p.context,...typeof p.context.sessionId=="string"?{busy:r}:{}}},"*")},[r,p]),s.jsxs("section",{className:"panel-host",children:[s.jsxs("header",{className:"panel-host-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{children:t.title["zh-CN"]||t.title.default}),s.jsxs("p",{children:["v",t.version," · 运行于当前工作区"]})]}),s.jsx("button",{onClick:a,children:"返回面板"})]}),(p?.limitations??t.compatibility.reasons).length>0&&s.jsxs("details",{className:"panel-host-limitations",open:!0,children:[s.jsx("summary",{children:"部分功能可用"}),s.jsx("p",{children:"面板界面可以使用;以下功能尚未接入网页,使用时会显示具体限制。"}),s.jsx("ul",{children:(p?.limitations??t.compatibility.reasons).map(ne=>s.jsx("li",{children:ne},ne))})]}),j&&s.jsx("p",{className:"panel-host-notice",role:"status",children:j}),C&&s.jsxs("div",{className:"panel-host-notice panel-host-directory",role:"status",children:[s.jsxs("p",{children:["文件保存在服务器目录:",C.path]}),C.url&&s.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",children:"查看并下载文件"})]}),_&&s.jsxs("section",{className:"panel-host-preview","aria-label":"文件预览",tabIndex:-1,ref:N,children:[s.jsxs("header",{children:[s.jsx("h2",{children:_.name}),s.jsx("button",{onClick:()=>D(void 0),children:"关闭预览"})]}),!q&&_.kind==="video"&&s.jsx("video",{src:_.url,controls:!0,playsInline:!0,preload:"metadata",onError:()=>se(!0)},_.url),!q&&_.kind==="audio"&&s.jsx("audio",{src:_.url,controls:!0,preload:"metadata",onError:()=>se(!0)},_.url),!q&&_.kind==="image"&&s.jsx("img",{src:_.url,alt:_.name,onError:()=>se(!0)},_.url),(q||_.kind==="file")&&s.jsx("p",{role:"status",children:"当前浏览器无法预览此文件。可以保存后打开;若保存失败,请重新打开面板检查访问权限。"}),s.jsx("a",{href:_.downloadUrl,download:_.name,children:"保存到此设备"})]}),U&&s.jsx("p",{className:"panel-host-notice",role:"status",children:U}),v&&s.jsxs("div",{className:"panel-host-error",role:"alert",children:[s.jsx("p",{children:v}),s.jsx("button",{disabled:y,onClick:()=>O(ne=>ne+1),children:"重新打开面板"})]}),y&&s.jsx("p",{className:"panel-host-loading",role:"status",children:"正在打开面板…"}),P&&s.jsx(US,{request:P}),G&&s.jsx(HS,{request:G}),I&&s.jsxs("section",{className:"panel-host-confirm",ref:Z,tabIndex:-1,onKeyDown:ne=>{ne.key==="Escape"&&!Q&&(ne.preventDefault(),I.finish(!1))},"aria-label":I.effect.effect==="external.open"?"确认打开外部链接":I.effect.effect==="host.confirm"?"确认面板操作":"确认发送面板任务",children:[s.jsx("h2",{children:I.effect.effect==="external.open"?"面板请求打开网页":I.effect.effect==="host.confirm"?I.effect.title:"面板请求向当前对话发送任务"}),I.effect.effect==="external.open"?s.jsx("p",{className:"panel-host-url",children:I.effect.url}):I.effect.effect==="host.confirm"?s.jsx("pre",{children:I.effect.body}):s.jsx("pre",{children:I.effect.prompt}),H&&s.jsx("p",{role:"alert",children:H}),s.jsxs("div",{className:"panel-host-actions",children:[s.jsx("button",{disabled:Q,onClick:()=>I.finish(!1),children:"取消"}),I.effect.effect==="external.open"?s.jsx("a",{href:I.effect.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>I.finish(!0),children:"确认打开网页"}):s.jsx("button",{className:"panel-host-primary",disabled:Q,onClick:()=>I.finish(!0),children:Q?"正在确认…":I.effect.effect==="host.confirm"?"确认执行":"确认发送任务"})]})]}),p&&s.jsx("iframe",{ref:h,src:p.src,title:`${t.title["zh-CN"]||t.title.default}面板`,sandbox:"allow-scripts allow-downloads",referrerPolicy:"no-referrer",inert:!!I||Q||!!P||!!G,onLoad:()=>be.current?.loaded(),allow:"camera 'none'; microphone 'none'; geolocation 'none'; display-capture 'none'; clipboard-read 'none'; clipboard-write 'none'",className:"panel-host-frame"})]})}function QS(t,i){const r={};return(t[t.length-1]===""?[...t,""]:t).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const XS=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,KS=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ZS={};function Oy(t,i){return(ZS.jsx?KS:XS).test(t)}const JS=/[ \t\n\f\r]/g;function WS(t){return typeof t=="object"?t.type==="text"?Ly(t.value):!1:Ly(t)}function Ly(t){return t.replace(JS,"")===""}class Da{constructor(i,r,a){this.normal=r,this.property=i,a&&(this.space=a)}}Da.prototype.normal={};Da.prototype.property={};Da.prototype.space=void 0;function iv(t,i){const r={},a={};for(const u of t)Object.assign(r,u.property),Object.assign(a,u.normal);return new Da(r,a,i)}function Xd(t){return t.toLowerCase()}class yn{constructor(i,r){this.attribute=r,this.property=i}}yn.prototype.attribute="";yn.prototype.booleanish=!1;yn.prototype.boolean=!1;yn.prototype.commaOrSpaceSeparated=!1;yn.prototype.commaSeparated=!1;yn.prototype.defined=!1;yn.prototype.mustUseProperty=!1;yn.prototype.number=!1;yn.prototype.overloadedBoolean=!1;yn.prototype.property="";yn.prototype.spaceSeparated=!1;yn.prototype.space=void 0;let ej=0;const Ge=Er(),Qt=Er(),Kd=Er(),Se=Er(),Et=Er(),xr=Er(),Cn=Er();function Er(){return 2**++ej}const Zd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ge,booleanish:Qt,commaOrSpaceSeparated:Cn,commaSeparated:xr,number:Se,overloadedBoolean:Kd,spaceSeparated:Et},Symbol.toStringTag,{value:"Module"})),Cd=Object.keys(Zd);class kf extends yn{constructor(i,r,a,u){let d=-1;if(super(i,r),By(this,"space",u),typeof a=="number")for(;++d<Cd.length;){const c=Cd[d];By(this,Cd[d],(a&Zd[c])===Zd[c])}}}kf.prototype.defined=!0;function By(t,i,r){r&&(t[i]=r)}function Sl(t){const i={},r={};for(const[a,u]of Object.entries(t.properties)){const d=new kf(a,t.transform(t.attributes||{},a),u,t.space);t.mustUseProperty&&t.mustUseProperty.includes(a)&&(d.mustUseProperty=!0),i[a]=d,r[Xd(a)]=a,r[Xd(d.attribute)]=a}return new Da(i,r,t.space)}const rv=Sl({properties:{ariaActiveDescendant:null,ariaAtomic:Qt,ariaAutoComplete:null,ariaBusy:Qt,ariaChecked:Qt,ariaColCount:Se,ariaColIndex:Se,ariaColSpan:Se,ariaControls:Et,ariaCurrent:null,ariaDescribedBy:Et,ariaDetails:null,ariaDisabled:Qt,ariaDropEffect:Et,ariaErrorMessage:null,ariaExpanded:Qt,ariaFlowTo:Et,ariaGrabbed:Qt,ariaHasPopup:null,ariaHidden:Qt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Et,ariaLevel:Se,ariaLive:null,ariaModal:Qt,ariaMultiLine:Qt,ariaMultiSelectable:Qt,ariaOrientation:null,ariaOwns:Et,ariaPlaceholder:null,ariaPosInSet:Se,ariaPressed:Qt,ariaReadOnly:Qt,ariaRelevant:null,ariaRequired:Qt,ariaRoleDescription:Et,ariaRowCount:Se,ariaRowIndex:Se,ariaRowSpan:Se,ariaSelected:Qt,ariaSetSize:Se,ariaSort:null,ariaValueMax:Se,ariaValueMin:Se,ariaValueNow:Se,ariaValueText:null,role:null},transform(t,i){return i==="role"?i:"aria-"+i.slice(4).toLowerCase()}});function lv(t,i){return i in t?t[i]:i}function av(t,i){return lv(t,i.toLowerCase())}const tj=Sl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:xr,acceptCharset:Et,accessKey:Et,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alpha:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:Et,autoFocus:Ge,autoPlay:Ge,blocking:Et,capture:null,charSet:null,checked:Ge,cite:null,className:Et,closedBy:null,colorSpace:null,cols:Se,colSpan:Se,command:null,commandFor:null,content:null,contentEditable:Qt,controls:Ge,controlsList:Et,coords:Se|xr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:Kd,draggable:Qt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:Et,height:Se,hidden:Kd,high:Se,href:null,hrefLang:null,htmlFor:Et,httpEquiv:Et,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:Et,itemRef:Et,itemScope:Ge,itemType:Et,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ge,low:Se,manifest:null,max:null,maxLength:Se,media:null,method:null,min:null,minLength:Se,multiple:Ge,muted:Ge,name:null,nonce:null,noModule:Ge,noValidate:Ge,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ge,optimum:Se,pattern:null,ping:Et,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:Et,required:Ge,reversed:Ge,rows:Se,rowSpan:Se,sandbox:Et,scope:null,scoped:Ge,seamless:Ge,selected:Ge,shadowRootClonable:Ge,shadowRootCustomElementRegistry:Ge,shadowRootDelegatesFocus:Ge,shadowRootMode:null,shadowRootSerializable:Ge,shape:null,size:Se,sizes:null,slot:null,span:Se,spellCheck:Qt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Se,step:null,style:null,tabIndex:Se,target:null,title:null,translate:null,type:null,typeMustMatch:Ge,useMap:null,value:Qt,width:Se,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Et,axis:null,background:null,bgColor:null,border:Se,borderColor:null,bottomMargin:Se,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ge,declare:Ge,event:null,face:null,frame:null,frameBorder:null,hSpace:Se,leftMargin:Se,link:null,longDesc:null,lowSrc:null,marginHeight:Se,marginWidth:Se,noResize:Ge,noHref:Ge,noShade:Ge,noWrap:Ge,object:null,profile:null,prompt:null,rev:null,rightMargin:Se,rules:null,scheme:null,scrolling:Qt,standby:null,summary:null,text:null,topMargin:Se,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Se,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ge,disablePictureInPicture:Ge,disableRemotePlayback:Ge,exportParts:xr,part:Et,prefix:null,property:null,results:Se,security:null,unselectable:null},space:"html",transform:av}),nj=Sl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Cn,accentHeight:Se,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Se,amplitude:Se,arabicForm:null,ascent:Se,attributeName:null,attributeType:null,azimuth:Se,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Se,by:null,calcMode:null,capHeight:Se,className:Et,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Se,diffuseConstant:Se,direction:null,display:null,dur:null,divisor:Se,dominantBaseline:null,download:Ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:Se,enableBackground:null,end:null,event:null,exponent:Se,externalResourcesRequired:null,fill:null,fillOpacity:Se,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:xr,g2:xr,glyphName:xr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Se,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Se,horizOriginX:Se,horizOriginY:Se,id:null,ideographic:Se,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Se,k:Se,k1:Se,k2:Se,k3:Se,k4:Se,kernelMatrix:Cn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Se,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Se,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Se,overlineThickness:Se,paintOrder:null,panose1:null,path:null,pathLength:Se,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Et,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Se,pointsAtY:Se,pointsAtZ:Se,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Cn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Cn,rev:Cn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Cn,requiredFeatures:Cn,requiredFonts:Cn,requiredFormats:Cn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Se,specularExponent:Se,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Se,strikethroughThickness:Se,string:null,stroke:null,strokeDashArray:Cn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Se,strokeOpacity:Se,strokeWidth:null,style:null,surfaceScale:Se,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Cn,tabIndex:Se,tableValues:null,target:null,targetX:Se,targetY:Se,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Cn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Se,underlineThickness:Se,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Se,values:null,vAlphabetic:Se,vMathematical:Se,vectorEffect:null,vHanging:Se,vIdeographic:Se,version:null,vertAdvY:Se,vertOriginX:Se,vertOriginY:Se,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Se,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:lv}),sv=Sl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,i){return"xlink:"+i.slice(5).toLowerCase()}}),ov=Sl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:av}),uv=Sl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,i){return"xml:"+i.slice(3).toLowerCase()}}),ij={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},rj=/[A-Z]/g,Uy=/-[a-z]/g,lj=/^data[-\w.:]+$/i;function aj(t,i){const r=Xd(i);let a=i,u=yn;if(r in t.normal)return t.property[t.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&lj.test(i)){if(i.charAt(4)==="-"){const d=i.slice(5).replace(Uy,oj);a="data"+d.charAt(0).toUpperCase()+d.slice(1)}else{const d=i.slice(4);if(!Uy.test(d)){let c=d.replace(rj,sj);c.charAt(0)!=="-"&&(c="-"+c),i="data"+c}}u=kf}return new u(a,i)}function sj(t){return"-"+t.toLowerCase()}function oj(t){return t.charAt(1).toUpperCase()}const uj=iv([rv,tj,sv,ov,uv],"html"),Cf=iv([rv,nj,sv,ov,uv],"svg");function cj(t){return t.join(" ").trim()}var hl={},Ed,Iy;function dj(){if(Iy)return Ed;Iy=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,r=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,u=/^:\s*/,d=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,h=/^\s+|\s+$/g,p=`
|
|
29
|
+
`,m="/",y="*",b="",v="comment",x="declaration";function j(C,T){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];T=T||{};var _=1,D=1;function q(W){var ee=W.match(i);ee&&(_+=ee.length);var G=W.lastIndexOf(p);D=~G?W.length-G:D+W.length}function se(){var W={line:_,column:D};return function(ee){return ee.position=new N(W),H(),ee}}function N(W){this.start=W,this.end={line:_,column:D},this.source=T.source}N.prototype.content=C;function U(W){var ee=new Error(T.source+":"+_+":"+D+": "+W);if(ee.reason=W,ee.filename=T.source,ee.line=_,ee.column=D,ee.source=C,!T.silent)throw ee}function X(W){var ee=W.exec(C);if(ee){var G=ee[0];return q(G),C=C.slice(G.length),ee}}function H(){X(r)}function A(W){var ee;for(W=W||[];ee=I();)ee!==!1&&W.push(ee);return W}function I(){var W=se();if(!(m!=C.charAt(0)||y!=C.charAt(1))){for(var ee=2;b!=C.charAt(ee)&&(y!=C.charAt(ee)||m!=C.charAt(ee+1));)++ee;if(ee+=2,b===C.charAt(ee-1))return U("End of comment missing");var G=C.slice(2,ee-2);return D+=2,q(G),C=C.slice(ee),D+=2,W({type:v,comment:G})}}function L(){var W=se(),ee=X(a);if(ee){if(I(),!X(u))return U("property missing ':'");var G=X(d),B=W({type:x,property:R(ee[0].replace(t,b)),value:G?R(G[0].replace(t,b)):b});return X(c),B}}function P(){var W=[];A(W);for(var ee;ee=L();)ee!==!1&&(W.push(ee),A(W));return W}return H(),P()}function R(C){return C?C.replace(h,b):b}return Ed=j,Ed}var qy;function fj(){if(qy)return hl;qy=1;var t=hl&&hl.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(hl,"__esModule",{value:!0}),hl.default=r;const i=t(dj());function r(a,u){let d=null;if(!a||typeof a!="string")return d;const c=(0,i.default)(a),h=typeof u=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:m,value:y}=p;h?u(m,y,p):y&&(d=d||{},d[m]=y)}),d}return hl}var va={},Hy;function hj(){if(Hy)return va;Hy=1,Object.defineProperty(va,"__esModule",{value:!0}),va.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,i=/-([a-z])/g,r=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,u=/^-(ms)-/,d=function(m){return!m||r.test(m)||t.test(m)},c=function(m,y){return y.toUpperCase()},h=function(m,y){return"".concat(y,"-")},p=function(m,y){return y===void 0&&(y={}),d(m)?m:(m=m.toLowerCase(),y.reactCompat?m=m.replace(u,h):m=m.replace(a,h),m.replace(i,c))};return va.camelCase=p,va}var xa,Gy;function pj(){if(Gy)return xa;Gy=1;var t=xa&&xa.__importDefault||function(u){return u&&u.__esModule?u:{default:u}},i=t(fj()),r=hj();function a(u,d){var c={};return!u||typeof u!="string"||(0,i.default)(u,function(h,p){h&&p&&(c[(0,r.camelCase)(h,d)]=p)}),c}return a.default=a,xa=a,xa}var mj=pj();const gj=jo(mj),cv=dv("end"),Ef=dv("start");function dv(t){return i;function i(r){const a=r&&r.position&&r.position[t]||{};if(typeof a.line=="number"&&a.line>0&&typeof a.column=="number"&&a.column>0)return{line:a.line,column:a.column,offset:typeof a.offset=="number"&&a.offset>-1?a.offset:void 0}}}function yj(t){const i=Ef(t),r=cv(t);if(i&&r)return{start:i,end:r}}function ka(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?Vy(t.position):"start"in t||"end"in t?Vy(t):"line"in t||"column"in t?Jd(t):""}function Jd(t){return $y(t&&t.line)+":"+$y(t&&t.column)}function Vy(t){return Jd(t&&t.start)+"-"+Jd(t&&t.end)}function $y(t){return t&&typeof t=="number"?t:1}class sn extends Error{constructor(i,r,a){super(),typeof r=="string"&&(a=r,r=void 0);let u="",d={},c=!1;if(r&&("line"in r&&"column"in r?d={place:r}:"start"in r&&"end"in r?d={place:r}:"type"in r?d={ancestors:[r],place:r.position}:d={...r}),typeof i=="string"?u=i:!d.cause&&i&&(c=!0,u=i.message,d.cause=i),!d.ruleId&&!d.source&&typeof a=="string"){const p=a.indexOf(":");p===-1?d.ruleId=a:(d.source=a.slice(0,p),d.ruleId=a.slice(p+1))}if(!d.place&&d.ancestors&&d.ancestors){const p=d.ancestors[d.ancestors.length-1];p&&(d.place=p.position)}const h=d.place&&"start"in d.place?d.place.start:d.place;this.ancestors=d.ancestors||void 0,this.cause=d.cause||void 0,this.column=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=u,this.line=h?h.line:void 0,this.name=ka(d.place)||"1:1",this.place=d.place||void 0,this.reason=this.message,this.ruleId=d.ruleId||void 0,this.source=d.source||void 0,this.stack=c&&d.cause&&typeof d.cause.stack=="string"?d.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}sn.prototype.file="";sn.prototype.name="";sn.prototype.reason="";sn.prototype.message="";sn.prototype.stack="";sn.prototype.column=void 0;sn.prototype.line=void 0;sn.prototype.ancestors=void 0;sn.prototype.cause=void 0;sn.prototype.fatal=void 0;sn.prototype.place=void 0;sn.prototype.ruleId=void 0;sn.prototype.source=void 0;const Nf={}.hasOwnProperty,bj=new Map,vj=/[A-Z]/g,xj=new Set(["table","tbody","thead","tfoot","tr"]),wj=new Set(["td","th"]),fv="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Sj(t,i){if(!i||i.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=i.filePath||void 0;let a;if(i.development){if(typeof i.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=Rj(r,i.jsxDEV)}else{if(typeof i.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof i.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");a=Tj(r,i.jsx,i.jsxs)}const u={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:a,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:i.passKeys!==!1,passNode:i.passNode||!1,schema:i.space==="svg"?Cf:uj,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:i.tableCellAlignToStyle!==!1},d=hv(u,t,void 0);return d&&typeof d!="string"?d:u.create(t,u.Fragment,{children:d||void 0},void 0)}function hv(t,i,r){if(i.type==="element")return jj(t,i,r);if(i.type==="mdxFlowExpression"||i.type==="mdxTextExpression")return kj(t,i);if(i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement")return Ej(t,i,r);if(i.type==="mdxjsEsm")return Cj(t,i);if(i.type==="root")return Nj(t,i,r);if(i.type==="text")return Aj(t,i)}function jj(t,i,r){const a=t.schema;let u=a;i.tagName.toLowerCase()==="svg"&&a.space==="html"&&(u=Cf,t.schema=u),t.ancestors.push(i);const d=mv(t,i.tagName,!1),c=zj(t,i);let h=Tf(t,i);return xj.has(i.tagName)&&(h=h.filter(function(p){return typeof p=="string"?!WS(p):!0})),pv(t,c,d,i),Af(c,h),t.ancestors.pop(),t.schema=a,t.create(i,d,c,r)}function kj(t,i){if(i.data&&i.data.estree&&t.evaluater){const a=i.data.estree.body[0];return a.type,t.evaluater.evaluateExpression(a.expression)}Aa(t,i.position)}function Cj(t,i){if(i.data&&i.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(i.data.estree);Aa(t,i.position)}function Ej(t,i,r){const a=t.schema;let u=a;i.name==="svg"&&a.space==="html"&&(u=Cf,t.schema=u),t.ancestors.push(i);const d=i.name===null?t.Fragment:mv(t,i.name,!0),c=_j(t,i),h=Tf(t,i);return pv(t,c,d,i),Af(c,h),t.ancestors.pop(),t.schema=a,t.create(i,d,c,r)}function Nj(t,i,r){const a={};return Af(a,Tf(t,i)),t.create(i,t.Fragment,a,r)}function Aj(t,i){return i.value}function pv(t,i,r,a){typeof r!="string"&&r!==t.Fragment&&t.passNode&&(i.node=a)}function Af(t,i){if(i.length>0){const r=i.length>1?i:i[0];r&&(t.children=r)}}function Tj(t,i,r){return a;function a(u,d,c,h){const m=Array.isArray(c.children)?r:i;return h?m(d,c,h):m(d,c)}}function Rj(t,i){return r;function r(a,u,d,c){const h=Array.isArray(d.children),p=Ef(a);return i(u,d,c,h,{columnNumber:p?p.column-1:void 0,fileName:t,lineNumber:p?p.line:void 0},void 0)}}function zj(t,i){const r={};let a,u;for(u in i.properties)if(u!=="children"&&Nf.call(i.properties,u)){const d=Dj(t,u,i.properties[u]);if(d){const[c,h]=d;t.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&wj.has(i.tagName)?a=h:r[c]=h}}if(a){const d=r.style||(r.style={});d[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return r}function _j(t,i){const r={};for(const a of i.attributes)if(a.type==="mdxJsxExpressionAttribute")if(a.data&&a.data.estree&&t.evaluater){const d=a.data.estree.body[0];d.type;const c=d.expression;c.type;const h=c.properties[0];h.type,Object.assign(r,t.evaluater.evaluateExpression(h.argument))}else Aa(t,i.position);else{const u=a.name;let d;if(a.value&&typeof a.value=="object")if(a.value.data&&a.value.data.estree&&t.evaluater){const h=a.value.data.estree.body[0];h.type,d=t.evaluater.evaluateExpression(h.expression)}else Aa(t,i.position);else d=a.value===null?!0:a.value;r[u]=d}return r}function Tf(t,i){const r=[];let a=-1;const u=t.passKeys?new Map:bj;for(;++a<i.children.length;){const d=i.children[a];let c;if(t.passKeys){const p=d.type==="element"?d.tagName:d.type==="mdxJsxFlowElement"||d.type==="mdxJsxTextElement"?d.name:void 0;if(p){const m=u.get(p)||0;c=p+"-"+m,u.set(p,m+1)}}const h=hv(t,d,c);h!==void 0&&r.push(h)}return r}function Dj(t,i,r){const a=aj(t.schema,i);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=a.commaSeparated?QS(r):cj(r)),a.property==="style"){let u=typeof r=="object"?r:Mj(t,String(r));return t.stylePropertyNameCase==="css"&&(u=Oj(u)),["style",u]}return[t.elementAttributeNameCase==="react"&&a.space?ij[a.property]||a.property:a.attribute,r]}}function Mj(t,i){try{return gj(i,{reactCompat:!0})}catch(r){if(t.ignoreInvalidStyle)return{};const a=r,u=new sn("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:a,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw u.file=t.filePath||void 0,u.url=fv+"#cannot-parse-style-attribute",u}}function mv(t,i,r){let a;if(!r)a={type:"Literal",value:i};else if(i.includes(".")){const u=i.split(".");let d=-1,c;for(;++d<u.length;){const h=Oy(u[d])?{type:"Identifier",name:u[d]}:{type:"Literal",value:u[d]};c=c?{type:"MemberExpression",object:c,property:h,computed:!!(d&&h.type==="Literal"),optional:!1}:h}a=c}else a=Oy(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};if(a.type==="Literal"){const u=a.value;return Nf.call(t.components,u)?t.components[u]:u}if(t.evaluater)return t.evaluater.evaluateExpression(a);Aa(t)}function Aa(t,i){const r=new sn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=t.filePath||void 0,r.url=fv+"#cannot-handle-mdx-estrees-without-createevaluater",r}function Oj(t){const i={};let r;for(r in t)Nf.call(t,r)&&(i[Lj(r)]=t[r]);return i}function Lj(t){let i=t.replace(vj,Bj);return i.slice(0,3)==="ms-"&&(i="-"+i),i}function Bj(t){return"-"+t.toLowerCase()}const Nd={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Uj={};function Rf(t,i){const r=Uj,a=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,u=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return gv(t,a,u)}function gv(t,i,r){if(Ij(t)){if("value"in t)return t.type==="html"&&!r?"":t.value;if(i&&"alt"in t&&t.alt)return t.alt;if("children"in t)return Yy(t.children,i,r)}return Array.isArray(t)?Yy(t,i,r):""}function Yy(t,i,r){const a=[];let u=-1;for(;++u<t.length;)a[u]=gv(t[u],i,r);return a.join("")}function Ij(t){return!!(t&&typeof t=="object")}const Fy=document.createElement("i");function zf(t){const i="&"+t+";";Fy.innerHTML=i;const r=Fy.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===i?!1:r}function En(t,i,r,a){const u=t.length;let d=0,c;if(i<0?i=-i>u?0:u+i:i=i>u?u:i,r=r>0?r:0,a.length<1e4)c=Array.from(a),c.unshift(i,r),t.splice(...c);else for(r&&t.splice(i,r);d<a.length;)c=a.slice(d,d+1e4),c.unshift(i,0),t.splice(...c),d+=1e4,i+=1e4}function Un(t,i){return t.length>0?(En(t,t.length,0,i),t):i}const Py={}.hasOwnProperty;function yv(t){const i={};let r=-1;for(;++r<t.length;)qj(i,t[r]);return i}function qj(t,i){let r;for(r in i){const u=(Py.call(t,r)?t[r]:void 0)||(t[r]={}),d=i[r];let c;if(d)for(c in d){Py.call(u,c)||(u[c]=[]);const h=d[c];Hj(u[c],Array.isArray(h)?h:h?[h]:[])}}}function Hj(t,i){let r=-1;const a=[];for(;++r<i.length;)(i[r].add==="after"?t:a).push(i[r]);En(t,0,0,a)}function bv(t,i){const r=Number.parseInt(t,i);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function $n(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const un=Ji(/[A-Za-z]/),an=Ji(/[\dA-Za-z]/),Gj=Ji(/[#-'*+\--9=?A-Z^-~]/);function bo(t){return t!==null&&(t<32||t===127)}const Wd=Ji(/\d/),Vj=Ji(/[\dA-Fa-f]/),$j=Ji(/[!-/:-@[-`{-~]/);function Le(t){return t!==null&&t<-2}function Nt(t){return t!==null&&(t<0||t===32)}function et(t){return t===-2||t===-1||t===32}const Eo=Ji(new RegExp("\\p{P}|\\p{S}","u")),wr=Ji(/\s/);function Ji(t){return i;function i(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function jl(t){const i=[];let r=-1,a=0,u=0;for(;++r<t.length;){const d=t.charCodeAt(r);let c="";if(d===37&&an(t.charCodeAt(r+1))&&an(t.charCodeAt(r+2)))u=2;else if(d<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(d))||(c=String.fromCharCode(d));else if(d>55295&&d<57344){const h=t.charCodeAt(r+1);d<56320&&h>56319&&h<57344?(c=String.fromCharCode(d,h),u=1):c="�"}else c=String.fromCharCode(d);c&&(i.push(t.slice(a,r),encodeURIComponent(c)),a=r+u+1,c=""),u&&(r+=u,u=0)}return i.join("")+t.slice(a)}function st(t,i,r,a){const u=a?a-1:Number.POSITIVE_INFINITY;let d=0;return c;function c(p){return et(p)?(t.enter(r),h(p)):i(p)}function h(p){return et(p)&&d++<u?(t.consume(p),h):(t.exit(r),i(p))}}const Yj={tokenize:Fj};function Fj(t){const i=t.attempt(this.parser.constructs.contentInitial,a,u);let r;return i;function a(h){if(h===null){t.consume(h);return}return t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),st(t,i,"linePrefix")}function u(h){return t.enter("paragraph"),d(h)}function d(h){const p=t.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=p),r=p,c(h)}function c(h){if(h===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(h);return}return Le(h)?(t.consume(h),t.exit("chunkText"),d):(t.consume(h),c)}}const Pj={tokenize:Qj},Qy={tokenize:Xj};function Qj(t){const i=this,r=[];let a=0,u,d,c;return h;function h(D){if(a<r.length){const q=r[a];return i.containerState=q[1],t.attempt(q[0].continuation,p,m)(D)}return m(D)}function p(D){if(a++,i.containerState._closeFlow){i.containerState._closeFlow=void 0,u&&_();const q=i.events.length;let se=q,N;for(;se--;)if(i.events[se][0]==="exit"&&i.events[se][1].type==="chunkFlow"){N=i.events[se][1].end;break}T(a);let U=q;for(;U<i.events.length;)i.events[U][1].end={...N},U++;return En(i.events,se+1,0,i.events.slice(q)),i.events.length=U,m(D)}return h(D)}function m(D){if(a===r.length){if(!u)return v(D);if(u.currentConstruct&&u.currentConstruct.concrete)return j(D);i.interrupt=!!(u.currentConstruct&&!u._gfmTableDynamicInterruptHack)}return i.containerState={},t.check(Qy,y,b)(D)}function y(D){return u&&_(),T(a),v(D)}function b(D){return i.parser.lazy[i.now().line]=a!==r.length,c=i.now().offset,j(D)}function v(D){return i.containerState={},t.attempt(Qy,x,j)(D)}function x(D){return a++,r.push([i.currentConstruct,i.containerState]),v(D)}function j(D){if(D===null){u&&_(),T(0),t.consume(D);return}return u=u||i.parser.flow(i.now()),t.enter("chunkFlow",{_tokenizer:u,contentType:"flow",previous:d}),R(D)}function R(D){if(D===null){C(t.exit("chunkFlow"),!0),T(0),t.consume(D);return}return Le(D)?(t.consume(D),C(t.exit("chunkFlow")),a=0,i.interrupt=void 0,h):(t.consume(D),R)}function C(D,q){const se=i.sliceStream(D);if(q&&se.push(null),D.previous=d,d&&(d.next=D),d=D,u.defineSkip(D.start),u.write(se),i.parser.lazy[D.start.line]){let N=u.events.length;for(;N--;)if(u.events[N][1].start.offset<c&&(!u.events[N][1].end||u.events[N][1].end.offset>c))return;const U=i.events.length;let X=U,H,A;for(;X--;)if(i.events[X][0]==="exit"&&i.events[X][1].type==="chunkFlow"){if(H){A=i.events[X][1].end;break}H=!0}for(T(a),N=U;N<i.events.length;)i.events[N][1].end={...A},N++;En(i.events,X+1,0,i.events.slice(U)),i.events.length=N}}function T(D){let q=r.length;for(;q-- >D;){const se=r[q];i.containerState=se[1],se[0].exit.call(i,t)}r.length=D}function _(){u.write([null]),d=void 0,u=void 0,i.containerState._closeFlow=void 0}}function Xj(t,i,r){return st(t,t.attempt(this.parser.constructs.document,i,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function xl(t){if(t===null||Nt(t)||wr(t))return 1;if(Eo(t))return 2}function No(t,i,r){const a=[];let u=-1;for(;++u<t.length;){const d=t[u].resolveAll;d&&!a.includes(d)&&(i=d(i,r),a.push(d))}return i}const ef={name:"attention",resolveAll:Kj,tokenize:Zj};function Kj(t,i){let r=-1,a,u,d,c,h,p,m,y;for(;++r<t.length;)if(t[r][0]==="enter"&&t[r][1].type==="attentionSequence"&&t[r][1]._close){for(a=r;a--;)if(t[a][0]==="exit"&&t[a][1].type==="attentionSequence"&&t[a][1]._open&&i.sliceSerialize(t[a][1]).charCodeAt(0)===i.sliceSerialize(t[r][1]).charCodeAt(0)){if((t[a][1]._close||t[r][1]._open)&&(t[r][1].end.offset-t[r][1].start.offset)%3&&!((t[a][1].end.offset-t[a][1].start.offset+t[r][1].end.offset-t[r][1].start.offset)%3))continue;p=t[a][1].end.offset-t[a][1].start.offset>1&&t[r][1].end.offset-t[r][1].start.offset>1?2:1;const b={...t[a][1].end},v={...t[r][1].start};Xy(b,-p),Xy(v,p),c={type:p>1?"strongSequence":"emphasisSequence",start:b,end:{...t[a][1].end}},h={type:p>1?"strongSequence":"emphasisSequence",start:{...t[r][1].start},end:v},d={type:p>1?"strongText":"emphasisText",start:{...t[a][1].end},end:{...t[r][1].start}},u={type:p>1?"strong":"emphasis",start:{...c.start},end:{...h.end}},t[a][1].end={...c.start},t[r][1].start={...h.end},m=[],t[a][1].end.offset-t[a][1].start.offset&&(m=Un(m,[["enter",t[a][1],i],["exit",t[a][1],i]])),m=Un(m,[["enter",u,i],["enter",c,i],["exit",c,i],["enter",d,i]]),m=Un(m,No(i.parser.constructs.insideSpan.null,t.slice(a+1,r),i)),m=Un(m,[["exit",d,i],["enter",h,i],["exit",h,i],["exit",u,i]]),t[r][1].end.offset-t[r][1].start.offset?(y=2,m=Un(m,[["enter",t[r][1],i],["exit",t[r][1],i]])):y=0,En(t,a-1,r-a+3,m),r=a+m.length-y-2;break}}for(r=-1;++r<t.length;)t[r][1].type==="attentionSequence"&&(t[r][1].type="data");return t}function Zj(t,i){const r=this.parser.constructs.attentionMarkers.null,a=this.previous,u=xl(a);let d;return c;function c(p){return d=p,t.enter("attentionSequence"),h(p)}function h(p){if(p===d)return t.consume(p),h;const m=t.exit("attentionSequence"),y=xl(p),b=!y||y===2&&u||r.includes(p),v=!u||u===2&&y||r.includes(a);return m._open=!!(d===42?b:b&&(u||!v)),m._close=!!(d===42?v:v&&(y||!b)),i(p)}}function Xy(t,i){t.column+=i,t.offset+=i,t._bufferIndex+=i}const Jj={name:"autolink",tokenize:Wj};function Wj(t,i,r){let a=0;return u;function u(x){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),d}function d(x){return un(x)?(t.consume(x),c):x===64?r(x):m(x)}function c(x){return x===43||x===45||x===46||an(x)?(a=1,h(x)):m(x)}function h(x){return x===58?(t.consume(x),a=0,p):(x===43||x===45||x===46||an(x))&&a++<32?(t.consume(x),h):(a=0,m(x))}function p(x){return x===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.exit("autolink"),i):x===null||x===32||x===60||bo(x)?r(x):(t.consume(x),p)}function m(x){return x===64?(t.consume(x),y):Gj(x)?(t.consume(x),m):r(x)}function y(x){return an(x)?b(x):r(x)}function b(x){return x===46?(t.consume(x),a=0,y):x===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.exit("autolink"),i):v(x)}function v(x){if((x===45||an(x))&&a++<63){const j=x===45?v:b;return t.consume(x),j}return r(x)}}const Ma={partial:!0,tokenize:ek};function ek(t,i,r){return a;function a(d){return et(d)?st(t,u,"linePrefix")(d):u(d)}function u(d){return d===null||Le(d)?i(d):r(d)}}const vv={continuation:{tokenize:nk},exit:ik,name:"blockQuote",tokenize:tk};function tk(t,i,r){const a=this;return u;function u(c){if(c===62){const h=a.containerState;return h.open||(t.enter("blockQuote",{_container:!0}),h.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(c),t.exit("blockQuoteMarker"),d}return r(c)}function d(c){return et(c)?(t.enter("blockQuotePrefixWhitespace"),t.consume(c),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),i):(t.exit("blockQuotePrefix"),i(c))}}function nk(t,i,r){const a=this;return u;function u(c){return et(c)?st(t,d,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):d(c)}function d(c){return t.attempt(vv,i,r)(c)}}function ik(t){t.exit("blockQuote")}const xv={name:"characterEscape",tokenize:rk};function rk(t,i,r){return a;function a(d){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(d),t.exit("escapeMarker"),u}function u(d){return $j(d)?(t.enter("characterEscapeValue"),t.consume(d),t.exit("characterEscapeValue"),t.exit("characterEscape"),i):r(d)}}const wv={name:"characterReference",tokenize:lk};function lk(t,i,r){const a=this;let u=0,d,c;return h;function h(b){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),p}function p(b){return b===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(b),t.exit("characterReferenceMarkerNumeric"),m):(t.enter("characterReferenceValue"),d=31,c=an,y(b))}function m(b){return b===88||b===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(b),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),d=6,c=Vj,y):(t.enter("characterReferenceValue"),d=7,c=Wd,y(b))}function y(b){if(b===59&&u){const v=t.exit("characterReferenceValue");return c===an&&!zf(a.sliceSerialize(v))?r(b):(t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),t.exit("characterReference"),i)}return c(b)&&u++<d?(t.consume(b),y):r(b)}}const Ky={partial:!0,tokenize:sk},Zy={concrete:!0,name:"codeFenced",tokenize:ak};function ak(t,i,r){const a=this,u={partial:!0,tokenize:se};let d=0,c=0,h;return p;function p(N){return m(N)}function m(N){const U=a.events[a.events.length-1];return d=U&&U[1].type==="linePrefix"?U[2].sliceSerialize(U[1],!0).length:0,h=N,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),y(N)}function y(N){return N===h?(c++,t.consume(N),y):c<3?r(N):(t.exit("codeFencedFenceSequence"),et(N)?st(t,b,"whitespace")(N):b(N))}function b(N){return N===null||Le(N)?(t.exit("codeFencedFence"),a.interrupt?i(N):t.check(Ky,R,q)(N)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),v(N))}function v(N){return N===null||Le(N)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),b(N)):et(N)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),st(t,x,"whitespace")(N)):N===96&&N===h?r(N):(t.consume(N),v)}function x(N){return N===null||Le(N)?b(N):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),j(N))}function j(N){return N===null||Le(N)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),b(N)):N===96&&N===h?r(N):(t.consume(N),j)}function R(N){return t.attempt(u,q,C)(N)}function C(N){return t.enter("lineEnding"),t.consume(N),t.exit("lineEnding"),T}function T(N){return d>0&&et(N)?st(t,_,"linePrefix",d+1)(N):_(N)}function _(N){return N===null||Le(N)?t.check(Ky,R,q)(N):(t.enter("codeFlowValue"),D(N))}function D(N){return N===null||Le(N)?(t.exit("codeFlowValue"),_(N)):(t.consume(N),D)}function q(N){return t.exit("codeFenced"),i(N)}function se(N,U,X){let H=0;return A;function A(ee){return N.enter("lineEnding"),N.consume(ee),N.exit("lineEnding"),I}function I(ee){return N.enter("codeFencedFence"),et(ee)?st(N,L,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ee):L(ee)}function L(ee){return ee===h?(N.enter("codeFencedFenceSequence"),P(ee)):X(ee)}function P(ee){return ee===h?(H++,N.consume(ee),P):H>=c?(N.exit("codeFencedFenceSequence"),et(ee)?st(N,W,"whitespace")(ee):W(ee)):X(ee)}function W(ee){return ee===null||Le(ee)?(N.exit("codeFencedFence"),U(ee)):X(ee)}}}function sk(t,i,r){const a=this;return u;function u(c){return c===null?r(c):(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),d)}function d(c){return a.parser.lazy[a.now().line]?r(c):i(c)}}const Ad={name:"codeIndented",tokenize:uk},ok={partial:!0,tokenize:ck};function uk(t,i,r){const a=this;return u;function u(m){return t.enter("codeIndented"),st(t,d,"linePrefix",5)(m)}function d(m){const y=a.events[a.events.length-1];return y&&y[1].type==="linePrefix"&&y[2].sliceSerialize(y[1],!0).length>=4?c(m):r(m)}function c(m){return m===null?p(m):Le(m)?t.attempt(ok,c,p)(m):(t.enter("codeFlowValue"),h(m))}function h(m){return m===null||Le(m)?(t.exit("codeFlowValue"),c(m)):(t.consume(m),h)}function p(m){return t.exit("codeIndented"),i(m)}}function ck(t,i,r){const a=this;return u;function u(c){return a.parser.lazy[a.now().line]?r(c):Le(c)?(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),u):st(t,d,"linePrefix",5)(c)}function d(c){const h=a.events[a.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?i(c):Le(c)?u(c):r(c)}}const dk={name:"codeText",previous:hk,resolve:fk,tokenize:pk};function fk(t){let i=t.length-4,r=3,a,u;if((t[r][1].type==="lineEnding"||t[r][1].type==="space")&&(t[i][1].type==="lineEnding"||t[i][1].type==="space")){for(a=r;++a<i;)if(t[a][1].type==="codeTextData"){t[r][1].type="codeTextPadding",t[i][1].type="codeTextPadding",r+=2,i-=2;break}}for(a=r-1,i++;++a<=i;)u===void 0?a!==i&&t[a][1].type!=="lineEnding"&&(u=a):(a===i||t[a][1].type==="lineEnding")&&(t[u][1].type="codeTextData",a!==u+2&&(t[u][1].end=t[a-1][1].end,t.splice(u+2,a-u-2),i-=a-u-2,a=u+2),u=void 0);return t}function hk(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function pk(t,i,r){let a=0,u,d;return c;function c(b){return t.enter("codeText"),t.enter("codeTextSequence"),h(b)}function h(b){return b===96?(t.consume(b),a++,h):(t.exit("codeTextSequence"),p(b))}function p(b){return b===null?r(b):b===32?(t.enter("space"),t.consume(b),t.exit("space"),p):b===96?(d=t.enter("codeTextSequence"),u=0,y(b)):Le(b)?(t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),p):(t.enter("codeTextData"),m(b))}function m(b){return b===null||b===32||b===96||Le(b)?(t.exit("codeTextData"),p(b)):(t.consume(b),m)}function y(b){return b===96?(t.consume(b),u++,y):u===a?(t.exit("codeTextSequence"),t.exit("codeText"),i(b)):(d.type="codeTextData",m(b))}}class mk{constructor(i){this.left=i?[...i]:[],this.right=[]}get(i){if(i<0||i>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+i+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return i<this.left.length?this.left[i]:this.right[this.right.length-i+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(i,r){const a=r??Number.POSITIVE_INFINITY;return a<this.left.length?this.left.slice(i,a):i>this.left.length?this.right.slice(this.right.length-a+this.left.length,this.right.length-i+this.left.length).reverse():this.left.slice(i).concat(this.right.slice(this.right.length-a+this.left.length).reverse())}splice(i,r,a){const u=r||0;this.setCursor(Math.trunc(i));const d=this.right.splice(this.right.length-u,Number.POSITIVE_INFINITY);return a&&wa(this.left,a),d.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(i){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(i)}pushMany(i){this.setCursor(Number.POSITIVE_INFINITY),wa(this.left,i)}unshift(i){this.setCursor(0),this.right.push(i)}unshiftMany(i){this.setCursor(0),wa(this.right,i.reverse())}setCursor(i){if(!(i===this.left.length||i>this.left.length&&this.right.length===0||i<0&&this.left.length===0))if(i<this.left.length){const r=this.left.splice(i,Number.POSITIVE_INFINITY);wa(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-i,Number.POSITIVE_INFINITY);wa(this.left,r.reverse())}}}function wa(t,i){let r=0;if(i.length<1e4)t.push(...i);else for(;r<i.length;)t.push(...i.slice(r,r+1e4)),r+=1e4}function Sv(t){const i={};let r=-1,a,u,d,c,h,p,m;const y=new mk(t);for(;++r<y.length;){for(;r in i;)r=i[r];if(a=y.get(r),r&&a[1].type==="chunkFlow"&&y.get(r-1)[1].type==="listItemPrefix"&&(p=a[1]._tokenizer.events,d=0,d<p.length&&p[d][1].type==="lineEndingBlank"&&(d+=2),d<p.length&&p[d][1].type==="content"))for(;++d<p.length&&p[d][1].type!=="content";)p[d][1].type==="chunkText"&&(p[d][1]._isInFirstContentOfListItem=!0,d++);if(a[0]==="enter")a[1].contentType&&(Object.assign(i,gk(y,r)),r=i[r],m=!0);else if(a[1]._container){for(d=r,u=void 0;d--;)if(c=y.get(d),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(u&&(y.get(u)[1].type="lineEndingBlank"),c[1].type="lineEnding",u=d);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;u&&(a[1].end={...y.get(u)[1].start},h=y.slice(u,r),h.unshift(a),y.splice(u,r-u+1,h))}}return En(t,0,Number.POSITIVE_INFINITY,y.slice(0)),!m}function gk(t,i){const r=t.get(i)[1],a=t.get(i)[2];let u=i-1;const d=[];let c=r._tokenizer;c||(c=a.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const h=c.events,p=[],m={};let y,b,v=-1,x=r,j=0,R=0;const C=[R];for(;x;){for(;t.get(++u)[1]!==x;);d.push(u),x._tokenizer||(y=a.sliceStream(x),x.next||y.push(null),b&&c.defineSkip(x.start),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(y),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),b=x,x=x.next}for(x=r;++v<h.length;)h[v][0]==="exit"&&h[v-1][0]==="enter"&&h[v][1].type===h[v-1][1].type&&h[v][1].start.line!==h[v][1].end.line&&(R=v+1,C.push(R),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(c.events=[],x?(x._tokenizer=void 0,x.previous=void 0):C.pop(),v=C.length;v--;){const T=h.slice(C[v],C[v+1]),_=d.pop();p.push([_,_+T.length-1]),t.splice(_,2,T)}for(p.reverse(),v=-1;++v<p.length;)m[j+p[v][0]]=j+p[v][1],j+=p[v][1]-p[v][0]-1;return m}const yk={resolve:vk,tokenize:xk},bk={partial:!0,tokenize:wk};function vk(t){return Sv(t),t}function xk(t,i){let r;return a;function a(h){return t.enter("content"),r=t.enter("chunkContent",{contentType:"content"}),u(h)}function u(h){return h===null?d(h):Le(h)?t.check(bk,c,d)(h):(t.consume(h),u)}function d(h){return t.exit("chunkContent"),t.exit("content"),i(h)}function c(h){return t.consume(h),t.exit("chunkContent"),r.next=t.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,u}}function wk(t,i,r){const a=this;return u;function u(c){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),st(t,d,"linePrefix")}function d(c){if(c===null||Le(c))return r(c);const h=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?i(c):t.interrupt(a.parser.constructs.flow,r,i)(c)}}function jv(t,i,r,a,u,d,c,h,p){const m=p||Number.POSITIVE_INFINITY;let y=0;return b;function b(T){return T===60?(t.enter(a),t.enter(u),t.enter(d),t.consume(T),t.exit(d),v):T===null||T===32||T===41||bo(T)?r(T):(t.enter(a),t.enter(c),t.enter(h),t.enter("chunkString",{contentType:"string"}),R(T))}function v(T){return T===62?(t.enter(d),t.consume(T),t.exit(d),t.exit(u),t.exit(a),i):(t.enter(h),t.enter("chunkString",{contentType:"string"}),x(T))}function x(T){return T===62?(t.exit("chunkString"),t.exit(h),v(T)):T===null||T===60||Le(T)?r(T):(t.consume(T),T===92?j:x)}function j(T){return T===60||T===62||T===92?(t.consume(T),x):x(T)}function R(T){return!y&&(T===null||T===41||Nt(T))?(t.exit("chunkString"),t.exit(h),t.exit(c),t.exit(a),i(T)):y<m&&T===40?(t.consume(T),y++,R):T===41?(t.consume(T),y--,R):T===null||T===32||T===40||bo(T)?r(T):(t.consume(T),T===92?C:R)}function C(T){return T===40||T===41||T===92?(t.consume(T),R):R(T)}}function kv(t,i,r,a,u,d){const c=this;let h=0,p;return m;function m(x){return t.enter(a),t.enter(u),t.consume(x),t.exit(u),t.enter(d),y}function y(x){return h>999||x===null||x===91||x===93&&!p||x===94&&!h&&"_hiddenFootnoteSupport"in c.parser.constructs?r(x):x===93?(t.exit(d),t.enter(u),t.consume(x),t.exit(u),t.exit(a),i):Le(x)?(t.enter("lineEnding"),t.consume(x),t.exit("lineEnding"),y):(t.enter("chunkString",{contentType:"string"}),b(x))}function b(x){return x===null||x===91||x===93||Le(x)||h++>999?(t.exit("chunkString"),y(x)):(t.consume(x),p||(p=!et(x)),x===92?v:b)}function v(x){return x===91||x===92||x===93?(t.consume(x),h++,b):b(x)}}function Cv(t,i,r,a,u,d){let c;return h;function h(v){return v===34||v===39||v===40?(t.enter(a),t.enter(u),t.consume(v),t.exit(u),c=v===40?41:v,p):r(v)}function p(v){return v===c?(t.enter(u),t.consume(v),t.exit(u),t.exit(a),i):(t.enter(d),m(v))}function m(v){return v===c?(t.exit(d),p(c)):v===null?r(v):Le(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),st(t,m,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),y(v))}function y(v){return v===c||v===null||Le(v)?(t.exit("chunkString"),m(v)):(t.consume(v),v===92?b:y)}function b(v){return v===c||v===92?(t.consume(v),y):y(v)}}function Ca(t,i){let r;return a;function a(u){return Le(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),r=!0,a):et(u)?st(t,a,r?"linePrefix":"lineSuffix")(u):i(u)}}const Sk={name:"definition",tokenize:kk},jk={partial:!0,tokenize:Ck};function kk(t,i,r){const a=this;let u;return d;function d(x){return t.enter("definition"),c(x)}function c(x){return kv.call(a,t,h,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function h(x){return u=$n(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),x===58?(t.enter("definitionMarker"),t.consume(x),t.exit("definitionMarker"),p):r(x)}function p(x){return Nt(x)?Ca(t,m)(x):m(x)}function m(x){return jv(t,y,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function y(x){return t.attempt(jk,b,b)(x)}function b(x){return et(x)?st(t,v,"whitespace")(x):v(x)}function v(x){return x===null||Le(x)?(t.exit("definition"),a.parser.defined.push(u),i(x)):r(x)}}function Ck(t,i,r){return a;function a(h){return Nt(h)?Ca(t,u)(h):r(h)}function u(h){return Cv(t,d,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function d(h){return et(h)?st(t,c,"whitespace")(h):c(h)}function c(h){return h===null||Le(h)?i(h):r(h)}}const Ek={name:"hardBreakEscape",tokenize:Nk};function Nk(t,i,r){return a;function a(d){return t.enter("hardBreakEscape"),t.consume(d),u}function u(d){return Le(d)?(t.exit("hardBreakEscape"),i(d)):r(d)}}const Ak={name:"headingAtx",resolve:Tk,tokenize:Rk};function Tk(t,i){let r=t.length-2,a=3,u,d;return t[a][1].type==="whitespace"&&(a+=2),r-2>a&&t[r][1].type==="whitespace"&&(r-=2),t[r][1].type==="atxHeadingSequence"&&(a===r-1||r-4>a&&t[r-2][1].type==="whitespace")&&(r-=a+1===r?2:4),r>a&&(u={type:"atxHeadingText",start:t[a][1].start,end:t[r][1].end},d={type:"chunkText",start:t[a][1].start,end:t[r][1].end,contentType:"text"},En(t,a,r-a+1,[["enter",u,i],["enter",d,i],["exit",d,i],["exit",u,i]])),t}function Rk(t,i,r){let a=0;return u;function u(y){return t.enter("atxHeading"),d(y)}function d(y){return t.enter("atxHeadingSequence"),c(y)}function c(y){return y===35&&a++<6?(t.consume(y),c):y===null||Nt(y)?(t.exit("atxHeadingSequence"),h(y)):r(y)}function h(y){return y===35?(t.enter("atxHeadingSequence"),p(y)):y===null||Le(y)?(t.exit("atxHeading"),i(y)):et(y)?st(t,h,"whitespace")(y):(t.enter("atxHeadingText"),m(y))}function p(y){return y===35?(t.consume(y),p):(t.exit("atxHeadingSequence"),h(y))}function m(y){return y===null||y===35||Nt(y)?(t.exit("atxHeadingText"),h(y)):(t.consume(y),m)}}const zk=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Jy=["pre","script","style","textarea"],_k={concrete:!0,name:"htmlFlow",resolveTo:Ok,tokenize:Lk},Dk={partial:!0,tokenize:Uk},Mk={partial:!0,tokenize:Bk};function Ok(t){let i=t.length;for(;i--&&!(t[i][0]==="enter"&&t[i][1].type==="htmlFlow"););return i>1&&t[i-2][1].type==="linePrefix"&&(t[i][1].start=t[i-2][1].start,t[i+1][1].start=t[i-2][1].start,t.splice(i-2,2)),t}function Lk(t,i,r){const a=this;let u,d,c,h,p;return m;function m(E){return y(E)}function y(E){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(E),b}function b(E){return E===33?(t.consume(E),v):E===47?(t.consume(E),d=!0,R):E===63?(t.consume(E),u=3,a.interrupt?i:k):un(E)?(t.consume(E),c=String.fromCharCode(E),C):r(E)}function v(E){return E===45?(t.consume(E),u=2,x):E===91?(t.consume(E),u=5,h=0,j):un(E)?(t.consume(E),u=4,a.interrupt?i:k):r(E)}function x(E){return E===45?(t.consume(E),a.interrupt?i:k):r(E)}function j(E){const J="CDATA[";return E===J.charCodeAt(h++)?(t.consume(E),h===J.length?a.interrupt?i:L:j):r(E)}function R(E){return un(E)?(t.consume(E),c=String.fromCharCode(E),C):r(E)}function C(E){if(E===null||E===47||E===62||Nt(E)){const J=E===47,be=c.toLowerCase();return!J&&!d&&Jy.includes(be)?(u=1,a.interrupt?i(E):L(E)):zk.includes(c.toLowerCase())?(u=6,J?(t.consume(E),T):a.interrupt?i(E):L(E)):(u=7,a.interrupt&&!a.parser.lazy[a.now().line]?r(E):d?_(E):D(E))}return E===45||an(E)?(t.consume(E),c+=String.fromCharCode(E),C):r(E)}function T(E){return E===62?(t.consume(E),a.interrupt?i:L):r(E)}function _(E){return et(E)?(t.consume(E),_):A(E)}function D(E){return E===47?(t.consume(E),A):E===58||E===95||un(E)?(t.consume(E),q):et(E)?(t.consume(E),D):A(E)}function q(E){return E===45||E===46||E===58||E===95||an(E)?(t.consume(E),q):se(E)}function se(E){return E===61?(t.consume(E),N):et(E)?(t.consume(E),se):D(E)}function N(E){return E===null||E===60||E===61||E===62||E===96?r(E):E===34||E===39?(t.consume(E),p=E,U):et(E)?(t.consume(E),N):X(E)}function U(E){return E===p?(t.consume(E),p=null,H):E===null||Le(E)?r(E):(t.consume(E),U)}function X(E){return E===null||E===34||E===39||E===47||E===60||E===61||E===62||E===96||Nt(E)?se(E):(t.consume(E),X)}function H(E){return E===47||E===62||et(E)?D(E):r(E)}function A(E){return E===62?(t.consume(E),I):r(E)}function I(E){return E===null||Le(E)?L(E):et(E)?(t.consume(E),I):r(E)}function L(E){return E===45&&u===2?(t.consume(E),G):E===60&&u===1?(t.consume(E),B):E===62&&u===4?(t.consume(E),O):E===63&&u===3?(t.consume(E),k):E===93&&u===5?(t.consume(E),fe):Le(E)&&(u===6||u===7)?(t.exit("htmlFlowData"),t.check(Dk,le,P)(E)):E===null||Le(E)?(t.exit("htmlFlowData"),P(E)):(t.consume(E),L)}function P(E){return t.check(Mk,W,le)(E)}function W(E){return t.enter("lineEnding"),t.consume(E),t.exit("lineEnding"),ee}function ee(E){return E===null||Le(E)?P(E):(t.enter("htmlFlowData"),L(E))}function G(E){return E===45?(t.consume(E),k):L(E)}function B(E){return E===47?(t.consume(E),c="",Q):L(E)}function Q(E){if(E===62){const J=c.toLowerCase();return Jy.includes(J)?(t.consume(E),O):L(E)}return un(E)&&c.length<8?(t.consume(E),c+=String.fromCharCode(E),Q):L(E)}function fe(E){return E===93?(t.consume(E),k):L(E)}function k(E){return E===62?(t.consume(E),O):E===45&&u===2?(t.consume(E),k):L(E)}function O(E){return E===null||Le(E)?(t.exit("htmlFlowData"),le(E)):(t.consume(E),O)}function le(E){return t.exit("htmlFlow"),i(E)}}function Bk(t,i,r){const a=this;return u;function u(c){return Le(c)?(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),d):r(c)}function d(c){return a.parser.lazy[a.now().line]?r(c):i(c)}}function Uk(t,i,r){return a;function a(u){return t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),t.attempt(Ma,i,r)}}const Ik={name:"htmlText",tokenize:qk};function qk(t,i,r){const a=this;let u,d,c;return h;function h(k){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(k),p}function p(k){return k===33?(t.consume(k),m):k===47?(t.consume(k),se):k===63?(t.consume(k),D):un(k)?(t.consume(k),X):r(k)}function m(k){return k===45?(t.consume(k),y):k===91?(t.consume(k),d=0,j):un(k)?(t.consume(k),_):r(k)}function y(k){return k===45?(t.consume(k),x):r(k)}function b(k){return k===null?r(k):k===45?(t.consume(k),v):Le(k)?(c=b,B(k)):(t.consume(k),b)}function v(k){return k===45?(t.consume(k),x):b(k)}function x(k){return k===62?G(k):k===45?v(k):b(k)}function j(k){const O="CDATA[";return k===O.charCodeAt(d++)?(t.consume(k),d===O.length?R:j):r(k)}function R(k){return k===null?r(k):k===93?(t.consume(k),C):Le(k)?(c=R,B(k)):(t.consume(k),R)}function C(k){return k===93?(t.consume(k),T):R(k)}function T(k){return k===62?G(k):k===93?(t.consume(k),T):R(k)}function _(k){return k===null||k===62?G(k):Le(k)?(c=_,B(k)):(t.consume(k),_)}function D(k){return k===null?r(k):k===63?(t.consume(k),q):Le(k)?(c=D,B(k)):(t.consume(k),D)}function q(k){return k===62?G(k):D(k)}function se(k){return un(k)?(t.consume(k),N):r(k)}function N(k){return k===45||an(k)?(t.consume(k),N):U(k)}function U(k){return Le(k)?(c=U,B(k)):et(k)?(t.consume(k),U):G(k)}function X(k){return k===45||an(k)?(t.consume(k),X):k===47||k===62||Nt(k)?H(k):r(k)}function H(k){return k===47?(t.consume(k),G):k===58||k===95||un(k)?(t.consume(k),A):Le(k)?(c=H,B(k)):et(k)?(t.consume(k),H):G(k)}function A(k){return k===45||k===46||k===58||k===95||an(k)?(t.consume(k),A):I(k)}function I(k){return k===61?(t.consume(k),L):Le(k)?(c=I,B(k)):et(k)?(t.consume(k),I):H(k)}function L(k){return k===null||k===60||k===61||k===62||k===96?r(k):k===34||k===39?(t.consume(k),u=k,P):Le(k)?(c=L,B(k)):et(k)?(t.consume(k),L):(t.consume(k),W)}function P(k){return k===u?(t.consume(k),u=void 0,ee):k===null?r(k):Le(k)?(c=P,B(k)):(t.consume(k),P)}function W(k){return k===null||k===34||k===39||k===60||k===61||k===96?r(k):k===47||k===62||Nt(k)?H(k):(t.consume(k),W)}function ee(k){return k===47||k===62||Nt(k)?H(k):r(k)}function G(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),i):r(k)}function B(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),Q}function Q(k){return et(k)?st(t,fe,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):fe(k)}function fe(k){return t.enter("htmlTextData"),c(k)}}const _f={name:"labelEnd",resolveAll:$k,resolveTo:Yk,tokenize:Fk},Hk={tokenize:Pk},Gk={tokenize:Qk},Vk={tokenize:Xk};function $k(t){let i=-1;const r=[];for(;++i<t.length;){const a=t[i][1];if(r.push(t[i]),a.type==="labelImage"||a.type==="labelLink"||a.type==="labelEnd"){const u=a.type==="labelImage"?4:2;a.type="data",i+=u}}return t.length!==r.length&&En(t,0,t.length,r),t}function Yk(t,i){let r=t.length,a=0,u,d,c,h;for(;r--;)if(u=t[r][1],d){if(u.type==="link"||u.type==="labelLink"&&u._inactive)break;t[r][0]==="enter"&&u.type==="labelLink"&&(u._inactive=!0)}else if(c){if(t[r][0]==="enter"&&(u.type==="labelImage"||u.type==="labelLink")&&!u._balanced&&(d=r,u.type!=="labelLink")){a=2;break}}else u.type==="labelEnd"&&(c=r);const p={type:t[d][1].type==="labelLink"?"link":"image",start:{...t[d][1].start},end:{...t[t.length-1][1].end}},m={type:"label",start:{...t[d][1].start},end:{...t[c][1].end}},y={type:"labelText",start:{...t[d+a+2][1].end},end:{...t[c-2][1].start}};return h=[["enter",p,i],["enter",m,i]],h=Un(h,t.slice(d+1,d+a+3)),h=Un(h,[["enter",y,i]]),h=Un(h,No(i.parser.constructs.insideSpan.null,t.slice(d+a+4,c-3),i)),h=Un(h,[["exit",y,i],t[c-2],t[c-1],["exit",m,i]]),h=Un(h,t.slice(c+1)),h=Un(h,[["exit",p,i]]),En(t,d,t.length,h),t}function Fk(t,i,r){const a=this;let u=a.events.length,d,c;for(;u--;)if((a.events[u][1].type==="labelImage"||a.events[u][1].type==="labelLink")&&!a.events[u][1]._balanced){d=a.events[u][1];break}return h;function h(v){return d?d._inactive?b(v):(c=a.parser.defined.includes($n(a.sliceSerialize({start:d.end,end:a.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(v),t.exit("labelMarker"),t.exit("labelEnd"),p):r(v)}function p(v){return v===40?t.attempt(Hk,y,c?y:b)(v):v===91?t.attempt(Gk,y,c?m:b)(v):c?y(v):b(v)}function m(v){return t.attempt(Vk,y,b)(v)}function y(v){return i(v)}function b(v){return d._balanced=!0,r(v)}}function Pk(t,i,r){return a;function a(b){return t.enter("resource"),t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),u}function u(b){return Nt(b)?Ca(t,d)(b):d(b)}function d(b){return b===41?y(b):jv(t,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function c(b){return Nt(b)?Ca(t,p)(b):y(b)}function h(b){return r(b)}function p(b){return b===34||b===39||b===40?Cv(t,m,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):y(b)}function m(b){return Nt(b)?Ca(t,y)(b):y(b)}function y(b){return b===41?(t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),t.exit("resource"),i):r(b)}}function Qk(t,i,r){const a=this;return u;function u(h){return kv.call(a,t,d,c,"reference","referenceMarker","referenceString")(h)}function d(h){return a.parser.defined.includes($n(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?i(h):r(h)}function c(h){return r(h)}}function Xk(t,i,r){return a;function a(d){return t.enter("reference"),t.enter("referenceMarker"),t.consume(d),t.exit("referenceMarker"),u}function u(d){return d===93?(t.enter("referenceMarker"),t.consume(d),t.exit("referenceMarker"),t.exit("reference"),i):r(d)}}const Kk={name:"labelStartImage",resolveAll:_f.resolveAll,tokenize:Zk};function Zk(t,i,r){const a=this;return u;function u(h){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(h),t.exit("labelImageMarker"),d}function d(h){return h===91?(t.enter("labelMarker"),t.consume(h),t.exit("labelMarker"),t.exit("labelImage"),c):r(h)}function c(h){return h===94&&"_hiddenFootnoteSupport"in a.parser.constructs?r(h):i(h)}}const Jk={name:"labelStartLink",resolveAll:_f.resolveAll,tokenize:Wk};function Wk(t,i,r){const a=this;return u;function u(c){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(c),t.exit("labelMarker"),t.exit("labelLink"),d}function d(c){return c===94&&"_hiddenFootnoteSupport"in a.parser.constructs?r(c):i(c)}}const Td={name:"lineEnding",tokenize:eC};function eC(t,i){return r;function r(a){return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),st(t,i,"linePrefix")}}const co={name:"thematicBreak",tokenize:tC};function tC(t,i,r){let a=0,u;return d;function d(m){return t.enter("thematicBreak"),c(m)}function c(m){return u=m,h(m)}function h(m){return m===u?(t.enter("thematicBreakSequence"),p(m)):a>=3&&(m===null||Le(m))?(t.exit("thematicBreak"),i(m)):r(m)}function p(m){return m===u?(t.consume(m),a++,p):(t.exit("thematicBreakSequence"),et(m)?st(t,h,"whitespace")(m):h(m))}}const gn={continuation:{tokenize:lC},exit:sC,name:"list",tokenize:rC},nC={partial:!0,tokenize:oC},iC={partial:!0,tokenize:aC};function rC(t,i,r){const a=this,u=a.events[a.events.length-1];let d=u&&u[1].type==="linePrefix"?u[2].sliceSerialize(u[1],!0).length:0,c=0;return h;function h(x){const j=a.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!a.containerState.marker||x===a.containerState.marker:Wd(x)){if(a.containerState.type||(a.containerState.type=j,t.enter(j,{_container:!0})),j==="listUnordered")return t.enter("listItemPrefix"),x===42||x===45?t.check(co,r,m)(x):m(x);if(!a.interrupt||x===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),p(x)}return r(x)}function p(x){return Wd(x)&&++c<10?(t.consume(x),p):(!a.interrupt||c<2)&&(a.containerState.marker?x===a.containerState.marker:x===41||x===46)?(t.exit("listItemValue"),m(x)):r(x)}function m(x){return t.enter("listItemMarker"),t.consume(x),t.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||x,t.check(Ma,a.interrupt?r:y,t.attempt(nC,v,b))}function y(x){return a.containerState.initialBlankLine=!0,d++,v(x)}function b(x){return et(x)?(t.enter("listItemPrefixWhitespace"),t.consume(x),t.exit("listItemPrefixWhitespace"),v):r(x)}function v(x){return a.containerState.size=d+a.sliceSerialize(t.exit("listItemPrefix"),!0).length,i(x)}}function lC(t,i,r){const a=this;return a.containerState._closeFlow=void 0,t.check(Ma,u,d);function u(h){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,st(t,i,"listItemIndent",a.containerState.size+1)(h)}function d(h){return a.containerState.furtherBlankLines||!et(h)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,c(h)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,t.attempt(iC,i,c)(h))}function c(h){return a.containerState._closeFlow=!0,a.interrupt=void 0,st(t,t.attempt(gn,i,r),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function aC(t,i,r){const a=this;return st(t,u,"listItemIndent",a.containerState.size+1);function u(d){const c=a.events[a.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===a.containerState.size?i(d):r(d)}}function sC(t){t.exit(this.containerState.type)}function oC(t,i,r){const a=this;return st(t,u,"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function u(d){const c=a.events[a.events.length-1];return!et(d)&&c&&c[1].type==="listItemPrefixWhitespace"?i(d):r(d)}}const Wy={name:"setextUnderline",resolveTo:uC,tokenize:cC};function uC(t,i){let r=t.length,a,u,d;for(;r--;)if(t[r][0]==="enter"){if(t[r][1].type==="content"){a=r;break}t[r][1].type==="paragraph"&&(u=r)}else t[r][1].type==="content"&&t.splice(r,1),!d&&t[r][1].type==="definition"&&(d=r);const c={type:"setextHeading",start:{...t[a][1].start},end:{...t[t.length-1][1].end}};return t[u][1].type="setextHeadingText",d?(t.splice(u,0,["enter",c,i]),t.splice(d+1,0,["exit",t[a][1],i]),t[a][1].end={...t[d][1].end}):t[a][1]=c,t.push(["exit",c,i]),t}function cC(t,i,r){const a=this;let u;return d;function d(m){let y=a.events.length,b;for(;y--;)if(a.events[y][1].type!=="lineEnding"&&a.events[y][1].type!=="linePrefix"&&a.events[y][1].type!=="content"){b=a.events[y][1].type==="paragraph";break}return!a.parser.lazy[a.now().line]&&(a.interrupt||b)?(t.enter("setextHeadingLine"),u=m,c(m)):r(m)}function c(m){return t.enter("setextHeadingLineSequence"),h(m)}function h(m){return m===u?(t.consume(m),h):(t.exit("setextHeadingLineSequence"),et(m)?st(t,p,"lineSuffix")(m):p(m))}function p(m){return m===null||Le(m)?(t.exit("setextHeadingLine"),i(m)):r(m)}}const dC={tokenize:fC};function fC(t){const i=this,r=t.attempt(Ma,a,t.attempt(this.parser.constructs.flowInitial,u,st(t,t.attempt(this.parser.constructs.flow,u,t.attempt(yk,u)),"linePrefix")));return r;function a(d){if(d===null){t.consume(d);return}return t.enter("lineEndingBlank"),t.consume(d),t.exit("lineEndingBlank"),i.currentConstruct=void 0,r}function u(d){if(d===null){t.consume(d);return}return t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),i.currentConstruct=void 0,r}}const hC={resolveAll:Nv()},pC=Ev("string"),mC=Ev("text");function Ev(t){return{resolveAll:Nv(t==="text"?gC:void 0),tokenize:i};function i(r){const a=this,u=this.parser.constructs[t],d=r.attempt(u,c,h);return c;function c(y){return m(y)?d(y):h(y)}function h(y){if(y===null){r.consume(y);return}return r.enter("data"),r.consume(y),p}function p(y){return m(y)?(r.exit("data"),d(y)):(r.consume(y),p)}function m(y){if(y===null)return!0;const b=u[y];let v=-1;if(b)for(;++v<b.length;){const x=b[v];if(!x.previous||x.previous.call(a,a.previous))return!0}return!1}}}function Nv(t){return i;function i(r,a){let u=-1,d;for(;++u<=r.length;)d===void 0?r[u]&&r[u][1].type==="data"&&(d=u,u++):(!r[u]||r[u][1].type!=="data")&&(u!==d+2&&(r[d][1].end=r[u-1][1].end,r.splice(d+2,u-d-2),u=d+2),d=void 0);return t?t(r,a):r}}function gC(t,i){let r=0;for(;++r<=t.length;)if((r===t.length||t[r][1].type==="lineEnding")&&t[r-1][1].type==="data"){const a=t[r-1][1],u=i.sliceStream(a);let d=u.length,c=-1,h=0,p;for(;d--;){const m=u[d];if(typeof m=="string"){for(c=m.length;m.charCodeAt(c-1)===32;)h++,c--;if(c)break;c=-1}else if(m===-2)p=!0,h++;else if(m!==-1){d++;break}}if(i._contentTypeTextTrailing&&r===t.length&&(h=0),h){const m={type:r===t.length||p||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:d?c:a.start._bufferIndex+c,_index:a.start._index+d,line:a.end.line,column:a.end.column-h,offset:a.end.offset-h},end:{...a.end}};a.end={...m.start},a.start.offset===a.end.offset?Object.assign(a,m):(t.splice(r,0,["enter",m,i],["exit",m,i]),r+=2)}r++}return t}const yC={42:gn,43:gn,45:gn,48:gn,49:gn,50:gn,51:gn,52:gn,53:gn,54:gn,55:gn,56:gn,57:gn,62:vv},bC={91:Sk},vC={[-2]:Ad,[-1]:Ad,32:Ad},xC={35:Ak,42:co,45:[Wy,co],60:_k,61:Wy,95:co,96:Zy,126:Zy},wC={38:wv,92:xv},SC={[-5]:Td,[-4]:Td,[-3]:Td,33:Kk,38:wv,42:ef,60:[Jj,Ik],91:Jk,92:[Ek,xv],93:_f,95:ef,96:dk},jC={null:[ef,hC]},kC={null:[42,95]},CC={null:[]},EC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:kC,contentInitial:bC,disable:CC,document:yC,flow:xC,flowInitial:vC,insideSpan:jC,string:wC,text:SC},Symbol.toStringTag,{value:"Module"}));function NC(t,i,r){let a={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const u={},d=[];let c=[],h=[];const p={attempt:U(se),check:U(N),consume:_,enter:D,exit:q,interrupt:U(N,{interrupt:!0})},m={code:null,containerState:{},defineSkip:R,events:[],now:j,parser:t,previous:null,sliceSerialize:v,sliceStream:x,write:b};let y=i.tokenize.call(m,p);return i.resolveAll&&d.push(i),m;function b(I){return c=Un(c,I),C(),c[c.length-1]!==null?[]:(X(i,0),m.events=No(d,m.events,m),m.events)}function v(I,L){return TC(x(I),L)}function x(I){return AC(c,I)}function j(){const{_bufferIndex:I,_index:L,line:P,column:W,offset:ee}=a;return{_bufferIndex:I,_index:L,line:P,column:W,offset:ee}}function R(I){u[I.line]=I.column,A()}function C(){let I;for(;a._index<c.length;){const L=c[a._index];if(typeof L=="string")for(I=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===I&&a._bufferIndex<L.length;)T(L.charCodeAt(a._bufferIndex));else T(L)}}function T(I){y=y(I)}function _(I){Le(I)?(a.line++,a.column=1,a.offset+=I===-3?2:1,A()):I!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===c[a._index].length&&(a._bufferIndex=-1,a._index++)),m.previous=I}function D(I,L){const P=L||{};return P.type=I,P.start=j(),m.events.push(["enter",P,m]),h.push(P),P}function q(I){const L=h.pop();return L.end=j(),m.events.push(["exit",L,m]),L}function se(I,L){X(I,L.from)}function N(I,L){L.restore()}function U(I,L){return P;function P(W,ee,G){let B,Q,fe,k;return Array.isArray(W)?le(W):"tokenize"in W?le([W]):O(W);function O(Z){return ne;function ne(ge){const Y=ge!==null&&Z[ge],ve=ge!==null&&Z.null,De=[...Array.isArray(Y)?Y:Y?[Y]:[],...Array.isArray(ve)?ve:ve?[ve]:[]];return le(De)(ge)}}function le(Z){return B=Z,Q=0,Z.length===0?G:E(Z[Q])}function E(Z){return ne;function ne(ge){return k=H(),fe=Z,Z.partial||(m.currentConstruct=Z),Z.name&&m.parser.constructs.disable.null.includes(Z.name)?be():Z.tokenize.call(L?Object.assign(Object.create(m),L):m,p,J,be)(ge)}}function J(Z){return I(fe,k),ee}function be(Z){return k.restore(),++Q<B.length?E(B[Q]):G}}}function X(I,L){I.resolveAll&&!d.includes(I)&&d.push(I),I.resolve&&En(m.events,L,m.events.length-L,I.resolve(m.events.slice(L),m)),I.resolveTo&&(m.events=I.resolveTo(m.events,m))}function H(){const I=j(),L=m.previous,P=m.currentConstruct,W=m.events.length,ee=Array.from(h);return{from:W,restore:G};function G(){a=I,m.previous=L,m.currentConstruct=P,m.events.length=W,h=ee,A()}}function A(){a.line in u&&a.column<2&&(a.column=u[a.line],a.offset+=u[a.line]-1)}}function AC(t,i){const r=i.start._index,a=i.start._bufferIndex,u=i.end._index,d=i.end._bufferIndex;let c;if(r===u)c=[t[r].slice(a,d)];else{if(c=t.slice(r,u),a>-1){const h=c[0];typeof h=="string"?c[0]=h.slice(a):c.shift()}d>0&&c.push(t[u].slice(0,d))}return c}function TC(t,i){let r=-1;const a=[];let u;for(;++r<t.length;){const d=t[r];let c;if(typeof d=="string")c=d;else switch(d){case-5:{c="\r";break}case-4:{c=`
|
|
30
|
+
`;break}case-3:{c=`\r
|
|
31
|
+
`;break}case-2:{c=i?" ":" ";break}case-1:{if(!i&&u)continue;c=" ";break}default:c=String.fromCharCode(d)}u=d===-2,a.push(c)}return a.join("")}function RC(t){const a={constructs:yv([EC,...(t||{}).extensions||[]]),content:u(Yj),defined:[],document:u(Pj),flow:u(dC),lazy:{},string:u(pC),text:u(mC)};return a;function u(d){return c;function c(h){return NC(a,d,h)}}}function zC(t){for(;!Sv(t););return t}const eb=/[\0\t\n\r]/g;function _C(){let t=1,i="",r=!0,a;return u;function u(d,c,h){const p=[];let m,y,b,v,x;for(d=i+(typeof d=="string"?d.toString():new TextDecoder(c||void 0).decode(d)),b=0,i="",r&&(d.charCodeAt(0)===65279&&b++,r=void 0);b<d.length;){if(eb.lastIndex=b,m=eb.exec(d),v=m&&m.index!==void 0?m.index:d.length,x=d.charCodeAt(v),!m){i=d.slice(b);break}if(x===10&&b===v&&a)p.push(-3),a=void 0;else switch(a&&(p.push(-5),a=void 0),b<v&&(p.push(d.slice(b,v)),t+=v-b),x){case 0:{p.push(65533),t++;break}case 9:{for(y=Math.ceil(t/4)*4,p.push(-2);t++<y;)p.push(-1);break}case 10:{p.push(-4),t=1;break}default:a=!0,t=1}b=v+1}return h&&(a&&p.push(-5),i&&p.push(i),p.push(null)),p}}const DC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function MC(t){return t.replace(DC,OC)}function OC(t,i,r){if(i)return i;if(r.charCodeAt(0)===35){const u=r.charCodeAt(1),d=u===120||u===88;return bv(r.slice(d?2:1),d?16:10)}return zf(r)||t}const Av={}.hasOwnProperty;function LC(t,i,r){return i&&typeof i=="object"&&(r=i,i=void 0),BC(r)(zC(RC(r).document().write(_C()(t,i,!0))))}function BC(t){const i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(Ie),autolinkProtocol:H,autolinkEmail:H,atxHeading:d(ot),blockQuote:d(ve),characterEscape:H,characterReference:H,codeFenced:d(De),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:d(De,c),codeText:d(ze,c),codeTextData:H,data:H,codeFlowValue:H,definition:d(_e),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:d(qe),hardBreakEscape:d($e),hardBreakTrailing:d($e),htmlFlow:d(At,c),htmlFlowData:H,htmlText:d(At,c),htmlTextData:H,image:d(ut),label:c,link:d(Ie),listItem:d(Ye),listItemValue:v,listOrdered:d(Lt,b),listUnordered:d(Lt),paragraph:d(rt),reference:E,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:d(ot),strong:d(Tt),thematicBreak:d(ct)},exit:{atxHeading:p(),atxHeadingSequence:se,autolink:p(),autolinkEmail:Y,autolinkProtocol:ge,blockQuote:p(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:be,characterReferenceMarkerNumeric:be,characterReferenceValue:Z,characterReference:ne,codeFenced:p(C),codeFencedFence:R,codeFencedFenceInfo:x,codeFencedFenceMeta:j,codeFlowValue:A,codeIndented:p(T),codeText:p(ee),codeTextData:A,data:A,definition:p(),definitionDestinationString:q,definitionLabelString:_,definitionTitleString:D,emphasis:p(),hardBreakEscape:p(L),hardBreakTrailing:p(L),htmlFlow:p(P),htmlFlowData:A,htmlText:p(W),htmlTextData:A,image:p(B),label:fe,labelText:Q,lineEnding:I,link:p(G),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:J,resourceDestinationString:k,resourceTitleString:O,resource:le,setextHeading:p(X),setextHeadingLineSequence:U,setextHeadingText:N,strong:p(),thematicBreak:p()}};Tv(i,(t||{}).mdastExtensions||[]);const r={};return a;function a(M){let ie={type:"root",children:[]};const ye={stack:[ie],tokenStack:[],config:i,enter:h,exit:m,buffer:c,resume:y,data:r},xe=[];let Ne=-1;for(;++Ne<M.length;)if(M[Ne][1].type==="listOrdered"||M[Ne][1].type==="listUnordered")if(M[Ne][0]==="enter")xe.push(Ne);else{const Te=xe.pop();Ne=u(M,Te,Ne)}for(Ne=-1;++Ne<M.length;){const Te=i[M[Ne][0]];Av.call(Te,M[Ne][1].type)&&Te[M[Ne][1].type].call(Object.assign({sliceSerialize:M[Ne][2].sliceSerialize},ye),M[Ne][1])}if(ye.tokenStack.length>0){const Te=ye.tokenStack[ye.tokenStack.length-1];(Te[1]||tb).call(ye,void 0,Te[0])}for(ie.position={start:Ki(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Ki(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},Ne=-1;++Ne<i.transforms.length;)ie=i.transforms[Ne](ie)||ie;return ie}function u(M,ie,ye){let xe=ie-1,Ne=-1,Te=!1,Fe,mt,dt,ft;for(;++xe<=ye;){const tt=M[xe];switch(tt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{tt[0]==="enter"?Ne++:Ne--,ft=void 0;break}case"lineEndingBlank":{tt[0]==="enter"&&(Fe&&!ft&&!Ne&&!dt&&(dt=xe),ft=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ft=void 0}if(!Ne&&tt[0]==="enter"&&tt[1].type==="listItemPrefix"||Ne===-1&&tt[0]==="exit"&&(tt[1].type==="listUnordered"||tt[1].type==="listOrdered")){if(Fe){let Bt=xe;for(mt=void 0;Bt--;){const yt=M[Bt];if(yt[1].type==="lineEnding"||yt[1].type==="lineEndingBlank"){if(yt[0]==="exit")continue;mt&&(M[mt][1].type="lineEndingBlank",Te=!0),yt[1].type="lineEnding",mt=Bt}else if(!(yt[1].type==="linePrefix"||yt[1].type==="blockQuotePrefix"||yt[1].type==="blockQuotePrefixWhitespace"||yt[1].type==="blockQuoteMarker"||yt[1].type==="listItemIndent"))break}dt&&(!mt||dt<mt)&&(Fe._spread=!0),Fe.end=Object.assign({},mt?M[mt][1].start:tt[1].end),M.splice(mt||xe,0,["exit",Fe,tt[2]]),xe++,ye++}if(tt[1].type==="listItemPrefix"){const Bt={type:"listItem",_spread:!1,start:Object.assign({},tt[1].start),end:void 0};Fe=Bt,M.splice(xe,0,["enter",Bt,tt[2]]),xe++,ye++,dt=void 0,ft=!0}}}return M[ie][1]._spread=Te,ye}function d(M,ie){return ye;function ye(xe){h.call(this,M(xe),xe),ie&&ie.call(this,xe)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(M,ie,ye){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([ie,ye||void 0]),M.position={start:Ki(ie.start),end:void 0}}function p(M){return ie;function ie(ye){M&&M.call(this,ye),m.call(this,ye)}}function m(M,ie){const ye=this.stack.pop(),xe=this.tokenStack.pop();if(xe)xe[0].type!==M.type&&(ie?ie.call(this,M,xe[0]):(xe[1]||tb).call(this,M,xe[0]));else throw new Error("Cannot close `"+M.type+"` ("+ka({start:M.start,end:M.end})+"): it’s not open");ye.position.end=Ki(M.end)}function y(){return Rf(this.stack.pop())}function b(){this.data.expectingFirstListItemValue=!0}function v(M){if(this.data.expectingFirstListItemValue){const ie=this.stack[this.stack.length-2];ie.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function x(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.lang=M}function j(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.meta=M}function R(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function T(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M.replace(/(\r?\n|\r)$/g,"")}function _(M){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.label=ie,ye.identifier=$n(this.sliceSerialize(M)).toLowerCase()}function D(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.title=M}function q(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.url=M}function se(M){const ie=this.stack[this.stack.length-1];if(!ie.depth){const ye=this.sliceSerialize(M).length;ie.depth=ye}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function U(M){const ie=this.stack[this.stack.length-1];ie.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function X(){this.data.setextHeadingSlurpLineEnding=void 0}function H(M){const ye=this.stack[this.stack.length-1].children;let xe=ye[ye.length-1];(!xe||xe.type!=="text")&&(xe=He(),xe.position={start:Ki(M.start),end:void 0},ye.push(xe)),this.stack.push(xe)}function A(M){const ie=this.stack.pop();ie.value+=this.sliceSerialize(M),ie.position.end=Ki(M.end)}function I(M){const ie=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=ie.children[ie.children.length-1];ye.position.end=Ki(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(ie.type)&&(H.call(this,M),A.call(this,M))}function L(){this.data.atHardBreak=!0}function P(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M}function W(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M}function ee(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M}function G(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const ie=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=ie,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function B(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const ie=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=ie,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function Q(M){const ie=this.sliceSerialize(M),ye=this.stack[this.stack.length-2];ye.label=MC(ie),ye.identifier=$n(ie).toLowerCase()}function fe(){const M=this.stack[this.stack.length-1],ie=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const xe=M.children;ye.children=xe}else ye.alt=ie}function k(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.url=M}function O(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.title=M}function le(){this.data.inReference=void 0}function E(){this.data.referenceType="collapsed"}function J(M){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.label=ie,ye.identifier=$n(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function be(M){this.data.characterReferenceType=M.type}function Z(M){const ie=this.sliceSerialize(M),ye=this.data.characterReferenceType;let xe;ye?(xe=bv(ie,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):xe=zf(ie);const Ne=this.stack[this.stack.length-1];Ne.value+=xe}function ne(M){const ie=this.stack.pop();ie.position.end=Ki(M.end)}function ge(M){A.call(this,M);const ie=this.stack[this.stack.length-1];ie.url=this.sliceSerialize(M)}function Y(M){A.call(this,M);const ie=this.stack[this.stack.length-1];ie.url="mailto:"+this.sliceSerialize(M)}function ve(){return{type:"blockquote",children:[]}}function De(){return{type:"code",lang:null,meta:null,value:""}}function ze(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function qe(){return{type:"emphasis",children:[]}}function ot(){return{type:"heading",depth:0,children:[]}}function $e(){return{type:"break"}}function At(){return{type:"html",value:""}}function ut(){return{type:"image",title:null,url:"",alt:null}}function Ie(){return{type:"link",title:null,url:"",children:[]}}function Lt(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Ye(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function rt(){return{type:"paragraph",children:[]}}function Tt(){return{type:"strong",children:[]}}function He(){return{type:"text",value:""}}function ct(){return{type:"thematicBreak"}}}function Ki(t){return{line:t.line,column:t.column,offset:t.offset}}function Tv(t,i){let r=-1;for(;++r<i.length;){const a=i[r];Array.isArray(a)?Tv(t,a):UC(t,a)}}function UC(t,i){let r;for(r in i)if(Av.call(i,r))switch(r){case"canContainEols":{const a=i[r];a&&t[r].push(...a);break}case"transforms":{const a=i[r];a&&t[r].push(...a);break}case"enter":case"exit":{const a=i[r];a&&Object.assign(t[r],a);break}}}function tb(t,i){throw t?new Error("Cannot close `"+t.type+"` ("+ka({start:t.start,end:t.end})+"): a different token (`"+i.type+"`, "+ka({start:i.start,end:i.end})+") is open"):new Error("Cannot close document, a token (`"+i.type+"`, "+ka({start:i.start,end:i.end})+") is still open")}function IC(t){const i=this;i.parser=r;function r(a){return LC(a,{...i.data("settings"),...t,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})}}function qC(t,i){const r={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(i),!0)};return t.patch(i,r),t.applyData(i,r)}function HC(t,i){const r={type:"element",tagName:"br",properties:{},children:[]};return t.patch(i,r),[t.applyData(i,r),{type:"text",value:`
|
|
32
|
+
`}]}function GC(t,i){const r=i.value?i.value+`
|
|
33
|
+
`:"",a={},u=i.lang?i.lang.split(/\s+/):[];u.length>0&&(a.className=["language-"+u[0]]);let d={type:"element",tagName:"code",properties:a,children:[{type:"text",value:r}]};return i.meta&&(d.data={meta:i.meta}),t.patch(i,d),d=t.applyData(i,d),d={type:"element",tagName:"pre",properties:{},children:[d]},t.patch(i,d),d}function VC(t,i){const r={type:"element",tagName:"del",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function $C(t,i){const r={type:"element",tagName:"em",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function YC(t,i){const r=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",a=String(i.identifier).toUpperCase(),u=jl(a.toLowerCase()),d=t.footnoteOrder.indexOf(a);let c,h=t.footnoteCounts.get(a);h===void 0?(h=0,t.footnoteOrder.push(a),c=t.footnoteOrder.length):c=d+1,h+=1,t.footnoteCounts.set(a,h);const p={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+u,id:r+"fnref-"+u+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};t.patch(i,p);const m={type:"element",tagName:"sup",properties:{},children:[p]};return t.patch(i,m),t.applyData(i,m)}function FC(t,i){const r={type:"element",tagName:"h"+i.depth,properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function PC(t,i){if(t.options.allowDangerousHtml){const r={type:"raw",value:i.value};return t.patch(i,r),t.applyData(i,r)}}function Rv(t,i){const r=i.referenceType;let a="]";if(r==="collapsed"?a+="[]":r==="full"&&(a+="["+(i.label||i.identifier)+"]"),i.type==="imageReference")return[{type:"text",value:"!["+i.alt+a}];const u=t.all(i),d=u[0];d&&d.type==="text"?d.value="["+d.value:u.unshift({type:"text",value:"["});const c=u[u.length-1];return c&&c.type==="text"?c.value+=a:u.push({type:"text",value:a}),u}function QC(t,i){const r=String(i.identifier).toUpperCase(),a=t.definitionById.get(r);if(!a)return Rv(t,i);const u={src:jl(a.url||""),alt:i.alt};a.title!==null&&a.title!==void 0&&(u.title=a.title);const d={type:"element",tagName:"img",properties:u,children:[]};return t.patch(i,d),t.applyData(i,d)}function XC(t,i){const r={src:jl(i.url)};i.alt!==null&&i.alt!==void 0&&(r.alt=i.alt),i.title!==null&&i.title!==void 0&&(r.title=i.title);const a={type:"element",tagName:"img",properties:r,children:[]};return t.patch(i,a),t.applyData(i,a)}function KC(t,i){const r={type:"text",value:i.value.replace(/\r?\n|\r/g," ")};t.patch(i,r);const a={type:"element",tagName:"code",properties:{},children:[r]};return t.patch(i,a),t.applyData(i,a)}function ZC(t,i){const r=String(i.identifier).toUpperCase(),a=t.definitionById.get(r);if(!a)return Rv(t,i);const u={href:jl(a.url||"")};a.title!==null&&a.title!==void 0&&(u.title=a.title);const d={type:"element",tagName:"a",properties:u,children:t.all(i)};return t.patch(i,d),t.applyData(i,d)}function JC(t,i){const r={href:jl(i.url)};i.title!==null&&i.title!==void 0&&(r.title=i.title);const a={type:"element",tagName:"a",properties:r,children:t.all(i)};return t.patch(i,a),t.applyData(i,a)}function WC(t,i,r){const a=t.all(i),u=r?eE(r):zv(i),d={},c=[];if(typeof i.checked=="boolean"){const y=a[0];let b;y&&y.type==="element"&&y.tagName==="p"?b=y:(b={type:"element",tagName:"p",properties:{},children:[]},a.unshift(b)),b.children.length>0&&b.children.unshift({type:"text",value:" "}),b.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:i.checked,disabled:!0},children:[]}),d.className=["task-list-item"]}let h=-1;for(;++h<a.length;){const y=a[h];(u||h!==0||y.type!=="element"||y.tagName!=="p")&&c.push({type:"text",value:`
|
|
34
|
+
`}),y.type==="element"&&y.tagName==="p"&&!u?c.push(...y.children):c.push(y)}const p=a[a.length-1];p&&(u||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
|
|
35
|
+
`});const m={type:"element",tagName:"li",properties:d,children:c};return t.patch(i,m),t.applyData(i,m)}function eE(t){let i=!1;if(t.type==="list"){i=t.spread||!1;const r=t.children;let a=-1;for(;!i&&++a<r.length;)i=zv(r[a])}return i}function zv(t){const i=t.spread;return i??t.children.length>1}function tE(t,i){const r={},a=t.all(i);let u=-1;for(typeof i.start=="number"&&i.start!==1&&(r.start=i.start);++u<a.length;){const c=a[u];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}const d={type:"element",tagName:i.ordered?"ol":"ul",properties:r,children:t.wrap(a,!0)};return t.patch(i,d),t.applyData(i,d)}function nE(t,i){const r={type:"element",tagName:"p",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function iE(t,i){const r={type:"root",children:t.wrap(t.all(i))};return t.patch(i,r),t.applyData(i,r)}function rE(t,i){const r={type:"element",tagName:"strong",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function lE(t,i){const r=t.all(i),a=r.shift(),u=[];if(a){const c={type:"element",tagName:"thead",properties:{},children:t.wrap([a],!0)};t.patch(i.children[0],c),u.push(c)}if(r.length>0){const c={type:"element",tagName:"tbody",properties:{},children:t.wrap(r,!0)},h=Ef(i.children[1]),p=cv(i.children[i.children.length-1]);h&&p&&(c.position={start:h,end:p}),u.push(c)}const d={type:"element",tagName:"table",properties:{},children:t.wrap(u,!0)};return t.patch(i,d),t.applyData(i,d)}function aE(t,i,r){const a=r?r.children:void 0,d=(a?a.indexOf(i):1)===0?"th":"td",c=r&&r.type==="table"?r.align:void 0,h=c?c.length:i.children.length;let p=-1;const m=[];for(;++p<h;){const b=i.children[p],v={},x=c?c[p]:void 0;x&&(v.align=x);let j={type:"element",tagName:d,properties:v,children:[]};b&&(j.children=t.all(b),t.patch(b,j),j=t.applyData(b,j)),m.push(j)}const y={type:"element",tagName:"tr",properties:{},children:t.wrap(m,!0)};return t.patch(i,y),t.applyData(i,y)}function sE(t,i){const r={type:"element",tagName:"td",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}const nb=9,ib=32;function oE(t){const i=String(t),r=/\r?\n|\r/g;let a=r.exec(i),u=0;const d=[];for(;a;)d.push(rb(i.slice(u,a.index),u>0,!0),a[0]),u=a.index+a[0].length,a=r.exec(i);return d.push(rb(i.slice(u),u>0,!1)),d.join("")}function rb(t,i,r){let a=0,u=t.length;if(i){let d=t.codePointAt(a);for(;d===nb||d===ib;)a++,d=t.codePointAt(a)}if(r){let d=t.codePointAt(u-1);for(;d===nb||d===ib;)u--,d=t.codePointAt(u-1)}return u>a?t.slice(a,u):""}function uE(t,i){const r={type:"text",value:oE(String(i.value))};return t.patch(i,r),t.applyData(i,r)}function cE(t,i){const r={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(i,r),t.applyData(i,r)}const dE={blockquote:qC,break:HC,code:GC,delete:VC,emphasis:$C,footnoteReference:YC,heading:FC,html:PC,imageReference:QC,image:XC,inlineCode:KC,linkReference:ZC,link:JC,listItem:WC,list:tE,paragraph:nE,root:iE,strong:rE,table:lE,tableCell:sE,tableRow:aE,text:uE,thematicBreak:cE,toml:io,yaml:io,definition:io,footnoteDefinition:io};function io(){}const _v=-1,Ao=0,Ea=1,vo=2,Df=3,Mf=4,Of=5,Lf=6,Dv=7,Mv=8,fE=typeof self=="object"?self:globalThis,lb=(t,i)=>{switch(t){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+t)}return new fE[t](i)},hE=(t,i)=>{const r=(u,d)=>(t.set(d,u),u),a=u=>{if(t.has(u))return t.get(u);const[d,c]=i[u];switch(d){case Ao:case _v:return r(c,u);case Ea:{const h=r([],u);for(const p of c)h.push(a(p));return h}case vo:{const h=r({},u);for(const[p,m]of c)h[a(p)]=a(m);return h}case Df:return r(new Date(c),u);case Mf:{const{source:h,flags:p}=c;return r(new RegExp(h,p),u)}case Of:{const h=r(new Map,u);for(const[p,m]of c)h.set(a(p),a(m));return h}case Lf:{const h=r(new Set,u);for(const p of c)h.add(a(p));return h}case Dv:{const{name:h,message:p}=c;return r(lb(h,p),u)}case Mv:return r(BigInt(c),u);case"BigInt":return r(Object(BigInt(c)),u);case"ArrayBuffer":return r(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:h}=new Uint8Array(c);return r(new DataView(h),c)}}return r(lb(d,c),u)};return a},ab=t=>hE(new Map,t)(0),pl="",{toString:pE}={},{keys:mE}=Object,Sa=t=>{const i=typeof t;if(i!=="object"||!t)return[Ao,i];const r=pE.call(t).slice(8,-1);switch(r){case"Array":return[Ea,pl];case"Object":return[vo,pl];case"Date":return[Df,pl];case"RegExp":return[Mf,pl];case"Map":return[Of,pl];case"Set":return[Lf,pl];case"DataView":return[Ea,r]}return r.includes("Array")?[Ea,r]:r.includes("Error")?[Dv,r]:[vo,r]},ro=([t,i])=>t===Ao&&(i==="function"||i==="symbol"),gE=(t,i,r,a)=>{const u=(c,h)=>{const p=a.push(c)-1;return r.set(h,p),p},d=c=>{if(r.has(c))return r.get(c);let[h,p]=Sa(c);switch(h){case Ao:{let y=c;switch(p){case"bigint":h=Mv,y=c.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+p);y=null;break;case"undefined":return u([_v],c)}return u([h,y],c)}case Ea:{if(p){let v=c;return p==="DataView"?v=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(v=new Uint8Array(c)),u([p,[...v]],c)}const y=[],b=u([h,y],c);for(const v of c)y.push(d(v));return b}case vo:{if(p)switch(p){case"BigInt":return u([p,c.toString()],c);case"Boolean":case"Number":case"String":return u([p,c.valueOf()],c)}if(i&&"toJSON"in c)return d(c.toJSON());const y=[],b=u([h,y],c);for(const v of mE(c))(t||!ro(Sa(c[v])))&&y.push([d(v),d(c[v])]);return b}case Df:return u([h,c.toISOString()],c);case Mf:{const{source:y,flags:b}=c;return u([h,{source:y,flags:b}],c)}case Of:{const y=[],b=u([h,y],c);for(const[v,x]of c)(t||!(ro(Sa(v))||ro(Sa(x))))&&y.push([d(v),d(x)]);return b}case Lf:{const y=[],b=u([h,y],c);for(const v of c)(t||!ro(Sa(v)))&&y.push(d(v));return b}}const{message:m}=c;return u([h,{name:p,message:m}],c)};return d},sb=(t,{json:i,lossy:r}={})=>{const a=[];return gE(!(i||r),!!i,new Map,a)(t),a},xo=typeof structuredClone=="function"?(t,i)=>i&&("json"in i||"lossy"in i)?ab(sb(t,i)):structuredClone(t):(t,i)=>ab(sb(t,i));function yE(t,i){const r=[{type:"text",value:"↩"}];return i>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(i)}]}),r}function bE(t,i){return"Back to reference "+(t+1)+(i>1?"-"+i:"")}function vE(t){const i=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=t.options.footnoteBackContent||yE,a=t.options.footnoteBackLabel||bE,u=t.options.footnoteLabel||"Footnotes",d=t.options.footnoteLabelTagName||"h2",c=t.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let p=-1;for(;++p<t.footnoteOrder.length;){const m=t.footnoteById.get(t.footnoteOrder[p]);if(!m)continue;const y=t.all(m),b=String(m.identifier).toUpperCase(),v=jl(b.toLowerCase());let x=0;const j=[],R=t.footnoteCounts.get(b);for(;R!==void 0&&++x<=R;){j.length>0&&j.push({type:"text",value:" "});let _=typeof r=="string"?r:r(p,x);typeof _=="string"&&(_={type:"text",value:_}),j.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+v+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof a=="string"?a:a(p,x),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const C=y[y.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const _=C.children[C.children.length-1];_&&_.type==="text"?_.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...j)}else y.push(...j);const T={type:"element",tagName:"li",properties:{id:i+"fn-"+v},children:t.wrap(y,!0)};t.patch(m,T),h.push(T)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:d,properties:{...xo(c),id:"footnote-label"},children:[{type:"text",value:u}]},{type:"text",value:`
|
|
36
|
+
`},{type:"element",tagName:"ol",properties:{},children:t.wrap(h,!0)},{type:"text",value:`
|
|
37
|
+
`}]}}const To=(function(t){if(t==null)return jE;if(typeof t=="function")return Ro(t);if(typeof t=="object")return Array.isArray(t)?xE(t):wE(t);if(typeof t=="string")return SE(t);throw new Error("Expected function, string, or object as test")});function xE(t){const i=[];let r=-1;for(;++r<t.length;)i[r]=To(t[r]);return Ro(a);function a(...u){let d=-1;for(;++d<i.length;)if(i[d].apply(this,u))return!0;return!1}}function wE(t){const i=t;return Ro(r);function r(a){const u=a;let d;for(d in t)if(u[d]!==i[d])return!1;return!0}}function SE(t){return Ro(i);function i(r){return r&&r.type===t}}function Ro(t){return i;function i(r,a,u){return!!(kE(r)&&t.call(this,r,typeof a=="number"?a:void 0,u||void 0))}}function jE(){return!0}function kE(t){return t!==null&&typeof t=="object"&&"type"in t}const Ov=[],CE=!0,tf=!1,EE="skip";function Lv(t,i,r,a){let u;typeof i=="function"&&typeof r!="function"?(a=r,r=i):u=i;const d=To(u),c=a?-1:1;h(t,void 0,[])();function h(p,m,y){const b=p&&typeof p=="object"?p:{};if(typeof b.type=="string"){const x=typeof b.tagName=="string"?b.tagName:typeof b.name=="string"?b.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(p.type+(x?"<"+x+">":""))+")"})}return v;function v(){let x=Ov,j,R,C;if((!i||d(p,m,y[y.length-1]||void 0))&&(x=NE(r(p,y)),x[0]===tf))return x;if("children"in p&&p.children){const T=p;if(T.children&&x[0]!==EE)for(R=(a?T.children.length:-1)+c,C=y.concat(T);R>-1&&R<T.children.length;){const _=T.children[R];if(j=h(_,R,C)(),j[0]===tf)return j;R=typeof j[1]=="number"?j[1]:R+c}}return x}}}function NE(t){return Array.isArray(t)?t:typeof t=="number"?[CE,t]:t==null?Ov:[t]}function Bf(t,i,r,a){let u,d,c;typeof i=="function"&&typeof r!="function"?(d=void 0,c=i,u=r):(d=i,c=r,u=a),Lv(t,d,h,u);function h(p,m){const y=m[m.length-1],b=y?y.children.indexOf(p):void 0;return c(p,b,y)}}const nf={}.hasOwnProperty,AE={};function TE(t,i){const r=i||AE,a=new Map,u=new Map,d=new Map,c={...dE,...r.handlers},h={all:m,applyData:zE,definitionById:a,footnoteById:u,footnoteCounts:d,footnoteOrder:[],handlers:c,one:p,options:r,patch:RE,wrap:DE};return Bf(t,function(y){if(y.type==="definition"||y.type==="footnoteDefinition"){const b=y.type==="definition"?a:u,v=String(y.identifier).toUpperCase();b.has(v)||b.set(v,y)}}),h;function p(y,b){const v=y.type,x=h.handlers[v];if(nf.call(h.handlers,v)&&x)return x(h,y,b);if(h.options.passThrough&&h.options.passThrough.includes(v)){if("children"in y){const{children:R,...C}=y,T=xo(C);return T.children=h.all(y),T}return xo(y)}return(h.options.unknownHandler||_E)(h,y,b)}function m(y){const b=[];if("children"in y){const v=y.children;let x=-1;for(;++x<v.length;){const j=h.one(v[x],y);if(j){if(x&&v[x-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=ob(j.value)),!Array.isArray(j)&&j.type==="element")){const R=j.children[0];R&&R.type==="text"&&(R.value=ob(R.value))}Array.isArray(j)?b.push(...j):b.push(j)}}}return b}}function RE(t,i){t.position&&(i.position=yj(t))}function zE(t,i){let r=i;if(t&&t.data){const a=t.data.hName,u=t.data.hChildren,d=t.data.hProperties;if(typeof a=="string")if(r.type==="element")r.tagName=a;else{const c="children"in r?r.children:[r];r={type:"element",tagName:a,properties:{},children:c}}r.type==="element"&&d&&Object.assign(r.properties,xo(d)),"children"in r&&r.children&&u!==null&&u!==void 0&&(r.children=u)}return r}function _E(t,i){const r=i.data||{},a="value"in i&&!(nf.call(r,"hProperties")||nf.call(r,"hChildren"))?{type:"text",value:i.value}:{type:"element",tagName:"div",properties:{},children:t.all(i)};return t.patch(i,a),t.applyData(i,a)}function DE(t,i){const r=[];let a=-1;for(i&&r.push({type:"text",value:`
|
|
38
|
+
`});++a<t.length;)a&&r.push({type:"text",value:`
|
|
39
|
+
`}),r.push(t[a]);return i&&t.length>0&&r.push({type:"text",value:`
|
|
40
|
+
`}),r}function ob(t){let i=0,r=t.charCodeAt(i);for(;r===9||r===32;)i++,r=t.charCodeAt(i);return t.slice(i)}function ub(t,i){const r=TE(t,i),a=r.one(t,void 0),u=vE(r),d=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return u&&d.children.push({type:"text",value:`
|
|
41
|
+
`},u),d}function ME(t,i){return t&&"run"in t?async function(r,a){const u=ub(r,{file:a,...i});await t.run(u,a)}:function(r,a){return ub(r,{file:a,...t||i})}}function cb(t){if(t)throw t}var Rd,db;function OE(){if(db)return Rd;db=1;var t=Object.prototype.hasOwnProperty,i=Object.prototype.toString,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,u=function(m){return typeof Array.isArray=="function"?Array.isArray(m):i.call(m)==="[object Array]"},d=function(m){if(!m||i.call(m)!=="[object Object]")return!1;var y=t.call(m,"constructor"),b=m.constructor&&m.constructor.prototype&&t.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!y&&!b)return!1;var v;for(v in m);return typeof v>"u"||t.call(m,v)},c=function(m,y){r&&y.name==="__proto__"?r(m,y.name,{enumerable:!0,configurable:!0,value:y.newValue,writable:!0}):m[y.name]=y.newValue},h=function(m,y){if(y==="__proto__")if(t.call(m,y)){if(a)return a(m,y).value}else return;return m[y]};return Rd=function p(){var m,y,b,v,x,j,R=arguments[0],C=1,T=arguments.length,_=!1;for(typeof R=="boolean"&&(_=R,R=arguments[1]||{},C=2),(R==null||typeof R!="object"&&typeof R!="function")&&(R={});C<T;++C)if(m=arguments[C],m!=null)for(y in m)b=h(R,y),v=h(m,y),R!==v&&(_&&v&&(d(v)||(x=u(v)))?(x?(x=!1,j=b&&u(b)?b:[]):j=b&&d(b)?b:{},c(R,{name:y,newValue:p(_,j,v)})):typeof v<"u"&&c(R,{name:y,newValue:v}));return R},Rd}var LE=OE();const zd=jo(LE);function rf(t){if(typeof t!="object"||t===null)return!1;const i=Object.getPrototypeOf(t);return(i===null||i===Object.prototype||Object.getPrototypeOf(i)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function BE(){const t=[],i={run:r,use:a};return i;function r(...u){let d=-1;const c=u.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);h(null,...u);function h(p,...m){const y=t[++d];let b=-1;if(p){c(p);return}for(;++b<u.length;)(m[b]===null||m[b]===void 0)&&(m[b]=u[b]);u=m,y?UE(y,h)(...m):c(null,...m)}}function a(u){if(typeof u!="function")throw new TypeError("Expected `middelware` to be a function, not "+u);return t.push(u),i}}function UE(t,i){let r;return a;function a(...c){const h=t.length>c.length;let p;h&&c.push(u);try{p=t.apply(this,c)}catch(m){const y=m;if(h&&r)throw y;return u(y)}h||(p&&p.then&&typeof p.then=="function"?p.then(d,u):p instanceof Error?u(p):d(p))}function u(c,...h){r||(r=!0,i(c,...h))}function d(c){u(null,c)}}const Jn={basename:IE,dirname:qE,extname:HE,join:GE,sep:"/"};function IE(t,i){if(i!==void 0&&typeof i!="string")throw new TypeError('"ext" argument must be a string');Oa(t);let r=0,a=-1,u=t.length,d;if(i===void 0||i.length===0||i.length>t.length){for(;u--;)if(t.codePointAt(u)===47){if(d){r=u+1;break}}else a<0&&(d=!0,a=u+1);return a<0?"":t.slice(r,a)}if(i===t)return"";let c=-1,h=i.length-1;for(;u--;)if(t.codePointAt(u)===47){if(d){r=u+1;break}}else c<0&&(d=!0,c=u+1),h>-1&&(t.codePointAt(u)===i.codePointAt(h--)?h<0&&(a=u):(h=-1,a=c));return r===a?a=c:a<0&&(a=t.length),t.slice(r,a)}function qE(t){if(Oa(t),t.length===0)return".";let i=-1,r=t.length,a;for(;--r;)if(t.codePointAt(r)===47){if(a){i=r;break}}else a||(a=!0);return i<0?t.codePointAt(0)===47?"/":".":i===1&&t.codePointAt(0)===47?"//":t.slice(0,i)}function HE(t){Oa(t);let i=t.length,r=-1,a=0,u=-1,d=0,c;for(;i--;){const h=t.codePointAt(i);if(h===47){if(c){a=i+1;break}continue}r<0&&(c=!0,r=i+1),h===46?u<0?u=i:d!==1&&(d=1):u>-1&&(d=-1)}return u<0||r<0||d===0||d===1&&u===r-1&&u===a+1?"":t.slice(u,r)}function GE(...t){let i=-1,r;for(;++i<t.length;)Oa(t[i]),t[i]&&(r=r===void 0?t[i]:r+"/"+t[i]);return r===void 0?".":VE(r)}function VE(t){Oa(t);const i=t.codePointAt(0)===47;let r=$E(t,!i);return r.length===0&&!i&&(r="."),r.length>0&&t.codePointAt(t.length-1)===47&&(r+="/"),i?"/"+r:r}function $E(t,i){let r="",a=0,u=-1,d=0,c=-1,h,p;for(;++c<=t.length;){if(c<t.length)h=t.codePointAt(c);else{if(h===47)break;h=47}if(h===47){if(!(u===c-1||d===1))if(u!==c-1&&d===2){if(r.length<2||a!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(p=r.lastIndexOf("/"),p!==r.length-1){p<0?(r="",a=0):(r=r.slice(0,p),a=r.length-1-r.lastIndexOf("/")),u=c,d=0;continue}}else if(r.length>0){r="",a=0,u=c,d=0;continue}}i&&(r=r.length>0?r+"/..":"..",a=2)}else r.length>0?r+="/"+t.slice(u+1,c):r=t.slice(u+1,c),a=c-u-1;u=c,d=0}else h===46&&d>-1?d++:d=-1}return r}function Oa(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const YE={cwd:FE};function FE(){return"/"}function lf(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function PE(t){if(typeof t=="string")t=new URL(t);else if(!lf(t)){const i=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw i.code="ERR_INVALID_ARG_TYPE",i}if(t.protocol!=="file:"){const i=new TypeError("The URL must be of scheme file");throw i.code="ERR_INVALID_URL_SCHEME",i}return QE(t)}function QE(t){if(t.hostname!==""){const a=new TypeError('File URL host must be "localhost" or empty on darwin');throw a.code="ERR_INVALID_FILE_URL_HOST",a}const i=t.pathname;let r=-1;for(;++r<i.length;)if(i.codePointAt(r)===37&&i.codePointAt(r+1)===50){const a=i.codePointAt(r+2);if(a===70||a===102){const u=new TypeError("File URL path must not include encoded / characters");throw u.code="ERR_INVALID_FILE_URL_PATH",u}}return decodeURIComponent(i)}const _d=["history","path","basename","stem","extname","dirname"];class Bv{constructor(i){let r;i?lf(i)?r={path:i}:typeof i=="string"||XE(i)?r={value:i}:r=i:r={},this.cwd="cwd"in r?"":YE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<_d.length;){const d=_d[a];d in r&&r[d]!==void 0&&r[d]!==null&&(this[d]=d==="history"?[...r[d]]:r[d])}let u;for(u in r)_d.includes(u)||(this[u]=r[u])}get basename(){return typeof this.path=="string"?Jn.basename(this.path):void 0}set basename(i){Md(i,"basename"),Dd(i,"basename"),this.path=Jn.join(this.dirname||"",i)}get dirname(){return typeof this.path=="string"?Jn.dirname(this.path):void 0}set dirname(i){fb(this.basename,"dirname"),this.path=Jn.join(i||"",this.basename)}get extname(){return typeof this.path=="string"?Jn.extname(this.path):void 0}set extname(i){if(Dd(i,"extname"),fb(this.dirname,"extname"),i){if(i.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(i.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Jn.join(this.dirname,this.stem+(i||""))}get path(){return this.history[this.history.length-1]}set path(i){lf(i)&&(i=PE(i)),Md(i,"path"),this.path!==i&&this.history.push(i)}get stem(){return typeof this.path=="string"?Jn.basename(this.path,this.extname):void 0}set stem(i){Md(i,"stem"),Dd(i,"stem"),this.path=Jn.join(this.dirname||"",i+(this.extname||""))}fail(i,r,a){const u=this.message(i,r,a);throw u.fatal=!0,u}info(i,r,a){const u=this.message(i,r,a);return u.fatal=void 0,u}message(i,r,a){const u=new sn(i,r,a);return this.path&&(u.name=this.path+":"+u.name,u.file=this.path),u.fatal=!1,this.messages.push(u),u}toString(i){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(i||void 0).decode(this.value)}}function Dd(t,i){if(t&&t.includes(Jn.sep))throw new Error("`"+i+"` cannot be a path: did not expect `"+Jn.sep+"`")}function Md(t,i){if(!t)throw new Error("`"+i+"` cannot be empty")}function fb(t,i){if(!t)throw new Error("Setting `"+i+"` requires `path` to be set too")}function XE(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const KE=(function(t){const a=this.constructor.prototype,u=a[t],d=function(){return u.apply(d,arguments)};return Object.setPrototypeOf(d,a),d}),ZE={}.hasOwnProperty;class Uf extends KE{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=BE()}copy(){const i=new Uf;let r=-1;for(;++r<this.attachers.length;){const a=this.attachers[r];i.use(...a)}return i.data(zd(!0,{},this.namespace)),i}data(i,r){return typeof i=="string"?arguments.length===2?(Bd("data",this.frozen),this.namespace[i]=r,this):ZE.call(this.namespace,i)&&this.namespace[i]||void 0:i?(Bd("data",this.frozen),this.namespace=i,this):this.namespace}freeze(){if(this.frozen)return this;const i=this;for(;++this.freezeIndex<this.attachers.length;){const[r,...a]=this.attachers[this.freezeIndex];if(a[0]===!1)continue;a[0]===!0&&(a[0]=void 0);const u=r.call(i,...a);typeof u=="function"&&this.transformers.use(u)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(i){this.freeze();const r=lo(i),a=this.parser||this.Parser;return Od("parse",a),a(String(r),r)}process(i,r){const a=this;return this.freeze(),Od("process",this.parser||this.Parser),Ld("process",this.compiler||this.Compiler),r?u(void 0,r):new Promise(u);function u(d,c){const h=lo(i),p=a.parse(h);a.run(p,h,function(y,b,v){if(y||!b||!v)return m(y);const x=b,j=a.stringify(x,v);eN(j)?v.value=j:v.result=j,m(y,v)});function m(y,b){y||!b?c(y):d?d(b):r(void 0,b)}}}processSync(i){let r=!1,a;return this.freeze(),Od("processSync",this.parser||this.Parser),Ld("processSync",this.compiler||this.Compiler),this.process(i,u),pb("processSync","process",r),a;function u(d,c){r=!0,cb(d),a=c}}run(i,r,a){hb(i),this.freeze();const u=this.transformers;return!a&&typeof r=="function"&&(a=r,r=void 0),a?d(void 0,a):new Promise(d);function d(c,h){const p=lo(r);u.run(i,p,m);function m(y,b,v){const x=b||i;y?h(y):c?c(x):a(void 0,x,v)}}}runSync(i,r){let a=!1,u;return this.run(i,r,d),pb("runSync","run",a),u;function d(c,h){cb(c),u=h,a=!0}}stringify(i,r){this.freeze();const a=lo(r),u=this.compiler||this.Compiler;return Ld("stringify",u),hb(i),u(i,a)}use(i,...r){const a=this.attachers,u=this.namespace;if(Bd("use",this.frozen),i!=null)if(typeof i=="function")p(i,r);else if(typeof i=="object")Array.isArray(i)?h(i):c(i);else throw new TypeError("Expected usable value, not `"+i+"`");return this;function d(m){if(typeof m=="function")p(m,[]);else if(typeof m=="object")if(Array.isArray(m)){const[y,...b]=m;p(y,b)}else c(m);else throw new TypeError("Expected usable value, not `"+m+"`")}function c(m){if(!("plugins"in m)&&!("settings"in m))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");h(m.plugins),m.settings&&(u.settings=zd(!0,u.settings,m.settings))}function h(m){let y=-1;if(m!=null)if(Array.isArray(m))for(;++y<m.length;){const b=m[y];d(b)}else throw new TypeError("Expected a list of plugins, not `"+m+"`")}function p(m,y){let b=-1,v=-1;for(;++b<a.length;)if(a[b][0]===m){v=b;break}if(v===-1)a.push([m,...y]);else if(y.length>0){let[x,...j]=y;const R=a[v][1];rf(R)&&rf(x)&&(x=zd(!0,R,x)),a[v]=[m,x,...j]}}}}const JE=new Uf().freeze();function Od(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function Ld(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Bd(t,i){if(i)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function hb(t){if(!rf(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function pb(t,i,r){if(!r)throw new Error("`"+t+"` finished async. Use `"+i+"` instead")}function lo(t){return WE(t)?t:new Bv(t)}function WE(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function eN(t){return typeof t=="string"||tN(t)}function tN(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const nN="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",mb=[],gb={allowDangerousHtml:!0},iN=/^(https?|ircs?|mailto|xmpp)$/i,rN=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function lN(t){const i=aN(t),r=sN(t);return oN(i.runSync(i.parse(r),r),t)}function aN(t){const i=t.rehypePlugins||mb,r=t.remarkPlugins||mb,a=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...gb}:gb;return JE().use(IC).use(r).use(ME,a).use(i)}function sN(t){const i=t.children||"",r=new Bv;return typeof i=="string"&&(r.value=i),r}function oN(t,i){const r=i.allowedElements,a=i.allowElement,u=i.components,d=i.disallowedElements,c=i.skipHtml,h=i.unwrapDisallowed,p=i.urlTransform||uN;for(const y of rN)Object.hasOwn(i,y.from)&&(""+y.from+(y.to?"use `"+y.to+"` instead":"remove it")+nN+y.id,void 0);return i.className&&(t={type:"element",tagName:"div",properties:{className:i.className},children:t.type==="root"?t.children:[t]}),Bf(t,m),Sj(t,{Fragment:s.Fragment,components:u,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function m(y,b,v){if(y.type==="raw"&&v&&typeof b=="number")return c?v.children.splice(b,1):v.children[b]={type:"text",value:y.value},b;if(y.type==="element"){let x;for(x in Nd)if(Object.hasOwn(Nd,x)&&Object.hasOwn(y.properties,x)){const j=y.properties[x],R=Nd[x];(R===null||R.includes(y.tagName))&&(y.properties[x]=p(String(j||""),x,y))}}if(y.type==="element"){let x=r?!r.includes(y.tagName):d?d.includes(y.tagName):!1;if(!x&&a&&typeof b=="number"&&(x=!a(y,b,v)),x&&v&&typeof b=="number")return h&&y.children?v.children.splice(b,1,...y.children):v.children.splice(b,1),b}}}function uN(t){const i=t.indexOf(":"),r=t.indexOf("?"),a=t.indexOf("#"),u=t.indexOf("/");return i===-1||u!==-1&&i>u||r!==-1&&i>r||a!==-1&&i>a||iN.test(t.slice(0,i))?t:""}function yb(t,i){const r=String(t);if(typeof i!="string")throw new TypeError("Expected character");let a=0,u=r.indexOf(i);for(;u!==-1;)a++,u=r.indexOf(i,u+i.length);return a}function cN(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function dN(t,i,r){const u=To((r||{}).ignore||[]),d=fN(i);let c=-1;for(;++c<d.length;)Lv(t,"text",h);function h(m,y){let b=-1,v;for(;++b<y.length;){const x=y[b],j=v?v.children:void 0;if(u(x,j?j.indexOf(x):void 0,v))return;v=x}if(v)return p(m,y)}function p(m,y){const b=y[y.length-1],v=d[c][0],x=d[c][1];let j=0;const C=b.children.indexOf(m);let T=!1,_=[];v.lastIndex=0;let D=v.exec(m.value);for(;D;){const q=D.index,se={index:D.index,input:D.input,stack:[...y,m]};let N=x(...D,se);if(typeof N=="string"&&(N=N.length>0?{type:"text",value:N}:void 0),N===!1?v.lastIndex=q+1:(j!==q&&_.push({type:"text",value:m.value.slice(j,q)}),Array.isArray(N)?_.push(...N):N&&_.push(N),j=q+D[0].length,T=!0),!v.global)break;D=v.exec(m.value)}return T?(j<m.value.length&&_.push({type:"text",value:m.value.slice(j)}),b.children.splice(C,1,..._)):_=[m],C+_.length}}function fN(t){const i=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const r=!t[0]||Array.isArray(t[0])?t:[t];let a=-1;for(;++a<r.length;){const u=r[a];i.push([hN(u[0]),pN(u[1])])}return i}function hN(t){return typeof t=="string"?new RegExp(cN(t),"g"):t}function pN(t){return typeof t=="function"?t:function(){return t}}const Ud="phrasing",Id=["autolink","link","image","label"];function mN(){return{transforms:[SN],enter:{literalAutolink:yN,literalAutolinkEmail:qd,literalAutolinkHttp:qd,literalAutolinkWww:qd},exit:{literalAutolink:wN,literalAutolinkEmail:xN,literalAutolinkHttp:bN,literalAutolinkWww:vN}}}function gN(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Ud,notInConstruct:Id},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Ud,notInConstruct:Id},{character:":",before:"[ps]",after:"\\/",inConstruct:Ud,notInConstruct:Id}]}}function yN(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function qd(t){this.config.enter.autolinkProtocol.call(this,t)}function bN(t){this.config.exit.autolinkProtocol.call(this,t)}function vN(t){this.config.exit.data.call(this,t);const i=this.stack[this.stack.length-1];i.type,i.url="http://"+this.sliceSerialize(t)}function xN(t){this.config.exit.autolinkEmail.call(this,t)}function wN(t){this.exit(t)}function SN(t){dN(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,jN],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),kN]],{ignore:["link","linkReference"]})}function jN(t,i,r,a,u){let d="";if(!Uv(u)||(/^w/i.test(i)&&(r=i+r,i="",d="http://"),!CN(r)))return!1;const c=EN(r+a);if(!c[0])return!1;const h={type:"link",title:null,url:d+i+c[0],children:[{type:"text",value:i+c[0]}]};return c[1]?[h,{type:"text",value:c[1]}]:h}function kN(t,i,r,a){return!Uv(a,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+i+"@"+r,children:[{type:"text",value:i+"@"+r}]}}function CN(t){const i=t.split(".");return!(i.length<2||i[i.length-1]&&(/_/.test(i[i.length-1])||!/[a-zA-Z\d]/.test(i[i.length-1]))||i[i.length-2]&&(/_/.test(i[i.length-2])||!/[a-zA-Z\d]/.test(i[i.length-2])))}function EN(t){const i=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!i)return[t,void 0];t=t.slice(0,i.index);let r=i[0],a=r.indexOf(")");const u=yb(t,"(");let d=yb(t,")");for(;a!==-1&&u>d;)t+=r.slice(0,a+1),r=r.slice(a+1),a=r.indexOf(")"),d++;return[t,r]}function Uv(t,i){const r=t.input.charCodeAt(t.index-1);return(t.index===0||wr(r)||Eo(r))&&(!i||r!==47)}Iv.peek=ON;function NN(){this.buffer()}function AN(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function TN(){this.buffer()}function RN(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function zN(t){const i=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=$n(this.sliceSerialize(t)).toLowerCase(),r.label=i}function _N(t){this.exit(t)}function DN(t){const i=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=$n(this.sliceSerialize(t)).toLowerCase(),r.label=i}function MN(t){this.exit(t)}function ON(){return"["}function Iv(t,i,r,a){const u=r.createTracker(a);let d=u.move("[^");const c=r.enter("footnoteReference"),h=r.enter("reference");return d+=u.move(r.safe(r.associationId(t),{after:"]",before:d})),h(),c(),d+=u.move("]"),d}function LN(){return{enter:{gfmFootnoteCallString:NN,gfmFootnoteCall:AN,gfmFootnoteDefinitionLabelString:TN,gfmFootnoteDefinition:RN},exit:{gfmFootnoteCallString:zN,gfmFootnoteCall:_N,gfmFootnoteDefinitionLabelString:DN,gfmFootnoteDefinition:MN}}}function BN(t){let i=!1;return t&&t.firstLineBlank&&(i=!0),{handlers:{footnoteDefinition:r,footnoteReference:Iv},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(a,u,d,c){const h=d.createTracker(c);let p=h.move("[^");const m=d.enter("footnoteDefinition"),y=d.enter("label");return p+=h.move(d.safe(d.associationId(a),{before:p,after:"]"})),y(),p+=h.move("]:"),a.children&&a.children.length>0&&(h.shift(4),p+=h.move((i?`
|
|
42
|
+
`:" ")+d.indentLines(d.containerFlow(a,h.current()),i?qv:UN))),m(),p}}function UN(t,i,r){return i===0?t:qv(t,i,r)}function qv(t,i,r){return(r?"":" ")+t}const IN=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Hv.peek=$N;function qN(){return{canContainEols:["delete"],enter:{strikethrough:GN},exit:{strikethrough:VN}}}function HN(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:IN}],handlers:{delete:Hv}}}function GN(t){this.enter({type:"delete",children:[]},t)}function VN(t){this.exit(t)}function Hv(t,i,r,a){const u=r.createTracker(a),d=r.enter("strikethrough");let c=u.move("~~");return c+=r.containerPhrasing(t,{...u.current(),before:c,after:"~"}),c+=u.move("~~"),d(),c}function $N(){return"~"}function YN(t){return t.length}function FN(t,i){const r=i||{},a=(r.align||[]).concat(),u=r.stringLength||YN,d=[],c=[],h=[],p=[];let m=0,y=-1;for(;++y<t.length;){const R=[],C=[];let T=-1;for(t[y].length>m&&(m=t[y].length);++T<t[y].length;){const _=PN(t[y][T]);if(r.alignDelimiters!==!1){const D=u(_);C[T]=D,(p[T]===void 0||D>p[T])&&(p[T]=D)}R.push(_)}c[y]=R,h[y]=C}let b=-1;if(typeof a=="object"&&"length"in a)for(;++b<m;)d[b]=bb(a[b]);else{const R=bb(a);for(;++b<m;)d[b]=R}b=-1;const v=[],x=[];for(;++b<m;){const R=d[b];let C="",T="";R===99?(C=":",T=":"):R===108?C=":":R===114&&(T=":");let _=r.alignDelimiters===!1?1:Math.max(1,p[b]-C.length-T.length);const D=C+"-".repeat(_)+T;r.alignDelimiters!==!1&&(_=C.length+_+T.length,_>p[b]&&(p[b]=_),x[b]=_),v[b]=D}c.splice(1,0,v),h.splice(1,0,x),y=-1;const j=[];for(;++y<c.length;){const R=c[y],C=h[y];b=-1;const T=[];for(;++b<m;){const _=R[b]||"";let D="",q="";if(r.alignDelimiters!==!1){const se=p[b]-(C[b]||0),N=d[b];N===114?D=" ".repeat(se):N===99?se%2?(D=" ".repeat(se/2+.5),q=" ".repeat(se/2-.5)):(D=" ".repeat(se/2),q=D):q=" ".repeat(se)}r.delimiterStart!==!1&&!b&&T.push("|"),r.padding!==!1&&!(r.alignDelimiters===!1&&_==="")&&(r.delimiterStart!==!1||b)&&T.push(" "),r.alignDelimiters!==!1&&T.push(D),T.push(_),r.alignDelimiters!==!1&&T.push(q),r.padding!==!1&&T.push(" "),(r.delimiterEnd!==!1||b!==m-1)&&T.push("|")}j.push(r.delimiterEnd===!1?T.join("").replace(/ +$/,""):T.join(""))}return j.join(`
|
|
43
|
+
`)}function PN(t){return t==null?"":String(t)}function bb(t){const i=typeof t=="string"?t.codePointAt(0):0;return i===67||i===99?99:i===76||i===108?108:i===82||i===114?114:0}function QN(t,i,r,a){const u=r.enter("blockquote"),d=r.createTracker(a);d.move("> "),d.shift(2);const c=r.indentLines(r.containerFlow(t,d.current()),XN);return u(),c}function XN(t,i,r){return">"+(r?"":" ")+t}function KN(t,i){return vb(t,i.inConstruct,!0)&&!vb(t,i.notInConstruct,!1)}function vb(t,i,r){if(typeof i=="string"&&(i=[i]),!i||i.length===0)return r;let a=-1;for(;++a<i.length;)if(t.includes(i[a]))return!0;return!1}function xb(t,i,r,a){let u=-1;for(;++u<r.unsafe.length;)if(r.unsafe[u].character===`
|
|
44
|
+
`&&KN(r.stack,r.unsafe[u]))return/[ \t]/.test(a.before)?"":" ";return`\\
|
|
45
|
+
`}function ZN(t,i){const r=String(t);let a=r.indexOf(i),u=a,d=0,c=0;if(typeof i!="string")throw new TypeError("Expected substring");for(;a!==-1;)a===u?++d>c&&(c=d):d=1,u=a+i.length,a=r.indexOf(i,u);return c}function JN(t,i){return!!(i.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function WN(t){const i=t.options.fence||"`";if(i!=="`"&&i!=="~")throw new Error("Cannot serialize code with `"+i+"` for `options.fence`, expected `` ` `` or `~`");return i}function e2(t,i,r,a){const u=WN(r),d=t.value||"",c=u==="`"?"GraveAccent":"Tilde";if(JN(t,r)){const b=r.enter("codeIndented"),v=r.indentLines(d,t2);return b(),v}const h=r.createTracker(a),p=u.repeat(Math.max(ZN(d,u)+1,3)),m=r.enter("codeFenced");let y=h.move(p);if(t.lang){const b=r.enter(`codeFencedLang${c}`);y+=h.move(r.safe(t.lang,{before:y,after:" ",encode:["`"],...h.current()})),b()}if(t.lang&&t.meta){const b=r.enter(`codeFencedMeta${c}`);y+=h.move(" "),y+=h.move(r.safe(t.meta,{before:y,after:`
|
|
46
|
+
`,encode:["`"],...h.current()})),b()}return y+=h.move(`
|
|
47
|
+
`),d&&(y+=h.move(d+`
|
|
48
|
+
`)),y+=h.move(p),m(),y}function t2(t,i,r){return(r?"":" ")+t}function If(t){const i=t.options.quote||'"';if(i!=='"'&&i!=="'")throw new Error("Cannot serialize title with `"+i+"` for `options.quote`, expected `\"`, or `'`");return i}function n2(t,i,r,a){const u=If(r),d=u==='"'?"Quote":"Apostrophe",c=r.enter("definition");let h=r.enter("label");const p=r.createTracker(a);let m=p.move("[");return m+=p.move(r.safe(r.associationId(t),{before:m,after:"]",...p.current()})),m+=p.move("]: "),h(),!t.url||/[\0- \u007F]/.test(t.url)?(h=r.enter("destinationLiteral"),m+=p.move("<"),m+=p.move(r.safe(t.url,{before:m,after:">",...p.current()})),m+=p.move(">")):(h=r.enter("destinationRaw"),m+=p.move(r.safe(t.url,{before:m,after:t.title?" ":`
|
|
49
|
+
`,...p.current()}))),h(),t.title&&(h=r.enter(`title${d}`),m+=p.move(" "+u),m+=p.move(r.safe(t.title,{before:m,after:u,...p.current()})),m+=p.move(u),h()),c(),m}function i2(t){const i=t.options.emphasis||"*";if(i!=="*"&&i!=="_")throw new Error("Cannot serialize emphasis with `"+i+"` for `options.emphasis`, expected `*`, or `_`");return i}function Ta(t){return"&#x"+t.toString(16).toUpperCase()+";"}function wo(t,i,r){const a=xl(t),u=xl(i);return a===void 0?u===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:u===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:a===1?u===void 0?{inside:!1,outside:!1}:u===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:u===void 0?{inside:!1,outside:!1}:u===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Gv.peek=r2;function Gv(t,i,r,a){const u=i2(r),d=r.enter("emphasis"),c=r.createTracker(a),h=c.move(u);let p=c.move(r.containerPhrasing(t,{after:u,before:h,...c.current()}));const m=p.charCodeAt(0),y=wo(a.before.charCodeAt(a.before.length-1),m,u);y.inside&&(p=Ta(m)+p.slice(1));const b=p.charCodeAt(p.length-1),v=wo(a.after.charCodeAt(0),b,u);v.inside&&(p=p.slice(0,-1)+Ta(b));const x=c.move(u);return d(),r.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},h+p+x}function r2(t,i,r){return r.options.emphasis||"*"}function l2(t,i){let r=!1;return Bf(t,function(a){if("value"in a&&/\r?\n|\r/.test(a.value)||a.type==="break")return r=!0,tf}),!!((!t.depth||t.depth<3)&&Rf(t)&&(i.options.setext||r))}function a2(t,i,r,a){const u=Math.max(Math.min(6,t.depth||1),1),d=r.createTracker(a);if(l2(t,r)){const y=r.enter("headingSetext"),b=r.enter("phrasing"),v=r.containerPhrasing(t,{...d.current(),before:`
|
|
50
|
+
`,after:`
|
|
51
|
+
`});return b(),y(),v+`
|
|
52
|
+
`+(u===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
|
|
53
|
+
`))+1))}const c="#".repeat(u),h=r.enter("headingAtx"),p=r.enter("phrasing");d.move(c+" ");let m=r.containerPhrasing(t,{before:"# ",after:`
|
|
54
|
+
`,...d.current()});return/^[\t ]/.test(m)&&(m=Ta(m.charCodeAt(0))+m.slice(1)),m=m?c+" "+m:c,r.options.closeAtx&&(m+=" "+c),p(),h(),m}Vv.peek=s2;function Vv(t){return t.value||""}function s2(){return"<"}$v.peek=o2;function $v(t,i,r,a){const u=If(r),d=u==='"'?"Quote":"Apostrophe",c=r.enter("image");let h=r.enter("label");const p=r.createTracker(a);let m=p.move("![");return m+=p.move(r.safe(t.alt,{before:m,after:"]",...p.current()})),m+=p.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=r.enter("destinationLiteral"),m+=p.move("<"),m+=p.move(r.safe(t.url,{before:m,after:">",...p.current()})),m+=p.move(">")):(h=r.enter("destinationRaw"),m+=p.move(r.safe(t.url,{before:m,after:t.title?" ":")",...p.current()}))),h(),t.title&&(h=r.enter(`title${d}`),m+=p.move(" "+u),m+=p.move(r.safe(t.title,{before:m,after:u,...p.current()})),m+=p.move(u),h()),m+=p.move(")"),c(),m}function o2(){return"!"}Yv.peek=u2;function Yv(t,i,r,a){const u=t.referenceType,d=r.enter("imageReference");let c=r.enter("label");const h=r.createTracker(a);let p=h.move("![");const m=r.safe(t.alt,{before:p,after:"]",...h.current()});p+=h.move(m+"]["),c();const y=r.stack;r.stack=[],c=r.enter("reference");const b=r.safe(r.associationId(t),{before:p,after:"]",...h.current()});return c(),r.stack=y,d(),u==="full"||!m||m!==b?p+=h.move(b+"]"):u==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function u2(){return"!"}Fv.peek=c2;function Fv(t,i,r){let a=t.value||"",u="`",d=-1;for(;new RegExp("(^|[^`])"+u+"([^`]|$)").test(a);)u+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++d<r.unsafe.length;){const c=r.unsafe[d],h=r.compilePattern(c);let p;if(c.atBreak)for(;p=h.exec(a);){let m=p.index;a.charCodeAt(m)===10&&a.charCodeAt(m-1)===13&&m--,a=a.slice(0,m)+" "+a.slice(p.index+1)}}return u+a+u}function c2(){return"`"}function Pv(t,i){const r=Rf(t);return!!(!i.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(r===t.url||"mailto:"+r===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Qv.peek=d2;function Qv(t,i,r,a){const u=If(r),d=u==='"'?"Quote":"Apostrophe",c=r.createTracker(a);let h,p;if(Pv(t,r)){const y=r.stack;r.stack=[],h=r.enter("autolink");let b=c.move("<");return b+=c.move(r.containerPhrasing(t,{before:b,after:">",...c.current()})),b+=c.move(">"),h(),r.stack=y,b}h=r.enter("link"),p=r.enter("label");let m=c.move("[");return m+=c.move(r.containerPhrasing(t,{before:m,after:"](",...c.current()})),m+=c.move("]("),p(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(p=r.enter("destinationLiteral"),m+=c.move("<"),m+=c.move(r.safe(t.url,{before:m,after:">",...c.current()})),m+=c.move(">")):(p=r.enter("destinationRaw"),m+=c.move(r.safe(t.url,{before:m,after:t.title?" ":")",...c.current()}))),p(),t.title&&(p=r.enter(`title${d}`),m+=c.move(" "+u),m+=c.move(r.safe(t.title,{before:m,after:u,...c.current()})),m+=c.move(u),p()),m+=c.move(")"),h(),m}function d2(t,i,r){return Pv(t,r)?"<":"["}Xv.peek=f2;function Xv(t,i,r,a){const u=t.referenceType,d=r.enter("linkReference");let c=r.enter("label");const h=r.createTracker(a);let p=h.move("[");const m=r.containerPhrasing(t,{before:p,after:"]",...h.current()});p+=h.move(m+"]["),c();const y=r.stack;r.stack=[],c=r.enter("reference");const b=r.safe(r.associationId(t),{before:p,after:"]",...h.current()});return c(),r.stack=y,d(),u==="full"||!m||m!==b?p+=h.move(b+"]"):u==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function f2(){return"["}function qf(t){const i=t.options.bullet||"*";if(i!=="*"&&i!=="+"&&i!=="-")throw new Error("Cannot serialize items with `"+i+"` for `options.bullet`, expected `*`, `+`, or `-`");return i}function h2(t){const i=qf(t),r=t.options.bulletOther;if(!r)return i==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===i)throw new Error("Expected `bullet` (`"+i+"`) and `bulletOther` (`"+r+"`) to be different");return r}function p2(t){const i=t.options.bulletOrdered||".";if(i!=="."&&i!==")")throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOrdered`, expected `.` or `)`");return i}function Kv(t){const i=t.options.rule||"*";if(i!=="*"&&i!=="-"&&i!=="_")throw new Error("Cannot serialize rules with `"+i+"` for `options.rule`, expected `*`, `-`, or `_`");return i}function m2(t,i,r,a){const u=r.enter("list"),d=r.bulletCurrent;let c=t.ordered?p2(r):qf(r);const h=t.ordered?c==="."?")":".":h2(r);let p=i&&r.bulletLastUsed?c===r.bulletLastUsed:!1;if(!t.ordered){const y=t.children?t.children[0]:void 0;if((c==="*"||c==="-")&&y&&(!y.children||!y.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(p=!0),Kv(r)===c&&y){let b=-1;for(;++b<t.children.length;){const v=t.children[b];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(c=h),r.bulletCurrent=c;const m=r.containerFlow(t,a);return r.bulletLastUsed=c,r.bulletCurrent=d,u(),m}function g2(t){const i=t.options.listItemIndent||"one";if(i!=="tab"&&i!=="one"&&i!=="mixed")throw new Error("Cannot serialize items with `"+i+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return i}function y2(t,i,r,a){const u=g2(r);let d=r.bulletCurrent||qf(r);i&&i.type==="list"&&i.ordered&&(d=(typeof i.start=="number"&&i.start>-1?i.start:1)+(r.options.incrementListMarker===!1?0:i.children.indexOf(t))+d);let c=d.length+1;(u==="tab"||u==="mixed"&&(i&&i.type==="list"&&i.spread||t.spread))&&(c=Math.ceil(c/4)*4);const h=r.createTracker(a);h.move(d+" ".repeat(c-d.length)),h.shift(c);const p=r.enter("listItem"),m=r.indentLines(r.containerFlow(t,h.current()),y);return p(),m;function y(b,v,x){return v?(x?"":" ".repeat(c))+b:(x?d:d+" ".repeat(c-d.length))+b}}function b2(t,i,r,a){const u=r.enter("paragraph"),d=r.enter("phrasing"),c=r.containerPhrasing(t,a);return d(),u(),c}const v2=To(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function x2(t,i,r,a){return(t.children.some(function(c){return v2(c)})?r.containerPhrasing:r.containerFlow).call(r,t,a)}function w2(t){const i=t.options.strong||"*";if(i!=="*"&&i!=="_")throw new Error("Cannot serialize strong with `"+i+"` for `options.strong`, expected `*`, or `_`");return i}Zv.peek=S2;function Zv(t,i,r,a){const u=w2(r),d=r.enter("strong"),c=r.createTracker(a),h=c.move(u+u);let p=c.move(r.containerPhrasing(t,{after:u,before:h,...c.current()}));const m=p.charCodeAt(0),y=wo(a.before.charCodeAt(a.before.length-1),m,u);y.inside&&(p=Ta(m)+p.slice(1));const b=p.charCodeAt(p.length-1),v=wo(a.after.charCodeAt(0),b,u);v.inside&&(p=p.slice(0,-1)+Ta(b));const x=c.move(u+u);return d(),r.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},h+p+x}function S2(t,i,r){return r.options.strong||"*"}function j2(t,i,r,a){return r.safe(t.value,a)}function k2(t){const i=t.options.ruleRepetition||3;if(i<3)throw new Error("Cannot serialize rules with repetition `"+i+"` for `options.ruleRepetition`, expected `3` or more");return i}function C2(t,i,r){const a=(Kv(r)+(r.options.ruleSpaces?" ":"")).repeat(k2(r));return r.options.ruleSpaces?a.slice(0,-1):a}const Jv={blockquote:QN,break:xb,code:e2,definition:n2,emphasis:Gv,hardBreak:xb,heading:a2,html:Vv,image:$v,imageReference:Yv,inlineCode:Fv,link:Qv,linkReference:Xv,list:m2,listItem:y2,paragraph:b2,root:x2,strong:Zv,text:j2,thematicBreak:C2};function E2(){return{enter:{table:N2,tableData:wb,tableHeader:wb,tableRow:T2},exit:{codeText:R2,table:A2,tableData:Hd,tableHeader:Hd,tableRow:Hd}}}function N2(t){const i=t._align;this.enter({type:"table",align:i.map(function(r){return r==="none"?null:r}),children:[]},t),this.data.inTable=!0}function A2(t){this.exit(t),this.data.inTable=void 0}function T2(t){this.enter({type:"tableRow",children:[]},t)}function Hd(t){this.exit(t)}function wb(t){this.enter({type:"tableCell",children:[]},t)}function R2(t){let i=this.resume();this.data.inTable&&(i=i.replace(/\\([\\|])/g,z2));const r=this.stack[this.stack.length-1];r.type,r.value=i,this.exit(t)}function z2(t,i){return i==="|"?i:t}function _2(t){const i=t||{},r=i.tableCellPadding,a=i.tablePipeAlign,u=i.stringLength,d=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
55
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:c,tableCell:p,tableRow:h}};function c(x,j,R,C){return m(y(x,R,C),x.align)}function h(x,j,R,C){const T=b(x,R,C),_=m([T]);return _.slice(0,_.indexOf(`
|
|
56
|
+
`))}function p(x,j,R,C){const T=R.enter("tableCell"),_=R.enter("phrasing"),D=R.containerPhrasing(x,{...C,before:d,after:d});return _(),T(),D}function m(x,j){return FN(x,{align:j,alignDelimiters:a,padding:r,stringLength:u})}function y(x,j,R){const C=x.children;let T=-1;const _=[],D=j.enter("table");for(;++T<C.length;)_[T]=b(C[T],j,R);return D(),_}function b(x,j,R){const C=x.children;let T=-1;const _=[],D=j.enter("tableRow");for(;++T<C.length;)_[T]=p(C[T],x,j,R);return D(),_}function v(x,j,R){let C=Jv.inlineCode(x,j,R);return R.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function D2(){return{exit:{taskListCheckValueChecked:Sb,taskListCheckValueUnchecked:Sb,paragraph:O2}}}function M2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:L2}}}function Sb(t){const i=this.stack[this.stack.length-2];i.type,i.checked=t.type==="taskListCheckValueChecked"}function O2(t){const i=this.stack[this.stack.length-2];if(i&&i.type==="listItem"&&typeof i.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const a=r.children[0];if(a&&a.type==="text"){const u=i.children;let d=-1,c;for(;++d<u.length;){const h=u[d];if(h.type==="paragraph"){c=h;break}}c===r&&(a.value=a.value.slice(1),a.value.length===0?r.children.shift():r.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,r.position.start=Object.assign({},a.position.start)))}}this.exit(t)}function L2(t,i,r,a){const u=t.children[0],d=typeof t.checked=="boolean"&&u&&u.type==="paragraph",c="["+(t.checked?"x":" ")+"] ",h=r.createTracker(a);d&&h.move(c);let p=Jv.listItem(t,i,r,{...a,...h.current()});return d&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),p;function m(y){return y+c}}function B2(){return[mN(),LN(),qN(),E2(),D2()]}function U2(t){return{extensions:[gN(),BN(t),HN(),_2(t),M2()]}}const I2={tokenize:Y2,partial:!0},Wv={tokenize:F2,partial:!0},ex={tokenize:P2,partial:!0},tx={tokenize:Q2,partial:!0},q2={tokenize:X2,partial:!0},nx={name:"wwwAutolink",tokenize:V2,previous:rx},ix={name:"protocolAutolink",tokenize:$2,previous:lx},Ci={name:"emailAutolink",tokenize:G2,previous:ax},ei={};function H2(){return{text:ei}}let yr=48;for(;yr<123;)ei[yr]=Ci,yr++,yr===58?yr=65:yr===91&&(yr=97);ei[43]=Ci;ei[45]=Ci;ei[46]=Ci;ei[95]=Ci;ei[72]=[Ci,ix];ei[104]=[Ci,ix];ei[87]=[Ci,nx];ei[119]=[Ci,nx];function G2(t,i,r){const a=this;let u,d;return c;function c(b){return!af(b)||!ax.call(a,a.previous)||Hf(a.events)?r(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),h(b))}function h(b){return af(b)?(t.consume(b),h):b===64?(t.consume(b),p):r(b)}function p(b){return b===46?t.check(q2,y,m)(b):b===45||b===95||an(b)?(d=!0,t.consume(b),p):y(b)}function m(b){return t.consume(b),u=!0,p}function y(b){return d&&u&&un(a.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),i(b)):r(b)}}function V2(t,i,r){const a=this;return u;function u(c){return c!==87&&c!==119||!rx.call(a,a.previous)||Hf(a.events)?r(c):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(I2,t.attempt(Wv,t.attempt(ex,d),r),r)(c))}function d(c){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),i(c)}}function $2(t,i,r){const a=this;let u="",d=!1;return c;function c(b){return(b===72||b===104)&&lx.call(a,a.previous)&&!Hf(a.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),u+=String.fromCodePoint(b),t.consume(b),h):r(b)}function h(b){if(un(b)&&u.length<5)return u+=String.fromCodePoint(b),t.consume(b),h;if(b===58){const v=u.toLowerCase();if(v==="http"||v==="https")return t.consume(b),p}return r(b)}function p(b){return b===47?(t.consume(b),d?m:(d=!0,p)):r(b)}function m(b){return b===null||bo(b)||Nt(b)||wr(b)||Eo(b)?r(b):t.attempt(Wv,t.attempt(ex,y),r)(b)}function y(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),i(b)}}function Y2(t,i,r){let a=0;return u;function u(c){return(c===87||c===119)&&a<3?(a++,t.consume(c),u):c===46&&a===3?(t.consume(c),d):r(c)}function d(c){return c===null?r(c):i(c)}}function F2(t,i,r){let a,u,d;return c;function c(m){return m===46||m===95?t.check(tx,p,h)(m):m===null||Nt(m)||wr(m)||m!==45&&Eo(m)?p(m):(d=!0,t.consume(m),c)}function h(m){return m===95?a=!0:(u=a,a=void 0),t.consume(m),c}function p(m){return u||a||!d?r(m):i(m)}}function P2(t,i){let r=0,a=0;return u;function u(c){return c===40?(r++,t.consume(c),u):c===41&&a<r?d(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?t.check(tx,i,d)(c):c===null||Nt(c)||wr(c)?i(c):(t.consume(c),u)}function d(c){return c===41&&a++,t.consume(c),u}}function Q2(t,i,r){return a;function a(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(t.consume(h),a):h===38?(t.consume(h),d):h===93?(t.consume(h),u):h===60||h===null||Nt(h)||wr(h)?i(h):r(h)}function u(h){return h===null||h===40||h===91||Nt(h)||wr(h)?i(h):a(h)}function d(h){return un(h)?c(h):r(h)}function c(h){return h===59?(t.consume(h),a):un(h)?(t.consume(h),c):r(h)}}function X2(t,i,r){return a;function a(d){return t.consume(d),u}function u(d){return an(d)?r(d):i(d)}}function rx(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Nt(t)}function lx(t){return!un(t)}function ax(t){return!(t===47||af(t))}function af(t){return t===43||t===45||t===46||t===95||an(t)}function Hf(t){let i=t.length,r=!1;for(;i--;){const a=t[i][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){r=!0;break}if(a._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const K2={tokenize:rA,partial:!0};function Z2(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:tA,continuation:{tokenize:nA},exit:iA}},text:{91:{name:"gfmFootnoteCall",tokenize:eA},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:J2,resolveTo:W2}}}}function J2(t,i,r){const a=this;let u=a.events.length;const d=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let c;for(;u--;){const p=a.events[u][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return h;function h(p){if(!c||!c._balanced)return r(p);const m=$n(a.sliceSerialize({start:c.end,end:a.now()}));return m.codePointAt(0)!==94||!d.includes(m.slice(1))?r(p):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(p),t.exit("gfmFootnoteCallLabelMarker"),i(p))}}function W2(t,i){let r=t.length;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},u={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};u.end.column++,u.end.offset++,u.end._bufferIndex++;const d={type:"gfmFootnoteCallString",start:Object.assign({},u.end),end:Object.assign({},t[t.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},d.start),end:Object.assign({},d.end)},h=[t[r+1],t[r+2],["enter",a,i],t[r+3],t[r+4],["enter",u,i],["exit",u,i],["enter",d,i],["enter",c,i],["exit",c,i],["exit",d,i],t[t.length-2],t[t.length-1],["exit",a,i]];return t.splice(r,t.length-r+1,...h),t}function eA(t,i,r){const a=this,u=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let d=0,c;return h;function h(b){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),p}function p(b){return b!==94?r(b):(t.enter("gfmFootnoteCallMarker"),t.consume(b),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",m)}function m(b){if(d>999||b===93&&!c||b===null||b===91||Nt(b))return r(b);if(b===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return u.includes($n(a.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),i):r(b)}return Nt(b)||(c=!0),d++,t.consume(b),b===92?y:m}function y(b){return b===91||b===92||b===93?(t.consume(b),d++,m):m(b)}}function tA(t,i,r){const a=this,u=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let d,c=0,h;return p;function p(j){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(j){return j===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",y):r(j)}function y(j){if(c>999||j===93&&!h||j===null||j===91||Nt(j))return r(j);if(j===93){t.exit("chunkString");const R=t.exit("gfmFootnoteDefinitionLabelString");return d=$n(a.sliceSerialize(R)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return Nt(j)||(h=!0),c++,t.consume(j),j===92?b:y}function b(j){return j===91||j===92||j===93?(t.consume(j),c++,y):y(j)}function v(j){return j===58?(t.enter("definitionMarker"),t.consume(j),t.exit("definitionMarker"),u.includes(d)||u.push(d),st(t,x,"gfmFootnoteDefinitionWhitespace")):r(j)}function x(j){return i(j)}}function nA(t,i,r){return t.check(Ma,i,t.attempt(K2,i,r))}function iA(t){t.exit("gfmFootnoteDefinition")}function rA(t,i,r){const a=this;return st(t,u,"gfmFootnoteDefinitionIndent",5);function u(d){const c=a.events[a.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?i(d):r(d)}}function lA(t){let r=(t||{}).singleTilde;const a={name:"strikethrough",tokenize:d,resolveAll:u};return r==null&&(r=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function u(c,h){let p=-1;for(;++p<c.length;)if(c[p][0]==="enter"&&c[p][1].type==="strikethroughSequenceTemporary"&&c[p][1]._close){let m=p;for(;m--;)if(c[m][0]==="exit"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._open&&c[p][1].end.offset-c[p][1].start.offset===c[m][1].end.offset-c[m][1].start.offset){c[p][1].type="strikethroughSequence",c[m][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[m][1].start),end:Object.assign({},c[p][1].end)},b={type:"strikethroughText",start:Object.assign({},c[m][1].end),end:Object.assign({},c[p][1].start)},v=[["enter",y,h],["enter",c[m][1],h],["exit",c[m][1],h],["enter",b,h]],x=h.parser.constructs.insideSpan.null;x&&En(v,v.length,0,No(x,c.slice(m+1,p),h)),En(v,v.length,0,[["exit",b,h],["enter",c[p][1],h],["exit",c[p][1],h],["exit",y,h]]),En(c,m-1,p-m+3,v),p=m+v.length-2;break}}for(p=-1;++p<c.length;)c[p][1].type==="strikethroughSequenceTemporary"&&(c[p][1].type="data");return c}function d(c,h,p){const m=this.previous,y=this.events;let b=0;return v;function v(j){return m===126&&y[y.length-1][1].type!=="characterEscape"?p(j):(c.enter("strikethroughSequenceTemporary"),x(j))}function x(j){const R=xl(m);if(j===126)return b>1?p(j):(c.consume(j),b++,x);if(b<2&&!r)return p(j);const C=c.exit("strikethroughSequenceTemporary"),T=xl(j);return C._open=!T||T===2&&!!R,C._close=!R||R===2&&!!T,h(j)}}}class aA{constructor(){this.map=[]}add(i,r,a){sA(this,i,r,a)}consume(i){if(this.map.sort(function(d,c){return d[0]-c[0]}),this.map.length===0)return;let r=this.map.length;const a=[];for(;r>0;)r-=1,a.push(i.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),i.length=this.map[r][0];a.push(i.slice()),i.length=0;let u=a.pop();for(;u;){for(const d of u)i.push(d);u=a.pop()}this.map.length=0}}function sA(t,i,r,a){let u=0;if(!(r===0&&a.length===0)){for(;u<t.map.length;){if(t.map[u][0]===i){t.map[u][1]+=r,t.map[u][2].push(...a);return}u+=1}t.map.push([i,r,a])}}function oA(t,i){let r=!1;const a=[];for(;i<t.length;){const u=t[i];if(r){if(u[0]==="enter")u[1].type==="tableContent"&&a.push(t[i+1][1].type==="tableDelimiterMarker"?"left":"none");else if(u[1].type==="tableContent"){if(t[i-1][1].type==="tableDelimiterMarker"){const d=a.length-1;a[d]=a[d]==="left"?"center":"right"}}else if(u[1].type==="tableDelimiterRow")break}else u[0]==="enter"&&u[1].type==="tableDelimiterRow"&&(r=!0);i+=1}return a}function uA(){return{flow:{null:{name:"table",tokenize:cA,resolveAll:dA}}}}function cA(t,i,r){const a=this;let u=0,d=0,c;return h;function h(A){let I=a.events.length-1;for(;I>-1;){const W=a.events[I][1].type;if(W==="lineEnding"||W==="linePrefix")I--;else break}const L=I>-1?a.events[I][1].type:null,P=L==="tableHead"||L==="tableRow"?N:p;return P===N&&a.parser.lazy[a.now().line]?r(A):P(A)}function p(A){return t.enter("tableHead"),t.enter("tableRow"),m(A)}function m(A){return A===124||(c=!0,d+=1),y(A)}function y(A){return A===null?r(A):Le(A)?d>1?(d=0,a.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(A),t.exit("lineEnding"),x):r(A):et(A)?st(t,y,"whitespace")(A):(d+=1,c&&(c=!1,u+=1),A===124?(t.enter("tableCellDivider"),t.consume(A),t.exit("tableCellDivider"),c=!0,y):(t.enter("data"),b(A)))}function b(A){return A===null||A===124||Nt(A)?(t.exit("data"),y(A)):(t.consume(A),A===92?v:b)}function v(A){return A===92||A===124?(t.consume(A),b):b(A)}function x(A){return a.interrupt=!1,a.parser.lazy[a.now().line]?r(A):(t.enter("tableDelimiterRow"),c=!1,et(A)?st(t,j,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):j(A))}function j(A){return A===45||A===58?C(A):A===124?(c=!0,t.enter("tableCellDivider"),t.consume(A),t.exit("tableCellDivider"),R):se(A)}function R(A){return et(A)?st(t,C,"whitespace")(A):C(A)}function C(A){return A===58?(d+=1,c=!0,t.enter("tableDelimiterMarker"),t.consume(A),t.exit("tableDelimiterMarker"),T):A===45?(d+=1,T(A)):A===null||Le(A)?q(A):se(A)}function T(A){return A===45?(t.enter("tableDelimiterFiller"),_(A)):se(A)}function _(A){return A===45?(t.consume(A),_):A===58?(c=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(A),t.exit("tableDelimiterMarker"),D):(t.exit("tableDelimiterFiller"),D(A))}function D(A){return et(A)?st(t,q,"whitespace")(A):q(A)}function q(A){return A===124?j(A):A===null||Le(A)?!c||u!==d?se(A):(t.exit("tableDelimiterRow"),t.exit("tableHead"),i(A)):se(A)}function se(A){return r(A)}function N(A){return t.enter("tableRow"),U(A)}function U(A){return A===124?(t.enter("tableCellDivider"),t.consume(A),t.exit("tableCellDivider"),U):A===null||Le(A)?(t.exit("tableRow"),i(A)):et(A)?st(t,U,"whitespace")(A):(t.enter("data"),X(A))}function X(A){return A===null||A===124||Nt(A)?(t.exit("data"),U(A)):(t.consume(A),A===92?H:X)}function H(A){return A===92||A===124?(t.consume(A),X):X(A)}}function dA(t,i){let r=-1,a=!0,u=0,d=[0,0,0,0],c=[0,0,0,0],h=!1,p=0,m,y,b;const v=new aA;for(;++r<t.length;){const x=t[r],j=x[1];x[0]==="enter"?j.type==="tableHead"?(h=!1,p!==0&&(jb(v,i,p,m,y),y=void 0,p=0),m={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(r,0,[["enter",m,i]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(a=!0,b=void 0,d=[0,0,0,0],c=[0,r+1,0,0],h&&(h=!1,y={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(r,0,[["enter",y,i]])),u=j.type==="tableDelimiterRow"?2:y?3:1):u&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(a=!1,c[2]===0&&(d[1]!==0&&(c[0]=c[1],b=ao(v,i,d,u,void 0,b),d=[0,0,0,0]),c[2]=r)):j.type==="tableCellDivider"&&(a?a=!1:(d[1]!==0&&(c[0]=c[1],b=ao(v,i,d,u,void 0,b)),d=c,c=[d[1],r,0,0])):j.type==="tableHead"?(h=!0,p=r):j.type==="tableRow"||j.type==="tableDelimiterRow"?(p=r,d[1]!==0?(c[0]=c[1],b=ao(v,i,d,u,r,b)):c[1]!==0&&(b=ao(v,i,c,u,r,b)),u=0):u&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(c[3]=r)}for(p!==0&&jb(v,i,p,m,y),v.consume(i.events),r=-1;++r<i.events.length;){const x=i.events[r];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=oA(i.events,r))}return t}function ao(t,i,r,a,u,d){const c=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",h="tableContent";r[0]!==0&&(d.end=Object.assign({},gl(i.events,r[0])),t.add(r[0],0,[["exit",d,i]]));const p=gl(i.events,r[1]);if(d={type:c,start:Object.assign({},p),end:Object.assign({},p)},t.add(r[1],0,[["enter",d,i]]),r[2]!==0){const m=gl(i.events,r[2]),y=gl(i.events,r[3]),b={type:h,start:Object.assign({},m),end:Object.assign({},y)};if(t.add(r[2],0,[["enter",b,i]]),a!==2){const v=i.events[r[2]],x=i.events[r[3]];if(v[1].end=Object.assign({},x[1].end),v[1].type="chunkText",v[1].contentType="text",r[3]>r[2]+1){const j=r[2]+1,R=r[3]-r[2]-1;t.add(j,R,[])}}t.add(r[3]+1,0,[["exit",b,i]])}return u!==void 0&&(d.end=Object.assign({},gl(i.events,u)),t.add(u,0,[["exit",d,i]]),d=void 0),d}function jb(t,i,r,a,u){const d=[],c=gl(i.events,r);u&&(u.end=Object.assign({},c),d.push(["exit",u,i])),a.end=Object.assign({},c),d.push(["exit",a,i]),t.add(r+1,0,d)}function gl(t,i){const r=t[i],a=r[0]==="enter"?"start":"end";return r[1][a]}const fA={name:"tasklistCheck",tokenize:pA};function hA(){return{text:{91:fA}}}function pA(t,i,r){const a=this;return u;function u(p){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?r(p):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(p),t.exit("taskListCheckMarker"),d)}function d(p){return Nt(p)?(t.enter("taskListCheckValueUnchecked"),t.consume(p),t.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(t.enter("taskListCheckValueChecked"),t.consume(p),t.exit("taskListCheckValueChecked"),c):r(p)}function c(p){return p===93?(t.enter("taskListCheckMarker"),t.consume(p),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),h):r(p)}function h(p){return Le(p)?i(p):et(p)?t.check({tokenize:mA},i,r)(p):r(p)}}function mA(t,i,r){return st(t,a,"whitespace");function a(u){return u===null?r(u):i(u)}}function gA(t){return yv([H2(),Z2(),lA(t),uA(),hA()])}const yA={};function bA(t){const i=this,r=t||yA,a=i.data(),u=a.micromarkExtensions||(a.micromarkExtensions=[]),d=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),c=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);u.push(gA(r)),d.push(B2()),c.push(U2(r))}function sf(t){const i=t.trim();if(!(!i||/[\u0000-\u0020\u007f]/.test(i)))try{const r=new URL(i);if(r.protocol==="https:"||r.protocol==="http:"||r.protocol==="mailto:")return i}catch{}}function of(t){return!!t&&!/[\u0000-\u001f\u007f]/.test(t)&&!/^[a-z][a-z\d+.-]*:/i.test(t)&&!t.startsWith("//")}function kb(t){if(!of(t))return;const i=t.split(/[?#]/,1)[0];if(i)try{const r=decodeURIComponent(i);return of(r)?r:void 0}catch{return}}async function vA(t){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(t);return}const i=document.activeElement,r=document.createElement("textarea");r.value=t,r.setAttribute("aria-label","复制内容"),r.style.cssText="position:fixed;left:-10000px;top:0",document.body.append(r);try{if(r.select(),!document.execCommand("copy"))throw new Error("复制不可用")}finally{r.remove(),i instanceof HTMLElement&&i.focus({preventScroll:!0})}}function zo({text:t,label:i="复制"}){const[r,a]=S.useState("idle"),u=S.useRef(!0),d=S.useRef(void 0);S.useEffect(()=>(u.current=!0,()=>{u.current=!1,clearTimeout(d.current)}),[]);const c=async()=>{clearTimeout(d.current);try{await vA(t),u.current&&a("copied")}catch{u.current&&a("error")}u.current&&(d.current=setTimeout(()=>a("idle"),2500))};return s.jsx("button",{className:"message-copy",onClick:()=>{c()},"aria-label":i,title:i,children:r==="copied"?"已复制":r==="error"?"复制失败":i})}function uf(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(uf).join(""):S.isValidElement(t)?uf(t.props.children):""}function xA({children:t}){const i=S.Children.toArray(t).find(d=>S.isValidElement(d)),a=(S.isValidElement(i)?i.props.className??"":"").match(/(?:^|\s)language-([\w+-]+)/)?.[1]??"代码",u=uf(t).replace(/\n$/,"");return s.jsxs("div",{className:"message-code-block",children:[s.jsxs("div",{className:"message-code-heading",children:[s.jsx("span",{children:a}),s.jsx(zo,{text:u,label:"复制代码"})]}),s.jsx("pre",{tabIndex:0,children:t})]})}function wA(t){return{a:({href:i,children:r,title:a})=>{const u=sf(i??"");if(u)return s.jsx("a",{href:u,title:a,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:r});const d=i?kb(i):void 0;return d?s.jsxs("span",{className:"message-file-reference",title:d,children:[t?s.jsx("button",{className:"message-file-open",onClick:()=>t(d),children:r}):r,s.jsx(zo,{text:d,label:"复制路径"})]}):s.jsx("span",{children:r})},img:({src:i,alt:r})=>{const a=sf(typeof i=="string"?i:""),u=typeof i=="string"?kb(i):void 0;return a?s.jsxs("a",{className:"message-image-reference",href:a,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:[r||"图片",s.jsx("span",{children:"打开图片 ↗"})]}):u&&t?s.jsxs("button",{className:"message-image-reference",title:u,onClick:()=>t(u),children:[r||"图片",s.jsx("span",{children:"查看图片"})]}):s.jsxs("span",{className:"message-image-reference",children:[r||"图片",s.jsx("span",{children:"图片路径不可直接访问"})]})},pre:({children:i})=>s.jsx(xA,{children:i}),table:({children:i})=>s.jsx("div",{className:"message-table-scroll",role:"region","aria-label":"表格",tabIndex:0,children:s.jsx("table",{children:i})})}}const SA=S.memo(function({text:i,reasoning:r="",streaming:a=!1,onOpenFile:u}){const d=S.useMemo(()=>wA(u),[u]);return s.jsxs("div",{className:"message-content",children:[r?s.jsxs("details",{className:"message-reasoning",children:[s.jsx("summary",{children:a&&!i?"思考中…":"思考过程"}),s.jsx("pre",{children:r})]}):null,a?s.jsxs("div",{className:"message-streaming",children:[i||(r?"":"正在思考…"),s.jsx("span",{className:"cursor","aria-hidden":"true",children:"▍"})]}):i?s.jsx(lN,{remarkPlugins:[bA],skipHtml:!0,urlTransform:c=>sf(c)??(of(c)?c:""),components:d,children:i}):null,!a&&i?s.jsx("div",{className:"message-actions",children:s.jsx(zo,{text:i,label:"复制回复"})}):null]})});function jA(t){const i=t.args??{},r=t.summary||[i.description,i.command,i.file_path,i.path,i.query,i.url].find(a=>typeof a=="string"&&a.trim());return typeof r=="string"?r.replace(/\s+/g," ").slice(0,180):""}const kA=S.memo(function({item:i,running:r}){const a=jA(i),u=i.done?i.error?"失败":"已完成":r?"执行中":"未完成";return s.jsxs("details",{className:`message-tool-card${i.error?" message-tool-error":""}`,children:[s.jsxs("summary",{children:[s.jsx("span",{className:"message-tool-indicator","aria-hidden":"true",children:i.done?i.error?"!":"✓":"·"}),s.jsx("span",{className:"message-tool-name",children:i.name}),s.jsx("span",{className:"message-tool-summary",children:a}),s.jsx("span",{className:"message-tool-status",children:u})]}),i.args&&Object.keys(i.args).length?s.jsxs("div",{className:"message-tool-section",children:[s.jsx("strong",{children:"参数"}),s.jsx("pre",{tabIndex:0,children:JSON.stringify(i.args,null,2)})]}):null,s.jsxs("div",{className:"message-tool-section",children:[s.jsxs("div",{className:"message-tool-result-heading",children:[s.jsx("strong",{children:"结果"}),i.result?s.jsx(zo,{text:i.result,label:"复制结果"}):null]}),s.jsx("pre",{tabIndex:0,children:i.result??(i.done?"工具没有返回文本内容。":r?"等待工具返回结果…":"这次工具调用没有保存结果。")})]})]})});function CA(t){return{running:"运行中",completed:"已完成",error:"失败",recorded:"历史记录"}[t]??t}function EA(t){const i=new URLSearchParams(t).get("session");return i&&/^[a-zA-Z0-9_-]{1,128}$/.test(i)?i:null}function sx(t,i){return!i||!t.hubEpoch||t.hubSequence===void 0?!0:t.hubEpoch===i.epoch&&t.hubSequence>i.sequence}function Cb(t,i=[]){let r=Xb(t.transcript);for(const u of t.liveStream?.events??[])r=vr(r,u.event);t.running?r={...r,run:"running"}:t.running===!1&&(r.run==="running"||r.run==="waiting")&&(r={...r,run:"idle"});let a=t.streamCursor;for(const u of i)sx(u,a)&&(r=vr(r,u.event),u.hubEpoch&&u.hubSequence!==void 0&&(a={epoch:u.hubEpoch,sequence:u.hubSequence}));return{chat:r,cursor:a,truncated:t.liveStream?.truncated??!1}}async function NA(t,i,r,a,u,d=()=>!0){let c=t.outputJournal??await i({});if(!d())throw new Error("Output recovery cancelled");if(c.status==="unavailable"){const x=u?await u():t.outputCoverage;if(!d())throw new Error("Output recovery cancelled");for(const j of[t.outputCoverage,x])ya({unpaired:j?.unpaired,inputIds:j?.inputIds},{},()=>!1);if(x?.outputCursor||a?.()||r.some(j=>j.event.outputCursor)){if(c=await i({}),c.status==="unavailable")throw new Error("Output recovery journal is unavailable")}else{if(x?.journalIdentity||t.outputCoverage?.journalIdentity)throw new Error("Output recovery journal is unavailable");return null}}if(c.status!=="ok"||!c.legacyBaseThroughEventId||t.transcript[0]?.type!=="session_meta")throw new Error("Output recovery has no complete legacy base");const h=t.transcript.findIndex(x=>x.id===c.legacyBaseThroughEventId);if(h<0)throw new Error("Output recovery legacy anchor was not retained");let p=Xb(t.transcript.slice(0,h+1)),m={incomplete:!1},y=0;const b=async()=>{for(;;){if(!d()||++y>2048)throw new Error("Output recovery exceeded its page budget");const x=iS(m,c,j=>{p=vr(p,j)});if(m.incomplete)throw new Error("Output recovery is incomplete");if(x)break;c=await i({after:m.cursor,through:m.through})}};await b();for(let x=0;x<8;x++){const j=u?await u():t.outputCoverage;if(!d())throw new Error("Output recovery cancelled");ya({...j,inputIds:void 0},c,()=>!0);let R;for(const T of[j?.outputCursor,a?.(),...r.map(_=>_.event.outputCursor)]){if(typeof T!="string")continue;const _=R?ja(T,R):1;if(_===void 0)throw new Error("Output recovery journal changed");_>0&&(R=T)}if(typeof R!="string"){j&&ya(j,c,T=>p.items.some(_=>_.kind==="user"&&_.clientMessageId===T));break}const C=ja(R,m.cursor);if(C===void 0)throw new Error("Output recovery journal changed");if(C<=0){j&&ya(j,c,T=>p.items.some(_=>_.kind==="user"&&_.clientMessageId===T));break}if(x===7)throw new Error("Output recovery could not catch up within its round budget");m={incomplete:!1,cursor:m.appliedCursor},c=await i({after:m.cursor,through:R}),await b()}const v=new Sf;for(const x of r)v.observe(x.event);ya({unpaired:v.incomplete,inputIds:v.inputIds},c,x=>p.items.some(j=>j.kind==="user"&&j.clientMessageId===x),{requireIdentity:!1});for(const x of r){const j=x.event.outputCursor;if(typeof j=="string"){const R=ja(j,m.cursor);if(R===void 0)throw new Error("Output recovery journal changed");if(R<=0)continue;m.cursor=j}else if(x.event.type==="session_title"){p=vr(p,x.event);continue}else{if(x.event.type==="session_user_message"&&typeof x.event.clientMessageId=="string"&&p.items.some(R=>R.kind==="user"&&R.clientMessageId===x.event.clientMessageId))continue;throw new Error("Output recovery received an unpaired legacy event")}p=vr(p,x.event)}return{chat:p,outputCursor:m.cursor}}function ox(t,i){if(t?.title)return t.title;const r=t?.items.find(a=>a.kind==="user");if(r&&r.kind==="user"&&r.text.trim()){const a=r.text.trim().split(`
|
|
57
|
+
`)[0];return a.length>32?`${a.slice(0,32)}…`:a}return r?.kind==="user"&&r.attachments?.length?`附件:${r.attachments[0].name}`:i.slice(0,8)}const AA=["profile","security","sessions","connections"],TA=["users","summary","audit"];function Eb(t){if(t.pathname==="/api/v1/account/manage"||t.pathname==="/settings/account")return{kind:"account",section:"profile"};const i=/^\/settings\/account\/([^/]+)\/?$/.exec(t.pathname);if(i&&AA.includes(i[1]))return{kind:"account",section:i[1]};const r=/^\/admin\/([^/]+)\/?$/.exec(t.pathname);return r&&TA.includes(r[1])?{kind:"admin",section:r[1]}:{kind:"workbench"}}function RA(t,i){const r=new URLSearchParams,a=i.searchParams.get("project"),u=i.searchParams.get("session");vl(a)&&(r.set("project",a),u&&/^[A-Za-z0-9_-]{1,128}$/.test(u)&&r.set("session",u));const d=fo(i);return d.view!=="chat"&&r.set("view",d.view),d.view==="settings"&&d.section!=="overview"&&r.set("section",d.section),(t.kind==="workbench"?"/":t.kind==="account"?`/settings/account/${t.section}`:`/admin/${t.section}`)+(r.size?`?${r}`:"")}function fo(t){const i=t.searchParams.get("view"),r=t.searchParams.get("section");return{view:["history","files","links","panels","settings"].includes(i??"")?i:"chat",section:["models","skills","mcp"].includes(r??"")?r:"overview"}}function zA(t,i){if(i.workspaceKey!==t.workspaceKey||i.sessionId!==t.activeId)throw new Error("当前工作区或对话已经变化,请重新打开面板后发送。");if(t.connection!=="open"||t.loading)throw new Error("工作台尚未连接,请连接后重新发送面板任务。");if(t.readOnly)throw new Error("当前对话为只读,无法发送面板任务。");if(t.running||t.chat.run==="running"||t.chat.run==="waiting"||t.approvals.some(r=>!r.sessionId||r.sessionId===i.sessionId))throw new Error("当前对话仍在处理任务,请完成后再发送面板任务。");if(t.uncertain||t.uploading||t.uploadBusy)throw new Error("当前消息或附件仍在发送,请等待结果后重试。");if(t.draft.length>0||t.files.length>0)throw new Error("当前对话还有草稿或附件,请先处理它们,再发送面板任务。");if(!i.prompt.trim()||i.prompt.length>2e4)throw new Error("面板任务内容无效。");if(t.setDraft(i.prompt),!t.send())throw t.setDraft(""),new Error("当前对话暂时无法接收任务,请稍后重新发送。");return{accepted:!0}}function _A({controller:t,onBackToProjects:i,projectName:r,cloudAccount:a,renderAccountControl:u}){const{connection:d,sessions:c,activeId:h,chat:p,draft:m,files:y,uploading:b,workerNote:v,replayNote:x,error:j,workspaceCwd:R,workspaceName:C,configuration:T,configurationVersion:_,sessionsVersion:D,localDrafts:q,running:se,title:N,approvalCount:U,onAuthLost:X,refreshSessions:H,refreshConfiguration:A,session:I}=t,L=t.workspaceApi,P=t.host==="desktop"?"桌面":"服务端",[W,ee]=S.useState(!1),G=S.useRef(null),B=S.useRef(null),[Q,fe]=S.useState(()=>fo(new URL(window.location.href)).view),[k,O]=S.useState(),[le,E]=S.useState(),[J,be]=S.useState(0),[Z,ne]=S.useState(!1),[ge,Y]=S.useState(null),[ve,De]=S.useState(()=>fo(new URL(window.location.href)).section);S.useEffect(()=>{const K=new URL(window.location.href);Q==="chat"?K.searchParams.delete("view"):K.searchParams.set("view",Q==="panel"?"panels":Q),Q==="settings"&&ve!=="overview"?K.searchParams.set("section",ve):K.searchParams.delete("section"),window.history.replaceState(window.history.state,"",K.pathname+K.search+K.hash)},[Q,ve]),S.useEffect(()=>{const K=()=>{const je=fo(new URL(window.location.href));fe(je.view),De(je.section)};return window.addEventListener("popstate",K),()=>window.removeEventListener("popstate",K)},[]);const[ze,_e]=S.useState(()=>window.matchMedia("(max-width: 760px)").matches),[qe,ot]=S.useState(()=>!window.matchMedia("(max-width: 760px)").matches),$e=S.useRef(null),At=S.useRef(null),ut=S.useRef(!1),Ie=S.useRef(null),Lt=S.useRef(null),Ye=S.useRef(!0);S.useEffect(()=>{O(void 0),fe(K=>K==="panel"?"panels":K)},[t.workspaceKey]),S.useEffect(()=>{ze&&!qe&&ut.current&&!W&&At.current?.focus(),ut.current=qe},[ze,qe,W]),S.useEffect(()=>{const K=window.matchMedia("(max-width: 760px)"),je=()=>{_e(K.matches),ot(!K.matches)};return K.addEventListener("change",je),()=>K.removeEventListener("change",je)},[]),S.useEffect(()=>{if(!ze||!qe)return;const K=$e.current;K?.querySelector("button")?.focus();const je=Ee=>{if(!document.querySelector("dialog[open]")){if(Ee.key==="Escape"&&!Ee.isComposing)Ee.preventDefault(),ot(!1),At.current?.focus();else if(Ee.key==="Tab"){const re=Array.from(K?.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), textarea:not(:disabled), a[href], summary, [tabindex]:not([tabindex="-1"])')??[]).filter(Ce=>Ce.getClientRects().length>0),we=re?.[0],Me=re?.[re.length-1];Ee.shiftKey&&document.activeElement===we?(Ee.preventDefault(),Me?.focus()):!Ee.shiftKey&&document.activeElement===Me&&(Ee.preventDefault(),we?.focus())}}};return document.addEventListener("keydown",je),()=>document.removeEventListener("keydown",je)},[ze,qe]),S.useLayoutEffect(()=>{const K=Lt.current;!K||Q!=="chat"||(K.style.height="auto",K.style.height=`${Math.min(180,Math.max(64,K.scrollHeight))}px`)},[m,Q]),S.useLayoutEffect(()=>{const K=Ie.current;K&&Ye.current&&Q==="chat"&&(K.scrollTop=K.scrollHeight)},[p.items,t.approvals.length,Q]);const rt=()=>{ze&&(ot(!1),At.current?.focus())},Tt=K=>{if(Q==="settings"&&ve===K){rt();return}He(()=>{De(K),fe("settings"),rt()})},He=K=>{Z?Y(()=>K):K()},ct=K=>He(()=>{E(K),be(je=>je+1),fe("files"),rt()}),M=S.useRef(ct);M.current=ct;const ie=S.useCallback(K=>M.current(K),[]);S.useEffect(()=>{if(!Z&&!t.uploadBusy&&!t.hasUnsent)return;const K=je=>{je.preventDefault(),je.returnValue=""};return window.addEventListener("beforeunload",K),()=>window.removeEventListener("beforeunload",K)},[Z,t.uploadBusy,t.hasUnsent]);const ye=K=>He(()=>{fe("chat"),rt(),Ye.current=!0,K()}),xe=K=>ye(()=>{t.selectSession(K)}),Ne=()=>ye(t.newSession),Te=()=>{Ye.current=!0,t.send()},Fe=t.stop,mt=t.approvals.filter(K=>!K.sessionId||K.sessionId===h),dt=t.approvals.filter(K=>K.sessionId&&K.sessionId!==h),ft=p.items.length===0&&mt.length===0,tt=T?.connections.find(K=>K.id===T.defaults.text),Bt=d==="open"?"已连接":d==="connecting"?"连接中":"正在重连",yt=Q==="chat"?N:Q==="files"?"工作区文件":Q==="history"?"历史对话":Q==="links"?"Link":Q==="panels"||Q==="panel"?k&&Q==="panel"?k.panel.title["zh-CN"]||k.panel.title.default:"面板":ve==="skills"?"Skills":"设置";return s.jsxs("div",{className:`shell${qe?" sidebar-open":""}`,children:[ze&&qe?s.jsx("div",{className:"sidebar-backdrop",onClick:()=>{ot(!1),At.current?.focus()},"aria-hidden":"true"}):null,s.jsxs("aside",{id:"workbench-sidebar",ref:$e,className:"rail",hidden:!qe,role:ze?"dialog":void 0,"aria-modal":ze&&qe?!0:void 0,"aria-label":"工作台导航",children:[s.jsxs("div",{className:"rail-head",children:[s.jsx("span",{className:"brand-mark",children:s.jsx(Mt,{name:"brand"})}),s.jsx("strong",{children:"CodeShell"}),s.jsx("span",{className:"hub-badge",children:a?"Cloud":t.host==="desktop"?"Desktop":L?"Hub":"Web"}),s.jsx("button",{className:"icon-button sidebar-close","aria-label":"收起侧栏",onClick:()=>{ot(!1),At.current?.focus()},children:s.jsx(Mt,{name:"sidebar"})})]}),s.jsx(bf,{discover:t.workspaceApi,navigate:K=>{const je=()=>window.location.assign(K);Z||t.hasUnsent||t.uploadBusy?Y(()=>je):je()}}),s.jsxs("nav",{className:"workbench-nav","aria-label":"主要功能",children:[i?s.jsxs("button",{className:"nav-button",title:r,onClick:()=>{Z||t.hasUnsent||t.uploadBusy?Y(()=>i):i()},children:[s.jsx(Mt,{name:"folder"}),s.jsx("span",{children:"返回项目列表"})]}):null,s.jsxs("button",{className:"nav-button new-chat-button",onClick:Ne,children:[s.jsx(Mt,{name:"plus"}),s.jsx("span",{children:"新对话"})]}),s.jsxs("button",{className:`nav-button${Q==="chat"?" active":""}`,onClick:()=>{He(()=>{fe("chat"),rt()})},"aria-current":Q==="chat"?"page":void 0,children:[s.jsx(Mt,{name:"chat"}),s.jsx("span",{children:"对话"})]}),L?s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:`nav-button${Q==="history"?" active":""}`,onClick:()=>He(()=>{fe("history"),rt()}),"aria-current":Q==="history"?"page":void 0,children:[s.jsx(Mt,{name:"history"}),s.jsx("span",{children:"历史对话"})]}),s.jsxs("button",{className:`nav-button${Q==="files"?" active":""}`,onClick:()=>ct(),"aria-current":Q==="files"?"page":void 0,children:[s.jsx(Mt,{name:"folder"}),s.jsx("span",{children:"文件"})]}),s.jsxs("button",{className:`nav-button${Q==="settings"&&ve==="skills"?" active":""}`,onClick:()=>Tt("skills"),"aria-current":Q==="settings"&&ve==="skills"?"page":void 0,children:[s.jsx(Mt,{name:"skills"}),s.jsx("span",{children:"Skills"})]}),s.jsxs("button",{className:`nav-button${Q==="panels"||Q==="panel"?" active":""}`,onClick:()=>He(()=>{fe("panels"),rt()}),"aria-current":Q==="panels"||Q==="panel"?"page":void 0,children:[s.jsx(Mt,{name:"panels"}),s.jsx("span",{children:"面板"})]}),s.jsxs("button",{className:`nav-button${Q==="links"?" active":""}`,onClick:()=>He(()=>{fe("links"),rt()}),"aria-current":Q==="links"?"page":void 0,children:[s.jsx(Mt,{name:"links"}),s.jsx("span",{children:"Link"})]}),s.jsxs("button",{className:`nav-button${Q==="settings"&&ve!=="skills"?" active":""}`,onClick:()=>Tt("overview"),"aria-current":Q==="settings"&&ve!=="skills"?"page":void 0,children:[s.jsx(Mt,{name:"settings"}),s.jsx("span",{children:"设置"})]})]}):null]}),s.jsx("div",{className:"rail-section-label",children:"工作区"}),L?s.jsxs("button",{className:"workspace-button",title:R??void 0,onClick:()=>ct(),children:[s.jsx(Mt,{name:"folder"}),s.jsx("span",{children:r??C}),s.jsx(Mt,{name:"chevron"})]}):s.jsxs("div",{className:"workspace-button",title:R??void 0,children:[s.jsx(Mt,{name:"folder"}),s.jsx("span",{children:r??C})]}),s.jsxs("div",{className:"rail-section-label history-label",children:[s.jsx("span",{children:"最近对话"}),s.jsx("span",{children:c.length})]}),t.renderSidebar?.({guard:He,conversation:ye}),s.jsxs("ul",{className:"sessions","aria-label":"最近对话",children:[q.map(({sessionId:K,draft:je})=>s.jsx("li",{children:s.jsxs("button",{className:K===h&&Q==="chat"?"session active":"session",onClick:()=>{xe(K)},children:[s.jsx("span",{className:"session-title",children:je.text.trim()||`附件:${je.files[0]?.name??"新对话"}`}),s.jsx("span",{className:"session-meta",children:"草稿"})]})},`draft-${K}`)),c.map(K=>s.jsx("li",{children:s.jsxs("button",{className:K.sessionId===h&&Q==="chat"?"session active":"session",onClick:()=>{xe(K.sessionId)},"aria-current":K.sessionId===h&&Q==="chat"?"page":void 0,children:[s.jsx("span",{className:"session-title",children:K.sessionId===h?K.customTitle||p.title||K.title||ox(p,K.sessionId):K.title||K.preview?.trim()||K.sessionId.slice(0,8)}),s.jsxs("span",{className:"session-meta",children:[t.unreadSessionIds?.has(K.sessionId)&&K.sessionId!==h?s.jsxs("span",{className:"session-unread","aria-label":"有新消息",children:["●"," "]}):null,U(K.sessionId)?`${U(K.sessionId)} 项待审批`:K.running?"进行中":MA(K.status),t.showTurnCounts!==!1?s.jsxs("span",{children:[" · ",K.turnCount," 轮"]}):null]})]})},K.sessionId)),c.length===0&&q.length===0?s.jsx("li",{className:"empty",children:"开始对话后,记录会保存在这里。"}):null]}),s.jsxs("div",{className:"rail-footer",children:[s.jsxs("div",{className:"host-label",children:[s.jsx("span",{className:`dot ${d}`}),s.jsxs("span",{children:[P,Bt]})]}),u?u({guard:He,conversation:ye}):a?s.jsx(Gb,{...a}):null,t.host==="hub"&&!a?s.jsxs("button",{className:"account-button",onClick:()=>{rt(),ee(!0)},children:[s.jsx("span",{className:"account-avatar",children:(I?.username||"C").slice(0,1).toUpperCase()}),s.jsxs("span",{className:"account-copy",children:[s.jsx("strong",{children:I?.username||"账号"}),s.jsx("span",{children:"设备与退出"})]}),s.jsx(Mt,{name:"chevron"})]}):null,t.logout?s.jsxs("button",{className:"account-button",onClick:t.logout,children:[s.jsx("span",{className:"account-avatar",children:(t.accountName||"D").slice(0,1)}),s.jsxs("span",{className:"account-copy",children:[s.jsx("strong",{children:t.accountName||"已配对设备"}),s.jsx("span",{children:"退出此设备"})]})]}):null]})]}),s.jsxs("main",{className:"workbench-main",inert:ze&&qe?!0:void 0,children:[s.jsxs("header",{className:"workbench-topbar",children:[s.jsx("button",{ref:At,className:"icon-button","aria-label":qe?"收起侧栏":"展开侧栏","aria-expanded":qe,"aria-controls":"workbench-sidebar",onClick:()=>ot(K=>!K),children:s.jsx(Mt,{name:"sidebar"})}),s.jsxs("div",{className:"topbar-context",children:[s.jsx("span",{className:"topbar-project","aria-label":"当前项目",title:r??C,children:r??C}),s.jsx("span",{className:"topbar-title",title:yt,children:yt})]}),s.jsxs("span",{className:"connection-pill",title:`任务在${P}工作区执行`,children:[s.jsx("span",{className:`dot ${d}`}),s.jsx("span",{children:P})]})]}),v?s.jsx("div",{className:"banner",children:v}):null,x?s.jsx("div",{className:"banner",children:x}):null,j?s.jsxs("div",{className:"banner form-error",role:"alert",children:[j,s.jsx("button",{className:"ghost","aria-label":"关闭错误提示",onClick:t.clearError,children:"×"})]}):null,dt.length?s.jsxs("div",{className:"banner",children:["其他会话有待处理审批。",dt.map(K=>s.jsxs("button",{className:"ghost",onClick:()=>{xe(K.sessionId)},children:["打开 ",K.sessionId.slice(0,8)]},K.id))]}):null,d!=="open"?s.jsxs("div",{className:"banner",children:["连接",d==="connecting"?"中…":"已断开,重连中…"]}):null,Q!=="chat"&&mt.length>0?s.jsxs("div",{className:"banner",children:["当前对话需要你的确认。",s.jsx("button",{className:"ghost",onClick:()=>He(()=>fe("chat")),children:"返回对话"})]}):null,s.jsxs("section",{className:`chat${ft?" chat-empty":""}`,hidden:Q!=="chat","aria-label":"对话",children:[s.jsx("div",{className:"messages",ref:Ie,onScroll:K=>{const je=K.currentTarget;Ye.current=je.scrollHeight-je.scrollTop-je.clientHeight<100},children:s.jsxs("div",{className:"transcript",children:[t.chatControls,t.loading?s.jsx("div",{className:"banner",role:"status",children:"正在恢复会话记录…"}):null,p.goal?s.jsxs("div",{className:"banner goal",children:[s.jsx("span",{children:p.goal}),t.goalActions]}):null,p.items.map(K=>{switch(K.kind){case"user":return s.jsxs("div",{className:"msg user",children:[K.text,K.attachments?.map((je,Ee)=>L&&je.path?s.jsxs("button",{className:"attachment attachment-open",onClick:()=>ct(je.path),children:["📎 ",je.name]},Ee):s.jsxs("span",{className:"attachment",children:["📎 ",je.name]},Ee))]},K.id);case"assistant":return K.done&&!K.text&&!K.reasoning?null:s.jsx("div",{className:"msg assistant",children:s.jsx(SA,{text:K.text,reasoning:K.reasoning,streaming:!K.done,onOpenFile:L?ie:void 0})},K.id);case"tool":return s.jsx("div",{className:`msg tool${K.error?" tool-error":""}`,children:s.jsx(kA,{item:K,running:se})},K.id);case"subagent":return s.jsxs("div",{className:"msg info",children:["↳ ",K.label," · ",CA(K.status)]},K.id);case"system":return s.jsx("div",{className:"msg info",children:K.text},K.id);case"system_error":return s.jsx("div",{className:"msg error",children:K.text},K.id);default:return null}}),t.approvalContent,ft?s.jsxs("div",{className:"empty-chat",children:[s.jsx("span",{className:"welcome-mark",children:s.jsx(Mt,{name:"brand"})}),s.jsx("h1",{children:"今天想完成什么?"}),s.jsx("p",{children:"从一个问题或想法开始,让 CodeShell 帮你一步步完成。"}),s.jsxs("span",{className:"welcome-workspace",children:[s.jsx(Mt,{name:"folder"}),r??C]})]}):null]})}),t.readOnlyNote?s.jsx("div",{className:"banner",children:t.readOnlyNote}):null,s.jsxs("div",{className:"composer-wrap",children:[s.jsxs("footer",{className:"composer",children:[y.length||b&&t.host==="hub"?s.jsxs("div",{className:"attachments","aria-live":"polite",children:[y.map(K=>s.jsxs("span",{className:"attachment",children:[s.jsx(Mt,{name:"attachment"}),K.name,s.jsx("button",{className:"ghost","aria-label":`移除 ${K.name}`,onClick:()=>{t.removeFile(K.id)},children:"×"})]},K.id)),b&&t.host==="hub"?s.jsx("span",{children:"正在上传…"}):null]}):null,s.jsx("textarea",{ref:Lt,"aria-label":"任务内容",value:m,disabled:t.readOnly,rows:2,placeholder:"描述你的任务,或提出一个问题…",onChange:K=>{t.setDraft(K.target.value)},onKeyDown:K=>{K.key==="Enter"&&!K.shiftKey&&!K.nativeEvent.isComposing&&(K.preventDefault(),Te())}}),s.jsxs("div",{className:"composer-toolbar",children:[L?s.jsxs(s.Fragment,{children:[s.jsx("input",{hidden:!0,multiple:!0,type:"file",accept:t.attachmentAccept,ref:G,onChange:K=>{const je=K.currentTarget;Promise.resolve(t.addFiles(je.files)).finally(()=>{je.value=""})}}),s.jsx("button",{className:"icon-button attach-button","aria-label":"添加附件",title:"添加附件",disabled:t.uploadBusy||d!=="open"||t.readOnly,onClick:()=>G.current?.click(),children:s.jsx(Mt,{name:"plus"})}),t.cameraAttachments?s.jsxs(s.Fragment,{children:[s.jsx("input",{hidden:!0,type:"file",accept:"image/*",capture:"environment",ref:B,onChange:K=>{const je=K.currentTarget;Promise.resolve(t.addFiles(je.files)).finally(()=>{je.value=""})}}),s.jsx("button",{className:"icon-button attach-button","aria-label":"拍照",title:"拍照",disabled:t.uploadBusy||d!=="open"||t.readOnly,onClick:()=>B.current?.click(),children:s.jsx(Mt,{name:"camera"})})]}):null,s.jsxs("button",{className:"model-button",title:"打开模型设置",onClick:()=>Tt("models"),children:[s.jsx("span",{children:tt?.model||"配置模型"}),s.jsx(Mt,{name:"chevron"})]})]}):null,s.jsx("span",{className:"composer-run-status",role:"status",children:t.uncertain?"正在核对消息…":b?t.host==="desktop"?"正在发送…":"正在上传附件…":mt.length?"等待你的确认":se?"正在处理…":""}),se?s.jsx("button",{className:"stop composer-submit","aria-label":"停止",title:"停止",onClick:Fe,disabled:d!=="open",children:s.jsx(Mt,{name:"stop"})}):s.jsx("button",{className:"send composer-submit","aria-label":"发送",title:"发送",onClick:Te,disabled:d!=="open"||b||t.uncertain||t.readOnly||!m.trim()&&!y.length,children:s.jsx(Mt,{name:"send"})})]})]}),s.jsxs("div",{className:"composer-caption",children:[s.jsxs("span",{children:["任务在",P,"工作区执行"]}),s.jsx("span",{children:"Enter 发送 · Shift + Enter 换行"})]})]})]}),Q==="settings"&&L?s.jsx(Dw,{host:t.host==="desktop"?"desktop":"hub",section:ve,onSectionChange:Tt,onAuthLost:X,onConfigurationChange:()=>{A()},configurationVersion:_,onDirtyChange:ne},`${t.workspaceKey}:settings`):null,Q==="files"&&L?s.jsx(qw,{initialPath:le,openVersion:J,onAuthLost:X},`${t.workspaceKey}:files`):null,Q==="history"&&L?s.jsx(Hw,{onAuthLost:X,onOpen:K=>{xe(K)},onChanged:()=>{H()},version:D,onDirtyChange:ne},`${t.workspaceKey}:history`):null,Q==="links"&&L?s.jsx(DS,{onAuthLost:X,onDirtyChange:ne,hostLabel:P,configurationVersion:_},`${t.workspaceKey}:links`):null,Q==="panels"&&L?s.jsx(MS,{onAuthLost:X,onDirtyChange:ne,onChanged:()=>{A()},hostLabel:P,configurationVersion:_,onOpen:K=>He(()=>{O({panel:K,workspaceKey:t.workspaceKey}),fe("panel"),rt()})},`${t.workspaceKey}:panels`):null,Q==="panel"&&L&&k?.workspaceKey===t.workspaceKey?s.jsx(PS,{panel:k.panel,sessionId:h,busy:se||b||t.uncertain,onAuthLost:X,onDirtyChange:ne,onClose:()=>He(()=>fe("panels")),onSubmitPrompt:async K=>zA(t,{...K,workspaceKey:k.workspaceKey})},`${t.workspaceKey}:panel:${k.panel.id}:${h}`):null]}),ge?s.jsx(DA,{onStay:()=>Y(null),onLeave:()=>{const K=ge;Y(null),ne(!1),K()}}):null,W&&t.host==="hub"&&!a?s.jsx(W1,{session:I,onClose:()=>ee(!1),onAuthLost:X}):null]})}function DA({onStay:t,onLeave:i}){const r=S.useRef(null);return S.useEffect(()=>{const a=document.activeElement;return r.current?.showModal(),()=>{r.current?.close(),a?.focus()}},[]),s.jsxs("dialog",{className:"navigation-prompt",ref:r,"aria-labelledby":"navigation-prompt-title",onCancel:a=>{a.preventDefault(),t()},children:[s.jsx("h2",{id:"navigation-prompt-title",children:"还有未保存的修改"}),s.jsx("p",{children:"离开会丢弃未提交的修改;切换项目还会清除未发送的草稿和附件。已经提交的操作可能仍会完成,请等待结果后再离开。"}),s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{className:"library-button primary",onClick:t,autoFocus:!0,children:"留在此页"}),s.jsx("button",{className:"library-button",onClick:i,children:"放弃修改并离开"})]})]})}function MA(t){switch(t){case"running":return"进行中";case"waiting":case"waiting_approval":return"等待确认";case"completed":return"已完成";case"cancelled":case"canceled":return"已停止";case"failed":case"error":return"发生错误";case"idle":return"可继续";default:return"对话"}}function Mt({name:t}){const i={panels:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M15 3v18M15 10h6"})]}),camera:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 7h4l2-3h6l2 3h4v13H3Z"}),s.jsx("circle",{cx:"12",cy:"13",r:"4"})]}),links:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-2 2"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l2-2"})]}),brand:s.jsx(s.Fragment,{children:s.jsx("path",{d:"m5 7 5 5-5 5M13 17h6"})}),sidebar:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M9 4v16"})]}),plus:s.jsx("path",{d:"M12 5v14M5 12h14"}),chat:s.jsx("path",{d:"M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5Z"}),history:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),s.jsx("path",{d:"M3 3v5h5M12 7v5l3 2"})]}),skills:s.jsx(s.Fragment,{children:s.jsx("path",{d:"m12 3 2.7 5.5L21 9.4l-4.5 4.4 1.1 6.2L12 17.1 6.4 20l1.1-6.2L3 9.4l6.3-.9L12 3Z"})}),settings:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m9 3-.7 3-2.6 1-2.6 2 1.4 3-1.4 3 2.6 2 2.6 1 .7 3h6l.7-3 2.6-1 2.6-2-1.4-3 1.4-3-2.6-2-2.6-1L15 3H9Z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),folder:s.jsx("path",{d:"M3 7V5a1 1 0 0 1 1-1h5l2 3h9a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7Z"}),chevron:s.jsx("path",{d:"m9 5 7 7-7 7"}),attachment:s.jsx("path",{d:"m21 11-8 8a6 6 0 0 1-8.5-8.5l9-9A4 4 0 0 1 19 7l-9 9a2 2 0 0 1-2.8-2.8l8-8"}),send:s.jsx("path",{d:"M12 19V5m-6 6 6-6 6 6"}),stop:s.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2",fill:"currentColor",stroke:"none"})};return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i[t]})}class Si extends Error{constructor(i,r,a){super(i),this.kind=r,this.code=a,this.name="ProtocolRequestError"}kind;code}const OA=3e4,Nb=800,LA=15e3;class BA{constructor(i){this.url=i}url;ws=null;nextId=1;pending=new Map;notificationHandlers=new Set;stateHandlers=new Set;reconnectDelay=Nb;closedByUser=!1;reconnectTimer;authHandlers=new Set;connect(){this.ws||(clearTimeout(this.reconnectTimer),this.closedByUser=!1,this.openSocket())}openSocket(){if(this.closedByUser)return;this.reconnectTimer=void 0,this.emitState("connecting");const i=new WebSocket(this.url);this.ws=i,i.onopen=()=>{this.ws!==i||this.closedByUser||(this.reconnectDelay=Nb,this.emitState("open"))},i.onmessage=r=>{if(this.ws!==i||this.closedByUser)return;let a;try{if(a=JSON.parse(String(r.data)),!a||typeof a!="object"||Array.isArray(a))return}catch{return}if(a.id!==void 0&&a.method===void 0){const u=this.pending.get(String(a.id));if(!u)return;this.pending.delete(String(a.id)),clearTimeout(u.timer),a.error?u.reject(new Si(a.error.message??"request failed","response",a.error.code)):u.resolve(a.result);return}if(a.method)for(const u of this.notificationHandlers)u(a.method,a.params??{})},i.onclose=r=>{if(this.ws===i){if(this.ws=null,this.emitState("closed"),this.failAllPending(new Si("connection closed","transport")),r.code===4401||r.code===4403){this.closedByUser=!0;for(const a of this.authHandlers)a()}this.closedByUser||(this.reconnectTimer=setTimeout(()=>this.openSocket(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,LA))}},i.onerror=()=>{}}close(){this.closedByUser=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0;const i=this.ws;this.ws=null,i?.close(),this.failAllPending(new Si("connection closed","transport"))}onNotification(i){return this.notificationHandlers.add(i),()=>this.notificationHandlers.delete(i)}onStateChange(i){return this.stateHandlers.add(i),()=>this.stateHandlers.delete(i)}onAuthLost(i){return this.authHandlers.add(i),()=>this.authHandlers.delete(i)}request(i,r,a=OA){const u=this.ws;if(!u||u.readyState!==WebSocket.OPEN)return Promise.reject(new Si("not connected","not-sent"));const d=`web-${this.nextId++}`;return new Promise((c,h)=>{const p=a>0?setTimeout(()=>{this.pending.delete(d),h(new Si(`request timed out: ${i}`,"timeout"))},a):void 0;this.pending.set(d,{resolve:c,reject:h,timer:p});try{u.send(JSON.stringify({jsonrpc:"2.0",id:d,method:i,params:r}))}catch(m){clearTimeout(p),this.pending.delete(d),h(new Si(m instanceof Error?m.message:"send failed","not-sent"))}})}run(i){return this.request("agent/run",i,0)}listSessions(){return this.request("agent/query",{type:"sessions"})}sessionDetail(i,r=!1){return this.request("agent/query",{type:"session_detail",sessionId:i,...r?{outputRecovery:!0}:{}})}outputCoverage(i){return this.request("agent/query",{type:"output_coverage",sessionId:i})}outputJournal(i,r={}){return this.request("agent/query",{type:"output_journal",sessionId:i,...r})}approve(i,r,a){return this.request("agent/approve",{sessionId:i.sessionId??"",...i.connectionId?{connectionId:i.connectionId}:{},...i.generation!==void 0?{generation:i.generation}:{},requestId:i.requestId,decision:r?{approved:!0,...a?{answer:a}:{}}:{approved:!1}})}cancel(i){return this.request("agent/cancel",{sessionId:i})}emitState(i){for(const r of this.stateHandlers)r(i)}failAllPending(i){for(const[,r]of this.pending)clearTimeout(r.timer),r.reject(i);this.pending.clear()}}function UA(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}${xt("/ws")}`}function IA(t,i){const{method:r,params:a}=i;if(r==="serve/approvalSnapshot"){if(!Array.isArray(a.approvals))return t;const d={};for(const c of a.approvals)c?.requestId&&c.request&&(d[c.requestId]={payload:c});return d}if(r==="agent/approvalRequest"){const d=a;return!d.requestId||!d.request?t:{...t,[d.requestId]:{...t[d.requestId],payload:d}}}const u=a.requestId;if(typeof u!="string"||!t[u])return t;if(r==="agent/approvalResolved"){const d={...t};return delete d[u],d}return r==="serve/approvalLease"?{...t,[u]:{...t[u],lease:a}}:t}class qA{drafts=new Map;get(i){return this.drafts.get(i)??{text:"",files:[],revision:0}}update(i,r){const a={...r,revision:this.get(i).revision+1};return this.drafts.set(i,a),a}setText(i,r){return this.update(i,{...this.get(i),text:r})}addFile(i,r){const a=this.get(i);return this.update(i,{...a,files:[...a.files,r]})}removeFile(i,r){const a=this.get(i);return this.update(i,{...a,files:a.files.filter(u=>u.id!==r)})}take(i){const r=this.get(i),a=this.update(i,{text:"",files:[]});return{sessionId:i,draft:r,clearedRevision:a.revision}}restore(i){const r=this.get(i.sessionId);return r.revision!==i.clearedRevision||r.text||r.files.length?!1:(this.update(i.sessionId,i.draft),!0)}unsent(){return[...this.drafts].flatMap(([i,r])=>r.text.trim()||r.files.length?[{sessionId:i,draft:r}]:[])}}function HA({payload:t,onDecide:i,busy:r,connected:a}){const[u,d]=S.useState(""),c=t.request.toolName==="__ask_user__",{summary:h,risk:p}=eS(t.request.args,t.request.riskLevel,t.request.toolName);return s.jsxs("div",{className:"approval",children:[s.jsxs("div",{className:"approval-title",children:[c?"Agent 提问":`工具审批:${t.request.toolName}`,c?null:s.jsxs("em",{children:[" · ",p]})]}),t.request.description?s.jsx("div",{className:"approval-desc",children:t.request.description}):null,c?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"approval-summary",children:h}),s.jsxs("details",{className:"approval-raw",children:[s.jsx("summary",{children:"原始参数"}),s.jsx("pre",{className:"approval-args",children:JSON.stringify(t.request.args,null,2)})]})]}),c?s.jsx("textarea",{className:"approval-answer",value:u,placeholder:"输入回答…",onChange:m=>d(m.target.value)}):null,r?s.jsx("span",{className:"muted",role:"status",children:"设备正在处理此审批…"}):null,s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{className:"send",disabled:r||!a||c&&!u.trim(),onClick:()=>i(t,!0,c?u:void 0),children:c?"回答":"允许"}),s.jsx("button",{className:"stop",disabled:r||!a,onClick:()=>i(t,!1),children:"拒绝"})]})]})}function Ab(){return _a()}const GA=()=>{},VA=async()=>{};function $A({session:t,hub:i=!1,onAuthLost:r=GA,onCheckAuth:a=VA}){const u=S.useRef(null),[d,c]=S.useState("connecting"),[h,p]=S.useState([]),m=S.useRef([]),[y,b]=S.useState(()=>EA(window.location.search)??Ab()),[v,x]=S.useState(uo()),[j,R]=S.useReducer(IA,{}),[C,T]=S.useState({}),[_,D]=S.useState(""),[q,se]=S.useState([]),N=S.useRef(new qA),[U,X]=S.useState(0),[H,A]=S.useState(null),I=H===y,[L,P]=S.useState(null),[W,ee]=S.useState(null),[G,B]=S.useState(""),[Q,fe]=S.useState(Date.now()),[k,O]=S.useState(0),[le,E]=S.useState(null),[J,be]=S.useState(0),Z=S.useRef(0),ne=S.useRef(y),ge=S.useRef(null),Y=S.useRef(null),ve=S.useRef(!1),De=S.useRef(new Map),ze=S.useRef(new Map),_e=S.useRef(new Set),qe=S.useRef(new Set),ot=S.useRef(new Set),$e=S.useRef(!1),At=S.useRef(null),ut=S.useRef(null),Ie=S.useCallback(re=>{if(X(Me=>Me+1),ne.current!==re)return;const we=N.current.get(re);D(we.text),se(we.files)},[]);S.useEffect(()=>{const re=new URL(window.location.href);re.searchParams.set("session",y),window.history.replaceState(window.history.state,"",re)},[y]);const Lt=S.useCallback((re,we)=>{const Me=N.current.restore(re.draft);Ie(re.draft.sessionId),ne.current===re.draft.sessionId&&(x(Ce=>({...Ce,run:"error",items:Ce.items.filter(V=>V.kind!=="user"||V.clientMessageId!==re.clientMessageId)})),Me&&B(`${we?`${we} `:"消息未送达。"}内容和附件已恢复,可以重试。`))},[Ie]),Ye=S.useCallback(re=>{$e.current&&(re instanceof Xe&&re.status===401?r():B(re instanceof Error?re.message:"操作失败,请重试。"))},[r]),rt=S.useCallback(async()=>{if(!i||!$e.current)return;const re=++Z.current;try{const we=await Vb();$e.current&&re===Z.current&&E(we)}catch(we){$e.current&&we instanceof Xe&&we.status===401&&r()}},[i,r]),Tt=S.useCallback(async()=>{const re=u.current;if(re)try{const we=i?(await Pd()).sessions:(await re.listSessions()).data;if(u.current===re&&$e.current){const Me=[...we].sort((Ce,V)=>(V.lastActiveAt??V.startedAt)-(Ce.lastActiveAt??Ce.startedAt));m.current=Me,p(Me)}}catch(we){Ye(we)}},[Ye,i]),He=S.useCallback(async()=>{const re=u.current;if(re)for(const[we,Me]of ze.current)try{const Ce=await re.sessionDetail(we);if(!$e.current||re!==u.current||ze.current.get(we)!==Me)continue;Cb(Ce.data).chat.items.some(ke=>ke.kind==="user"&&ke.clientMessageId===Me.clientMessageId)?ze.current.delete(we):Ce.data.running||(ze.current.delete(we),Lt(Me))}catch(Ce){if(!$e.current||re!==u.current||ze.current.get(we)!==Me)continue;Ce instanceof Si&&Ce.kind==="response"&&Ce.code===-32001&&Ce.message===`Session not found: ${we}`&&(ze.current.delete(we),Lt(Me))}},[Lt]),ct=S.useCallback(async re=>{const we=u.current;if(!we)return;const Me={sessionId:re,events:[],bytes:0};ut.current=Me;try{const Ce=await we.sessionDetail(re,!0);if(!$e.current||ut.current!==Me||ne.current!==re)return;let V=Me.running??Ce.data.running;V?qe.current.add(re):V===!1&&qe.current.delete(re);const de=Cb(Ce.data,Me.events);let ke=de.chat,Ke=!1,at=!1;try{const Rt=await NA(Ce.data,async kt=>(await we.outputJournal(re,kt)).data,Me.events,()=>Me.latestOutputCursor,Ce.data.outputCoverage?async()=>(await we.outputCoverage(re)).data:void 0,()=>$e.current&&ut.current===Me&&ne.current===re);Rt?(ke=Rt.chat,Y.current=Rt.outputCursor,Ke=!0):Y.current=null}catch(Rt){Y.current=null,at=!(!Ce.data.outputJournal&&Rt instanceof Si&&Rt.kind==="response"&&Rt.code===-32602&&Rt.message==="Unknown query type: output_journal")}if(!$e.current||ut.current!==Me||ne.current!==re)return;V=Me.running??Ce.data.running,ve.current=at,at||(ge.current=de.cursor??null),ee(at?"部分运行记录无法验证,已保留当前可见内容。请修复会话记录后重试。":!Ke&&(de.truncated||Me.overflow)?"这次运行的实时记录较长,已恢复已保存的内容;结束后重新打开可查看完整记录。":null),V||_e.current.has(re)?ke.run="running":V===!1&&(ke.run==="running"||ke.run==="waiting")&&(ke.run="idle"),x(Rt=>at?Rt:ke)}catch(Ce){ne.current===re&&Ye(Ce)}finally{ut.current===Me&&(ut.current=null)}},[Ye]);S.useEffect(()=>{$e.current=!0;const re=new BA(UA());u.current=re;const we=re.onAuthLost(r),Me=re.onStateChange(V=>{c(V),V==="open"?(P(null),B(""),Tt().then(()=>{const de=ne.current;$e.current&&u.current===re&&(m.current.some(ke=>ke.sessionId===de)||qe.current.has(de)||_e.current.has(de)||ze.current.has(de))&&ct(de)}),rt(),He()):V==="closed"&&(i&&a(),x(de=>({...de,run:"idle"})))}),Ce=re.onNotification((V,de)=>{if(V==="serve/sessionsChanged"){Tt(),O(ke=>ke+1);return}if(V==="agent/runAccepted"&&typeof de.sessionId=="string"){const ke=De.current.get(de.sessionId);ke&&(ke.accepted=!0);return}if(V==="serve/configurationChanged"){rt(),be(ke=>ke+1);return}if(V==="agent/streamEvent"){const ke=de,{sessionId:Ke,event:at}=ke,Rt=De.current.get(Ke);if(Rt&&["stream_request_start","text_delta","thinking_delta","tool_use_start"].includes(String(at.type))&&(Rt.accepted=!0),Ke===ne.current){if(ut.current?.sessionId===Ke){const kt=ut.current;typeof at.outputCursor=="string"&&(kt.latestOutputCursor=at.outputCursor);const ni=new TextEncoder().encode(JSON.stringify(ke)).length;for(kt.events.push(ke),kt.bytes+=ni;kt.events.length>2048||kt.bytes>8*1024*1024;){const Vt=kt.events.shift();Vt&&(kt.bytes-=new TextEncoder().encode(JSON.stringify(Vt)).length),kt.overflow=!0}}if(ve.current&&at.type!=="session_title")return;if(typeof at.outputCursor=="string"&&Y.current){const kt=ja(at.outputCursor,Y.current);if(kt===void 0){ct(Ke);return}if(kt<=0)return;Y.current=at.outputCursor}if(!sx(ke,ge.current))return;ke.hubEpoch&&ke.hubSequence!==void 0&&(ge.current={epoch:ke.hubEpoch,sequence:ke.hubSequence}),x(kt=>vr(kt,at))}at.type==="stream_request_start"&&P(null),at.type==="turn_complete"&&Tt();return}if(V==="serve/sessionStatus"){O(at=>at+1);const{sessionId:ke,running:Ke}=de;if(typeof ke!="string"||typeof Ke!="boolean")return;ut.current?.sessionId===ke&&(ut.current.running=Ke),Ke?qe.current.add(ke):qe.current.delete(ke),!Ke&&ze.current.has(ke)&&He(),ke===ne.current&&x(at=>Ke?{...at,run:"running"}:at.run==="running"||at.run==="waiting"?{...at,run:"idle"}:at),Tt();return}if(V==="agent/approvalRequest"||V==="agent/approvalResolved"||V==="serve/approvalSnapshot"||V==="serve/approvalLease"){R({method:V,params:de});return}if(V==="serve/workerExit"){qe.current.clear();const ke=de.clean;P(ke?"服务进程已退出,发送消息会自动重启":"服务进程异常退出,发送消息会自动重启"),x(Ke=>({...Ke,run:"idle"}))}});return re.connect(),()=>{$e.current=!1,At.current?.abort(),Me(),Ce(),we(),re.close(),u.current=null}},[Tt,ct,rt,He,r,a,i]);const M=Object.values(j).some(re=>re.lease?.holderId&&(re.lease.expiresAt??0)>Q);S.useEffect(()=>{if(!M)return;fe(Date.now());const re=setInterval(()=>fe(Date.now()),1e3);return()=>clearInterval(re)},[M]);const ie=async re=>{ne.current=re,ge.current=null,Y.current=null,ve.current=!1,b(re),Ie(re),x(uo()),B(""),ee(null),!(!h.some(we=>we.sessionId===re)&&!qe.current.has(re)&&N.current.unsent().some(we=>we.sessionId===re))&&await ct(re)},ye=()=>{const re=Ab();ne.current=re,ge.current=null,Y.current=null,ve.current=!1,ut.current=null,b(re),Ie(re),x(uo()),B(""),ee(null)},xe=()=>{const re=N.current.get(ne.current),we=re.text.trim(),Me=u.current;if(!we&&!re.files.length||!Me||d!=="open"||I)return!1;const Ce=ne.current;if(_e.current.has(Ce)||qe.current.has(Ce)||v.run==="running"||v.run==="waiting"||Object.values(j).some(ke=>ke.payload.sessionId===Ce)||ze.current.has(Ce))return!1;ne.current=Ce,b(Ce),_e.current.add(Ce);const V={clientMessageId:_a(),draft:N.current.take(Ce),accepted:!1};De.current.set(Ce,V);const de=V.draft.draft.files;return Ie(Ce),B(""),x(ke=>({...Fw(ke,we,de.map(Ke=>({name:Ke.name,mime:Ke.mimeType,size:Ke.size})),V.clientMessageId),run:"running"})),Me.run({sessionId:Ce,task:we,clientMessageId:V.clientMessageId,displayText:we,...de.length?{uploadIds:de.map(ke=>ke.id)}:{}}).catch(ke=>{$e.current&&(Ye(ke),ke instanceof Si&&(ke.kind==="transport"||ke.kind==="timeout")?(ze.current.set(Ce,V),B("连接中断,重新连接后会核对这条消息是否已经送达。")):V.accepted||Lt(V,ke instanceof Error?ke.message==="upload not found or expired"?"附件已失效,请移除后重新上传。":ke.message:void 0),ne.current===Ce&&x(Ke=>({...Ke,run:"error"})))}).finally(()=>{_e.current.delete(Ce),De.current.get(Ce)===V&&De.current.delete(Ce),$e.current&&ne.current===Ce&&!qe.current.has(Ce)&&x(ke=>ke.run==="running"?{...ke,run:"idle"}:ke)}),!0},Ne=(re,we,Me)=>{const Ce=u.current;!Ce||d!=="open"||ot.current.has(re.requestId)||(ot.current.add(re.requestId),T(V=>({...V,[re.requestId]:!0})),B(""),Ce.approve({...re,sessionId:re.sessionId??ne.current??""},we,Me).then(()=>R({method:"agent/approvalResolved",params:{requestId:re.requestId}})).catch(Ye).finally(()=>{ot.current.delete(re.requestId),T(V=>{const de={...V};return delete de[re.requestId],de})}))},Te=()=>{y&&u.current?.cancel(y).catch(Ye)},Fe=async re=>{if(!re?.length||At.current)return;const we=new AbortController,Me=po();At.current=we,A(ne.current),B("");const Ce=ne.current;try{for(const V of Array.from(re)){if(!$e.current||we.signal.aborted)break;const de=await z1(V,{signal:we.signal,scope:Me});$e.current&&!we.signal.aborted&&(N.current.addFile(Ce,de),Ie(Ce))}}catch(V){Ye(V)}finally{At.current===we&&(At.current=null),$e.current&&A(null)}},mt=Object.values(j).filter(re=>!re.payload.sessionId||re.payload.sessionId===y),dt=re=>Object.values(j).filter(we=>we.payload.sessionId===re).length,ft=v.run==="running"||v.run==="waiting"||mt.length>0,tt=S.useMemo(()=>N.current.unsent().filter(re=>!h.some(we=>we.sessionId===re.sessionId)),[U,h]),Bt=le?.workspace.path??h.find(re=>re.sessionId===y)?.cwd??h[0]?.cwd??null,yt=Bt?.split(/[\\/]/).filter(Boolean).pop()??"服务端工作区",K=v.items.length===0&&mt.length===0,je=h.find(re=>re.sessionId===y),Ee=K?"新对话":je?.customTitle||v.title||je?.title||je?.preview?.trim()||ox(v,y??"新对话");return{host:i?"hub":"legacy",workspaceApi:i,connection:d,session:t,activeId:y,chat:v,sessions:h,workspaceCwd:Bt,workspaceName:yt,title:Ee,workspaceKey:Bt??"hub",configuration:le,configurationVersion:J,sessionsVersion:k,draft:_,files:q,uploading:I,uploadBusy:H!==null,hasUnsent:N.current.unsent().length>0,localDrafts:tt,uncertain:ze.current.has(y),running:ft,approvals:Object.values(j).map(re=>({id:re.payload.requestId,sessionId:re.payload.sessionId})),approvalCount:dt,approvalContent:mt.map(re=>s.jsx(HA,{payload:re.payload,onDecide:Ne,busy:!!C[re.payload.requestId]||!!(re.lease?.holderId&&(re.lease.expiresAt??0)>Q),connected:d==="open"},re.payload.requestId)),workerNote:L,replayNote:W,error:G,clearError:()=>B(""),setDraft:re=>{N.current.setText(ne.current,re),Ie(ne.current)},removeFile:re=>{N.current.removeFile(ne.current,re),Ie(ne.current)},selectSession:ie,newSession:ye,send:xe,stop:Te,addFiles:Fe,refreshSessions:Tt,refreshConfiguration:rt,onAuthLost:r}}function cf({onBackToProjects:t,projectName:i,cloudAccount:r,renderAccountControl:a,...u}){return s.jsx(_A,{controller:$A(u),onBackToProjects:t,projectName:i,cloudAccount:r,renderAccountControl:a})}function df(t){if(!t||typeof t!="object")return!1;const i=t;return vl(i.id)&&typeof i.name=="string"&&i.name.length>0&&["stopped","starting","running","stopping","error"].includes(i.status)&&Number.isSafeInteger(i.generation)&&i.generation>=0&&Number.isSafeInteger(i.createdAt)&&i.createdAt>=0&&(i.error===void 0||typeof i.error=="string")}function YA(t){const i=t;if(!i||i.runtime!=="docker"||typeof i.available!="boolean"||!Array.isArray(i.projects)||!i.projects.every(df)||new Set(i.projects.map(r=>r.id)).size!==i.projects.length||i.error!==void 0&&typeof i.error!="string")throw new Error("服务端返回了无效的项目列表,请重试。");return i}function Tb(){return new URL(window.location.href).searchParams.get("project")}function ml(t,i=!1){const r=new URL(window.location.href);t?r.searchParams.set("project",t):r.searchParams.delete("project"),i||r.searchParams.delete("session"),window.history.replaceState(window.history.state,"",r)}const FA={stopped:"已停止",starting:"正在启动",running:"运行中",stopping:"正在停止",error:"启动失败"};function ux({children:t,onAuthLost:i,accountControl:r,allowLegacy:a=!0,autoEnterSingle:u=!1,startCreatedProject:d=!1,canRequest:c}){const[h,p]=S.useState(null),[m,y]=S.useState(!1),[b,v]=S.useState(null),[x,j]=S.useState(""),[R,C]=S.useState(!0),[T,_]=S.useState(null),[D,q]=S.useState(""),[se,N]=S.useState(null),U=S.useRef(null),X=S.useRef(Tb()),H=S.useRef(b),A=S.useRef(h),I=S.useRef(0),L=S.useRef(0),P=S.useRef(null),W=S.useRef(i),ee=S.useRef(!1),G=S.useRef(!0),B=S.useRef(c);B.current=c,W.current=i,H.current=b,A.current=h;const Q=S.useCallback(E=>{if(E.status!=="running")return;const J=Tb()===E.id;Zs(),Ks(E.id),ml(E.id,J),X.current=null,G.current=!1,H.current=E,v(E),j("")},[]),fe=S.useCallback(()=>{X.current=null,H.current=null,v(null),Ks(null),Zs(),ml(null)},[]),k=S.useCallback(async E=>{if(ee.current||B.current&&!B.current())return;const J=++L.current,be=I.current;try{const Z=YA(await Ue("/api/v1/projects",{signal:E}));if(E?.aborted||J!==L.current||be!==I.current)return;p(Z),A.current=Z,C(!1),j("");const ne=H.current;if(ne){const Y=Z.projects.find(ve=>ve.id===ne.id);(!Y||Y.status!=="running"||Y.generation!==ne.generation)&&(fe(),j("项目运行状态已经变化,请重新打开项目。未发送的内容不会带入其他项目。"));return}if(!X.current){u&&G.current&&Z.available&&Z.projects.length===1&&Z.projects[0].status==="running"&&Q(Z.projects[0]);return}const ge=Z.projects.find(Y=>Y.id===X.current);ge?ge.status==="running"&&Z.available&&Q(ge):(G.current=!1,X.current=null,ml(null),j("链接中的项目不存在或当前账号无权访问,请选择一个项目。"))}catch(Z){if(E?.aborted||J!==L.current||be!==I.current)return;C(!1),a&&Z instanceof Xe&&Z.status===404&&!A.current?(Ks(null),Zs(),ee.current=!0,y(!0)):Z instanceof Xe&&Z.status===401?W.current():j(Z instanceof Error?Z.message:"无法读取项目,请重试。")}},[fe,Q,a,u]);S.useEffect(()=>{I.current++;const E=new AbortController;k(E.signal);const J=()=>{k(E.signal)},be=()=>{document.visibilityState==="visible"&&J()};return window.addEventListener("focus",J),document.addEventListener("visibilitychange",be),()=>{I.current++,E.abort(),P.current?.abort(),window.removeEventListener("focus",J),document.removeEventListener("visibilitychange",be),Ks(null),Zs()}},[k]);const O=h?.projects.some(E=>E.status==="starting"||E.status==="stopping");S.useEffect(()=>{if(m||!h)return;const E=new AbortController,J=setInterval(()=>{k(E.signal)},O?2e3:1e4);return()=>{clearInterval(J),E.abort()}},[m,!!h,O,k]),S.useEffect(()=>{if(!se)return;const E=document.activeElement,J=U.current;return J?.showModal?.(),()=>{J?.close?.(),E?.focus()}},[se]);const le=async(E,J)=>{if(B.current&&!B.current()||P.current||E==="create"&&!D.trim())return;const be=new AbortController;P.current=be,_(J?.id??"create"),j(""),L.current++;try{const Z=await Ue(E==="create"?"/api/v1/projects":`/api/v1/projects/${J.id}/${E}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E==="create"?{name:D.trim()}:{}),signal:be.signal});if(be.signal.aborted)return;if(!df(Z.project)||J&&J.id!==Z.project.id)throw new Error("服务端返回了无效的项目状态,请刷新列表。");let ne=Z.project;if(E==="create"&&d){const ge=await Ue(`/api/v1/projects/${ne.id}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",signal:be.signal});if(be.signal.aborted)return;if(!df(ge.project)||ge.project.id!==ne.id)throw new Error("服务端返回了无效的项目状态,请刷新列表。");ne=ge.project,X.current=ne.id,ml(ne.id),ne.status==="running"&&Q(ne)}p(ge=>ge&&{...ge,projects:ge.projects.some(Y=>Y.id===ne.id)?ge.projects.map(Y=>Y.id===ne.id?ne:Y):[...ge.projects,ne]}),E==="create"&&q(""),E==="start"&&(X.current=ne.id,ml(ne.id),ne.status==="running"&&Q(ne)),E==="stop"&&(X.current===ne.id&&(X.current=null,ml(null)),N(null)),await k(be.signal)}catch(Z){if(be.signal.aborted)return;Z instanceof Xe&&Z.status===401?W.current():j(Z instanceof Error?Z.message:"项目操作失败,请重试。")}finally{P.current===be&&(P.current=null),be.signal.aborted||_(null)}};return m?s.jsx(S.Fragment,{children:t(null)},"single-project"):b?s.jsxs(S.Fragment,{children:[x?s.jsxs("div",{className:"project-connection-note",role:"status",children:["项目状态暂时无法刷新,当前工作台会保留。",x]}):null,t(b,fe)]},`${b.id}:${b.generation}`):s.jsxs("main",{className:"projects-page",children:[s.jsxs("header",{className:"projects-header",children:[s.jsxs("div",{className:"auth-brand",children:["CodeShell ",s.jsx("span",{children:r?"Cloud":"Hub"})]}),s.jsx(bf,{}),r,s.jsx("h1",{children:"你的项目"}),s.jsx("p",{children:"每个项目有独立的运行环境、文件、会话和配置。启动后进入同一个工作台。"})]}),R?s.jsx("p",{role:"status",children:"正在读取项目…"}):null,x?s.jsxs("div",{className:"form-error",role:"alert",children:[x,s.jsx("button",{className:"library-button",onClick:()=>{k()},children:"刷新项目"})]}):null,h?s.jsxs(s.Fragment,{children:[h.available?null:s.jsx("p",{className:"form-error",role:"alert",children:d?"云端执行环境暂时不可用,请稍后重试或联系管理员。":s.jsxs(s.Fragment,{children:["项目运行环境暂不可用。",h.error||"请检查服务端 Docker 是否已启动。"]})}),s.jsxs("form",{className:"project-create",onSubmit:E=>{E.preventDefault(),le("create")},children:[s.jsxs("label",{children:["新项目名称",s.jsx("input",{value:D,maxLength:80,required:!0,placeholder:"例如:个人网站",onChange:E=>q(E.target.value)})]}),s.jsx("button",{className:"library-button primary",disabled:!!T||!D.trim(),type:"submit",children:T==="create"?"正在创建…":d?"创建并打开":"创建项目"})]}),s.jsxs("section",{className:"projects-grid","aria-label":"项目列表",children:[h.projects.length===0?s.jsx("p",{className:"project-empty",children:"创建第一个项目,开始配置模型、添加技能和使用面板。"}):null,h.projects.map(E=>s.jsxs("article",{className:"project-card",children:[s.jsxs("div",{className:"project-card-heading",children:[s.jsx("h2",{children:E.name}),s.jsx("span",{className:`project-status ${E.status}`,children:FA[E.status]})]}),s.jsxs("p",{className:"project-date",children:["创建于 ",new Date(E.createdAt).toLocaleDateString()]}),E.error?s.jsx("p",{className:"form-error",role:"alert",children:E.error}):null,s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{className:"library-button primary",disabled:!!T||!h.available||E.status==="starting"||E.status==="stopping",onClick:()=>E.status==="running"?Q(E):void le("start",E),children:T===E.id||E.status==="starting"||E.status==="stopping"?"正在处理…":E.status==="running"?"打开项目":"启动并打开"}),E.status==="running"?s.jsx("button",{className:"library-button",disabled:!!T,onClick:()=>N(E),children:"停止项目"}):null]})]},E.id))]})]}):null,se?s.jsxs("dialog",{className:"project-stop-confirm",ref:U,role:"alertdialog","aria-modal":"true","aria-labelledby":"project-stop-title",onCancel:E=>{E.preventDefault(),T||N(null)},children:[s.jsxs("h2",{id:"project-stop-title",children:["停止 ",se.name,"?"]}),s.jsx("p",{children:"正在运行的任务和面板进程会中断。项目文件和配置保留,可稍后重新启动。"}),s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{className:"library-button primary",disabled:!!T,onClick:()=>N(null),children:"继续运行"}),s.jsx("button",{className:"library-button",disabled:!!T,onClick:()=>{le("stop",se)},children:"确认停止"})]})]}):null]})}function PA({setupToken:t}){const[i,r]=S.useState("checking"),[a,u]=S.useState(),[d,c]=S.useState(),[h,p]=S.useState(!1),[m,y]=S.useState(""),[b,v]=S.useState(""),[x,j]=S.useState(""),[R,C]=S.useState(t),[T,_]=S.useState(""),[D,q]=S.useState(!1),[se,N]=S.useState(""),U=S.useRef(!1),X=S.useRef(!1),H=S.useRef(!1),A=S.useRef(0),I=S.useRef(i);I.current=i;const L=S.useCallback(B=>{H.current&&(X.current=B?.mode==="cloud-account",p(X.current),c(B?.cloudSession),u(B?.session),r(B===null?"legacy":B.mode==="cloud-account"?B.authenticated?"authenticated":"cloud-login":B.initialized?B.authenticated?"authenticated":"login":"setup"),q(!1),_(""),B?.initialized&&C(""))},[]),P=S.useCallback(()=>{H.current&&(A.current++,u(void 0),c(void 0),r(X.current?"cloud-login":"login"),v(""),_(X.current?"Cloud 管理登录已失效,请从桌面 Cloud 管理器重新打开。":"登录已过期或此设备已被撤销,请重新登录。"))},[]),W=S.useCallback(async()=>{if(U.current)return;const B=++A.current;try{const Q=await T1();if(B===A.current&&X.current&&Q?.mode!=="cloud-account"){P();return}B===A.current&&L(Q)}catch(Q){if(!H.current||B!==A.current)return;if(X.current&&(Q instanceof Xe&&Q.status===401||Q instanceof Ob)){P();return}if(I.current==="authenticated"||I.current==="legacy")return;r("error"),_(Q instanceof Error?Q.message:"无法连接服务端")}},[L,P]);S.useEffect(()=>{H.current=!0,W();const B=()=>{W()},Q=()=>{document.visibilityState==="visible"&&W()};return window.addEventListener("focus",B),document.addEventListener("visibilitychange",Q),()=>{H.current=!1,window.removeEventListener("focus",B),document.removeEventListener("visibilitychange",Q)}},[W]),S.useEffect(()=>{if(!d)return;const B=setTimeout(P,Math.max(0,d.expiresAt-Date.now()));return()=>clearTimeout(B)},[d,P]);const ee=async()=>{if(U.current||!X.current)return;U.current=!0;const B=++A.current;q(!0),N("");try{const Q=await Vd("/api/v1/auth/logout");if(!H.current||B!==A.current)return;if(Q.revoked!==!0)throw new Error("Cloud 退出尚未确认。");P(),_("此 Cloud 工作台已退出。请从桌面 Cloud 管理器重新打开。")}catch(Q){if(!H.current||B!==A.current)return;Q instanceof Xe&&Q.status===401?P():N("未能确认退出此 Cloud 工作台,请重试。也可关闭此页并在桌面撤销登录。")}finally{U.current=!1,H.current&&q(!1)}},G=async B=>{if(B.preventDefault(),D||X.current)return;const Q=++A.current;q(!0),_("");try{const fe=await Vd(`/api/v1/auth/${i==="setup"?"setup":"login"}`,{username:m.trim(),password:b,deviceName:x.trim()||void 0,...i==="setup"?{token:R.trim()}:{}});if(!H.current||Q!==A.current)return;if(!fe.authenticated)throw new Error("登录失败,请重试。");v(""),C(""),L({initialized:!0,authenticated:!0,session:fe.session})}catch(fe){if(!H.current||Q!==A.current)return;_(fe instanceof Error?fe.message:"登录失败,请重试。"),fe instanceof Xe&&fe.status===409&&W()}finally{H.current&&Q===A.current&&q(!1)}};if(i==="authenticated"){const B=h?{pending:D,error:se,onLogout:()=>{ee()},accountOrigin:d?.accountOrigin}:void 0;return s.jsx(ux,{onAuthLost:P,allowLegacy:!h,accountControl:B?s.jsx(Gb,{...B}):void 0,children:(Q,fe)=>s.jsx(cf,{session:a,hub:!0,onAuthLost:P,onCheckAuth:W,projectName:Q?.name,onBackToProjects:fe,cloudAccount:B})},d?`${d.audience}:${d.installationId}:${d.managementEpoch}:${d.accountOrigin}:${d.accountId}:${d.id}`:a?.id)}return i==="legacy"?s.jsx(cf,{session:a,hub:!1,onAuthLost:P,onCheckAuth:W}):s.jsx("main",{className:"auth-page",children:s.jsxs("section",{className:"auth-card",children:[s.jsx(bf,{discover:!1}),s.jsxs("div",{className:"auth-brand",children:["CodeShell ",s.jsx("span",{children:h?"Cloud":"Hub"})]}),i==="checking"?s.jsx("p",{role:"status",children:"正在连接你的工作空间…"}):null,i==="error"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"form-error",role:"alert",children:T}),s.jsx("button",{className:"send",onClick:()=>{W()},children:"重试连接"})]}):null,i==="cloud-login"?s.jsxs(s.Fragment,{children:[s.jsx("h1",{children:"请从桌面 Cloud 管理器登录"}),s.jsx("p",{children:"在 CodeShell 桌面端登录云账号,再从 Cloud 管理器打开这个工作台。"}),T?s.jsx("p",{role:"status",children:T}):null,s.jsx("button",{className:"send",onClick:()=>{W()},children:"重新检查 Cloud 登录"})]}):null,i==="setup"||i==="login"?s.jsxs("form",{onSubmit:B=>{G(B)},children:[s.jsx("h1",{children:i==="setup"?"创建管理员账号":"登录工作空间"}),s.jsx("p",{children:i==="setup"?"首次启动需要服务端提供的初始化令牌。创建后,可在其他设备使用此账号登录。":"连接服务端,继续你的会话与任务。"}),i==="setup"?s.jsxs("label",{children:["初始化令牌",s.jsx("input",{type:"password",autoComplete:"off",required:!0,value:R,onChange:B=>C(B.target.value)})]}):null,s.jsxs("label",{children:["用户名",s.jsx("input",{autoComplete:"username",required:!0,maxLength:64,value:m,onChange:B=>y(B.target.value)})]}),s.jsxs("label",{children:["密码",s.jsx("input",{type:"password",autoComplete:i==="setup"?"new-password":"current-password",required:!0,maxLength:256,minLength:i==="setup"?12:void 0,value:b,onChange:B=>v(B.target.value)})]}),i==="setup"?s.jsx("small",{children:"密码至少 12 个字符。"}):null,s.jsxs("label",{children:["设备名称 ",s.jsx("span",{children:"(可选)"}),s.jsx("input",{autoComplete:"off",maxLength:100,placeholder:"例如:我的笔记本",value:x,onChange:B=>j(B.target.value)})]}),T?s.jsx("p",{className:"form-error",role:"alert",children:T}):null,s.jsx("button",{className:"send",type:"submit",disabled:D,children:D?"正在连接…":i==="setup"?"创建并进入":"登录"})]}):null]})})}async function bl(t){const i=globalThis.navigator?.locks;if(!i?.request)throw new Error("浏览器不支持安全的登录会话管理,请使用新版 Chrome、Edge、Firefox 或 Safari。");return await i.request("codeshell:account-web:cookie-v1",{mode:"exclusive"},t)}const Gd="/api/v1/account/web",Ra=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/,ho=/^[A-Za-z0-9_-]{43}$/,Rb={invalid_credentials:"用户名或密码不正确。",invalid_username:"用户名须为 3–64 位字母、数字、点、下划线或连字符。",username_unavailable:"这个用户名已被使用,请换一个。",invalid_display_name:"昵称须为 1–64 个字符,且不能包含控制字符。",invalid_password:"密码须为 12–1024 个字符。",incorrect_password:"当前密码不正确,请重新输入。",password_changed:"密码已在其他页面修改,请使用最新密码重试。",password_not_configured:"此账号尚未设置密码,请继续使用 GitHub 登录。",registration_disabled:"当前服务未开放注册,请使用已有账号登录。",authentication_required:"登录已过期,请重新登录。",invalid_session:"登录已过期,请重新登录。",invalid_web_session:"登录已过期,请重新登录。",csrf_required:"页面验证已过期,请刷新后重试。",invalid_csrf:"页面验证已过期,请刷新后重试。",github_login_failed:"GitHub 登录未完成,请重新发起登录。",github_login_denied:"GitHub 授权未完成,请重新发起。",invalid_github_receipt:"GitHub 授权请求已失效,请重新发起。",provider_already_linked:"这个 GitHub 身份已关联到其他账号,或当前账号已有不同的 GitHub 身份。",account_login_required:"登录已失效,请重新登录后关联 GitHub。",administrator_required:"当前账号没有管理员权限。",protected_administrator:"不能停用当前账号或其他管理员。",too_many_attempts:"操作过于频繁,请稍后再试。",too_many_account_sessions:"登录会话已达上限,请先退出其他设备。",account_not_found:"账号已不存在,请刷新列表。",session_not_found:"此登录会话已结束,请刷新列表。",link_management_disabled:"当前服务尚未开放数据连接管理。",link_management_unavailable:"数据连接服务暂时不可用,请稍后重试。",cloud_management_disabled:"当前服务尚未配置云端工作区。"};class Ze extends Error{constructor(i,r=0,a){super(i),this.status=r,this.code=a}status;code}function so(t,i,r){const a=t,u=typeof a?.error=="string"?a.error:void 0;if(r==="/github/poll"&&u==="github_login_failed"){if(a?.reason==="provider_timeout")return new Ze("服务器连接 GitHub 超时,请重新发起授权。",i,u);if(a?.reason==="provider_unavailable")return new Ze("服务器暂时无法访问 GitHub,请稍后重新发起授权。",i,u)}return new Ze(u&&Object.hasOwn(Rb,u)?Rb[u]:"操作未完成,请稍后重试。",i,u)}function ff(t){if(typeof t!="string")return!1;try{const i=new URL(t);return i.origin===t&&!i.username&&!i.password&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}}function Gf(t){const i=t;return!!i&&Ra.test(i.id)&&typeof i.username=="string"&&/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(i.username)&&typeof i.displayName=="string"&&[...i.displayName].length>=1&&[...i.displayName].length<=64&&!/[\p{Cc}\p{Cs}]/u.test(i.displayName)&&["member","admin"].includes(i.role)}function Vf(t){const i=t;return!!i&&ff(i.cloudOrigin)&&ff(i.accountOrigin)&&Ra.test(i.installationId)}function Wn(t){const i=t,r=i&&{...i,cloudTarget:i.cloudTarget?.enabled===!1?null:i.cloudTarget};if(!r||i.accessToken!==void 0||i.refreshToken!==void 0||typeof r.authenticated!="boolean"||(r.authenticated||r.refreshRequired)&&!ho.test(r.csrfToken??"")||!r.authenticated&&typeof r.refreshRequired!="boolean"||r.cloudTarget!==null&&!Vf(r.cloudTarget)||r.authenticated&&(!Gf(r.account)||!r.session||!Ra.test(r.session.id)||!Number.isSafeInteger(r.session.expiresAt)||r.session.expiresAt<=Date.now())||!r.authenticated&&(r.account!==void 0||r.session!==void 0))throw new Ze("账号服务返回了无效的会话,请刷新后重试。");const a=r.authenticated?cx(r.overview,r.account.id):void 0;if(a&&a.account.role!==r.account.role)throw new Ze("账号服务返回了不一致的权限,请刷新后重试。");return{authenticated:r.authenticated,...typeof r.csrfToken=="string"?{csrfToken:r.csrfToken}:{},...typeof r.refreshRequired=="boolean"?{refreshRequired:r.refreshRequired}:{},cloudTarget:r.cloudTarget?{cloudOrigin:r.cloudTarget.cloudOrigin,accountOrigin:r.cloudTarget.accountOrigin,installationId:r.cloudTarget.installationId}:null,...a?{account:{id:r.account.id,username:r.account.username,displayName:r.account.displayName,role:r.account.role},overview:a,session:{id:r.session.id,expiresAt:r.session.expiresAt}}:{}}}function cx(t,i){const r=t;if(!r||!Gf(r.account)||r.account.id!==i||typeof r.security?.hasPassword!="boolean"||typeof r.security?.githubLinked!="boolean"||![r.capabilities?.sessions,r.capabilities?.passwordChange,r.capabilities?.admin,r.capabilities?.links].every(a=>typeof a=="boolean")||r.capabilities.admin!==(r.account.role==="admin")||![r.stats?.activeSessions,r.stats?.loginMethods].every(a=>Number.isSafeInteger(a)&&a>=0))throw new Ze("账号服务返回了无效的资料,请刷新后重试。");return{account:{id:r.account.id,username:r.account.username,displayName:r.account.displayName,role:r.account.role},security:{hasPassword:r.security.hasPassword,githubLinked:r.security.githubLinked},capabilities:{sessions:r.capabilities.sessions,passwordChange:r.capabilities.passwordChange,admin:r.capabilities.admin,links:r.capabilities.links},stats:{activeSessions:r.stats.activeSessions,loginMethods:r.stats.loginMethods}}}class QA{constructor(i=globalThis.fetch.bind(globalThis)){this.fetcher=i}fetcher;epoch=0;csrfToken="";requests=new Set;rootId;onSessionLost;setCsrf(i){this.csrfToken=i}setSession(i){this.rootId!==i.session?.id&&this.invalidate(),this.csrfToken=i.csrfToken??"",this.rootId=i.session?.id}async nativeRequest(i,r,a){if(!/^\/(?:login|register|github\/(?:start|poll|cancel))$/.test(i))throw new Ze("登录请求地址无效。");const u=this.epoch,d=AbortSignal.timeout(i==="/github/poll"?2e4:1e4);try{const c=await this.fetcher("/api/v1/account"+i,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",signal:d,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),h=await c.json();if(a?.(h),u!==this.epoch)throw h?.accessToken&&this.revokeTransient(h),new Ze("账号状态已改变。");if(!c.ok)throw so(h,c.status,i);return h}catch(c){throw c instanceof Ze?c:new Ze(i==="/github/poll"&&(d.aborted||c?.name==="TimeoutError")?"等待 GitHub 登录验证超时,请重新发起授权。":"无法连接账号服务,请检查网络后重试。")}}async revokeTransient(i){ho.test(i?.accessToken??"")&&await this.fetcher("/api/v1/account/logout",{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json",Authorization:"Bearer "+i.accessToken},body:"{}"}).catch(()=>{})}async exchangeGrant(i,r){const a=this.rootId;if(!ho.test(i?.accessToken??"")||!ho.test(i?.refreshToken??"")||!Ra.test(i?.account?.id??"")||!Ra.test(i?.sessionId??"")||!Number.isSafeInteger(i?.accessTokenExpiresAt)||i.accessTokenExpiresAt<=Date.now())throw new Ze("登录授权结果无效,请重新发起。");return bl(async()=>{if(!r())throw await this.revokeTransient(i),new Ze("账号状态已改变。");let u;try{u=Wn(await this.request("/session"))}catch(p){if(!(p instanceof Ze&&p.status===401&&a===void 0))throw p;u={authenticated:!1,refreshRequired:!1,cloudTarget:null}}if(u.refreshRequired&&(u=Wn(await this.cookieRequest("/refresh","POST",{},u.csrfToken))),(u.authenticated?u.session?.id:void 0)!==a)throw await this.revokeTransient(i),new Ze("其他页面已切换账号,请刷新后重新发起登录。");if(!r())throw await this.revokeTransient(i),new Ze("账号状态已改变。");const d=await this.fetcher(Gd+"/session",{method:"POST",credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json",Authorization:"Bearer "+i.accessToken},body:JSON.stringify({refreshToken:i.refreshToken})}),c=await d.json();if(!d.ok)throw so(c,d.status,"/session");const h=Wn(c);if(!h.authenticated||h.account?.id!==i.account.id||h.session?.id!==i.sessionId)throw new Ze("账号登录结果不一致,请重新登录。");if(!r())throw this.setSession(h),await this.cookieRequest("/logout","POST",{}),this.setSession({authenticated:!1,refreshRequired:!1,cloudTarget:h.cloudTarget}),new Ze("账号状态已改变。");return this.setSession(h),h})}async restoreSession(i=5e3){return bl(async()=>{let r=Wn(await this.request("/session"));return(r.refreshRequired||r.authenticated&&r.session.expiresAt<=Date.now()+i)&&(r=Wn(await this.cookieRequest("/refresh","POST",{},r.csrfToken))),r})}async logoutSession(){const i=this.rootId;return bl(async()=>{let r=Wn(await this.request("/session"));if(r.refreshRequired){if(r.csrfToken!==this.csrfToken)throw new Ze("其他页面已切换账号,请刷新后确认。");r=Wn(await this.cookieRequest("/refresh","POST",{},r.csrfToken))}if(r.authenticated&&r.session?.id!==i)throw new Ze("其他页面已切换账号,请刷新后确认。");if(this.setSession(r),r.authenticated&&(await this.cookieRequest("/logout","POST",{})).ok!==!0)throw new Ze("服务端尚未确认退出,请重试。");return{authenticated:!1,refreshRequired:!1,cloudTarget:r.cloudTarget}})}async cookieRequest(i,r,a,u=this.csrfToken){const d=await this.fetcher(Gd+i,{method:r,credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{...a===void 0?{}:{"Content-Type":"application/json"},"X-CodeShell-CSRF":u},body:a===void 0?void 0:JSON.stringify(a)}),c=await d.json();if(!d.ok)throw so(c,d.status,i);if(c?.accessToken!==void 0||c?.refreshToken!==void 0)throw new Ze("账号服务返回了不支持的授权结果。");return c}invalidate(){this.epoch++;for(const i of this.requests)i.abort();this.requests.clear()}async request(i,r="GET",a,u,d,c=0){if(!/^\/[A-Za-z0-9/?=&_-]+$/.test(i)||i.startsWith("//"))throw new Ze("账号请求地址无效。");if(r!=="GET"&&!this.csrfToken)throw new Ze("页面验证尚未完成,请刷新后重试。");if(r==="DELETE"&&/^\/sessions\/[0-9a-f-]{36}$/.test(i)){const b=this.rootId;return bl(async()=>{const v=Wn(await this.request("/session"));if(!v.authenticated||v.session?.id!==b)throw new Ze("账号状态已改变,请刷新后重试。");return this.setSession(v),this.cookieRequest(i,r)})}const h=this.epoch,p=this.rootId,m=new AbortController;this.requests.add(m);const y=AbortSignal.timeout(i==="/github/poll"?2e4:1e4);try{const b=await this.fetcher(Gd+i,{method:r,credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.any([m.signal,y,...u?[u]:[]]),headers:{...a===void 0?{}:{"Content-Type":"application/json"},...this.csrfToken?{"X-CodeShell-CSRF":this.csrfToken}:{}},body:a===void 0?void 0:JSON.stringify(a)}),v=await b.json();if(d?.(v),h!==this.epoch||u?.aborted)throw new Ze("账号状态已改变。");if(v?.accessToken!==void 0||v?.refreshToken!==void 0)throw new Ze("账号服务返回了不支持的授权结果。");if(!b.ok){if(b.status===401&&c===0&&i!=="/session"&&i!=="/refresh"&&!i.startsWith("/github/")){const x=p;try{const j=await this.restoreSession();if(j.authenticated&&j.session?.id===x&&h===this.epoch&&this.rootId===p)return this.setSession(j),await this.request(i,r,a,u,d,1)}catch{}}throw h!==this.epoch||p!==this.rootId?new Ze("账号状态已改变。"):(b.status===401&&i!=="/session"&&i!=="/refresh"&&!i.startsWith("/github/")&&this.onSessionLost?.(),so(v,b.status,i))}return v}catch(b){throw b instanceof Ze?b:h!==this.epoch||u?.aborted||m.signal.aborted?new Ze("账号状态已改变。"):new Ze(i==="/github/poll"&&(y.aborted||b?.name==="TimeoutError")?"等待 GitHub 登录验证超时,请重新发起授权。":"无法连接账号服务,请检查网络后重试。")}finally{this.requests.delete(m)}}}const dx=S.createContext(null);function ti(){const t=S.useContext(dx);if(!t)throw new Error("Account session provider is missing");return t}function XA({children:t}){const i=S.useRef(null);i.current??=new QA;const r=i.current,[a,u]=S.useState(null),d=S.useRef(a);d.current=a;const[c,h]=S.useState(!1),[p,m]=S.useState(!1),y=S.useRef(!1),[b,v]=S.useState(""),[x,j]=S.useState(""),[R,C]=S.useState({registrationAllowed:!1,githubEnabled:!1}),[T,_]=S.useState(!1),D=S.useRef(null),q=S.useRef(0),se=S.useRef(!1),N=B=>se.current&&B===q.current,U=B=>{y.current=B,m(B)},X=B=>v(B instanceof Error?B.message:"请求失败,请稍后重试。"),H=B=>{const Q=Wn(B);r.setSession(Q),u(Q),d.current=Q,h(!0)},A=B=>(B.popup.close(),B.mode==="link"&&(B.accountId!==d.current?.account?.id||B.rootId!==d.current?.session?.id)?Promise.resolve():(B.receipt&&!B.cleanup&&(B.cleanup=(B.mode==="login"?r.nativeRequest("/github/cancel",{receipt:B.receipt,codeVerifier:B.verifier}):r.request("/github/cancel","POST",{receipt:B.receipt,codeVerifier:B.verifier})).then(()=>{},()=>{})),B.cleanup??Promise.resolve())),I=()=>{const B=D.current;B&&(B.cancelled=!0,D.current=null,B.mode==="login"&&q.current++,A(B),_(!1),U(!1),v(""),j(B.mode==="link"?"已取消关联流程,可刷新连接状态确认。":"已取消登录。"))},L=S.useCallback(async()=>{if(y.current)return;const B=++q.current;U(!0),v("");try{const Q=await r.restoreSession();N(B)&&H(Q)}catch(Q){N(B)&&(Q instanceof Ze&&Q.status===401?H({authenticated:!1,refreshRequired:!1,cloudTarget:null}):h(!1),X(Q))}finally{N(B)&&U(!1)}},[r]);S.useEffect(()=>{se.current=!0,r.onSessionLost=()=>{q.current++,r.invalidate();const fe=d.current;if(fe){const k={authenticated:!1,refreshRequired:!1,cloudTarget:fe.cloudTarget};u(k),d.current=k,r.setSession(k)}j(""),v("登录已过期,请重新登录。"),U(!1)},L();const B=new AbortController;fetch("/api/v1/account/status",{credentials:"omit",cache:"no-store",redirect:"error",signal:B.signal}).then(async fe=>{if(!fe.ok)throw new Error("登录方式暂时无法读取。");const k=await fe.json();if(typeof k.registrationAllowed!="boolean"||typeof k.githubEnabled!="boolean")throw new Error("登录方式数据无效。");B.signal.aborted||C({registrationAllowed:k.registrationAllowed,githubEnabled:k.githubEnabled})}).catch(()=>{});const Q=()=>{D.current||L()};return window.addEventListener("focus",Q),()=>{se.current=!1,q.current++,y.current=!1,D.current&&(D.current.cancelled=!0,A(D.current),D.current=null),r.invalidate(),B.abort(),window.removeEventListener("focus",Q)}},[r,L]),S.useEffect(()=>{if(!a?.authenticated||!a.session)return;let B;const Q=async()=>{if(y.current){B=setTimeout(Q,1e3);return}const fe=q.current;try{const k=await r.restoreSession(6e4);N(fe)&&H(k)}catch(k){N(fe)&&(k instanceof Ze&&k.status===401?r.onSessionLost?.():X(k))}};return B=setTimeout(Q,Math.max(1e3,a.session.expiresAt-Date.now()-6e4)),()=>clearTimeout(B)},[r,a]);const P=async(B,Q)=>{if(y.current||!c)return!1;const fe=++q.current;r.invalidate(),U(!0),v(""),j("");try{const k=await r.nativeRequest("/"+B,{...Q,deviceName:"CodeShell 网站"});if(!N(fe))return r.revokeTransient(k),!1;try{const O=await r.exchangeGrant(k,()=>N(fe));if(!N(fe))return!1;H(O)}catch(O){throw r.revokeTransient(k),O}return!0}catch(k){return N(fe)&&X(k),!1}finally{N(fe)&&U(!1)}},W=async()=>{I();const B=++q.current;r.invalidate(),U(!0),v(""),j("");const Q=d.current;if(Q){const fe={authenticated:!1,refreshRequired:!1,csrfToken:Q.csrfToken,cloudTarget:Q.cloudTarget};u(fe),d.current=fe}try{const fe=await r.logoutSession();return N(B)&&H(fe),!0}catch(fe){return N(B)&&(h(!1),X(fe)),!1}finally{N(B)&&U(!1)}},ee=async B=>{if(y.current||!c||!R.githubEnabled||B==="link"&&!d.current?.authenticated)return;const Q=window.open("about:blank","_blank");if(!Q){v("请允许此页打开 GitHub 授权窗口后重试。");return}Q.opener=null;const fe=J=>btoa(String.fromCharCode(...J)).replaceAll("+","-").replaceAll("/","_").replaceAll("=",""),k={popup:Q,mode:B,verifier:fe(crypto.getRandomValues(new Uint8Array(32))),cancelled:!1,accountId:d.current?.account?.id,rootId:d.current?.session?.id};D.current=k;const O=d.current?.account?.id,le=B==="login"?++q.current:q.current,E=()=>N(le)&&D.current===k&&!k.cancelled&&(B!=="link"||d.current?.account?.id===O);U(!0),_(!0),v(""),j(B==="link"?"请在 GitHub 页面确认要关联的身份。":"请在 GitHub 页面完成登录,最终结果会显示在这里。");try{const J=fe(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(k.verifier))));if(!E())return;const be=ge=>{/^[A-Za-z0-9_-]{43}$/.test(ge?.receipt)&&(k.receipt=ge.receipt),k.cancelled&&A(k)},Z=B==="login"?await r.nativeRequest("/github/start",{codeChallenge:J},be):await r.request("/github/start","POST",{codeChallenge:J,mode:B},void 0,be);if(!E())return;const ne=new URL(Z.authorizationUrl);if(ne.origin!=="https://github.com"||ne.pathname!=="/login/oauth/authorize"||ne.username||ne.password||ne.hash||ne.searchParams.get("code_challenge")!==J||ne.searchParams.get("code_challenge_method")!=="S256"||ne.searchParams.get("scope")!=="read:user"||!k.receipt||!Number.isSafeInteger(Z.expiresAt)||Z.expiresAt<=Date.now()||Z.expiresAt>Date.now()+9e5)throw new Ze("GitHub 授权请求无效,请重新发起。");for(Q.location.href=ne.href;Date.now()<Z.expiresAt&&E();){const ge={receipt:Z.receipt,codeVerifier:k.verifier,deviceName:"CodeShell 网站"},Y=B==="login"?await r.nativeRequest("/github/poll",ge):await r.request("/github/poll","POST",ge);if(!E()){Y?.accessToken&&r.revokeTransient(Y);return}if(Y.status!=="pending"){if(B==="link"){if(Y.linked!==!0||Y.account?.id!==O)throw new Ze("GitHub 关联结果无效,请刷新后重试。");j("GitHub 登录身份已关联,数据授权保持独立。")}else try{const ve=await r.exchangeGrant(Y,E);E()&&(H(ve),j(""))}catch(ve){throw r.revokeTransient(Y),ve}return}await new Promise(ve=>setTimeout(ve,Math.min(1e4,Math.max(1e3,Z.pollIntervalMs||1e3))))}if(E())throw new Ze("GitHub 授权已超时,请重新发起。")}catch(J){E()&&(j(""),X(J))}finally{A(k),D.current===k&&(D.current=null,_(!1),N(le)&&U(!1))}},G=S.useCallback((...B)=>r.request(...B),[r]);return s.jsx(dx.Provider,{value:{session:a,ready:c,busy:p,error:b,status:x,...R,oauthPending:T,restore:L,signIn:P,logout:W,github:ee,cancelGithub:I,clearError:()=>v(""),workspaceActive:B=>!y.current&&d.current?.authenticated===!0&&`${d.current.account.id}:${d.current.session.id}`===B,request:G},children:t})}function _o(t){const{request:i}=ti(),[r,a]=S.useState(),[u,d]=S.useState(""),[c,h]=S.useState(!!t),[p,m]=S.useState(0);return S.useEffect(()=>{const y=new AbortController;return a(void 0),d(""),h(!!t),t&&i(t,"GET",void 0,y.signal).then(b=>{y.signal.aborted||a(b)}).catch(b=>{y.signal.aborted||d(b.message)}).finally(()=>{y.signal.aborted||h(!1)}),()=>y.abort()},[t,i,p]),{value:r,error:u,loading:c,reload:()=>m(y=>y+1)}}function Sr({error:t,status:i}){return s.jsxs(s.Fragment,{children:[t?s.jsx("p",{className:"form-error",role:"alert",children:t}):null,i?s.jsx("p",{className:"website-notice",role:"status",children:i}):null]})}const So=t=>Number.isSafeInteger(t)&&t>=0?new Date(t).toLocaleString():"—",ji=t=>typeof t=="string"&&/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(t);function KA({route:t}){const i=ti(),r=_o("/overview");let a,u="";if(r.value&&i.session?.account)try{a=cx(r.value,i.session.account.id)}catch(c){u=c.message}const d=a?.capabilities.admin===!0&&i.session?.account?.role==="admin";return s.jsxs("section",{className:"website-settings-content",children:[s.jsx(Sr,{error:r.error||u}),r.loading?s.jsx("p",{role:"status",children:"正在读取账号设置…"}):null,r.error||u?s.jsx("button",{className:"website-button",onClick:r.reload,children:"重试读取"}):null,a&&t.kind==="account"?s.jsxs(s.Fragment,{children:[t.section==="profile"?s.jsx(ZA,{profile:a.account},a.account.id):null,t.section==="security"?s.jsx(JA,{overview:a}):null,t.section==="sessions"?s.jsx(WA,{enabled:a.capabilities.sessions}):null,t.section==="connections"?s.jsx(eT,{overview:a,reload:r.reload}):null]}):null,a&&t.kind==="admin"?d?s.jsx(tT,{section:t.section}):s.jsx("p",{role:"alert",children:"当前账号没有管理员权限。"}):null]})}function ZA({profile:t}){const i=ti(),[r,a]=S.useState(t.displayName),[u,d]=S.useState(t.username),[c,h]=S.useState(!1),[p,m]=S.useState(""),[y,b]=S.useState(""),v=S.useRef(!0);S.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const x=async j=>{j.preventDefault();const R=r.trim().normalize("NFC"),C=u.trim().toLowerCase();if(!R||[...R].length>64||/[\p{Cc}\p{Cs}\u061c\u200b\u200e\u200f\u202a-\u202e\u2066-\u2069\ufeff]/u.test(R)){m("昵称须为 1–64 个字符,且不能包含控制字符。");return}if(!/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(C)){m("用户名须为 3–64 位字母、数字、点、下划线或连字符。");return}const T={...R===t.displayName?{}:{displayName:R},...C===t.username?{}:{username:C}};if(!(c||!Object.keys(T).length)){h(!0),m(""),b("");try{if((await i.request("/profile","PATCH",T)).account?.id!==t.id)throw new Ze("账号资料结果无效,请刷新后重试。");await i.restore(),v.current&&b("账号资料已保存。")}catch(_){v.current&&m(_.message)}finally{v.current&&h(!1)}}};return s.jsxs(s.Fragment,{children:[s.jsx(La,{title:"账号资料",description:"昵称用于显示,用户名用于密码登录,分别修改。"}),s.jsxs("form",{className:"website-settings-card",onSubmit:j=>{x(j)},children:[s.jsxs("label",{children:["昵称",s.jsx("input",{autoComplete:"nickname",value:r,maxLength:128,disabled:c,onChange:j=>a(j.target.value)})]}),s.jsxs("label",{children:["登录用户名",s.jsx("input",{autoComplete:"username",value:u,maxLength:64,disabled:c,onChange:j=>d(j.target.value)}),s.jsx("small",{children:"修改用户名后,请使用新的用户名登录。昵称不会自动变化。"})]}),s.jsx("button",{className:"website-button primary",type:"submit",disabled:c,children:c?"保存中…":"保存修改"}),s.jsx(Sr,{error:p,status:y})]})]})}function La({title:t,description:i}){return s.jsxs("header",{className:"website-settings-heading",children:[s.jsx("p",{className:"website-eyebrow",children:"设置"}),s.jsx("h1",{children:t}),s.jsx("p",{className:"website-muted",children:i})]})}function JA({overview:t}){const{request:i}=ti(),[r,a]=S.useState(""),[u,d]=S.useState(""),[c,h]=S.useState(""),[p,m]=S.useState(!1),[y,b]=S.useState(""),[v,x]=S.useState(""),j=S.useRef(void 0);S.useEffect(()=>()=>j.current?.abort(),[]);const R=async C=>{if(C.preventDefault(),p||!t.capabilities.passwordChange)return;if(b(""),u.length<12||u.length>1024){b("新密码须为 12–1024 个字符。");return}if(u!==c){b("两次输入的新密码不一致。");return}if(!window.confirm("修改密码后,其他登录会话及其设备授权将退出。继续修改吗?"))return;const T=new AbortController;j.current=T,m(!0),x("");try{await i("/password","POST",{currentPassword:r,newPassword:u},T.signal),T.signal.aborted||(a(""),d(""),h(""),x("密码已修改,其他登录会话已退出。"))}catch(_){T.signal.aborted||b(_.message)}finally{T.signal.aborted||m(!1)}};return s.jsxs(s.Fragment,{children:[s.jsx(La,{title:"安全",description:"管理密码与账号登录方式。"}),s.jsxs("div",{className:"website-settings-card",children:[s.jsx("h2",{children:"密码"}),t.capabilities.passwordChange?s.jsxs("form",{onSubmit:C=>{R(C)},children:[s.jsxs("label",{children:["当前密码",s.jsx("input",{type:"password",autoComplete:"current-password",maxLength:1024,value:r,disabled:p,onChange:C=>a(C.target.value),required:!0})]}),s.jsxs("label",{children:["新密码",s.jsx("input",{type:"password",autoComplete:"new-password",maxLength:1024,value:u,disabled:p,onChange:C=>d(C.target.value),required:!0})]}),s.jsxs("label",{children:["确认新密码",s.jsx("input",{type:"password",autoComplete:"new-password",maxLength:1024,value:c,disabled:p,onChange:C=>h(C.target.value),required:!0})]}),s.jsx("button",{className:"website-button",disabled:p,type:"submit",children:"修改密码"})]}):s.jsx("p",{className:"website-muted",children:"此账号使用 GitHub 登录,尚未设置密码。请继续使用 GitHub。"}),s.jsx(Sr,{error:y,status:v})]})]})}function WA({enabled:t}){const i=ti(),r=_o(t?"/sessions":null),[a,u]=S.useState(!1),[d,c]=S.useState(""),h=S.useRef(!0);S.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const p=async y=>{if(!(a||!window.confirm(y?.current?"退出当前登录?未发送内容会被清除。":y?"退出此登录会话?其派生设备授权也会撤销。":"退出其他所有登录会话及其设备授权?"))){u(!0),c("");try{await i.request(y?`/sessions/${y.id}`:"/sessions/revoke-others",y?"DELETE":"POST",y?void 0:{}),y?.current?await i.restore():h.current&&r.reload()}catch(b){h.current&&c(b.message)}finally{h.current&&u(!1)}}},m=r.value&&Array.isArray(r.value.sessions)&&r.value.sessions.length<=64&&r.value.sessions.every(y=>ji(y.id)&&typeof y.deviceName=="string"&&typeof y.current=="boolean"&&Number.isSafeInteger(y.expiresAt));return s.jsxs(s.Fragment,{children:[s.jsx(La,{title:"登录会话",description:"查看账号的有效登录,退出不再使用的设备或浏览器。"}),t?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"website-action-row",children:[s.jsx("button",{className:"website-button",disabled:a,onClick:r.reload,children:"刷新"}),s.jsx("button",{className:"website-button",disabled:a,onClick:()=>{p()},children:"退出其他会话"})]}),s.jsx(Sr,{error:d||r.error||(r.value&&!m?"会话列表数据无效,请刷新后重试。":"")}),r.loading?s.jsx("p",{role:"status",children:"正在读取登录会话…"}):null,m?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"website-hint",children:r.value.hasMore?`显示最近 ${r.value.sessions.length} 个登录会话,共 ${r.value.total} 个。`:`共 ${r.value.total??r.value.sessions.length} 个有效登录。`}),s.jsx("div",{className:"website-list",children:r.value.sessions.map(y=>s.jsxs("article",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:y.deviceName}),y.current?s.jsx("span",{className:"website-tag",children:"当前登录"}):null,s.jsxs("p",{children:["创建于 ",So(y.createdAt)," · 有效期至 ",So(y.expiresAt)]})]}),s.jsx("button",{className:"website-button",disabled:a,onClick:()=>{p(y)},children:"退出"})]},y.id))})]}):null]}):s.jsx("p",{children:"当前服务尚未开放登录会话管理。"})]})}function eT({overview:t,reload:i}){const r=ti(),a=_o(t.capabilities.links?"/links":null),[u,d]=S.useState(""),[c,h]=S.useState(!1),p=S.useRef(void 0);S.useEffect(()=>()=>p.current?.abort(),[]);const m=async(v,x)=>{if(c||!window.confirm(v==="connections"?"撤销这个数据连接及相关授权?":"撤销这个工具授权?"))return;const j=new AbortController;p.current=j,h(!0),d("");try{if((await r.request(`/links/${v}/${x}`,"DELETE",void 0,j.signal)).revoked!==!0)throw new Ze("数据授权撤销尚未确认,请刷新后重试。");j.signal.aborted||a.reload()}catch(R){j.signal.aborted||d(R.message)}finally{j.signal.aborted||h(!1)}},y=a.value&&Array.isArray(a.value.connections)&&a.value.connections.length<=512&&Array.isArray(a.value.grants)&&a.value.grants.length<=4096&&a.value.connections.every(v=>ji(v.id)&&typeof v.provider=="string"&&typeof v.revoked=="boolean"&&typeof v.account?.id=="string"&&(v.account.label===void 0||typeof v.account.label=="string")&&(v.account.login===void 0||typeof v.account.login=="string"))&&a.value.grants.every(v=>ji(v.id)&&ji(v.connectionId)&&typeof v.client?.name=="string"&&typeof v.revoked=="boolean"&&Array.isArray(v.scopes)&&v.scopes.every(x=>typeof x=="string")&&Array.isArray(v.resources)&&v.resources.every(x=>typeof x=="string")),b=y?[...a.value.connections.filter(v=>!v.revoked).map(v=>({kind:"connections",id:v.id,title:v.account.label||v.account.login||v.provider,description:`${v.provider} · 数据连接`})),...a.value.grants.filter(v=>!v.revoked).map(v=>({kind:"grants",id:v.id,title:v.client.name,description:`权限:${v.scopes.join("、")} · 资源:${v.resources.join("、")}`}))]:[];return s.jsxs(s.Fragment,{children:[s.jsx(La,{title:"连接",description:"GitHub 登录身份与工具的数据访问授权分别管理。"}),s.jsxs("div",{className:"website-settings-card",children:[s.jsxs("div",{className:"website-setting-line",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"GitHub 登录身份"}),s.jsx("p",{className:"website-muted",children:"用于登录 CodeShell,不代表已授权仓库访问。"})]}),s.jsx("span",{className:"website-tag",children:t.security.githubLinked?"已关联":"未关联"})]}),!t.security.githubLinked&&r.githubEnabled?s.jsx("button",{className:"website-button",disabled:r.busy,onClick:()=>{r.github("link").then(i)},children:"关联 GitHub 登录身份"}):null,r.oauthPending?s.jsx("button",{className:"website-button",onClick:r.cancelGithub,children:"取消关联"}):null,s.jsx("button",{className:"ghost",disabled:r.busy,onClick:i,children:"刷新登录方式"}),s.jsx(Sr,{error:r.error,status:r.status})]}),s.jsx("h2",{children:"Link 数据连接"}),t.capabilities.links?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"website-button",disabled:c,onClick:a.reload,children:"刷新数据连接"}),s.jsx(Sr,{error:u||a.error||(a.value&&!y?"数据连接列表无效,请刷新后重试。":"")}),y?s.jsxs("div",{className:"website-list",children:[b.map(v=>s.jsxs("article",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:v.title}),s.jsx("p",{children:v.description})]}),s.jsx("button",{className:"website-button",disabled:c,onClick:()=>{m(v.kind,v.id)},children:"撤销"})]},`${v.kind}:${v.id}`)),b.length?null:s.jsx("p",{className:"website-muted",children:"还没有数据连接。"})]}):null]}):s.jsx("p",{className:"website-muted",children:"当前服务尚未开放数据连接管理。"}),s.jsx("p",{className:"website-hint",children:"退出登录不会自动撤销已有 Link 数据授权。"})]})}function tT({section:t}){const i=ti(),[r,a]=S.useState(null),u=_o(t==="summary"?"/admin/summary":`/admin/${t}?limit=30${r?`&cursor=${r}`:""}`),[d,c]=S.useState(!1),[h,p]=S.useState(""),m=S.useRef(void 0);S.useEffect(()=>()=>m.current?.abort(),[]);const y=async(C,T=!1)=>{if(d||!window.confirm(T?`退出 ${C.username} 的所有登录会话?`:`${C.disabled?"恢复":"停用"}账号 ${C.username}?`))return;const _=new AbortController;m.current=_,c(!0),p("");try{await i.request(`/admin/users/${C.id}${T?"/revoke-sessions":""}`,T?"POST":"PATCH",T?{}:{disabled:!C.disabled},_.signal),_.signal.aborted||u.reload()}catch(D){_.signal.aborted||(p(D.message),D instanceof Ze&&D.status===403&&i.restore())}finally{_.signal.aborted||c(!1)}},b=ji(u.value?.nextCursor)?u.value.nextCursor:null,v=u.value?.nextCursor===null||ji(u.value?.nextCursor),x=t==="users"&&Array.isArray(u.value?.users)&&u.value.users.length<=30&&v&&u.value.users.every(C=>Gf(C)&&typeof C.disabled=="boolean"&&Number.isSafeInteger(C.createdAt)&&C.createdAt>=0&&Number.isSafeInteger(C.sessionCount)&&C.sessionCount>=0)?u.value.users:null,j=t==="audit"&&Array.isArray(u.value?.events)&&u.value.events.length<=30&&v&&u.value.events.every(C=>ji(C.id)&&ji(C.actorId)&&ji(C.targetId)&&["admin.account.disabled","admin.account.enabled","admin.sessions.revoked"].includes(C.action))?u.value.events:null,R=t==="summary"&&u.value?.users&&[u.value.users.total,u.value.users.active,u.value.users.disabled,u.value.users.administrators,u.value.sessions?.active,u.value.auditEvents].every(C=>Number.isSafeInteger(C)&&C>=0)?u.value:null;return s.jsxs(s.Fragment,{children:[s.jsx(La,{title:t==="users"?"用户管理":t==="summary"?"系统统计":"操作记录",description:"管理员控制台 · 权限由服务端核验。"}),s.jsx("button",{className:"website-button",disabled:d,onClick:()=>{a(null),u.reload()},children:"刷新"}),s.jsx(Sr,{error:h||u.error}),u.loading?s.jsx("p",{role:"status",children:"正在读取…"}):null,x?s.jsx("div",{className:"website-list",children:x.map(C=>s.jsxs("article",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:C.displayName}),s.jsxs("p",{children:["@",C.username," · ",C.role==="admin"?"管理员":"成员"," ·"," ",C.disabled?"已停用":"正常"]}),s.jsxs("p",{children:[C.sessionCount," 个登录会话 · 创建于 ",So(C.createdAt)]})]}),s.jsxs("div",{className:"website-action-row",children:[C.role!=="admin"&&C.id!==i.session?.account?.id?s.jsx("button",{className:"website-button",disabled:d,onClick:()=>{y(C)},children:C.disabled?"恢复":"停用"}):null,s.jsx("button",{className:"website-button",disabled:d,onClick:()=>{y(C,!0)},children:"退出会话"})]})]},C.id))}):null,j?s.jsxs("div",{className:"website-list",children:[j.map(C=>s.jsx("article",{children:s.jsxs("div",{children:[s.jsx("strong",{children:{"admin.account.disabled":"停用账号","admin.account.enabled":"恢复账号","admin.sessions.revoked":"撤销登录会话"}[C.action]}),s.jsxs("p",{children:["操作人 ",C.actorId," · 目标 ",C.targetId]}),s.jsx("p",{children:So(C.createdAt)})]})},C.id)),j.length?null:s.jsx("p",{className:"website-muted",children:"暂无操作记录。"})]}):null,R?s.jsx("div",{className:"website-statistics",children:[["账号总数",R.users.total],["正常账号",R.users.active],["停用账号",R.users.disabled],["管理员",R.users.administrators],["有效登录",R.sessions.active],["审计事件",R.auditEvents]].map(([C,T])=>s.jsxs("article",{children:[s.jsx("span",{children:C}),s.jsx("strong",{children:T})]},C))}):null,u.value&&!x&&!j&&!R?s.jsx("p",{role:"alert",children:"管理员数据无效,请刷新后重试。"}):null,b?s.jsx("button",{className:"website-button",disabled:d||u.loading,onClick:()=>a(b),children:"下一页"}):null]})}function nT(){const t=ti(),[i,r]=S.useState(!1),[a,u]=S.useState(""),[d,c]=S.useState(""),[h,p]=S.useState(""),[m,y]=S.useState(""),[b,v]=S.useState(""),x=async j=>{if(j.preventDefault(),v(""),!/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(a.trim())){v("用户名须为 3–64 位字母、数字、点、下划线或连字符。");return}if(h.length<12||h.length>1024){v("密码须为 12–1024 个字符。");return}if(i&&h!==m){v("两次输入的密码不一致。");return}const R=d.trim().normalize("NFC");if(i&&(!R||[...R].length>64||/[\p{Cc}\p{Cs}]/u.test(R))){v("昵称须为 1–64 个字符,且不能包含控制字符。");return}await t.signIn(i?"register":"login",{username:a.trim().toLowerCase(),password:h,...i?{displayName:R}:{}})&&(p(""),y(""))};return s.jsxs("main",{className:"website-login",children:[s.jsxs("header",{className:"website-brand",children:["CodeShell ",s.jsx("span",{children:"工作台"})]}),s.jsxs("div",{className:"website-welcome",children:[s.jsxs("section",{className:"website-introduction",children:[s.jsx("p",{className:"website-eyebrow",children:"给想法一个开始"}),s.jsxs("h1",{children:["从一句话,",s.jsx("br",{}),"到真正完成。"]}),s.jsxs("p",{children:["与 CodeShell 对话,让 Agent 帮你处理任务。",s.jsx("br",{}),"项目、工具与历史记录,都在你的工作空间。"]}),s.jsxs("div",{className:"website-features",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"继续你的工作"}),s.jsx("span",{children:"随时回到对话、任务和项目文件。"})]}),s.jsxs("p",{children:[s.jsx("strong",{children:"选择执行环境"}),s.jsx("span",{children:"任务在你选定的工作区里运行。"})]}),s.jsxs("p",{children:[s.jsx("strong",{children:"按需连接工具"}),s.jsx("span",{children:"GitHub 登录身份与数据访问授权分别管理。"})]})]})]}),s.jsxs("section",{className:"auth-card website-auth","aria-labelledby":"website-login-title",children:[s.jsx("p",{className:"website-eyebrow",children:"欢迎来到 CodeShell"}),s.jsx("h2",{id:"website-login-title",children:i?"创建你的账号":"继续你的工作"}),s.jsx("p",{className:"website-muted",children:"登录后进入你的工作台。"}),s.jsx("button",{className:"website-button website-wide",disabled:t.busy||!t.githubEnabled,onClick:()=>{t.github("login")},children:"使用 GitHub 继续"}),s.jsx("p",{className:"website-hint",children:"首次使用 GitHub 登录会按服务设置创建账号。"}),s.jsx("div",{className:"website-divider",children:"或使用用户名和密码"}),s.jsxs("form",{onSubmit:j=>{x(j)},children:[i?s.jsxs("label",{children:["昵称",s.jsx("input",{maxLength:128,autoComplete:"nickname",value:d,disabled:t.busy,onChange:j=>c(j.target.value),placeholder:"显示给你的名字",required:!0})]}):null,s.jsxs("label",{children:["用户名",s.jsx("input",{maxLength:64,autoComplete:"username",value:a,disabled:t.busy,onChange:j=>u(j.target.value),required:!0})]}),s.jsxs("label",{children:["密码",s.jsx("input",{type:"password",maxLength:1024,autoComplete:i?"new-password":"current-password",value:h,disabled:t.busy,onChange:j=>p(j.target.value),required:!0})]}),i?s.jsxs("label",{children:["确认密码",s.jsx("input",{type:"password",maxLength:1024,autoComplete:"new-password",value:m,disabled:t.busy,onChange:j=>y(j.target.value),required:!0})]}):null,s.jsx("button",{className:"send website-wide",disabled:t.busy||!t.ready,type:"submit",children:t.busy?"正在连接…":i?"创建账号":"登录"})]}),t.registrationAllowed?s.jsx("button",{className:"ghost website-wide",disabled:t.busy,onClick:()=>{r(!i),y(""),v(""),t.clearError()},children:i?"已有账号?登录":"没有账号?创建账号"}):null,t.oauthPending?s.jsx("button",{className:"ghost website-wide",onClick:t.cancelGithub,children:"取消 GitHub 授权"}):null,t.status?s.jsx("p",{role:"status",className:"website-hint",children:t.status}):null,b||t.error?s.jsx("p",{role:"alert",className:"form-error",children:b||t.error}):null,!t.ready&&!t.busy?s.jsx("button",{className:"website-button",onClick:()=>{t.restore()},children:"重试连接"}):null]})]}),s.jsx("footer",{className:"website-login-footer",children:"CodeShell · 让工作继续"})]})}async function iT(t=globalThis.fetch,i){const r=await t("/api/v1/cloud-browser/capabilities",{credentials:"omit",cache:"no-store",redirect:"error",signal:i});if(r.status===404)return null;if(!r.ok)throw new Error("暂时无法确认工作台登录方式,请重试。");const a=await r.json();if(a?.version!==1||a?.mode!=="cloud-browser"||!Vf(a))throw new Error("工作台返回了无效的登录配置,请联系管理员。");return{...a,version:1,mode:"cloud-browser"}}function rT(t,i,r){return ff(r)&&Vf(i)&&t.cloudOrigin===r&&i.cloudOrigin===r&&t.accountOrigin===r&&i.accountOrigin===r&&t.installationId===i.installationId}function lT(t,i,r){const a=t,u=a?.session,d=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;if(a?.authenticated!==!0||a.mode!=="cloud-account"||!u||u.kind!=="cloud-management"||u.accountId!==r||u.accountOrigin!==i.accountOrigin||u.audience!==i.cloudOrigin||u.installationId!==i.installationId||![u.id,u.accountId,u.managementEpoch].every(c=>d.test(c))||!Number.isSafeInteger(u.expiresAt)||u.expiresAt<=Date.now())throw new Error("工作区登录与当前账号不一致,请重新连接。");return u}async function aT(t,i=globalThis.fetch){await bl(async()=>{const r={credentials:"include",cache:"no-store",redirect:"error"},a=await i("/api/v1/cloud-browser/status",{...r,signal:AbortSignal.timeout(1e4)});if(!a.ok)return;const u=await a.json();u?.authenticated!==!0||u.mode!=="cloud-account"||u.session?.id!==t.id||u.session?.accountId!==t.accountId||u.session?.managementEpoch!==t.managementEpoch||u.session?.audience!==t.audience||await i("/api/v1/cloud-browser/logout",{...r,method:"POST",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json"},body:"{}"})})}function sT({setupToken:t}){const[i,r]=S.useState(),[a,u]=S.useState(""),[d,c]=S.useState(0);return S.useEffect(()=>{const h=new AbortController;return u(""),iT(globalThis.fetch,h.signal).then(p=>{h.signal.aborted||r(p)}).catch(p=>{h.signal.aborted||u(p instanceof Error?p.message:"无法连接工作台,请重试。")}),()=>h.abort()},[d]),i===null?s.jsx(PA,{setupToken:t}):i?s.jsx(XA,{children:s.jsx(oT,{capability:i})}):s.jsx("main",{className:"auth-page",children:s.jsxs("section",{className:"auth-card",children:[s.jsx("h1",{children:"CodeShell"}),a?s.jsxs(s.Fragment,{children:[s.jsx("p",{role:"alert",className:"form-error",children:a}),s.jsx("button",{className:"send",onClick:()=>c(h=>h+1),children:"重试连接"})]}):s.jsx("p",{role:"status",children:"正在连接工作台…"})]})})}function zb({go:t,logout:i}){const r=ti(),a=r.session?.account;return s.jsxs("details",{className:"website-account-menu",children:[s.jsx("summary",{"aria-label":"打开账号菜单",children:s.jsx("span",{"aria-hidden":"true",children:(a?.displayName||"C").slice(0,1)})}),s.jsxs("div",{className:"website-account-popover",children:[s.jsx("strong",{children:a?.displayName}),s.jsxs("small",{children:["@",a?.username]}),s.jsx("button",{onClick:u=>{u.currentTarget.closest("details")?.removeAttribute("open"),t({kind:"account",section:"profile"})},children:"账号设置"}),s.jsx("button",{onClick:u=>{u.currentTarget.closest("details")?.removeAttribute("open"),t({kind:"account",section:"connections"})},children:"连接"}),a?.role==="admin"?s.jsx("button",{onClick:()=>t({kind:"admin",section:"users"}),children:"管理控制台"}):null,s.jsx("button",{disabled:r.busy,onClick:i,children:"退出登录"})]})]})}function oT({capability:t}){const i=ti(),[r,a]=S.useState(()=>Eb(new URL(window.location.href))),[u,d]=S.useState(null),[c,h]=S.useState(""),[p,m]=S.useState(!1),[y,b]=S.useState(0),v=S.useRef(0),x=i.session?.authenticated?`${i.session.account.id}:${i.session.session.id}`:null,j=u?.identity===x?u.session:null,R=i.session?.cloudTarget,C=i.session?.account?.id,T=N=>{window.history.pushState(null,"",RA(N,new URL(window.location.href))),a(N),i.clearError(),i.oauthPending&&i.cancelGithub()};S.useEffect(()=>{const N=()=>{a(Eb(new URL(window.location.href))),i.oauthPending&&i.cancelGithub()};return window.addEventListener("popstate",N),()=>window.removeEventListener("popstate",N)},[i.oauthPending]),S.useEffect(()=>{const N=++v.current,U=new AbortController;if(d(null),h(""),m(!1),!x||!C)return()=>U.abort();if(!R)return h("当前账号尚未分配云端环境。你仍可管理账号设置。"),()=>U.abort();if(!rT(t,R,window.location.origin))return h("云端环境与账号服务配置不一致,请联系管理员。"),()=>U.abort();let X;const H=async()=>{if(!(U.signal.aborted||N!==v.current)){m(!0),h("");try{const A=await i.request("/cloud-tickets","POST",{},U.signal);if(!/^[A-Za-z0-9_-]{43}$/.test(A.ticket)||!Number.isSafeInteger(A.expiresAt)||A.expiresAt<=Date.now()||A.expiresAt>Date.now()+61e3||A.cloudOrigin!==R.cloudOrigin||A.accountOrigin!==R.accountOrigin||A.installationId!==R.installationId)throw new Error("云端授权目标无效,请联系管理员。");const I=await bl(async()=>{if(U.signal.aborted||N!==v.current)throw new Error("账号状态已改变。");const L=Wn(await i.request("/session"));if(!L.authenticated||`${L.account.id}:${L.session.id}`!==x)throw i.restore(),new Error("其他页面已切换账号,请重新连接。");const P=await fetch("/api/v1/cloud-browser/session",{method:"POST",credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json"},body:JSON.stringify({ticket:A.ticket})});if(!P.ok)throw new Error("云端工作区登录未完成,请重试连接。");const W=lT(await P.json(),R,C);if(U.signal.aborted||N!==v.current)throw await fetch("/api/v1/cloud-browser/logout",{method:"POST",credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json"},body:"{}"}),new Error("账号状态已改变。");return W});!U.signal.aborted&&N===v.current&&(d({session:I,identity:x}),X=setTimeout(()=>{H()},Math.max(1e3,I.expiresAt-Date.now()-3e4)))}catch(A){!U.signal.aborted&&N===v.current&&(d(null),h(A instanceof Error?A.message:"无法连接云端工作区,请重试。"))}finally{!U.signal.aborted&&N===v.current&&m(!1)}}};return H(),()=>{U.abort(),clearTimeout(X)}},[x,R?.cloudOrigin,R?.installationId,R?.accountOrigin,t,i.request,y]);const _=()=>{const N=j;v.current++,d(null),i.logout().then(U=>{if(U&&N)return aT(N)}).catch(()=>{})};if(!i.session?.authenticated)return s.jsx(nT,{});const D=s.jsx(zb,{go:T,logout:_}),q=r.kind!=="workbench",se=i.session.account?.role==="admin";return s.jsxs(Hb.Provider,{value:"/api/v1/cloud-browser/environment",children:[j?s.jsx("div",{hidden:q,className:"website-workbench-root",children:s.jsx(ux,{allowLegacy:!1,autoEnterSingle:!0,startCreatedProject:!0,canRequest:()=>i.workspaceActive(x),onAuthLost:()=>{d(null),b(N=>N+1)},accountControl:D,children:(N,U)=>s.jsx(cf,{hub:!0,onAuthLost:()=>{d(null),b(X=>X+1)},projectName:N?.name,onBackToProjects:U,cloudAccount:{pending:i.busy,error:"",onLogout:_,accountOrigin:R?.accountOrigin},renderAccountControl:X=>s.jsx(zb,{go:T,logout:()=>X.guard(_)})})},x)}):q?null:s.jsxs("main",{className:"website-environment-empty",children:[s.jsxs("header",{className:"website-brand",children:["CodeShell ",D]}),s.jsxs("section",{children:[s.jsx("p",{className:"website-eyebrow",children:"你的工作台"}),s.jsx("h1",{children:p?"正在打开工作空间…":"连接你的工作空间"}),s.jsx("p",{role:c?"alert":"status",className:c?"form-error":"website-muted",children:c||"正在验证账号与云端环境。"}),c?s.jsx("button",{className:"website-button",onClick:()=>b(N=>N+1),children:"重新连接"}):null,s.jsx("button",{className:"ghost",onClick:()=>T({kind:"account",section:"profile"}),children:"账号设置"})]})]}),q?s.jsxs("div",{className:"website-settings-shell",children:[s.jsxs("aside",{className:"website-settings-nav",children:[s.jsx("button",{className:"website-back",onClick:()=>T({kind:"workbench"}),children:"← 返回工作台"}),s.jsx("p",{className:"website-eyebrow",children:"账号设置"}),s.jsx("nav",{"aria-label":"账号设置",children:[["profile","账号资料"],["security","安全"],["sessions","登录会话"],["connections","连接"]].map(([N,U])=>s.jsx("button",{"aria-current":r.kind==="account"&&r.section===N?"page":void 0,onClick:()=>T({kind:"account",section:N}),children:U},N))}),se?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"website-eyebrow",children:"管理控制台"}),s.jsx("nav",{"aria-label":"管理控制台",children:[["users","用户管理"],["summary","系统统计"],["audit","操作记录"]].map(([N,U])=>s.jsx("button",{"aria-current":r.kind==="admin"&&r.section===N?"page":void 0,onClick:()=>T({kind:"admin",section:N}),children:U},N))})]}):null,s.jsx("div",{className:"website-settings-avatar",children:D})]}),s.jsx("main",{children:s.jsx(KA,{route:r},`${x}:${r.kind}:${r.section}`)})]}):null]})}function uT(t="/"){"serviceWorker"in navigator&&window.isSecureContext&&navigator.serviceWorker.register(`${t}sw.js`).catch(()=>{})}const _b=G1(),cT=R1(window.location,window.history);X1.createRoot(document.getElementById("root")).render(s.jsx(S.StrictMode,{children:_b?s.jsx(V1,{callback:_b}):s.jsx(sT,{setupToken:cT})}));uT("/");
|