@cjhyy/code-shell-web 0.9.35 → 0.9.37
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.
- package/dist/hooks/useRemoteApp.js +123 -23
- package/dist/lib/messageMappers.d.ts +1 -0
- package/dist/lib/messageMappers.js +2 -0
- package/dist/lib/roomHistory.d.ts +22 -0
- package/dist/lib/roomHistory.js +58 -0
- package/dist-app/assets/{index-kPe-x_IE.css → index-D79KFrq-.css} +1 -1
- package/dist-app/assets/index-Du4uVDSz.js +57 -0
- package/dist-app/index.html +2 -2
- package/package.json +3 -3
- package/dist-app/assets/index-hVyQ_FRP.js +0 -57
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const f of o)if(f.type==="childList")for(const u of f.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&a(u)}).observe(document,{childList:!0,subtree:!0});function l(o){const f={};return o.integrity&&(f.integrity=o.integrity),o.referrerPolicy&&(f.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?f.credentials="include":o.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function a(o){if(o.ep)return;o.ep=!0;const f=l(o);fetch(o.href,f)}})();function co(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ac={exports:{}},la={};var pg;function Z0(){if(pg)return la;pg=1;var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function l(a,o,f){var u=null;if(f!==void 0&&(u=""+f),o.key!==void 0&&(u=""+o.key),"key"in o){f={};for(var m in o)m!=="key"&&(f[m]=o[m])}else f=o;return o=f.ref,{$$typeof:t,type:a,key:u,ref:o!==void 0?o:null,props:f}}return la.Fragment=i,la.jsx=l,la.jsxs=l,la}var mg;function J0(){return mg||(mg=1,Ac.exports=Z0()),Ac.exports}var c=J0(),Tc={exports:{}},Ye={};var gg;function W0(){if(gg)return Ye;gg=1;var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),u=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),x=Symbol.iterator;function v(L){return L===null||typeof L!="object"?null:(L=x&&L[x]||L["@@iterator"],typeof L=="function"?L:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,N={};function A(L,J,_){this.props=L,this.context=J,this.refs=N,this.updater=_||j}A.prototype.isReactComponent={},A.prototype.setState=function(L,J){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,J,"setState")},A.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function R(){}R.prototype=A.prototype;function O(L,J,_){this.props=L,this.context=J,this.refs=N,this.updater=_||j}var Y=O.prototype=new R;Y.constructor=O,D(Y,A.prototype),Y.isPureReactComponent=!0;var re=Array.isArray;function T(){}var V={H:null,A:null,T:null,S:null},Q=Object.prototype.hasOwnProperty;function I(L,J,_){var te=_.ref;return{$$typeof:t,type:L,key:J,ref:te!==void 0?te:null,props:_}}function C(L,J){return I(L.type,J,L.props)}function B(L){return typeof L=="object"&&L!==null&&L.$$typeof===t}function U(L){var J={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(_){return J[_]})}var $=/\/+/g;function ee(L,J){return typeof L=="object"&&L!==null&&L.key!=null?U(""+L.key):J.toString(36)}function K(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(T,T):(L.status="pending",L.then(function(J){L.status==="pending"&&(L.status="fulfilled",L.value=J)},function(J){L.status==="pending"&&(L.status="rejected",L.reason=J)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function z(L,J,_,te,xe){var ae=typeof L;(ae==="undefined"||ae==="boolean")&&(L=null);var se=!1;if(L===null)se=!0;else switch(ae){case"bigint":case"string":case"number":se=!0;break;case"object":switch(L.$$typeof){case t:case i:se=!0;break;case y:return se=L._init,z(se(L._payload),J,_,te,xe)}}if(se)return xe=xe(L),se=te===""?"."+ee(L,0):te,re(xe)?(_="",se!=null&&(_=se.replace($,"$&/")+"/"),z(xe,J,_,"",function(we){return we})):xe!=null&&(B(xe)&&(xe=C(xe,_+(xe.key==null||L&&L.key===xe.key?"":(""+xe.key).replace($,"$&/")+"/")+se)),J.push(xe)),1;se=0;var ye=te===""?".":te+":";if(re(L))for(var F=0;F<L.length;F++)te=L[F],ae=ye+ee(te,F),se+=z(te,J,_,ae,xe);else if(F=v(L),typeof F=="function")for(L=F.call(L),F=0;!(te=L.next()).done;)te=te.value,ae=ye+ee(te,F++),se+=z(te,J,_,ae,xe);else if(ae==="object"){if(typeof L.then=="function")return z(K(L),J,_,te,xe);throw J=String(L),Error("Objects are not valid as a React child (found: "+(J==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":J)+"). If you meant to render a collection of children, use an array instead.")}return se}function Z(L,J,_){if(L==null)return L;var te=[],xe=0;return z(L,te,"","",function(ae){return J.call(_,ae,xe++)}),te}function he(L){if(L._status===-1){var J=L._result;J=J(),J.then(function(_){(L._status===0||L._status===-1)&&(L._status=1,L._result=_)},function(_){(L._status===0||L._status===-1)&&(L._status=2,L._result=_)}),L._status===-1&&(L._status=0,L._result=J)}if(L._status===1)return L._result.default;throw L._result}var me=typeof reportError=="function"?reportError:function(L){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var J=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof L=="object"&&L!==null&&typeof L.message=="string"?String(L.message):String(L),error:L});if(!window.dispatchEvent(J))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",L);return}console.error(L)},k={map:Z,forEach:function(L,J,_){Z(L,function(){J.apply(this,arguments)},_)},count:function(L){var J=0;return Z(L,function(){J++}),J},toArray:function(L){return Z(L,function(J){return J})||[]},only:function(L){if(!B(L))throw Error("React.Children.only expected to receive a single React element child.");return L}};return Ye.Activity=b,Ye.Children=k,Ye.Component=A,Ye.Fragment=l,Ye.Profiler=o,Ye.PureComponent=O,Ye.StrictMode=a,Ye.Suspense=h,Ye.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=V,Ye.__COMPILER_RUNTIME={__proto__:null,c:function(L){return V.H.useMemoCache(L)}},Ye.cache=function(L){return function(){return L.apply(null,arguments)}},Ye.cacheSignal=function(){return null},Ye.cloneElement=function(L,J,_){if(L==null)throw Error("The argument must be a React element, but you passed "+L+".");var te=D({},L.props),xe=L.key;if(J!=null)for(ae in J.key!==void 0&&(xe=""+J.key),J)!Q.call(J,ae)||ae==="key"||ae==="__self"||ae==="__source"||ae==="ref"&&J.ref===void 0||(te[ae]=J[ae]);var ae=arguments.length-2;if(ae===1)te.children=_;else if(1<ae){for(var se=Array(ae),ye=0;ye<ae;ye++)se[ye]=arguments[ye+2];te.children=se}return I(L.type,xe,te)},Ye.createContext=function(L){return L={$$typeof:u,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null},L.Provider=L,L.Consumer={$$typeof:f,_context:L},L},Ye.createElement=function(L,J,_){var te,xe={},ae=null;if(J!=null)for(te in J.key!==void 0&&(ae=""+J.key),J)Q.call(J,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(xe[te]=J[te]);var se=arguments.length-2;if(se===1)xe.children=_;else if(1<se){for(var ye=Array(se),F=0;F<se;F++)ye[F]=arguments[F+2];xe.children=ye}if(L&&L.defaultProps)for(te in se=L.defaultProps,se)xe[te]===void 0&&(xe[te]=se[te]);return I(L,ae,xe)},Ye.createRef=function(){return{current:null}},Ye.forwardRef=function(L){return{$$typeof:m,render:L}},Ye.isValidElement=B,Ye.lazy=function(L){return{$$typeof:y,_payload:{_status:-1,_result:L},_init:he}},Ye.memo=function(L,J){return{$$typeof:p,type:L,compare:J===void 0?null:J}},Ye.startTransition=function(L){var J=V.T,_={};V.T=_;try{var te=L(),xe=V.S;xe!==null&&xe(_,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(T,me)}catch(ae){me(ae)}finally{J!==null&&_.types!==null&&(J.types=_.types),V.T=J}},Ye.unstable_useCacheRefresh=function(){return V.H.useCacheRefresh()},Ye.use=function(L){return V.H.use(L)},Ye.useActionState=function(L,J,_){return V.H.useActionState(L,J,_)},Ye.useCallback=function(L,J){return V.H.useCallback(L,J)},Ye.useContext=function(L){return V.H.useContext(L)},Ye.useDebugValue=function(){},Ye.useDeferredValue=function(L,J){return V.H.useDeferredValue(L,J)},Ye.useEffect=function(L,J){return V.H.useEffect(L,J)},Ye.useEffectEvent=function(L){return V.H.useEffectEvent(L)},Ye.useId=function(){return V.H.useId()},Ye.useImperativeHandle=function(L,J,_){return V.H.useImperativeHandle(L,J,_)},Ye.useInsertionEffect=function(L,J){return V.H.useInsertionEffect(L,J)},Ye.useLayoutEffect=function(L,J){return V.H.useLayoutEffect(L,J)},Ye.useMemo=function(L,J){return V.H.useMemo(L,J)},Ye.useOptimistic=function(L,J){return V.H.useOptimistic(L,J)},Ye.useReducer=function(L,J,_){return V.H.useReducer(L,J,_)},Ye.useRef=function(L){return V.H.useRef(L)},Ye.useState=function(L){return V.H.useState(L)},Ye.useSyncExternalStore=function(L,J,_){return V.H.useSyncExternalStore(L,J,_)},Ye.useTransition=function(){return V.H.useTransition()},Ye.version="19.2.6",Ye}var yg;function Kf(){return yg||(yg=1,Tc.exports=W0()),Tc.exports}var e1=Kf();const w=co(e1);let ka,fo=null;const t1=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,fb=/^\/p\/([0-9a-f-]{36})(\/.*)$/;function xa(t){return typeof t=="string"&&t1.test(t)}function Vs(t){if(t!==null&&!xa(t))throw new Error("项目标识无效。");fo=t}function Sa(){return fo}function no(){return{workspace:ka??"",projectId:fo}}function Ys(t){ka=void 0}function io(){return ka}function bg(t=ka){return t?{"X-CodeShell-Workspace":encodeURIComponent(t)}:{}}function db(t){return/^\/api\/v1\/(?:auth|projects|environment)(?:\/|\?|$)/.test(t)||/^\/api\/v1\/desktop\/session(?:\?|$)/.test(t)}function n1(t){const i=fb.exec(t);return!!i&&xa(i[1])}function St(t,i=ka,l=fo){const a=fb.exec(t),o=a?a[2]:t;if(a&&!xa(a[1])||!o.startsWith("/api/v1/")&&o!=="/ws"||/[\\\r\n]/.test(t))throw new Error("Workspace URLs must use the local API");const f=new URL(o,"http://codeshell.invalid");if(f.pathname!==o.split(/[?#]/,1)[0])throw new Error("Workspace URLs must use the local API");if(db(o))return o;if(a)return t;if(l!==null&&!xa(l))throw new Error("项目标识无效。");return i&&o.startsWith("/api/v1/")&&f.searchParams.set("workspace",i),`${l?`/p/${l}`:""}${f.pathname}${f.search}${f.hash}`}class Pe extends Error{constructor(i,l,a,o){super(i),this.status=l,this.code=a,this.retryAfterMs=o}status;code;retryAfterMs}async function He(t,i={},l){const a=l?bg(l.workspace):bg(),o={...i};if(Object.keys(a).length&&!db(t)&&!n1(t)&&!t.includes("workspace=")){const m=new Headers(i.headers);for(const[h,p]of Object.entries(a))m.has(h)||m.set(h,p);o.headers=m}const f=await fetch(l?St(t,l.workspace,l.projectId):St(t,""),{...o,credentials:"same-origin",cache:"no-store"}),u=await f.json().catch(()=>({}));if(!f.ok){const m=typeof u.error=="string"?u.error:u.error?.message;throw new Pe(m??u.message??`请求失败(${f.status})`,f.status,typeof u.code=="string"?u.code:void 0,typeof u.retryAfterMs=="number"?u.retryAfterMs:void 0)}return u}function hb(t,i={}){return He(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async function i1(){try{const t=await He("/api/v1/auth/status");if(typeof t.initialized!="boolean"||typeof t.authenticated!="boolean")throw new Error("服务端返回了无效的登录状态,请稍后重试。");return t}catch(t){if(t instanceof Pe&&t.status===404)return null;throw t}}function r1(t,i){const l=new URLSearchParams(t.hash.replace(/^#/,"")),a=l.get("setup")??"";if(l.has("setup")){l.delete("setup");const o=l.toString();i.replaceState(i.state,"",`${t.pathname}${t.search}${o?`#${o}`:""}`)}return a}function Ea(){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,l=>l.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 l1(t,i={}){const l=i.scope??no();return He(St(`/api/v1/uploads/${Ea()}`,l.workspace,l.projectId),{method:"PUT",headers:{"Content-Type":t.type||"application/octet-stream","X-File-Name":encodeURIComponent(t.name)},body:t,signal:i.signal})}function a1(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 Rc(t,i){const l=t.authModes?.filter(a=>a.available&&(!i||a.methodId===i));return l?.find(a=>a.preferred)??l?.[0]}function xi(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 s1=new Set(["redirect","device-code","qr-code","credential-input","local-session","consent","processing"]);function o1(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 l=xi(t);if(t.state==="pending"&&(!l||!s1.has(l.kind)))throw new Error("当前客户端不支持这个授权步骤,请更新客户端。");if(l&&(!l.id||!Number.isFinite(Date.parse(l.expiresAt))))throw new Error("授权步骤缺少有效期限,请重新连接。");if(t.expiresAt&&(!Number.isFinite(Date.parse(t.expiresAt))||l&&Date.parse(l.expiresAt)>Date.parse(t.expiresAt)))throw new Error("授权任务的有效期限无效,请重新连接。")}class u1{constructor(i,l={}){this.transport=i,this.options=l}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 l of this.listeners)l()}}stop(){return clearTimeout(this.timer),++this.generation}current(i){return!this.disposed&&i===this.generation}deadline(i){const l=xi(i);return Math.min(i.expiresAt?Date.parse(i.expiresAt):1/0,l?Date.parse(l.expiresAt):1/0)}accept(i,l,a){if(this.current(l)){if(o1(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(l)}}schedule(i,l=this.options.pollIntervalMs??2e3){const a=this.value.authorization;if(!this.current(i)||a?.state!=="pending")return;const o=this.deadline(a)-Date.now();if(o<=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 f=xi(a),u=f&&["credential-input","local-session","consent"].includes(f.kind);this.timer=setTimeout(()=>{u?this.schedule(i):this.poll(i)},Math.min(l,o))}async poll(i){const l=this.value.authorization;if(!(!this.current(i)||l?.state!=="pending")){if(this.deadline(l)<=Date.now()){this.schedule(i);return}try{const a=await this.transport.status(l.id);this.accept(a,i,l.id)}catch(a){if(!this.current(i))return;this.publish({...this.value,busy:!1,error:Gs(a)});const o=a?.status;o!==401&&o!==404&&this.schedule(i,this.options.retryIntervalMs??4e3)}}}async begin(i,l){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 o=await this.transport.begin(i,l);if(!this.current(a)){o.state==="pending"&&this.transport.cancel(o.id).catch(()=>{});return}try{this.accept(o,a)}catch(f){throw o.state==="pending"&&this.transport.cancel(o.id).catch(()=>{}),f}return o}catch(o){this.current(a)&&this.publish({busy:!1,error:Gs(o)})}}async respond(i){const l=this.value.authorization,a=l&&xi(l);if(this.disposed||this.value.busy||l?.state!=="pending"||!a||a.id!==i.stepId)return;if(this.deadline(l)<=Date.now()){this.schedule(this.generation);return}const o=this.stop();this.publish({authorization:l,busy:!0});try{const f=await this.transport.respond(l.id,i);return this.accept(f,o,l.id),this.current(o)?f:void 0}catch(f){this.current(o)&&(this.publish({authorization:l,busy:!1,error:Gs(f)}),this.timer=setTimeout(()=>{this.poll(o)},this.options.retryIntervalMs??4e3))}}async cancel(){const i=this.value.authorization,l=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(l))return;this.publish({busy:!1,authorization:a??{...i,state:"cancelled",step:void 0,prompt:void 0,redirect:void 0}})}catch(a){this.current(l)&&(this.publish({authorization:i,busy:!1,error:Gs(a)}),this.schedule(l,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 Gs(t){return t instanceof Error?t:new Error("连接操作失败,请重试。")}const Rf="codeshell.remote-link.authorization.v1",Pf="/api/v1/links/authorizations/",zf="[a-f0-9-]{36}",c1=new RegExp(`^(?:/p/${zf})?${Pf}${zf}$`);function Zf(t){return t==="/link/callback"?"/":t==="/mobile/link/callback"?"/mobile/":void 0}function f1(t,i){const l=new URL(t),a=new URL(i);if(l.origin!==a.origin||l.pathname!=="/oauth/authorize"||l.username||l.password||l.hash||l.protocol!=="https:"&&!(l.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(l.hostname)))throw new Error("授权地址无效,请检查 Link 服务配置。");return l}function d1(t,i,l,a=window.location.origin,o=window.sessionStorage){const f=xi(t);if(f?.kind!=="redirect"||!new RegExp(`^${zf}$`).test(t.id))throw new Error("授权请求无效。");const u=f1(f.authorizationUrl,i),m=u.searchParams.get("state"),h=u.searchParams.get("redirect_uri"),p=Date.parse(f.expiresAt),y=h?Zf(new URL(h,a).pathname):void 0;if(!m||!h||!y||h!==`${a}${y}link/callback`||y==="/mobile/"&&l.projectId!==null||u.searchParams.getAll("state").length!==1||u.searchParams.getAll("redirect_uri").length!==1||!Number.isFinite(p)||p<=Date.now())throw new Error("授权回调地址或有效期无效,请检查服务配置。");const b=St(Pf+t.id,l.workspace,l.projectId),x=new URLSearchParams({view:"links",...l.projectId?{project:l.projectId}:{},...y==="/mobile/"?{workspace:l.workspace}:{}});return o.setItem(Rf,JSON.stringify({target:b,state:m,redirectUri:h,returnUrl:`${y}?${x}`,expiresAt:p,providerId:t.providerId})),u.href}function h1(t,i,l){const a=Zf(t.pathname);if(!a)return;const o=t.href;i.replaceState(i.state,"",t.pathname);try{const f=l.getItem(Rf);l.removeItem(Rf);const u=JSON.parse(f??"null");if(!u||!Number.isFinite(u.expiresAt)||u.expiresAt<=Date.now())throw new Error;const m=new URL(o),h=new URL(u.target,t.origin),p=new URL(u.returnUrl,t.origin);if(u.redirectUri!==`${t.origin}${t.pathname}`||m.origin!==t.origin||m.hash||m.searchParams.getAll("state").length!==1||m.searchParams.get("state")!==u.state||h.origin!==t.origin||!c1.test(h.pathname)||h.hash||h.username||h.password||[...h.searchParams.keys()].some(y=>y!=="workspace")||h.searchParams.getAll("workspace").length>1||p.origin!==t.origin||p.pathname!==a||p.username||p.password||p.hash||[...p.searchParams.keys()].some(y=>!(a==="/mobile/"?["workspace","view"]:["project","view"]).includes(y))||p.searchParams.getAll("view").length!==1||p.searchParams.get("view")!=="links"||a==="/mobile/"&&(!h.pathname.startsWith(Pf)||p.searchParams.getAll("workspace").length!==1||p.searchParams.get("workspace")!==(h.searchParams.get("workspace")??"")))throw new Error;return{callbackUrl:o,pending:u,denied:m.searchParams.has("error")}}catch{return{error:"找不到匹配的授权,或授权已过期。请返回原项目重新连接。",home:a}}}async function p1(t){const i=new URL(t.pending.target,window.location.origin),l=pb(i);return t.denied?(await He(t.pending.target,{method:"DELETE"},l),{id:"",providerId:t.pending.providerId??"",state:"cancelled"}):(i.pathname+="/complete",He(i.pathname+i.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:t.callbackUrl})},l))}function pb(t){return{workspace:t.searchParams.get("workspace")??"",projectId:/^\/p\/([a-f0-9-]{36})\//.exec(t.pathname)?.[1]??null}}function m1(t){const i=new URL(t.pending.target,window.location.origin);return He(t.pending.target,{},pb(i))}function g1(){const t=Zf(window.location.pathname);if(t)try{return h1(window.location,window.history,window.sessionStorage)}catch{return window.history.replaceState(window.history.state,"",window.location.pathname),{error:"浏览器无法读取原授权记录。请允许此站点保存临时数据后重新连接。",home:t}}}function y1({callback:t}){const i=w.useRef(void 0),[l,a]=w.useState(),[o,f]=w.useState("error"in t?t.error:""),[u,m]=w.useState(!1),h=b=>f(b instanceof Pe&&b.status===401?"原登录已失效。请返回工作台登录,并重新发起授权。":b instanceof Error?b.message:"无法确认授权结果,请检查结果或返回项目重新连接。"),p=b=>{if(b.state==="connected"&&!b.connection){h(new Error("服务尚未确认连接已保存,请检查授权结果。"));return}a(b),f("")};w.useEffect(()=>{if("error"in t)return;let b=!0;return i.current??=p1(t),i.current.then(x=>{b&&p(x)},x=>{b&&h(x)}),()=>{b=!1}},[t]);const y=!l&&!o;return c.jsx("main",{className:"auth-page",children:c.jsxs("section",{className:"auth-card",children:[c.jsx("h1",{children:"Link 授权"}),y&&c.jsx("p",{role:"status",children:"正在确认授权并保存到原项目…"}),l?.state==="connected"&&c.jsxs("p",{role:"status",children:["已连接 ",l.connection?.account?.label??l.connection?.providerId,",授权已保存到原项目。"]}),l?.previousGrantRevocationPending&&c.jsx("p",{role:"alert",children:"新连接已保存。有遗留授权等待撤销,项目所在环境将自动重试,重启后仍会继续;也可在 Link 服务中撤销。"}),l?.state==="cancelled"&&c.jsx("p",{role:"status",children:"授权已取消,没有新增连接。"}),l?.state==="failed"&&c.jsx("p",{role:"alert",children:"授权未完成。请返回原项目重新连接。"}),l?.state==="pending"&&c.jsx("p",{role:"status",children:"服务端尚未确认完成。可以稍后检查结果,或返回项目重新发起授权。"}),o&&c.jsx("p",{className:"form-error",role:"alert",children:o}),!("error"in t)&&(o||l?.state==="pending")&&c.jsx("button",{disabled:u,onClick:()=>{u||(m(!0),m1(t).then(p,h).finally(()=>m(!1)))},children:u?"正在查询…":"检查授权结果"}),!y&&c.jsx("a",{href:"error"in t?t.home??"/":t.pending.returnUrl,children:"返回原项目"})]})})}var zc={exports:{}},aa={},Dc={exports:{}},_c={};var vg;function b1(){return vg||(vg=1,(function(t){function i(z,Z){var he=z.length;z.push(Z);e:for(;0<he;){var me=he-1>>>1,k=z[me];if(0<o(k,Z))z[me]=Z,z[he]=k,he=me;else break e}}function l(z){return z.length===0?null:z[0]}function a(z){if(z.length===0)return null;var Z=z[0],he=z.pop();if(he!==Z){z[0]=he;e:for(var me=0,k=z.length,L=k>>>1;me<L;){var J=2*(me+1)-1,_=z[J],te=J+1,xe=z[te];if(0>o(_,he))te<k&&0>o(xe,_)?(z[me]=xe,z[te]=he,me=te):(z[me]=_,z[J]=he,me=J);else if(te<k&&0>o(xe,he))z[me]=xe,z[te]=he,me=te;else break e}}return Z}function o(z,Z){var he=z.sortIndex-Z.sortIndex;return he!==0?he:z.id-Z.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;t.unstable_now=function(){return f.now()}}else{var u=Date,m=u.now();t.unstable_now=function(){return u.now()-m}}var h=[],p=[],y=1,b=null,x=3,v=!1,j=!1,D=!1,N=!1,A=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;function Y(z){for(var Z=l(p);Z!==null;){if(Z.callback===null)a(p);else if(Z.startTime<=z)a(p),Z.sortIndex=Z.expirationTime,i(h,Z);else break;Z=l(p)}}function re(z){if(D=!1,Y(z),!j)if(l(h)!==null)j=!0,T||(T=!0,U());else{var Z=l(p);Z!==null&&K(re,Z.startTime-z)}}var T=!1,V=-1,Q=5,I=-1;function C(){return N?!0:!(t.unstable_now()-I<Q)}function B(){if(N=!1,T){var z=t.unstable_now();I=z;var Z=!0;try{e:{j=!1,D&&(D=!1,R(V),V=-1),v=!0;var he=x;try{t:{for(Y(z),b=l(h);b!==null&&!(b.expirationTime>z&&C());){var me=b.callback;if(typeof me=="function"){b.callback=null,x=b.priorityLevel;var k=me(b.expirationTime<=z);if(z=t.unstable_now(),typeof k=="function"){b.callback=k,Y(z),Z=!0;break t}b===l(h)&&a(h),Y(z)}else a(h);b=l(h)}if(b!==null)Z=!0;else{var L=l(p);L!==null&&K(re,L.startTime-z),Z=!1}}break e}finally{b=null,x=he,v=!1}Z=void 0}}finally{Z?U():T=!1}}}var U;if(typeof O=="function")U=function(){O(B)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,ee=$.port2;$.port1.onmessage=B,U=function(){ee.postMessage(null)}}else U=function(){A(B,0)};function K(z,Z){V=A(function(){z(t.unstable_now())},Z)}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(z){z.callback=null},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return x},t.unstable_next=function(z){switch(x){case 1:case 2:case 3:var Z=3;break;default:Z=x}var he=x;x=Z;try{return z()}finally{x=he}},t.unstable_requestPaint=function(){N=!0},t.unstable_runWithPriority=function(z,Z){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var he=x;x=z;try{return Z()}finally{x=he}},t.unstable_scheduleCallback=function(z,Z,he){var me=t.unstable_now();switch(typeof he=="object"&&he!==null?(he=he.delay,he=typeof he=="number"&&0<he?me+he:me):he=me,z){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=he+k,z={id:y++,callback:Z,priorityLevel:z,startTime:he,expirationTime:k,sortIndex:-1},he>me?(z.sortIndex=he,i(p,z),l(h)===null&&z===l(p)&&(D?(R(V),V=-1):D=!0,K(re,he-me))):(z.sortIndex=k,i(h,z),j||v||(j=!0,T||(T=!0,U()))),z},t.unstable_shouldYield=C,t.unstable_wrapCallback=function(z){var Z=x;return function(){var he=x;x=Z;try{return z.apply(this,arguments)}finally{x=he}}}})(_c)),_c}var xg;function v1(){return xg||(xg=1,Dc.exports=b1()),Dc.exports}var Mc={exports:{}},rn={};var Sg;function x1(){if(Sg)return rn;Sg=1;var t=Kf();function i(h){var p="https://react.dev/errors/"+h;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+h+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(){}var a={d:{f:l,r:function(){throw Error(i(522))},D:l,C:l,L:l,m:l,X:l,S:l,M:l},p:0,findDOMNode:null},o=Symbol.for("react.portal");function f(h,p,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:h,containerInfo:p,implementation:y}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(h,p){if(h==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return rn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,rn.createPortal=function(h,p){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(i(299));return f(h,p,null,y)},rn.flushSync=function(h){var p=u.T,y=a.p;try{if(u.T=null,a.p=2,h)return h()}finally{u.T=p,a.p=y,a.d.f()}},rn.preconnect=function(h,p){typeof h=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,a.d.C(h,p))},rn.prefetchDNS=function(h){typeof h=="string"&&a.d.D(h)},rn.preinit=function(h,p){if(typeof h=="string"&&p&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin),x=typeof p.integrity=="string"?p.integrity:void 0,v=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?a.d.S(h,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:x,fetchPriority:v}):y==="script"&&a.d.X(h,{crossOrigin:b,integrity:x,fetchPriority:v,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},rn.preinitModule=function(h,p){if(typeof h=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=m(p.as,p.crossOrigin);a.d.M(h,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&a.d.M(h)},rn.preload=function(h,p){if(typeof h=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin);a.d.L(h,y,{crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},rn.preloadModule=function(h,p){if(typeof h=="string")if(p){var y=m(p.as,p.crossOrigin);a.d.m(h,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else a.d.m(h)},rn.requestFormReset=function(h){a.d.r(h)},rn.unstable_batchedUpdates=function(h,p){return h(p)},rn.useFormState=function(h,p,y){return u.H.useFormState(h,p,y)},rn.useFormStatus=function(){return u.H.useHostTransitionStatus()},rn.version="19.2.6",rn}var wg;function mb(){if(wg)return Mc.exports;wg=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(),Mc.exports=x1(),Mc.exports}var jg;function S1(){if(jg)return aa;jg=1;var t=v1(),i=Kf(),l=mb();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)n+="&args[]="+encodeURIComponent(arguments[r])}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 o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var n=e,r=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(r=n.return),e=n.return;while(e)}return n.tag===3?r:null}function u(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 m(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 h(e){if(f(e)!==e)throw Error(a(188))}function p(e){var n=e.alternate;if(!n){if(n=f(e),n===null)throw Error(a(188));return n!==e?null:e}for(var r=e,s=n;;){var d=r.return;if(d===null)break;var g=d.alternate;if(g===null){if(s=d.return,s!==null){r=s;continue}break}if(d.child===g.child){for(g=d.child;g;){if(g===r)return h(d),e;if(g===s)return h(d),n;g=g.sibling}throw Error(a(188))}if(r.return!==s.return)r=d,s=g;else{for(var S=!1,E=d.child;E;){if(E===r){S=!0,r=d,s=g;break}if(E===s){S=!0,s=d,r=g;break}E=E.sibling}if(!S){for(E=g.child;E;){if(E===r){S=!0,r=g,s=d;break}if(E===s){S=!0,s=g,r=d;break}E=E.sibling}if(!S)throw Error(a(189))}}if(r.alternate!==s)throw Error(a(190))}if(r.tag!==3)throw Error(a(188));return r.stateNode.current===r?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,x=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),O=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),C=Symbol.for("react.memo_cache_sentinel"),B=Symbol.iterator;function U(e){return e===null||typeof e!="object"?null:(e=B&&e[B]||e["@@iterator"],typeof e=="function"?e:null)}var $=Symbol.for("react.client.reference");function ee(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===$?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case D:return"Fragment";case A:return"Profiler";case N:return"StrictMode";case re:return"Suspense";case T:return"SuspenseList";case I:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case O:return e.displayName||"Context";case R:return(e._context.displayName||"Context")+".Consumer";case Y:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:ee(e.type)||"Memo";case Q:n=e._payload,e=e._init;try{return ee(e(n))}catch{}}return null}var K=Array.isArray,z=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he={pending:!1,data:null,method:null,action:null},me=[],k=-1;function L(e){return{current:e}}function J(e){0>k||(e.current=me[k],me[k]=null,k--)}function _(e,n){k++,me[k]=e.current,e.current=n}var te=L(null),xe=L(null),ae=L(null),se=L(null);function ye(e,n){switch(_(ae,n),_(xe,e),_(te,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Bm(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Bm(n),e=Um(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}J(te),_(te,e)}function F(){J(te),J(xe),J(ae)}function we(e){e.memoizedState!==null&&_(se,e);var n=te.current,r=Um(n,e.type);n!==r&&(_(xe,e),_(te,r))}function Le(e){xe.current===e&&(J(te),J(xe)),se.current===e&&(J(se),ta._currentValue=he)}var Ae,Te;function tt(e){if(Ae===void 0)try{throw Error()}catch(r){var n=r.stack.trim().match(/\n( *(at )?)/);Ae=n&&n[1]||"",Te=-1<r.stack.indexOf(`
|
|
2
|
-
at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+Ae+e+Te}var ut=!1;function Ge(e,n){if(!e||ut)return"";ut=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var s={DetermineComponentFrameRoot:function(){try{if(n){var pe=function(){throw Error()};if(Object.defineProperty(pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(pe,[])}catch(ue){var le=ue}Reflect.construct(e,[],pe)}else{try{pe.call()}catch(ue){le=ue}e.call(pe.prototype)}}else{try{throw Error()}catch(ue){le=ue}(pe=e())&&typeof pe.catch=="function"&&pe.catch(function(){})}}catch(ue){if(ue&&le&&typeof ue.stack=="string")return[ue.stack,le.stack]}return[null,null]}};s.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(s.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(s.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=s.DetermineComponentFrameRoot(),S=g[0],E=g[1];if(S&&E){var H=S.split(`
|
|
4
|
-
`),ie=E.split(`
|
|
5
|
-
`);for(d=s=0;s<H.length&&!H[s].includes("DetermineComponentFrameRoot");)s++;for(;d<ie.length&&!ie[d].includes("DetermineComponentFrameRoot");)d++;if(s===H.length||d===ie.length)for(s=H.length-1,d=ie.length-1;1<=s&&0<=d&&H[s]!==ie[d];)d--;for(;1<=s&&0<=d;s--,d--)if(H[s]!==ie[d]){if(s!==1||d!==1)do if(s--,d--,0>d||H[s]!==ie[d]){var fe=`
|
|
6
|
-
`+H[s].replace(" at new "," at ");return e.displayName&&fe.includes("<anonymous>")&&(fe=fe.replace("<anonymous>",e.displayName)),fe}while(1<=s&&0<=d);break}}}finally{ut=!1,Error.prepareStackTrace=r}return(r=e?e.displayName||e.name:"")?tt(r):""}function Lt(e,n){switch(e.tag){case 26:case 27:case 5:return tt(e.type);case 16:return tt("Lazy");case 13:return e.child!==n&&n!==null?tt("Suspense Fallback"):tt("Suspense");case 19:return tt("SuspenseList");case 0:case 15:return Ge(e.type,!1);case 11:return Ge(e.type.render,!1);case 1:return Ge(e.type,!0);case 31:return tt("Activity");default:return""}}function ct(e){try{var n="",r=null;do n+=Lt(e,r),r=e,e=e.return;while(e);return n}catch(s){return`
|
|
7
|
-
Error generating stack: `+s.message+`
|
|
8
|
-
`+s.stack}}var qe=Object.prototype.hasOwnProperty,ht=t.unstable_scheduleCallback,Fe=t.unstable_cancelCallback,nt=t.unstable_shouldYield,Et=t.unstable_requestPaint,lt=t.unstable_now,bt=t.unstable_getCurrentPriorityLevel,M=t.unstable_ImmediatePriority,P=t.unstable_UserBlockingPriority,ge=t.unstable_NormalPriority,Se=t.unstable_LowPriority,Ce=t.unstable_IdlePriority,Re=t.log,Qe=t.unstable_setDisableYieldValue,yt=null,pt=null;function mt(e){if(typeof Re=="function"&&Qe(e),pt&&typeof pt.setStrictMode=="function")try{pt.setStrictMode(yt,e)}catch{}}var Ze=Math.clz32?Math.clz32:Ee,oe=Math.log,_e=Math.LN2;function Ee(e){return e>>>=0,e===0?32:31-(oe(e)/_e|0)|0}var Me=256,ze=262144,W=4194304;function ve(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 Be(e,n,r){var s=e.pendingLanes;if(s===0)return 0;var d=0,g=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var E=s&134217727;return E!==0?(s=E&~g,s!==0?d=ve(s):(S&=E,S!==0?d=ve(S):r||(r=E&~e,r!==0&&(d=ve(r))))):(E=s&~g,E!==0?d=ve(E):S!==0?d=ve(S):r||(r=s&~e,r!==0&&(d=ve(r)))),d===0?0:n!==0&&n!==d&&(n&g)===0&&(g=d&-d,r=n&-n,g>=r||g===32&&(r&4194048)!==0)?n:d}function ke(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function q(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 ce(){var e=W;return W<<=1,(W&62914560)===0&&(W=4194304),e}function je(e){for(var n=[],r=0;31>r;r++)n.push(e);return n}function Ke(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function st(e,n,r,s,d,g){var S=e.pendingLanes;e.pendingLanes=r,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=r,e.entangledLanes&=r,e.errorRecoveryDisabledLanes&=r,e.shellSuspendCounter=0;var E=e.entanglements,H=e.expirationTimes,ie=e.hiddenUpdates;for(r=S&~r;0<r;){var fe=31-Ze(r),pe=1<<fe;E[fe]=0,H[fe]=-1;var le=ie[fe];if(le!==null)for(ie[fe]=null,fe=0;fe<le.length;fe++){var ue=le[fe];ue!==null&&(ue.lane&=-536870913)}r&=~pe}s!==0&&Rt(e,s,0),g!==0&&d===0&&e.tag!==0&&(e.suspendedLanes|=g&~(S&~n))}function Rt(e,n,r){e.pendingLanes|=n,e.suspendedLanes&=~n;var s=31-Ze(n);e.entangledLanes|=n,e.entanglements[s]=e.entanglements[s]|1073741824|r&261930}function Ct(e,n){var r=e.entangledLanes|=n;for(e=e.entanglements;r;){var s=31-Ze(r),d=1<<s;d&n|e[s]&n&&(e[s]|=n),r&=~d}}function Wn(e,n){var r=n&-n;return r=(r&42)!==0?1:Vt(r),(r&(e.suspendedLanes|n))!==0?0:r}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 wr(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Ta(){var e=Z.p;return e!==0?e:(e=window.event,e===void 0?32:sg(e.type))}function Ki(e,n){var r=Z.p;try{return Z.p=e,n()}finally{Z.p=r}}var Cn=Math.random().toString(36).slice(2),Bt="__reactFiber$"+Cn,Jt="__reactProps$"+Cn,Gn="__reactContainer$"+Cn,Fn="__reactEvents$"+Cn,qv="__reactListeners$"+Cn,Hv="__reactHandles$"+Cn,kd="__reactResources$"+Cn,gl="__reactMarker$"+Cn;function xo(e){delete e[Bt],delete e[Jt],delete e[Fn],delete e[qv],delete e[Hv]}function jr(e){var n=e[Bt];if(n)return n;for(var r=e.parentNode;r;){if(n=r[Gn]||r[Bt]){if(r=n.alternate,n.child!==null||r!==null&&r.child!==null)for(e=Fm(e);e!==null;){if(r=e[Bt])return r;e=Fm(e)}return n}e=r,r=e.parentNode}return null}function kr(e){if(e=e[Bt]||e[Gn]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function yl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(a(33))}function Er(e){var n=e[kd];return n||(n=e[kd]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Kt(e){e[gl]=!0}var Ed=new Set,Cd={};function Pi(e,n){Cr(e,n),Cr(e+"Capture",n)}function Cr(e,n){for(Cd[e]=n,e=0;e<n.length;e++)Ed.add(n[e])}var Vv=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]*$"),Nd={},Ad={};function Yv(e){return qe.call(Ad,e)?!0:qe.call(Nd,e)?!1:Vv.test(e)?Ad[e]=!0:(Nd[e]=!0,!1)}function Ra(e,n,r){if(Yv(n))if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var s=n.toLowerCase().slice(0,5);if(s!=="data-"&&s!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+r)}}function za(e,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+r)}}function ei(e,n,r,s){if(s===null)e.removeAttribute(r);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttributeNS(n,r,""+s)}}function Nn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Td(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Gv(e,n,r){var s=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var d=s.get,g=s.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return d.call(this)},set:function(S){r=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:s.enumerable}),{getValue:function(){return r},setValue:function(S){r=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function So(e){if(!e._valueTracker){var n=Td(e)?"checked":"value";e._valueTracker=Gv(e,n,""+e[n])}}function Rd(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var r=n.getValue(),s="";return e&&(s=Td(e)?e.checked?"true":"false":e.value),e=s,e!==r?(n.setValue(e),!0):!1}function Da(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 Fv=/[\n"\\]/g;function An(e){return e.replace(Fv,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function wo(e,n,r,s,d,g,S,E){e.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.type=S:e.removeAttribute("type"),n!=null?S==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Nn(n)):e.value!==""+Nn(n)&&(e.value=""+Nn(n)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),n!=null?jo(e,S,Nn(n)):r!=null?jo(e,S,Nn(r)):s!=null&&e.removeAttribute("value"),d==null&&g!=null&&(e.defaultChecked=!!g),d!=null&&(e.checked=d&&typeof d!="function"&&typeof d!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?e.name=""+Nn(E):e.removeAttribute("name")}function zd(e,n,r,s,d,g,S,E){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||r!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){So(e);return}r=r!=null?""+Nn(r):"",n=n!=null?""+Nn(n):r,E||n===e.value||(e.value=n),e.defaultValue=n}s=s??d,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=E?e.checked:!!s,e.defaultChecked=!!s,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),So(e)}function jo(e,n,r){n==="number"&&Da(e.ownerDocument)===e||e.defaultValue===""+r||(e.defaultValue=""+r)}function Nr(e,n,r,s){if(e=e.options,n){n={};for(var d=0;d<r.length;d++)n["$"+r[d]]=!0;for(r=0;r<e.length;r++)d=n.hasOwnProperty("$"+e[r].value),e[r].selected!==d&&(e[r].selected=d),d&&s&&(e[r].defaultSelected=!0)}else{for(r=""+Nn(r),n=null,d=0;d<e.length;d++){if(e[d].value===r){e[d].selected=!0,s&&(e[d].defaultSelected=!0);return}n!==null||e[d].disabled||(n=e[d])}n!==null&&(n.selected=!0)}}function Dd(e,n,r){if(n!=null&&(n=""+Nn(n),n!==e.value&&(e.value=n),r==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=r!=null?""+Nn(r):""}function _d(e,n,r,s){if(n==null){if(s!=null){if(r!=null)throw Error(a(92));if(K(s)){if(1<s.length)throw Error(a(93));s=s[0]}r=s}r==null&&(r=""),n=r}r=Nn(n),e.defaultValue=r,s=e.textContent,s===r&&s!==""&&s!==null&&(e.value=s),So(e)}function Ar(e,n){if(n){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=n;return}}e.textContent=n}var Qv=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 Md(e,n,r){var s=n.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?s?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":s?e.setProperty(n,r):typeof r!="number"||r===0||Qv.has(n)?n==="float"?e.cssFloat=r:e[n]=(""+r).trim():e[n]=r+"px"}function Od(e,n,r){if(n!=null&&typeof n!="object")throw Error(a(62));if(e=e.style,r!=null){for(var s in r)!r.hasOwnProperty(s)||n!=null&&n.hasOwnProperty(s)||(s.indexOf("--")===0?e.setProperty(s,""):s==="float"?e.cssFloat="":e[s]="");for(var d in n)s=n[d],n.hasOwnProperty(d)&&r[d]!==s&&Md(e,d,s)}else for(var g in n)n.hasOwnProperty(g)&&Md(e,g,n[g])}function ko(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 $v=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"]]),Xv=/^[\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 _a(e){return Xv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function ti(){}var Eo=null;function Co(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Tr=null,Rr=null;function Ld(e){var n=kr(e);if(n&&(e=n.stateNode)){var r=e[Jt]||null;e:switch(e=n.stateNode,n.type){case"input":if(wo(e,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),n=r.name,r.type==="radio"&&n!=null){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+An(""+n)+'"][type="radio"]'),n=0;n<r.length;n++){var s=r[n];if(s!==e&&s.form===e.form){var d=s[Jt]||null;if(!d)throw Error(a(90));wo(s,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name)}}for(n=0;n<r.length;n++)s=r[n],s.form===e.form&&Rd(s)}break e;case"textarea":Dd(e,r.value,r.defaultValue);break e;case"select":n=r.value,n!=null&&Nr(e,!!r.multiple,n,!1)}}}var No=!1;function Bd(e,n,r){if(No)return e(n,r);No=!0;try{var s=e(n);return s}finally{if(No=!1,(Tr!==null||Rr!==null)&&(xs(),Tr&&(n=Tr,e=Rr,Rr=Tr=null,Ld(n),e)))for(n=0;n<e.length;n++)Ld(e[n])}}function bl(e,n){var r=e.stateNode;if(r===null)return null;var s=r[Jt]||null;if(s===null)return null;r=s[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":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(r&&typeof r!="function")throw Error(a(231,n,typeof r));return r}var ni=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ao=!1;if(ni)try{var vl={};Object.defineProperty(vl,"passive",{get:function(){Ao=!0}}),window.addEventListener("test",vl,vl),window.removeEventListener("test",vl,vl)}catch{Ao=!1}var wi=null,To=null,Ma=null;function Ud(){if(Ma)return Ma;var e,n=To,r=n.length,s,d="value"in wi?wi.value:wi.textContent,g=d.length;for(e=0;e<r&&n[e]===d[e];e++);var S=r-e;for(s=1;s<=S&&n[r-s]===d[g-s];s++);return Ma=d.slice(e,1<s?1-s:void 0)}function Oa(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 La(){return!0}function Id(){return!1}function un(e){function n(r,s,d,g,S){this._reactName=r,this._targetInst=d,this.type=s,this.nativeEvent=g,this.target=S,this.currentTarget=null;for(var E in e)e.hasOwnProperty(E)&&(r=e[E],this[E]=r?r(g):g[E]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?La:Id,this.isPropagationStopped=Id,this}return b(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=La)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=La)},persist:function(){},isPersistent:La}),n}var Zi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ba=un(Zi),xl=b({},Zi,{view:0,detail:0}),Kv=un(xl),Ro,zo,Sl,Ua=b({},xl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_o,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!==Sl&&(Sl&&e.type==="mousemove"?(Ro=e.screenX-Sl.screenX,zo=e.screenY-Sl.screenY):zo=Ro=0,Sl=e),Ro)},movementY:function(e){return"movementY"in e?e.movementY:zo}}),qd=un(Ua),Pv=b({},Ua,{dataTransfer:0}),Zv=un(Pv),Jv=b({},xl,{relatedTarget:0}),Do=un(Jv),Wv=b({},Zi,{animationName:0,elapsedTime:0,pseudoElement:0}),ex=un(Wv),tx=b({},Zi,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),nx=un(tx),ix=b({},Zi,{data:0}),Hd=un(ix),rx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lx={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"},ax={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sx(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=ax[e])?!!n[e]:!1}function _o(){return sx}var ox=b({},xl,{key:function(e){if(e.key){var n=rx[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=Oa(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?lx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_o,charCode:function(e){return e.type==="keypress"?Oa(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Oa(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),ux=un(ox),cx=b({},Ua,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Vd=un(cx),fx=b({},xl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_o}),dx=un(fx),hx=b({},Zi,{propertyName:0,elapsedTime:0,pseudoElement:0}),px=un(hx),mx=b({},Ua,{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=un(mx),yx=b({},Zi,{newState:0,oldState:0}),bx=un(yx),vx=[9,13,27,32],Mo=ni&&"CompositionEvent"in window,wl=null;ni&&"documentMode"in document&&(wl=document.documentMode);var xx=ni&&"TextEvent"in window&&!wl,Yd=ni&&(!Mo||wl&&8<wl&&11>=wl),Gd=" ",Fd=!1;function Qd(e,n){switch(e){case"keyup":return vx.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $d(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var zr=!1;function Sx(e,n){switch(e){case"compositionend":return $d(n);case"keypress":return n.which!==32?null:(Fd=!0,Gd);case"textInput":return e=n.data,e===Gd&&Fd?null:e;default:return null}}function wx(e,n){if(zr)return e==="compositionend"||!Mo&&Qd(e,n)?(e=Ud(),Ma=To=wi=null,zr=!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 Yd&&n.locale!=="ko"?null:n.data;default:return null}}var jx={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 Xd(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!jx[e.type]:n==="textarea"}function Kd(e,n,r,s){Tr?Rr?Rr.push(s):Rr=[s]:Tr=s,n=Ns(n,"onChange"),0<n.length&&(r=new Ba("onChange","change",null,r,s),e.push({event:r,listeners:n}))}var jl=null,kl=null;function kx(e){zm(e,0)}function Ia(e){var n=yl(e);if(Rd(n))return e}function Pd(e,n){if(e==="change")return n}var Zd=!1;if(ni){var Oo;if(ni){var Lo="oninput"in document;if(!Lo){var Jd=document.createElement("div");Jd.setAttribute("oninput","return;"),Lo=typeof Jd.oninput=="function"}Oo=Lo}else Oo=!1;Zd=Oo&&(!document.documentMode||9<document.documentMode)}function Wd(){jl&&(jl.detachEvent("onpropertychange",eh),kl=jl=null)}function eh(e){if(e.propertyName==="value"&&Ia(kl)){var n=[];Kd(n,kl,e,Co(e)),Bd(kx,n)}}function Ex(e,n,r){e==="focusin"?(Wd(),jl=n,kl=r,jl.attachEvent("onpropertychange",eh)):e==="focusout"&&Wd()}function Cx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ia(kl)}function Nx(e,n){if(e==="click")return Ia(n)}function Ax(e,n){if(e==="input"||e==="change")return Ia(n)}function Tx(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var yn=typeof Object.is=="function"?Object.is:Tx;function El(e,n){if(yn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var r=Object.keys(e),s=Object.keys(n);if(r.length!==s.length)return!1;for(s=0;s<r.length;s++){var d=r[s];if(!qe.call(n,d)||!yn(e[d],n[d]))return!1}return!0}function th(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function nh(e,n){var r=th(e);e=0;for(var s;r;){if(r.nodeType===3){if(s=e+r.textContent.length,e<=n&&s>=n)return{node:r,offset:n-e};e=s}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=th(r)}}function ih(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?ih(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function rh(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=Da(e.document);n instanceof e.HTMLIFrameElement;){try{var r=typeof n.contentWindow.location.href=="string"}catch{r=!1}if(r)e=n.contentWindow;else break;n=Da(e.document)}return n}function Bo(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 Rx=ni&&"documentMode"in document&&11>=document.documentMode,Dr=null,Uo=null,Cl=null,Io=!1;function lh(e,n,r){var s=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Io||Dr==null||Dr!==Da(s)||(s=Dr,"selectionStart"in s&&Bo(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),Cl&&El(Cl,s)||(Cl=s,s=Ns(Uo,"onSelect"),0<s.length&&(n=new Ba("onSelect","select",null,n,r),e.push({event:n,listeners:s}),n.target=Dr)))}function Ji(e,n){var r={};return r[e.toLowerCase()]=n.toLowerCase(),r["Webkit"+e]="webkit"+n,r["Moz"+e]="moz"+n,r}var _r={animationend:Ji("Animation","AnimationEnd"),animationiteration:Ji("Animation","AnimationIteration"),animationstart:Ji("Animation","AnimationStart"),transitionrun:Ji("Transition","TransitionRun"),transitionstart:Ji("Transition","TransitionStart"),transitioncancel:Ji("Transition","TransitionCancel"),transitionend:Ji("Transition","TransitionEnd")},qo={},ah={};ni&&(ah=document.createElement("div").style,"AnimationEvent"in window||(delete _r.animationend.animation,delete _r.animationiteration.animation,delete _r.animationstart.animation),"TransitionEvent"in window||delete _r.transitionend.transition);function Wi(e){if(qo[e])return qo[e];if(!_r[e])return e;var n=_r[e],r;for(r in n)if(n.hasOwnProperty(r)&&r in ah)return qo[e]=n[r];return e}var sh=Wi("animationend"),oh=Wi("animationiteration"),uh=Wi("animationstart"),zx=Wi("transitionrun"),Dx=Wi("transitionstart"),_x=Wi("transitioncancel"),ch=Wi("transitionend"),fh=new Map,Ho="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(" ");Ho.push("scrollEnd");function Un(e,n){fh.set(e,n),Pi(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)},Tn=[],Mr=0,Vo=0;function Ha(){for(var e=Mr,n=Vo=Mr=0;n<e;){var r=Tn[n];Tn[n++]=null;var s=Tn[n];Tn[n++]=null;var d=Tn[n];Tn[n++]=null;var g=Tn[n];if(Tn[n++]=null,s!==null&&d!==null){var S=s.pending;S===null?d.next=d:(d.next=S.next,S.next=d),s.pending=d}g!==0&&dh(r,d,g)}}function Va(e,n,r,s){Tn[Mr++]=e,Tn[Mr++]=n,Tn[Mr++]=r,Tn[Mr++]=s,Vo|=s,e.lanes|=s,e=e.alternate,e!==null&&(e.lanes|=s)}function Yo(e,n,r,s){return Va(e,n,r,s),Ya(e)}function er(e,n){return Va(e,null,null,n),Ya(e)}function dh(e,n,r){e.lanes|=r;var s=e.alternate;s!==null&&(s.lanes|=r);for(var d=!1,g=e.return;g!==null;)g.childLanes|=r,s=g.alternate,s!==null&&(s.childLanes|=r),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(d=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,d&&n!==null&&(d=31-Ze(r),e=g.hiddenUpdates,s=e[d],s===null?e[d]=[n]:s.push(n),n.lane=r|536870912),g):null}function Ya(e){if(50<Xl)throw Xl=0,Ju=null,Error(a(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var Or={};function Mx(e,n,r,s){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bn(e,n,r,s){return new Mx(e,n,r,s)}function Go(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ii(e,n){var r=e.alternate;return r===null?(r=bn(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function hh(e,n){e.flags&=65011714;var r=e.alternate;return r===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=r.childLanes,e.lanes=r.lanes,e.child=r.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=r.memoizedProps,e.memoizedState=r.memoizedState,e.updateQueue=r.updateQueue,e.type=r.type,n=r.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function Ga(e,n,r,s,d,g){var S=0;if(s=e,typeof e=="function")Go(e)&&(S=1);else if(typeof e=="string")S=I0(e,r,te.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case I:return e=bn(31,r,n,d),e.elementType=I,e.lanes=g,e;case D:return tr(r.children,d,g,n);case N:S=8,d|=24;break;case A:return e=bn(12,r,n,d|2),e.elementType=A,e.lanes=g,e;case re:return e=bn(13,r,n,d),e.elementType=re,e.lanes=g,e;case T:return e=bn(19,r,n,d),e.elementType=T,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case O:S=10;break e;case R:S=9;break e;case Y:S=11;break e;case V:S=14;break e;case Q:S=16,s=null;break e}S=29,r=Error(a(130,e===null?"null":typeof e,"")),s=null}return n=bn(S,r,n,d),n.elementType=e,n.type=s,n.lanes=g,n}function tr(e,n,r,s){return e=bn(7,e,s,n),e.lanes=r,e}function Fo(e,n,r){return e=bn(6,e,null,n),e.lanes=r,e}function ph(e){var n=bn(18,null,null,0);return n.stateNode=e,n}function Qo(e,n,r){return n=bn(4,e.children!==null?e.children:[],e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var mh=new WeakMap;function Rn(e,n){if(typeof e=="object"&&e!==null){var r=mh.get(e);return r!==void 0?r:(n={value:e,source:n,stack:ct(n)},mh.set(e,n),n)}return{value:e,source:n,stack:ct(n)}}var Lr=[],Br=0,Fa=null,Nl=0,zn=[],Dn=0,ji=null,Qn=1,$n="";function ri(e,n){Lr[Br++]=Nl,Lr[Br++]=Fa,Fa=e,Nl=n}function gh(e,n,r){zn[Dn++]=Qn,zn[Dn++]=$n,zn[Dn++]=ji,ji=e;var s=Qn;e=$n;var d=32-Ze(s)-1;s&=~(1<<d),r+=1;var g=32-Ze(n)+d;if(30<g){var S=d-d%5;g=(s&(1<<S)-1).toString(32),s>>=S,d-=S,Qn=1<<32-Ze(n)+d|r<<d|s,$n=g+e}else Qn=1<<g|r<<d|s,$n=e}function $o(e){e.return!==null&&(ri(e,1),gh(e,1,0))}function Xo(e){for(;e===Fa;)Fa=Lr[--Br],Lr[Br]=null,Nl=Lr[--Br],Lr[Br]=null;for(;e===ji;)ji=zn[--Dn],zn[Dn]=null,$n=zn[--Dn],zn[Dn]=null,Qn=zn[--Dn],zn[Dn]=null}function yh(e,n){zn[Dn++]=Qn,zn[Dn++]=$n,zn[Dn++]=ji,Qn=n.id,$n=n.overflow,ji=e}var Wt=null,zt=null,at=!1,ki=null,_n=!1,Ko=Error(a(519));function Ei(e){var n=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Al(Rn(n,e)),Ko}function bh(e){var n=e.stateNode,r=e.type,s=e.memoizedProps;switch(n[Bt]=e,n[Jt]=s,r){case"dialog":We("cancel",n),We("close",n);break;case"iframe":case"object":case"embed":We("load",n);break;case"video":case"audio":for(r=0;r<Pl.length;r++)We(Pl[r],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),zd(n,s.value,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name,!0);break;case"select":We("invalid",n);break;case"textarea":We("invalid",n),_d(n,s.value,s.defaultValue,s.children)}r=s.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||n.textContent===""+r||s.suppressHydrationWarning===!0||Om(n.textContent,r)?(s.popover!=null&&(We("beforetoggle",n),We("toggle",n)),s.onScroll!=null&&We("scroll",n),s.onScrollEnd!=null&&We("scrollend",n),s.onClick!=null&&(n.onclick=ti),n=!0):n=!1,n||Ei(e,!0)}function vh(e){for(Wt=e.return;Wt;)switch(Wt.tag){case 5:case 31:case 13:_n=!1;return;case 27:case 3:_n=!0;return;default:Wt=Wt.return}}function Ur(e){if(e!==Wt)return!1;if(!at)return vh(e),at=!0,!1;var n=e.tag,r;if((r=n!==3&&n!==27)&&((r=n===5)&&(r=e.type,r=!(r!=="form"&&r!=="button")||hc(e.type,e.memoizedProps)),r=!r),r&&zt&&Ei(e),vh(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));zt=Gm(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));zt=Gm(e)}else n===27?(n=zt,Ii(e.type)?(e=bc,bc=null,zt=e):zt=n):zt=Wt?On(e.stateNode.nextSibling):null;return!0}function nr(){zt=Wt=null,at=!1}function Po(){var e=ki;return e!==null&&(hn===null?hn=e:hn.push.apply(hn,e),ki=null),e}function Al(e){ki===null?ki=[e]:ki.push(e)}var Zo=L(null),ir=null,li=null;function Ci(e,n,r){_(Zo,n._currentValue),n._currentValue=r}function ai(e){e._currentValue=Zo.current,J(Zo)}function Jo(e,n,r){for(;e!==null;){var s=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,s!==null&&(s.childLanes|=n)):s!==null&&(s.childLanes&n)!==n&&(s.childLanes|=n),e===r)break;e=e.return}}function Wo(e,n,r,s){var d=e.child;for(d!==null&&(d.return=e);d!==null;){var g=d.dependencies;if(g!==null){var S=d.child;g=g.firstContext;e:for(;g!==null;){var E=g;g=d;for(var H=0;H<n.length;H++)if(E.context===n[H]){g.lanes|=r,E=g.alternate,E!==null&&(E.lanes|=r),Jo(g.return,r,e),s||(S=null);break e}g=E.next}}else if(d.tag===18){if(S=d.return,S===null)throw Error(a(341));S.lanes|=r,g=S.alternate,g!==null&&(g.lanes|=r),Jo(S,r,e),S=null}else S=d.child;if(S!==null)S.return=d;else for(S=d;S!==null;){if(S===e){S=null;break}if(d=S.sibling,d!==null){d.return=S.return,S=d;break}S=S.return}d=S}}function Ir(e,n,r,s){e=null;for(var d=n,g=!1;d!==null;){if(!g){if((d.flags&524288)!==0)g=!0;else if((d.flags&262144)!==0)break}if(d.tag===10){var S=d.alternate;if(S===null)throw Error(a(387));if(S=S.memoizedProps,S!==null){var E=d.type;yn(d.pendingProps.value,S.value)||(e!==null?e.push(E):e=[E])}}else if(d===se.current){if(S=d.alternate,S===null)throw Error(a(387));S.memoizedState.memoizedState!==d.memoizedState.memoizedState&&(e!==null?e.push(ta):e=[ta])}d=d.return}e!==null&&Wo(n,e,r,s),n.flags|=262144}function Qa(e){for(e=e.firstContext;e!==null;){if(!yn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function rr(e){ir=e,li=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function en(e){return xh(ir,e)}function $a(e,n){return ir===null&&rr(e),xh(e,n)}function xh(e,n){var r=n._currentValue;if(n={context:n,memoizedValue:r,next:null},li===null){if(e===null)throw Error(a(308));li=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else li=li.next=n;return r}var Ox=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(r,s){e.push(s)}};this.abort=function(){n.aborted=!0,e.forEach(function(r){return r()})}},Lx=t.unstable_scheduleCallback,Bx=t.unstable_NormalPriority,Yt={$$typeof:O,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function eu(){return{controller:new Ox,data:new Map,refCount:0}}function Tl(e){e.refCount--,e.refCount===0&&Lx(Bx,function(){e.controller.abort()})}var Rl=null,tu=0,qr=0,Hr=null;function Ux(e,n){if(Rl===null){var r=Rl=[];tu=0,qr=rc(),Hr={status:"pending",value:void 0,then:function(s){r.push(s)}}}return tu++,n.then(Sh,Sh),n}function Sh(){if(--tu===0&&Rl!==null){Hr!==null&&(Hr.status="fulfilled");var e=Rl;Rl=null,qr=0,Hr=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Ix(e,n){var r=[],s={status:"pending",value:null,reason:null,then:function(d){r.push(d)}};return e.then(function(){s.status="fulfilled",s.value=n;for(var d=0;d<r.length;d++)(0,r[d])(n)},function(d){for(s.status="rejected",s.reason=d,d=0;d<r.length;d++)(0,r[d])(void 0)}),s}var wh=z.S;z.S=function(e,n){lm=lt(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&Ux(e,n),wh!==null&&wh(e,n)};var lr=L(null);function nu(){var e=lr.current;return e!==null?e:Nt.pooledCache}function Xa(e,n){n===null?_(lr,lr.current):_(lr,n.pool)}function jh(){var e=nu();return e===null?null:{parent:Yt._currentValue,pool:e}}var Vr=Error(a(460)),iu=Error(a(474)),Ka=Error(a(542)),Pa={then:function(){}};function kh(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Eh(e,n,r){switch(r=e[r],r===void 0?e.push(n):r!==n&&(n.then(ti,ti),n=r),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Nh(e),e;default:if(typeof n.status=="string")n.then(ti,ti);else{if(e=Nt,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=n,e.status="pending",e.then(function(s){if(n.status==="pending"){var d=n;d.status="fulfilled",d.value=s}},function(s){if(n.status==="pending"){var d=n;d.status="rejected",d.reason=s}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Nh(e),e}throw sr=n,Vr}}function ar(e){try{var n=e._init;return n(e._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(sr=r,Vr):r}}var sr=null;function Ch(){if(sr===null)throw Error(a(459));var e=sr;return sr=null,e}function Nh(e){if(e===Vr||e===Ka)throw Error(a(483))}var Yr=null,zl=0;function Za(e){var n=zl;return zl+=1,Yr===null&&(Yr=[]),Eh(Yr,e,n)}function Dl(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ja(e,n){throw n.$$typeof===x?Error(a(525)):(e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Ah(e){function n(X,G){if(e){var ne=X.deletions;ne===null?(X.deletions=[G],X.flags|=16):ne.push(G)}}function r(X,G){if(!e)return null;for(;G!==null;)n(X,G),G=G.sibling;return null}function s(X){for(var G=new Map;X!==null;)X.key!==null?G.set(X.key,X):G.set(X.index,X),X=X.sibling;return G}function d(X,G){return X=ii(X,G),X.index=0,X.sibling=null,X}function g(X,G,ne){return X.index=ne,e?(ne=X.alternate,ne!==null?(ne=ne.index,ne<G?(X.flags|=67108866,G):ne):(X.flags|=67108866,G)):(X.flags|=1048576,G)}function S(X){return e&&X.alternate===null&&(X.flags|=67108866),X}function E(X,G,ne,de){return G===null||G.tag!==6?(G=Fo(ne,X.mode,de),G.return=X,G):(G=d(G,ne),G.return=X,G)}function H(X,G,ne,de){var Oe=ne.type;return Oe===D?fe(X,G,ne.props.children,de,ne.key):G!==null&&(G.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===Q&&ar(Oe)===G.type)?(G=d(G,ne.props),Dl(G,ne),G.return=X,G):(G=Ga(ne.type,ne.key,ne.props,null,X.mode,de),Dl(G,ne),G.return=X,G)}function ie(X,G,ne,de){return G===null||G.tag!==4||G.stateNode.containerInfo!==ne.containerInfo||G.stateNode.implementation!==ne.implementation?(G=Qo(ne,X.mode,de),G.return=X,G):(G=d(G,ne.children||[]),G.return=X,G)}function fe(X,G,ne,de,Oe){return G===null||G.tag!==7?(G=tr(ne,X.mode,de,Oe),G.return=X,G):(G=d(G,ne),G.return=X,G)}function pe(X,G,ne){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Fo(""+G,X.mode,ne),G.return=X,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case v:return ne=Ga(G.type,G.key,G.props,null,X.mode,ne),Dl(ne,G),ne.return=X,ne;case j:return G=Qo(G,X.mode,ne),G.return=X,G;case Q:return G=ar(G),pe(X,G,ne)}if(K(G)||U(G))return G=tr(G,X.mode,ne,null),G.return=X,G;if(typeof G.then=="function")return pe(X,Za(G),ne);if(G.$$typeof===O)return pe(X,$a(X,G),ne);Ja(X,G)}return null}function le(X,G,ne,de){var Oe=G!==null?G.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return Oe!==null?null:E(X,G,""+ne,de);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case v:return ne.key===Oe?H(X,G,ne,de):null;case j:return ne.key===Oe?ie(X,G,ne,de):null;case Q:return ne=ar(ne),le(X,G,ne,de)}if(K(ne)||U(ne))return Oe!==null?null:fe(X,G,ne,de,null);if(typeof ne.then=="function")return le(X,G,Za(ne),de);if(ne.$$typeof===O)return le(X,G,$a(X,ne),de);Ja(X,ne)}return null}function ue(X,G,ne,de,Oe){if(typeof de=="string"&&de!==""||typeof de=="number"||typeof de=="bigint")return X=X.get(ne)||null,E(G,X,""+de,Oe);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case v:return X=X.get(de.key===null?ne:de.key)||null,H(G,X,de,Oe);case j:return X=X.get(de.key===null?ne:de.key)||null,ie(G,X,de,Oe);case Q:return de=ar(de),ue(X,G,ne,de,Oe)}if(K(de)||U(de))return X=X.get(ne)||null,fe(G,X,de,Oe,null);if(typeof de.then=="function")return ue(X,G,ne,Za(de),Oe);if(de.$$typeof===O)return ue(X,G,ne,$a(G,de),Oe);Ja(G,de)}return null}function Ne(X,G,ne,de){for(var Oe=null,ft=null,De=G,Xe=G=0,rt=null;De!==null&&Xe<ne.length;Xe++){De.index>Xe?(rt=De,De=null):rt=De.sibling;var dt=le(X,De,ne[Xe],de);if(dt===null){De===null&&(De=rt);break}e&&De&&dt.alternate===null&&n(X,De),G=g(dt,G,Xe),ft===null?Oe=dt:ft.sibling=dt,ft=dt,De=rt}if(Xe===ne.length)return r(X,De),at&&ri(X,Xe),Oe;if(De===null){for(;Xe<ne.length;Xe++)De=pe(X,ne[Xe],de),De!==null&&(G=g(De,G,Xe),ft===null?Oe=De:ft.sibling=De,ft=De);return at&&ri(X,Xe),Oe}for(De=s(De);Xe<ne.length;Xe++)rt=ue(De,X,Xe,ne[Xe],de),rt!==null&&(e&&rt.alternate!==null&&De.delete(rt.key===null?Xe:rt.key),G=g(rt,G,Xe),ft===null?Oe=rt:ft.sibling=rt,ft=rt);return e&&De.forEach(function(Gi){return n(X,Gi)}),at&&ri(X,Xe),Oe}function Ie(X,G,ne,de){if(ne==null)throw Error(a(151));for(var Oe=null,ft=null,De=G,Xe=G=0,rt=null,dt=ne.next();De!==null&&!dt.done;Xe++,dt=ne.next()){De.index>Xe?(rt=De,De=null):rt=De.sibling;var Gi=le(X,De,dt.value,de);if(Gi===null){De===null&&(De=rt);break}e&&De&&Gi.alternate===null&&n(X,De),G=g(Gi,G,Xe),ft===null?Oe=Gi:ft.sibling=Gi,ft=Gi,De=rt}if(dt.done)return r(X,De),at&&ri(X,Xe),Oe;if(De===null){for(;!dt.done;Xe++,dt=ne.next())dt=pe(X,dt.value,de),dt!==null&&(G=g(dt,G,Xe),ft===null?Oe=dt:ft.sibling=dt,ft=dt);return at&&ri(X,Xe),Oe}for(De=s(De);!dt.done;Xe++,dt=ne.next())dt=ue(De,X,Xe,dt.value,de),dt!==null&&(e&&dt.alternate!==null&&De.delete(dt.key===null?Xe:dt.key),G=g(dt,G,Xe),ft===null?Oe=dt:ft.sibling=dt,ft=dt);return e&&De.forEach(function(P0){return n(X,P0)}),at&&ri(X,Xe),Oe}function kt(X,G,ne,de){if(typeof ne=="object"&&ne!==null&&ne.type===D&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case v:e:{for(var Oe=ne.key;G!==null;){if(G.key===Oe){if(Oe=ne.type,Oe===D){if(G.tag===7){r(X,G.sibling),de=d(G,ne.props.children),de.return=X,X=de;break e}}else if(G.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===Q&&ar(Oe)===G.type){r(X,G.sibling),de=d(G,ne.props),Dl(de,ne),de.return=X,X=de;break e}r(X,G);break}else n(X,G);G=G.sibling}ne.type===D?(de=tr(ne.props.children,X.mode,de,ne.key),de.return=X,X=de):(de=Ga(ne.type,ne.key,ne.props,null,X.mode,de),Dl(de,ne),de.return=X,X=de)}return S(X);case j:e:{for(Oe=ne.key;G!==null;){if(G.key===Oe)if(G.tag===4&&G.stateNode.containerInfo===ne.containerInfo&&G.stateNode.implementation===ne.implementation){r(X,G.sibling),de=d(G,ne.children||[]),de.return=X,X=de;break e}else{r(X,G);break}else n(X,G);G=G.sibling}de=Qo(ne,X.mode,de),de.return=X,X=de}return S(X);case Q:return ne=ar(ne),kt(X,G,ne,de)}if(K(ne))return Ne(X,G,ne,de);if(U(ne)){if(Oe=U(ne),typeof Oe!="function")throw Error(a(150));return ne=Oe.call(ne),Ie(X,G,ne,de)}if(typeof ne.then=="function")return kt(X,G,Za(ne),de);if(ne.$$typeof===O)return kt(X,G,$a(X,ne),de);Ja(X,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint"?(ne=""+ne,G!==null&&G.tag===6?(r(X,G.sibling),de=d(G,ne),de.return=X,X=de):(r(X,G),de=Fo(ne,X.mode,de),de.return=X,X=de),S(X)):r(X,G)}return function(X,G,ne,de){try{zl=0;var Oe=kt(X,G,ne,de);return Yr=null,Oe}catch(De){if(De===Vr||De===Ka)throw De;var ft=bn(29,De,null,X.mode);return ft.lanes=de,ft.return=X,ft}}}var or=Ah(!0),Th=Ah(!1),Ni=!1;function ru(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lu(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 Ai(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ti(e,n,r){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(gt&2)!==0){var d=s.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),s.pending=n,n=Ya(e),dh(e,null,r),n}return Va(e,s,n,r),Ya(e)}function _l(e,n,r){if(n=n.updateQueue,n!==null&&(n=n.shared,(r&4194048)!==0)){var s=n.lanes;s&=e.pendingLanes,r|=s,n.lanes=r,Ct(e,r)}}function au(e,n){var r=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,r===s)){var d=null,g=null;if(r=r.firstBaseUpdate,r!==null){do{var S={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};g===null?d=g=S:g=g.next=S,r=r.next}while(r!==null);g===null?d=g=n:g=g.next=n}else d=g=n;r={baseState:s.baseState,firstBaseUpdate:d,lastBaseUpdate:g,shared:s.shared,callbacks:s.callbacks},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=n:e.next=n,r.lastBaseUpdate=n}var su=!1;function Ml(){if(su){var e=Hr;if(e!==null)throw e}}function Ol(e,n,r,s){su=!1;var d=e.updateQueue;Ni=!1;var g=d.firstBaseUpdate,S=d.lastBaseUpdate,E=d.shared.pending;if(E!==null){d.shared.pending=null;var H=E,ie=H.next;H.next=null,S===null?g=ie:S.next=ie,S=H;var fe=e.alternate;fe!==null&&(fe=fe.updateQueue,E=fe.lastBaseUpdate,E!==S&&(E===null?fe.firstBaseUpdate=ie:E.next=ie,fe.lastBaseUpdate=H))}if(g!==null){var pe=d.baseState;S=0,fe=ie=H=null,E=g;do{var le=E.lane&-536870913,ue=le!==E.lane;if(ue?(it&le)===le:(s&le)===le){le!==0&&le===qr&&(su=!0),fe!==null&&(fe=fe.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Ne=e,Ie=E;le=n;var kt=r;switch(Ie.tag){case 1:if(Ne=Ie.payload,typeof Ne=="function"){pe=Ne.call(kt,pe,le);break e}pe=Ne;break e;case 3:Ne.flags=Ne.flags&-65537|128;case 0:if(Ne=Ie.payload,le=typeof Ne=="function"?Ne.call(kt,pe,le):Ne,le==null)break e;pe=b({},pe,le);break e;case 2:Ni=!0}}le=E.callback,le!==null&&(e.flags|=64,ue&&(e.flags|=8192),ue=d.callbacks,ue===null?d.callbacks=[le]:ue.push(le))}else ue={lane:le,tag:E.tag,payload:E.payload,callback:E.callback,next:null},fe===null?(ie=fe=ue,H=pe):fe=fe.next=ue,S|=le;if(E=E.next,E===null){if(E=d.shared.pending,E===null)break;ue=E,E=ue.next,ue.next=null,d.lastBaseUpdate=ue,d.shared.pending=null}}while(!0);fe===null&&(H=pe),d.baseState=H,d.firstBaseUpdate=ie,d.lastBaseUpdate=fe,g===null&&(d.shared.lanes=0),Mi|=S,e.lanes=S,e.memoizedState=pe}}function Rh(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function zh(e,n){var r=e.callbacks;if(r!==null)for(e.callbacks=null,e=0;e<r.length;e++)Rh(r[e],n)}var Gr=L(null),Wa=L(0);function Dh(e,n){e=mi,_(Wa,e),_(Gr,n),mi=e|n.baseLanes}function ou(){_(Wa,mi),_(Gr,Gr.current)}function uu(){mi=Wa.current,J(Gr),J(Wa)}var vn=L(null),Mn=null;function Ri(e){var n=e.alternate;_(qt,qt.current&1),_(vn,e),Mn===null&&(n===null||Gr.current!==null||n.memoizedState!==null)&&(Mn=e)}function cu(e){_(qt,qt.current),_(vn,e),Mn===null&&(Mn=e)}function _h(e){e.tag===22?(_(qt,qt.current),_(vn,e),Mn===null&&(Mn=e)):zi()}function zi(){_(qt,qt.current),_(vn,vn.current)}function xn(e){J(vn),Mn===e&&(Mn=null),J(qt)}var qt=L(0);function es(e){for(var n=e;n!==null;){if(n.tag===13){var r=n.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||gc(r)||yc(r)))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 si=0,$e=null,wt=null,Gt=null,ts=!1,Fr=!1,ur=!1,ns=0,Ll=0,Qr=null,qx=0;function Ut(){throw Error(a(321))}function fu(e,n){if(n===null)return!1;for(var r=0;r<n.length&&r<e.length;r++)if(!yn(e[r],n[r]))return!1;return!0}function du(e,n,r,s,d,g){return si=g,$e=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,z.H=e===null||e.memoizedState===null?gp:Nu,ur=!1,g=r(s,d),ur=!1,Fr&&(g=Oh(n,r,s,d)),Mh(e),g}function Mh(e){z.H=Il;var n=wt!==null&&wt.next!==null;if(si=0,Gt=wt=$e=null,ts=!1,Ll=0,Qr=null,n)throw Error(a(300));e===null||Ft||(e=e.dependencies,e!==null&&Qa(e)&&(Ft=!0))}function Oh(e,n,r,s){$e=e;var d=0;do{if(Fr&&(Qr=null),Ll=0,Fr=!1,25<=d)throw Error(a(301));if(d+=1,Gt=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)}z.H=yp,g=n(r,s)}while(Fr);return g}function Hx(){var e=z.H,n=e.useState()[0];return n=typeof n.then=="function"?Bl(n):n,e=e.useState()[0],(wt!==null?wt.memoizedState:null)!==e&&($e.flags|=1024),n}function hu(){var e=ns!==0;return ns=0,e}function pu(e,n,r){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r}function mu(e){if(ts){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}ts=!1}si=0,Gt=wt=$e=null,Fr=!1,Ll=ns=0,Qr=null}function sn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Gt===null?$e.memoizedState=Gt=e:Gt=Gt.next=e,Gt}function Ht(){if(wt===null){var e=$e.alternate;e=e!==null?e.memoizedState:null}else e=wt.next;var n=Gt===null?$e.memoizedState:Gt.next;if(n!==null)Gt=n,wt=e;else{if(e===null)throw $e.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},Gt===null?$e.memoizedState=Gt=e:Gt=Gt.next=e}return Gt}function is(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Bl(e){var n=Ll;return Ll+=1,Qr===null&&(Qr=[]),e=Eh(Qr,e,n),n=$e,(Gt===null?n.memoizedState:Gt.next)===null&&(n=n.alternate,z.H=n===null||n.memoizedState===null?gp:Nu),e}function rs(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Bl(e);if(e.$$typeof===O)return en(e)}throw Error(a(438,String(e)))}function gu(e){var n=null,r=$e.updateQueue;if(r!==null&&(n=r.memoCache),n==null){var s=$e.alternate;s!==null&&(s=s.updateQueue,s!==null&&(s=s.memoCache,s!=null&&(n={data:s.data.map(function(d){return d.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),r===null&&(r=is(),$e.updateQueue=r),r.memoCache=n,r=n.data[n.index],r===void 0)for(r=n.data[n.index]=Array(e),s=0;s<e;s++)r[s]=C;return n.index++,r}function oi(e,n){return typeof n=="function"?n(e):n}function ls(e){var n=Ht();return yu(n,wt,e)}function yu(e,n,r){var s=e.queue;if(s===null)throw Error(a(311));s.lastRenderedReducer=r;var d=e.baseQueue,g=s.pending;if(g!==null){if(d!==null){var S=d.next;d.next=g.next,g.next=S}n.baseQueue=d=g,s.pending=null}if(g=e.baseState,d===null)e.memoizedState=g;else{n=d.next;var E=S=null,H=null,ie=n,fe=!1;do{var pe=ie.lane&-536870913;if(pe!==ie.lane?(it&pe)===pe:(si&pe)===pe){var le=ie.revertLane;if(le===0)H!==null&&(H=H.next={lane:0,revertLane:0,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),pe===qr&&(fe=!0);else if((si&le)===le){ie=ie.next,le===qr&&(fe=!0);continue}else pe={lane:0,revertLane:ie.revertLane,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},H===null?(E=H=pe,S=g):H=H.next=pe,$e.lanes|=le,Mi|=le;pe=ie.action,ur&&r(g,pe),g=ie.hasEagerState?ie.eagerState:r(g,pe)}else le={lane:pe,revertLane:ie.revertLane,gesture:ie.gesture,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},H===null?(E=H=le,S=g):H=H.next=le,$e.lanes|=pe,Mi|=pe;ie=ie.next}while(ie!==null&&ie!==n);if(H===null?S=g:H.next=E,!yn(g,e.memoizedState)&&(Ft=!0,fe&&(r=Hr,r!==null)))throw r;e.memoizedState=g,e.baseState=S,e.baseQueue=H,s.lastRenderedState=g}return d===null&&(s.lanes=0),[e.memoizedState,s.dispatch]}function bu(e){var n=Ht(),r=n.queue;if(r===null)throw Error(a(311));r.lastRenderedReducer=e;var s=r.dispatch,d=r.pending,g=n.memoizedState;if(d!==null){r.pending=null;var S=d=d.next;do g=e(g,S.action),S=S.next;while(S!==d);yn(g,n.memoizedState)||(Ft=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),r.lastRenderedState=g}return[g,s]}function Lh(e,n,r){var s=$e,d=Ht(),g=at;if(g){if(r===void 0)throw Error(a(407));r=r()}else r=n();var S=!yn((wt||d).memoizedState,r);if(S&&(d.memoizedState=r,Ft=!0),d=d.queue,Su(Ih.bind(null,s,d,e),[e]),d.getSnapshot!==n||S||Gt!==null&&Gt.memoizedState.tag&1){if(s.flags|=2048,$r(9,{destroy:void 0},Uh.bind(null,s,d,r,n),null),Nt===null)throw Error(a(349));g||(si&127)!==0||Bh(s,n,r)}return r}function Bh(e,n,r){e.flags|=16384,e={getSnapshot:n,value:r},n=$e.updateQueue,n===null?(n=is(),$e.updateQueue=n,n.stores=[e]):(r=n.stores,r===null?n.stores=[e]:r.push(e))}function Uh(e,n,r,s){n.value=r,n.getSnapshot=s,qh(n)&&Hh(e)}function Ih(e,n,r){return r(function(){qh(n)&&Hh(e)})}function qh(e){var n=e.getSnapshot;e=e.value;try{var r=n();return!yn(e,r)}catch{return!0}}function Hh(e){var n=er(e,2);n!==null&&pn(n,e,2)}function vu(e){var n=sn();if(typeof e=="function"){var r=e;if(e=r(),ur){mt(!0);try{r()}finally{mt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:oi,lastRenderedState:e},n}function Vh(e,n,r,s){return e.baseState=r,yu(e,wt,typeof s=="function"?s:oi)}function Vx(e,n,r,s,d){if(os(e))throw Error(a(485));if(e=n.action,e!==null){var g={payload:d,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){g.listeners.push(S)}};z.T!==null?r(!0):g.isTransition=!1,s(g),r=n.pending,r===null?(g.next=n.pending=g,Yh(n,g)):(g.next=r.next,n.pending=r.next=g)}}function Yh(e,n){var r=n.action,s=n.payload,d=e.state;if(n.isTransition){var g=z.T,S={};z.T=S;try{var E=r(d,s),H=z.S;H!==null&&H(S,E),Gh(e,n,E)}catch(ie){xu(e,n,ie)}finally{g!==null&&S.types!==null&&(g.types=S.types),z.T=g}}else try{g=r(d,s),Gh(e,n,g)}catch(ie){xu(e,n,ie)}}function Gh(e,n,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(s){Fh(e,n,s)},function(s){return xu(e,n,s)}):Fh(e,n,r)}function Fh(e,n,r){n.status="fulfilled",n.value=r,Qh(n),e.state=r,n=e.pending,n!==null&&(r=n.next,r===n?e.pending=null:(r=r.next,n.next=r,Yh(e,r)))}function xu(e,n,r){var s=e.pending;if(e.pending=null,s!==null){s=s.next;do n.status="rejected",n.reason=r,Qh(n),n=n.next;while(n!==s)}e.action=null}function Qh(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function $h(e,n){return n}function Xh(e,n){if(at){var r=Nt.formState;if(r!==null){e:{var s=$e;if(at){if(zt){t:{for(var d=zt,g=_n;d.nodeType!==8;){if(!g){d=null;break t}if(d=On(d.nextSibling),d===null){d=null;break t}}g=d.data,d=g==="F!"||g==="F"?d:null}if(d){zt=On(d.nextSibling),s=d.data==="F!";break e}}Ei(s)}s=!1}s&&(n=r[0])}}return r=sn(),r.memoizedState=r.baseState=n,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:$h,lastRenderedState:n},r.queue=s,r=hp.bind(null,$e,s),s.dispatch=r,s=vu(!1),g=Cu.bind(null,$e,!1,s.queue),s=sn(),d={state:n,dispatch:null,action:e,pending:null},s.queue=d,r=Vx.bind(null,$e,d,g,r),d.dispatch=r,s.memoizedState=e,[n,r,!1]}function Kh(e){var n=Ht();return Ph(n,wt,e)}function Ph(e,n,r){if(n=yu(e,n,$h)[0],e=ls(oi)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var s=Bl(n)}catch(S){throw S===Vr?Ka:S}else s=n;n=Ht();var d=n.queue,g=d.dispatch;return r!==n.memoizedState&&($e.flags|=2048,$r(9,{destroy:void 0},Yx.bind(null,d,r),null)),[s,g,e]}function Yx(e,n){e.action=n}function Zh(e){var n=Ht(),r=wt;if(r!==null)return Ph(n,r,e);Ht(),n=n.memoizedState,r=Ht();var s=r.queue.dispatch;return r.memoizedState=e,[n,s,!1]}function $r(e,n,r,s){return e={tag:e,create:r,deps:s,inst:n,next:null},n=$e.updateQueue,n===null&&(n=is(),$e.updateQueue=n),r=n.lastEffect,r===null?n.lastEffect=e.next=e:(s=r.next,r.next=e,e.next=s,n.lastEffect=e),e}function Jh(){return Ht().memoizedState}function as(e,n,r,s){var d=sn();$e.flags|=e,d.memoizedState=$r(1|n,{destroy:void 0},r,s===void 0?null:s)}function ss(e,n,r,s){var d=Ht();s=s===void 0?null:s;var g=d.memoizedState.inst;wt!==null&&s!==null&&fu(s,wt.memoizedState.deps)?d.memoizedState=$r(n,g,r,s):($e.flags|=e,d.memoizedState=$r(1|n,g,r,s))}function Wh(e,n){as(8390656,8,e,n)}function Su(e,n){ss(2048,8,e,n)}function Gx(e){$e.flags|=4;var n=$e.updateQueue;if(n===null)n=is(),$e.updateQueue=n,n.events=[e];else{var r=n.events;r===null?n.events=[e]:r.push(e)}}function ep(e){var n=Ht().memoizedState;return Gx({ref:n,nextImpl:e}),function(){if((gt&2)!==0)throw Error(a(440));return n.impl.apply(void 0,arguments)}}function tp(e,n){return ss(4,2,e,n)}function np(e,n){return ss(4,4,e,n)}function ip(e,n){if(typeof n=="function"){e=e();var r=n(e);return function(){typeof r=="function"?r():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function rp(e,n,r){r=r!=null?r.concat([e]):null,ss(4,4,ip.bind(null,n,e),r)}function wu(){}function lp(e,n){var r=Ht();n=n===void 0?null:n;var s=r.memoizedState;return n!==null&&fu(n,s[1])?s[0]:(r.memoizedState=[e,n],e)}function ap(e,n){var r=Ht();n=n===void 0?null:n;var s=r.memoizedState;if(n!==null&&fu(n,s[1]))return s[0];if(s=e(),ur){mt(!0);try{e()}finally{mt(!1)}}return r.memoizedState=[s,n],s}function ju(e,n,r){return r===void 0||(si&1073741824)!==0&&(it&261930)===0?e.memoizedState=n:(e.memoizedState=r,e=sm(),$e.lanes|=e,Mi|=e,r)}function sp(e,n,r,s){return yn(r,n)?r:Gr.current!==null?(e=ju(e,r,s),yn(e,n)||(Ft=!0),e):(si&42)===0||(si&1073741824)!==0&&(it&261930)===0?(Ft=!0,e.memoizedState=r):(e=sm(),$e.lanes|=e,Mi|=e,n)}function op(e,n,r,s,d){var g=Z.p;Z.p=g!==0&&8>g?g:8;var S=z.T,E={};z.T=E,Cu(e,!1,n,r);try{var H=d(),ie=z.S;if(ie!==null&&ie(E,H),H!==null&&typeof H=="object"&&typeof H.then=="function"){var fe=Ix(H,s);Ul(e,n,fe,jn(e))}else Ul(e,n,s,jn(e))}catch(pe){Ul(e,n,{then:function(){},status:"rejected",reason:pe},jn())}finally{Z.p=g,S!==null&&E.types!==null&&(S.types=E.types),z.T=S}}function Fx(){}function ku(e,n,r,s){if(e.tag!==5)throw Error(a(476));var d=up(e).queue;op(e,d,n,he,r===null?Fx:function(){return cp(e),r(s)})}function up(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:he,baseState:he,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:oi,lastRenderedState:he},next:null};var r={};return n.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:oi,lastRenderedState:r},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function cp(e){var n=up(e);n.next===null&&(n=e.alternate.memoizedState),Ul(e,n.next.queue,{},jn())}function Eu(){return en(ta)}function fp(){return Ht().memoizedState}function dp(){return Ht().memoizedState}function Qx(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var r=jn();e=Ai(r);var s=Ti(n,e,r);s!==null&&(pn(s,n,r),_l(s,n,r)),n={cache:eu()},e.payload=n;return}n=n.return}}function $x(e,n,r){var s=jn();r={lane:s,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},os(e)?pp(n,r):(r=Yo(e,n,r,s),r!==null&&(pn(r,e,s),mp(r,n,s)))}function hp(e,n,r){var s=jn();Ul(e,n,r,s)}function Ul(e,n,r,s){var d={lane:s,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(os(e))pp(n,d);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,E=g(S,r);if(d.hasEagerState=!0,d.eagerState=E,yn(E,S))return Va(e,n,d,0),Nt===null&&Ha(),!1}catch{}if(r=Yo(e,n,d,s),r!==null)return pn(r,e,s),mp(r,n,s),!0}return!1}function Cu(e,n,r,s){if(s={lane:2,revertLane:rc(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},os(e)){if(n)throw Error(a(479))}else n=Yo(e,r,s,2),n!==null&&pn(n,e,2)}function os(e){var n=e.alternate;return e===$e||n!==null&&n===$e}function pp(e,n){Fr=ts=!0;var r=e.pending;r===null?n.next=n:(n.next=r.next,r.next=n),e.pending=n}function mp(e,n,r){if((r&4194048)!==0){var s=n.lanes;s&=e.pendingLanes,r|=s,n.lanes=r,Ct(e,r)}}var Il={readContext:en,use:rs,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useLayoutEffect:Ut,useInsertionEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useSyncExternalStore:Ut,useId:Ut,useHostTransitionStatus:Ut,useFormState:Ut,useActionState:Ut,useOptimistic:Ut,useMemoCache:Ut,useCacheRefresh:Ut};Il.useEffectEvent=Ut;var gp={readContext:en,use:rs,useCallback:function(e,n){return sn().memoizedState=[e,n===void 0?null:n],e},useContext:en,useEffect:Wh,useImperativeHandle:function(e,n,r){r=r!=null?r.concat([e]):null,as(4194308,4,ip.bind(null,n,e),r)},useLayoutEffect:function(e,n){return as(4194308,4,e,n)},useInsertionEffect:function(e,n){as(4,2,e,n)},useMemo:function(e,n){var r=sn();n=n===void 0?null:n;var s=e();if(ur){mt(!0);try{e()}finally{mt(!1)}}return r.memoizedState=[s,n],s},useReducer:function(e,n,r){var s=sn();if(r!==void 0){var d=r(n);if(ur){mt(!0);try{r(n)}finally{mt(!1)}}}else d=n;return s.memoizedState=s.baseState=d,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:d},s.queue=e,e=e.dispatch=$x.bind(null,$e,e),[s.memoizedState,e]},useRef:function(e){var n=sn();return e={current:e},n.memoizedState=e},useState:function(e){e=vu(e);var n=e.queue,r=hp.bind(null,$e,n);return n.dispatch=r,[e.memoizedState,r]},useDebugValue:wu,useDeferredValue:function(e,n){var r=sn();return ju(r,e,n)},useTransition:function(){var e=vu(!1);return e=op.bind(null,$e,e.queue,!0,!1),sn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,r){var s=$e,d=sn();if(at){if(r===void 0)throw Error(a(407));r=r()}else{if(r=n(),Nt===null)throw Error(a(349));(it&127)!==0||Bh(s,n,r)}d.memoizedState=r;var g={value:r,getSnapshot:n};return d.queue=g,Wh(Ih.bind(null,s,g,e),[e]),s.flags|=2048,$r(9,{destroy:void 0},Uh.bind(null,s,g,r,n),null),r},useId:function(){var e=sn(),n=Nt.identifierPrefix;if(at){var r=$n,s=Qn;r=(s&~(1<<32-Ze(s)-1)).toString(32)+r,n="_"+n+"R_"+r,r=ns++,0<r&&(n+="H"+r.toString(32)),n+="_"}else r=qx++,n="_"+n+"r_"+r.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:Eu,useFormState:Xh,useActionState:Xh,useOptimistic:function(e){var n=sn();n.memoizedState=n.baseState=e;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=r,n=Cu.bind(null,$e,!0,r),r.dispatch=n,[e,n]},useMemoCache:gu,useCacheRefresh:function(){return sn().memoizedState=Qx.bind(null,$e)},useEffectEvent:function(e){var n=sn(),r={impl:e};return n.memoizedState=r,function(){if((gt&2)!==0)throw Error(a(440));return r.impl.apply(void 0,arguments)}}},Nu={readContext:en,use:rs,useCallback:lp,useContext:en,useEffect:Su,useImperativeHandle:rp,useInsertionEffect:tp,useLayoutEffect:np,useMemo:ap,useReducer:ls,useRef:Jh,useState:function(){return ls(oi)},useDebugValue:wu,useDeferredValue:function(e,n){var r=Ht();return sp(r,wt.memoizedState,e,n)},useTransition:function(){var e=ls(oi)[0],n=Ht().memoizedState;return[typeof e=="boolean"?e:Bl(e),n]},useSyncExternalStore:Lh,useId:fp,useHostTransitionStatus:Eu,useFormState:Kh,useActionState:Kh,useOptimistic:function(e,n){var r=Ht();return Vh(r,wt,e,n)},useMemoCache:gu,useCacheRefresh:dp};Nu.useEffectEvent=ep;var yp={readContext:en,use:rs,useCallback:lp,useContext:en,useEffect:Su,useImperativeHandle:rp,useInsertionEffect:tp,useLayoutEffect:np,useMemo:ap,useReducer:bu,useRef:Jh,useState:function(){return bu(oi)},useDebugValue:wu,useDeferredValue:function(e,n){var r=Ht();return wt===null?ju(r,e,n):sp(r,wt.memoizedState,e,n)},useTransition:function(){var e=bu(oi)[0],n=Ht().memoizedState;return[typeof e=="boolean"?e:Bl(e),n]},useSyncExternalStore:Lh,useId:fp,useHostTransitionStatus:Eu,useFormState:Zh,useActionState:Zh,useOptimistic:function(e,n){var r=Ht();return wt!==null?Vh(r,wt,e,n):(r.baseState=e,[e,r.queue.dispatch])},useMemoCache:gu,useCacheRefresh:dp};yp.useEffectEvent=ep;function Au(e,n,r,s){n=e.memoizedState,r=r(s,n),r=r==null?n:b({},n,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var Tu={enqueueSetState:function(e,n,r){e=e._reactInternals;var s=jn(),d=Ai(s);d.payload=n,r!=null&&(d.callback=r),n=Ti(e,d,s),n!==null&&(pn(n,e,s),_l(n,e,s))},enqueueReplaceState:function(e,n,r){e=e._reactInternals;var s=jn(),d=Ai(s);d.tag=1,d.payload=n,r!=null&&(d.callback=r),n=Ti(e,d,s),n!==null&&(pn(n,e,s),_l(n,e,s))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var r=jn(),s=Ai(r);s.tag=2,n!=null&&(s.callback=n),n=Ti(e,s,r),n!==null&&(pn(n,e,r),_l(n,e,r))}};function bp(e,n,r,s,d,g,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,g,S):n.prototype&&n.prototype.isPureReactComponent?!El(r,s)||!El(d,g):!0}function vp(e,n,r,s){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(r,s),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(r,s),n.state!==e&&Tu.enqueueReplaceState(n,n.state,null)}function cr(e,n){var r=n;if("ref"in n){r={};for(var s in n)s!=="ref"&&(r[s]=n[s])}if(e=e.defaultProps){r===n&&(r=b({},r));for(var d in e)r[d]===void 0&&(r[d]=e[d])}return r}function xp(e){qa(e)}function Sp(e){console.error(e)}function wp(e){qa(e)}function us(e,n){try{var r=e.onUncaughtError;r(n.value,{componentStack:n.stack})}catch(s){setTimeout(function(){throw s})}}function jp(e,n,r){try{var s=e.onCaughtError;s(r.value,{componentStack:r.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(d){setTimeout(function(){throw d})}}function Ru(e,n,r){return r=Ai(r),r.tag=3,r.payload={element:null},r.callback=function(){us(e,n)},r}function kp(e){return e=Ai(e),e.tag=3,e}function Ep(e,n,r,s){var d=r.type.getDerivedStateFromError;if(typeof d=="function"){var g=s.value;e.payload=function(){return d(g)},e.callback=function(){jp(n,r,s)}}var S=r.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){jp(n,r,s),typeof d!="function"&&(Oi===null?Oi=new Set([this]):Oi.add(this));var E=s.stack;this.componentDidCatch(s.value,{componentStack:E!==null?E:""})})}function Xx(e,n,r,s,d){if(r.flags|=32768,s!==null&&typeof s=="object"&&typeof s.then=="function"){if(n=r.alternate,n!==null&&Ir(n,r,d,!0),r=vn.current,r!==null){switch(r.tag){case 31:case 13:return Mn===null?Ss():r.alternate===null&&It===0&&(It=3),r.flags&=-257,r.flags|=65536,r.lanes=d,s===Pa?r.flags|=16384:(n=r.updateQueue,n===null?r.updateQueue=new Set([s]):n.add(s),tc(e,s,d)),!1;case 22:return r.flags|=65536,s===Pa?r.flags|=16384:(n=r.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([s])},r.updateQueue=n):(r=n.retryQueue,r===null?n.retryQueue=new Set([s]):r.add(s)),tc(e,s,d)),!1}throw Error(a(435,r.tag))}return tc(e,s,d),Ss(),!1}if(at)return n=vn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=d,s!==Ko&&(e=Error(a(422),{cause:s}),Al(Rn(e,r)))):(s!==Ko&&(n=Error(a(423),{cause:s}),Al(Rn(n,r))),e=e.current.alternate,e.flags|=65536,d&=-d,e.lanes|=d,s=Rn(s,r),d=Ru(e.stateNode,s,d),au(e,d),It!==4&&(It=2)),!1;var g=Error(a(520),{cause:s});if(g=Rn(g,r),$l===null?$l=[g]:$l.push(g),It!==4&&(It=2),n===null)return!0;s=Rn(s,r),r=n;do{switch(r.tag){case 3:return r.flags|=65536,e=d&-d,r.lanes|=e,e=Ru(r.stateNode,s,e),au(r,e),!1;case 1:if(n=r.type,g=r.stateNode,(r.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Oi===null||!Oi.has(g))))return r.flags|=65536,d&=-d,r.lanes|=d,d=kp(d),Ep(d,e,r,s),au(r,d),!1}r=r.return}while(r!==null);return!1}var zu=Error(a(461)),Ft=!1;function tn(e,n,r,s){n.child=e===null?Th(n,null,r,s):or(n,e.child,r,s)}function Cp(e,n,r,s,d){r=r.render;var g=n.ref;if("ref"in s){var S={};for(var E in s)E!=="ref"&&(S[E]=s[E])}else S=s;return rr(n),s=du(e,n,r,S,g,d),E=hu(),e!==null&&!Ft?(pu(e,n,d),ui(e,n,d)):(at&&E&&$o(n),n.flags|=1,tn(e,n,s,d),n.child)}function Np(e,n,r,s,d){if(e===null){var g=r.type;return typeof g=="function"&&!Go(g)&&g.defaultProps===void 0&&r.compare===null?(n.tag=15,n.type=g,Ap(e,n,g,s,d)):(e=Ga(r.type,null,s,n,n.mode,d),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Iu(e,d)){var S=g.memoizedProps;if(r=r.compare,r=r!==null?r:El,r(S,s)&&e.ref===n.ref)return ui(e,n,d)}return n.flags|=1,e=ii(g,s),e.ref=n.ref,e.return=n,n.child=e}function Ap(e,n,r,s,d){if(e!==null){var g=e.memoizedProps;if(El(g,s)&&e.ref===n.ref)if(Ft=!1,n.pendingProps=s=g,Iu(e,d))(e.flags&131072)!==0&&(Ft=!0);else return n.lanes=e.lanes,ui(e,n,d)}return Du(e,n,r,s,d)}function Tp(e,n,r,s){var d=s.children,g=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.mode==="hidden"){if((n.flags&128)!==0){if(g=g!==null?g.baseLanes|r:r,e!==null){for(s=n.child=e.child,d=0;s!==null;)d=d|s.lanes|s.childLanes,s=s.sibling;s=d&~g}else s=0,n.child=null;return Rp(e,n,g,r,s)}if((r&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&Xa(n,g!==null?g.cachePool:null),g!==null?Dh(n,g):ou(),_h(n);else return s=n.lanes=536870912,Rp(e,n,g!==null?g.baseLanes|r:r,r,s)}else g!==null?(Xa(n,g.cachePool),Dh(n,g),zi(),n.memoizedState=null):(e!==null&&Xa(n,null),ou(),zi());return tn(e,n,d,r),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 Rp(e,n,r,s,d){var g=nu();return g=g===null?null:{parent:Yt._currentValue,pool:g},n.memoizedState={baseLanes:r,cachePool:g},e!==null&&Xa(n,null),ou(),_h(n),e!==null&&Ir(e,n,s,!0),n.childLanes=d,null}function cs(e,n){return n=ds({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function zp(e,n,r){return or(n,e.child,null,r),e=cs(n,n.pendingProps),e.flags|=2,xn(n),n.memoizedState=null,e}function Kx(e,n,r){var s=n.pendingProps,d=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(at){if(s.mode==="hidden")return e=cs(n,s),n.lanes=536870912,ql(null,e);if(cu(n),(e=zt)?(e=Ym(e,_n),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:ji!==null?{id:Qn,overflow:$n}:null,retryLane:536870912,hydrationErrors:null},r=ph(e),r.return=n,n.child=r,Wt=n,zt=null)):e=null,e===null)throw Ei(n);return n.lanes=536870912,null}return cs(n,s)}var g=e.memoizedState;if(g!==null){var S=g.dehydrated;if(cu(n),d)if(n.flags&256)n.flags&=-257,n=zp(e,n,r);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(a(558));else if(Ft||Ir(e,n,r,!1),d=(r&e.childLanes)!==0,Ft||d){if(s=Nt,s!==null&&(S=Wn(s,r),S!==0&&S!==g.retryLane))throw g.retryLane=S,er(e,S),pn(s,e,S),zu;Ss(),n=zp(e,n,r)}else e=g.treeContext,zt=On(S.nextSibling),Wt=n,at=!0,ki=null,_n=!1,e!==null&&yh(n,e),n=cs(n,s),n.flags|=4096;return n}return e=ii(e.child,{mode:s.mode,children:s.children}),e.ref=n.ref,n.child=e,e.return=n,e}function fs(e,n){var r=n.ref;if(r===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(a(284));(e===null||e.ref!==r)&&(n.flags|=4194816)}}function Du(e,n,r,s,d){return rr(n),r=du(e,n,r,s,void 0,d),s=hu(),e!==null&&!Ft?(pu(e,n,d),ui(e,n,d)):(at&&s&&$o(n),n.flags|=1,tn(e,n,r,d),n.child)}function Dp(e,n,r,s,d,g){return rr(n),n.updateQueue=null,r=Oh(n,s,r,d),Mh(e),s=hu(),e!==null&&!Ft?(pu(e,n,g),ui(e,n,g)):(at&&s&&$o(n),n.flags|=1,tn(e,n,r,g),n.child)}function _p(e,n,r,s,d){if(rr(n),n.stateNode===null){var g=Or,S=r.contextType;typeof S=="object"&&S!==null&&(g=en(S)),g=new r(s,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Tu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=s,g.state=n.memoizedState,g.refs={},ru(n),S=r.contextType,g.context=typeof S=="object"&&S!==null?en(S):Or,g.state=n.memoizedState,S=r.getDerivedStateFromProps,typeof S=="function"&&(Au(n,r,S,s),g.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(S=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),S!==g.state&&Tu.enqueueReplaceState(g,g.state,null),Ol(n,s,g,d),Ml(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),s=!0}else if(e===null){g=n.stateNode;var E=n.memoizedProps,H=cr(r,E);g.props=H;var ie=g.context,fe=r.contextType;S=Or,typeof fe=="object"&&fe!==null&&(S=en(fe));var pe=r.getDerivedStateFromProps;fe=typeof pe=="function"||typeof g.getSnapshotBeforeUpdate=="function",E=n.pendingProps!==E,fe||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(E||ie!==S)&&vp(n,g,s,S),Ni=!1;var le=n.memoizedState;g.state=le,Ol(n,s,g,d),Ml(),ie=n.memoizedState,E||le!==ie||Ni?(typeof pe=="function"&&(Au(n,r,pe,s),ie=n.memoizedState),(H=Ni||bp(n,r,H,s,le,ie,S))?(fe||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=s,n.memoizedState=ie),g.props=s,g.state=ie,g.context=S,s=H):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),s=!1)}else{g=n.stateNode,lu(e,n),S=n.memoizedProps,fe=cr(r,S),g.props=fe,pe=n.pendingProps,le=g.context,ie=r.contextType,H=Or,typeof ie=="object"&&ie!==null&&(H=en(ie)),E=r.getDerivedStateFromProps,(ie=typeof E=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==pe||le!==H)&&vp(n,g,s,H),Ni=!1,le=n.memoizedState,g.state=le,Ol(n,s,g,d),Ml();var ue=n.memoizedState;S!==pe||le!==ue||Ni||e!==null&&e.dependencies!==null&&Qa(e.dependencies)?(typeof E=="function"&&(Au(n,r,E,s),ue=n.memoizedState),(fe=Ni||bp(n,r,fe,s,le,ue,H)||e!==null&&e.dependencies!==null&&Qa(e.dependencies))?(ie||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(s,ue,H),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(s,ue,H)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),n.memoizedProps=s,n.memoizedState=ue),g.props=s,g.state=ue,g.context=H,s=fe):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),s=!1)}return g=s,fs(e,n),s=(n.flags&128)!==0,g||s?(g=n.stateNode,r=s&&typeof r.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&s?(n.child=or(n,e.child,null,d),n.child=or(n,null,r,d)):tn(e,n,r,d),n.memoizedState=g.state,e=n.child):e=ui(e,n,d),e}function Mp(e,n,r,s){return nr(),n.flags|=256,tn(e,n,r,s),n.child}var _u={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Mu(e){return{baseLanes:e,cachePool:jh()}}function Ou(e,n,r){return e=e!==null?e.childLanes&~r:0,n&&(e|=wn),e}function Op(e,n,r){var s=n.pendingProps,d=!1,g=(n.flags&128)!==0,S;if((S=g)||(S=e!==null&&e.memoizedState===null?!1:(qt.current&2)!==0),S&&(d=!0,n.flags&=-129),S=(n.flags&32)!==0,n.flags&=-33,e===null){if(at){if(d?Ri(n):zi(),(e=zt)?(e=Ym(e,_n),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:ji!==null?{id:Qn,overflow:$n}:null,retryLane:536870912,hydrationErrors:null},r=ph(e),r.return=n,n.child=r,Wt=n,zt=null)):e=null,e===null)throw Ei(n);return yc(e)?n.lanes=32:n.lanes=536870912,null}var E=s.children;return s=s.fallback,d?(zi(),d=n.mode,E=ds({mode:"hidden",children:E},d),s=tr(s,d,r,null),E.return=n,s.return=n,E.sibling=s,n.child=E,s=n.child,s.memoizedState=Mu(r),s.childLanes=Ou(e,S,r),n.memoizedState=_u,ql(null,s)):(Ri(n),Lu(n,E))}var H=e.memoizedState;if(H!==null&&(E=H.dehydrated,E!==null)){if(g)n.flags&256?(Ri(n),n.flags&=-257,n=Bu(e,n,r)):n.memoizedState!==null?(zi(),n.child=e.child,n.flags|=128,n=null):(zi(),E=s.fallback,d=n.mode,s=ds({mode:"visible",children:s.children},d),E=tr(E,d,r,null),E.flags|=2,s.return=n,E.return=n,s.sibling=E,n.child=s,or(n,e.child,null,r),s=n.child,s.memoizedState=Mu(r),s.childLanes=Ou(e,S,r),n.memoizedState=_u,n=ql(null,s));else if(Ri(n),yc(E)){if(S=E.nextSibling&&E.nextSibling.dataset,S)var ie=S.dgst;S=ie,s=Error(a(419)),s.stack="",s.digest=S,Al({value:s,source:null,stack:null}),n=Bu(e,n,r)}else if(Ft||Ir(e,n,r,!1),S=(r&e.childLanes)!==0,Ft||S){if(S=Nt,S!==null&&(s=Wn(S,r),s!==0&&s!==H.retryLane))throw H.retryLane=s,er(e,s),pn(S,e,s),zu;gc(E)||Ss(),n=Bu(e,n,r)}else gc(E)?(n.flags|=192,n.child=e.child,n=null):(e=H.treeContext,zt=On(E.nextSibling),Wt=n,at=!0,ki=null,_n=!1,e!==null&&yh(n,e),n=Lu(n,s.children),n.flags|=4096);return n}return d?(zi(),E=s.fallback,d=n.mode,H=e.child,ie=H.sibling,s=ii(H,{mode:"hidden",children:s.children}),s.subtreeFlags=H.subtreeFlags&65011712,ie!==null?E=ii(ie,E):(E=tr(E,d,r,null),E.flags|=2),E.return=n,s.return=n,s.sibling=E,n.child=s,ql(null,s),s=n.child,E=e.child.memoizedState,E===null?E=Mu(r):(d=E.cachePool,d!==null?(H=Yt._currentValue,d=d.parent!==H?{parent:H,pool:H}:d):d=jh(),E={baseLanes:E.baseLanes|r,cachePool:d}),s.memoizedState=E,s.childLanes=Ou(e,S,r),n.memoizedState=_u,ql(e.child,s)):(Ri(n),r=e.child,e=r.sibling,r=ii(r,{mode:"visible",children:s.children}),r.return=n,r.sibling=null,e!==null&&(S=n.deletions,S===null?(n.deletions=[e],n.flags|=16):S.push(e)),n.child=r,n.memoizedState=null,r)}function Lu(e,n){return n=ds({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function ds(e,n){return e=bn(22,e,null,n),e.lanes=0,e}function Bu(e,n,r){return or(n,e.child,null,r),e=Lu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Lp(e,n,r){e.lanes|=n;var s=e.alternate;s!==null&&(s.lanes|=n),Jo(e.return,n,r)}function Uu(e,n,r,s,d,g){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:s,tail:r,tailMode:d,treeForkCount:g}:(S.isBackwards=n,S.rendering=null,S.renderingStartTime=0,S.last=s,S.tail=r,S.tailMode=d,S.treeForkCount=g)}function Bp(e,n,r){var s=n.pendingProps,d=s.revealOrder,g=s.tail;s=s.children;var S=qt.current,E=(S&2)!==0;if(E?(S=S&1|2,n.flags|=128):S&=1,_(qt,S),tn(e,n,s,r),s=at?Nl:0,!E&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Lp(e,r,n);else if(e.tag===19)Lp(e,r,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(d){case"forwards":for(r=n.child,d=null;r!==null;)e=r.alternate,e!==null&&es(e)===null&&(d=r),r=r.sibling;r=d,r===null?(d=n.child,n.child=null):(d=r.sibling,r.sibling=null),Uu(n,!1,d,r,g,s);break;case"backwards":case"unstable_legacy-backwards":for(r=null,d=n.child,n.child=null;d!==null;){if(e=d.alternate,e!==null&&es(e)===null){n.child=d;break}e=d.sibling,d.sibling=r,r=d,d=e}Uu(n,!0,r,null,g,s);break;case"together":Uu(n,!1,null,null,void 0,s);break;default:n.memoizedState=null}return n.child}function ui(e,n,r){if(e!==null&&(n.dependencies=e.dependencies),Mi|=n.lanes,(r&n.childLanes)===0)if(e!==null){if(Ir(e,n,r,!1),(r&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,r=ii(e,e.pendingProps),n.child=r,r.return=n;e.sibling!==null;)e=e.sibling,r=r.sibling=ii(e,e.pendingProps),r.return=n;r.sibling=null}return n.child}function Iu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&Qa(e)))}function Px(e,n,r){switch(n.tag){case 3:ye(n,n.stateNode.containerInfo),Ci(n,Yt,e.memoizedState.cache),nr();break;case 27:case 5:we(n);break;case 4:ye(n,n.stateNode.containerInfo);break;case 10:Ci(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,cu(n),null;break;case 13:var s=n.memoizedState;if(s!==null)return s.dehydrated!==null?(Ri(n),n.flags|=128,null):(r&n.child.childLanes)!==0?Op(e,n,r):(Ri(n),e=ui(e,n,r),e!==null?e.sibling:null);Ri(n);break;case 19:var d=(e.flags&128)!==0;if(s=(r&n.childLanes)!==0,s||(Ir(e,n,r,!1),s=(r&n.childLanes)!==0),d){if(s)return Bp(e,n,r);n.flags|=128}if(d=n.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),_(qt,qt.current),s)break;return null;case 22:return n.lanes=0,Tp(e,n,r,n.pendingProps);case 24:Ci(n,Yt,e.memoizedState.cache)}return ui(e,n,r)}function Up(e,n,r){if(e!==null)if(e.memoizedProps!==n.pendingProps)Ft=!0;else{if(!Iu(e,r)&&(n.flags&128)===0)return Ft=!1,Px(e,n,r);Ft=(e.flags&131072)!==0}else Ft=!1,at&&(n.flags&1048576)!==0&&gh(n,Nl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var s=n.pendingProps;if(e=ar(n.elementType),n.type=e,typeof e=="function")Go(e)?(s=cr(e,s),n.tag=1,n=_p(null,n,e,s,r)):(n.tag=0,n=Du(null,n,e,s,r));else{if(e!=null){var d=e.$$typeof;if(d===Y){n.tag=11,n=Cp(null,n,e,s,r);break e}else if(d===V){n.tag=14,n=Np(null,n,e,s,r);break e}}throw n=ee(e)||e,Error(a(306,n,""))}}return n;case 0:return Du(e,n,n.type,n.pendingProps,r);case 1:return s=n.type,d=cr(s,n.pendingProps),_p(e,n,s,d,r);case 3:e:{if(ye(n,n.stateNode.containerInfo),e===null)throw Error(a(387));s=n.pendingProps;var g=n.memoizedState;d=g.element,lu(e,n),Ol(n,s,null,r);var S=n.memoizedState;if(s=S.cache,Ci(n,Yt,s),s!==g.cache&&Wo(n,[Yt],r,!0),Ml(),s=S.element,g.isDehydrated)if(g={element:s,isDehydrated:!1,cache:S.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=Mp(e,n,s,r);break e}else if(s!==d){d=Rn(Error(a(424)),n),Al(d),n=Mp(e,n,s,r);break e}else for(e=n.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,zt=On(e.firstChild),Wt=n,at=!0,ki=null,_n=!0,r=Th(n,null,s,r),n.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(nr(),s===d){n=ui(e,n,r);break e}tn(e,n,s,r)}n=n.child}return n;case 26:return fs(e,n),e===null?(r=Km(n.type,null,n.pendingProps,null))?n.memoizedState=r:at||(r=n.type,e=n.pendingProps,s=As(ae.current).createElement(r),s[Bt]=n,s[Jt]=e,nn(s,r,e),Kt(s),n.stateNode=s):n.memoizedState=Km(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return we(n),e===null&&at&&(s=n.stateNode=Qm(n.type,n.pendingProps,ae.current),Wt=n,_n=!0,d=zt,Ii(n.type)?(bc=d,zt=On(s.firstChild)):zt=d),tn(e,n,n.pendingProps.children,r),fs(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&at&&((d=s=zt)&&(s=C0(s,n.type,n.pendingProps,_n),s!==null?(n.stateNode=s,Wt=n,zt=On(s.firstChild),_n=!1,d=!0):d=!1),d||Ei(n)),we(n),d=n.type,g=n.pendingProps,S=e!==null?e.memoizedProps:null,s=g.children,hc(d,g)?s=null:S!==null&&hc(d,S)&&(n.flags|=32),n.memoizedState!==null&&(d=du(e,n,Hx,null,null,r),ta._currentValue=d),fs(e,n),tn(e,n,s,r),n.child;case 6:return e===null&&at&&((e=r=zt)&&(r=N0(r,n.pendingProps,_n),r!==null?(n.stateNode=r,Wt=n,zt=null,e=!0):e=!1),e||Ei(n)),null;case 13:return Op(e,n,r);case 4:return ye(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=or(n,null,s,r):tn(e,n,s,r),n.child;case 11:return Cp(e,n,n.type,n.pendingProps,r);case 7:return tn(e,n,n.pendingProps,r),n.child;case 8:return tn(e,n,n.pendingProps.children,r),n.child;case 12:return tn(e,n,n.pendingProps.children,r),n.child;case 10:return s=n.pendingProps,Ci(n,n.type,s.value),tn(e,n,s.children,r),n.child;case 9:return d=n.type._context,s=n.pendingProps.children,rr(n),d=en(d),s=s(d),n.flags|=1,tn(e,n,s,r),n.child;case 14:return Np(e,n,n.type,n.pendingProps,r);case 15:return Ap(e,n,n.type,n.pendingProps,r);case 19:return Bp(e,n,r);case 31:return Kx(e,n,r);case 22:return Tp(e,n,r,n.pendingProps);case 24:return rr(n),s=en(Yt),e===null?(d=nu(),d===null&&(d=Nt,g=eu(),d.pooledCache=g,g.refCount++,g!==null&&(d.pooledCacheLanes|=r),d=g),n.memoizedState={parent:s,cache:d},ru(n),Ci(n,Yt,d)):((e.lanes&r)!==0&&(lu(e,n),Ol(n,null,null,r),Ml()),d=e.memoizedState,g=n.memoizedState,d.parent!==s?(d={parent:s,cache:s},n.memoizedState=d,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=d),Ci(n,Yt,s)):(s=g.cache,Ci(n,Yt,s),s!==d.cache&&Wo(n,[Yt],r,!0))),tn(e,n,n.pendingProps.children,r),n.child;case 29:throw n.pendingProps}throw Error(a(156,n.tag))}function ci(e){e.flags|=4}function qu(e,n,r,s,d){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(d&335544128)===d)if(e.stateNode.complete)e.flags|=8192;else if(fm())e.flags|=8192;else throw sr=Pa,iu}else e.flags&=-16777217}function Ip(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!eg(n))if(fm())e.flags|=8192;else throw sr=Pa,iu}function hs(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?ce():536870912,e.lanes|=n,Zr|=n)}function Hl(e,n){if(!at)switch(e.tailMode){case"hidden":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var s=null;r!==null;)r.alternate!==null&&(s=r),r=r.sibling;s===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function Dt(e){var n=e.alternate!==null&&e.alternate.child===e.child,r=0,s=0;if(n)for(var d=e.child;d!==null;)r|=d.lanes|d.childLanes,s|=d.subtreeFlags&65011712,s|=d.flags&65011712,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)r|=d.lanes|d.childLanes,s|=d.subtreeFlags,s|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=s,e.childLanes=r,n}function Zx(e,n,r){var s=n.pendingProps;switch(Xo(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Dt(n),null;case 1:return Dt(n),null;case 3:return r=n.stateNode,s=null,e!==null&&(s=e.memoizedState.cache),n.memoizedState.cache!==s&&(n.flags|=2048),ai(Yt),F(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Ur(n)?ci(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Po())),Dt(n),null;case 26:var d=n.type,g=n.memoizedState;return e===null?(ci(n),g!==null?(Dt(n),Ip(n,g)):(Dt(n),qu(n,d,null,s,r))):g?g!==e.memoizedState?(ci(n),Dt(n),Ip(n,g)):(Dt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==s&&ci(n),Dt(n),qu(n,d,e,s,r)),null;case 27:if(Le(n),r=ae.current,d=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==s&&ci(n);else{if(!s){if(n.stateNode===null)throw Error(a(166));return Dt(n),null}e=te.current,Ur(n)?bh(n):(e=Qm(d,s,r),n.stateNode=e,ci(n))}return Dt(n),null;case 5:if(Le(n),d=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==s&&ci(n);else{if(!s){if(n.stateNode===null)throw Error(a(166));return Dt(n),null}if(g=te.current,Ur(n))bh(n);else{var S=As(ae.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",d);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;default:switch(d){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",d);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;case"script":g=S.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof s.is=="string"?S.createElement("select",{is:s.is}):S.createElement("select"),s.multiple?g.multiple=!0:s.size&&(g.size=s.size);break;default:g=typeof s.is=="string"?S.createElement(d,{is:s.is}):S.createElement(d)}}g[Bt]=n,g[Jt]=s;e:for(S=n.child;S!==null;){if(S.tag===5||S.tag===6)g.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===n)break e;for(;S.sibling===null;){if(S.return===null||S.return===n)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}n.stateNode=g;e:switch(nn(g,d,s),d){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&ci(n)}}return Dt(n),qu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,r),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==s&&ci(n);else{if(typeof s!="string"&&n.stateNode===null)throw Error(a(166));if(e=ae.current,Ur(n)){if(e=n.stateNode,r=n.memoizedProps,s=null,d=Wt,d!==null)switch(d.tag){case 27:case 5:s=d.memoizedProps}e[Bt]=n,e=!!(e.nodeValue===r||s!==null&&s.suppressHydrationWarning===!0||Om(e.nodeValue,r)),e||Ei(n,!0)}else e=As(e).createTextNode(s),e[Bt]=n,n.stateNode=e}return Dt(n),null;case 31:if(r=n.memoizedState,e===null||e.memoizedState!==null){if(s=Ur(n),r!==null){if(e===null){if(!s)throw Error(a(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(557));e[Bt]=n}else nr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Dt(n),e=!1}else r=Po(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),e=!0;if(!e)return n.flags&256?(xn(n),n):(xn(n),null);if((n.flags&128)!==0)throw Error(a(558))}return Dt(n),null;case 13:if(s=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(d=Ur(n),s!==null&&s.dehydrated!==null){if(e===null){if(!d)throw Error(a(318));if(d=n.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(a(317));d[Bt]=n}else nr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Dt(n),d=!1}else d=Po(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=d),d=!0;if(!d)return n.flags&256?(xn(n),n):(xn(n),null)}return xn(n),(n.flags&128)!==0?(n.lanes=r,n):(r=s!==null,e=e!==null&&e.memoizedState!==null,r&&(s=n.child,d=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(d=s.alternate.memoizedState.cachePool.pool),g=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(g=s.memoizedState.cachePool.pool),g!==d&&(s.flags|=2048)),r!==e&&r&&(n.child.flags|=8192),hs(n,n.updateQueue),Dt(n),null);case 4:return F(),e===null&&oc(n.stateNode.containerInfo),Dt(n),null;case 10:return ai(n.type),Dt(n),null;case 19:if(J(qt),s=n.memoizedState,s===null)return Dt(n),null;if(d=(n.flags&128)!==0,g=s.rendering,g===null)if(d)Hl(s,!1);else{if(It!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=es(e),g!==null){for(n.flags|=128,Hl(s,!1),e=g.updateQueue,n.updateQueue=e,hs(n,e),n.subtreeFlags=0,e=r,r=n.child;r!==null;)hh(r,e),r=r.sibling;return _(qt,qt.current&1|2),at&&ri(n,s.treeForkCount),n.child}e=e.sibling}s.tail!==null&<()>bs&&(n.flags|=128,d=!0,Hl(s,!1),n.lanes=4194304)}else{if(!d)if(e=es(g),e!==null){if(n.flags|=128,d=!0,e=e.updateQueue,n.updateQueue=e,hs(n,e),Hl(s,!0),s.tail===null&&s.tailMode==="hidden"&&!g.alternate&&!at)return Dt(n),null}else 2*lt()-s.renderingStartTime>bs&&r!==536870912&&(n.flags|=128,d=!0,Hl(s,!1),n.lanes=4194304);s.isBackwards?(g.sibling=n.child,n.child=g):(e=s.last,e!==null?e.sibling=g:n.child=g,s.last=g)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=lt(),e.sibling=null,r=qt.current,_(qt,d?r&1|2:r&1),at&&ri(n,s.treeForkCount),e):(Dt(n),null);case 22:case 23:return xn(n),uu(),s=n.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(n.flags|=8192):s&&(n.flags|=8192),s?(r&536870912)!==0&&(n.flags&128)===0&&(Dt(n),n.subtreeFlags&6&&(n.flags|=8192)):Dt(n),r=n.updateQueue,r!==null&&hs(n,r.retryQueue),r=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),s=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(s=n.memoizedState.cachePool.pool),s!==r&&(n.flags|=2048),e!==null&&J(lr),null;case 24:return r=null,e!==null&&(r=e.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),ai(Yt),Dt(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function Jx(e,n){switch(Xo(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ai(Yt),F(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return Le(n),null;case 31:if(n.memoizedState!==null){if(xn(n),n.alternate===null)throw Error(a(340));nr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(xn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));nr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return J(qt),null;case 4:return F(),null;case 10:return ai(n.type),null;case 22:case 23:return xn(n),uu(),e!==null&&J(lr),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return ai(Yt),null;case 25:return null;default:return null}}function qp(e,n){switch(Xo(n),n.tag){case 3:ai(Yt),F();break;case 26:case 27:case 5:Le(n);break;case 4:F();break;case 31:n.memoizedState!==null&&xn(n);break;case 13:xn(n);break;case 19:J(qt);break;case 10:ai(n.type);break;case 22:case 23:xn(n),uu(),e!==null&&J(lr);break;case 24:ai(Yt)}}function Vl(e,n){try{var r=n.updateQueue,s=r!==null?r.lastEffect:null;if(s!==null){var d=s.next;r=d;do{if((r.tag&e)===e){s=void 0;var g=r.create,S=r.inst;s=g(),S.destroy=s}r=r.next}while(r!==d)}}catch(E){xt(n,n.return,E)}}function Di(e,n,r){try{var s=n.updateQueue,d=s!==null?s.lastEffect:null;if(d!==null){var g=d.next;s=g;do{if((s.tag&e)===e){var S=s.inst,E=S.destroy;if(E!==void 0){S.destroy=void 0,d=n;var H=r,ie=E;try{ie()}catch(fe){xt(d,H,fe)}}}s=s.next}while(s!==g)}}catch(fe){xt(n,n.return,fe)}}function Hp(e){var n=e.updateQueue;if(n!==null){var r=e.stateNode;try{zh(n,r)}catch(s){xt(e,e.return,s)}}}function Vp(e,n,r){r.props=cr(e.type,e.memoizedProps),r.state=e.memoizedState;try{r.componentWillUnmount()}catch(s){xt(e,n,s)}}function Yl(e,n){try{var r=e.ref;if(r!==null){switch(e.tag){case 26:case 27:case 5:var s=e.stateNode;break;case 30:s=e.stateNode;break;default:s=e.stateNode}typeof r=="function"?e.refCleanup=r(s):r.current=s}}catch(d){xt(e,n,d)}}function Xn(e,n){var r=e.ref,s=e.refCleanup;if(r!==null)if(typeof s=="function")try{s()}catch(d){xt(e,n,d)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(d){xt(e,n,d)}else r.current=null}function Yp(e){var n=e.type,r=e.memoizedProps,s=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":r.autoFocus&&s.focus();break e;case"img":r.src?s.src=r.src:r.srcSet&&(s.srcset=r.srcSet)}}catch(d){xt(e,e.return,d)}}function Hu(e,n,r){try{var s=e.stateNode;x0(s,e.type,r,n),s[Jt]=n}catch(d){xt(e,e.return,d)}}function Gp(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ii(e.type)||e.tag===4}function Vu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Gp(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&&Ii(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 Yu(e,n,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(e,n):(n=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,n.appendChild(e),r=r._reactRootContainer,r!=null||n.onclick!==null||(n.onclick=ti));else if(s!==4&&(s===27&&Ii(e.type)&&(r=e.stateNode,n=null),e=e.child,e!==null))for(Yu(e,n,r),e=e.sibling;e!==null;)Yu(e,n,r),e=e.sibling}function ps(e,n,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?r.insertBefore(e,n):r.appendChild(e);else if(s!==4&&(s===27&&Ii(e.type)&&(r=e.stateNode),e=e.child,e!==null))for(ps(e,n,r),e=e.sibling;e!==null;)ps(e,n,r),e=e.sibling}function Fp(e){var n=e.stateNode,r=e.memoizedProps;try{for(var s=e.type,d=n.attributes;d.length;)n.removeAttributeNode(d[0]);nn(n,s,r),n[Bt]=e,n[Jt]=r}catch(g){xt(e,e.return,g)}}var fi=!1,Qt=!1,Gu=!1,Qp=typeof WeakSet=="function"?WeakSet:Set,Pt=null;function Wx(e,n){if(e=e.containerInfo,fc=Os,e=rh(e),Bo(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var s=r.getSelection&&r.getSelection();if(s&&s.rangeCount!==0){r=s.anchorNode;var d=s.anchorOffset,g=s.focusNode;s=s.focusOffset;try{r.nodeType,g.nodeType}catch{r=null;break e}var S=0,E=-1,H=-1,ie=0,fe=0,pe=e,le=null;t:for(;;){for(var ue;pe!==r||d!==0&&pe.nodeType!==3||(E=S+d),pe!==g||s!==0&&pe.nodeType!==3||(H=S+s),pe.nodeType===3&&(S+=pe.nodeValue.length),(ue=pe.firstChild)!==null;)le=pe,pe=ue;for(;;){if(pe===e)break t;if(le===r&&++ie===d&&(E=S),le===g&&++fe===s&&(H=S),(ue=pe.nextSibling)!==null)break;pe=le,le=pe.parentNode}pe=ue}r=E===-1||H===-1?null:{start:E,end:H}}else r=null}r=r||{start:0,end:0}}else r=null;for(dc={focusedElem:e,selectionRange:r},Os=!1,Pt=n;Pt!==null;)if(n=Pt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Pt=e;else for(;Pt!==null;){switch(n=Pt,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(r=0;r<e.length;r++)d=e[r],d.ref.impl=d.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&g!==null){e=void 0,r=n,d=g.memoizedProps,g=g.memoizedState,s=r.stateNode;try{var Ne=cr(r.type,d);e=s.getSnapshotBeforeUpdate(Ne,g),s.__reactInternalSnapshotBeforeUpdate=e}catch(Ie){xt(r,r.return,Ie)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,r=e.nodeType,r===9)mc(e);else if(r===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":mc(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,Pt=e;break}Pt=n.return}}function $p(e,n,r){var s=r.flags;switch(r.tag){case 0:case 11:case 15:hi(e,r),s&4&&Vl(5,r);break;case 1:if(hi(e,r),s&4)if(e=r.stateNode,n===null)try{e.componentDidMount()}catch(S){xt(r,r.return,S)}else{var d=cr(r.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(d,n,e.__reactInternalSnapshotBeforeUpdate)}catch(S){xt(r,r.return,S)}}s&64&&Hp(r),s&512&&Yl(r,r.return);break;case 3:if(hi(e,r),s&64&&(e=r.updateQueue,e!==null)){if(n=null,r.child!==null)switch(r.child.tag){case 27:case 5:n=r.child.stateNode;break;case 1:n=r.child.stateNode}try{zh(e,n)}catch(S){xt(r,r.return,S)}}break;case 27:n===null&&s&4&&Fp(r);case 26:case 5:hi(e,r),n===null&&s&4&&Yp(r),s&512&&Yl(r,r.return);break;case 12:hi(e,r);break;case 31:hi(e,r),s&4&&Pp(e,r);break;case 13:hi(e,r),s&4&&Zp(e,r),s&64&&(e=r.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(r=o0.bind(null,r),A0(e,r))));break;case 22:if(s=r.memoizedState!==null||fi,!s){n=n!==null&&n.memoizedState!==null||Qt,d=fi;var g=Qt;fi=s,(Qt=n)&&!g?pi(e,r,(r.subtreeFlags&8772)!==0):hi(e,r),fi=d,Qt=g}break;case 30:break;default:hi(e,r)}}function Xp(e){var n=e.alternate;n!==null&&(e.alternate=null,Xp(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&xo(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 _t=null,cn=!1;function di(e,n,r){for(r=r.child;r!==null;)Kp(e,n,r),r=r.sibling}function Kp(e,n,r){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(yt,r)}catch{}switch(r.tag){case 26:Qt||Xn(r,n),di(e,n,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:Qt||Xn(r,n);var s=_t,d=cn;Ii(r.type)&&(_t=r.stateNode,cn=!1),di(e,n,r),Jl(r.stateNode),_t=s,cn=d;break;case 5:Qt||Xn(r,n);case 6:if(s=_t,d=cn,_t=null,di(e,n,r),_t=s,cn=d,_t!==null)if(cn)try{(_t.nodeType===9?_t.body:_t.nodeName==="HTML"?_t.ownerDocument.body:_t).removeChild(r.stateNode)}catch(g){xt(r,n,g)}else try{_t.removeChild(r.stateNode)}catch(g){xt(r,n,g)}break;case 18:_t!==null&&(cn?(e=_t,Hm(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,r.stateNode),ll(e)):Hm(_t,r.stateNode));break;case 4:s=_t,d=cn,_t=r.stateNode.containerInfo,cn=!0,di(e,n,r),_t=s,cn=d;break;case 0:case 11:case 14:case 15:Di(2,r,n),Qt||Di(4,r,n),di(e,n,r);break;case 1:Qt||(Xn(r,n),s=r.stateNode,typeof s.componentWillUnmount=="function"&&Vp(r,n,s)),di(e,n,r);break;case 21:di(e,n,r);break;case 22:Qt=(s=Qt)||r.memoizedState!==null,di(e,n,r),Qt=s;break;default:di(e,n,r)}}function Pp(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{ll(e)}catch(r){xt(n,n.return,r)}}}function Zp(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{ll(e)}catch(r){xt(n,n.return,r)}}function e0(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new Qp),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new Qp),n;default:throw Error(a(435,e.tag))}}function ms(e,n){var r=e0(e);n.forEach(function(s){if(!r.has(s)){r.add(s);var d=u0.bind(null,e,s);s.then(d,d)}})}function fn(e,n){var r=n.deletions;if(r!==null)for(var s=0;s<r.length;s++){var d=r[s],g=e,S=n,E=S;e:for(;E!==null;){switch(E.tag){case 27:if(Ii(E.type)){_t=E.stateNode,cn=!1;break e}break;case 5:_t=E.stateNode,cn=!1;break e;case 3:case 4:_t=E.stateNode.containerInfo,cn=!0;break e}E=E.return}if(_t===null)throw Error(a(160));Kp(g,S,d),_t=null,cn=!1,g=d.alternate,g!==null&&(g.return=null),d.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Jp(n,e),n=n.sibling}var In=null;function Jp(e,n){var r=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:fn(n,e),dn(e),s&4&&(Di(3,e,e.return),Vl(3,e),Di(5,e,e.return));break;case 1:fn(n,e),dn(e),s&512&&(Qt||r===null||Xn(r,r.return)),s&64&&fi&&(e=e.updateQueue,e!==null&&(s=e.callbacks,s!==null&&(r=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=r===null?s:r.concat(s))));break;case 26:var d=In;if(fn(n,e),dn(e),s&512&&(Qt||r===null||Xn(r,r.return)),s&4){var g=r!==null?r.memoizedState:null;if(s=e.memoizedState,r===null)if(s===null)if(e.stateNode===null){e:{s=e.type,r=e.memoizedProps,d=d.ownerDocument||d;t:switch(s){case"title":g=d.getElementsByTagName("title")[0],(!g||g[gl]||g[Bt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=d.createElement(s),d.head.insertBefore(g,d.querySelector("head > title"))),nn(g,s,r),g[Bt]=e,Kt(g),s=g;break e;case"link":var S=Jm("link","href",d).get(s+(r.href||""));if(S){for(var E=0;E<S.length;E++)if(g=S[E],g.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&g.getAttribute("rel")===(r.rel==null?null:r.rel)&&g.getAttribute("title")===(r.title==null?null:r.title)&&g.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){S.splice(E,1);break t}}g=d.createElement(s),nn(g,s,r),d.head.appendChild(g);break;case"meta":if(S=Jm("meta","content",d).get(s+(r.content||""))){for(E=0;E<S.length;E++)if(g=S[E],g.getAttribute("content")===(r.content==null?null:""+r.content)&&g.getAttribute("name")===(r.name==null?null:r.name)&&g.getAttribute("property")===(r.property==null?null:r.property)&&g.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&g.getAttribute("charset")===(r.charSet==null?null:r.charSet)){S.splice(E,1);break t}}g=d.createElement(s),nn(g,s,r),d.head.appendChild(g);break;default:throw Error(a(468,s))}g[Bt]=e,Kt(g),s=g}e.stateNode=s}else Wm(d,e.type,e.stateNode);else e.stateNode=Zm(d,s,e.memoizedProps);else g!==s?(g===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):g.count--,s===null?Wm(d,e.type,e.stateNode):Zm(d,s,e.memoizedProps)):s===null&&e.stateNode!==null&&Hu(e,e.memoizedProps,r.memoizedProps)}break;case 27:fn(n,e),dn(e),s&512&&(Qt||r===null||Xn(r,r.return)),r!==null&&s&4&&Hu(e,e.memoizedProps,r.memoizedProps);break;case 5:if(fn(n,e),dn(e),s&512&&(Qt||r===null||Xn(r,r.return)),e.flags&32){d=e.stateNode;try{Ar(d,"")}catch(Ne){xt(e,e.return,Ne)}}s&4&&e.stateNode!=null&&(d=e.memoizedProps,Hu(e,d,r!==null?r.memoizedProps:d)),s&1024&&(Gu=!0);break;case 6:if(fn(n,e),dn(e),s&4){if(e.stateNode===null)throw Error(a(162));s=e.memoizedProps,r=e.stateNode;try{r.nodeValue=s}catch(Ne){xt(e,e.return,Ne)}}break;case 3:if(zs=null,d=In,In=Ts(n.containerInfo),fn(n,e),In=d,dn(e),s&4&&r!==null&&r.memoizedState.isDehydrated)try{ll(n.containerInfo)}catch(Ne){xt(e,e.return,Ne)}Gu&&(Gu=!1,Wp(e));break;case 4:s=In,In=Ts(e.stateNode.containerInfo),fn(n,e),dn(e),In=s;break;case 12:fn(n,e),dn(e);break;case 31:fn(n,e),dn(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,ms(e,s)));break;case 13:fn(n,e),dn(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(ys=lt()),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,ms(e,s)));break;case 22:d=e.memoizedState!==null;var H=r!==null&&r.memoizedState!==null,ie=fi,fe=Qt;if(fi=ie||d,Qt=fe||H,fn(n,e),Qt=fe,fi=ie,dn(e),s&8192)e:for(n=e.stateNode,n._visibility=d?n._visibility&-2:n._visibility|1,d&&(r===null||H||fi||Qt||fr(e)),r=null,n=e;;){if(n.tag===5||n.tag===26){if(r===null){H=r=n;try{if(g=H.stateNode,d)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{E=H.stateNode;var pe=H.memoizedProps.style,le=pe!=null&&pe.hasOwnProperty("display")?pe.display:null;E.style.display=le==null||typeof le=="boolean"?"":(""+le).trim()}}catch(Ne){xt(H,H.return,Ne)}}}else if(n.tag===6){if(r===null){H=n;try{H.stateNode.nodeValue=d?"":H.memoizedProps}catch(Ne){xt(H,H.return,Ne)}}}else if(n.tag===18){if(r===null){H=n;try{var ue=H.stateNode;d?Vm(ue,!0):Vm(H.stateNode,!1)}catch(Ne){xt(H,H.return,Ne)}}}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;r===n&&(r=null),n=n.return}r===n&&(r=null),n.sibling.return=n.return,n=n.sibling}s&4&&(s=e.updateQueue,s!==null&&(r=s.retryQueue,r!==null&&(s.retryQueue=null,ms(e,r))));break;case 19:fn(n,e),dn(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,ms(e,s)));break;case 30:break;case 21:break;default:fn(n,e),dn(e)}}function dn(e){var n=e.flags;if(n&2){try{for(var r,s=e.return;s!==null;){if(Gp(s)){r=s;break}s=s.return}if(r==null)throw Error(a(160));switch(r.tag){case 27:var d=r.stateNode,g=Vu(e);ps(e,g,d);break;case 5:var S=r.stateNode;r.flags&32&&(Ar(S,""),r.flags&=-33);var E=Vu(e);ps(e,E,S);break;case 3:case 4:var H=r.stateNode.containerInfo,ie=Vu(e);Yu(e,ie,H);break;default:throw Error(a(161))}}catch(fe){xt(e,e.return,fe)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Wp(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;Wp(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function hi(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)$p(e,n.alternate,n),n=n.sibling}function fr(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Di(4,n,n.return),fr(n);break;case 1:Xn(n,n.return);var r=n.stateNode;typeof r.componentWillUnmount=="function"&&Vp(n,n.return,r),fr(n);break;case 27:Jl(n.stateNode);case 26:case 5:Xn(n,n.return),fr(n);break;case 22:n.memoizedState===null&&fr(n);break;case 30:fr(n);break;default:fr(n)}e=e.sibling}}function pi(e,n,r){for(r=r&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var s=n.alternate,d=e,g=n,S=g.flags;switch(g.tag){case 0:case 11:case 15:pi(d,g,r),Vl(4,g);break;case 1:if(pi(d,g,r),s=g,d=s.stateNode,typeof d.componentDidMount=="function")try{d.componentDidMount()}catch(ie){xt(s,s.return,ie)}if(s=g,d=s.updateQueue,d!==null){var E=s.stateNode;try{var H=d.shared.hiddenCallbacks;if(H!==null)for(d.shared.hiddenCallbacks=null,d=0;d<H.length;d++)Rh(H[d],E)}catch(ie){xt(s,s.return,ie)}}r&&S&64&&Hp(g),Yl(g,g.return);break;case 27:Fp(g);case 26:case 5:pi(d,g,r),r&&s===null&&S&4&&Yp(g),Yl(g,g.return);break;case 12:pi(d,g,r);break;case 31:pi(d,g,r),r&&S&4&&Pp(d,g);break;case 13:pi(d,g,r),r&&S&4&&Zp(d,g);break;case 22:g.memoizedState===null&&pi(d,g,r),Yl(g,g.return);break;case 30:break;default:pi(d,g,r)}n=n.sibling}}function Fu(e,n){var r=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==r&&(e!=null&&e.refCount++,r!=null&&Tl(r))}function Qu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Tl(e))}function qn(e,n,r,s){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)em(e,n,r,s),n=n.sibling}function em(e,n,r,s){var d=n.flags;switch(n.tag){case 0:case 11:case 15:qn(e,n,r,s),d&2048&&Vl(9,n);break;case 1:qn(e,n,r,s);break;case 3:qn(e,n,r,s),d&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Tl(e)));break;case 12:if(d&2048){qn(e,n,r,s),e=n.stateNode;try{var g=n.memoizedProps,S=g.id,E=g.onPostCommit;typeof E=="function"&&E(S,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(H){xt(n,n.return,H)}}else qn(e,n,r,s);break;case 31:qn(e,n,r,s);break;case 13:qn(e,n,r,s);break;case 23:break;case 22:g=n.stateNode,S=n.alternate,n.memoizedState!==null?g._visibility&2?qn(e,n,r,s):Gl(e,n):g._visibility&2?qn(e,n,r,s):(g._visibility|=2,Xr(e,n,r,s,(n.subtreeFlags&10256)!==0||!1)),d&2048&&Fu(S,n);break;case 24:qn(e,n,r,s),d&2048&&Qu(n.alternate,n);break;default:qn(e,n,r,s)}}function Xr(e,n,r,s,d){for(d=d&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,S=n,E=r,H=s,ie=S.flags;switch(S.tag){case 0:case 11:case 15:Xr(g,S,E,H,d),Vl(8,S);break;case 23:break;case 22:var fe=S.stateNode;S.memoizedState!==null?fe._visibility&2?Xr(g,S,E,H,d):Gl(g,S):(fe._visibility|=2,Xr(g,S,E,H,d)),d&&ie&2048&&Fu(S.alternate,S);break;case 24:Xr(g,S,E,H,d),d&&ie&2048&&Qu(S.alternate,S);break;default:Xr(g,S,E,H,d)}n=n.sibling}}function Gl(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var r=e,s=n,d=s.flags;switch(s.tag){case 22:Gl(r,s),d&2048&&Fu(s.alternate,s);break;case 24:Gl(r,s),d&2048&&Qu(s.alternate,s);break;default:Gl(r,s)}n=n.sibling}}var Fl=8192;function Kr(e,n,r){if(e.subtreeFlags&Fl)for(e=e.child;e!==null;)tm(e,n,r),e=e.sibling}function tm(e,n,r){switch(e.tag){case 26:Kr(e,n,r),e.flags&Fl&&e.memoizedState!==null&&q0(r,In,e.memoizedState,e.memoizedProps);break;case 5:Kr(e,n,r);break;case 3:case 4:var s=In;In=Ts(e.stateNode.containerInfo),Kr(e,n,r),In=s;break;case 22:e.memoizedState===null&&(s=e.alternate,s!==null&&s.memoizedState!==null?(s=Fl,Fl=16777216,Kr(e,n,r),Fl=s):Kr(e,n,r));break;default:Kr(e,n,r)}}function nm(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 Ql(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];Pt=s,rm(s,e)}nm(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)im(e),e=e.sibling}function im(e){switch(e.tag){case 0:case 11:case 15:Ql(e),e.flags&2048&&Di(9,e,e.return);break;case 3:Ql(e);break;case 12:Ql(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,gs(e)):Ql(e);break;default:Ql(e)}}function gs(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];Pt=s,rm(s,e)}nm(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Di(8,n,n.return),gs(n);break;case 22:r=n.stateNode,r._visibility&2&&(r._visibility&=-3,gs(n));break;default:gs(n)}e=e.sibling}}function rm(e,n){for(;Pt!==null;){var r=Pt;switch(r.tag){case 0:case 11:case 15:Di(8,r,n);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var s=r.memoizedState.cachePool.pool;s!=null&&s.refCount++}break;case 24:Tl(r.memoizedState.cache)}if(s=r.child,s!==null)s.return=r,Pt=s;else e:for(r=e;Pt!==null;){s=Pt;var d=s.sibling,g=s.return;if(Xp(s),s===r){Pt=null;break e}if(d!==null){d.return=g,Pt=d;break e}Pt=g}}}var t0={getCacheForType:function(e){var n=en(Yt),r=n.data.get(e);return r===void 0&&(r=e(),n.data.set(e,r)),r},cacheSignal:function(){return en(Yt).controller.signal}},n0=typeof WeakMap=="function"?WeakMap:Map,gt=0,Nt=null,Je=null,it=0,vt=0,Sn=null,_i=!1,Pr=!1,$u=!1,mi=0,It=0,Mi=0,dr=0,Xu=0,wn=0,Zr=0,$l=null,hn=null,Ku=!1,ys=0,lm=0,bs=1/0,vs=null,Oi=null,Xt=0,Li=null,Jr=null,gi=0,Pu=0,Zu=null,am=null,Xl=0,Ju=null;function jn(){return(gt&2)!==0&&it!==0?it&-it:z.T!==null?rc():Ta()}function sm(){if(wn===0)if((it&536870912)===0||at){var e=ze;ze<<=1,(ze&3932160)===0&&(ze=262144),wn=e}else wn=536870912;return e=vn.current,e!==null&&(e.flags|=32),wn}function pn(e,n,r){(e===Nt&&(vt===2||vt===9)||e.cancelPendingCommit!==null)&&(Wr(e,0),Bi(e,it,wn,!1)),Ke(e,r),((gt&2)===0||e!==Nt)&&(e===Nt&&((gt&2)===0&&(dr|=r),It===4&&Bi(e,it,wn,!1)),Kn(e))}function om(e,n,r){if((gt&6)!==0)throw Error(a(327));var s=!r&&(n&127)===0&&(n&e.expiredLanes)===0||ke(e,n),d=s?l0(e,n):ec(e,n,!0),g=s;do{if(d===0){Pr&&!s&&Bi(e,n,0,!1);break}else{if(r=e.current.alternate,g&&!i0(r)){d=ec(e,n,!1),g=!1;continue}if(d===2){if(g=n,e.errorRecoveryDisabledLanes&g)var S=0;else S=e.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){n=S;e:{var E=e;d=$l;var H=E.current.memoizedState.isDehydrated;if(H&&(Wr(E,S).flags|=256),S=ec(E,S,!1),S!==2){if($u&&!H){E.errorRecoveryDisabledLanes|=g,dr|=g,d=4;break e}g=hn,hn=d,g!==null&&(hn===null?hn=g:hn.push.apply(hn,g))}d=S}if(g=!1,d!==2)continue}}if(d===1){Wr(e,0),Bi(e,n,0,!0);break}e:{switch(s=e,g=d,g){case 0:case 1:throw Error(a(345));case 4:if((n&4194048)!==n)break;case 6:Bi(s,n,wn,!_i);break e;case 2:hn=null;break;case 3:case 5:break;default:throw Error(a(329))}if((n&62914560)===n&&(d=ys+300-lt(),10<d)){if(Bi(s,n,wn,!_i),Be(s,0,!0)!==0)break e;gi=n,s.timeoutHandle=Im(um.bind(null,s,r,hn,vs,Ku,n,wn,dr,Zr,_i,g,"Throttled",-0,0),d);break e}um(s,r,hn,vs,Ku,n,wn,dr,Zr,_i,g,null,-0,0)}}break}while(!0);Kn(e)}function um(e,n,r,s,d,g,S,E,H,ie,fe,pe,le,ue){if(e.timeoutHandle=-1,pe=n.subtreeFlags,pe&8192||(pe&16785408)===16785408){pe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ti},tm(n,g,pe);var Ne=(g&62914560)===g?ys-lt():(g&4194048)===g?lm-lt():0;if(Ne=H0(pe,Ne),Ne!==null){gi=g,e.cancelPendingCommit=Ne(ym.bind(null,e,n,g,r,s,d,S,E,H,fe,pe,null,le,ue)),Bi(e,g,S,!ie);return}}ym(e,n,g,r,s,d,S,E,H)}function i0(e){for(var n=e;;){var r=n.tag;if((r===0||r===11||r===15)&&n.flags&16384&&(r=n.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var s=0;s<r.length;s++){var d=r[s],g=d.getSnapshot;d=d.value;try{if(!yn(g(),d))return!1}catch{return!1}}if(r=n.child,n.subtreeFlags&16384&&r!==null)r.return=n,n=r;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 Bi(e,n,r,s){n&=~Xu,n&=~dr,e.suspendedLanes|=n,e.pingedLanes&=~n,s&&(e.warmLanes|=n),s=e.expirationTimes;for(var d=n;0<d;){var g=31-Ze(d),S=1<<g;s[g]=-1,d&=~S}r!==0&&Rt(e,r,n)}function xs(){return(gt&6)===0?(Kl(0),!1):!0}function Wu(){if(Je!==null){if(vt===0)var e=Je.return;else e=Je,li=ir=null,mu(e),Yr=null,zl=0,e=Je;for(;e!==null;)qp(e.alternate,e),e=e.return;Je=null}}function Wr(e,n){var r=e.timeoutHandle;r!==-1&&(e.timeoutHandle=-1,j0(r)),r=e.cancelPendingCommit,r!==null&&(e.cancelPendingCommit=null,r()),gi=0,Wu(),Nt=e,Je=r=ii(e.current,null),it=n,vt=0,Sn=null,_i=!1,Pr=ke(e,n),$u=!1,Zr=wn=Xu=dr=Mi=It=0,hn=$l=null,Ku=!1,(n&8)!==0&&(n|=n&32);var s=e.entangledLanes;if(s!==0)for(e=e.entanglements,s&=n;0<s;){var d=31-Ze(s),g=1<<d;n|=e[d],s&=~g}return mi=n,Ha(),r}function cm(e,n){$e=null,z.H=Il,n===Vr||n===Ka?(n=Ch(),vt=3):n===iu?(n=Ch(),vt=4):vt=n===zu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Sn=n,Je===null&&(It=1,us(e,Rn(n,e.current)))}function fm(){var e=vn.current;return e===null?!0:(it&4194048)===it?Mn===null:(it&62914560)===it||(it&536870912)!==0?e===Mn:!1}function dm(){var e=z.H;return z.H=Il,e===null?Il:e}function hm(){var e=z.A;return z.A=t0,e}function Ss(){It=4,_i||(it&4194048)!==it&&vn.current!==null||(Pr=!0),(Mi&134217727)===0&&(dr&134217727)===0||Nt===null||Bi(Nt,it,wn,!1)}function ec(e,n,r){var s=gt;gt|=2;var d=dm(),g=hm();(Nt!==e||it!==n)&&(vs=null,Wr(e,n)),n=!1;var S=It;e:do try{if(vt!==0&&Je!==null){var E=Je,H=Sn;switch(vt){case 8:Wu(),S=6;break e;case 3:case 2:case 9:case 6:vn.current===null&&(n=!0);var ie=vt;if(vt=0,Sn=null,el(e,E,H,ie),r&&Pr){S=0;break e}break;default:ie=vt,vt=0,Sn=null,el(e,E,H,ie)}}r0(),S=It;break}catch(fe){cm(e,fe)}while(!0);return n&&e.shellSuspendCounter++,li=ir=null,gt=s,z.H=d,z.A=g,Je===null&&(Nt=null,it=0,Ha()),S}function r0(){for(;Je!==null;)pm(Je)}function l0(e,n){var r=gt;gt|=2;var s=dm(),d=hm();Nt!==e||it!==n?(vs=null,bs=lt()+500,Wr(e,n)):Pr=ke(e,n);e:do try{if(vt!==0&&Je!==null){n=Je;var g=Sn;t:switch(vt){case 1:vt=0,Sn=null,el(e,n,g,1);break;case 2:case 9:if(kh(g)){vt=0,Sn=null,mm(n);break}n=function(){vt!==2&&vt!==9||Nt!==e||(vt=7),Kn(e)},g.then(n,n);break e;case 3:vt=7;break e;case 4:vt=5;break e;case 7:kh(g)?(vt=0,Sn=null,mm(n)):(vt=0,Sn=null,el(e,n,g,7));break;case 5:var S=null;switch(Je.tag){case 26:S=Je.memoizedState;case 5:case 27:var E=Je;if(S?eg(S):E.stateNode.complete){vt=0,Sn=null;var H=E.sibling;if(H!==null)Je=H;else{var ie=E.return;ie!==null?(Je=ie,ws(ie)):Je=null}break t}}vt=0,Sn=null,el(e,n,g,5);break;case 6:vt=0,Sn=null,el(e,n,g,6);break;case 8:Wu(),It=6;break e;default:throw Error(a(462))}}a0();break}catch(fe){cm(e,fe)}while(!0);return li=ir=null,z.H=s,z.A=d,gt=r,Je!==null?0:(Nt=null,it=0,Ha(),It)}function a0(){for(;Je!==null&&!nt();)pm(Je)}function pm(e){var n=Up(e.alternate,e,mi);e.memoizedProps=e.pendingProps,n===null?ws(e):Je=n}function mm(e){var n=e,r=n.alternate;switch(n.tag){case 15:case 0:n=Dp(r,n,n.pendingProps,n.type,void 0,it);break;case 11:n=Dp(r,n,n.pendingProps,n.type.render,n.ref,it);break;case 5:mu(n);default:qp(r,n),n=Je=hh(n,mi),n=Up(r,n,mi)}e.memoizedProps=e.pendingProps,n===null?ws(e):Je=n}function el(e,n,r,s){li=ir=null,mu(n),Yr=null,zl=0;var d=n.return;try{if(Xx(e,d,n,r,it)){It=1,us(e,Rn(r,e.current)),Je=null;return}}catch(g){if(d!==null)throw Je=d,g;It=1,us(e,Rn(r,e.current)),Je=null;return}n.flags&32768?(at||s===1?e=!0:Pr||(it&536870912)!==0?e=!1:(_i=e=!0,(s===2||s===9||s===3||s===6)&&(s=vn.current,s!==null&&s.tag===13&&(s.flags|=16384))),gm(n,e)):ws(n)}function ws(e){var n=e;do{if((n.flags&32768)!==0){gm(n,_i);return}e=n.return;var r=Zx(n.alternate,n,mi);if(r!==null){Je=r;return}if(n=n.sibling,n!==null){Je=n;return}Je=n=e}while(n!==null);It===0&&(It=5)}function gm(e,n){do{var r=Jx(e.alternate,e);if(r!==null){r.flags&=32767,Je=r;return}if(r=e.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!n&&(e=e.sibling,e!==null)){Je=e;return}Je=e=r}while(e!==null);It=6,Je=null}function ym(e,n,r,s,d,g,S,E,H){e.cancelPendingCommit=null;do js();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|=Vo,st(e,r,g,S,E,H),e===Nt&&(Je=Nt=null,it=0),Jr=n,Li=e,gi=r,Pu=g,Zu=d,am=s,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,c0(ge,function(){return wm(),null})):(e.callbackNode=null,e.callbackPriority=0),s=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||s){s=z.T,z.T=null,d=Z.p,Z.p=2,S=gt,gt|=4;try{Wx(e,n,r)}finally{gt=S,Z.p=d,z.T=s}}Xt=1,bm(),vm(),xm()}}function bm(){if(Xt===1){Xt=0;var e=Li,n=Jr,r=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||r){r=z.T,z.T=null;var s=Z.p;Z.p=2;var d=gt;gt|=4;try{Jp(n,e);var g=dc,S=rh(e.containerInfo),E=g.focusedElem,H=g.selectionRange;if(S!==E&&E&&E.ownerDocument&&ih(E.ownerDocument.documentElement,E)){if(H!==null&&Bo(E)){var ie=H.start,fe=H.end;if(fe===void 0&&(fe=ie),"selectionStart"in E)E.selectionStart=ie,E.selectionEnd=Math.min(fe,E.value.length);else{var pe=E.ownerDocument||document,le=pe&&pe.defaultView||window;if(le.getSelection){var ue=le.getSelection(),Ne=E.textContent.length,Ie=Math.min(H.start,Ne),kt=H.end===void 0?Ie:Math.min(H.end,Ne);!ue.extend&&Ie>kt&&(S=kt,kt=Ie,Ie=S);var X=nh(E,Ie),G=nh(E,kt);if(X&&G&&(ue.rangeCount!==1||ue.anchorNode!==X.node||ue.anchorOffset!==X.offset||ue.focusNode!==G.node||ue.focusOffset!==G.offset)){var ne=pe.createRange();ne.setStart(X.node,X.offset),ue.removeAllRanges(),Ie>kt?(ue.addRange(ne),ue.extend(G.node,G.offset)):(ne.setEnd(G.node,G.offset),ue.addRange(ne))}}}}for(pe=[],ue=E;ue=ue.parentNode;)ue.nodeType===1&&pe.push({element:ue,left:ue.scrollLeft,top:ue.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<pe.length;E++){var de=pe[E];de.element.scrollLeft=de.left,de.element.scrollTop=de.top}}Os=!!fc,dc=fc=null}finally{gt=d,Z.p=s,z.T=r}}e.current=n,Xt=2}}function vm(){if(Xt===2){Xt=0;var e=Li,n=Jr,r=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||r){r=z.T,z.T=null;var s=Z.p;Z.p=2;var d=gt;gt|=4;try{$p(e,n.alternate,n)}finally{gt=d,Z.p=s,z.T=r}}Xt=3}}function xm(){if(Xt===4||Xt===3){Xt=0,Et();var e=Li,n=Jr,r=gi,s=am;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Xt=5:(Xt=0,Jr=Li=null,Sm(e,e.pendingLanes));var d=e.pendingLanes;if(d===0&&(Oi=null),wr(r),n=n.stateNode,pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(yt,n,void 0,(n.current.flags&128)===128)}catch{}if(s!==null){n=z.T,d=Z.p,Z.p=2,z.T=null;try{for(var g=e.onRecoverableError,S=0;S<s.length;S++){var E=s[S];g(E.value,{componentStack:E.stack})}}finally{z.T=n,Z.p=d}}(gi&3)!==0&&js(),Kn(e),d=e.pendingLanes,(r&261930)!==0&&(d&42)!==0?e===Ju?Xl++:(Xl=0,Ju=e):Xl=0,Kl(0)}}function Sm(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,Tl(n)))}function js(){return bm(),vm(),xm(),wm()}function wm(){if(Xt!==5)return!1;var e=Li,n=Pu;Pu=0;var r=wr(gi),s=z.T,d=Z.p;try{Z.p=32>r?32:r,z.T=null,r=Zu,Zu=null;var g=Li,S=gi;if(Xt=0,Jr=Li=null,gi=0,(gt&6)!==0)throw Error(a(331));var E=gt;if(gt|=4,im(g.current),em(g,g.current,S,r),gt=E,Kl(0,!1),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(yt,g)}catch{}return!0}finally{Z.p=d,z.T=s,Sm(e,n)}}function jm(e,n,r){n=Rn(r,n),n=Ru(e.stateNode,n,2),e=Ti(e,n,2),e!==null&&(Ke(e,2),Kn(e))}function xt(e,n,r){if(e.tag===3)jm(e,e,r);else for(;n!==null;){if(n.tag===3){jm(n,e,r);break}else if(n.tag===1){var s=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(Oi===null||!Oi.has(s))){e=Rn(r,e),r=kp(2),s=Ti(n,r,2),s!==null&&(Ep(r,s,n,e),Ke(s,2),Kn(s));break}}n=n.return}}function tc(e,n,r){var s=e.pingCache;if(s===null){s=e.pingCache=new n0;var d=new Set;s.set(n,d)}else d=s.get(n),d===void 0&&(d=new Set,s.set(n,d));d.has(r)||($u=!0,d.add(r),e=s0.bind(null,e,n,r),n.then(e,e))}function s0(e,n,r){var s=e.pingCache;s!==null&&s.delete(n),e.pingedLanes|=e.suspendedLanes&r,e.warmLanes&=~r,Nt===e&&(it&r)===r&&(It===4||It===3&&(it&62914560)===it&&300>lt()-ys?(gt&2)===0&&Wr(e,0):Xu|=r,Zr===it&&(Zr=0)),Kn(e)}function km(e,n){n===0&&(n=ce()),e=er(e,n),e!==null&&(Ke(e,n),Kn(e))}function o0(e){var n=e.memoizedState,r=0;n!==null&&(r=n.retryLane),km(e,r)}function u0(e,n){var r=0;switch(e.tag){case 31:case 13:var s=e.stateNode,d=e.memoizedState;d!==null&&(r=d.retryLane);break;case 19:s=e.stateNode;break;case 22:s=e.stateNode._retryCache;break;default:throw Error(a(314))}s!==null&&s.delete(n),km(e,r)}function c0(e,n){return ht(e,n)}var ks=null,tl=null,nc=!1,Es=!1,ic=!1,Ui=0;function Kn(e){e!==tl&&e.next===null&&(tl===null?ks=tl=e:tl=tl.next=e),Es=!0,nc||(nc=!0,d0())}function Kl(e,n){if(!ic&&Es){ic=!0;do for(var r=!1,s=ks;s!==null;){if(e!==0){var d=s.pendingLanes;if(d===0)var g=0;else{var S=s.suspendedLanes,E=s.pingedLanes;g=(1<<31-Ze(42|e)+1)-1,g&=d&~(S&~E),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(r=!0,Am(s,g))}else g=it,g=Be(s,s===Nt?g:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(g&3)===0||ke(s,g)||(r=!0,Am(s,g));s=s.next}while(r);ic=!1}}function f0(){Em()}function Em(){Es=nc=!1;var e=0;Ui!==0&&w0()&&(e=Ui);for(var n=lt(),r=null,s=ks;s!==null;){var d=s.next,g=Cm(s,n);g===0?(s.next=null,r===null?ks=d:r.next=d,d===null&&(tl=r)):(r=s,(e!==0||(g&3)!==0)&&(Es=!0)),s=d}Xt!==0&&Xt!==5||Kl(e),Ui!==0&&(Ui=0)}function Cm(e,n){for(var r=e.suspendedLanes,s=e.pingedLanes,d=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var S=31-Ze(g),E=1<<S,H=d[S];H===-1?((E&r)===0||(E&s)!==0)&&(d[S]=q(E,n)):H<=n&&(e.expiredLanes|=E),g&=~E}if(n=Nt,r=it,r=Be(e,e===n?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s=e.callbackNode,r===0||e===n&&(vt===2||vt===9)||e.cancelPendingCommit!==null)return s!==null&&s!==null&&Fe(s),e.callbackNode=null,e.callbackPriority=0;if((r&3)===0||ke(e,r)){if(n=r&-r,n===e.callbackPriority)return n;switch(s!==null&&Fe(s),wr(r)){case 2:case 8:r=P;break;case 32:r=ge;break;case 268435456:r=Ce;break;default:r=ge}return s=Nm.bind(null,e),r=ht(r,s),e.callbackPriority=n,e.callbackNode=r,n}return s!==null&&s!==null&&Fe(s),e.callbackPriority=2,e.callbackNode=null,2}function Nm(e,n){if(Xt!==0&&Xt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var r=e.callbackNode;if(js()&&e.callbackNode!==r)return null;var s=it;return s=Be(e,e===Nt?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s===0?null:(om(e,s,n),Cm(e,lt()),e.callbackNode!=null&&e.callbackNode===r?Nm.bind(null,e):null)}function Am(e,n){if(js())return null;om(e,n,!0)}function d0(){k0(function(){(gt&6)!==0?ht(M,f0):Em()})}function rc(){if(Ui===0){var e=qr;e===0&&(e=Me,Me<<=1,(Me&261888)===0&&(Me=256)),Ui=e}return Ui}function Tm(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:_a(""+e)}function Rm(e,n){var r=n.ownerDocument.createElement("input");return r.name=n.name,r.value=n.value,e.id&&r.setAttribute("form",e.id),n.parentNode.insertBefore(r,n),e=new FormData(e),r.parentNode.removeChild(r),e}function h0(e,n,r,s,d){if(n==="submit"&&r&&r.stateNode===d){var g=Tm((d[Jt]||null).action),S=s.submitter;S&&(n=(n=S[Jt]||null)?Tm(n.formAction):S.getAttribute("formAction"),n!==null&&(g=n,S=null));var E=new Ba("action","action",null,s,d);e.push({event:E,listeners:[{instance:null,listener:function(){if(s.defaultPrevented){if(Ui!==0){var H=S?Rm(d,S):new FormData(d);ku(r,{pending:!0,data:H,method:d.method,action:g},null,H)}}else typeof g=="function"&&(E.preventDefault(),H=S?Rm(d,S):new FormData(d),ku(r,{pending:!0,data:H,method:d.method,action:g},g,H))},currentTarget:d}]})}}for(var lc=0;lc<Ho.length;lc++){var ac=Ho[lc],p0=ac.toLowerCase(),m0=ac[0].toUpperCase()+ac.slice(1);Un(p0,"on"+m0)}Un(sh,"onAnimationEnd"),Un(oh,"onAnimationIteration"),Un(uh,"onAnimationStart"),Un("dblclick","onDoubleClick"),Un("focusin","onFocus"),Un("focusout","onBlur"),Un(zx,"onTransitionRun"),Un(Dx,"onTransitionStart"),Un(_x,"onTransitionCancel"),Un(ch,"onTransitionEnd"),Cr("onMouseEnter",["mouseout","mouseover"]),Cr("onMouseLeave",["mouseout","mouseover"]),Cr("onPointerEnter",["pointerout","pointerover"]),Cr("onPointerLeave",["pointerout","pointerover"]),Pi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Pi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Pi("onBeforeInput",["compositionend","keypress","textInput","paste"]),Pi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Pi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Pi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Pl="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(Pl));function zm(e,n){n=(n&4)!==0;for(var r=0;r<e.length;r++){var s=e[r],d=s.event;s=s.listeners;e:{var g=void 0;if(n)for(var S=s.length-1;0<=S;S--){var E=s[S],H=E.instance,ie=E.currentTarget;if(E=E.listener,H!==g&&d.isPropagationStopped())break e;g=E,d.currentTarget=ie;try{g(d)}catch(fe){qa(fe)}d.currentTarget=null,g=H}else for(S=0;S<s.length;S++){if(E=s[S],H=E.instance,ie=E.currentTarget,E=E.listener,H!==g&&d.isPropagationStopped())break e;g=E,d.currentTarget=ie;try{g(d)}catch(fe){qa(fe)}d.currentTarget=null,g=H}}}}function We(e,n){var r=n[Fn];r===void 0&&(r=n[Fn]=new Set);var s=e+"__bubble";r.has(s)||(Dm(n,e,2,!1),r.add(s))}function sc(e,n,r){var s=0;n&&(s|=4),Dm(r,e,s,n)}var Cs="_reactListening"+Math.random().toString(36).slice(2);function oc(e){if(!e[Cs]){e[Cs]=!0,Ed.forEach(function(r){r!=="selectionchange"&&(g0.has(r)||sc(r,!1,e),sc(r,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[Cs]||(n[Cs]=!0,sc("selectionchange",!1,n))}}function Dm(e,n,r,s){switch(sg(n)){case 2:var d=G0;break;case 8:d=F0;break;default:d=jc}r=d.bind(null,n,r,e),d=void 0,!Ao||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(d=!0),s?d!==void 0?e.addEventListener(n,r,{capture:!0,passive:d}):e.addEventListener(n,r,!0):d!==void 0?e.addEventListener(n,r,{passive:d}):e.addEventListener(n,r,!1)}function uc(e,n,r,s,d){var g=s;if((n&1)===0&&(n&2)===0&&s!==null)e:for(;;){if(s===null)return;var S=s.tag;if(S===3||S===4){var E=s.stateNode.containerInfo;if(E===d)break;if(S===4)for(S=s.return;S!==null;){var H=S.tag;if((H===3||H===4)&&S.stateNode.containerInfo===d)return;S=S.return}for(;E!==null;){if(S=jr(E),S===null)return;if(H=S.tag,H===5||H===6||H===26||H===27){s=g=S;continue e}E=E.parentNode}}s=s.return}Bd(function(){var ie=g,fe=Co(r),pe=[];e:{var le=fh.get(e);if(le!==void 0){var ue=Ba,Ne=e;switch(e){case"keypress":if(Oa(r)===0)break e;case"keydown":case"keyup":ue=ux;break;case"focusin":Ne="focus",ue=Do;break;case"focusout":Ne="blur",ue=Do;break;case"beforeblur":case"afterblur":ue=Do;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ue=qd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ue=Zv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ue=dx;break;case sh:case oh:case uh:ue=ex;break;case ch:ue=px;break;case"scroll":case"scrollend":ue=Kv;break;case"wheel":ue=gx;break;case"copy":case"cut":case"paste":ue=nx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ue=Vd;break;case"toggle":case"beforetoggle":ue=bx}var Ie=(n&4)!==0,kt=!Ie&&(e==="scroll"||e==="scrollend"),X=Ie?le!==null?le+"Capture":null:le;Ie=[];for(var G=ie,ne;G!==null;){var de=G;if(ne=de.stateNode,de=de.tag,de!==5&&de!==26&&de!==27||ne===null||X===null||(de=bl(G,X),de!=null&&Ie.push(Zl(G,de,ne))),kt)break;G=G.return}0<Ie.length&&(le=new ue(le,Ne,null,r,fe),pe.push({event:le,listeners:Ie}))}}if((n&7)===0){e:{if(le=e==="mouseover"||e==="pointerover",ue=e==="mouseout"||e==="pointerout",le&&r!==Eo&&(Ne=r.relatedTarget||r.fromElement)&&(jr(Ne)||Ne[Gn]))break e;if((ue||le)&&(le=fe.window===fe?fe:(le=fe.ownerDocument)?le.defaultView||le.parentWindow:window,ue?(Ne=r.relatedTarget||r.toElement,ue=ie,Ne=Ne?jr(Ne):null,Ne!==null&&(kt=f(Ne),Ie=Ne.tag,Ne!==kt||Ie!==5&&Ie!==27&&Ie!==6)&&(Ne=null)):(ue=null,Ne=ie),ue!==Ne)){if(Ie=qd,de="onMouseLeave",X="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(Ie=Vd,de="onPointerLeave",X="onPointerEnter",G="pointer"),kt=ue==null?le:yl(ue),ne=Ne==null?le:yl(Ne),le=new Ie(de,G+"leave",ue,r,fe),le.target=kt,le.relatedTarget=ne,de=null,jr(fe)===ie&&(Ie=new Ie(X,G+"enter",Ne,r,fe),Ie.target=ne,Ie.relatedTarget=kt,de=Ie),kt=de,ue&&Ne)t:{for(Ie=y0,X=ue,G=Ne,ne=0,de=X;de;de=Ie(de))ne++;de=0;for(var Oe=G;Oe;Oe=Ie(Oe))de++;for(;0<ne-de;)X=Ie(X),ne--;for(;0<de-ne;)G=Ie(G),de--;for(;ne--;){if(X===G||G!==null&&X===G.alternate){Ie=X;break t}X=Ie(X),G=Ie(G)}Ie=null}else Ie=null;ue!==null&&_m(pe,le,ue,Ie,!1),Ne!==null&&kt!==null&&_m(pe,kt,Ne,Ie,!0)}}e:{if(le=ie?yl(ie):window,ue=le.nodeName&&le.nodeName.toLowerCase(),ue==="select"||ue==="input"&&le.type==="file")var ft=Pd;else if(Xd(le))if(Zd)ft=Ax;else{ft=Cx;var De=Ex}else ue=le.nodeName,!ue||ue.toLowerCase()!=="input"||le.type!=="checkbox"&&le.type!=="radio"?ie&&ko(ie.elementType)&&(ft=Pd):ft=Nx;if(ft&&(ft=ft(e,ie))){Kd(pe,ft,r,fe);break e}De&&De(e,le,ie),e==="focusout"&&ie&&le.type==="number"&&ie.memoizedProps.value!=null&&jo(le,"number",le.value)}switch(De=ie?yl(ie):window,e){case"focusin":(Xd(De)||De.contentEditable==="true")&&(Dr=De,Uo=ie,Cl=null);break;case"focusout":Cl=Uo=Dr=null;break;case"mousedown":Io=!0;break;case"contextmenu":case"mouseup":case"dragend":Io=!1,lh(pe,r,fe);break;case"selectionchange":if(Rx)break;case"keydown":case"keyup":lh(pe,r,fe)}var Xe;if(Mo)e:{switch(e){case"compositionstart":var rt="onCompositionStart";break e;case"compositionend":rt="onCompositionEnd";break e;case"compositionupdate":rt="onCompositionUpdate";break e}rt=void 0}else zr?Qd(e,r)&&(rt="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&(rt="onCompositionStart");rt&&(Yd&&r.locale!=="ko"&&(zr||rt!=="onCompositionStart"?rt==="onCompositionEnd"&&zr&&(Xe=Ud()):(wi=fe,To="value"in wi?wi.value:wi.textContent,zr=!0)),De=Ns(ie,rt),0<De.length&&(rt=new Hd(rt,e,null,r,fe),pe.push({event:rt,listeners:De}),Xe?rt.data=Xe:(Xe=$d(r),Xe!==null&&(rt.data=Xe)))),(Xe=xx?Sx(e,r):wx(e,r))&&(rt=Ns(ie,"onBeforeInput"),0<rt.length&&(De=new Hd("onBeforeInput","beforeinput",null,r,fe),pe.push({event:De,listeners:rt}),De.data=Xe)),h0(pe,e,ie,r,fe)}zm(pe,n)})}function Zl(e,n,r){return{instance:e,listener:n,currentTarget:r}}function Ns(e,n){for(var r=n+"Capture",s=[];e!==null;){var d=e,g=d.stateNode;if(d=d.tag,d!==5&&d!==26&&d!==27||g===null||(d=bl(e,r),d!=null&&s.unshift(Zl(e,d,g)),d=bl(e,n),d!=null&&s.push(Zl(e,d,g))),e.tag===3)return s;e=e.return}return[]}function y0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function _m(e,n,r,s,d){for(var g=n._reactName,S=[];r!==null&&r!==s;){var E=r,H=E.alternate,ie=E.stateNode;if(E=E.tag,H!==null&&H===s)break;E!==5&&E!==26&&E!==27||ie===null||(H=ie,d?(ie=bl(r,g),ie!=null&&S.unshift(Zl(r,ie,H))):d||(ie=bl(r,g),ie!=null&&S.push(Zl(r,ie,H)))),r=r.return}S.length!==0&&e.push({event:n,listeners:S})}var b0=/\r\n?/g,v0=/\u0000|\uFFFD/g;function Mm(e){return(typeof e=="string"?e:""+e).replace(b0,`
|
|
9
|
-
`).replace(v0,"")}function Om(e,n){return n=Mm(n),Mm(e)===n}function jt(e,n,r,s,d,g){switch(r){case"children":typeof s=="string"?n==="body"||n==="textarea"&&s===""||Ar(e,s):(typeof s=="number"||typeof s=="bigint")&&n!=="body"&&Ar(e,""+s);break;case"className":za(e,"class",s);break;case"tabIndex":za(e,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":za(e,r,s);break;case"style":Od(e,s,g);break;case"data":if(n!=="object"){za(e,"data",s);break}case"src":case"href":if(s===""&&(n!=="a"||r!=="href")){e.removeAttribute(r);break}if(s==null||typeof s=="function"||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(r);break}s=_a(""+s),e.setAttribute(r,s);break;case"action":case"formAction":if(typeof s=="function"){e.setAttribute(r,"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"&&(r==="formAction"?(n!=="input"&&jt(e,n,"name",d.name,d,null),jt(e,n,"formEncType",d.formEncType,d,null),jt(e,n,"formMethod",d.formMethod,d,null),jt(e,n,"formTarget",d.formTarget,d,null)):(jt(e,n,"encType",d.encType,d,null),jt(e,n,"method",d.method,d,null),jt(e,n,"target",d.target,d,null)));if(s==null||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(r);break}s=_a(""+s),e.setAttribute(r,s);break;case"onClick":s!=null&&(e.onclick=ti);break;case"onScroll":s!=null&&We("scroll",e);break;case"onScrollEnd":s!=null&&We("scrollend",e);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(a(61));if(r=s.__html,r!=null){if(d.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"multiple":e.multiple=s&&typeof s!="function"&&typeof s!="symbol";break;case"muted":e.muted=s&&typeof s!="function"&&typeof s!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(s==null||typeof s=="function"||typeof s=="boolean"||typeof s=="symbol"){e.removeAttribute("xlink:href");break}r=_a(""+s),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(r,""+s):e.removeAttribute(r);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":s&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(r,""):e.removeAttribute(r);break;case"capture":case"download":s===!0?e.setAttribute(r,""):s!==!1&&s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(r,s):e.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":s!=null&&typeof s!="function"&&typeof s!="symbol"&&!isNaN(s)&&1<=s?e.setAttribute(r,s):e.removeAttribute(r);break;case"rowSpan":case"start":s==null||typeof s=="function"||typeof s=="symbol"||isNaN(s)?e.removeAttribute(r):e.setAttribute(r,s);break;case"popover":We("beforetoggle",e),We("toggle",e),Ra(e,"popover",s);break;case"xlinkActuate":ei(e,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":ei(e,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":ei(e,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":ei(e,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":ei(e,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":ei(e,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":ei(e,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":ei(e,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":ei(e,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":Ra(e,"is",s);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=$v.get(r)||r,Ra(e,r,s))}}function cc(e,n,r,s,d,g){switch(r){case"style":Od(e,s,g);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(a(61));if(r=s.__html,r!=null){if(d.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"children":typeof s=="string"?Ar(e,s):(typeof s=="number"||typeof s=="bigint")&&Ar(e,""+s);break;case"onScroll":s!=null&&We("scroll",e);break;case"onScrollEnd":s!=null&&We("scrollend",e);break;case"onClick":s!=null&&(e.onclick=ti);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Cd.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(d=r.endsWith("Capture"),n=r.slice(2,d?r.length-7:void 0),g=e[Jt]||null,g=g!=null?g[r]:null,typeof g=="function"&&e.removeEventListener(n,g,d),typeof s=="function")){typeof g!="function"&&g!==null&&(r in e?e[r]=null:e.hasAttribute(r)&&e.removeAttribute(r)),e.addEventListener(n,s,d);break e}r in e?e[r]=s:s===!0?e.setAttribute(r,""):Ra(e,r,s)}}}function nn(e,n,r){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 s=!1,d=!1,g;for(g in r)if(r.hasOwnProperty(g)){var S=r[g];if(S!=null)switch(g){case"src":s=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:jt(e,n,g,S,r,null)}}d&&jt(e,n,"srcSet",r.srcSet,r,null),s&&jt(e,n,"src",r.src,r,null);return;case"input":We("invalid",e);var E=g=S=d=null,H=null,ie=null;for(s in r)if(r.hasOwnProperty(s)){var fe=r[s];if(fe!=null)switch(s){case"name":d=fe;break;case"type":S=fe;break;case"checked":H=fe;break;case"defaultChecked":ie=fe;break;case"value":g=fe;break;case"defaultValue":E=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(a(137,n));break;default:jt(e,n,s,fe,r,null)}}zd(e,g,E,H,ie,S,d,!1);return;case"select":We("invalid",e),s=S=g=null;for(d in r)if(r.hasOwnProperty(d)&&(E=r[d],E!=null))switch(d){case"value":g=E;break;case"defaultValue":S=E;break;case"multiple":s=E;default:jt(e,n,d,E,r,null)}n=g,r=S,e.multiple=!!s,n!=null?Nr(e,!!s,n,!1):r!=null&&Nr(e,!!s,r,!0);return;case"textarea":We("invalid",e),g=d=s=null;for(S in r)if(r.hasOwnProperty(S)&&(E=r[S],E!=null))switch(S){case"value":s=E;break;case"defaultValue":d=E;break;case"children":g=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(a(91));break;default:jt(e,n,S,E,r,null)}_d(e,s,d,g);return;case"option":for(H in r)r.hasOwnProperty(H)&&(s=r[H],s!=null)&&(H==="selected"?e.selected=s&&typeof s!="function"&&typeof s!="symbol":jt(e,n,H,s,r,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(s=0;s<Pl.length;s++)We(Pl[s],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(ie in r)if(r.hasOwnProperty(ie)&&(s=r[ie],s!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:jt(e,n,ie,s,r,null)}return;default:if(ko(n)){for(fe in r)r.hasOwnProperty(fe)&&(s=r[fe],s!==void 0&&cc(e,n,fe,s,r,void 0));return}}for(E in r)r.hasOwnProperty(E)&&(s=r[E],s!=null&&jt(e,n,E,s,r,null))}function x0(e,n,r,s){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var d=null,g=null,S=null,E=null,H=null,ie=null,fe=null;for(ue in r){var pe=r[ue];if(r.hasOwnProperty(ue)&&pe!=null)switch(ue){case"checked":break;case"value":break;case"defaultValue":H=pe;default:s.hasOwnProperty(ue)||jt(e,n,ue,null,s,pe)}}for(var le in s){var ue=s[le];if(pe=r[le],s.hasOwnProperty(le)&&(ue!=null||pe!=null))switch(le){case"type":g=ue;break;case"name":d=ue;break;case"checked":ie=ue;break;case"defaultChecked":fe=ue;break;case"value":S=ue;break;case"defaultValue":E=ue;break;case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(a(137,n));break;default:ue!==pe&&jt(e,n,le,ue,s,pe)}}wo(e,S,E,H,ie,fe,g,d);return;case"select":ue=S=E=le=null;for(g in r)if(H=r[g],r.hasOwnProperty(g)&&H!=null)switch(g){case"value":break;case"multiple":ue=H;default:s.hasOwnProperty(g)||jt(e,n,g,null,s,H)}for(d in s)if(g=s[d],H=r[d],s.hasOwnProperty(d)&&(g!=null||H!=null))switch(d){case"value":le=g;break;case"defaultValue":E=g;break;case"multiple":S=g;default:g!==H&&jt(e,n,d,g,s,H)}n=E,r=S,s=ue,le!=null?Nr(e,!!r,le,!1):!!s!=!!r&&(n!=null?Nr(e,!!r,n,!0):Nr(e,!!r,r?[]:"",!1));return;case"textarea":ue=le=null;for(E in r)if(d=r[E],r.hasOwnProperty(E)&&d!=null&&!s.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:jt(e,n,E,null,s,d)}for(S in s)if(d=s[S],g=r[S],s.hasOwnProperty(S)&&(d!=null||g!=null))switch(S){case"value":le=d;break;case"defaultValue":ue=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(a(91));break;default:d!==g&&jt(e,n,S,d,s,g)}Dd(e,le,ue);return;case"option":for(var Ne in r)le=r[Ne],r.hasOwnProperty(Ne)&&le!=null&&!s.hasOwnProperty(Ne)&&(Ne==="selected"?e.selected=!1:jt(e,n,Ne,null,s,le));for(H in s)le=s[H],ue=r[H],s.hasOwnProperty(H)&&le!==ue&&(le!=null||ue!=null)&&(H==="selected"?e.selected=le&&typeof le!="function"&&typeof le!="symbol":jt(e,n,H,le,s,ue));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 Ie in r)le=r[Ie],r.hasOwnProperty(Ie)&&le!=null&&!s.hasOwnProperty(Ie)&&jt(e,n,Ie,null,s,le);for(ie in s)if(le=s[ie],ue=r[ie],s.hasOwnProperty(ie)&&le!==ue&&(le!=null||ue!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(a(137,n));break;default:jt(e,n,ie,le,s,ue)}return;default:if(ko(n)){for(var kt in r)le=r[kt],r.hasOwnProperty(kt)&&le!==void 0&&!s.hasOwnProperty(kt)&&cc(e,n,kt,void 0,s,le);for(fe in s)le=s[fe],ue=r[fe],!s.hasOwnProperty(fe)||le===ue||le===void 0&&ue===void 0||cc(e,n,fe,le,s,ue);return}}for(var X in r)le=r[X],r.hasOwnProperty(X)&&le!=null&&!s.hasOwnProperty(X)&&jt(e,n,X,null,s,le);for(pe in s)le=s[pe],ue=r[pe],!s.hasOwnProperty(pe)||le===ue||le==null&&ue==null||jt(e,n,pe,le,s,ue)}function Lm(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function S0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,r=performance.getEntriesByType("resource"),s=0;s<r.length;s++){var d=r[s],g=d.transferSize,S=d.initiatorType,E=d.duration;if(g&&E&&Lm(S)){for(S=0,E=d.responseEnd,s+=1;s<r.length;s++){var H=r[s],ie=H.startTime;if(ie>E)break;var fe=H.transferSize,pe=H.initiatorType;fe&&Lm(pe)&&(H=H.responseEnd,S+=fe*(H<E?1:(E-ie)/(H-ie)))}if(--s,n+=8*(g+S)/(d.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 fc=null,dc=null;function As(e){return e.nodeType===9?e:e.ownerDocument}function Bm(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 Um(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 hc(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 pc=null;function w0(){var e=window.event;return e&&e.type==="popstate"?e===pc?!1:(pc=e,!0):(pc=null,!1)}var Im=typeof setTimeout=="function"?setTimeout:void 0,j0=typeof clearTimeout=="function"?clearTimeout:void 0,qm=typeof Promise=="function"?Promise:void 0,k0=typeof queueMicrotask=="function"?queueMicrotask:typeof qm<"u"?function(e){return qm.resolve(null).then(e).catch(E0)}:Im;function E0(e){setTimeout(function(){throw e})}function Ii(e){return e==="head"}function Hm(e,n){var r=n,s=0;do{var d=r.nextSibling;if(e.removeChild(r),d&&d.nodeType===8)if(r=d.data,r==="/$"||r==="/&"){if(s===0){e.removeChild(d),ll(n);return}s--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")s++;else if(r==="html")Jl(e.ownerDocument.documentElement);else if(r==="head"){r=e.ownerDocument.head,Jl(r);for(var g=r.firstChild;g;){var S=g.nextSibling,E=g.nodeName;g[gl]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&g.rel.toLowerCase()==="stylesheet"||r.removeChild(g),g=S}}else r==="body"&&Jl(e.ownerDocument.body);r=d}while(r);ll(n)}function Vm(e,n){var r=e;e=0;do{var s=r.nextSibling;if(r.nodeType===1?n?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(n?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),s&&s.nodeType===8)if(r=s.data,r==="/$"){if(e===0)break;e--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||e++;r=s}while(r)}function mc(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var r=n;switch(n=n.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":mc(r),xo(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}e.removeChild(r)}}function C0(e,n,r,s){for(;e.nodeType===1;){var d=r;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!s&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(s){if(!e[gl])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!==d.rel||e.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||e.getAttribute("title")!==(d.title==null?null:d.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(g=e.getAttribute("src"),(g!==(d.src==null?null:d.src)||e.getAttribute("type")!==(d.type==null?null:d.type)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=d.name==null?null:""+d.name;if(d.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=On(e.nextSibling),e===null)break}return null}function N0(e,n,r){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=On(e.nextSibling),e===null))return null;return e}function Ym(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=On(e.nextSibling),e===null))return null;return e}function gc(e){return e.data==="$?"||e.data==="$~"}function yc(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function A0(e,n){var r=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||r.readyState!=="loading")n();else{var s=function(){n(),r.removeEventListener("DOMContentLoaded",s)};r.addEventListener("DOMContentLoaded",s),e._reactRetry=s}}function On(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 bc=null;function Gm(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="/$"||r==="/&"){if(n===0)return On(e.nextSibling);n--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||n++}e=e.nextSibling}return null}function Fm(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(n===0)return e;n--}else r!=="/$"&&r!=="/&"||n++}e=e.previousSibling}return null}function Qm(e,n,r){switch(n=As(r),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 Jl(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);xo(e)}var Ln=new Map,$m=new Set;function Ts(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var yi=Z.d;Z.d={f:T0,r:R0,D:z0,C:D0,L:_0,m:M0,X:L0,S:O0,M:B0};function T0(){var e=yi.f(),n=xs();return e||n}function R0(e){var n=kr(e);n!==null&&n.tag===5&&n.type==="form"?cp(n):yi.r(e)}var nl=typeof document>"u"?null:document;function Xm(e,n,r){var s=nl;if(s&&typeof n=="string"&&n){var d=An(n);d='link[rel="'+e+'"][href="'+d+'"]',typeof r=="string"&&(d+='[crossorigin="'+r+'"]'),$m.has(d)||($m.add(d),e={rel:e,crossOrigin:r,href:n},s.querySelector(d)===null&&(n=s.createElement("link"),nn(n,"link",e),Kt(n),s.head.appendChild(n)))}}function z0(e){yi.D(e),Xm("dns-prefetch",e,null)}function D0(e,n){yi.C(e,n),Xm("preconnect",e,n)}function _0(e,n,r){yi.L(e,n,r);var s=nl;if(s&&e&&n){var d='link[rel="preload"][as="'+An(n)+'"]';n==="image"&&r&&r.imageSrcSet?(d+='[imagesrcset="'+An(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(d+='[imagesizes="'+An(r.imageSizes)+'"]')):d+='[href="'+An(e)+'"]';var g=d;switch(n){case"style":g=il(e);break;case"script":g=rl(e)}Ln.has(g)||(e=b({rel:"preload",href:n==="image"&&r&&r.imageSrcSet?void 0:e,as:n},r),Ln.set(g,e),s.querySelector(d)!==null||n==="style"&&s.querySelector(Wl(g))||n==="script"&&s.querySelector(ea(g))||(n=s.createElement("link"),nn(n,"link",e),Kt(n),s.head.appendChild(n)))}}function M0(e,n){yi.m(e,n);var r=nl;if(r&&e){var s=n&&typeof n.as=="string"?n.as:"script",d='link[rel="modulepreload"][as="'+An(s)+'"][href="'+An(e)+'"]',g=d;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=rl(e)}if(!Ln.has(g)&&(e=b({rel:"modulepreload",href:e},n),Ln.set(g,e),r.querySelector(d)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(ea(g)))return}s=r.createElement("link"),nn(s,"link",e),Kt(s),r.head.appendChild(s)}}}function O0(e,n,r){yi.S(e,n,r);var s=nl;if(s&&e){var d=Er(s).hoistableStyles,g=il(e);n=n||"default";var S=d.get(g);if(!S){var E={loading:0,preload:null};if(S=s.querySelector(Wl(g)))E.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":n},r),(r=Ln.get(g))&&vc(e,r);var H=S=s.createElement("link");Kt(H),nn(H,"link",e),H._p=new Promise(function(ie,fe){H.onload=ie,H.onerror=fe}),H.addEventListener("load",function(){E.loading|=1}),H.addEventListener("error",function(){E.loading|=2}),E.loading|=4,Rs(S,n,s)}S={type:"stylesheet",instance:S,count:1,state:E},d.set(g,S)}}}function L0(e,n){yi.X(e,n);var r=nl;if(r&&e){var s=Er(r).hoistableScripts,d=rl(e),g=s.get(d);g||(g=r.querySelector(ea(d)),g||(e=b({src:e,async:!0},n),(n=Ln.get(d))&&xc(e,n),g=r.createElement("script"),Kt(g),nn(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},s.set(d,g))}}function B0(e,n){yi.M(e,n);var r=nl;if(r&&e){var s=Er(r).hoistableScripts,d=rl(e),g=s.get(d);g||(g=r.querySelector(ea(d)),g||(e=b({src:e,async:!0,type:"module"},n),(n=Ln.get(d))&&xc(e,n),g=r.createElement("script"),Kt(g),nn(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},s.set(d,g))}}function Km(e,n,r,s){var d=(d=ae.current)?Ts(d):null;if(!d)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(n=il(r.href),r=Er(d).hoistableStyles,s=r.get(n),s||(s={type:"style",instance:null,count:0,state:null},r.set(n,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){e=il(r.href);var g=Er(d).hoistableStyles,S=g.get(e);if(S||(d=d.ownerDocument||d,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,S),(g=d.querySelector(Wl(e)))&&!g._p&&(S.instance=g,S.state.loading=5),Ln.has(e)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},Ln.set(e,r),g||U0(d,e,r,S.state))),n&&s===null)throw Error(a(528,""));return S}if(n&&s!==null)throw Error(a(529,""));return null;case"script":return n=r.async,r=r.src,typeof r=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=rl(r),r=Er(d).hoistableScripts,s=r.get(n),s||(s={type:"script",instance:null,count:0,state:null},r.set(n,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function il(e){return'href="'+An(e)+'"'}function Wl(e){return'link[rel="stylesheet"]['+e+"]"}function Pm(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function U0(e,n,r,s){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?s.loading=1:(n=e.createElement("link"),s.preload=n,n.addEventListener("load",function(){return s.loading|=1}),n.addEventListener("error",function(){return s.loading|=2}),nn(n,"link",r),Kt(n),e.head.appendChild(n))}function rl(e){return'[src="'+An(e)+'"]'}function ea(e){return"script[async]"+e}function Zm(e,n,r){if(n.count++,n.instance===null)switch(n.type){case"style":var s=e.querySelector('style[data-href~="'+An(r.href)+'"]');if(s)return n.instance=s,Kt(s),s;var d=b({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),Kt(s),nn(s,"style",d),Rs(s,r.precedence,e),n.instance=s;case"stylesheet":d=il(r.href);var g=e.querySelector(Wl(d));if(g)return n.state.loading|=4,n.instance=g,Kt(g),g;s=Pm(r),(d=Ln.get(d))&&vc(s,d),g=(e.ownerDocument||e).createElement("link"),Kt(g);var S=g;return S._p=new Promise(function(E,H){S.onload=E,S.onerror=H}),nn(g,"link",s),n.state.loading|=4,Rs(g,r.precedence,e),n.instance=g;case"script":return g=rl(r.src),(d=e.querySelector(ea(g)))?(n.instance=d,Kt(d),d):(s=r,(d=Ln.get(g))&&(s=b({},r),xc(s,d)),e=e.ownerDocument||e,d=e.createElement("script"),Kt(d),nn(d,"link",s),e.head.appendChild(d),n.instance=d);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(s=n.instance,n.state.loading|=4,Rs(s,r.precedence,e));return n.instance}function Rs(e,n,r){for(var s=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=s.length?s[s.length-1]:null,g=d,S=0;S<s.length;S++){var E=s[S];if(E.dataset.precedence===n)g=E;else if(g!==d)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=r.nodeType===9?r.head:r,n.insertBefore(e,n.firstChild))}function vc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function xc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var zs=null;function Jm(e,n,r){if(zs===null){var s=new Map,d=zs=new Map;d.set(r,s)}else d=zs,s=d.get(r),s||(s=new Map,d.set(r,s));if(s.has(e))return s;for(s.set(e,null),r=r.getElementsByTagName(e),d=0;d<r.length;d++){var g=r[d];if(!(g[gl]||g[Bt]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(n)||"";S=e+S;var E=s.get(S);E?E.push(g):s.set(S,[g])}}return s}function Wm(e,n,r){e=e.ownerDocument||e,e.head.insertBefore(r,n==="title"?e.querySelector("head > title"):null)}function I0(e,n,r){if(r===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 eg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function q0(e,n,r,s){if(r.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var d=il(s.href),g=n.querySelector(Wl(d));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=Ds.bind(e),n.then(e,e)),r.state.loading|=4,r.instance=g,Kt(g);return}g=n.ownerDocument||n,s=Pm(s),(d=Ln.get(d))&&vc(s,d),g=g.createElement("link"),Kt(g);var S=g;S._p=new Promise(function(E,H){S.onload=E,S.onerror=H}),nn(g,"link",s),r.instance=g}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(r,n),(n=r.state.preload)&&(r.state.loading&3)===0&&(e.count++,r=Ds.bind(e),n.addEventListener("load",r),n.addEventListener("error",r))}}var Sc=0;function H0(e,n){return e.stylesheets&&e.count===0&&Ms(e,e.stylesheets),0<e.count||0<e.imgCount?function(r){var s=setTimeout(function(){if(e.stylesheets&&Ms(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&Sc===0&&(Sc=62500*S0());var d=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Ms(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>Sc?50:800)+n);return e.unsuspend=r,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(d)}}:null}function Ds(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ms(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var _s=null;function Ms(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,_s=new Map,n.forEach(V0,e),_s=null,Ds.call(e))}function V0(e,n){if(!(n.state.loading&4)){var r=_s.get(e);if(r)var s=r.get(null);else{r=new Map,_s.set(e,r);for(var d=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<d.length;g++){var S=d[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(r.set(S.dataset.precedence,S),s=S)}s&&r.set(null,s)}d=n.instance,S=d.getAttribute("data-precedence"),g=r.get(S)||s,g===s&&r.set(null,d),r.set(S,d),this.count++,s=Ds.bind(this),d.addEventListener("load",s),d.addEventListener("error",s),g?g.parentNode.insertBefore(d,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(d,e.firstChild)),n.state.loading|=4}}var ta={$$typeof:O,Provider:null,Consumer:null,_currentValue:he,_currentValue2:he,_threadCount:0};function Y0(e,n,r,s,d,g,S,E,H){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=je(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=je(0),this.hiddenUpdates=je(null),this.identifierPrefix=s,this.onUncaughtError=d,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=H,this.incompleteTransitions=new Map}function tg(e,n,r,s,d,g,S,E,H,ie,fe,pe){return e=new Y0(e,n,r,S,H,ie,fe,pe,E),n=1,g===!0&&(n|=24),g=bn(3,null,null,n),e.current=g,g.stateNode=e,n=eu(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:s,isDehydrated:r,cache:n},ru(g),e}function ng(e){return e?(e=Or,e):Or}function ig(e,n,r,s,d,g){d=ng(d),s.context===null?s.context=d:s.pendingContext=d,s=Ai(n),s.payload={element:r},g=g===void 0?null:g,g!==null&&(s.callback=g),r=Ti(e,s,n),r!==null&&(pn(r,e,n),_l(r,e,n))}function rg(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<n?r:n}}function wc(e,n){rg(e,n),(e=e.alternate)&&rg(e,n)}function lg(e){if(e.tag===13||e.tag===31){var n=er(e,67108864);n!==null&&pn(n,e,67108864),wc(e,67108864)}}function ag(e){if(e.tag===13||e.tag===31){var n=jn();n=Vt(n);var r=er(e,n);r!==null&&pn(r,e,n),wc(e,n)}}var Os=!0;function G0(e,n,r,s){var d=z.T;z.T=null;var g=Z.p;try{Z.p=2,jc(e,n,r,s)}finally{Z.p=g,z.T=d}}function F0(e,n,r,s){var d=z.T;z.T=null;var g=Z.p;try{Z.p=8,jc(e,n,r,s)}finally{Z.p=g,z.T=d}}function jc(e,n,r,s){if(Os){var d=kc(s);if(d===null)uc(e,n,s,Ls,r),og(e,s);else if($0(d,e,n,r,s))s.stopPropagation();else if(og(e,s),n&4&&-1<Q0.indexOf(e)){for(;d!==null;){var g=kr(d);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=ve(g.pendingLanes);if(S!==0){var E=g;for(E.pendingLanes|=2,E.entangledLanes|=2;S;){var H=1<<31-Ze(S);E.entanglements[1]|=H,S&=~H}Kn(g),(gt&6)===0&&(bs=lt()+500,Kl(0))}}break;case 31:case 13:E=er(g,2),E!==null&&pn(E,g,2),xs(),wc(g,2)}if(g=kc(s),g===null&&uc(e,n,s,Ls,r),g===d)break;d=g}d!==null&&s.stopPropagation()}else uc(e,n,s,null,r)}}function kc(e){return e=Co(e),Ec(e)}var Ls=null;function Ec(e){if(Ls=null,e=jr(e),e!==null){var n=f(e);if(n===null)e=null;else{var r=n.tag;if(r===13){if(e=u(n),e!==null)return e;e=null}else if(r===31){if(e=m(n),e!==null)return e;e=null}else if(r===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return Ls=e,null}function sg(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(bt()){case M:return 2;case P:return 8;case ge:case Se:return 32;case Ce:return 268435456;default:return 32}default:return 32}}var Cc=!1,qi=null,Hi=null,Vi=null,na=new Map,ia=new Map,Yi=[],Q0="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 og(e,n){switch(e){case"focusin":case"focusout":qi=null;break;case"dragenter":case"dragleave":Hi=null;break;case"mouseover":case"mouseout":Vi=null;break;case"pointerover":case"pointerout":na.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":ia.delete(n.pointerId)}}function ra(e,n,r,s,d,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:r,eventSystemFlags:s,nativeEvent:g,targetContainers:[d]},n!==null&&(n=kr(n),n!==null&&lg(n)),e):(e.eventSystemFlags|=s,n=e.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),e)}function $0(e,n,r,s,d){switch(n){case"focusin":return qi=ra(qi,e,n,r,s,d),!0;case"dragenter":return Hi=ra(Hi,e,n,r,s,d),!0;case"mouseover":return Vi=ra(Vi,e,n,r,s,d),!0;case"pointerover":var g=d.pointerId;return na.set(g,ra(na.get(g)||null,e,n,r,s,d)),!0;case"gotpointercapture":return g=d.pointerId,ia.set(g,ra(ia.get(g)||null,e,n,r,s,d)),!0}return!1}function ug(e){var n=jr(e.target);if(n!==null){var r=f(n);if(r!==null){if(n=r.tag,n===13){if(n=u(r),n!==null){e.blockedOn=n,Ki(e.priority,function(){ag(r)});return}}else if(n===31){if(n=m(r),n!==null){e.blockedOn=n,Ki(e.priority,function(){ag(r)});return}}else if(n===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Bs(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var r=kc(e.nativeEvent);if(r===null){r=e.nativeEvent;var s=new r.constructor(r.type,r);Eo=s,r.target.dispatchEvent(s),Eo=null}else return n=kr(r),n!==null&&lg(n),e.blockedOn=r,!1;n.shift()}return!0}function cg(e,n,r){Bs(e)&&r.delete(n)}function X0(){Cc=!1,qi!==null&&Bs(qi)&&(qi=null),Hi!==null&&Bs(Hi)&&(Hi=null),Vi!==null&&Bs(Vi)&&(Vi=null),na.forEach(cg),ia.forEach(cg)}function Us(e,n){e.blockedOn===n&&(e.blockedOn=null,Cc||(Cc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,X0)))}var Is=null;function fg(e){Is!==e&&(Is=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Is===e&&(Is=null);for(var n=0;n<e.length;n+=3){var r=e[n],s=e[n+1],d=e[n+2];if(typeof s!="function"){if(Ec(s||r)===null)continue;break}var g=kr(r);g!==null&&(e.splice(n,3),n-=3,ku(g,{pending:!0,data:d,method:r.method,action:s},s,d))}}))}function ll(e){function n(H){return Us(H,e)}qi!==null&&Us(qi,e),Hi!==null&&Us(Hi,e),Vi!==null&&Us(Vi,e),na.forEach(n),ia.forEach(n);for(var r=0;r<Yi.length;r++){var s=Yi[r];s.blockedOn===e&&(s.blockedOn=null)}for(;0<Yi.length&&(r=Yi[0],r.blockedOn===null);)ug(r),r.blockedOn===null&&Yi.shift();if(r=(e.ownerDocument||e).$$reactFormReplay,r!=null)for(s=0;s<r.length;s+=3){var d=r[s],g=r[s+1],S=d[Jt]||null;if(typeof g=="function")S||fg(r);else if(S){var E=null;if(g&&g.hasAttribute("formAction")){if(d=g,S=g[Jt]||null)E=S.formAction;else if(Ec(d)!==null)continue}else E=S.action;typeof E=="function"?r[s+1]=E:(r.splice(s,3),s-=3),fg(r)}}}function dg(){function e(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return d=S})},focusReset:"manual",scroll:"manual"})}function n(){d!==null&&(d(),d=null),s||setTimeout(r,20)}function r(){if(!s&&!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 s=!1,d=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(r,100),function(){s=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),d!==null&&(d(),d=null)}}}function Nc(e){this._internalRoot=e}qs.prototype.render=Nc.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));var r=n.current,s=jn();ig(r,s,e,n,null,null)},qs.prototype.unmount=Nc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;ig(e.current,2,null,e,null,null),xs(),n[Gn]=null}};function qs(e){this._internalRoot=e}qs.prototype.unstable_scheduleHydration=function(e){if(e){var n=Ta();e={blockedOn:null,target:e,priority:n};for(var r=0;r<Yi.length&&n!==0&&n<Yi[r].priority;r++);Yi.splice(r,0,e),r===0&&ug(e)}};var hg=i.version;if(hg!=="19.2.6")throw Error(a(527,hg,"19.2.6"));Z.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=p(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var K0={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Hs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hs.isDisabled&&Hs.supportsFiber)try{yt=Hs.inject(K0),pt=Hs}catch{}}return aa.createRoot=function(e,n){if(!o(e))throw Error(a(299));var r=!1,s="",d=xp,g=Sp,S=wp;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onUncaughtError!==void 0&&(d=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(S=n.onRecoverableError)),n=tg(e,1,!1,null,null,r,s,null,d,g,S,dg),e[Gn]=n.current,oc(e),new Nc(n)},aa.hydrateRoot=function(e,n,r){if(!o(e))throw Error(a(299));var s=!1,d="",g=xp,S=Sp,E=wp,H=null;return r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onUncaughtError!==void 0&&(g=r.onUncaughtError),r.onCaughtError!==void 0&&(S=r.onCaughtError),r.onRecoverableError!==void 0&&(E=r.onRecoverableError),r.formState!==void 0&&(H=r.formState)),n=tg(e,1,!0,n,r??null,s,d,H,g,S,E,dg),n.context=ng(null),r=n.current,s=jn(),s=Vt(s),d=Ai(s),d.callback=null,Ti(r,d,s),r=s,n.current.lanes=r,Ke(n,r),Kn(n),e[Gn]=n.current,oc(e),new qs(n)},aa.version="19.2.6",aa}var kg;function w1(){if(kg)return zc.exports;kg=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(),zc.exports=S1(),zc.exports}var j1=w1();const k1=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;function gb(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 Jf="codeshell.environments.v1",yb=32;function Wf(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 bb(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&&!gb({version:1,id:i.environmentId,name:"Host",kind:"hub",entryPath:"/"}))throw new Error("无效的环境身份。");return{address:Wf(i.address),name:i.name.trim(),...i.environmentId?{environmentId:i.environmentId}:{}}}function ro(t){const i=t.getItem(Jf);if(i===null)return[];if(i.length>1e5)throw new Error("连接记录过大,请清理当前工作台的连接记录。");const l=JSON.parse(i);if(!Array.isArray(l)||l.length>yb)throw new Error("连接记录格式无效。");return l.map(bb)}function Eg(t,i){const l=bb(i),a=ro(t),o=a.find(u=>u.address===l.address);if(o?.environmentId&&l.environmentId&&o.environmentId!==l.environmentId)throw new Error("这个地址的环境身份已变化。请确认目标后,删除旧连接再添加。");const f=[...a.filter(u=>u.address!==l.address),{...l,...o?.environmentId?{environmentId:o.environmentId}:{}}];if(f.length>yb)throw new Error("最多保存 32 个环境,请先移除不再使用的连接。");return t.setItem(Jf,JSON.stringify(f)),f}function E1(t,i){const l=ro(t).filter(a=>a.address!==Wf(i));return t.setItem(Jf,JSON.stringify(l)),l}function C1(t,i,l){const a=t.find(o=>o.address===i+l.entryPath);if(a?.environmentId&&a.environmentId!==l.id)throw new Error("当前地址对应的环境已变化,请核对项目后重新保存连接。")}function ed({discover:t=!0,navigate:i}){const[l,a]=w.useState(!1),[o,f]=w.useState(),[u,m]=w.useState([]),[h,p]=w.useState(""),[y,b]=w.useState(""),[x,v]=w.useState(""),j=w.useRef(null),D=w.useRef(null);w.useEffect(()=>{try{m(ro(window.localStorage))}catch{v("无法读取连接记录。当前项目仍可使用。")}},[]),w.useEffect(()=>{if(!t)return;const R=new AbortController;return He("/api/v1/environment",{signal:R.signal}).then(O=>{if(!R.signal.aborted){if(!gb(O))throw new Error("环境信息无效,请更新工作台后重试。");f(O),C1(ro(window.localStorage),window.location.origin,O)}}).catch(O=>{R.signal.aborted||O instanceof Pe&&[401,404].includes(O.status)||v(O instanceof Error?O.message:"无法读取环境信息。")}),()=>R.abort()},[t]),w.useEffect(()=>{l&&(j.current?.showModal(),D.current?.focus())},[l]);const N=R=>{try{m(R()),v("")}catch(O){v(O instanceof Error?O.message:"保存连接失败。")}},A=R=>{const O=Wf(R);a(!1),i?i(O):window.location.assign(O)};return c.jsxs("div",{className:"environment-switcher",children:[c.jsxs("button",{type:"button",className:"ghost environment-trigger",onClick:()=>a(!0),children:[o?.name??"连接环境",c.jsx("span",{"aria-hidden":"true",children:" ▾"})]}),l?c.jsxs("dialog",{ref:j,className:"environment-dialog","aria-labelledby":"environment-title",onCancel:()=>a(!1),onClose:()=>a(!1),children:[c.jsxs("header",{children:[c.jsx("h2",{id:"environment-title",children:"电脑与云端"}),c.jsx("button",{ref:D,type:"button",className:"ghost",onClick:()=>a(!1),children:"关闭"})]}),c.jsx("p",{children:"打开目标环境后选择项目。切换入口不会移动文件或正在运行的任务。"}),c.jsxs("p",{className:"environment-location",children:["当前地址:",window.location.origin]}),x?c.jsx("p",{role:"alert",className:"form-error",children:x}):null,o?c.jsx("button",{type:"button",className:"library-button",onClick:()=>N(()=>Eg(window.localStorage,{name:o.name,address:window.location.origin+o.entryPath,environmentId:o.id})),children:"保存当前环境"}):null,c.jsx("ul",{className:"environment-list",children:u.map(R=>c.jsxs("li",{children:[c.jsxs("div",{children:[c.jsx("strong",{children:R.name}),c.jsx("small",{children:R.address})]}),c.jsx("button",{type:"button",className:"library-button",onClick:()=>A(R.address),children:"打开"}),c.jsx("button",{type:"button",className:"ghost","aria-label":`移除 ${R.name}`,onClick:()=>N(()=>E1(window.localStorage,R.address)),children:"移除"})]},R.address))}),c.jsxs("form",{onSubmit:R=>{R.preventDefault(),N(()=>Eg(window.localStorage,{name:h,address:y.trim()}))},children:[c.jsxs("label",{children:["连接名称",c.jsx("input",{required:!0,maxLength:80,value:h,onChange:R=>p(R.target.value),placeholder:"例如:家里的电脑"})]}),c.jsxs("label",{children:["工作台地址",c.jsx("input",{required:!0,type:"url",maxLength:2048,value:y,onChange:R=>b(R.target.value),placeholder:"https://example.com/"})]}),c.jsx("button",{type:"submit",className:"library-button primary",children:"添加连接"})]}),c.jsx("p",{className:"environment-hint",children:"连接记录保存在当前工作台的浏览器存储中。目标环境需要单独登录或配对,请勿保存带配对令牌的地址。未连接的环境不会显示为在线。"})]}):null]})}function N1({session:t,onClose:i,onAuthLost:l}){const[a,o]=w.useState([]),[f,u]=w.useState(""),[m,h]=w.useState("loading"),p=w.useRef(null),y=w.useCallback(v=>{v instanceof Pe&&v.status===401?l():u(v instanceof Error?v.message:"操作失败,请重试。")},[l]);w.useEffect(()=>{let v=!0;return p.current?.showModal(),He("/api/v1/auth/sessions").then(j=>{v&&o(j.sessions)}).catch(j=>{v&&y(j)}).finally(()=>{v&&h(null)}),()=>{v=!1}},[y]);const b=async v=>{h(v.id),u("");try{await He(`/api/v1/auth/sessions/${encodeURIComponent(v.id)}`,{method:"DELETE"}),v.current?l():o(j=>j.filter(D=>D.id!==v.id))}catch(j){y(j)}finally{h(null)}},x=async()=>{h("logout"),u("");try{await hb("/api/v1/auth/logout"),l()}catch(v){y(v)}finally{h(null)}};return c.jsxs("dialog",{className:"devices-dialog",ref:p,onCancel:i,"aria-labelledby":"devices-title",children:[c.jsxs("div",{className:"dialog-head",children:[c.jsx("h2",{id:"devices-title",children:"账号与设备"}),c.jsx("button",{className:"ghost",onClick:i,"aria-label":"关闭",children:"×"})]}),c.jsxs("p",{className:"muted",children:[t?.username," · ",t?.deviceName||"当前设备"]}),f?c.jsx("p",{className:"form-error",role:"alert",children:f}):null,m==="loading"?c.jsx("p",{role:"status",children:"正在读取设备…"}):null,c.jsx("ul",{className:"device-list",children:a.map(v=>c.jsxs("li",{children:[c.jsxs("div",{children:[c.jsxs("strong",{children:[v.deviceName||"未命名设备",v.current?"(当前)":""]}),c.jsxs("span",{children:["最近活动 ",new Date(v.lastSeenAt).toLocaleString()]})]}),c.jsx("button",{className:"ghost",disabled:m!==null,onClick:()=>{b(v)},children:m===v.id?"处理中…":"撤销登录"})]},v.id))}),c.jsx("button",{className:"stop",disabled:m!==null,onClick:()=>{x()},children:"退出当前设备"})]})}function Oc(t){return{expectedRevision:t?t.revision:null,id:t?.id??"",catalogId:t?.catalogId??"",model:t?.model??"",baseUrl:t?.baseUrl??"",apiKey:""}}function A1(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 td(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 td(await He("/api/v1/configuration",{signal:t}))}async function nd(t,i,l){return td(await He(`/api/v1/configuration/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:l}))}function T1(t,i){return nd("connections",A1(t),i)}function R1(t,i){return nd("defaults",t,i)}function z1(t,i,l){return nd("skills",{name:t,enabled:i},l)}function xb(t){const i=t instanceof Error?t.message:"设置更新失败,请重试。",l={"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 l[i]?l[i]:/^(id|catalogId|model|text|auxText|apiKey) is invalid$/.exec(i)?"配置字段无效,请检查名称、模型与密钥后重试。":i}async function D1(t,i,l,a){return td(await He("/api/v1/configuration/connections",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,...i?{replacementText:i}:{},...a?{expectedRevision:a}:{}}),signal:l}))}async function _1(t,i){const l=Ea(),a=St("/api/v1/configuration/connections/probe"),o=St("/api/v1/configuration/connections/probe/cancel");let f;try{f=await He(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,requestId:l}),signal:i})}catch(u){throw i?.aborted&&await He(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:l}),signal:AbortSignal.timeout(2e3)}).catch(()=>{}),u}if(!f||f.connectionId!==t||typeof f.ok!="boolean"||typeof f.message!="string"||typeof f.code!="string"||!Number.isFinite(f.latencyMs))throw new Error("服务端返回了无效的测试结果,请重试。");return f}const id="/api/v1/skills";async function Cg(t){const i=await He(id,{signal:t});if(!i||!Array.isArray(i.skills)||!Array.isArray(i.directories))throw new Error("Skills 列表读取失败,请刷新重试。");return i}async function M1(t,i){const l=await He(`${id}/detail?name=${encodeURIComponent(t)}`,{signal:i});if(l.name!==t||typeof l.content!="string"||typeof l.revision!="string")throw new Error("Skill 内容读取失败,请重试。");return l}function br(t,i,l,a){return He(`${id}${t}`,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(l),signal:a})}const O1=(t,i,l)=>br("/local","POST",{name:t,content:i},l),L1=(t,i,l,a)=>br("/local","PUT",{name:t,content:i,revision:l},a),B1=(t,i,l)=>br("/local","DELETE",{name:t,revision:i},l),U1=(t,i)=>br("/github/preview","POST",{url:t.trim()},i),I1=(t,i,l,a)=>br("/github/install","POST",{reviewToken:t,pathInRepo:i,name:l.trim()},a),q1=(t,i,l)=>br("/github/update-preview","POST",{name:t,revision:i},l),H1=(t,i)=>br("/github/update","POST",{reviewToken:t},i);function Fs(t){return`---
|
|
10
|
-
name: ${t||"my-skill"}
|
|
11
|
-
description: 描述这个 Skill 适合处理什么任务
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
# 工作方式
|
|
15
|
-
|
|
16
|
-
在这里写下具体步骤、输入要求和完成标准。
|
|
17
|
-
`}function Df(t){return/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(t)&&!t.includes("..")}function V1(t,i,l){const a=i.trim().toLocaleLowerCase();return t.filter(o=>(l==="all"||o.source===l)&&(!a||`${o.name} ${o.description}`.toLocaleLowerCase().includes(a)))}const Ng={project:"工作区",user:"用户级",plugin:"插件","panel-app":"Panel App"};function Y1({onAuthLost:t,onChanged:i,onDirtyChange:l,configurationVersion:a=0}){const[o,f]=w.useState(null),[u,m]=w.useState(null),[h,p]=w.useState(""),[y,b]=w.useState("all"),[x,v]=w.useState(""),[j,D]=w.useState(""),[N,A]=w.useState(""),[R,O]=w.useState(0),[Y,re]=w.useState(!1),[T,V]=w.useState(!1),Q=w.useRef(null),I=w.useRef(null),C=w.useRef(!1),B=w.useRef({onAuthLost:t,onChanged:i});B.current={onAuthLost:t,onChanged:i};const U=w.useRef(null),$=w.useRef(null),ee=w.useCallback(k=>{k instanceof Pe&&k.status===401?B.current.onAuthLost():D(k instanceof Error?k.message:"操作失败,请重试。")},[]);w.useEffect(()=>()=>{Q.current?.abort(),I.current?.abort()},[]),w.useEffect(()=>{if(Q.current){C.current=!0;return}const k=new AbortController;return I.current=k,Cg(k.signal).then(L=>{k.signal.aborted||f(L)}).catch(L=>{k.signal.aborted||ee(L)}),()=>k.abort()},[R,a,ee]),w.useEffect(()=>{u&&U.current?.focus()},[u?.kind]);const K=k=>{$.current=document.activeElement,D(""),A(""),re(!1),V(!1),m(k)},z=()=>{m(null),re(!1),V(!1),D(""),$.current?.focus()},Z=()=>{if(!Q.current){if(Y){V(!0);return}z()}},he=async(k,L,J=!1)=>{if(Q.current)return;I.current?.abort();const _=new AbortController;Q.current=_,v(k),D(""),A("");try{const te=await L(_.signal);if(_.signal.aborted)return;if(J){try{const xe=await Cg(_.signal);_.signal.aborted||f(xe)}catch(xe){if(xe instanceof Pe&&xe.status===401)throw xe;_.signal.aborted||D("操作已完成,但列表刷新失败。请点击刷新查看最新状态。")}if(_.signal.aborted)return;A(te.message||"设置已保存,下次任务生效。"),B.current.onChanged?.()}return te}catch(te){_.signal.aborted||ee(te);return}finally{Q.current===_&&(Q.current=null),_.signal.aborted||(v(""),C.current&&(C.current=!1,O(te=>te+1)))}};w.useEffect(()=>(l?.(Y||!!x),()=>l?.(!1)),[Y,x,l]);const me=V1(o?.skills??[],h,y);return c.jsxs("section",{className:"hub-skills","aria-labelledby":"skills-title",onKeyDown:k=>{k.key==="Escape"&&u&&!x&&(k.preventDefault(),Z())},children:[c.jsxs("header",{className:"skills-heading",children:[c.jsxs("div",{children:[c.jsx("span",{className:"skills-eyebrow",children:"工作区能力"}),c.jsx("h1",{id:"skills-title",children:"Skills"}),c.jsx("p",{children:"创建工作说明,导入社区技能,把常用流程留在工作区。"})]}),c.jsxs("div",{className:"skills-actions",children:[c.jsx("button",{className:"config-button",disabled:!!x||!!u,onClick:()=>K({kind:"import"}),children:"从 GitHub 导入"}),c.jsx("button",{className:"config-button config-button-primary",disabled:!!x||!!u,onClick:()=>K({kind:"create"}),children:"+ 创建 Skill"})]})]}),j&&c.jsx("div",{className:"config-message config-error",role:"alert",children:j}),N&&c.jsx("div",{className:"config-message config-success",role:"status",children:N}),x&&c.jsxs("p",{className:"skills-progress",role:"status",children:[x,"…"]}),u&&c.jsxs("section",{className:"skills-workspace-panel","aria-labelledby":"skills-panel-title",children:[c.jsxs("header",{children:[c.jsx("h2",{id:"skills-panel-title",ref:U,tabIndex:-1,children:u.kind==="create"?"创建 Skill":u.kind==="detail"?u.detail.editable?`编辑 ${u.detail.name}`:u.detail.name:u.kind==="import"?"从 GitHub 导入":u.kind==="update"?`更新 ${u.preview.name}`:`移除 ${u.skill.name}`}),c.jsx("button",{className:"config-button config-button-quiet",disabled:!!x,onClick:Z,children:"关闭"})]}),T&&c.jsxs("div",{className:"skills-discard-confirm",role:"alert",children:[c.jsx("p",{children:"还有未保存的修改。关闭会丢弃这些修改。"}),c.jsxs("div",{className:"skills-actions",children:[c.jsx("button",{className:"config-button",onClick:()=>V(!1),children:"继续编辑"}),c.jsx("button",{className:"config-button skills-danger",onClick:z,children:"放弃修改并关闭"})]})]}),(u.kind==="create"||u.kind==="detail")&&c.jsx(G1,{detail:u.kind==="detail"?u.detail:void 0,busy:!!x,run:he,onSaved:z,onDirtyChange:re},u.kind==="detail"?u.detail.name+u.detail.revision:"create"),u.kind==="import"&&c.jsx(F1,{preview:u.preview,busy:!!x,run:he,onPreview:k=>m({kind:"import",preview:k}),onInstalled:z},u.preview?.reviewToken??"url"),u.kind==="update"&&c.jsx(Q1,{preview:u.preview,busy:!!x,run:he,onUpdated:z}),u.kind==="remove"&&c.jsxs("div",{className:"skills-remove-confirm",children:[c.jsxs("p",{children:["确认从当前工作区移除 ",c.jsx("strong",{children:u.skill.name}),"?它的 SKILL.md、脚本和资源文件都会移除。"]}),c.jsx("p",{className:"config-help",children:"已保存的对话会保留。其他设备下一次运行任务时将不再使用这个工作区 Skill。"}),c.jsxs("div",{className:"skills-actions",children:[c.jsx("button",{className:"config-button",disabled:!!x,onClick:Z,children:"取消"}),c.jsx("button",{className:"config-button skills-danger",disabled:!!x,onClick:()=>{he("正在移除 Skill",k=>B1(u.skill.name,u.skill.revision,k),!0).then(k=>{k&&z()})},children:"确认移除"})]})]})]}),c.jsxs("div",{className:"skills-filter",children:[c.jsxs("label",{children:[c.jsx("span",{className:"config-sr-only",children:"搜索 Skills"}),c.jsx("input",{type:"search","aria-label":"搜索 Skills",value:h,onChange:k=>p(k.target.value),placeholder:"搜索名称或用途…"})]}),c.jsxs("select",{"aria-label":"Skill 来源",value:y,onChange:k=>b(k.target.value),children:[c.jsx("option",{value:"all",children:"全部来源"}),Object.entries(Ng).map(([k,L])=>c.jsx("option",{value:k,children:L},k))]}),c.jsx("button",{className:"config-button config-button-quiet",disabled:!!x,onClick:()=>{D(""),O(k=>k+1)},children:"刷新"})]}),!o&&!j?c.jsx("p",{className:"config-help",children:"正在读取 Skills…"}):o?c.jsxs("p",{className:"skills-count",children:[me.length===o.skills.length?`${me.length} 个 Skill`:`显示 ${me.length} / ${o.skills.length} 个 Skill`," · ",o.skills.filter(k=>k.enabled).length," 个已启用"]}):null,o&&!me.length&&c.jsxs("div",{className:"skills-empty",children:[c.jsx("h2",{children:h||y!=="all"?"没有匹配的 Skills":"从一个常用流程开始"}),c.jsx("p",{children:h||y!=="all"?"调整搜索词或来源筛选。":"创建自己的 Skill,或粘贴 GitHub 地址导入完整的社区技能。"})]}),c.jsx("div",{className:"skills-list",children:me.map(k=>c.jsxs("article",{className:"skills-card",children:[c.jsxs("div",{className:"skills-card-heading",children:[c.jsxs("div",{children:[c.jsx("h2",{children:k.name}),c.jsx("span",{className:"config-badge",children:Ng[k.source]}),k.origin&&c.jsx("span",{className:"config-badge",children:"GitHub"})]}),c.jsx("button",{className:"config-switch",role:"switch","aria-checked":k.enabled,"aria-label":`${k.enabled?"停用":"启用"} ${k.name}`,disabled:!!x||!!k.disabledReason,title:k.disabledReason,onClick:()=>{he("正在更新 Skill",async L=>(await z1(k.name,!k.enabled,L),{ok:!0,name:k.name,message:k.enabled?"Skill 已停用,下次任务生效。":"Skill 已启用,下次任务生效。"}),!0)},children:c.jsx("span",{})})]}),c.jsx("p",{children:k.description||"暂未填写用途描述。"}),k.origin&&c.jsxs("p",{className:"skills-source",children:[k.origin.url.replace("https://github.com/","")," · ",k.origin.ref," ·"," ",k.origin.commit.slice(0,8)]}),k.readOnlyReason&&c.jsx("p",{className:"config-help",children:k.readOnlyReason}),k.disabledReason&&c.jsx("p",{className:"config-help",children:k.disabledReason}),c.jsxs("footer",{className:"skills-actions",children:[c.jsx("button",{className:"config-button config-button-quiet",disabled:!!x||!!u,onClick:()=>{$.current=document.activeElement,he("正在读取 Skill",L=>M1(k.name,L)).then(L=>{L&&K({kind:"detail",detail:L})})},children:k.editable?"查看与编辑":"查看说明"}),k.editable&&k.origin&&c.jsx("button",{className:"config-button config-button-quiet",disabled:!!x||!!u,onClick:()=>{he("正在检查来源更新",L=>q1(k.name,k.revision,L)).then(L=>{L?.changed?K({kind:"update",preview:L}):L&&A(`${k.name} 已是最新版本。`)})},children:"检查更新"}),k.removable&&c.jsx("button",{className:"config-button config-button-quiet skills-remove",disabled:!!x||!!u,onClick:()=>K({kind:"remove",skill:k}),children:"移除"})]})]},k.name))}),o&&c.jsxs("details",{className:"skills-directories",children:[c.jsx("summary",{children:"Skills 存在哪里"}),c.jsx("p",{children:"这里管理当前工作区。用户级、插件和 Panel App 的 Skills 可以查看和启停,安装内容由各自来源管理。"}),c.jsx("ul",{children:o.directories.map(k=>c.jsx("li",{children:c.jsx("code",{children:k})},k))})]})]})}function G1({detail:t,busy:i,run:l,onSaved:a,onDirtyChange:o}){const[f,u]=w.useState(t?.name??"my-skill"),[m,h]=w.useState(t?.content??Fs("my-skill")),p=m!==t?.content,y=!t||t.editable;return w.useEffect(()=>{o(y&&(t?m!==t.content:f!=="my-skill"||m!==Fs("my-skill")))},[m,f,t,y,o]),c.jsx("form",{className:"skills-editor",onSubmit:b=>{b.preventDefault(),l(t?"正在保存 Skill":"正在创建 Skill",x=>t?L1(t.name,m,t.revision,x):O1(f.trim(),m,x),!0).then(x=>{x&&a()})},children:c.jsxs("fieldset",{disabled:i,children:[!t&&c.jsxs("label",{children:[c.jsx("span",{children:"名称"}),c.jsx("input",{required:!0,value:f,maxLength:128,onChange:b=>{const x=b.target.value;m===Fs(f)&&h(Fs(x)),u(x)},"aria-describedby":"skill-name-help","aria-label":"Skill 名称"}),c.jsx("small",{id:"skill-name-help",children:"字母、数字、短横线、下划线或点;创建后名称保持不变。"}),!Df(f)&&c.jsx("span",{className:"skills-field-error",children:"请输入有效名称。"})]}),c.jsxs("label",{children:[c.jsxs("span",{children:[y?"SKILL.md":"说明",t&&y&&p&&c.jsx("small",{className:"skills-unsaved",children:"未保存"})]}),c.jsx("textarea",{value:m,readOnly:!y,onChange:b=>h(b.target.value),rows:18,spellCheck:!1,"aria-label":"SKILL.md 内容"})]}),t?.origin&&y&&c.jsx("p",{className:"config-help",children:"手动编辑会保留 GitHub 来源;以后更新来源时,会预览将替换的完整内容。"}),y&&c.jsxs("div",{className:"skills-actions",children:[c.jsx("span",{className:"config-help",children:"支持 Markdown 和 YAML Frontmatter。变更在下一次任务中生效。"}),c.jsx("button",{className:"config-button config-button-primary",type:"submit",disabled:!m.trim()||!t&&!Df(f)||!!t&&!p,children:t?"保存修改":"创建 Skill"})]})]})})}function F1({preview:t,busy:i,run:l,onPreview:a,onInstalled:o}){const[f,u]=w.useState(""),[m,h]=w.useState(t?.skills[0]?.pathInRepo??""),[p,y]=w.useState(t?.skills[0]?.name??"");return t?c.jsxs("form",{className:"skills-import-preview",onSubmit:b=>{b.preventDefault(),l("正在导入 Skill 与资源",x=>I1(t.reviewToken,m,p,x),!0).then(x=>{x&&o()})},children:[c.jsxs("p",{children:[c.jsx("a",{href:t.repoUrl,target:"_blank",rel:"noreferrer",children:t.repoUrl.replace("https://github.com/","")})," ",c.jsx("span",{className:"config-badge",children:t.commit.slice(0,8)})]}),t.warning&&c.jsx("p",{className:"config-help",children:t.warning}),c.jsxs("fieldset",{disabled:i,children:[c.jsx("legend",{children:"选择一个 Skill"}),c.jsx("div",{className:"skills-source-choices",children:t.skills.map(b=>c.jsxs("label",{children:[c.jsx("input",{type:"radio",name:"github-skill",checked:m===b.pathInRepo,onChange:()=>{h(b.pathInRepo),y(b.name)}}),c.jsxs("span",{children:[c.jsx("strong",{children:b.name}),c.jsx("small",{children:b.description||b.pathInRepo}),b.alreadyInstalled&&c.jsx("small",{children:"已有同名 Skill,可修改安装名称。"})]})]},b.pathInRepo))}),!!t.skills.length&&c.jsxs(c.Fragment,{children:[c.jsxs("label",{children:[c.jsx("span",{children:"安装到工作区时使用的名称"}),c.jsx("input",{required:!0,maxLength:128,value:p,onChange:b=>y(b.target.value)})]}),c.jsx("p",{className:"config-help",children:"将导入预览时的确定版本。不会执行其中的脚本。"}),c.jsx("button",{className:"config-button config-button-primary",disabled:!m||!Df(p),type:"submit",children:"确认导入到工作区"})]})]})]}):c.jsxs("form",{className:"skills-import-url",onSubmit:b=>{b.preventDefault(),l("正在检查 GitHub 来源",x=>U1(f,x)).then(x=>{x&&a(x)})},children:[c.jsxs("label",{children:[c.jsx("span",{children:"GitHub 仓库或 Skill 目录地址"}),c.jsx("input",{type:"url",required:!0,value:f,onChange:b=>u(b.target.value),placeholder:"https://github.com/owner/repository/tree/main/skills/example",disabled:i})]}),c.jsx("p",{className:"config-help",children:"先查看可导入的技能,再确认安装。脚本和资源文件会一起保留。"}),c.jsx("button",{className:"config-button config-button-primary",disabled:i||!f.trim(),children:"预览来源"})]})}function Q1({preview:t,busy:i,run:l,onUpdated:a}){return c.jsxs("div",{className:"skills-update-preview",children:[c.jsxs("p",{children:["来源版本 ",c.jsx("code",{children:t.currentCommit.slice(0,8)})," →"," ",c.jsx("code",{children:t.latestCommit.slice(0,8)})]}),c.jsx("p",{children:"确认后会用下方版本替换此 Skill 的说明、脚本和资源,包括你在其中做过的本地修改。"}),c.jsxs("details",{children:[c.jsxs("summary",{children:["查看将导入的 ",t.files?.length??0," 个文件"]}),c.jsx("ul",{children:t.files?.map(o=>c.jsxs("li",{children:[c.jsx("code",{children:o.path}),c.jsxs("span",{children:[Math.ceil(o.size/1024)," KB",o.executable?" · 可执行脚本":""]})]},o.path))})]}),c.jsxs("label",{children:[c.jsx("span",{children:"新的 SKILL.md"}),c.jsx("textarea",{value:t.content??"",readOnly:!0,rows:16,"aria-label":"更新后的 SKILL.md"})]}),c.jsx("button",{className:"config-button config-button-primary",disabled:i||!t.reviewToken,onClick:()=>{l("正在更新 Skill",o=>H1(t.reviewToken,o),!0).then(o=>{o&&a()})},children:"确认更新到预览版本"})]})}function $1(t){const i=l=>l.map((a,o)=>({id:`stored-${o}`,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(([l,a],o)=>({id:`stored-${o}`,name:l,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 Lc(t){return t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean)}function X1(t,i){const l={},a=new Set;for(const o of t){if(!o.stored&&o.removed)continue;const f=o.name.trim();if(["__proto__","prototype","constructor"].includes(f))throw new Error(`${i}名称无效。`);if(!f&&!o.value&&!o.stored)continue;if(!f||!o.stored&&!o.value)throw new Error(`请完整填写${i}的名称和值,或移除空行。`);const u=i==="环境变量"?f:f.toLowerCase();if(a.has(u))throw new Error(`${i}名称不能重复。`);a.add(u),o.removed?l[f]=null:o.value&&o.value!==o.initialValue&&(l[f]=o.value)}return l}function Ag(t){try{return new URL(t).origin}catch{return""}}function K1(t,i){if(!i)return!1;const l=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:Ag(t.url)!==Ag(i.url??""));return!!l&&a}function P1(t,i){const l={name:t.name.trim()};(!i||t.transport!==i.transport)&&(l.transport=t.transport),(!i||t.enabled!==i.enabled)&&(l.enabled=t.enabled),t.transport==="stdio"?((!i||t.command.trim()!==i.command)&&(l.command=t.command.trim()),t.clearArgs?l.args=[]:t.args.trim()&&(l.args=t.args.split(/\r?\n/).filter(u=>u.length>0))):(!i||t.url.trim()!==i.url)&&(l.url=t.url.trim());for(const[u,m]of[["env","环境变量"],["headers","请求头"],["envHeaders","环境变量请求头"]]){const h=X1(t[u],m);Object.keys(h).length&&(l[u]=h)}const a=Lc(t.envVars);(!i||JSON.stringify(a)!==JSON.stringify(i.envVars))&&(l.envVars=a);for(const u of["bearerTokenEnvVar","credentialRef"])(!i||t[u].trim()!==(i[u]??""))&&(l[u]=t[u].trim()||null);const o=t.restrictTools?Lc(t.allowedTools):void 0;(!i||JSON.stringify(o)!==JSON.stringify(i.allowedTools))&&(l.allowedTools=o??null);const f=Lc(t.disabledTools);return(!i||JSON.stringify(f)!==JSON.stringify(i.disabledTools))&&(l.disabledTools=f),t.reuseStoredSecrets&&(l.reuseStoredSecrets=!0),l}function Sb(t){if(!t||typeof t.workspacePath!="string"||!Array.isArray(t.servers)||!Array.isArray(t.removed))throw new Error("服务端返回了无效的 MCP 配置,请刷新重试。");return t}const hl=(t,i="")=>`/api/v1/mcp/servers/${encodeURIComponent(t)}${i}`;async function Z1(t){return Sb(await He("/api/v1/mcp",{signal:t}))}async function ho(t,i,l,a){return Sb(await He(t,{method:i,headers:{"Content-Type":"application/json"},...l===void 0?{}:{body:JSON.stringify(l)},signal:a}))}function J1(t,i,l){return ho(i?hl(i.name):"/api/v1/mcp/servers",i?"PUT":"POST",P1(t,i),l)}function W1(t,i,l){return ho(hl(t,"/enabled"),"PUT",{enabled:i},l)}function eS(t,i){return ho(hl(t),"DELETE",void 0,i)}function Tg(t,i){return ho(hl(t,"/inherit"),"POST",{},i)}async function tS(t,i){const l=await He(hl(t,"/probe"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",signal:i});if(l.name!==t||!["ok","error","cancelled"].includes(l.status))throw new Error("服务端返回了无效的连接测试结果。");return l}function Rg(t,i,l){return He(St(hl(t,"/cancel-probe"),i,l),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",keepalive:!0})}const nS={local:"工作区本地",project:"工作区配置",user:"用户级",managed:"启动配置",plugin:"插件提供"};function iS({onAuthLost:t,onConfigurationChange:i,configurationVersion:l=0,onDirtyChange:a}){const[o,f]=w.useState(null),[u,m]=w.useState(!0),[h,p]=w.useState(!1),[y,b]=w.useState(!1),[x,v]=w.useState(""),[j,D]=w.useState(""),[N,A]=w.useState(null),[R,O]=w.useState(null),[Y,re]=w.useState(""),[T,V]=w.useState({}),[Q,I]=w.useState(null),[C,B]=w.useState(0),U=w.useRef({onAuthLost:t,onConfigurationChange:i,onDirtyChange:a});U.current={onAuthLost:t,onConfigurationChange:i,onDirtyChange:a};const $=w.useRef(!1),ee=w.useRef(null),K=w.useRef(null),z=w.useRef(null),Z=w.useRef(0),he=w.useRef(!1),me=w.useRef(l);w.useEffect(()=>{U.current.onDirtyChange?.(y||h)},[y,h]);const k=w.useCallback(F=>{F instanceof Pe&&F.status===401?U.current.onAuthLost():v(F instanceof Error?F.message:"MCP 操作失败,请重试。")},[]);w.useEffect(()=>($.current=!0,()=>{$.current=!1,U.current.onDirtyChange?.(!1),K.current?.abort();const F=z.current;F&&(F.controller.abort(),Rg(F.name,F.workspace,F.projectId).catch(()=>{}))}),[]),w.useEffect(()=>{me.current!==l&&(me.current=l,K.current?he.current=!0:B(F=>F+1))},[l]),w.useEffect(()=>{const F=new AbortController;ee.current=F;const we=Date.now(),Le=++Z.current;return m(!0),v(""),Z1(F.signal).then(Ae=>{!F.signal.aborted&&Le===Z.current&&(f(Ae),V(Te=>Object.fromEntries(Object.entries(Te).filter(([,tt])=>Date.parse(tt.checkedAt)>=we))))}).catch(Ae=>{!F.signal.aborted&&Le===Z.current&&k(Ae)}).finally(()=>{!F.signal.aborted&&Le===Z.current&&m(!1)}),()=>F.abort()},[C,k]);const L=async(F,we="MCP 设置已保存,任务进程会加载新的配置。")=>{if(K.current||z.current)return!1;ee.current?.abort();const Le=++Z.current,Ae=new AbortController;K.current=Ae,p(!0),m(!1),v(""),D("");try{const Te=await F(Ae.signal);return!$.current||Ae.signal.aborted||Le!==Z.current?!1:(f(Te),V({}),D(we),U.current.onConfigurationChange?.(),!0)}catch(Te){return $.current&&!Ae.signal.aborted&&k(Te),!1}finally{K.current===Ae&&(K.current=null),$.current&&!Ae.signal.aborted&&(p(!1),he.current&&(he.current=!1,B(Te=>Te+1)))}},J=async F=>{if(z.current||K.current)return;const we=new AbortController;z.current={name:F,controller:we,workspace:io()??"",projectId:Sa()},I(F),v(""),D(""),V(Le=>{const Ae={...Le};return delete Ae[F],Ae});try{const Le=await tS(F,we.signal);$.current&&!we.signal.aborted&&V(Ae=>({...Ae,[F]:Le}))}catch(Le){$.current&&!we.signal.aborted&&k(Le)}finally{z.current?.controller===we&&(z.current=null),$.current&&I(null)}},_=async()=>{const F=z.current;if(F)try{await Rg(F.name,F.workspace,F.projectId)}catch(we){$.current&&k(we)}finally{F.controller.abort(),z.current===F&&(z.current=null),$.current&&(I(null),V(we=>({...we,[F.name]:{name:F.name,status:"cancelled",checkedAt:new Date().toISOString(),durationMs:0,error:{code:"cancelled",message:"测试已取消。"}}})))}},te=h||u||Q!==null,xe=Y.trim().toLocaleLowerCase(),ae=[...o?.servers??[]];N?.kind==="edit"&&!ae.some(F=>F.name===N.name)&&ae.push(N.original);const se=ae.filter(F=>!xe||F.name.toLocaleLowerCase().includes(xe)||N?.kind==="edit"&&N.name===F.name),ye=N?.kind==="edit"?ae.find(F=>F.name===N.name):void 0;return c.jsxs("div",{className:"hub-mcp",children:[c.jsxs("div",{className:"config-section-heading hub-mcp-toolbar",children:[c.jsxs("label",{className:"config-search",children:[c.jsx("span",{"aria-hidden":"true",children:"⌕"}),c.jsx("input",{type:"search",value:Y,onChange:F=>re(F.target.value),placeholder:"搜索 MCP 服务…","aria-label":"搜索 MCP 服务"})]}),c.jsxs("div",{className:"hub-mcp-toolbar-actions",children:[c.jsx("button",{className:"config-button config-button-quiet",disabled:te,onClick:()=>B(F=>F+1),children:"刷新 MCP"}),c.jsx("button",{className:"config-button",disabled:te||N!==null,onClick:()=>A({kind:"new"}),children:"+ 添加服务"})]})]}),x&&c.jsx("p",{className:"config-message config-error",role:"alert",children:x}),j&&c.jsx("p",{className:"config-message config-success",role:"status",children:j}),h&&c.jsx("p",{className:"config-help",role:"status",children:"正在保存 MCP 配置…"}),u&&!o&&c.jsx("p",{className:"config-help",role:"status",children:"正在读取 MCP 配置…"}),N?.kind==="new"&&c.jsxs("div",{className:"config-card hub-mcp-editor-card",children:[c.jsx("h2",{children:"添加 MCP 服务"}),c.jsx(zg,{disabled:te,save:L,onDone:()=>A(null),onProbe:F=>{J(F)},onDirtyChange:b})]}),!se.length&&o&&N?.kind!=="new"&&c.jsxs("div",{className:"config-empty",children:[c.jsx("span",{"aria-hidden":"true",children:"⌘"}),c.jsx("h3",{children:xe?"没有匹配的服务":"连接你的工具与数据"}),c.jsx("p",{children:xe?"试试其他服务名称。":"添加运行 CodeShell 的设备上的命令,或连接提供 MCP 接口的 HTTP 服务。"})]}),c.jsx("div",{className:"hub-mcp-list",children:se.map(F=>c.jsxs("article",{className:"config-card hub-mcp-card",children:[c.jsxs("div",{className:"hub-mcp-card-head",children:[c.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:"⌘"}),c.jsxs("div",{className:"config-row-copy",children:[c.jsx("strong",{children:F.name}),c.jsxs("span",{children:[F.transport==="stdio"?"本地命令":F.transport==="inprocess"?"内置工具":"HTTP 服务"," ","· ",nS[F.scope]]})]}),c.jsx("button",{className:"config-switch",type:"button",role:"switch","aria-checked":F.enabled,"aria-label":`${F.enabled?"停用":"启用"} MCP ${F.name}`,disabled:te||F.pluginDisabled,onClick:()=>{L(we=>W1(F.name,!F.enabled,we))},children:c.jsx("span",{})})]}),N?.kind==="edit"&&N.name===F.name&&ye?c.jsx(zg,{server:ye,disabled:te,save:L,onDone:()=>A(null),onProbe:we=>{J(we)},onDirtyChange:b},F.name):c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:"hub-mcp-endpoint",children:[c.jsx("code",{children:F.transport==="stdio"?F.command:F.url||"由任务进程提供"}),F.argsCount>0&&c.jsxs("span",{children:[F.argsCount," 个已保存参数"]})]}),c.jsxs("div",{className:"hub-mcp-metadata",children:[c.jsx("span",{className:`config-badge${F.enabled?" config-badge-accent":""}`,children:F.enabled?"配置启用":"配置停用"}),F.envKeys.length>0&&c.jsxs("span",{children:[F.envKeys.length," 个环境变量"]}),(F.headerKeys.length>0||F.credentialRef||F.bearerTokenEnvVar||Object.keys(F.envHeaders).length>0)&&c.jsx("span",{children:"已配置认证"}),F.hasLocalOverride&&c.jsx("span",{children:"本地覆盖"})]}),F.source==="plugin"&&c.jsx("p",{className:"config-help",children:F.pluginDisabled?"所属插件已停用。启用插件后,才能启用或测试这个服务。":"连接命令与地址由插件提供,可在此启停或测试。"}),c.jsxs("div",{className:"hub-mcp-card-actions",children:[Q===F.name?c.jsx("button",{className:"config-button",onClick:()=>{_()},children:"取消测试"}):c.jsx("button",{className:"config-button",disabled:te||F.pluginDisabled||F.transport==="inprocess",onClick:()=>{J(F.name)},children:"测试连接"}),F.editable&&c.jsx("button",{className:"config-button config-button-quiet",disabled:te||N!==null,onClick:()=>{O(null),A({kind:"edit",name:F.name,original:F})},children:"编辑"}),F.hasLocalOverride&&c.jsx("button",{className:"config-button config-button-quiet",disabled:te,onClick:()=>{L(we=>Tg(F.name,we),"已移除本地覆盖,恢复继承配置。")},children:"恢复继承"}),F.deletable&&c.jsx("button",{className:"config-button config-button-quiet hub-mcp-remove",disabled:te||N!==null,onClick:()=>O(F.name),children:"移除"})]}),R===F.name&&c.jsxs("div",{className:"hub-mcp-delete",role:"alert",children:[c.jsxs("span",{children:["从当前工作区移除 ",F.name,"?其他工作区的配置不受影响。"]}),c.jsxs("div",{children:[c.jsx("button",{className:"config-button config-button-quiet",disabled:te,onClick:()=>O(null),children:"取消"}),c.jsx("button",{className:"config-button hub-mcp-remove",disabled:te,onClick:async()=>{await L(we=>eS(F.name,we),"已从当前工作区移除服务。")&&O(null)},children:"确认移除"})]})]}),Q===F.name&&c.jsx("p",{className:"hub-mcp-probing",role:"status",children:"正在建立测试连接并读取工具列表…"}),T[F.name]&&c.jsx(rS,{result:T[F.name]})]})]},F.name))}),!!o?.removed.length&&c.jsxs("details",{className:"hub-mcp-removed",children:[c.jsxs("summary",{children:["已在当前工作区移除(",o.removed.length,")"]}),o.removed.map(F=>c.jsxs("div",{className:"hub-mcp-removed-row",children:[c.jsx("span",{children:F.name}),c.jsx("button",{className:"config-button config-button-quiet",disabled:te,onClick:()=>{L(we=>Tg(F.name,we),"已恢复继承的 MCP 配置。")},children:"恢复继承"})]},F.name))]}),c.jsx("p",{className:"config-help hub-mcp-explanation",children:"连接使用运行 CodeShell 的设备上的网络、环境和凭据。测试只建立一次短连接并读取工具列表,完成后关闭;不会调用工具或改变启用状态。"})]})}function zg({server:t,disabled:i,save:l,onDone:a,onProbe:o,onDirtyChange:f}){const u=w.useRef(t).current,[m,h]=w.useState(()=>$1(u)),p=w.useRef(JSON.stringify(m)).current,y=JSON.stringify(m)!==p;w.useEffect(()=>{f(y)},[y,f]),w.useEffect(()=>()=>f(!1),[f]);const[b,x]=w.useState(""),v=(N,A)=>h(R=>({...R,[N]:A})),j=K1(m,u),D=m.transport==="stdio";return c.jsx("form",{className:"hub-mcp-editor",onSubmit:async N=>{N.preventDefault(),x("");const A=N.nativeEvent.submitter?.getAttribute("data-probe")==="true";try{await l(R=>J1(m,u,R))&&(a(),A&&o(m.name.trim()))}catch(R){x(R instanceof Error?R.message:"请检查填写内容。")}},children:c.jsxs("fieldset",{disabled:i,children:[c.jsx("legend",{className:"config-sr-only",children:u?`编辑 MCP ${u.name}`:"新 MCP 服务"}),c.jsxs("div",{className:"config-form-grid",children:[c.jsxs("label",{children:[c.jsx("span",{children:"服务名称"}),c.jsx("input",{required:!0,readOnly:!!u,maxLength:128,pattern:"[A-Za-z0-9][A-Za-z0-9._:\\-]*",value:m.name,onChange:N=>v("name",N.target.value),placeholder:"例如 workspace-tools"})]}),c.jsxs("label",{children:[c.jsx("span",{children:"连接方式"}),c.jsxs("select",{"aria-label":"连接方式",value:m.transport,onChange:N=>v("transport",N.target.value),children:[c.jsx("option",{value:"stdio",children:"本地命令(stdio)"}),c.jsx("option",{value:"streamable-http",children:"HTTP(Streamable HTTP)"}),u?.transport==="sse"&&c.jsx("option",{value:"sse",children:"HTTP(已有 SSE 配置)"})]})]}),D?c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"启动命令"}),c.jsx("input",{required:!0,"aria-label":"启动命令",value:m.command,onChange:N=>v("command",N.target.value),placeholder:"例如 node、uvx 或可执行文件路径"}),c.jsx("small",{children:"在当前工作区执行。命令与参数分别填写。"})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"命令参数"}),c.jsx("textarea",{"aria-label":"命令参数",rows:3,disabled:m.clearArgs,value:m.args,onChange:N=>v("args",N.target.value),placeholder:u?.argsCount?`已有 ${u.argsCount} 个参数,留空保留。填写后将完整替换。`:"每行一个参数,不需要额外添加引号",autoComplete:"off",spellCheck:!1}),c.jsx("small",{children:"参数可能含密钥,因此不会读回已有值。每一行会作为一个完整参数。"})]}),!!u?.argsCount&&c.jsxs("label",{className:"hub-mcp-check config-full-width",children:[c.jsx("input",{type:"checkbox",checked:m.clearArgs,onChange:N=>v("clearArgs",N.target.checked)}),c.jsx("span",{children:"清空已保存的所有参数"})]})]}):c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"MCP 接口地址"}),c.jsx("input",{type:"url","aria-label":"MCP 接口地址",required:!0,value:m.url,onChange:N=>v("url",N.target.value),placeholder:"https://example.com/mcp"}),u?.urlHasHiddenParts&&c.jsx("small",{children:"已有地址的查询参数已隐藏;不修改地址时会保留。"})]})]}),D?c.jsx(Bc,{title:"环境变量",rows:m.env,onChange:N=>v("env",N)}):c.jsx(Bc,{title:"请求头",rows:m.headers,onChange:N=>v("headers",N)}),c.jsxs("details",{className:"hub-mcp-advanced",children:[c.jsx("summary",{children:"高级配置"}),c.jsx("div",{className:"config-form-grid",children:D?c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"转发运行环境变量"}),c.jsx("textarea",{"aria-label":"转发运行环境变量",rows:2,value:m.envVars,onChange:N=>v("envVars",N.target.value),placeholder:"每行一个环境变量名称,例如 GITHUB_TOKEN"}),c.jsx("small",{children:"只填写名称,实际值在连接时从CodeShell 的启动环境读取。"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("label",{children:[c.jsx("span",{children:"Bearer Token 环境变量"}),c.jsx("input",{"aria-label":"Bearer Token 环境变量",value:m.bearerTokenEnvVar,onChange:N=>v("bearerTokenEnvVar",N.target.value),placeholder:"例如 MCP_ACCESS_TOKEN",autoComplete:"off"}),c.jsx("small",{children:"填写运行环境中的变量名称。"})]}),c.jsxs("label",{children:[c.jsx("span",{children:"已存储的凭据 ID"}),c.jsx("input",{"aria-label":"已存储的凭据 ID",value:m.credentialRef,onChange:N=>v("credentialRef",N.target.value),placeholder:"可选",autoComplete:"off"}),c.jsx("small",{children:"引用已有凭据;优先于 Bearer 环境变量。"})]})]})}),!D&&c.jsx(Bc,{title:"环境变量请求头",rows:m.envHeaders,onChange:N=>v("envHeaders",N),visibleValues:!0}),c.jsxs("label",{className:"hub-mcp-check",children:[c.jsx("input",{type:"checkbox",checked:m.restrictTools,onChange:N=>v("restrictTools",N.target.checked)}),c.jsx("span",{children:"只允许指定工具"})]}),c.jsxs("div",{className:"config-form-grid",children:[m.restrictTools&&c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"允许的工具名称"}),c.jsx("textarea",{rows:2,value:m.allowedTools,onChange:N=>v("allowedTools",N.target.value),placeholder:"每行一个精确工具名称;留空则不开放任何工具"})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"停用的工具名称"}),c.jsx("textarea",{rows:2,value:m.disabledTools,onChange:N=>v("disabledTools",N.target.value),placeholder:"每行一个精确工具名称,可留空"})]})]})]}),c.jsxs("label",{className:"hub-mcp-check",children:[c.jsx("input",{type:"checkbox",checked:m.enabled,onChange:N=>v("enabled",N.target.checked)}),c.jsx("span",{children:"启用服务,让任务可以使用这些工具"})]}),j&&c.jsxs("label",{className:"hub-mcp-check hub-mcp-reuse",children:[c.jsx("input",{type:"checkbox",required:!0,checked:m.reuseStoredSecrets,onChange:N=>v("reuseStoredSecrets",N.target.checked)}),c.jsx("span",{children:"允许新的启动方式或服务地址使用已保存的参数、环境变量和认证配置。"})]}),b&&c.jsx("p",{className:"config-error config-message",role:"alert",children:b}),c.jsxs("div",{className:"config-form-actions",children:[c.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:a,children:"取消"}),c.jsx("button",{type:"submit","data-probe":"true",className:"config-button",children:"保存并测试"}),c.jsx("button",{type:"submit",className:"config-button config-button-primary",children:"保存配置"})]})]})})}function Bc({title:t,rows:i,onChange:l,visibleValues:a=!1}){const o=(f,u)=>l(i.map(m=>m.id===f?{...m,...u}:m));return c.jsxs("div",{className:"hub-mcp-keys",children:[c.jsxs("div",{className:"hub-mcp-key-heading",children:[c.jsx("h3",{children:t}),c.jsxs("button",{className:"config-text-button",type:"button",onClick:()=>l([...i,{id:Ea(),name:"",value:"",stored:!1,removed:!1}]),children:["+ 添加",t]})]}),!i.length&&c.jsx("p",{className:"config-help",children:a?"可按请求头名称引用运行环境变量。":"无需此项时可以留空。"}),i.map(f=>c.jsxs("div",{className:`hub-mcp-key-row${f.removed?" hub-mcp-key-removed":""}`,children:[c.jsxs("label",{children:[c.jsxs("span",{className:"config-sr-only",children:[t,"名称"]}),c.jsx("input",{"aria-label":`${t}名称`,value:f.name,readOnly:f.stored,disabled:f.removed,onChange:u=>o(f.id,{name:u.target.value}),placeholder:t==="环境变量"?"例如 API_KEY":"例如 Authorization",autoComplete:"off"})]}),c.jsxs("label",{children:[c.jsxs("span",{className:"config-sr-only",children:[t,"值"]}),c.jsx("input",{"aria-label":`${t} ${f.name||"新条目"} 的值`,type:a?"text":"password",value:f.value,disabled:f.removed,onChange:u=>o(f.id,{value:u.target.value}),placeholder:f.removed?"保存时移除":a?"运行环境变量名称":f.stored?"已配置 · 留空保留":"输入值",autoComplete:a?"off":"new-password",spellCheck:!1})]}),c.jsx("button",{className:"config-button config-button-quiet",type:"button",onClick:()=>f.stored?o(f.id,{removed:!f.removed}):l(i.filter(u=>u.id!==f.id)),children:f.removed?"撤销移除":"移除"})]},f.id)),!!i.length&&!a&&c.jsx("p",{className:"config-help",children:"已有值保留在运行 CodeShell 的设备上;留空保留,填写新值替换,点击“移除”后保存才能删除。"})]})}function rS({result:t}){return c.jsxs("div",{className:`hub-mcp-probe-result hub-mcp-probe-${t.status}`,role:"status",children:[c.jsxs("div",{className:"hub-mcp-probe-summary",children:[c.jsx("strong",{children:t.status==="ok"?"测试连接成功":t.status==="cancelled"?"测试已取消":"连接测试失败"}),c.jsxs("span",{children:[new Date(t.checkedAt).toLocaleTimeString()," ·"," ",t.durationMs<1e3?`${t.durationMs} ms`:`${(t.durationMs/1e3).toFixed(1)} 秒`]})]}),t.error&&c.jsx("p",{children:t.error.message}),t.status==="ok"&&c.jsxs(c.Fragment,{children:[c.jsxs("p",{children:["发现 ",t.toolCount??0," 个工具",t.truncated?"(列表已截取)":"","。测试连接现已关闭。"]}),!!t.tools?.length&&c.jsxs("details",{children:[c.jsx("summary",{children:"查看工具列表"}),c.jsx("ul",{children:t.tools.map((i,l)=>c.jsxs("li",{children:[c.jsxs("div",{children:[c.jsx("code",{children:i.name}),!i.allowed&&c.jsx("span",{className:"config-badge",children:"被工具策略停用"})]}),i.description&&c.jsx("p",{children:i.description})]},`${i.name}-${l}`))})]})]})]})}const lS={overview:{title:"设置",description:"管理当前工作区的模型、Skills 和工具连接。"},models:{title:"模型与连接",description:"选择默认模型,管理工作区使用的服务商连接与凭据。"},skills:{title:"Skills",description:"让 CodeShell 按照你熟悉的工作方式完成任务。"},mcp:{title:"MCP 工具",description:"管理工具连接,测试连接并查看可用工具。"}};function aS(t){return t.section==="skills"?c.jsx(Y1,{onAuthLost:t.onAuthLost,onDirtyChange:t.onDirtyChange,onChanged:t.onConfigurationChange,configurationVersion:t.configurationVersion}):c.jsx(sS,{...t})}function sS({host:t="hub",section:i,onSectionChange:l,onAuthLost:a,onDirtyChange:o,onConfigurationChange:f,configurationVersion:u=0}){const[m,h]=w.useState(null),[p,y]=w.useState(!0),[b,x]=w.useState(""),[v,j]=w.useState(""),[D,N]=w.useState(null),[A,R]=w.useState(0),O=w.useRef({onAuthLost:a,onConfigurationChange:f});O.current={onAuthLost:a,onConfigurationChange:f};const Y=w.useRef(!1),re=w.useRef(0),T=w.useRef(null),V=w.useRef(null),Q=w.useRef(!1),I=w.useRef(u),C=w.useCallback($=>{$ instanceof Pe&&$.status===401?O.current.onAuthLost():x(xb($))},[]);w.useEffect(()=>{u!==I.current&&(I.current=u,V.current?Q.current=!0:R($=>$+1))},[u]),w.useEffect(()=>(Y.current=!0,()=>{Y.current=!1,V.current?.abort()}),[]),w.useEffect(()=>{const $=new AbortController;T.current=$;const ee=++re.current;return y(!0),x(""),vb($.signal).then(K=>{!$.signal.aborted&&ee===re.current&&h(K)}).catch(K=>{!$.signal.aborted&&ee===re.current&&C(K)}).finally(()=>{!$.signal.aborted&&ee===re.current&&y(!1)}),()=>$.abort()},[A,C]);const B=async($,ee)=>{if(V.current)return!1;T.current?.abort();const K=++re.current,z=new AbortController;V.current=z,y(!1),N($),x(""),j("");try{const Z=await ee(z.signal);return!Y.current||z.signal.aborted||K!==re.current?!1:(h(Z),j(Z.restartRequired?"设置已保存,重启服务后生效。":"设置已保存,下次运行任务时生效。"),O.current.onConfigurationChange?.(),!0)}catch(Z){return Z instanceof Pe&&Z.status===409&&(Q.current=!0),Y.current&&!z.signal.aborted&&C(Z),!1}finally{V.current===z&&(V.current=null),Y.current&&!z.signal.aborted&&(N(null),Q.current&&(Q.current=!1,R(Z=>Z+1)))}},U=lS[i];return c.jsxs("section",{className:"hub-settings","aria-labelledby":"hub-settings-title",children:[c.jsxs("div",{className:"hub-settings-heading",children:[c.jsxs("div",{children:[c.jsx("span",{className:"hub-settings-eyebrow",children:t==="desktop"?"桌面工作区":"服务端工作区"}),c.jsx("h1",{id:"hub-settings-title",children:U.title}),c.jsx("p",{children:U.description})]}),c.jsx("button",{className:"config-button config-button-quiet",disabled:p||D!==null,onClick:()=>{j(""),R($=>$+1)},children:p?"读取中…":"刷新"})]}),b&&c.jsx("div",{className:"config-message config-error",role:"alert",children:b}),v&&c.jsx("div",{className:"config-message config-success",role:"status",children:v}),D&&c.jsxs("p",{className:"config-loading",role:"status",children:["正在保存",D,"…"]}),!m&&p?c.jsx("p",{className:"config-loading",role:"status",children:"正在读取工作区设置…"}):null,m&&c.jsxs(c.Fragment,{children:[i==="overview"&&c.jsx(oS,{host:t,configuration:m,onSectionChange:l}),i==="models"&&c.jsx(uS,{configuration:m,disabled:D!==null||p,saving:D!==null,save:B,onDirtyChange:o,onAuthLost:a}),i==="mcp"&&c.jsx(iS,{onAuthLost:a,onDirtyChange:o,onConfigurationChange:f,configurationVersion:u}),c.jsx("p",{className:"config-scope-note",children:"配置作用于当前工作区,所有连接到这里的设备共用。"})]})]})}function oS({host:t,configuration:i,onSectionChange:l}){const a=i.connections.find(u=>u.id===i.defaults.text),o=i.skills.filter(u=>u.enabled).length,f=[{section:"models",title:"模型与连接",summary:a?`${a.id} · ${a.model}`:"尚未设置默认模型",icon:"◈"},{section:"skills",title:"Skills",summary:`${i.skills.length} 个可用 · ${o} 个已启用`,icon:"✧"},{section:"mcp",title:"MCP 工具",summary:`${i.mcpServers.length} 个已配置的工具服务`,icon:"⌘"}];return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"config-workspace-card",children:[c.jsx("span",{className:"config-workspace-icon","aria-hidden":"true",children:"▱"}),c.jsxs("div",{children:[c.jsx("strong",{children:"当前工作区"}),c.jsx("code",{children:i.workspace.path}),c.jsx("p",{children:t==="desktop"?"对话、文件操作和工具都由已连接的桌面端执行。":"对话、文件操作和工具都在服务端运行。"})]}),c.jsx("span",{className:"config-badge",children:t==="desktop"?"桌面工作区":"服务端工作区"})]}),c.jsx("h2",{className:"config-section-title",children:"工作区配置"}),c.jsx("div",{className:"config-card config-overview-list",children:f.map(u=>{const m=c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:u.icon}),c.jsxs("span",{className:"config-row-copy",children:[c.jsx("strong",{children:u.title}),c.jsx("span",{children:u.summary})]}),l&&c.jsx("span",{className:"config-chevron","aria-hidden":"true",children:"›"})]});return l?c.jsx("button",{className:"config-overview-row",onClick:()=>l(u.section),children:m},u.section):c.jsx("div",{className:"config-overview-row",children:m},u.section)})}),c.jsxs("div",{className:"config-explanation",children:[c.jsx("h2",{children:"工作区与执行位置"}),c.jsx("p",{children:t==="desktop"?"这里直接使用桌面端的任务、模型、Skills 和工具连接。修改配置后,桌面窗口和已配对的网页共同使用。":"这里使用服务端的任务、模型、Skills 和工具连接。修改配置后,连接到这个服务端的网页共同使用。"}),c.jsx("p",{children:t==="desktop"?"切换项目会切换对应的文件、历史和工作区设置;无需复制桌面配置。":"独立部署使用自己的运行环境。部署到另一台机器时,需要迁移配置和数据,或在这里重新设置。"})]})]})}function uS({configuration:t,disabled:i,saving:l,save:a,onDirtyChange:o,onAuthLost:f}){const[u,m]=w.useState(null),[h,p]=w.useState(null),[y,b]=w.useState(""),[x,v]=w.useState(!1),[j,D]=w.useState(!1),[N,A]=w.useState(null),[R,O]=w.useState({}),Y=w.useRef(null),re=t.connections.filter(C=>C.tag==="text"),T=t.connections.length-re.length,V=i||!!N;w.useEffect(()=>{h&&!t.connections.some(C=>C.id===h.id)&&p(null)},[t.connections,h]),w.useEffect(()=>()=>Y.current?.abort(),[]);const Q=w.useRef(new Map);w.useEffect(()=>{const C=new Map(t.connections.map(U=>[U.id,U.revision??JSON.stringify(U)])),B=new Set([...Q.current].filter(([U,$])=>C.get(U)!==$).map(([U])=>U));Q.current=C,N&&B.has(N)&&Y.current?.abort(),B.size&&O(U=>Object.fromEntries(Object.entries(U).filter(([$])=>!B.has($))))},[t,N]),w.useEffect(()=>(o?.(x||j||l||!!N),()=>o?.(!1)),[x,j,l,N,o]);const I=async C=>{if(Y.current)return;const B=new AbortController;Y.current=B,A(C.id),O(U=>({...U,[C.id]:"正在发送一条简短测试请求…"}));try{const U=await _1(C.id,B.signal);B.signal.aborted||O($=>({...$,[C.id]:U}))}catch(U){B.signal.aborted||(U instanceof Pe&&U.status===401?f():O($=>({...$,[C.id]:xb(U)})))}finally{Y.current===B&&(Y.current=null,A(null))}};return c.jsxs(c.Fragment,{children:[c.jsx(cS,{configuration:t,disabled:V,save:a,onDirtyChange:D}),c.jsxs("div",{className:"config-section-heading",children:[c.jsxs("h2",{children:["文字模型连接 ",c.jsx("span",{className:"config-count",children:re.length})]}),c.jsxs("button",{className:"config-button",disabled:V||u!==null||h!==null||!t.catalog.length,onClick:()=>m("__new__"),children:[c.jsx("span",{"aria-hidden":"true",children:"+"})," 添加连接"]})]}),u!==null&&c.jsxs("div",{className:"config-card config-editor-card",children:[c.jsx("h3",{children:u==="__new__"?"添加模型连接":`编辑 ${u.id}`}),c.jsx(fS,{connection:u==="__new__"?void 0:u,configuration:t,disabled:V,save:a,onDone:()=>m(null),onDirtyChange:v},u==="__new__"?"new":u.id)]}),!re.length&&u!=="__new__"&&c.jsx(dS,{title:"还没有文字模型连接",description:"添加服务商地址、模型名称和 API Key,再选择一个默认模型。"}),c.jsx("div",{className:"config-connection-list",children:re.map(C=>{const B=t.catalog.find(z=>z.id===C.catalogId),U=h?.id===C.id,$=U&&h?.revision!==C.revision,ee=t.defaults.text===C.id&&re.length>1,K=R[C.id];return c.jsxs("article",{className:"config-card config-connection-card",children:[c.jsxs("div",{className:"config-connection-head",children:[c.jsx("span",{className:"config-model-icon","aria-hidden":"true",children:"◈"}),c.jsxs("div",{className:"config-row-copy",children:[c.jsx("strong",{children:C.id}),c.jsx("span",{children:B?.displayName??C.catalogId})]}),t.defaults.text===C.id&&c.jsx("span",{className:"config-badge config-badge-accent",children:"默认"}),c.jsx("button",{className:"config-button config-button-quiet",disabled:V||u!==null||h!==null,onClick:()=>m(C),children:"编辑"})]}),c.jsxs("dl",{className:"config-connection-facts",children:[c.jsxs("div",{children:[c.jsx("dt",{children:"模型"}),c.jsx("dd",{children:C.model||"未填写"})]}),c.jsxs("div",{children:[c.jsx("dt",{children:"服务地址"}),c.jsx("dd",{children:C.baseUrl||B?.defaultBaseUrl||"服务商默认地址"})]}),c.jsxs("div",{children:[c.jsx("dt",{children:"API Key"}),c.jsx("dd",{children:C.hasApiKey?"•••••••• · 已配置":C.needsKey?"未配置":"无需 API Key"})]})]}),c.jsxs("div",{className:"config-model-actions",children:[N===C.id?c.jsx("button",{className:"config-button",onClick:()=>{Y.current?.abort(),O(z=>({...z,[C.id]:"已取消连接测试。"}))},children:"取消测试"}):c.jsx("button",{className:"config-button",disabled:V||u!==null||h!==null,onClick:()=>{I(C)},children:"测试连接"}),c.jsx("span",{className:"config-help",children:"发送一条简短请求,服务商可能计费。"}),c.jsx("button",{className:"config-button config-button-quiet config-remove-connection",disabled:V||u!==null||h!==null,onClick:()=>{p(C),b("")},children:"删除"})]}),K&&c.jsxs("div",{className:`config-probe-result ${typeof K!="string"&&K.ok?"is-success":""}`,role:"status",children:[c.jsx("span",{children:typeof K=="string"?K:K.message}),typeof K!="string"&&c.jsxs("small",{children:[Math.max(.01,K.latencyMs/1e3).toFixed(2)," 秒 ·"," ",new Date(K.checkedAt).toLocaleTimeString()]})]}),U&&c.jsxs("div",{className:"config-remove-confirm",children:[c.jsxs("h3",{children:["删除连接 ",C.id,"?"]}),c.jsx("p",{children:"连接会从当前工作区移除,已有对话记录会保留。"}),$&&c.jsx("p",{role:"alert",children:"连接已被其他设备更新,请取消后重新检查再删除。"}),re.length===1&&c.jsx("p",{children:"这是最后一个文字模型连接。删除后需重新添加连接才能继续对话。"}),ee&&c.jsxs("label",{children:[c.jsx("span",{children:"替代默认模型"}),c.jsxs("select",{"aria-label":"替代默认模型",value:y,onChange:z=>b(z.target.value),disabled:V,children:[c.jsx("option",{value:"",children:"请选择其他连接"}),re.filter(z=>z.id!==C.id).map(z=>c.jsxs("option",{value:z.id,children:[z.id," · ",z.model]},z.id))]})]}),c.jsxs("div",{className:"config-form-actions",children:[c.jsx("button",{className:"config-button",disabled:V,onClick:()=>p(null),children:"取消删除"}),c.jsx("button",{className:"config-button config-button-danger",disabled:V||$||ee&&!y,onClick:()=>{a("删除连接",z=>D1(C.id,y||void 0,z,h?.revision)).then(z=>{z&&p(null)})},children:"确认删除连接"})]})]})]},C.id)})}),T>0&&c.jsxs("p",{className:"config-help",children:["另有 ",T," 个其他类型的模型连接,保留在工作区配置中。目前此处提供文字模型编辑。"]})]})}function cS({configuration:t,disabled:i,save:l,onDirtyChange:a}){const[o,f]=w.useState(t.defaults.text??""),[u,m]=w.useState(t.defaults.auxText??""),h=w.useRef(t.defaults);w.useEffect(()=>{const b=h.current;h.current=t.defaults,f(x=>x===(b.text??"")?t.defaults.text??"":x),m(x=>x===(b.auxText??"")?t.defaults.auxText??"":x)},[t.defaults]);const p=t.connections.filter(b=>b.tag==="text"),y=o!==(t.defaults.text??"")||u!==(t.defaults.auxText??"");return w.useEffect(()=>(a(y),()=>a(!1)),[y,a]),c.jsx("form",{className:"config-card config-defaults",onSubmit:b=>{b.preventDefault(),l("默认模型",x=>R1({text:o,auxText:u||null},x))},children:c.jsxs("fieldset",{disabled:i||!p.length,children:[c.jsx("legend",{children:"默认模型"}),c.jsxs("div",{className:"config-form-grid",children:[c.jsxs("label",{children:[c.jsx("span",{children:"对话模型"}),c.jsxs("select",{required:!0,value:o,onChange:b=>f(b.target.value),"aria-label":"默认对话模型",children:[c.jsx("option",{value:"",disabled:!0,children:"选择模型连接"}),o&&!p.some(b=>b.id===o)&&c.jsxs("option",{value:o,disabled:!0,children:[o,"(连接不可用)"]}),p.map(b=>c.jsxs("option",{value:b.id,children:[b.id," · ",b.model]},b.id))]})]}),c.jsxs("label",{children:[c.jsx("span",{children:"辅助模型"}),c.jsxs("select",{value:u,onChange:b=>m(b.target.value),"aria-label":"默认辅助模型",children:[c.jsx("option",{value:"",children:"跟随对话模型"}),u&&!p.some(b=>b.id===u)&&c.jsxs("option",{value:u,disabled:!0,children:[u,"(连接不可用)"]}),p.map(b=>c.jsxs("option",{value:b.id,children:[b.id," · ",b.model]},b.id))]})]})]}),c.jsxs("div",{className:"config-form-footer",children:[c.jsx("p",{className:"config-help",children:"辅助模型用于标题生成等轻量任务。"}),c.jsx("button",{className:"config-button",disabled:!y||!o,type:"submit",children:"保存默认模型"})]})]})})}function fS({connection:t,configuration:i,disabled:l,save:a,onDone:o,onDirtyChange:f}){const[u,m]=w.useState(()=>{const R=Oc(t);return t||(R.catalogId=i.catalog[0]?.id??""),R}),h=w.useRef(u),p=JSON.stringify(u)!==JSON.stringify(h.current),[y,b]=w.useState(!1),x=t?i.connections.find(R=>R.id===t.id):void 0,v=!!t&&(!x||u.expectedRevision!==x.revision);w.useEffect(()=>{if(!p&&x&&u.expectedRevision!==x.revision){const R=Oc(x);h.current=R,m(R)}},[p,x,u.expectedRevision]);const j=()=>{if(!x)return;const R=Oc(x);h.current=R,m(R),b(!1)};w.useEffect(()=>(f(p),()=>f(!1)),[p,f]);const D=i.catalog.find(R=>R.id===u.catalogId),N=!t&&i.connections.some(R=>R.id===u.id.trim()),A=(R,O)=>m(Y=>({...Y,[R]:O}));return c.jsx("form",{className:"config-connection-editor",onSubmit:async R=>{R.preventDefault(),!v&&await a("模型连接",O=>T1(u,O))&&o()},children:c.jsxs("fieldset",{disabled:l,children:[c.jsx("legend",{className:"config-sr-only",children:t?`编辑 ${t.id}`:"新模型连接"}),v&&c.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[c.jsx("p",{children:x?"其他设备已更新这个连接。你的草稿已保留,请检查最新设置后再保存。":"这个连接已被其他设备删除。草稿仍保留,你可以复制内容后关闭编辑。"}),x&&c.jsx("button",{className:"config-button",type:"button",onClick:j,children:"放弃草稿并载入最新设置"})]}),c.jsxs("div",{className:"config-form-grid",children:[c.jsxs("label",{children:[c.jsx("span",{children:"连接名称"}),c.jsx("input",{required:!0,maxLength:120,value:u.id,readOnly:!!t,onChange:R=>A("id",R.target.value),placeholder:"例如 work-model",autoComplete:"off"})]}),c.jsxs("label",{children:[c.jsx("span",{children:"服务商"}),c.jsxs("select",{required:!0,disabled:!!t,"aria-label":"服务商",value:u.catalogId,onChange:R=>A("catalogId",R.target.value),children:[t&&!D&&c.jsx("option",{value:u.catalogId,children:u.catalogId}),i.catalog.map(R=>c.jsx("option",{value:R.id,children:R.displayName},R.id))]})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"模型名称"}),c.jsx("input",{required:!0,maxLength:240,value:u.model,onChange:R=>A("model",R.target.value),placeholder:"服务商提供的模型 ID",autoComplete:"off"})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"服务地址"}),c.jsx("input",{type:"url","aria-label":"服务地址",value:u.baseUrl,onChange:R=>A("baseUrl",R.target.value),placeholder:D?.defaultBaseUrl||"使用服务商默认地址",autoComplete:"off"}),c.jsx("small",{children:"留空使用服务商默认地址,支持兼容接口。"})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsxs("span",{children:["API Key ",t?.hasApiKey&&c.jsx("span",{className:"config-field-meta",children:"已配置"})]}),c.jsx("input",{type:"password","aria-label":"API Key",required:D?.needsKey&&!t?.hasApiKey,value:u.apiKey,onChange:R=>A("apiKey",R.target.value),placeholder:t?.hasApiKey?"留空保留现有 API Key":D?.needsKey?"输入 API Key":"可选",autoComplete:"new-password",spellCheck:!1}),c.jsx("small",{children:t?.hasApiKey?"现有密钥保留在运行 CodeShell 的设备上,输入新值可替换。":"密钥保存在当前工作区配置中。"})]})]}),N&&c.jsx("p",{className:"config-error config-message",role:"alert",children:"连接名称已存在,请使用其他名称或编辑现有连接。"}),c.jsx("p",{className:"config-help",children:"保存后可在连接卡片中测试实际连接。"}),y&&c.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[c.jsx("p",{children:"还有未保存的修改,确定放弃?"}),c.jsxs("div",{className:"config-form-actions",children:[c.jsx("button",{type:"button",className:"config-button",onClick:()=>b(!1),children:"继续编辑"}),c.jsx("button",{type:"button",className:"config-button config-button-danger",onClick:o,children:"放弃修改"})]})]}),c.jsxs("div",{className:"config-form-actions",children:[c.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:()=>p?b(!0):o(),children:"取消"}),c.jsx("button",{type:"submit",className:"config-button config-button-primary",disabled:N||v,children:"保存连接"})]})]})})}function dS({title:t,description:i}){return c.jsxs("div",{className:"config-empty",children:[c.jsx("span",{"aria-hidden":"true",children:"◇"}),c.jsx("h3",{children:t}),c.jsx("p",{children:i})]})}function Uc(t,i=!1){return St(`/api/v1/files/content?path=${encodeURIComponent(t)}${i?"&inline=true":""}`)}function Dg(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function hS({initialPath:t,openVersion:i=0,onAuthLost:l}){const[a,o]=w.useState(""),[f,u]=w.useState(null),[m,h]=w.useState(null),[p,y]=w.useState(!1),[b,x]=w.useState(!1),[v,j]=w.useState(""),[D,N]=w.useState(0),[A,R]=w.useState(""),O=w.useRef(null),Y=w.useRef(l);Y.current=l;const re=w.useCallback(I=>{I instanceof Pe&&I.status===401?Y.current():j(I instanceof Error?I.message:"文件读取失败,请重试。")},[]);w.useEffect(()=>{const I=new AbortController;return y(!0),j(""),He(`/api/v1/files?path=${encodeURIComponent(a)}`,{signal:I.signal}).then(C=>{I.signal.aborted||u(C)}).catch(C=>{I.signal.aborted||re(C)}).finally(()=>{I.signal.aborted||y(!1)}),()=>I.abort()},[a,D,re]);const T=w.useCallback((I,C=!1)=>{O.current?.abort();const B=new AbortController;O.current=B,h(null),x(!0),j(""),He(`${Uc(I)}&preview=true`,{signal:B.signal}).then(U=>{B.signal.aborted||(C&&o(U.path.split("/").slice(0,-1).join("/")),h(U))}).catch(U=>{B.signal.aborted||re(U)}).finally(()=>{B.signal.aborted||x(!1)})},[re]);w.useEffect(()=>{t&&T(t,!0)},[t,i,T]),w.useEffect(()=>()=>O.current?.abort(),[]);const V=I=>{O.current?.abort(),x(!1),h(null),o(I),R("")},Q=f?.files.filter(I=>I.name.toLocaleLowerCase().includes(A.toLocaleLowerCase()))??[];return c.jsxs("section",{className:"hub-library hub-files","aria-labelledby":"hub-files-heading",children:[c.jsxs("header",{className:"library-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{id:"hub-files-heading",children:"工作区文件"}),c.jsx("p",{children:"查看任务生成的内容,下载到当前设备。"})]}),c.jsx("button",{className:"library-button",onClick:()=>{N(I=>I+1),m&&T(m.path)},children:"刷新"})]}),v?c.jsx("div",{className:"library-error",role:"alert",children:v}):null,c.jsxs("nav",{className:"file-breadcrumbs","aria-label":"文件位置",children:[c.jsx("button",{onClick:()=>V(""),children:"工作区"}),(f?.path??a).split("/").filter(Boolean).map((I,C,B)=>c.jsxs(w.Fragment,{children:[c.jsx("span",{"aria-hidden":"true",children:"/"}),c.jsx("button",{onClick:()=>V(B.slice(0,C+1).join("/")),children:I})]},C))]}),c.jsxs("div",{className:`file-columns${m||b?" has-preview":""}`,children:[c.jsxs("div",{className:"file-directory",children:[c.jsxs("label",{className:"library-search",children:[c.jsx("span",{className:"sr-only",children:"筛选当前文件夹"}),c.jsx("input",{type:"search",placeholder:"筛选当前文件夹…",value:A,onChange:I=>R(I.target.value)})]}),c.jsx("div",{className:"file-entries","aria-busy":p,children:p?c.jsx("p",{className:"library-empty",role:"status",children:"正在读取文件…"}):Q.length===0?c.jsx("p",{className:"library-empty",children:A?"没有匹配的文件。":"这个文件夹还没有文件。"}):Q.map(I=>c.jsxs("button",{className:`file-entry${m?.path===I.path?" selected":""}`,onClick:()=>I.kind==="directory"?V(I.path):T(I.path),children:[c.jsx("span",{className:"file-glyph","aria-hidden":"true",children:I.kind==="directory"?"▱":"▤"}),c.jsx("span",{className:"file-entry-name",children:I.name}),c.jsx("span",{className:"file-entry-size",children:I.kind==="directory"?"文件夹":Dg(I.size)})]},I.path))}),f?.truncated?c.jsx("p",{className:"library-hint",children:"这里只显示前 500 项。可以进入子文件夹继续查看。"}):null]}),b||m?c.jsxs("article",{className:"file-preview","aria-label":"文件预览",children:[c.jsxs("header",{children:[c.jsxs("div",{children:[c.jsx("strong",{children:m?.name??"正在打开…"}),m?c.jsx("span",{children:Dg(m.size)}):null]}),c.jsxs("div",{className:"library-actions",children:[m?c.jsx("a",{className:"library-button",href:Uc(m.path),download:!0,children:"下载"}):null,c.jsx("button",{className:"library-button",onClick:()=>{O.current?.abort(),x(!1),h(null)},children:"关闭预览"})]})]}),b?c.jsx("p",{className:"library-empty",role:"status",children:"正在读取内容…"}):m?.kind==="text"?c.jsxs(c.Fragment,{children:[c.jsx("pre",{tabIndex:0,children:m.content}),m.truncated?c.jsx("p",{className:"library-hint",children:"预览显示前 512 KB,下载可获取完整内容。"}):null]}):m?.kind==="image"?c.jsx("img",{src:Uc(m.path,!0),alt:m.name,onError:()=>j("图片无法预览,可以下载后打开。")}):c.jsx("div",{className:"library-empty",children:"这个文件暂不支持直接预览,可以下载后打开。"})]}):null]})]})}async function _f(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),He(`/api/v1/sessions?${i}`,{signal:t.signal})}function _g(t,i="markdown"){return St(`/api/v1/sessions/${encodeURIComponent(t)}/export?format=${i}`)}function pS({onAuthLost:t,onOpen:i,onChanged:l,version:a=0,onDirtyChange:o}){const[f,u]=w.useState(""),[m,h]=w.useState(""),[p,y]=w.useState("false"),[b,x]=w.useState([]),[v,j]=w.useState(null),[D,N]=w.useState(!0),[A,R]=w.useState(!1),[O,Y]=w.useState(""),[re,T]=w.useState(""),[V,Q]=w.useState(0),[I,C]=w.useState(""),[B,U]=w.useState(null),$=w.useRef(null),ee=w.useRef(null),K=w.useRef(null),z=w.useRef(null);w.useEffect(()=>{B?.id&&$.current?.focus()},[B?.id]),w.useEffect(()=>{B?.error&&ee.current?.focus()},[B?.error]);const Z=()=>{U(null),requestAnimationFrame(()=>{K.current?.isConnected?K.current.focus():z.current?.focus()})};w.useEffect(()=>{o?.(!!B||!!I)},[B,I,o]),w.useEffect(()=>()=>o?.(!1),[o]);const he=w.useRef(null),me=w.useRef(null),k=w.useRef({onAuthLost:t,onChanged:l,onOpen:i});k.current={onAuthLost:t,onChanged:l,onOpen:i};const L=w.useCallback(ae=>{ae instanceof Pe&&ae.status===401?k.current.onAuthLost():Y(ae instanceof Error?ae.message:"会话操作失败,请重试。")},[]);w.useEffect(()=>{const ae=setTimeout(()=>h(f.trim()),200);return()=>clearTimeout(ae)},[f]),w.useEffect(()=>{he.current?.abort();const ae=new AbortController;return he.current=ae,N(!0),R(!1),Y(""),_f({query:m,archived:p,signal:ae.signal}).then(se=>{ae.signal.aborted||(x(se.sessions),j(se.nextCursor))}).catch(se=>{ae.signal.aborted||L(se)}).finally(()=>{ae.signal.aborted||N(!1)}),()=>ae.abort()},[m,p,a,V,L]),w.useEffect(()=>()=>{he.current?.abort(),me.current?.abort()},[]);const J=()=>{if(!v||A||D)return;const ae=new AbortController;he.current?.abort(),he.current=ae,R(!0),_f({query:m,archived:p,cursor:v,signal:ae.signal}).then(se=>{ae.signal.aborted||(x(ye=>{const F=new Set(ye.map(we=>we.sessionId));return[...ye,...se.sessions.filter(we=>!F.has(we.sessionId))]}),j(se.nextCursor))}).catch(se=>{ae.signal.aborted||L(se)}).finally(()=>{ae.signal.aborted||R(!1)})},_=async(ae,se,ye=!1)=>{if(me.current)return;const F=new AbortController;me.current=F,C(ae),Y(""),T(""),"title"in se&&U(we=>we&&{...we,error:""});try{if(await He(`/api/v1/sessions/${encodeURIComponent(ae)}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(se),signal:F.signal}),F.signal.aborted)return;"title"in se?(Z(),T(se.title?"标题已保存。":"已恢复自动标题。")):T(se.archived?"对话已归档,可以在“已归档”中恢复。":"对话已恢复。"),Q(we=>we+1),k.current.onChanged?.(),ye&&k.current.onOpen(ae)}catch(we){F.signal.aborted||("title"in se&&!(we instanceof Pe&&we.status===401)?U(Le=>Le?.id===ae?{...Le,error:we instanceof Error?we.message:"标题保存失败,请重试。",conflict:we instanceof Pe&&we.status===409,unavailable:we instanceof Pe&&we.status===404}:Le):L(we))}finally{me.current===F&&(me.current=null),F.signal.aborted||C("")}},te=async()=>{if(!B||me.current)return;const ae=B.id,se=new AbortController;me.current=se,C(ae),U(ye=>ye&&{...ye,error:""});try{const ye=await He(`/api/v1/sessions/${encodeURIComponent(ae)}`,{signal:se.signal});if(se.signal.aborted)return;U(F=>F?.id===ae?{...F,expectedTitle:ye.customTitle,reviewedTitle:ye.title,conflict:!1,unavailable:!1,error:""}:F),$.current?.focus()}catch(ye){se.signal.aborted||(ye instanceof Pe&&ye.status===401?L(ye):U(F=>F?.id===ae?{...F,error:ye instanceof Error?ye.message:"无法读取最新标题,请重试。",unavailable:ye instanceof Pe&&ye.status===404}:F))}finally{me.current===se&&(me.current=null),se.signal.aborted||C("")}},xe=ae=>ae.archivedAt?void _(ae.sessionId,{archived:!1},!0):k.current.onOpen(ae.sessionId);return c.jsxs("section",{className:"hub-library hub-sessions","aria-labelledby":"hub-history-heading",children:[c.jsxs("header",{className:"library-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{id:"hub-history-heading",children:"历史对话"}),c.jsx("p",{children:"查找、整理并导出当前工作区的对话。"})]}),c.jsx("button",{className:"library-button",onClick:()=>Q(ae=>ae+1),children:"刷新"})]}),O?c.jsx("div",{className:"library-error",role:"alert",children:O}):null,re?c.jsx("p",{className:"library-hint",role:"status",children:re}):null,c.jsxs("div",{className:"session-toolbar",children:[c.jsxs("label",{className:"library-search",children:[c.jsx("span",{className:"sr-only",children:"搜索对话标题"}),c.jsx("input",{ref:z,type:"search",placeholder:"搜索对话标题…",value:f,onChange:ae=>u(ae.target.value)})]}),c.jsxs("label",{children:[c.jsx("span",{className:"sr-only",children:"对话范围"}),c.jsxs("select",{value:p,onChange:ae=>y(ae.target.value),children:[c.jsx("option",{value:"false",children:"当前对话"}),c.jsx("option",{value:"true",children:"已归档"}),c.jsx("option",{value:"all",children:"全部对话"})]})]})]}),B?c.jsxs("form",{className:"session-history-editor","aria-labelledby":"session-title-editor-heading",onSubmit:ae=>{ae.preventDefault(),!I&&!B.conflict&&!B.unavailable&&_(B.id,{title:B.title,expectedTitle:B.expectedTitle})},children:[c.jsxs("div",{children:[c.jsx("h2",{id:"session-title-editor-heading",children:"重命名对话"}),c.jsxs("p",{className:"library-hint",children:["正在编辑:",B.originalTitle]}),!D&&!b.some(ae=>ae.sessionId===B.id)?c.jsx("p",{className:"library-hint",children:"此对话已不在当前列表中,标题草稿仍保留在这里。"}):null]}),B.error?c.jsx("div",{className:"library-error",id:"session-title-error",role:"alert",tabIndex:-1,ref:ee,children:B.error}):null,B.reviewedTitle?c.jsxs("p",{className:"session-title-review",role:"status",children:["最新标题:",c.jsx("strong",{children:B.reviewedTitle}),"。你的草稿仍保留,请核对后再保存。"]}):null,c.jsxs("label",{children:[c.jsx("span",{children:"对话标题"}),c.jsx("input",{ref:$,className:"library-title-input",value:B.title,maxLength:1024,"aria-describedby":B.error?"session-title-error":void 0,onChange:ae=>{const se=ae.target.value;U(ye=>ye&&{...ye,title:se})},readOnly:!!I})]}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{type:"submit",className:"library-button primary",disabled:!!I||B.conflict||B.unavailable,children:I?"处理中…":B.reviewedTitle?"确认保存我的标题":"保存标题"}),B.conflict||B.unavailable?c.jsx("button",{type:"button",className:"library-button",disabled:!!I,onClick:()=>{te()},children:"读取最新标题"}):null,c.jsx("button",{type:"button",className:"library-button",disabled:!!I,onClick:Z,children:"取消"}),B.expectedTitle?c.jsx("button",{type:"button",className:"library-button",disabled:!!I||B.conflict||B.unavailable,onClick:()=>{_(B.id,{title:"",expectedTitle:B.expectedTitle})},children:"使用自动标题"}):null]})]}):null,c.jsx("div",{className:"session-history-list","aria-busy":D,children:D?c.jsx("p",{className:"library-empty",role:"status",children:"正在读取对话…"}):b.length===0?c.jsx("p",{className:"library-empty",children:m?"没有找到匹配的对话。":p==="true"?"还没有归档的对话。":"还没有保存的对话,开始一条新对话后会显示在这里。"}):b.map(ae=>c.jsxs("article",{className:"session-history-row",children:[c.jsxs("div",{className:"session-history-info",children:[c.jsx("button",{className:"session-history-title",onClick:()=>xe(ae),children:ae.title}),ae.preview&&ae.preview!==ae.title?c.jsx("p",{children:ae.preview.slice(0,150)}):null,c.jsxs("div",{className:"session-history-meta",children:[c.jsx("span",{children:new Date(ae.lastActiveAt||ae.startedAt).toLocaleString()}),c.jsxs("span",{children:[ae.turnCount," 轮"]}),ae.running?c.jsx("span",{children:"正在运行"}):ae.archivedAt?c.jsx("span",{children:"已归档"}):null]})]}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button",disabled:!!I||!!B,onClick:se=>{K.current=se.currentTarget,T(""),U({id:ae.sessionId,title:ae.title,originalTitle:ae.title,expectedTitle:ae.customTitle})},children:B?.id===ae.sessionId?"正在编辑":"重命名"}),c.jsx("button",{className:"library-button",disabled:!!I||ae.running,onClick:()=>{_(ae.sessionId,{archived:!ae.archivedAt})},children:I===ae.sessionId?"处理中…":ae.archivedAt?"恢复":"归档"}),ae.running?c.jsx("button",{className:"library-button",disabled:!0,children:"运行结束后导出"}):c.jsxs("details",{className:"session-export",children:[c.jsx("summary",{className:"library-button",children:"导出"}),c.jsxs("div",{children:[c.jsx("a",{href:_g(ae.sessionId),download:!0,children:"Markdown 文档"}),c.jsx("a",{href:_g(ae.sessionId,"json"),download:!0,children:"完整 JSON 记录"})]})]})]})]},ae.sessionId))}),v&&!D?c.jsx("div",{className:"session-load-more",children:c.jsx("button",{className:"library-button",disabled:A,onClick:J,children:A?"读取中…":"加载更多"})}):null]})}var mS=mb();function lo(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ws(t){return typeof t=="string"?t:""}function wb(t){return Array.isArray(t)?t.map(lo).filter(i=>i!==void 0):[]}function gS(t){return typeof t=="string"?t:wb(t).filter(i=>i.type==="text").map(i=>Ws(i.text)).join("")}function sa(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function Ic(t){const i=t.replace(/\\/g,"/").split("/").filter(Boolean).pop()||"附件";return t.includes(".code-shell/attachments/")?i.replace(/^[a-f0-9]{16}-/,""):i}function qc(t){const i=typeof t=="number"?t:Number(t);return Number.isSafeInteger(i)&&i>=0?i:0}function jb(t,i={}){const l=[],a=h=>/^(?:[a-zA-Z]:[\\/]|[\\/])/.test(h)||!i.cwd?h:`${i.cwd.replace(/[\\/]$/,"")}/${h}`,o=[];let f=gS(t.content);f=f.replace(/<attached-file\s+path="([^"]*)">\s*([\s\S]*?)<\/attached-file>/g,(h,p,y)=>{if(!/^absolutePath:\s*.+$/m.test(y)||!/^origin:\s*.+$/m.test(y))return h;const b=y.match(/^mime:\s*(.+)$/m)?.[1]?.trim();return l.push({name:Ic(sa(p)),path:sa(p),...i.includeAbsolutePaths?{absPath:y.match(/^absolutePath:\s*(.+)$/m)[1].trim()}:{},size:qc(y.match(/^size:\s*(\d+)\s*$/m)?.[1]),...b?{mime:b}:{}}),""}),f=f.replace(/<attached-directory\s+path="([^"]*)"[^>]*>[\s\S]*?<\/attached-directory>/g,(h,p)=>(l.push({name:`${Ic(sa(p))}/`,path:sa(p),...i.includeAbsolutePaths?{absPath:a(sa(p))}:{},size:0}),"")),f=f.replace(/<attached-image-paths>\s*([\s\S]*?)<\/attached-image-paths>\s*(?:\(上面附带的图片在工作区的真实路径[^\n]*\))?/g,(h,p)=>(o.push(...p.split(`
|
|
21
|
-
`).map(y=>y.trim()).filter(Boolean)),""));const u=wb(t.content).filter(h=>h.type==="image");for(let h=0;h<Math.max(u.length,o.length);h++){const p=lo(u[h]?.source),y=Ws(p?.data).replace(/\s/g,"");l.push({name:o[h]?Ic(o[h]):`图片 ${h+1}`,...o[h]?{path:o[h]}:{},...i.includeAbsolutePaths&&o[h]?{absPath:a(o[h])}:{},size:y?Math.max(0,Math.floor(y.length*3/4)-(y.match(/=+$/)?.[0].length??0)):qc(p?.byteLength),...typeof p?.media_type=="string"?{mime:p.media_type}:{}})}const m=Array.isArray(t.attachments)?t.attachments.flatMap(h=>{const p=lo(h),y=Ws(p?.name)||Ws(p?.originalName);return y?[{name:y,size:qc(p?.size),...typeof p?.mime=="string"?{mime:p.mime}:{},...typeof p?.path=="string"?{path:p.path}:{}}]:[]}):[];return{text:typeof t.displayText=="string"?t.displayText:f.trim(),attachments:m.length?m:l}}function kb(t){if(t.type!=="session_user_message"&&t.type!=="steer_injected")return t;const i=lo(t.transcriptMessage);return i?{...t,...jb(i,{includeAbsolutePaths:!0,...typeof i.cwd=="string"?{cwd:i.cwd}:{}})}:t}function Mg(t){return t.replace(/<system-reminder>[\s\S]*?<\/system-reminder>\s*/g,"")}function eo(){return{items:[],run:"idle",seq:0,liveByAgent:{}}}function oa(t){return t.agentId??""}function Qs(t,i,l=!1){const a=i.goalId;if(t.goalId!==a&&!(l&&t.goalId===void 0&&a!==void 0))return!0;const o=i.revision;return t.goalRevision!==void 0&&(o===void 0||o<t.goalRevision)}function yS(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 bS(t){if(!t||typeof t!="object")return null;const i=t;if(i.method==="agent/streamEvent"&&i.params&&typeof i.params=="object"){const l=i.params;if(l.event&&typeof l.event=="object")return{event:l.event,sessionId:typeof l.sessionId=="string"?l.sessionId:void 0}}return typeof i.type=="string"?{event:i}:null}function mr(t,i){const l=bS(i);if(!l)return t;const{sessionId:a}=l,o=kb(l.event),f=o.type;let u=t;a&&a!==u.sessionId&&(u={...u,sessionId:a});const m=h=>{const p=u.seq+1;return[`${h}-${p}`,{...u,seq:p}]};switch(f){case"stream_request_start":{const h=oa(o),[p,y]=m("a"),b={kind:"assistant",id:p,text:"",reasoning:"",done:!1,agentId:o.agentId,...typeof o.messageId=="string"?{messageId:o.messageId}:{}};return{...y,items:[...y.items,b],liveByAgent:{...y.liveByAgent,[h]:p},run:"running"}}case"text_delta":{const h=o.text??"",p=oa(o),y=u.liveByAgent[p];if(y&&u.items.find(D=>D.id===y&&D.kind==="assistant"))return{...u,run:"running",items:u.items.map(D=>D.id===y&&D.kind==="assistant"?{...D,text:D.text+h}:D)};const[x,v]=m("a"),j={kind:"assistant",id:x,text:h,reasoning:"",done:!1,agentId:o.agentId};return{...v,items:[...v.items,j],liveByAgent:{...v.liveByAgent,[p]:x},run:"running"}}case"thinking_delta":{const h=o.text??"",p=oa(o),y=u.liveByAgent[p];if(y&&u.items.some(j=>j.id===y&&j.kind==="assistant"))return{...u,run:"running",items:u.items.map(j=>j.id===y&&j.kind==="assistant"?{...j,reasoning:j.reasoning+h}:j)};const[b,x]=m("a"),v={kind:"assistant",id:b,text:"",reasoning:h,done:!1,agentId:o.agentId};return{...x,items:[...x.items,v],liveByAgent:{...x.liveByAgent,[p]:b},run:"running"}}case"tool_use_start":{const h=o.toolCall;if(!h||u.items.some(x=>x.kind==="tool"&&x.id===h.id))return u;const p=u.orphanResults?.[h.id],y={kind:"tool",id:h.id,name:h.toolName,args:h.args,summary:h.summary,done:!!p,result:p?.result,error:p?.error,agentId:o.agentId};let b=u.orphanResults;if(p){const{[h.id]:x,...v}=u.orphanResults;b=Object.keys(v).length>0?v:void 0}return{...u,run:"running",items:[...u.items,y],orphanResults:b}}case"tool_use_args_delta":{const h=o.toolCallId,p=o.args;return!h||!p?u:{...u,items:u.items.map(y=>y.kind==="tool"&&y.id===h?{...y,args:{...y.args??{},...p}}:y)}}case"tool_result":{const h=o.result;return h?u.items.some(y=>y.kind==="tool"&&y.id===h.id)?{...u,items:u.items.map(y=>y.kind==="tool"&&y.id===h.id?{...y,done:!0,result:Mg(h.result??h.error??""),error:!!(h.isError||h.error)}:y)}:{...u,orphanResults:{...u.orphanResults??{},[h.id]:{result:h.result??h.error??"",error:!!(h.isError||h.error)}}}:u}case"room_tool_result":{const h=o.summary??"",p=Mg(h),y=!!o.isError;let b=-1;for(let j=u.items.length-1;j>=0;j--)if(u.items[j].kind==="tool"&&!u.items[j].done){b=j;break}if(b===-1)return u;const x=u.items.slice(),v=x[b];return x[b]={...v,done:!0,result:p,summary:p||v.summary,error:y},{...u,items:x}}case"tool_summary":{const h=o.summary??"",p=Array.isArray(o.toolCallIds)?o.toolCallIds.filter(D=>typeof D=="string"):[],b=p.length>0?p[p.length-1]:void 0,x=o.agentId;if(b){let D=!1;const N=u.items.map(A=>A.kind!=="tool"||A.id!==b||A.agentId!==x?A:(D=!0,{...A,summary:h}));return D?{...u,items:N}:u}if(x){let D=-1;for(let A=u.items.length-1;A>=0;A--){const R=u.items[A];if(R.kind==="tool"&&R.agentId===x){D=A;break}}if(D===-1)return u;const N=u.items.slice();return N[D]={...N[D],summary:h},{...u,items:N}}let v=-1;for(let D=u.items.length-1;D>=0;D--){const N=u.items[D];if(N.kind==="tool"&&N.agentId===void 0){v=D;break}}if(v===-1)return u;const j=u.items.slice();return j[v]={...j[v],summary:h},{...u,items:j}}case"tombstone":{if(typeof o.messageId!="string")return u;const h=new Set(u.items.filter(p=>p.kind==="assistant"&&p.messageId===o.messageId||p.kind==="tool"&&p.id===o.messageId).map(p=>p.id));return h.size?{...u,items:u.items.filter(p=>!h.has(p.id)),liveByAgent:Object.fromEntries(Object.entries(u.liveByAgent).filter(([,p])=>!h.has(p)))}:u}case"assistant_message":{const h=oa(o);if(!(h in u.liveByAgent))return u;const{[h]:p,...y}=u.liveByAgent,b=u.items.map(x=>x.kind==="assistant"&&!x.done&&(x.agentId??"")===h?{...x,done:!0}:x);return{...u,liveByAgent:y,items:b}}case"turn_complete":{const h=o.reason??"completed",p=oa(o),{[p]:y,...b}=u.liveByAgent,x=u.items.map(v=>v.kind==="assistant"&&!v.done&&(v.agentId??"")===p?{...v,done:!0}:v);return o.agentId?{...u,liveByAgent:b,items:x}:{...u,liveByAgent:b,items:x,run:yS(h)}}case"goal_set":{const h=o.objective??"",p=!!o.paused;return u.goal&&u.goalId===o.goalId&&Qs(u,o)?u:{...u,goal:h?`◎ ${h}${p?" (已暂停)":""}`:"◎ 目标",goalId:o.goalId,goalPaused:p,goalRevision:o.revision}}case"goal_updated":{if(u.goal&&Qs(u,o,!0))return u;const h=o.goalId,p=o.objective??"",y=!!o.paused;return{...u,goal:p?`◎ ${p}${y?" (已暂停)":""}`:u.goal,goalId:h??u.goalId,goalPaused:y,goalRevision:o.revision??u.goalRevision}}case"goal_cleared":return u.goal&&Qs(u,o)?u:{...u,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};case"goal_progress":{if(u.goal&&Qs(u,o))return u;const h=o.status??"";if(h==="met"||h==="exhausted")return{...u,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};const p=o.round,y=p?`目标 · 第 ${p} 轮 (${h})`:`目标 (${h})`;return{...u,goal:y,goalRevision:o.revision??u.goalRevision}}case"task_update":{const h=o.agentId;if(!h)return u;const p=o.tasks??[],y=p.filter(j=>j.status==="completed").length,b=`任务 ${y}/${p.length}`,x=u.items.findIndex(j=>j.kind==="subagent"&&j.agentId===h),v={kind:"subagent",id:`sub-${h}`,agentId:h,label:b,status:p.length>0&&y===p.length?"completed":"running"};if(x>=0){const j=u.items.slice();return j[x]=v,{...u,items:j}}return{...u,items:[...u.items,v]}}case"agent_start":{const h=o.agentId;if(!h)return u;const p={kind:"subagent",id:`sub-${h}`,agentId:h,label:o.name||o.description||"子代理",status:o.status==="recorded"?"recorded":"running"};return u.items.some(y=>y.kind==="subagent"&&y.agentId===h)?u:{...u,items:[...u.items,p]}}case"agent_end":{const h=o.agentId;return{...u,items:u.items.map(p=>p.kind==="subagent"&&p.agentId===h?{...p,status:o.error?"error":"completed"}:p)}}case"background_agent_completed":{const h=typeof o.agentId=="string"?o.agentId:"",p=o.status==="failed",y=p?"error":o.status==="cancelled"?"cancelled":"completed",b=typeof o.name=="string"?o.name:"后台任务",x=p?o.error??o.description:o.finalText??o.description,v=`${b} · ${y}${typeof x=="string"&&x.trim()?`: ${x.trim().slice(0,240)}`:""}`,[j,D]=m("bg-done");return{...D,items:[...u.items.map(N=>N.kind==="subagent"&&N.agentId===h?{...N,status:y}:N),{kind:"system",id:j,text:v}]}}case"error":{const[h,p]=m("err");return{...p,run:"error",liveByAgent:{},items:[...p.items,{kind:"system_error",id:h,text:o.error||"运行出错"}]}}case"session_title":return{...u,title:o.title};case"session_user_message":case"steer_injected":case"user_message":{if(o.agentId||o.injected===!0||o.authority==="agent"||o.authority==="system"||o.authority==="policy")return u;const h=typeof o.clientMessageId=="string"?o.clientMessageId:void 0,p=Array.isArray(o.attachments)?o.attachments.map(x=>x).filter(x=>!!x&&typeof x.name=="string"&&typeof x.size=="number"&&Number.isFinite(x.size)&&x.size>=0).map(x=>({name:x.name,size:x.size,...typeof x.mime=="string"?{mime:x.mime}:{},...typeof x.path=="string"?{path:x.path}:{}})):void 0;if(h&&u.items.some(x=>x.kind==="user"&&x.clientMessageId===h))return p?.length?{...u,items:u.items.map(x=>x.kind==="user"&&x.clientMessageId===h?{...x,attachments:p.map((v,j)=>{const D=x.attachments?.[j];return D?.name===v.name?{...D,...v}:v})}:x)}:u;const[y,b]=m("u");return{...b,items:[...b.items,{kind:"user",id:y,text:o.text??"",...p?.length?{attachments:p}:{},...h?{clientMessageId:h}:{}}]}}case"assistant_text":{const[h,p]=m("a");return{...p,run:"running",items:[...p.items,{kind:"assistant",id:h,text:o.text??"",reasoning:"",done:!0,agentId:o.agentId}]}}default:return u}}function vS(t,i,l,a){const o=`u-${t.seq+1}`;return{...t,seq:t.seq+1,items:[...t.items,{kind:"user",id:o,text:i,...l?.length?{attachments:l}:{},...a?{clientMessageId:a}:{}}]}}const xS="codeshell.uiLanguage";function SS(){try{const t=globalThis.localStorage?.getItem(xS);if(t==="zh"||t==="en")return t}catch{}return"zh"}const wS={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)"}}}},Og=wS;function Lg(t,i){let l=t;for(const a of i.split(".")){if(l==null||typeof l!="object")return;l=l[a]}return typeof l=="string"?l:void 0}function jS(t,i){return i?t.replace(/\{(\w+)\}/g,(l,a)=>a in i?String(i[a]):l):t}function kS(t,i,l){const a=Lg(Og[t],i)??Lg(Og.zh,i)??i;return jS(a,l)}function ES(t,i){return kS(SS(),t,i)}const CS=["command","file_path","path","url","pattern","query"];function NS(t,i,l){let a="";const o=t?.source,f=t?.scope,u=t?.resource;if(l==="ReadSource"&&typeof o=="string"&&o.length>0&&typeof f=="string"&&f.length>0&&typeof u=="string"&&u.length>0)a=ES("mobile.approval.readSourceSummary",{source:o,scope:f,resource:u});else for(const h of CS){const p=t?.[h];if(typeof p=="string"&&p.length>0){a=p;break}}a||(a=JSON.stringify(t??{}));let m;return i==="low"||i==="medium"||i==="high"?m=i:i===void 0||i===""?m="medium":m="high",{summary:a,risk:m}}const AS=16*1024*1024;function pr(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 TS(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,l=>l.charCodeAt(0))}function ga(t,i){try{const l=pr(t),a=pr(i);return l.identity===a.identity?Math.sign(l.sequence-a.sequence):void 0}catch{return}}function RS(t,i,l){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=pr(i.from);const o=pr(i.through),f=pr(i.coverageStart);if(f.sequence!==0||f.identity!==a.identity||o.identity!==a.identity||a.sequence>o.sequence)throw new Error("Output recovery cursor domain changed");let u=t.pending?{...t.pending,chunks:t.pending.chunks.slice()}:void 0,m=t.appliedCursor??i.from;const h=[];for(const y of i.frames){const b=pr(y.cursor);if(b.identity!==a.identity||b.sequence!==a.sequence+1||y.sequence!==b.sequence||b.offset<=a.offset||b.sequence>o.sequence||!!y.event==!!y.fragment)throw new Error("Output recovery has a gap");let x=y.event;if(y.fragment){const v=y.fragment;if(!u){if(v.index!==0||!Number.isSafeInteger(v.total)||v.total<2||v.total>256)throw new Error("Output fragment has no beginning");u={id:v.id,total:v.total,next:0,bytes:0,chunks:[]}}if(v.id!==u.id||v.total!==u.total||v.index!==u.next)throw new Error("Output fragment has a gap");const j=TS(v.data);if(u.bytes+=j.length,u.bytes>AS)throw new Error("Output fragment exceeds its budget");if(u.chunks.push(j),u.next++,u.next===u.total){const D=new Uint8Array(u.bytes);let N=0;for(const A of u.chunks)D.set(A,N),N+=A.length;x=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(D)),u=void 0}}else if(u)throw new Error("Output fragment was interrupted");if(x){if(typeof x!="object"||typeof x.type!="string"||x.outputRecovery==="incomplete")throw new Error("Invalid output event");h.push({...kb(x),outputCursor:y.cursor}),m=y.cursor}a=b}const p=pr(i.next);if(p.identity!==a.identity||p.sequence!==a.sequence||p.offset!==a.offset||(i.frames.at(-1)?.cursor??i.from)!==i.next||i.complete!==(i.next===i.through)||i.complete&&u||!i.complete&&!i.frames.length)throw new Error("Output recovery page did not establish coverage");t.cursor=i.next,t.appliedCursor=m,t.through=i.through,t.coverageStart=i.coverageStart,t.legacyBaseThroughEventId=i.legacyBaseThroughEventId,t.pending=u;for(const y of h)l(y);return i.complete}catch{return t.incomplete=!0,t.pending=void 0,!1}}const zS=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 DS(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 rd{lastCursor;blocked=!1;overflowed=!1;inputs=new Set;copy(){const i=new rd;i.lastCursor=this.lastCursor,i.blocked=this.blocked,i.overflowed=this.overflowed;for(const l of this.inputs)i.inputs.add(l);return i}observe(i){if(this.overflowed)return;const l=i;if(l){if(l.outputCursor!==void 0){const a=DS(l.outputCursor)?this.lastCursor?ga(l.outputCursor,this.lastCursor):1:void 0;if(a===void 0||a<=0){this.discardProof();return}this.lastCursor=l.outputCursor;return}if(!(!l.type||!zS.has(l.type))&&!(["session_user_message","steer_injected","user_message"].includes(l.type)&&(l.agentId||l.injected===!0||["agent","system","policy"].includes(String(l.authority)))))if(l.type==="session_user_message"){const a=l.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 l of i)this.inputs.delete(l)}get inputIds(){return[...this.inputs]}get incomplete(){return this.blocked||this.overflowed}get memoryBytes(){return this.inputIds.reduce((i,l)=>i+new TextEncoder().encode(l).length,0)}discardProof(){this.overflowed=!0,this.inputs.clear()}}function ua(t,i,l,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 f;try{f=JSON.parse(atob((i.coverageStart??"").replace(/-/g,"+").replace(/_/g,"/"))).hash}catch{throw new Error("Output recovery journal pin is unpaired")}if(f!==t.journalIdentity)throw new Error("Output recovery journal pin changed")}const o=t.inputIds??[];if(!Array.isArray(o)||o.length>128||new Set(o).size!==o.length||o.some(f=>typeof f!="string"||!f.trim()||f.length>512)||o.reduce((f,u)=>f+new TextEncoder().encode(u).length,0)>32*1024)throw new Error("Output recovery input identities are unpaired");if(o.some(f=>!l(f)))throw new Error("Output recovery input has no recorded anchor")}function bi(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ot(t){return typeof t=="string"?t:""}function Mf(t){return Array.isArray(t)?t.map(bi).filter(i=>i!==void 0):[]}function Bg(t){return typeof t=="string"?t:Mf(t).filter(i=>i.type==="text").map(i=>Ot(i.text)).join("")}function Ug(t){return bi(t.data)??bi(t.message)??t}function _S(t){const i=[],l=new Set,a=new Set,o=new Map;for(const m of t){const h=bi(m);if(!h)continue;const p=Ug(h);h.type==="tool_use"&&Ot(p.toolCallId)&&o.set(Ot(p.toolCallId),{name:Ot(p.toolName)||"工具",args:bi(p.args)??{}});for(const y of Mf(p.content))y.type==="tool_use"&&Ot(y.id)&&o.set(Ot(y.id),{name:Ot(y.name)||"工具",args:bi(y.input)??{}})}const f=(m,h,p,y)=>{m&&(a.has(m)?i.push({type:"tool_use_args_delta",toolCallId:m,args:p,...y?{agentId:y}:{}}):(a.add(m),i.push({type:"tool_use_start",toolCall:{id:m,toolName:h||"工具",args:p},...y?{agentId:y}:{}})))},u=(m,h,p)=>{if(!m)return;const y=o.get(m);a.has(m)||f(m,y?.name||Ot(h.toolName)||"工具",y?.args??{},p);const b=typeof h.result=="string"?h.result:Bg(h.content??h.contentBlocks),x=Ot(h.error);i.push({type:"tool_result",result:{id:m,result:b||x,...x?{error:x}:{},isError:h.isError===!0||h.is_error===!0||!!x},...p?{agentId:p}:{}})};for(const m of t){const h=bi(m);if(!h)continue;const p=Ot(h.id);if(p&&l.has(p))continue;p&&l.add(p);const y=Ug(h),b=Ot(y.agentId)||void 0;switch(typeof h.type=="string"?h.type:typeof y.role=="string"?"message":""){case"message":{const v=Mf(y.content);if(y.role==="user"){if(y.injected===!0||y.authority==="agent"||y.authority==="system"||y.authority==="policy")break;const j=jb(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 D of v)D.type==="tool_result"&&u(Ot(D.tool_use_id),D,b)}else if(y.role==="assistant"){const j=Bg(y.content),D=v.filter(N=>N.type==="reasoning").map(N=>Ot(N.reasoningContent)||Ot(N.text)).join("");if(j||D){const N=b?{agentId:b}:{};i.push({type:"stream_request_start",...N}),D&&i.push({type:"thinking_delta",text:D,...N}),j&&i.push({type:"text_delta",text:j,...N}),i.push({type:"assistant_message",...N})}for(const N of v)N.type==="tool_use"&&f(Ot(N.id),Ot(N.name),bi(N.input)??{},b)}else y.role==="tool"&&u(Ot(y.tool_call_id),y,b);break}case"tool_use":f(Ot(y.toolCallId),Ot(y.toolName),bi(y.args)??{},b);break;case"tool_result":u(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 Eb(t){let i=eo();for(const l of _S(t))i=mr(i,l);return{...i,run:i.run==="error"?"error":"idle",liveByAgent:{}}}var al={},Hc,Ig;function MS(){return Ig||(Ig=1,Hc=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Hc}var Vc={},Fi={},qg;function vr(){if(qg)return Fi;qg=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 Fi.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},Fi.getSymbolTotalCodewords=function(a){return i[a]},Fi.getBCHDigit=function(l){let a=0;for(;l!==0;)a++,l>>>=1;return a},Fi.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');t=a},Fi.isKanjiModeEnabled=function(){return typeof t<"u"},Fi.toSJIS=function(a){return t(a)},Fi}var Yc={},Hg;function ld(){return Hg||(Hg=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function i(l){if(typeof l!="string")throw new Error("Param is not a string");switch(l.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: "+l)}}t.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},t.from=function(a,o){if(t.isValid(a))return a;try{return i(a)}catch{return o}}})(Yc)),Yc}var Gc,Vg;function OS(){if(Vg)return Gc;Vg=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(i){const l=Math.floor(i/8);return(this.buffer[l]>>>7-i%8&1)===1},put:function(i,l){for(let a=0;a<l;a++)this.putBit((i>>>l-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(i){const l=Math.floor(this.length/8);this.buffer.length<=l&&this.buffer.push(0),i&&(this.buffer[l]|=128>>>this.length%8),this.length++}},Gc=t,Gc}var Fc,Yg;function LS(){if(Yg)return Fc;Yg=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,l,a,o){const f=i*this.size+l;this.data[f]=a,o&&(this.reservedBit[f]=!0)},t.prototype.get=function(i,l){return this.data[i*this.size+l]},t.prototype.xor=function(i,l,a){this.data[i*this.size+l]^=a},t.prototype.isReserved=function(i,l){return this.reservedBit[i*this.size+l]},Fc=t,Fc}var Qc={},Gg;function BS(){return Gg||(Gg=1,(function(t){const i=vr().getSymbolSize;t.getRowColCoords=function(a){if(a===1)return[];const o=Math.floor(a/7)+2,f=i(a),u=f===145?26:Math.ceil((f-13)/(2*o-2))*2,m=[f-7];for(let h=1;h<o-1;h++)m[h]=m[h-1]-u;return m.push(6),m.reverse()},t.getPositions=function(a){const o=[],f=t.getRowColCoords(a),u=f.length;for(let m=0;m<u;m++)for(let h=0;h<u;h++)m===0&&h===0||m===0&&h===u-1||m===u-1&&h===0||o.push([f[m],f[h]]);return o}})(Qc)),Qc}var $c={},Fg;function US(){if(Fg)return $c;Fg=1;const t=vr().getSymbolSize,i=7;return $c.getPositions=function(a){const o=t(a);return[[0,0],[o-i,0],[0,o-i]]},$c}var Xc={},Qg;function IS(){return Qg||(Qg=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(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},t.from=function(o){return t.isValid(o)?parseInt(o,10):void 0},t.getPenaltyN1=function(o){const f=o.size;let u=0,m=0,h=0,p=null,y=null;for(let b=0;b<f;b++){m=h=0,p=y=null;for(let x=0;x<f;x++){let v=o.get(b,x);v===p?m++:(m>=5&&(u+=i.N1+(m-5)),p=v,m=1),v=o.get(x,b),v===y?h++:(h>=5&&(u+=i.N1+(h-5)),y=v,h=1)}m>=5&&(u+=i.N1+(m-5)),h>=5&&(u+=i.N1+(h-5))}return u},t.getPenaltyN2=function(o){const f=o.size;let u=0;for(let m=0;m<f-1;m++)for(let h=0;h<f-1;h++){const p=o.get(m,h)+o.get(m,h+1)+o.get(m+1,h)+o.get(m+1,h+1);(p===4||p===0)&&u++}return u*i.N2},t.getPenaltyN3=function(o){const f=o.size;let u=0,m=0,h=0;for(let p=0;p<f;p++){m=h=0;for(let y=0;y<f;y++)m=m<<1&2047|o.get(p,y),y>=10&&(m===1488||m===93)&&u++,h=h<<1&2047|o.get(y,p),y>=10&&(h===1488||h===93)&&u++}return u*i.N3},t.getPenaltyN4=function(o){let f=0;const u=o.data.length;for(let h=0;h<u;h++)f+=o.data[h];return Math.abs(Math.ceil(f*100/u/5)-10)*i.N4};function l(a,o,f){switch(a){case t.Patterns.PATTERN000:return(o+f)%2===0;case t.Patterns.PATTERN001:return o%2===0;case t.Patterns.PATTERN010:return f%3===0;case t.Patterns.PATTERN011:return(o+f)%3===0;case t.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(f/3))%2===0;case t.Patterns.PATTERN101:return o*f%2+o*f%3===0;case t.Patterns.PATTERN110:return(o*f%2+o*f%3)%2===0;case t.Patterns.PATTERN111:return(o*f%3+(o+f)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}t.applyMask=function(o,f){const u=f.size;for(let m=0;m<u;m++)for(let h=0;h<u;h++)f.isReserved(h,m)||f.xor(h,m,l(o,h,m))},t.getBestMask=function(o,f){const u=Object.keys(t.Patterns).length;let m=0,h=1/0;for(let p=0;p<u;p++){f(p),t.applyMask(p,o);const y=t.getPenaltyN1(o)+t.getPenaltyN2(o)+t.getPenaltyN3(o)+t.getPenaltyN4(o);t.applyMask(p,o),y<h&&(h=y,m=p)}return m}})(Xc)),Xc}var $s={},$g;function Cb(){if($g)return $s;$g=1;const t=ld(),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],l=[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 $s.getBlocksCount=function(o,f){switch(f){case t.L:return i[(o-1)*4+0];case t.M:return i[(o-1)*4+1];case t.Q:return i[(o-1)*4+2];case t.H:return i[(o-1)*4+3];default:return}},$s.getTotalCodewordsCount=function(o,f){switch(f){case t.L:return l[(o-1)*4+0];case t.M:return l[(o-1)*4+1];case t.Q:return l[(o-1)*4+2];case t.H:return l[(o-1)*4+3];default:return}},$s}var Kc={},ca={},Xg;function qS(){if(Xg)return ca;Xg=1;const t=new Uint8Array(512),i=new Uint8Array(256);return(function(){let a=1;for(let o=0;o<255;o++)t[o]=a,i[a]=o,a<<=1,a&256&&(a^=285);for(let o=255;o<512;o++)t[o]=t[o-255]})(),ca.log=function(a){if(a<1)throw new Error("log("+a+")");return i[a]},ca.exp=function(a){return t[a]},ca.mul=function(a,o){return a===0||o===0?0:t[i[a]+i[o]]},ca}var Kg;function HS(){return Kg||(Kg=1,(function(t){const i=qS();t.mul=function(a,o){const f=new Uint8Array(a.length+o.length-1);for(let u=0;u<a.length;u++)for(let m=0;m<o.length;m++)f[u+m]^=i.mul(a[u],o[m]);return f},t.mod=function(a,o){let f=new Uint8Array(a);for(;f.length-o.length>=0;){const u=f[0];for(let h=0;h<o.length;h++)f[h]^=i.mul(o[h],u);let m=0;for(;m<f.length&&f[m]===0;)m++;f=f.slice(m)}return f},t.generateECPolynomial=function(a){let o=new Uint8Array([1]);for(let f=0;f<a;f++)o=t.mul(o,new Uint8Array([1,i.exp(f)]));return o}})(Kc)),Kc}var Pc,Pg;function VS(){if(Pg)return Pc;Pg=1;const t=HS();function i(l){this.genPoly=void 0,this.degree=l,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 o=new Uint8Array(a.length+this.degree);o.set(a);const f=t.mod(o,this.genPoly),u=this.degree-f.length;if(u>0){const m=new Uint8Array(this.degree);return m.set(f,u),m}return f},Pc=i,Pc}var Zc={},Jc={},Wc={},Zg;function Nb(){return Zg||(Zg=1,Wc.isValid=function(i){return!isNaN(i)&&i>=1&&i<=40}),Wc}var Pn={},Jg;function Ab(){if(Jg)return Pn;Jg=1;const t="[0-9]+",i="[A-Z $%*+\\-./:]+";let l="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";l=l.replace(/u/g,"\\u");const a="(?:(?![A-Z0-9 $%*+\\-./:]|"+l+`)(?:.|[\r
|
|
22
|
-
]))+`;Pn.KANJI=new RegExp(l,"g"),Pn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Pn.BYTE=new RegExp(a,"g"),Pn.NUMERIC=new RegExp(t,"g"),Pn.ALPHANUMERIC=new RegExp(i,"g");const o=new RegExp("^"+l+"$"),f=new RegExp("^"+t+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Pn.testKanji=function(h){return o.test(h)},Pn.testNumeric=function(h){return f.test(h)},Pn.testAlphanumeric=function(h){return u.test(h)},Pn}var Wg;function xr(){return Wg||(Wg=1,(function(t){const i=Nb(),l=Ab();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(f,u){if(!f.ccBits)throw new Error("Invalid mode: "+f);if(!i.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?f.ccBits[0]:u<27?f.ccBits[1]:f.ccBits[2]},t.getBestModeForData=function(f){return l.testNumeric(f)?t.NUMERIC:l.testAlphanumeric(f)?t.ALPHANUMERIC:l.testKanji(f)?t.KANJI:t.BYTE},t.toString=function(f){if(f&&f.id)return f.id;throw new Error("Invalid mode")},t.isValid=function(f){return f&&f.bit&&f.ccBits};function a(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.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: "+o)}}t.from=function(f,u){if(t.isValid(f))return f;try{return a(f)}catch{return u}}})(Jc)),Jc}var ey;function YS(){return ey||(ey=1,(function(t){const i=vr(),l=Cb(),a=ld(),o=xr(),f=Nb(),u=7973,m=i.getBCHDigit(u);function h(x,v,j){for(let D=1;D<=40;D++)if(v<=t.getCapacity(D,j,x))return D}function p(x,v){return o.getCharCountIndicator(x,v)+4}function y(x,v){let j=0;return x.forEach(function(D){const N=p(D.mode,v);j+=N+D.getBitsLength()}),j}function b(x,v){for(let j=1;j<=40;j++)if(y(x,j)<=t.getCapacity(j,v,o.MIXED))return j}t.from=function(v,j){return f.isValid(v)?parseInt(v,10):j},t.getCapacity=function(v,j,D){if(!f.isValid(v))throw new Error("Invalid QR Code version");typeof D>"u"&&(D=o.BYTE);const N=i.getSymbolTotalCodewords(v),A=l.getTotalCodewordsCount(v,j),R=(N-A)*8;if(D===o.MIXED)return R;const O=R-p(D,v);switch(D){case o.NUMERIC:return Math.floor(O/10*3);case o.ALPHANUMERIC:return Math.floor(O/11*2);case o.KANJI:return Math.floor(O/13);case o.BYTE:default:return Math.floor(O/8)}},t.getBestVersionForData=function(v,j){let D;const N=a.from(j,a.M);if(Array.isArray(v)){if(v.length>1)return b(v,N);if(v.length===0)return 1;D=v[0]}else D=v;return h(D.mode,D.getLength(),N)},t.getEncodedBits=function(v){if(!f.isValid(v)||v<7)throw new Error("Invalid QR Code version");let j=v<<12;for(;i.getBCHDigit(j)-m>=0;)j^=u<<i.getBCHDigit(j)-m;return v<<12|j}})(Zc)),Zc}var ef={},ty;function GS(){if(ty)return ef;ty=1;const t=vr(),i=1335,l=21522,a=t.getBCHDigit(i);return ef.getEncodedBits=function(f,u){const m=f.bit<<3|u;let h=m<<10;for(;t.getBCHDigit(h)-a>=0;)h^=i<<t.getBCHDigit(h)-a;return(m<<10|h)^l},ef}var tf={},nf,ny;function FS(){if(ny)return nf;ny=1;const t=xr();function i(l){this.mode=t.NUMERIC,this.data=l.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 o,f,u;for(o=0;o+3<=this.data.length;o+=3)f=this.data.substr(o,3),u=parseInt(f,10),a.put(u,10);const m=this.data.length-o;m>0&&(f=this.data.substr(o),u=parseInt(f,10),a.put(u,m*3+1))},nf=i,nf}var rf,iy;function QS(){if(iy)return rf;iy=1;const t=xr(),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 l(a){this.mode=t.ALPHANUMERIC,this.data=a}return l.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},l.prototype.getLength=function(){return this.data.length},l.prototype.getBitsLength=function(){return l.getBitsLength(this.data.length)},l.prototype.write=function(o){let f;for(f=0;f+2<=this.data.length;f+=2){let u=i.indexOf(this.data[f])*45;u+=i.indexOf(this.data[f+1]),o.put(u,11)}this.data.length%2&&o.put(i.indexOf(this.data[f]),6)},rf=l,rf}var lf,ry;function $S(){if(ry)return lf;ry=1;const t=xr();function i(l){this.mode=t.BYTE,typeof l=="string"?this.data=new TextEncoder().encode(l):this.data=new Uint8Array(l)}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(l){for(let a=0,o=this.data.length;a<o;a++)l.put(this.data[a],8)},lf=i,lf}var af,ly;function XS(){if(ly)return af;ly=1;const t=xr(),i=vr();function l(a){this.mode=t.KANJI,this.data=a}return l.getBitsLength=function(o){return o*13},l.prototype.getLength=function(){return this.data.length},l.prototype.getBitsLength=function(){return l.getBitsLength(this.data.length)},l.prototype.write=function(a){let o;for(o=0;o<this.data.length;o++){let f=i.toSJIS(this.data[o]);if(f>=33088&&f<=40956)f-=33088;else if(f>=57408&&f<=60351)f-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
23
|
-
Make sure your charset is UTF-8`);f=(f>>>8&255)*192+(f&255),a.put(f,13)}},af=l,af}var sf={exports:{}},ay;function KS(){return ay||(ay=1,(function(t){var i={single_source_shortest_paths:function(l,a,o){var f={},u={};u[a]=0;var m=i.PriorityQueue.make();m.push(a,0);for(var h,p,y,b,x,v,j,D,N;!m.empty();){h=m.pop(),p=h.value,b=h.cost,x=l[p]||{};for(y in x)x.hasOwnProperty(y)&&(v=x[y],j=b+v,D=u[y],N=typeof u[y]>"u",(N||D>j)&&(u[y]=j,m.push(y,j),f[y]=p))}if(typeof o<"u"&&typeof u[o]>"u"){var A=["Could not find a path from ",a," to ",o,"."].join("");throw new Error(A)}return f},extract_shortest_path_from_predecessor_list:function(l,a){for(var o=[],f=a;f;)o.push(f),l[f],f=l[f];return o.reverse(),o},find_path:function(l,a,o){var f=i.single_source_shortest_paths(l,a,o);return i.extract_shortest_path_from_predecessor_list(f,o)},PriorityQueue:{make:function(l){var a=i.PriorityQueue,o={},f;l=l||{};for(f in a)a.hasOwnProperty(f)&&(o[f]=a[f]);return o.queue=[],o.sorter=l.sorter||a.default_sorter,o},default_sorter:function(l,a){return l.cost-a.cost},push:function(l,a){var o={value:l,cost:a};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=i})(sf)),sf.exports}var sy;function PS(){return sy||(sy=1,(function(t){const i=xr(),l=FS(),a=QS(),o=$S(),f=XS(),u=Ab(),m=vr(),h=KS();function p(A){return unescape(encodeURIComponent(A)).length}function y(A,R,O){const Y=[];let re;for(;(re=A.exec(O))!==null;)Y.push({data:re[0],index:re.index,mode:R,length:re[0].length});return Y}function b(A){const R=y(u.NUMERIC,i.NUMERIC,A),O=y(u.ALPHANUMERIC,i.ALPHANUMERIC,A);let Y,re;return m.isKanjiModeEnabled()?(Y=y(u.BYTE,i.BYTE,A),re=y(u.KANJI,i.KANJI,A)):(Y=y(u.BYTE_KANJI,i.BYTE,A),re=[]),R.concat(O,Y,re).sort(function(V,Q){return V.index-Q.index}).map(function(V){return{data:V.data,mode:V.mode,length:V.length}})}function x(A,R){switch(R){case i.NUMERIC:return l.getBitsLength(A);case i.ALPHANUMERIC:return a.getBitsLength(A);case i.KANJI:return f.getBitsLength(A);case i.BYTE:return o.getBitsLength(A)}}function v(A){return A.reduce(function(R,O){const Y=R.length-1>=0?R[R.length-1]:null;return Y&&Y.mode===O.mode?(R[R.length-1].data+=O.data,R):(R.push(O),R)},[])}function j(A){const R=[];for(let O=0;O<A.length;O++){const Y=A[O];switch(Y.mode){case i.NUMERIC:R.push([Y,{data:Y.data,mode:i.ALPHANUMERIC,length:Y.length},{data:Y.data,mode:i.BYTE,length:Y.length}]);break;case i.ALPHANUMERIC:R.push([Y,{data:Y.data,mode:i.BYTE,length:Y.length}]);break;case i.KANJI:R.push([Y,{data:Y.data,mode:i.BYTE,length:p(Y.data)}]);break;case i.BYTE:R.push([{data:Y.data,mode:i.BYTE,length:p(Y.data)}])}}return R}function D(A,R){const O={},Y={start:{}};let re=["start"];for(let T=0;T<A.length;T++){const V=A[T],Q=[];for(let I=0;I<V.length;I++){const C=V[I],B=""+T+I;Q.push(B),O[B]={node:C,lastCount:0},Y[B]={};for(let U=0;U<re.length;U++){const $=re[U];O[$]&&O[$].node.mode===C.mode?(Y[$][B]=x(O[$].lastCount+C.length,C.mode)-x(O[$].lastCount,C.mode),O[$].lastCount+=C.length):(O[$]&&(O[$].lastCount=C.length),Y[$][B]=x(C.length,C.mode)+4+i.getCharCountIndicator(C.mode,R))}}re=Q}for(let T=0;T<re.length;T++)Y[re[T]].end=0;return{map:Y,table:O}}function N(A,R){let O;const Y=i.getBestModeForData(A);if(O=i.from(R,Y),O!==i.BYTE&&O.bit<Y.bit)throw new Error('"'+A+'" cannot be encoded with mode '+i.toString(O)+`.
|
|
24
|
-
Suggested mode is: `+i.toString(Y));switch(O===i.KANJI&&!m.isKanjiModeEnabled()&&(O=i.BYTE),O){case i.NUMERIC:return new l(A);case i.ALPHANUMERIC:return new a(A);case i.KANJI:return new f(A);case i.BYTE:return new o(A)}}t.fromArray=function(R){return R.reduce(function(O,Y){return typeof Y=="string"?O.push(N(Y,null)):Y.data&&O.push(N(Y.data,Y.mode)),O},[])},t.fromString=function(R,O){const Y=b(R,m.isKanjiModeEnabled()),re=j(Y),T=D(re,O),V=h.find_path(T.map,"start","end"),Q=[];for(let I=1;I<V.length-1;I++)Q.push(T.table[V[I]].node);return t.fromArray(v(Q))},t.rawSplit=function(R){return t.fromArray(b(R,m.isKanjiModeEnabled()))}})(tf)),tf}var oy;function ZS(){if(oy)return Vc;oy=1;const t=vr(),i=ld(),l=OS(),a=LS(),o=BS(),f=US(),u=IS(),m=Cb(),h=VS(),p=YS(),y=GS(),b=xr(),x=PS();function v(T,V){const Q=T.size,I=f.getPositions(V);for(let C=0;C<I.length;C++){const B=I[C][0],U=I[C][1];for(let $=-1;$<=7;$++)if(!(B+$<=-1||Q<=B+$))for(let ee=-1;ee<=7;ee++)U+ee<=-1||Q<=U+ee||($>=0&&$<=6&&(ee===0||ee===6)||ee>=0&&ee<=6&&($===0||$===6)||$>=2&&$<=4&&ee>=2&&ee<=4?T.set(B+$,U+ee,!0,!0):T.set(B+$,U+ee,!1,!0))}}function j(T){const V=T.size;for(let Q=8;Q<V-8;Q++){const I=Q%2===0;T.set(Q,6,I,!0),T.set(6,Q,I,!0)}}function D(T,V){const Q=o.getPositions(V);for(let I=0;I<Q.length;I++){const C=Q[I][0],B=Q[I][1];for(let U=-2;U<=2;U++)for(let $=-2;$<=2;$++)U===-2||U===2||$===-2||$===2||U===0&&$===0?T.set(C+U,B+$,!0,!0):T.set(C+U,B+$,!1,!0)}}function N(T,V){const Q=T.size,I=p.getEncodedBits(V);let C,B,U;for(let $=0;$<18;$++)C=Math.floor($/3),B=$%3+Q-8-3,U=(I>>$&1)===1,T.set(C,B,U,!0),T.set(B,C,U,!0)}function A(T,V,Q){const I=T.size,C=y.getEncodedBits(V,Q);let B,U;for(B=0;B<15;B++)U=(C>>B&1)===1,B<6?T.set(B,8,U,!0):B<8?T.set(B+1,8,U,!0):T.set(I-15+B,8,U,!0),B<8?T.set(8,I-B-1,U,!0):B<9?T.set(8,15-B-1+1,U,!0):T.set(8,15-B-1,U,!0);T.set(I-8,8,1,!0)}function R(T,V){const Q=T.size;let I=-1,C=Q-1,B=7,U=0;for(let $=Q-1;$>0;$-=2)for($===6&&$--;;){for(let ee=0;ee<2;ee++)if(!T.isReserved(C,$-ee)){let K=!1;U<V.length&&(K=(V[U]>>>B&1)===1),T.set(C,$-ee,K),B--,B===-1&&(U++,B=7)}if(C+=I,C<0||Q<=C){C-=I,I=-I;break}}}function O(T,V,Q){const I=new l;Q.forEach(function(ee){I.put(ee.mode.bit,4),I.put(ee.getLength(),b.getCharCountIndicator(ee.mode,T)),ee.write(I)});const C=t.getSymbolTotalCodewords(T),B=m.getTotalCodewordsCount(T,V),U=(C-B)*8;for(I.getLengthInBits()+4<=U&&I.put(0,4);I.getLengthInBits()%8!==0;)I.putBit(0);const $=(U-I.getLengthInBits())/8;for(let ee=0;ee<$;ee++)I.put(ee%2?17:236,8);return Y(I,T,V)}function Y(T,V,Q){const I=t.getSymbolTotalCodewords(V),C=m.getTotalCodewordsCount(V,Q),B=I-C,U=m.getBlocksCount(V,Q),$=I%U,ee=U-$,K=Math.floor(I/U),z=Math.floor(B/U),Z=z+1,he=K-z,me=new h(he);let k=0;const L=new Array(U),J=new Array(U);let _=0;const te=new Uint8Array(T.buffer);for(let F=0;F<U;F++){const we=F<ee?z:Z;L[F]=te.slice(k,k+we),J[F]=me.encode(L[F]),k+=we,_=Math.max(_,we)}const xe=new Uint8Array(I);let ae=0,se,ye;for(se=0;se<_;se++)for(ye=0;ye<U;ye++)se<L[ye].length&&(xe[ae++]=L[ye][se]);for(se=0;se<he;se++)for(ye=0;ye<U;ye++)xe[ae++]=J[ye][se];return xe}function re(T,V,Q,I){let C;if(Array.isArray(T))C=x.fromArray(T);else if(typeof T=="string"){let K=V;if(!K){const z=x.rawSplit(T);K=p.getBestVersionForData(z,Q)}C=x.fromString(T,K||40)}else throw new Error("Invalid data");const B=p.getBestVersionForData(C,Q);if(!B)throw new Error("The amount of data is too big to be stored in a QR Code");if(!V)V=B;else if(V<B)throw new Error(`
|
|
25
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
26
|
-
Minimum version required to store current data is: `+B+`.
|
|
27
|
-
`);const U=O(V,Q,C),$=t.getSymbolSize(V),ee=new a($);return v(ee,V),j(ee),D(ee,V),A(ee,Q,0),V>=7&&N(ee,V),R(ee,U),isNaN(I)&&(I=u.getBestMask(ee,A.bind(null,ee,Q))),u.applyMask(I,ee),A(ee,Q,I),{modules:ee,version:V,errorCorrectionLevel:Q,maskPattern:I,segments:C}}return Vc.create=function(V,Q){if(typeof V>"u"||V==="")throw new Error("No input text");let I=i.M,C,B;return typeof Q<"u"&&(I=i.from(Q.errorCorrectionLevel,i.M),C=p.from(Q.version),B=u.from(Q.maskPattern),Q.toSJISFunc&&t.setToSJISFunction(Q.toSJISFunc)),re(V,C,I,B)},Vc}var of={},uf={},uy;function Tb(){return uy||(uy=1,(function(t){function i(l){if(typeof l=="number"&&(l=l.toString()),typeof l!="string")throw new Error("Color should be defined as hex string");let a=l.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+l);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(f){return[f,f]}))),a.length===6&&a.push("F","F");const o=parseInt(a.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+a.slice(0,6).join("")}}t.getOptions=function(a){a||(a={}),a.color||(a.color={});const o=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,f=a.width&&a.width>=21?a.width:void 0,u=a.scale||4;return{width:f,scale:f?4:u,margin:o,color:{dark:i(a.color.dark||"#000000ff"),light:i(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},t.getScale=function(a,o){return o.width&&o.width>=a+o.margin*2?o.width/(a+o.margin*2):o.scale},t.getImageWidth=function(a,o){const f=t.getScale(a,o);return Math.floor((a+o.margin*2)*f)},t.qrToImageData=function(a,o,f){const u=o.modules.size,m=o.modules.data,h=t.getScale(u,f),p=Math.floor((u+f.margin*2)*h),y=f.margin*h,b=[f.color.light,f.color.dark];for(let x=0;x<p;x++)for(let v=0;v<p;v++){let j=(x*p+v)*4,D=f.color.light;if(x>=y&&v>=y&&x<p-y&&v<p-y){const N=Math.floor((x-y)/h),A=Math.floor((v-y)/h);D=b[m[N*u+A]?1:0]}a[j++]=D.r,a[j++]=D.g,a[j++]=D.b,a[j]=D.a}}})(uf)),uf}var cy;function JS(){return cy||(cy=1,(function(t){const i=Tb();function l(o,f,u){o.clearRect(0,0,f.width,f.height),f.style||(f.style={}),f.height=u,f.width=u,f.style.height=u+"px",f.style.width=u+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(f,u,m){let h=m,p=u;typeof h>"u"&&(!u||!u.getContext)&&(h=u,u=void 0),u||(p=a()),h=i.getOptions(h);const y=i.getImageWidth(f.modules.size,h),b=p.getContext("2d"),x=b.createImageData(y,y);return i.qrToImageData(x.data,f,h),l(b,p,y),b.putImageData(x,0,0),p},t.renderToDataURL=function(f,u,m){let h=m;typeof h>"u"&&(!u||!u.getContext)&&(h=u,u=void 0),h||(h={});const p=t.render(f,u,h),y=h.type||"image/png",b=h.rendererOpts||{};return p.toDataURL(y,b.quality)}})(of)),of}var cf={},fy;function WS(){if(fy)return cf;fy=1;const t=Tb();function i(o,f){const u=o.a/255,m=f+'="'+o.hex+'"';return u<1?m+" "+f+'-opacity="'+u.toFixed(2).slice(1)+'"':m}function l(o,f,u){let m=o+f;return typeof u<"u"&&(m+=" "+u),m}function a(o,f,u){let m="",h=0,p=!1,y=0;for(let b=0;b<o.length;b++){const x=Math.floor(b%f),v=Math.floor(b/f);!x&&!p&&(p=!0),o[b]?(y++,b>0&&x>0&&o[b-1]||(m+=p?l("M",x+u,.5+v+u):l("m",h,0),h=0,p=!1),x+1<f&&o[b+1]||(m+=l("h",y),y=0)):h++}return m}return cf.render=function(f,u,m){const h=t.getOptions(u),p=f.modules.size,y=f.modules.data,b=p+h.margin*2,x=h.color.light.a?"<path "+i(h.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",v="<path "+i(h.color.dark,"stroke")+' d="'+a(y,p,h.margin)+'"/>',j='viewBox="0 0 '+b+" "+b+'"',N='<svg xmlns="http://www.w3.org/2000/svg" '+(h.width?'width="'+h.width+'" height="'+h.width+'" ':"")+j+' shape-rendering="crispEdges">'+x+v+`</svg>
|
|
28
|
-
`;return typeof m=="function"&&m(null,N),N},cf}var dy;function ew(){if(dy)return al;dy=1;const t=MS(),i=ZS(),l=JS(),a=WS();function o(f,u,m,h,p){const y=[].slice.call(arguments,1),b=y.length,x=typeof y[b-1]=="function";if(!x&&!t())throw new Error("Callback required as last argument");if(x){if(b<2)throw new Error("Too few arguments provided");b===2?(p=m,m=u,u=h=void 0):b===3&&(u.getContext&&typeof p>"u"?(p=h,h=void 0):(p=h,h=m,m=u,u=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(m=u,u=h=void 0):b===2&&!u.getContext&&(h=m,m=u,u=void 0),new Promise(function(v,j){try{const D=i.create(m,h);v(f(D,u,h))}catch(D){j(D)}})}try{const v=i.create(m,h);p(null,f(v,u,h))}catch(v){p(v)}}return al.create=i.create,al.toCanvas=o.bind(null,l.render),al.toDataURL=o.bind(null,l.renderToDataURL),al.toString=o.bind(null,function(f,u,m){return a.render(f,m)}),al}var tw=ew();const nw=co(tw),iw={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 rw(t){const i={...iw,...t.labels},l=xi(t.authorization),[a,o]=w.useState({}),[f,u]=w.useState({}),[m,h]=w.useState(),[p,y]=w.useState(!1),[b,x]=w.useState(Date.now()),v=Math.min(t.authorization.expiresAt?Date.parse(t.authorization.expiresAt):1/0,l?Date.parse(l.expiresAt):1/0),j=l?.kind==="qr-code"&&l.qr?Date.parse(l.qr.challengeExpiresAt):1/0,D=l?.kind==="qr-code"&&l.phase!=="expired"?l.qr?.payload:void 0;if(w.useEffect(()=>{o({}),u({})},[t.authorization.id,l?.id]),w.useEffect(()=>{x(Date.now());const T=[v,j].filter(V=>Number.isFinite(V)&&V>Date.now()).map(V=>setTimeout(()=>x(Date.now()),V-Date.now()+1));return()=>{for(const V of T)clearTimeout(V)}},[v,j]),w.useEffect(()=>{let T=!0;if(h(void 0),y(!1),!D||D.length>4096||j<=Date.now()){D&&D.length>4096&&y(!0);return}return nw.toDataURL(D,{width:220,margin:2,errorCorrectionLevel:"M"}).then(V=>{T&&h(V)}).catch(()=>{T&&y(!0)}),()=>{T=!1}},[D,j]),t.authorization.state!=="pending"){const T=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 c.jsx("p",{className:"link-authorization-status",role:"status",children:T})}if(!l)return c.jsx("p",{role:"alert",children:i.unsupported});if(!Number.isFinite(v)||v<=b)return c.jsx("p",{className:"link-authorization-status",role:"status",children:i.expired});const N=!!t.busy,A=(T,V)=>t.onRespond({stepId:l.id,operation:T,...V?{input:V}:{}}),R=T=>{if(t.canOpenUrl===!1)return null;const V=a1(T);return V?c.jsxs("button",{type:"button",disabled:N,onClick:()=>t.onOpenUrl(V),children:[i.openPage," ↗"]}):c.jsx("p",{role:"alert",children:i.invalidUrl})},O=c.jsxs("p",{className:"link-authorization-expires",children:[i.expiresAt," ",new Date(v).toLocaleTimeString()]}),Y=t.authorization.errorCode?c.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,re=()=>{switch(l.kind){case"redirect":return c.jsxs("div",{className:"link-authorization-step",role:"status",children:[c.jsx("p",{children:i.waitingBrowser}),R(l.authorizationUrl),O]});case"device-code":return c.jsxs("div",{className:"link-authorization-step link-authorization-device",children:[c.jsx("p",{children:i.deviceInstruction}),c.jsx("strong",{className:"link-authorization-code",children:l.userCode}),c.jsxs("div",{className:"link-authorization-actions",children:[t.onCopy&&c.jsx("button",{type:"button",onClick:()=>t.onCopy?.(l.userCode),children:i.copy}),R(l.verificationUriComplete??l.verificationUri)]}),O]});case"qr-code":{const T=l.phase==="expired"||j<=b;return c.jsxs("div",{className:"link-authorization-step link-authorization-qr",children:[c.jsx("p",{role:"status",children:T?i.qrExpired:l.phase==="awaiting-confirmation"?i.confirmOnPhone:i.scan}),!T&&m&&c.jsx("img",{width:220,height:220,src:m,alt:i.qrAlt}),!T&&p&&c.jsx("p",{role:"alert",children:i.qrError}),!T&&l.qr?.instructions.map((V,Q)=>c.jsx("p",{children:V},Q)),l.canRefresh&&c.jsx("button",{type:"button",disabled:N,onClick:()=>A("refresh-qr"),children:i.refreshQr}),O]})}case"credential-input":return c.jsxs("form",{className:"link-authorization-step link-authorization-fields",onSubmit:T=>{if(T.preventDefault(),N)return;const V={};for(const Q of l.fields)V[Q.id]=a[Q.id]??"";o({}),A("submit",V)},children:[l.purpose!=="credential"&&c.jsx("p",{children:l.purpose==="verification-code"?i.verifyCode:i.secondFactor}),l.fields.map(T=>c.jsxs("label",{children:[T.label,c.jsx("input",{name:T.id,type:T.secret?"password":"text",autoComplete:"off",spellCheck:!1,value:a[T.id]??"",placeholder:T.placeholder,maxLength:Math.min(T.maxLength??16384,16384),required:T.required,disabled:N,onChange:V=>o(Q=>({...Q,[T.id]:V.target.value}))})]},T.id)),c.jsx("button",{type:"submit",disabled:N||l.fields.some(T=>T.required&&!a[T.id]?.trim()),children:i.submit}),O]});case"local-session":return c.jsxs("div",{className:"link-authorization-step",children:[c.jsx("p",{role:"status",children:l.session.authenticated?`${i.authenticated}${l.session.account?`:${l.session.account}`:""}`:l.session.installed?i.notAuthenticated:i.notInstalled}),l.session.message&&c.jsx("p",{children:l.session.message}),c.jsxs("div",{className:"link-authorization-actions",children:[c.jsx("button",{type:"button",disabled:N,onClick:()=>A("detect-session"),children:i.detectSession}),!l.session.authenticated&&l.session.canLogin&&c.jsx("button",{type:"button",disabled:N,onClick:()=>A("login-session"),children:i.loginSession}),l.session.authenticated&&c.jsx("button",{type:"button",disabled:N,onClick:()=>A("bind-session"),children:i.bindSession})]}),O]});case"consent":{const T=f.permissions??l.permissions.filter(I=>I.required).map(I=>I.id),V=(I,C,B,U)=>u($=>({...$,[I]:B?[...new Set([...U,C])]:U.filter(ee=>ee!==C)})),Q=l.resourceGroups.some(I=>{const C=(f[I.id]??[]).length;return C<(I.minSelected??0)||C>(I.maxSelected??1/0)||I.truncated});return c.jsxs("form",{className:"link-authorization-step link-authorization-consent",onSubmit:I=>{I.preventDefault(),!N&&!Q&&A("confirm",{...f,permissions:T})},children:[c.jsx("p",{children:c.jsx("strong",{children:l.account.label})}),c.jsx("div",{children:l.permissions.map(I=>c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:I.required||T.includes(I.id),disabled:N||I.required,onChange:C=>V("permissions",I.id,C.target.checked,T)}),I.label,I.description&&c.jsx("small",{children:I.description})]},I.id))}),l.resourceGroups.map(I=>c.jsxs("fieldset",{children:[c.jsx("legend",{children:I.label}),I.items.map(C=>c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:(f[I.id]??[]).includes(C.id),disabled:N,onChange:B=>V(I.id,C.id,B.target.checked,f[I.id]??[])}),C.label,C.description&&c.jsx("small",{children:C.description})]},C.id)),I.truncated&&c.jsx("p",{children:i.resourcesTruncated})]},I.id)),c.jsx("button",{type:"submit",disabled:N||Q,children:i.confirm}),O]})}case"processing":return c.jsx("p",{className:"link-authorization-status",role:"status",children:i.processing});default:return c.jsx("p",{role:"alert",children:i.unsupported})}};return c.jsxs(c.Fragment,{children:[Y,re()]})}const Hn="/api/v1/links",lw={connected:"已连接",expired:"授权已过期",invalid:"需要重新连接",unavailable:"凭据不可用"};function sl(t){try{const i=new URL(t??"");return i.protocol==="https:"&&!i.username&&!i.password?i.href:void 0}catch{return}}function aw({onAuthLost:t,onDirtyChange:i,hostLabel:l="服务端",configurationVersion:a=0}){const[o,f]=w.useState(),[u,m]=w.useState(),[h,p]=w.useState(""),[y,b]=w.useState(""),[x,v]=w.useState(""),[j,D]=w.useState(!0),[N,A]=w.useState(!1),[R,O]=w.useState(),[Y,re]=w.useState(),[T,V]=w.useState(),[Q,I]=w.useState(),C=w.useRef(new Map),B=w.useRef(new Set),[U,$]=w.useState(),ee=w.useMemo(()=>new u1({begin:async(M,P)=>{const ge=no(),{workspace:Se,projectId:Ce}=ge,Re=await He(St(`${Hn}/authorizations`,Se,Ce),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M,authModeId:P})},ge);return C.current.set(Re.id,{target:St(`${Hn}/authorizations/${encodeURIComponent(Re.id)}`,Se,Ce),scope:ge}),Re},status:M=>{const P=C.current.get(M);return He(P.target,{},P.scope)},respond:(M,P)=>{const ge=C.current.get(M),Se=new URL(ge.target,window.location.origin);return Se.pathname+="/responses",He(Se.pathname+Se.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)},ge.scope)},cancel:async M=>{if(B.current.has(M))return;const P=C.current.get(M);P&&(await He(P.target,{method:"DELETE",keepalive:!0},P.scope),C.current.delete(M))}}),[]),K=w.useSyncExternalStore(ee.subscribe,ee.getSnapshot),z=o?.capabilities.authorizationSteps===1&&!!u?.provider.authModes,Z=z&&K.authorization?.state==="pending",[he,me]=w.useState(0),k=w.useRef(!1),L=w.useRef(0),J=w.useRef(null),_=w.useRef(void 0),te=w.useRef(void 0),xe=w.useRef(void 0),ae=w.useRef(void 0),se=w.useRef({onAuthLost:t,onDirtyChange:i});se.current={onAuthLost:t,onDirtyChange:i};const ye=N||K.busy||Z||T?.state==="pending"||!!(u&&(u.token||u.label!==(u.original?.label??u.provider.displayName))),F=w.useCallback(M=>{M instanceof Pe&&M.status===401?se.current.onAuthLost():b(M instanceof Error?M.message:"连接操作失败,请重试。")},[]);w.useEffect(()=>{if(!u)return;const M=document.activeElement;return J.current?.querySelector("input:not(:disabled), button:not(:disabled)")?.focus(),()=>M?.focus?.()},[!!u]),w.useEffect(()=>{se.current.onDirtyChange?.(ye)},[ye]),w.useEffect(()=>{k.current=!0;const M=++L.current;return()=>{k.current=!1,se.current.onDirtyChange?.(!1),_.current?.abort(),queueMicrotask(()=>{L.current===M&&ee.dispose()}),te.current&&He(te.current,{method:"DELETE",keepalive:!0},xe.current).catch(()=>{})}},[ee]),w.useEffect(()=>{const M=new AbortController;return ae.current=M,D(!0),He(Hn,{signal:M.signal}).then(P=>{M.signal.aborted||f(P)}).catch(P=>{M.signal.aborted||F(P)}).finally(()=>{M.signal.aborted||D(!1)}),()=>M.abort()},[he,a,F]),w.useEffect(()=>{z&&(K.error&&F(K.error),K.authorization?.state==="connected"&&K.authorization.connection&&(m(void 0),v("授权完成,连接已保存。"),me(M=>M+1)))},[z,K.authorization,K.error,F]),w.useEffect(()=>{if(!o?.remoteCleanupPending)return;const M=setInterval(()=>me(P=>P+1),3e4);return()=>clearInterval(M)},[o?.remoteCleanupPending]),w.useEffect(()=>{if(T?.state!=="pending"||!te.current)return;const M=te.current,P=xe.current,ge=new AbortController;let Se;const Ce=async()=>{try{const Re=await He(M,{signal:ge.signal},P);if(ge.signal.aborted||te.current!==M)return;V(Re),Re.state==="connected"?(te.current=void 0,m(void 0),v("授权完成,连接已保存。"),me(Qe=>Qe+1)):Re.state!=="pending"?(te.current=void 0,b(Re.state==="cancelled"?"授权已取消。":"授权未完成或已过期,请重新开始。")):Se=setTimeout(()=>{Ce()},2e3)}catch(Re){if(ge.signal.aborted||te.current!==M)return;F(Re),Re instanceof Pe&&[401,404].includes(Re.status)?(te.current=void 0,V(Qe=>Qe?{...Qe,state:"failed"}:void 0)):Se=setTimeout(()=>{Ce()},4e3)}};return Se=setTimeout(()=>{Ce()},1e3),()=>{ge.abort(),clearTimeout(Se)}},[T?.id,T?.state,F]);async function we(M,P){if(_.current)return;const ge=new AbortController;_.current=ge,ae.current?.abort(),A(!0),D(!1),b(""),v("");try{const Se=await M(ge.signal);k.current&&!ge.signal.aborted&&P(Se)}catch(Se){k.current&&!ge.signal.aborted&&(F(Se),Se instanceof Pe&&[409,503].includes(Se.status)&&me(Ce=>Ce+1))}finally{_.current===ge&&(_.current=void 0),k.current&&A(!1)}}function Le(M,P,ge,Se,Ce){return He(M,{method:P,headers:{"Content-Type":"application/json"},body:JSON.stringify(ge),signal:Se},Ce)}function Ae(){return{providerId:u.provider.id,methodId:u.methodId,label:u.label.trim(),expectedRevision:u.original?.revision??null,...u.original?{connectionId:u.original.id}:{}}}function Te(){m(void 0),re(void 0),v("连接已保存。"),me(M=>M+1)}function tt(M,P){if(N||K.busy||Z||T?.state==="pending"||ye&&!window.confirm("放弃当前未保存的连接修改?"))return;ee.reset();const ge=P?Rc(M,P.methodId):Rc(M),Se=P?M.connectionMethods.find(Re=>Re.id===P.methodId):M.connectionMethods.find(Re=>Re.id===ge?.methodId)??M.connectionMethods.find(Re=>Re.executionRuntime==="local"&&Re.availability==="available");if(!Se){b("当前环境未提供此连接的授权方式,请检查服务器连接设置。");return}const Ce={provider:M,original:P,methodId:Se.id,label:P?.label??M.displayName,token:""};m(Ce),re(void 0),V(void 0),I(ge?.id),b(""),v(""),!P&&o?.capabilities.authorizationSteps===1&&ge&&ut(Ce,ge)}async function ut(M,P){if(!P.available||!M.label.trim()||ee.getSnapshot().authorization?.state==="pending"&&(await ee.cancel(),ee.getSnapshot().authorization?.state==="pending"))return;b(""),I(P.id),m({...M,methodId:P.methodId});const ge={workspace:io()??"",projectId:Sa()},Se=await ee.begin({providerId:M.provider.id,methodId:P.methodId,label:M.label.trim(),expectedRevision:M.original?.revision??null,...M.original?{connectionId:M.original.id}:{}},P.id);if(!(Se?.state!=="pending"||xi(Se)?.kind!=="redirect"))try{if(o?.capabilities.browserHandoff===1){const Qe=C.current.get(Se.id),yt=new URL(Qe.target,window.location.origin);yt.pathname+="/browser";const pt=await He(yt.pathname+yt.search,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},Qe.scope),mt=new URL(pt.launchUrl);if(mt.origin!==window.location.origin||mt.pathname!=="/link/authorize"||mt.username||mt.password||mt.hash||mt.searchParams.size!==1||!/^[A-Za-z0-9_-]{43}$/.test(mt.searchParams.get("ticket")??""))throw new Error("授权浏览器入口无效,请重新连接。");ee.getSnapshot().authorization?.id===Se.id&&ee.getSnapshot().authorization?.state==="pending"&&$({id:Se.id,url:mt.href});return}const Ce=o?.remoteServer?.issuer;if(!Ce)throw new Error("当前 Host 尚未配置授权服务。");const Re=d1(Se,Ce,ge);B.current.add(Se.id),mS.flushSync(()=>{m(void 0),se.current.onDirtyChange?.(!1)}),window.location.assign(Re)}catch(Ce){await ee.cancel(),F(Ce)}}async function Ge(){if(Z){await ee.cancel(),ee.getSnapshot().authorization?.state==="cancelled"&&v("授权已取消。");return}if(!te.current)return;const M=te.current,P=xe.current;await we(ge=>He(M,{method:"DELETE",signal:ge},P),()=>{te.current=void 0,V(void 0),v("授权已取消。")})}function Lt(){z?ee.cancel().then(()=>{ee.getSnapshot().authorization?.state!=="pending"&&m(void 0)}):!Fe&&(!ye||window.confirm("放弃未保存的连接修改?"))&&m(void 0)}function ct(M,P=no()){if(z&&ee.getSnapshot().authorization?.state==="pending"&&u?.original?.id===M.id){ee.cancel().then(()=>{ee.getSnapshot().authorization?.state!=="pending"&&ct(M,P)});return}const ge=u?.original?.id===M.id&&T?.state==="pending"?te.current:void 0,Se=St(`${Hn}/connections/${encodeURIComponent(M.id)}`,P.workspace,P.projectId),Ce=xe.current;we(async Re=>{if(ge){try{await He(ge,{method:"DELETE",signal:Re},Ce)}catch(Qe){if(!(Qe instanceof Pe&&Qe.status===404))throw Qe}k.current&&!Re.aborted&&te.current===ge&&(te.current=void 0,V(void 0))}return Le(Se,"DELETE",{expectedRevision:M.revision},Re,P)},()=>{u?.original?.id===M.id&&m(void 0),O(void 0),me(Re=>Re+1),v("连接已断开。")})}const qe=u?.provider.connectionMethods.find(M=>M.id===u.methodId),ht=T?.state==="pending",Fe=N||K.busy||ht||Z,nt=h.trim().toLowerCase(),Et=(o?.providers??[]).filter(M=>(o?.capabilities.authorizationSteps!==1||M.authModes?.some(P=>P.available))&&`${M.displayName} ${M.description.zh}`.toLowerCase().includes(nt)),lt=u&&o?.connections.find(M=>u.original?M.id===u.original.id:M.id===`link-${u.provider.id}-${u.methodId}`&&M.providerId===u.provider.id&&M.methodId===u.methodId),bt=u&&o&&(u.original?lt?.revision!==u.original.revision:!!lt);return c.jsxs("section",{className:"hub-links",children:[c.jsxs("header",{className:"links-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{children:"Link"}),c.jsx("p",{children:"连接你的工具与账号,让任务访问已授权的服务。"})]}),c.jsx("button",{onClick:()=>{b(""),me(M=>M+1)},disabled:N||j,children:"刷新"})]}),!!o?.remoteCleanupPending&&c.jsxs("p",{role:"status",className:"links-muted",children:["有 ",o.remoteCleanupPending," 项遗留授权等待撤销。项目所在环境 会自动重试,重启后仍会继续;也可在 Link 服务中撤销。"]}),c.jsxs("p",{className:"links-host",children:["连接由当前项目所属的",l,"管理,授权后只访问你允许的服务与资源。"]}),y&&c.jsx("p",{className:"form-error",role:"alert",children:y}),x&&c.jsx("p",{className:"links-notice",role:"status",children:x}),j&&!o&&c.jsx("p",{role:"status",children:"正在加载连接…"}),c.jsx("h2",{children:"已连接"}),o&&o.connections.length===0&&c.jsx("p",{className:"links-muted",children:"还没有连接。选择下面的服务开始。"}),c.jsx("div",{className:"links-connections",children:o?.connections.map(M=>{const P=o.providers.find(ge=>ge.id===M.providerId);return c.jsxs("article",{className:"links-connection",children:[c.jsxs("div",{children:[c.jsx("strong",{children:M.label}),c.jsxs("p",{children:[P?.displayName??M.providerId," ·"," ",M.account?.label??M.account?.id??"已授权账号"]}),c.jsx("span",{className:`links-state ${M.status==="connected"?"ready":""}`,children:lw[M.status]}),c.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?c.jsx("p",{children:M.account.resources.join("、")}):null]}),c.jsx("div",{className:"links-actions",children:M.editable?c.jsxs(c.Fragment,{children:[c.jsx("button",{disabled:Fe||!P,onClick:()=>P&&tt(P,M),children:"管理连接"}),c.jsx("button",{disabled:N,onClick:()=>O(M),children:"断开"})]}):c.jsx("small",{children:"项目配置管理"})})]},M.id)})}),R&&c.jsxs("div",{className:"links-confirm",role:"alertdialog","aria-label":"断开连接",children:[c.jsxs("p",{children:["断开「",R.label,"」后,后续任务将无法使用这个连接,正在执行的请求会尝试停止。"]}),c.jsx("button",{disabled:N,onClick:()=>ct(R),children:"确认断开"}),c.jsx("button",{disabled:N,onClick:()=>O(void 0),children:"取消"})]}),u&&qe&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"links-editor-backdrop","aria-hidden":"true"}),c.jsxs("section",{className:"links-editor",ref:J,onKeyDown:M=>{if(M.key==="Escape"&&(M.preventDefault(),Lt()),M.key!=="Tab")return;const P=J.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), a[href], summary");if(!P?.length)return;const ge=P[0],Se=P[P.length-1];M.shiftKey&&document.activeElement===ge?(M.preventDefault(),Se.focus()):!M.shiftKey&&document.activeElement===Se&&(M.preventDefault(),ge.focus())},role:"dialog","aria-modal":"true","aria-label":`${u.provider.displayName} 连接设置`,children:[c.jsxs("div",{className:"links-heading",children:[c.jsxs("h2",{children:[u.provider.displayName," · ",u.original?"管理连接":"添加连接"]}),c.jsx("button",{disabled:!z&&Fe,onClick:Lt,children:"关闭"})]}),c.jsxs("label",{children:["连接名称",c.jsx("input",{maxLength:100,value:u.label,disabled:Fe,onChange:M=>m({...u,label:M.target.value})})]}),bt&&c.jsxs("div",{className:"links-conflict",role:"alert",children:[c.jsx("p",{children:"这个连接已在其他设备创建、修改或删除。你的输入仍然保留,请先载入最新版本。"}),c.jsx("button",{disabled:Fe,onClick:()=>m({...u,original:lt||void 0}),children:"载入最新版本,保留输入"})]}),z?c.jsxs("div",{className:"links-authorization",children:[c.jsx("p",{className:"links-muted",children:qe.executionRuntime==="server"?"由 Link 服务保存授权并访问已选择的资源。":`连接保存到当前项目所属的${l}。`}),K.authorization?c.jsx(rw,{authorization:K.authorization,busy:K.busy||!!bt||o?.capabilities.browserHandoff===1&&xi(K.authorization)?.kind==="redirect"&&U?.id!==K.authorization.id,onRespond:M=>{ee.respond(M)},onOpenUrl:M=>{const ge=o?.capabilities.browserHandoff===1&&xi(K.authorization)?.kind==="redirect"?U&&U.id===K.authorization?.id?U.url:void 0:M;ge&&window.open(ge,"_blank","noopener,noreferrer")},onCopy:M=>{navigator.clipboard?.writeText(M).catch(F)}}):c.jsx("button",{disabled:K.busy||!!bt||!u.label.trim(),onClick:()=>{const M=u.provider.authModes?.find(P=>P.id===Q&&P.available)??Rc(u.provider,u.methodId);M&&ut(u,M)},children:K.busy?"正在连接…":u.original?"重新连接":"开始连接"}),c.jsxs("div",{className:"links-actions",children:[Z&&c.jsx("button",{disabled:K.busy,onClick:()=>{Ge()},children:"取消授权"}),K.authorization&&K.authorization.state!=="pending"&&c.jsx("button",{disabled:K.busy||!!bt||!u.label.trim(),onClick:()=>{const M=u.provider.authModes?.find(P=>P.id===Q&&P.available);M&&ut(u,M)},children:"重新连接"})]}),c.jsxs("details",{className:"links-other-methods",children:[c.jsx("summary",{children:"其他连接方式"}),c.jsx("div",{className:"links-methods",children:u.provider.authModes?.map(M=>c.jsxs("button",{disabled:K.busy||!M.available||!!bt||!u.label.trim(),title:M.unavailableReason,onClick:()=>{ut(u,M)},children:[M.label,M.id===Q?" · 当前":""]},M.id))})]}),u.original&&c.jsx("button",{disabled:Fe||!!bt||!u.label.trim(),onClick:()=>{we(M=>Le(`${Hn}/connections/${encodeURIComponent(u.original.id)}`,"PATCH",{label:u.label.trim(),expectedRevision:u.original.revision},M),Te)},children:"保存名称"})]}):c.jsxs(c.Fragment,{children:[qe.browserAuth&&c.jsxs("div",{className:"links-auth-option",children:[c.jsx("h3",{children:"浏览器授权"}),u.provider.deviceAuth?.configured?c.jsx("button",{disabled:Fe||!u.label.trim()||!!bt,onClick:()=>{const M=io()??"",P=Sa(),ge={workspace:M,projectId:P},Se=St(`${Hn}/authorizations/device`,M,P);we(Ce=>Le(Se,"POST",Ae(),Ce,ge),Ce=>{te.current=St(`${Hn}/authorizations/${encodeURIComponent(Ce.id)}`,M,P),xe.current=ge,V(Ce)})},children:"开始授权"}):c.jsxs("p",{className:"links-muted",children:["这台",l,"尚未配置此服务的浏览器授权,可使用下面的连接方式。"]}),ht&&T.prompt&&c.jsxs("div",{className:"links-device-code",role:"status",children:[c.jsx("p",{children:"在服务商页面输入验证码:"}),c.jsx("strong",{children:T.prompt.userCode}),c.jsx("p",{children:sl(T.prompt.verificationUriComplete??T.prompt.verificationUri)&&c.jsx("a",{href:sl(T.prompt.verificationUriComplete??T.prompt.verificationUri),target:"_blank",rel:"noreferrer",children:"打开授权页面 ↗"})}),c.jsxs("p",{children:["完成后会自动保存。有效期至"," ",new Date(T.prompt.expiresAt).toLocaleTimeString(),"。"]}),c.jsx("button",{disabled:N,onClick:()=>{Ge()},children:"取消授权"})]})]}),qe.quickAuth&&c.jsxs("div",{className:"links-auth-option",children:[c.jsx("h3",{children:"使用已登录的 CLI"}),c.jsxs("p",{children:[l,"需要已安装并登录 ",qe.quickAuth.command,"。"]}),c.jsx("button",{disabled:Fe,onClick:()=>{we(M=>He(`${Hn}/providers/${encodeURIComponent(u.provider.id)}/cli`,{signal:M}),re)},children:"检查登录状态"}),Y&&c.jsx("p",{role:"status",children:Y.authenticated?`已登录${Y.account?`:${Y.account}`:""}`:Y.installed?"已安装,尚未登录。请在运行服务的机器上登录。":"尚未安装。"}),Y?.authenticated&&c.jsx("button",{disabled:Fe||!u.label.trim()||!!bt,onClick:()=>{we(M=>Le(`${Hn}/connections/cli`,"POST",Ae(),M),Te)},children:"绑定这个登录"})]}),qe.authKind==="token"&&c.jsxs("form",{className:"links-auth-option",onSubmit:M=>{M.preventDefault(),!(Fe||bt)&&we(P=>u.original&&!u.token.trim()?Le(`${Hn}/connections/${encodeURIComponent(u.original.id)}`,"PATCH",{label:u.label.trim(),expectedRevision:u.original.revision},P):Le(`${Hn}/connections/token`,"POST",{...Ae(),token:u.token.trim()},P),Te)},children:[c.jsx("h3",{children:u.original?"名称与 Token":"使用 Token"}),qe.authGuide&&c.jsxs(c.Fragment,{children:[c.jsx("p",{children:qe.authGuide.summary.zh}),c.jsxs("div",{className:"links-actions",children:[sl(qe.authGuide.createCredentialUrl)&&c.jsx("a",{href:sl(qe.authGuide.createCredentialUrl),target:"_blank",rel:"noreferrer",children:"创建凭据 ↗"}),sl(qe.authGuide.docsUrl)&&c.jsx("a",{href:sl(qe.authGuide.docsUrl),target:"_blank",rel:"noreferrer",children:"授权说明 ↗"})]}),c.jsxs("details",{children:[c.jsx("summary",{children:"所需权限与设置步骤"}),c.jsx("ul",{children:qe.authGuide.permissions.map(M=>c.jsxs("li",{children:[M.label,"(",M.level==="required"?"必需":"可选",")",M.description?`:${M.description.zh}`:""]},M.id))}),c.jsx("ol",{children:qe.authGuide.steps.map((M,P)=>c.jsx("li",{children:M.zh},P))})]})]}),c.jsxs("label",{children:[qe.tokenLabel??u.provider.tokenLabel,c.jsx("input",{type:"password",autoComplete:"off",value:u.token,disabled:Fe,placeholder:u.original?"留空保留当前授权,仅修改名称":qe.tokenPlaceholder??u.provider.tokenPlaceholder,onChange:M=>m({...u,token:M.target.value}),required:!u.original,maxLength:16384})]}),c.jsx("button",{type:"submit",className:"send",disabled:Fe||!!bt||!u.label.trim(),children:N?"正在验证并保存…":u.token.trim()||!u.original?"验证并保存":"保存名称"})]})]}),c.jsxs("details",{children:[c.jsxs("summary",{children:[z?"服务支持的操作":"可用操作","(",u.provider.actions.length,")"]}),z&&c.jsx("p",{className:"links-muted",children:"此连接实际可用的操作以授权时确认的权限为准。"}),c.jsx("ul",{children:u.provider.actions.map(M=>c.jsxs("li",{children:[c.jsx("strong",{children:M.title}),M.risk==="write"?" · 执行前需要确认":"",c.jsx("p",{children:M.description})]},M.id))})]})]})]}),c.jsxs("div",{className:"links-heading",children:[c.jsx("h2",{children:"添加服务"}),c.jsx("input",{type:"search","aria-label":"搜索 Link 服务",placeholder:"搜索服务",value:h,onChange:M=>p(M.target.value)})]}),c.jsx("div",{className:"links-providers",children:Et.map(M=>{const P=o?.connections.find(ge=>ge.providerId===M.id);return c.jsxs("article",{className:"links-provider",children:[c.jsx("div",{className:`links-brand accent-${M.accent}`,"aria-hidden":"true",children:M.brandText}),c.jsx("h3",{children:M.displayName}),c.jsx("p",{children:M.description.zh}),c.jsxs("small",{children:[M.actions.length," 项操作"]}),c.jsx("button",{disabled:Fe||o?.capabilities.authorizationSteps!==1&&!!(P&&!P.editable),onClick:()=>tt(M,o?.capabilities.authorizationSteps===1?void 0:P),children:o?.capabilities.authorizationSteps===1?"添加连接":P?P.editable?"管理连接":"项目配置管理":"添加连接"})]},M.id)})}),o&&Et.length===0&&c.jsx("p",{className:"links-muted",children:"没有匹配的服务。"})]})}const ff="/api/v1/panels",hy="https://github.com/cjhyy/codeshell-panel-apps.git",py={"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 Xs({value:t}){return t.supported&&t.reasons.length===0?null:c.jsxs("div",{className:"panels-warning",children:[c.jsx("strong",{children:t.supported?"部分功能可用":"当前 Web 工作台暂不支持此面板"}),t.supported&&c.jsx("p",{children:"可以打开面板,以下功能当前不可用或需要额外配置。"}),t.reasons.length>0&&c.jsx("ul",{children:t.reasons.map(i=>c.jsx("li",{children:i},i))})]})}function sw({onAuthLost:t,onDirtyChange:i,onChanged:l,onOpen:a,hostLabel:o="服务端",configurationVersion:f=0}){const[u,m]=w.useState(),[h,p]=w.useState(""),[y,b]=w.useState(""),[x,v]=w.useState(""),[j,D]=w.useState(""),[N,A]=w.useState(),[R,O]=w.useState(),[Y,re]=w.useState(),[T,V]=w.useState(),[Q,I]=w.useState(!1),[C,B]=w.useState(),[U,$]=w.useState(),[ee,K]=w.useState(!1),[z,Z]=w.useState(!0),[he,me]=w.useState(!1),[k,L]=w.useState(),[J,_]=w.useState(!0),[te,xe]=w.useState(""),[ae,se]=w.useState(""),[ye,F]=w.useState(""),[we,Le]=w.useState(0),Ae=w.useRef(!1),Te=w.useRef(void 0),tt=w.useRef(void 0),ut=w.useRef(!1),Ge=w.useRef(void 0),Lt=w.useRef(null),ct=w.useRef({onAuthLost:t,onDirtyChange:i,onChanged:l,onOpen:a});ct.current={onAuthLost:t,onDirtyChange:i,onChanged:l,onOpen:a};function qe(q){fetch(q.target,{method:"DELETE",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviewToken:q.token}),keepalive:!0,signal:AbortSignal.timeout(5e3)}).catch(()=>{})}const ht=!!(te||R||Y||U||k||h.trim()||y.trim()||x.trim()),Fe=w.useCallback(q=>{q instanceof Pe&&q.status===401?ct.current.onAuthLost():se(q instanceof Error?q.message:"面板操作失败,请重试。")},[]);w.useEffect(()=>(Ae.current=!0,()=>{Ae.current=!1,Te.current?.abort(),tt.current?.abort(),Ge.current&&(qe(Ge.current),Ge.current=void 0),ct.current.onDirtyChange?.(!1)}),[]),w.useEffect(()=>{ct.current.onDirtyChange?.(ht)},[ht]),w.useEffect(()=>{if(Te.current){ut.current=!0;return}const q=new AbortController;return tt.current=q,_(!0),He(St(ff),{signal:q.signal}).then(ce=>{q.signal.aborted||m(ce)}).catch(ce=>{q.signal.aborted||Fe(ce)}).finally(()=>{q.signal.aborted||_(!1)}),()=>q.abort()},[we,f,Fe]),w.useEffect(()=>{R&&Lt.current?.focus()},[R?.reviewToken]);async function nt(q,ce,je,Ke,st=!1,Rt){if(Te.current||!Ae.current)return;const Ct=new AbortController;Te.current=Ct,tt.current?.abort(),_(!1),xe(q),se(""),F("");const Wn=St(`${ff}${ce}`);try{const Vt=await He(Wn,{method:je,headers:{"Content-Type":"application/json"},body:JSON.stringify(Ke),signal:Ct.signal});if(Ct.signal.aborted||!Ae.current){Rt?.(Vt);return}return st&&(ut.current=!0,ct.current.onChanged?.()),Vt}catch(Vt){if(Ct.signal.aborted||!Ae.current)return;Vt instanceof Pe&&(Vt.status===409||Vt.status===410)&&(R&&K(!0),T&&I(!0),ut.current=!0),Fe(Vt);return}finally{Te.current===Ct&&(Te.current=void 0),Ae.current&&!Ct.signal.aborted&&(xe(""),ut.current&&(ut.current=!1,Le(Vt=>Vt+1)))}}const Et=async q=>{if(!await Qe())return;re(void 0),V(void 0),$(void 0),O(void 0),L(void 0),A(void 0);const ce=await nt("正在读取仓库…","/github/discover","POST",{url:q.url,...q.ref?{ref:q.ref}:{},...q.subdir?{subdir:q.subdir}:{}});ce&&A(ce)},lt=async q=>{if(!await Qe())return;re(void 0),V(void 0);const ce=await nt("正在准备安装审阅…","/preview","POST",{source:q});ce&&(L(void 0),B(q),O(ce),K(!1),me(!1),Z(!!u?.hasProject&&ce.compatibility.supported))},bt=async q=>{if(!await Qe())return;re(void 0),V(void 0);const ce=await nt("正在检查更新…",`/${encodeURIComponent(q.id)}/update-preview`,"POST",{expectedRevision:q.revision});ce&&(L(void 0),B(void 0),O(ce),K(!1),me(q.bound),Z(q.bound&&ce.compatibility.supported))},M=()=>{if(R)if(R.kind==="update"){const q=u?.panels.find(ce=>ce.id===R.preview.id);q?bt(q):(se("此面板已被卸载,请重新从 GitHub 选择安装。"),O(void 0))}else C&<(C)},P=()=>{$(void 0),A(void 0),p(""),b(""),v("")},ge=async()=>{if(O(void 0),!U||U.position+1>=U.candidates.length){P();return}const q=U.position+1;$({...U,position:q}),await lt(U.candidates[q].source)},Se=async q=>{q.length&&($({candidates:q,position:0}),await lt(q[0].source))},Ce=async()=>{if(!R||ee)return;if(R.expiresAt<=Date.now()){K(!0),se("安装审阅已过期,请重新审阅后继续。");return}await nt(R.kind==="update"?"正在更新面板…":"正在安装面板…","/install","POST",{reviewToken:R.reviewToken,bind:z},!0)&&(F(`${Vn(R.preview.title)} 已${R.kind==="update"?"更新":"安装"}${z?"并绑定当前工作区":""}。`),O(void 0),U?await ge():P())},Re=async q=>{const ce=await nt(q.bound?"正在解除绑定…":"正在绑定工作区…",`/${encodeURIComponent(q.id)}/binding`,"PATCH",{bound:!q.bound,expectedRevision:q.revision},!0);ce&&(m(ce),F(`${Vn(q.title)} 已${q.bound?"解除当前工作区绑定":"绑定当前工作区"}。`))},Qe=async()=>T?(await nt("正在关闭版本审阅…","/restore/review","DELETE",{reviewToken:T.reviewToken}))?.cancelled?(Ge.current=void 0,V(void 0),!0):!1:!0,yt=async()=>{await Qe()&&re(void 0)},pt=async q=>{if(!await Qe())return;O(void 0),L(void 0),V(void 0),re(void 0);const ce=await nt("正在检查保留版本…",`/${encodeURIComponent(q.id)}/versions`,"POST",{expectedRevision:q.revision});ce&&(re(ce),I(!1))},mt=async q=>{if(!Y||!await Qe())return;const ce=St(`${ff}/restore/review`),je=await nt("正在审阅项目版本…",`/${encodeURIComponent(Y.appId)}/restore-preview`,"POST",{packageDigest:q,expectedRevision:Y.expectedRevision},!1,Ke=>qe({target:ce,token:Ke.reviewToken}));if(je){if(!Ae.current){qe({target:ce,token:je.reviewToken});return}Ge.current={target:ce,token:je.reviewToken},V(je),I(!1)}},Ze=async()=>{if(!T||ke)return;if(T.expiresAt<=Date.now()){I(!0),se("版本审阅已过期,请重新选择版本。");return}await nt("正在恢复项目版本…","/restore","POST",{reviewToken:T.reviewToken},!0)&&(Ge.current=void 0,F(`${Vn(T.title)} 的项目版本已恢复为 v${T.version}。`),re(void 0),V(void 0))},oe=async()=>{if(!k||u?.panels.find(ce=>ce.id===k.id)?.revision!==k.revision)return;(await nt("正在卸载面板…",`/${encodeURIComponent(k.id)}`,"DELETE",{expectedRevision:k.revision},!0))?.removed&&(F(`${Vn(k.title)} 已卸载。`),L(void 0))},_e=!!te||!u||!!U,Ee=j.trim().toLowerCase(),Me=(u?.panels??[]).filter(q=>[Vn(q.title),q.id,q.description??"",q.source.label].join(" ").toLowerCase().includes(Ee)),ze=N?.panels.filter(q=>!u?.panels.some(ce=>ce.id===q.id)&&!u?.issues?.some(ce=>ce.id===q.id)&&N.panels.filter(ce=>ce.id===q.id).length===1)??[],W=k&&u?.panels.find(q=>q.id===k.id),ve=!!k&&W?.revision!==k.revision,Be=R?.kind==="update"?u?.panels.find(q=>q.id===R.preview.id):void 0,ke=Q||!!Y&&(u?.panels.find(q=>q.id===Y.appId)?.revision??u?.issues?.find(q=>q.id===Y.appId)?.revision)!==Y.expectedRevision;return c.jsxs("section",{className:"hub-panels",children:[c.jsxs("header",{className:"panels-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{children:"面板"}),c.jsx("p",{children:"从 GitHub 安装工具面板,绑定工作区后直接在工作台中打开。"})]}),c.jsx("button",{disabled:!!te||J,onClick:()=>Le(q=>q+1),children:J?"正在刷新…":"刷新"})]}),c.jsxs("p",{className:"panels-muted",children:["面板安装在",o,"上,文件和任务操作使用当前工作区。"]}),u&&!u.hasProject&&c.jsx("div",{className:"panels-warning",children:"请先选择一个项目,才能绑定和打开面板。"}),ae&&c.jsx("p",{role:"alert",className:"error",children:ae}),ye&&c.jsx("p",{role:"status",className:"panels-notice",children:ye}),te&&c.jsx("p",{role:"status",className:"panels-muted",children:te}),u?.issues?.filter(q=>q.id.toLowerCase().includes(Ee)).map(q=>c.jsxs("section",{className:"panels-warning","aria-label":"需要修复的面板",children:[c.jsx("h2",{children:q.id}),c.jsxs("p",{children:["项目记录版本:",q.version??"未记录","。安装包缺失或无法校验,面板暂不可用。"]}),c.jsx("p",{children:"项目数据和任务记录仍保留。可检查宿主保留的版本,审阅权限后恢复。"}),c.jsx("button",{disabled:!!te||!q.bound||!u.canRestorePackages,onClick:()=>{pt(q)},children:"检查可用版本"})]},q.id)),Y&&c.jsxs("section",{className:"panels-review","aria-label":"项目保留版本",children:[c.jsxs("header",{className:"panels-heading",children:[c.jsxs("div",{children:[c.jsxs("h2",{children:[Vn(Y.title)," · 项目版本"]}),c.jsxs("p",{children:["项目记录版本:",Y.current.version]})]}),c.jsx("button",{disabled:!!te,onClick:()=>{yt()},children:"关闭版本记录"})]}),c.jsx("p",{children:"选择宿主已保留的程序版本,仅切换当前项目。其他项目继续使用各自版本。"}),c.jsx("p",{className:"panels-warning",children:"切换程序版本不会恢复旧数据。请先备份项目,确认该版本支持当前文档格式;任务与产物记录会保留。"}),Y.current.unavailable&&c.jsx("p",{role:"status",children:"当前安装包不可用,无法读取原权限;恢复前需重新审阅目标版本的全部权限。"}),Y.unavailablePackages>0&&c.jsxs("p",{role:"status",children:["有 ",Y.unavailablePackages," 个保留包无法校验,暂不能选择。"]}),!Y.versions.length&&c.jsx("p",{children:"没有可用的保留版本。"}),c.jsx("div",{className:"panels-grid",children:Y.versions.map(q=>c.jsxs("article",{className:"panels-card",children:[c.jsxs("h3",{children:["v",q.version]}),c.jsxs("small",{children:["内容编号 ",q.packageDigest.slice(0,12)]}),c.jsx(Xs,{value:q.compatibility}),c.jsx("button",{disabled:!!te||!q.compatibility.supported||q.packageDigest===Y.current.packageDigest,onClick:()=>{mt(q.packageDigest)},children:q.packageDigest===Y.current.packageDigest?"当前项目版本":`审阅 v${q.version}`})]},q.packageDigest))}),T&&c.jsxs("section",{className:"panels-confirm","aria-label":"确认恢复项目版本",children:[c.jsxs("h3",{children:["v",T.current.version," → v",T.version]}),c.jsx("h4",{children:"此版本请求的权限"}),!T.permissions.length&&c.jsx("p",{children:"未申请宿主权限。"}),T.permissions.map(q=>c.jsxs("div",{className:"panels-permission",children:[c.jsx("span",{children:py[q]??q}),T.addedPermissions.includes(q)&&c.jsx("strong",{children:T.current.unavailable?"需重新确认":"新增权限"})]},q)),c.jsx(Xs,{value:T.compatibility}),ke&&c.jsx("p",{role:"alert",children:"项目或审阅已变化,请关闭版本记录并重新读取。"}),c.jsx("button",{disabled:!!te||ke||!T.compatibility.supported,onClick:()=>{Ze()},children:"确认权限并恢复项目版本"})]})]}),U&&c.jsxs("section",{className:"panels-confirm","aria-label":"逐个审阅面板",children:[c.jsxs("p",{children:["正在审阅第 ",U.position+1," / ",U.candidates.length," 个面板:",Vn(U.candidates[U.position].title),"。每个面板都需要单独确认安装。"]}),c.jsxs("div",{className:"panels-actions",children:[!R&&c.jsx("button",{disabled:!!te,onClick:()=>{lt(U.candidates[U.position].source)},children:"重新读取此面板"}),c.jsx("button",{disabled:!!te,onClick:()=>{ge()},children:"跳过此面板"}),c.jsx("button",{disabled:!!te,onClick:()=>{$(void 0),O(void 0),se("")},children:"取消逐个审阅"})]})]}),R&&c.jsxs("section",{className:"panels-review","aria-labelledby":"panel-review-heading",children:[c.jsxs("header",{className:"panels-heading",children:[c.jsxs("div",{children:[c.jsx("h2",{id:"panel-review-heading",ref:Lt,tabIndex:-1,children:R.kind==="update"?"审阅面板更新":"审阅面板安装"}),c.jsxs("p",{children:[Vn(R.preview.title)," · ",R.preview.id," · v",R.preview.version]})]}),c.jsx("button",{disabled:!!te,onClick:()=>{$(void 0),O(void 0),se("")},children:"取消审阅"})]}),R.preview.description&&c.jsx("p",{children:R.preview.description}),Be&&c.jsxs("p",{className:"panels-warning",children:["当前版本 v",Be.version," → 更新后 v",R.preview.version,Be.source.commit&&c.jsxs(c.Fragment,{children:[c.jsx("br",{}),"当前提交 ",c.jsx("code",{children:Be.source.commit.slice(0,12)})," → 更新提交"," ",c.jsx("code",{children:R.source.commit.slice(0,12)})]})]}),c.jsxs("section",{children:[c.jsx("h3",{children:"安装来源"}),c.jsxs("dl",{children:[c.jsx("dt",{children:"仓库"}),c.jsx("dd",{children:R.source.url}),c.jsx("dt",{children:"分支 / 标签"}),c.jsx("dd",{children:R.source.ref}),c.jsx("dt",{children:"已锁定提交"}),c.jsx("dd",{children:c.jsx("code",{children:R.source.commit})}),c.jsx("dt",{children:"面板目录"}),c.jsx("dd",{children:R.source.subdir||"仓库根目录"}),c.jsx("dt",{children:"界面入口"}),c.jsx("dd",{children:c.jsx("code",{children:R.preview.entry})})]})]}),c.jsxs("section",{children:[c.jsx("h3",{children:"面板请求的权限"}),R.preview.permissions.length===0?c.jsx("p",{className:"panels-muted",children:"未申请宿主权限。"}):R.preview.permissions.map(q=>c.jsxs("div",{className:"panels-permission",children:[c.jsx("span",{children:py[q]??q}),c.jsx("small",{children:q})]},q))]}),c.jsxs("section",{children:[c.jsx("h3",{children:"随面板安装的工具与 Skills"}),R.preview.agent?.tools.length||R.preview.agent?.skills.length?c.jsxs("div",{className:"panels-badges",children:[R.preview.agent?.tools.map(q=>c.jsxs("span",{className:"panels-badge",title:q.description,children:[q.name," · ",q.readOnly?"只读":"可修改数据"]},q.name)),R.preview.agent?.skills.map(q=>c.jsxs("span",{className:"panels-badge",children:["Skill · ",q.split("/").at(-2)??q]},q))]}):c.jsx("p",{className:"panels-muted",children:"此面板没有额外的 Agent 工具或 Skills。"})]}),c.jsx(Xs,{value:R.compatibility}),R.preview.warnings.length>0&&c.jsx("div",{className:"panels-warning",children:c.jsx("ul",{children:R.preview.warnings.map(q=>c.jsx("li",{children:q},q))})}),c.jsxs("footer",{children:[!R.compatibility.supported&&c.jsxs("p",{className:"panels-muted",children:["可以安装到",o,",但当前 Web 工作台无法绑定或打开它。"]}),he?c.jsx("p",{className:"panels-muted",children:"已绑定当前工作区,更新将保留绑定。"}):c.jsxs("label",{className:"panels-check",children:[c.jsx("input",{type:"checkbox",checked:z,disabled:!!te||!u?.hasProject||!R.compatibility.supported,onChange:q=>Z(q.target.checked)}),"绑定当前工作区"]}),ee?c.jsxs("div",{className:"panels-actions",children:[c.jsx("span",{className:"panels-muted",children:"安装内容或本地版本已变化,请重新审阅。"}),c.jsx("button",{disabled:!!te,onClick:M,children:"重新审阅"})]}):c.jsx("button",{className:"panels-primary",disabled:!!te,onClick:()=>{Ce()},children:R.kind==="update"?"确认更新":"确认安装"})]})]}),c.jsxs("section",{className:"panels-section","aria-labelledby":"installed-panels-heading",children:[c.jsxs("div",{className:"panels-heading",children:[c.jsxs("h2",{id:"installed-panels-heading",children:["已安装面板",u?` · ${u.panels.length+(u.issues?.length??0)}`:""]}),c.jsx("input",{type:"search","aria-label":"搜索已安装面板",placeholder:"搜索已安装面板",value:j,onChange:q=>D(q.target.value)})]}),!u&&c.jsx("p",{className:"panels-muted",children:J?"正在读取面板…":"暂时无法读取面板,请刷新重试。"}),u&&Me.length===0&&!u.issues?.some(q=>q.id.toLowerCase().includes(Ee))&&c.jsxs("div",{className:"panels-empty",children:[c.jsx("strong",{children:u.panels.length||u.issues?.length?"没有匹配的面板":"还没有安装面板"}),c.jsx("p",{className:"panels-muted",children:u.panels.length||u.issues?.length?"试试其他名称或清除搜索。":"在下方粘贴 GitHub 仓库地址,或浏览官方面板仓库。"})]}),c.jsx("div",{className:"panels-grid",children:Me.map(q=>c.jsxs("article",{className:"panels-card",children:[c.jsxs("div",{className:"panels-card-heading",children:[c.jsx("h3",{children:Vn(q.title)}),c.jsxs("span",{className:"panels-badge",children:["v",q.version]})]}),c.jsx("small",{children:q.id}),q.description&&c.jsx("p",{children:q.description}),c.jsx("div",{className:"panels-badges",children:c.jsx("span",{className:`panels-badge ${q.enabled&&q.compatibility.supported?"panels-badge-ready":""}`,children:q.globalDisabled?"已全局停用":q.bound?"已绑定当前工作区":"未绑定当前工作区"})}),c.jsxs("dl",{children:[c.jsx("dt",{children:"来源"}),c.jsx("dd",{children:q.source.label}),q.source.ref&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:"分支 / 标签"}),c.jsx("dd",{children:q.source.ref})]})]}),c.jsx(Xs,{value:q.compatibility}),q.globalDisabled&&c.jsx("p",{className:"panels-muted",children:"请在宿主配置中启用此面板后使用。"}),c.jsxs("div",{className:"panels-actions",children:[c.jsx("button",{className:"panels-primary",disabled:_e||!q.enabled||!q.compatibility.supported,onClick:()=>ct.current.onOpen(q),children:"打开面板"}),c.jsx("button",{disabled:_e||!u?.hasProject||!q.bound&&(q.globalDisabled||!q.compatibility.supported),onClick:()=>{Re(q)},children:q.bound?"解除绑定":"绑定工作区"}),q.updatable&&c.jsx("button",{disabled:_e,onClick:()=>{bt(q)},children:"检查更新"}),u?.canRestorePackages&&q.bound&&c.jsx("button",{disabled:_e,onClick:()=>{pt(q)},children:"项目版本"}),c.jsx("button",{className:"panels-danger",disabled:_e,onClick:async()=>{!await Qe()||!Ae.current||(L(q),O(void 0),re(void 0),V(void 0),se(""),F(""))},children:"卸载"})]})]},q.id))}),k&&c.jsxs("section",{className:"panels-confirm","aria-label":"确认卸载面板",children:[c.jsxs("p",{children:["卸载「",Vn(k.title),"」v",k.version,"?面板将从",o,"移除,其他工作区也将无法打开它。"]}),c.jsxs("div",{className:"panels-actions",children:[c.jsx("button",{disabled:!!te,onClick:()=>L(void 0),children:"取消卸载"}),ve&&c.jsx("span",{className:"panels-muted",children:W?"面板已被其他设备修改,请查看最新版本后重新确认。":"此面板已被其他设备卸载。"}),ve&&W&&c.jsx("button",{disabled:!!te||J,onClick:()=>{L(W),se("")},children:"查看最新版本"}),c.jsx("button",{className:"panels-danger",disabled:!!te||J||ve,onClick:()=>{oe()},children:"确认卸载"})]})]})]}),c.jsxs("section",{className:"panels-import panels-section","aria-labelledby":"github-panels-heading",children:[c.jsxs("div",{className:"panels-heading",children:[c.jsxs("div",{children:[c.jsx("h2",{id:"github-panels-heading",children:"从 GitHub 安装"}),c.jsx("p",{children:"先读取仓库并选择面板,再查看安装内容和所需权限。"})]}),c.jsx("button",{disabled:_e,onClick:()=>{p(hy),b(""),v(""),Et({url:hy})},children:"浏览官方仓库"})]}),c.jsxs("form",{onSubmit:q=>{q.preventDefault(),h.trim()&&Et({url:h.trim(),...y.trim()?{ref:y.trim()}:{},...x.trim()?{subdir:x.trim()}:{}})},children:[c.jsxs("label",{children:["GitHub 仓库地址",c.jsx("input",{type:"url",placeholder:"https://github.com/owner/repository",value:h,required:!0,disabled:!!te||!!U,onChange:q=>{p(q.target.value),A(void 0)}})]}),c.jsxs("details",{children:[c.jsx("summary",{children:"指定分支或子目录"}),c.jsxs("div",{className:"panels-source-fields",children:[c.jsxs("label",{children:["分支 / 标签(可选)",c.jsx("input",{value:y,placeholder:"使用默认分支",disabled:!!te||!!U,onChange:q=>{b(q.target.value),A(void 0)}})]}),c.jsxs("label",{children:["子目录(可选)",c.jsx("input",{value:x,placeholder:"例如 apps/my-panel",disabled:!!te||!!U,onChange:q=>{v(q.target.value),A(void 0)}})]})]})]}),c.jsxs("div",{className:"panels-actions",children:[c.jsx("button",{type:"submit",disabled:_e||!h.trim(),children:"读取仓库"}),(h||y||x||N)&&c.jsx("button",{type:"button",disabled:!!te,onClick:()=>{P(),O(void 0)},children:"清除"})]})]}),N&&c.jsxs("div",{className:"panels-candidates",children:[c.jsxs("h3",{children:["找到 ",N.panels.length," 个面板"]}),c.jsxs("p",{className:"panels-muted",children:[N.source.url," · ",N.source.ref," ·"," ",c.jsx("code",{children:N.source.commit.slice(0,12)})]}),N.panels.length===0&&c.jsx("p",{className:"panels-muted",children:"仓库中没有找到可安装的面板。请检查地址和子目录。"}),ze.length>1&&c.jsxs("div",{className:"panels-actions panels-batch-start",children:[c.jsxs("button",{disabled:_e,onClick:()=>{Se(ze)},children:["逐个审阅未安装面板(",ze.length,")"]}),c.jsx("small",{children:"按顺序确认,可随时跳过或停止。"})]}),c.jsx("div",{className:"panels-grid",children:N.panels.map(q=>{const ce=u?.panels.find(je=>je.id===q.id);return c.jsxs("article",{className:"panels-card",children:[c.jsxs("div",{className:"panels-card-heading",children:[c.jsx("h3",{children:Vn(q.title)}),c.jsxs("span",{className:"panels-badge",children:["v",q.version]})]}),q.description&&c.jsx("p",{children:q.description}),c.jsx("small",{children:q.subdir==="."?"仓库根目录":q.subdir}),c.jsx("div",{className:"panels-actions",children:c.jsx("button",{disabled:_e||!!(ce&&!ce.updatable),onClick:()=>ce?void bt(ce):void lt(q.source),children:ce?ce.updatable?"已安装 · 检查更新":"已从其他来源安装":"审阅安装"})})]},`${q.id}:${q.subdir}`)})}),N.issues.length>0&&c.jsxs("div",{className:"panels-warning",children:[c.jsx("strong",{children:"部分目录无法作为面板安装"}),c.jsx("ul",{children:N.issues.map(q=>c.jsxs("li",{children:[q.subdir,":",q.error]},q.subdir))})]})]})]})]})}function ow(t){const i=t.projectId===void 0?Sa():t.projectId,l=`/api/v1/panels/runtime/${encodeURIComponent(t.instanceId)}`,a=new Set,o=new Set;let f=!1,u=t.expiresAt,m=u-6e4,h,p=0,y=0,b=0,x,v;const j=(C,B)=>{const U=setTimeout(()=>{a.delete(U),f||C()},Math.max(0,Math.min(B,2147483647)));return a.add(U),U},D=C=>{C!==void 0&&(clearTimeout(C),a.delete(C))},N=()=>{if(!f){f=!0;for(const C of a)clearTimeout(C);a.clear();for(const C of o)C.abort();o.clear()}},A=C=>{f||(N(),t.onTerminal(C))},R=()=>A(new Error("面板连接已到期,请重新打开继续使用。")),O=C=>C instanceof Pe&&[401,403,410].includes(C.status),Y=()=>{f||t.onStatus(p||y?"面板连接暂时中断,正在重试;当前内容会保留。":"")},re=async(C,B="GET")=>{const U=new AbortController;o.add(U);const $=j(()=>U.abort(),8e3);try{return await He(St(`${l}${C}`,t.workspace,i),{method:B,...B==="POST"?{headers:{"Content-Type":"application/json"},body:"{}"}:{},signal:U.signal})}finally{D($),o.delete(U)}},T=()=>{D(x),x=j(()=>{Date.now()>=u?R():T()},u-Date.now())},V=()=>{D(v),p<5&&(v=j(Q,m-Date.now()))};function Q(){if(!f){if(Date.now()>=u){R();return}h||p>=5||Date.now()<m||(h=(async()=>{try{const C=await re("/renew","POST");if(f)return;if(!C||typeof C!="object"||!("expiresAt"in C)||typeof C.expiresAt!="number"||!Number.isFinite(C.expiresAt)||C.expiresAt<=Date.now()+6e4)throw new Error("面板续期响应无效。");u=C.expiresAt,m=u-6e4,p=0,T(),Y()}catch(C){if(f)return;if(O(C)){A(C);return}p++,m=Date.now()+Math.min(5e3*2**(p-1),3e4),Y()}finally{h=void 0,f||V()}})())}}async function I(){try{const C=await re(`/events?after=${b}`);if(f)return;if(!C||typeof C!="object"||!("cursor"in C)||!("events"in C))throw new Error("面板事件响应无效。");if(!Number.isSafeInteger(C.cursor)||C.cursor<b||!Array.isArray(C.events)||C.events.length>2048)throw new Error("面板事件响应无效。");const B=[];let U=b;for(const $ of C.events){if(!$||typeof $!="object"||!Number.isSafeInteger($.id)||$.id<=U||$.id>C.cursor||typeof $.event!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,100}$/.test($.event))throw new Error("面板事件响应无效。");U=$.id,B.push($)}t.onEvents(B),b=C.cursor,y=0,Y()}catch(C){if(f)return;if(O(C)){A(C);return}y++,Y()}finally{f||j(()=>{I()},Math.min(1e3*2**y,5e3))}}return T(),V(),I(),{stop:N,refresh:Q}}function uw(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:"点击开始录音后,浏览器才会请求麦克风。"},l=0,a,o,f,u=[],m=0,h="",p=t.signal.aborted;const y=j=>{i={...i,...j},p||t.onChange({...i})},b=()=>{a?.getTracks().forEach(j=>j.stop()),a=void 0,f&&clearInterval(f),f=void 0},x=()=>{try{o?.state!=="inactive"&&o?.stop()}finally{b()}},v=()=>{if(!p){p=!0,l++,o&&(o.ondataavailable=null,o.onstop=null,o.onerror=null);try{x()}finally{b()}u=[],i={phase:"closed",elapsedSeconds:0,message:"录音已关闭。"},t.signal.removeEventListener("abort",v)}};return p?i={phase:"closed",elapsedSeconds:0,message:"录音授权已结束。"}:t.signal.addEventListener("abort",v,{once:!0}),{snapshot:()=>({...i}),async start(){if(p||t.signal.aborted)throw new Error("录音授权已结束。");if(["requesting","recording"].includes(i.phase))throw new Error("已有录音正在进行。");const j=++l,D=()=>!p&&j===l&&!t.signal.aborted;u=[],m=0,h="",y({phase:"requesting",elapsedSeconds:0,blob:void 0,message:"正在等待麦克风授权…"});try{const N=await(t.getStream?t.getStream():navigator.mediaDevices.getUserMedia({audio:!0,video:!1}));if(!D()){N.getTracks().forEach(Y=>Y.stop());return}a=N;const A=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(Y=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(Y));o=t.makeRecorder?t.makeRecorder(a):new MediaRecorder(a,{...A?{mimeType:A}:{},audioBitsPerSecond:128e3});const R=o;R.ondataavailable=Y=>{!D()||!Y.data.size||(u.push(Y.data),m+=Y.data.size,m>t.maxBytes&&(h="录音超过大小限制;可以下载备份,或重新录制较短的音频。",x()))},R.onerror=()=>{if(D()){h="录音设备发生错误;请检查麦克风后重新录制。";try{x()}catch{b()}y({phase:"error",message:h})}},R.onstop=()=>{if(!D())return;b();const Y=new Blob(u,{type:R.mimeType.split(";")[0]||"audio/webm"});u=[],y({phase:Y.size&&!h?"review":"error",blob:Y.size?Y:void 0,message:h||(Y.size?"录音已停止。可以试听,再保存到当前项目。":"没有录到声音,请重新录制。")})};const O=Date.now();R.start(250),y({phase:"recording",message:"正在使用这台设备的麦克风录音。"}),f=setInterval(()=>{if(!D())return;const Y=Math.floor((Date.now()-O)/1e3);y({elapsedSeconds:Y}),Y>=t.maxDurationSeconds&&x()},250)}catch(N){if(b(),!D())return;y({phase:"error",message:N instanceof Error&&["NotAllowedError","SecurityError"].includes(N.name)?"麦克风未获授权,请检查浏览器和系统的麦克风权限。":"无法启动录音,请确认安全连接、麦克风和浏览器录音支持。"})}},stop:x,close:v}}function Rb(t){const i=new Blob([t.blob],{type:t.blob.type.split(";")[0].trim().toLowerCase()}),l=[],a=t.timing?.now??Date.now,o=t.timing?.sleep??((x,v)=>new Promise((j,D)=>{const N=()=>{clearTimeout(A),D(v.reason)},A=setTimeout(()=>{v.removeEventListener("abort",N),j()},x);v.addEventListener("abort",N,{once:!0}),v.aborted&&N()})),f=async()=>{const x=t.transferBudget;if(!(!x||!Number.isSafeInteger(x.rateWindowMs)||x.rateWindowMs<1||!Number.isSafeInteger(x.maxTransferCallsPerWindow)||x.maxTransferCallsPerWindow<1))for(;;){t.signal.throwIfAborted();const v=a();for(;l.length&&l[0]<=v-x.rateWindowMs;)l.shift();if(l.length<x.maxTransferCallsPerWindow){l.push(v);return}await o(Math.max(1,l[0]+x.rateWindowMs-v),t.signal)}};let u,m=!1,h;const p=()=>t.signal.throwIfAborted(),y=async(x,v)=>{p();const j=await t.call(x,v);return p(),j},b=x=>{const v=x;if(!v||typeof v.sessionId!="string"||!/^upload-[a-f0-9-]{36}$/.test(v.sessionId)||u&&u!==v.sessionId||v.mimeType!==i.type||!["uploading","finished"].includes(String(v.state))||!Number.isSafeInteger(v.receivedBytes)||Number(v.receivedBytes)<0||Number(v.receivedBytes)>i.size||!Number.isSafeInteger(v.nextSequence)||Number(v.nextSequence)<0||!Number.isSafeInteger(v.maxChunkBytes)||Number(v.maxChunkBytes)<1||Number(v.maxChunkBytes)>32768)throw new Error("文件上传状态无效,请保留本机备份后重新打开面板。");return v};return{async save(){if(p(),m)throw new Error("文件正在保存,请稍候。");if(!i.size||i.size>t.maxBytes||!t.mimeTypes.includes(i.type))throw new Error("文件格式或大小无效。");m=!0;try{if(!h){const j=await i.arrayBuffer();p(),h=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",j)),D=>D.toString(16).padStart(2,"0")).join(""),p()}let x=b(u?await y("resources.upload.get",{sessionId:u}):await y("resources.upload.begin",{name:t.name,mimeType:i.type,expectedBytes:i.size,expectedSha256:h}));for(u=x.sessionId,t.onProgress(x.receivedBytes);x.receivedBytes<i.size;){if(x.state!=="uploading")throw new Error("文件上传已结束,文件大小不匹配。");const j=x.receivedBytes,D=new Uint8Array(await i.slice(j,j+x.maxChunkBytes).arrayBuffer());p(),await f(),p();const N=b(await y("resources.upload.write",{sessionId:u,sequence:x.nextSequence,offset:j,dataBase64:btoa(String.fromCharCode(...D))}));if(N.receivedBytes!==j+D.length||N.nextSequence!==x.nextSequence+1)throw new Error("文件上传进度不匹配,请重试保存以核对服务端状态。");x=N,t.onProgress(x.receivedBytes)}const v=await y("resources.upload.finish",{sessionId:u});if(!v?.asset||v.asset.id!==`asset-${h}`||v.asset.bytes!==i.size||v.asset.mimeType!==i.type)throw new Error("文件保存回执不匹配,请保留本机备份并重试。");return v}finally{m=!1}}}}function cw(t){return Rb({...t,maxBytes:25*1024*1024,mimeTypes:["audio/webm","audio/mp4","audio/ogg","audio/wav"]})}function fw({request:t}){const[i,l]=w.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"}),[a,o]=w.useState(""),[f,u]=w.useState(!1),[m,h]=w.useState(0),[p,y]=w.useState(""),b=w.useRef(null),x=w.useRef(void 0),v=w.useRef(void 0),j=w.useRef(void 0);w.useEffect(()=>{const A=new AbortController;j.current=A;const R=AbortSignal.any([t.signal,A.signal]);return x.current=uw({...t,signal:R,onChange:l}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{A.abort(),x.current?.close(),x.current=void 0,v.current=void 0}},[t]),w.useEffect(()=>{if(!i.blob){y("");return}const A=URL.createObjectURL(i.blob);return y(A),()=>URL.revokeObjectURL(A)},[i.blob]);const D=i.blob?.type==="audio/mp4"?"m4a":i.blob?.type==="audio/ogg"?"ogg":"webm",N=async()=>{const A=i.blob,R=j.current;if(!A||!R||f||i.phase!=="review")return;const O=AbortSignal.any([t.signal,R.signal]);u(!0),o("");try{v.current?.blob!==A&&(v.current={blob:A,transfer:cw({blob:A,name:`recording.${D}`,signal:O,call:(re,T)=>t.call(re,T,O),onProgress:h})});const Y=await v.current.transfer.save();O.throwIfAborted(),t.finish(Y)}catch(Y){O.aborted||o(`${Y instanceof Error?Y.message:"保存失败。"} 录音仍保留在本页,可重试保存或下载备份。`)}finally{O.aborted||u(!1)}};return c.jsxs("section",{className:"panel-host-audio panel-host-preview","aria-label":"录音",tabIndex:-1,ref:b,children:[c.jsxs("header",{children:[c.jsx("h2",{children:"录音并保存到当前项目"}),c.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录音"})]}),c.jsxs("p",{children:["使用当前设备的麦克风;最长 ",t.maxDurationSeconds," ","秒。停止后可试听,点击保存才会上传到当前项目。关闭面板会丢弃未保存录音。"]}),c.jsxs("p",{role:"status",children:[i.message," ",i.elapsedSeconds>0&&`${i.elapsedSeconds} 秒`]}),p&&c.jsx("audio",{controls:!0,src:p}),a&&c.jsx("p",{role:"alert",children:a}),f&&c.jsxs("p",{role:"status",children:["正在保存录音:",Math.round(m/(i.blob?.size||1)*100),"%"]}),c.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(i.phase)&&!i.blob&&c.jsx("button",{onClick:()=>{o(""),x.current?.start().catch(A=>o(String(A)))},children:"开始录音"}),i.phase==="recording"&&c.jsx("button",{onClick:()=>x.current?.stop(),children:"停止录音"}),i.phase==="review"&&c.jsx("button",{disabled:f,className:"panel-host-primary",onClick:()=>{N()},children:f?"正在保存…":"保存到当前项目"}),p&&c.jsx("button",{disabled:f,onClick:()=>{o(""),v.current=void 0,x.current?.start().catch(A=>o(String(A)))},children:"丢弃并重新录制"}),p&&c.jsx("a",{href:p,download:`recording.${D}`,children:"下载本机备份"})]})]})}const fl=Object.freeze({maxDurationSeconds:1200,maxBytes:200*1024*1024,defaultDurationSeconds:300,defaultBytes:64*1024*1024});function zb(t){const i=t;if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).some(o=>!["source","microphone","systemAudio","maxDurationSeconds","maxBytes"].includes(o))||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 l=i.maxDurationSeconds??fl.defaultDurationSeconds,a=i.maxBytes??fl.defaultBytes;if(!Number.isSafeInteger(l)||Number(l)<1||Number(l)>fl.maxDurationSeconds||!Number.isSafeInteger(a)||Number(a)<1||Number(a)>fl.maxBytes)throw new Error("视频录制限制无效。");return{source:i.source,microphone:i.microphone!==!1,systemAudio:i.systemAudio===!0,maxDurationSeconds:Number(l),maxBytes:Number(a)}}const dw=["video/webm;codecs=vp8,opus","video/webm;codecs=vp9,opus","video/webm","video/mp4"];function Db(){try{return dw.find(t=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(t))}catch{return}}function df(){const t=typeof navigator>"u"?void 0:navigator.mediaDevices,i=typeof window<"u"&&window.isSecureContext===!0&&!!Db(),l=i&&typeof t?.getUserMedia=="function",a=i&&typeof t?.getDisplayMedia=="function";return{camera:l,screen:a,microphone:l,systemAudio:a,maxDurationSeconds:fl.maxDurationSeconds,maxBytes:fl.maxBytes}}function hw(t){const i=zb({source:t.source,microphone:t.microphone,systemAudio:t.systemAudio,maxDurationSeconds:t.maxDurationSeconds,maxBytes:t.maxBytes});let l={phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:i.source,microphone:!1,systemAudio:!1}},a=0,o=t.signal.aborted,f,u,m,h=[],p=0,y="";const b=new Set,x=N=>{l={...l,...N},o||t.onChange({...l})},v=()=>{m&&clearInterval(m),m=void 0;for(const N of new Set([...b].flatMap(A=>A.getTracks())))N.onended=null,N.stop();b.clear(),u&&u.state!=="closed"&&u.close().catch(()=>{}),u=void 0},j=()=>{try{f?.state!=="inactive"&&f?.stop()}finally{v()}},D=()=>{if(!o){o=!0,a++,f&&(f.ondataavailable=null,f.onstop=null,f.onerror=null);try{j()}finally{v()}h=[],l={...l,phase:"closed",stream:void 0,blob:void 0},t.signal.removeEventListener("abort",D)}};return o?l.phase="closed":t.signal.addEventListener("abort",D,{once:!0}),{snapshot:()=>({...l}),async start(){if(o||t.signal.aborted)throw new Error("录制授权已结束。");if(["requesting","recording"].includes(l.phase))throw new Error("已有录制正在进行。");const N=++a,A=()=>!o&&a===N&&!t.signal.aborted,R=O=>{if(!A())throw O.getTracks().forEach(Y=>Y.stop()),new Error("录制授权已结束。");b.add(O);for(const Y of O.getTracks()){if(Y.readyState==="ended")throw new Error("所选采集来源已经停止,请重新连接。");Y.onended=()=>{A()&&(l.phase==="recording"?j():(a++,v(),x({phase:"error",stream:void 0,message:"采集来源已停止,请重新连接。"})))}}return O};v(),h=[],p=0,y="",x({phase:"requesting",elapsedSeconds:0,stream:void 0,blob:void 0,message:"正在等待设备授权…"});try{const O=t.devices??navigator.mediaDevices;if(!O)throw new Error("录制需要安全连接和浏览器设备支持。");const Y=R(await(i.source==="screen"?O.getDisplayMedia({video:!0,audio:i.systemAudio}):O.getUserMedia({video:!0,audio:i.microphone})));if(!Y.getVideoTracks().length)throw new Error("没有获得可录制的画面。");const re=i.source==="screen"&&i.microphone?R(await O.getUserMedia({audio:!0,video:!1})):void 0,T=i.microphone?(i.source==="camera"?Y:re)?.getAudioTracks()??[]:[];if(i.microphone&&!T.length)throw new Error("没有获得麦克风音轨。");const V=i.source==="screen"&&i.systemAudio?Y.getAudioTracks():[];let Q=R(new MediaStream([...Y.getVideoTracks(),...T,...V]));if(T.length&&i.source==="screen")if(V.length){u=t.makeAudioContext?t.makeAudioContext():new AudioContext;const U=u,$=U.createMediaStreamDestination();R($.stream);for(const K of[T,V])U.createMediaStreamSource(new MediaStream(K)).connect($);let ee;try{await Promise.race([U.resume(),new Promise((K,z)=>{ee=setTimeout(()=>z(new Error("声音混合未能启动,请重新录制。")),2e3)})])}finally{ee&&clearTimeout(ee)}t.signal.throwIfAborted(),Q=R(new MediaStream([...Y.getVideoTracks(),...$.stream.getAudioTracks()]))}else Q=R(new MediaStream([...Y.getVideoTracks(),...T]));if(!A()){v();return}const I=Db();if(!I)throw new Error("此浏览器不支持视频录制编码。");f=t.makeRecorder?t.makeRecorder(Q,I):new MediaRecorder(Q,{mimeType:I});const C=f;C.ondataavailable=U=>{!A()||!U.data.size||(h.push(U.data),p+=U.data.size,p>i.maxBytes&&(y="录制超过大小限制;可以下载备份或重新录制较短的视频。",j()))},C.onerror=()=>{if(A()){y="录制设备或编码器发生错误,请保留备份后重试。";try{j()}catch{v()}x({phase:"error",stream:void 0,message:y})}},C.onstop=()=>{if(!A())return;v();const U=new Blob(h,{type:C.mimeType.split(";")[0]||I.split(";")[0]});h=[],x({phase:U.size&&!y?"review":"error",stream:void 0,blob:U.size?U:void 0,message:y||(U.size?"录制已停止。可以预览,再保存到当前项目。":"没有录到内容,请重新录制。")})};const B=Date.now();C.start(250),x({phase:"recording",stream:Q,capture:{source:i.source,microphone:T.length>0,systemAudio:V.length>0},message:"正在使用这台设备录制;停止后可以预览和保存。"}),m=setInterval(()=>{if(!A())return;const U=Math.floor((Date.now()-B)/1e3);x({elapsedSeconds:U}),U>=i.maxDurationSeconds&&j()},250)}catch(O){if(v(),!A())return;x({phase:"error",stream:void 0,message:O instanceof Error&&["NotAllowedError","SecurityError"].includes(O.name)?"设备未获授权或屏幕选择已取消,请检查浏览器和系统权限后重试。":O instanceof Error?O.message:"无法启动录制,请检查设备和浏览器支持。"})}},stop:j,close:D}}function pw({request:t}){const[i,l]=w.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:t.source,microphone:!1,systemAudio:!1}}),[a,o]=w.useState(""),[f,u]=w.useState(!1),[m,h]=w.useState(0),[p,y]=w.useState(""),b=w.useRef(null),x=w.useRef(null),v=w.useRef(void 0),j=w.useRef(void 0),D=w.useRef(void 0);w.useEffect(()=>{const O=new AbortController;D.current=O;const Y=AbortSignal.any([t.signal,O.signal]);v.current=hw({...t,signal:Y,onChange:l});const re=()=>{O.abort(),t.finish({cancelled:!0})};return window.addEventListener("pagehide",re,{once:!0}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{window.removeEventListener("pagehide",re),O.abort(),v.current?.close(),v.current=void 0,j.current=void 0}},[t]),w.useEffect(()=>{const O=x.current;if(O)return O.srcObject=i.stream??null,i.stream&&O.play().catch(()=>{}),()=>{O.srcObject=null}},[i.stream]),w.useEffect(()=>{if(!i.blob){y("");return}const O=URL.createObjectURL(i.blob);return y(O),()=>URL.revokeObjectURL(O)},[i.blob]);const N=i.blob?.type==="video/mp4"?"mp4":"webm",A=()=>{o(""),j.current=void 0,v.current?.start().catch(O=>o(String(O)))},R=async()=>{const O=i.blob,Y=D.current;if(!O||!Y||f||i.phase!=="review")return;const re=AbortSignal.any([t.signal,Y.signal]);u(!0),o("");try{j.current?.blob!==O&&(j.current={blob:O,transfer:Rb({blob:O,name:`recording.${N}`,signal:re,maxBytes:t.maxBytes,mimeTypes:["video/webm","video/mp4"],transferBudget:t.transferBudget,call:(V,Q)=>t.call(V,Q,re),onProgress:h})});const T=await j.current.transfer.save();re.throwIfAborted(),t.finish({...T,capture:i.capture})}catch(T){re.aborted||o(`${T instanceof Error?T.message:"保存失败。"} 视频仍保留在本页,可重试保存或下载备份。若已保存但未收到回复,重开面板后可从项目资源找回。`)}finally{re.aborted||u(!1)}};return c.jsxs("section",{className:"panel-host-video panel-host-preview","aria-label":"视频录制",tabIndex:-1,ref:b,children:[c.jsxs("header",{children:[c.jsxs("h2",{children:[t.source==="camera"?"摄像头录制":"屏幕录制","并保存到当前项目"]}),c.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录制"})]}),c.jsxs("p",{children:["使用当前设备;最长 ",t.maxDurationSeconds," 秒,最多"," ",Math.ceil(t.maxBytes/1024/1024)," MiB。",t.microphone?"使用麦克风。":"不使用麦克风。",t.systemAudio&&"屏幕声音取决于浏览器和你选择的共享来源,可能没有声音音轨。","停止后可预览,点击保存才会上传。关闭面板会丢弃未保存录制。"]}),c.jsxs("p",{role:"status",children:[i.message," ",i.elapsedSeconds>0&&`${i.elapsedSeconds} 秒`]}),i.stream&&c.jsx("video",{ref:x,muted:!0,playsInline:!0,"aria-label":"实时录制预览"}),p&&c.jsx("video",{controls:!0,playsInline:!0,src:p,"aria-label":"录制预览"}),i.phase==="recording"&&c.jsxs("p",{children:["麦克风:",i.capture.microphone?"已采集":"未采集",";屏幕声音:",i.capture.systemAudio?"已采集":"未采集"]}),a&&c.jsx("p",{role:"alert",children:a}),f&&c.jsxs("p",{role:"status",children:["正在保存视频:",Math.round(m/(i.blob?.size||1)*100),"%"]}),c.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(i.phase)&&!i.blob&&c.jsx("button",{onClick:A,children:"开始录制"}),i.phase==="recording"&&c.jsx("button",{onClick:()=>v.current?.stop(),children:"停止录制"}),i.phase==="review"&&c.jsx("button",{disabled:f,className:"panel-host-primary",onClick:()=>{R()},children:f?"正在保存…":"保存到当前项目"}),p&&c.jsx("button",{disabled:f,onClick:A,children:"丢弃并重新录制"}),p&&c.jsx("a",{href:p,download:`recording.${N}`,children:"下载本机备份"})]})]})}const $i="/api/v1/panels/runtime";function Zt(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function mw(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 gw(t,i){const l=`${$i}/${i}/directory/`;return typeof t=="string"&&t.startsWith(l)&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.slice(l.length))}function yw(t,i,l){if(!Zt(t)||t.effect!=="resources.open"||!Zt(t.asset))return;const a=t.asset;if(typeof a.id!="string"||!/^(?:asset|external)-[a-f0-9]{64}$/.test(a.id)||a.id!==l||t.url!==`${$i}/${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 o=["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:o}}function bw(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 l=decodeURIComponent(i);return!!l&&!l.startsWith(".")&&!/[\\/:\u0000-\u001f\u007f]/.test(l)})}catch{return!1}}function vw(t){return Zt(t)?typeof t.instanceId=="string"&&/^[A-Za-z0-9_-]{20,128}$/.test(t.instanceId)&&bw(t.src)&&typeof t.expiresAt=="number"&&Number.isFinite(t.expiresAt)&&Zt(t.context)&&Array.isArray(t.limitations)&&t.limitations.every(i=>typeof i=="string"):!1}function xw({panel:t,sessionId:i,busy:l,onClose:a,onAuthLost:o,onDirtyChange:f,onSubmitPrompt:u}){const m=w.useRef(null),[h,p]=w.useState(),[y,b]=w.useState(!0),[x,v]=w.useState(""),[j,D]=w.useState(""),[N,A]=w.useState(),[R,O]=w.useState(),[Y,re]=w.useState(!1),T=w.useRef(null);w.useEffect(()=>{R&&(T.current?.focus(),T.current?.scrollIntoView?.({block:"nearest"}))},[R]);const[V,Q]=w.useState(""),[I,C]=w.useState(""),[B,U]=w.useState(),[$,ee]=w.useState(),K=w.useRef(void 0),[z,Z]=w.useState(),[he,me]=w.useState(!1),[k,L]=w.useState(0),J=w.useRef({onClose:a,onAuthLost:o,onDirtyChange:f,onSubmitPrompt:u,busy:l});J.current={onClose:a,onAuthLost:o,onDirtyChange:f,onSubmitPrompt:u,busy:l};const _=w.useRef(!1),te=w.useRef(void 0),xe=w.useRef(void 0),ae=w.useRef(null);return w.useEffect(()=>{J.current.onDirtyChange?.(!!B||he||!!$||!!z),B&&(ae.current?.focus(),ae.current?.scrollIntoView?.({block:"nearest"}))},[B,he,$,z]),w.useEffect(()=>{const se=io()??"",ye=Sa(),F={workspace:se,grant:void 0},we=new AbortController,Le=new Set,Ae=new Set;let Te=!1,tt;const ut=[],Ge=[],Lt=new Set,ct=new Set;let qe,ht=!1,Fe=!1,nt=!1,Et=!1;const lt=()=>{const Ee=m.current?.contentWindow;if(!(Te||!F.grant||!Ee||!Et))for(const Me of ut.splice(0))Me.event==="tools.invoke"&&Zt(Me.payload)&&typeof Me.payload.requestId=="string"&&/^[A-Za-z0-9_-]{1,128}$/.test(Me.payload.requestId)&&ct.add(Me.payload.requestId),Ee.postMessage({type:"codeshell-panel:event",instanceId:F.grant.instanceId,event:Me.event,payload:Me.payload},"*")},bt=()=>{Te||!nt||!Et||!F.grant||(qe&&clearTimeout(qe),b(!1),lt())},M={loaded:()=>{nt=!0,bt()}};xe.current=M,p(void 0),b(!0),v(""),D(""),A(void 0),O(void 0),re(!1),Q(""),C(""),U(void 0),me(!1),ee(void 0),Z(void 0);const P=Ee=>{ht||(ht=!0,He(St(`${$i}/${encodeURIComponent(Ee.instanceId)}`,se,ye),{method:"DELETE",keepalive:!0}).catch(()=>{}))},ge=Ee=>{Te||(Ee instanceof Pe&&Ee.status===401&&!_.current&&(_.current=!0,J.current.onAuthLost()),v(Ee instanceof Error?Ee.message:"面板连接失败,请重新打开。"))},Se=Ee=>{if(Te||!F.grant)return;const Me=F.grant;F.grant=void 0,tt?.stop(),te.current?.cancel(),Ge.length=0,ut.length=0,P(Me);for(const ze of Le)ze.abort();qe&&clearTimeout(qe),p(void 0),A(void 0),O(void 0),b(!1),me(!1),Q(""),ge(Ee)},Ce=Ee=>{const Me=df();return{...Ee,...Array.isArray(Ee.availableMethods)?{availableMethods:Ee.availableMethods.filter(ze=>ze!=="resources.recordVideo"||Me.camera||Me.screen)}:{},...typeof Ee.sessionId=="string"?{busy:J.current.busy}:{}}},Re=(Ee,Me,ze,W,ve)=>{Te||!F.grant||Ee!==m.current?.contentWindow||Ee.postMessage({type:"codeshell-panel:response",instanceId:F.grant.instanceId,requestId:Me,...W?{error:W,...ve?.code?{code:ve.code}:{},...ve?.retryAfterMs!==void 0?{retryAfterMs:ve.retryAfterMs}:{}}:{result:ze}},"*")},Qe=()=>{if(Te||!F.grant||te.current||K.current||Fe)return;const Ee=Ge.shift();if(!Ee)return;if(Ee.expiresAt<=Date.now()){Qe();return}let Me=!1;const ze={effect:Ee,cancel:()=>{te.current===ze&&(clearTimeout(W),te.current=void 0,Te||(U(void 0),C(""),me(!1)))},finish:ve=>{if(Te||!F.grant||te.current!==ze||Me)return;Me=!0,me(!0),C("");const Be=new AbortController;Le.add(Be);const ke=setTimeout(()=>Be.abort(),8e3);He(St(`${$i}/${F.grant.instanceId}/confirm`,se,ye),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:Ee.requestId,allowed:ve}),signal:Be.signal}).then(q=>{if(!(Te||te.current!==ze)){if(typeof q.allowed!="boolean")throw new Error("确认响应无效。");ve&&q.allowed===!1&&D("此确认已超时或被取消,操作未获准执行,请在面板中重新发起。"),!ve&&q.allowed===!0&&D("该操作此前已获准执行,请在面板中查看进度或停止。"),ze.cancel(),Qe()}}).catch(q=>{if(!(Te||te.current!==ze)){if(q instanceof Pe&&[401,403,410].includes(q.status)){Se(q);return}if(q instanceof Pe&&q.status===409){ze.cancel(),D("面板操作确认已失效,请在面板中重新发起。"),Qe();return}C("暂未收到确认结果。可以重试本次确认,或取消尚未执行的请求。")}}).finally(()=>{clearTimeout(ke),Le.delete(Be),Me=!1,!Te&&te.current===ze&&me(!1)})}},W=setTimeout(()=>{ze.cancel(),!Te&&F.grant&&(D("面板操作确认已超时,请在面板中重新发起。"),Qe())},Ee.expiresAt-Date.now());te.current=ze,U(ze),C("")},yt=Ee=>{for(const Me of Ee){if(Me.event!=="host.confirm"){ut.push(Me);continue}const ze=Me.payload;if(!Zt(ze)||typeof ze.requestId!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(ze.requestId)||typeof ze.title!="string"||ze.title.length>500||typeof ze.body!="string"||ze.body.length>3e4)throw new Error("面板操作确认格式无效。");Lt.has(ze.requestId)||(Lt.add(ze.requestId),Ge.push({effect:"host.confirm",requestId:ze.requestId,title:ze.title,body:ze.body,expiresAt:Date.now()+5e4}))}if(ut.length>2048||Ge.length>32){Se(new Error("面板状态积压过多,请重新打开面板。"));return}Qe(),lt()},pt=Ee=>new Promise(Me=>{if(te.current||K.current||Fe){Me(!1);return}const ze={effect:Ee,finish:ve=>{te.current===ze&&(clearTimeout(W),te.current=void 0,Te||U(void 0),Me(ve),queueMicrotask(Qe))},cancel:()=>ze.finish(!1)},W=setTimeout(()=>ze.finish(!1),55e3);te.current=ze,U(ze)}),mt=async Ee=>{const Me=m.current?.contentWindow,ze=F.grant,W=Ee.data;if(Te||!Me||Ee.source!==Me||Ee.origin!=="null"||!ze||!Zt(W)||W.instanceId!==ze.instanceId)return;if(W.type==="codeshell-panel:ready"){Et=!0,bt();return}if(W.type==="codeshell-panel:tool-result"){if(typeof W.requestId!="string"||!ct.has(W.requestId)||Le.size>=32)return;let ce;try{if(ce=JSON.stringify({requestId:W.requestId,...typeof W.error=="string"?{error:W.error}:{result:W.result}}),new TextEncoder().encode(ce).length>512*1024)return}catch{return}ct.delete(W.requestId);const je=new AbortController;Le.add(je);const Ke=setTimeout(()=>je.abort(),8e3);try{await He(St(`${$i}/${ze.instanceId}/tool-results`,se,ye),{method:"POST",headers:{"Content-Type":"application/json"},body:ce,signal:je.signal})}catch(st){!Te&&F.grant&&(st instanceof Pe&&[401,410].includes(st.status)?Se(st):D("面板工具结果未能送达,请在对话中重新发起操作。"))}finally{clearTimeout(Ke),Le.delete(je)}return}if(W.type!=="codeshell-panel:call"||typeof W.requestId!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(W.requestId))return;const ve=W.requestId;if(Ae.has(ve)){Re(Me,ve,void 0,"此请求已经处理,请重新发起。");return}if(Ae.size>=8192||Le.size>=32){Re(Me,ve,void 0,"面板请求过于频繁,请稍后重试。");return}if(Ae.add(ve),typeof W.method!="string"||!/^[A-Za-z][A-Za-z0-9.]{0,63}$/.test(W.method)){Re(Me,ve,void 0,"面板方法无效。");return}let Be;try{if(Be=JSON.stringify({method:W.method,params:W.params}),new TextEncoder().encode(Be).length>3*1024*1024)throw new Error("too large")}catch{Re(Me,ve,void 0,"面板请求内容过大或格式无效。");return}const ke=new AbortController;let q=!1;Le.add(ke);try{const ce=await He(St(`${$i}/${ze.instanceId}/call`,se,ye),{method:"POST",headers:{"Content-Type":"application/json"},body:Be,signal:ke.signal});if(Te||ke.signal.aborted)return;if(W.method==="context.get"&&(Et=!0,bt()),W.method==="external.open"){const je=Zt(ce)&&ce.effect===W.method?mw(ce.url):void 0;if(!je)throw new Error("面板返回的外部链接无效。");if(!await pt({effect:"external.open",url:je}))throw new Error("你取消了打开链接,或确认已超时。");Re(Me,ve,{opened:!0})}else if(W.method==="agent.submitPrompt"){if(!Zt(ce)||ce.effect!==W.method||typeof ce.prompt!="string"||!ce.prompt.trim()||ce.prompt.length>2e4||ce.sessionId!==i)throw new Error("面板任务与当前对话不匹配,请重新打开面板。");if(!await pt({effect:"agent.submitPrompt",prompt:ce.prompt,sessionId:i}))throw new Error("你取消了发送任务,或确认已超时。");if(Te||ke.signal.aborted)return;q=!0,Fe=!0,me(!0);const je=await J.current.onSubmitPrompt({prompt:ce.prompt,sessionId:i});if(Te||ke.signal.aborted)return;D("面板任务已提交到当前对话,可切换到对话查看进度。"),Re(Me,ve,je)}else if(W.method==="resources.recordVideo.capabilities"){if(!Zt(ce)||ce.effect!==W.method)throw new Error("视频录制能力响应无效。");Re(Me,ve,df())}else if(W.method==="resources.recordAudio"||W.method==="resources.recordVideo"){const je=W.method==="resources.recordVideo";if(!Zt(ce)||ce.effect!==W.method)throw new Error("录制请求无效。");const Ke=je?zb(Object.fromEntries(Object.entries(ce).filter(([Rt])=>Rt!=="effect"))):void 0;if(Ke){const Rt=df();if(!Rt[Ke.source]||Ke.microphone&&!Rt.microphone)throw new Error("当前浏览器不支持所选视频录制方式,请检查安全连接和设备支持。")}if(!je&&(!Zt(ce)||ce.effect!==W.method||!Number.isInteger(ce.maxDurationSeconds)||Number(ce.maxDurationSeconds)<1||Number(ce.maxDurationSeconds)>600||!Number.isInteger(ce.maxBytes)||Number(ce.maxBytes)<1||Number(ce.maxBytes)>25*1024*1024))throw new Error("录音请求无效。");if(K.current||te.current||Fe)throw new Error("请先完成当前的录制或确认操作。");const st=await new Promise((Rt,Ct)=>{let Wn=!1;const Vt=(Cn,Bt)=>{Wn||(Wn=!0,clearTimeout(Ta),ke.signal.removeEventListener("abort",wr),K.current===Ki&&(K.current=void 0,Te||(ee(void 0),Z(void 0))),Bt?Ct(Bt):Rt(Cn),Qe())},wr=()=>Vt(void 0,new Error("录制已关闭或授权已结束。")),Ta=setTimeout(()=>Vt(void 0,new Error("录制操作已超时,请重新打开。")),25*6e4),Ki={signal:ke.signal,maxDurationSeconds:Number(ce.maxDurationSeconds),maxBytes:Number(ce.maxBytes),...Ke?{...Ke,transferBudget:Zt(ze.context.capabilities)&&Zt(ze.context.capabilities.bridge)?ze.context.capabilities.bridge:void 0}:{},call:async(Cn,Bt,Jt)=>{const Gn=Jt?AbortSignal.any([ke.signal,Jt]):ke.signal;if(Gn.throwIfAborted(),Te||F.grant!==ze)throw new Error("当前项目授权已结束。");try{const Fn=await He(St(`${$i}/${ze.instanceId}/call`,se,ye),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:Cn,params:Bt}),signal:Gn});if(Gn.throwIfAborted(),Te||F.grant!==ze)throw new Error("当前项目授权已结束。");return Fn}catch(Fn){throw Fn instanceof Pe&&[401,403,410].includes(Fn.status)&&Se(Fn),Fn}},finish:Vt};K.current=Ki,ke.signal.addEventListener("abort",wr,{once:!0}),je?Z(Ki):ee(Ki)});Re(Me,ve,st)}else if(W.method==="resources.open"){O(void 0),re(!1);const je=yw(ce,ze.instanceId,Zt(W.params)?W.params.assetId:void 0);if(!je)throw new Error("面板文件预览链接无效,请重新打开文件。");O({...je,url:St(je.url,se,ye),downloadUrl:St(`${je.url}?download=1`,se,ye)}),Re(Me,ve,{opened:!0})}else if(W.method==="filesystem.openDirectory"){if(A(void 0),!Zt(ce)||ce.effect!==W.method||typeof ce.path!="string")throw new Error("面板目录信息无效。");if(ce.url!==void 0&&!gw(ce.url,ze.instanceId))throw new Error("面板目录链接无效,请重新打开目录。");A({path:ce.path,...typeof ce.url=="string"?{url:St(ce.url,se,ye)}:{}}),Re(Me,ve,{opened:!1,path:ce.path})}else if(W.method==="notifications.send"){if(!Zt(ce)||ce.effect!==W.method||typeof ce.title!="string"||ce.title.length>160||typeof ce.body!="string"||ce.body.length>2e3)throw new Error("面板通知格式无效。");D(`${ce.title}${ce.body?`:${ce.body}`:""}`),Re(Me,ve,{sent:!0})}else Re(Me,ve,W.method==="context.get"&&Zt(ce)?Ce(ce):ce)}catch(ce){!Te&&!ke.signal.aborted&&(ce instanceof Pe&&[401,410].includes(ce.status)&&Se(ce),(W.method==="agent.submitPrompt"||W.method==="external.open")&&D(ce instanceof Error?ce.message:"面板操作未完成。"),Re(Me,ve,void 0,ce instanceof Error?ce.message:"面板请求失败。",ce instanceof Pe?{code:ce.code,retryAfterMs:ce.retryAfterMs}:void 0))}finally{Le.delete(ke),q&&(Fe=!1,Te||me(!1),Qe())}},Ze=Ee=>{mt(Ee)};window.addEventListener("message",Ze);const oe=()=>tt?.refresh(),_e=()=>{document.visibilityState==="visible"&&oe()};return window.addEventListener("focus",oe),window.addEventListener("online",oe),document.addEventListener("visibilitychange",_e),He(St(`${$i}/prepare`,se,ye),{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:we.signal}).then(Ee=>{if(!vw(Ee))throw new Error("面板启动信息无效,请刷新面板列表后重试。");if(Te||we.signal.aborted){P(Ee);return}if(Ee.expiresAt<=Date.now())throw P(Ee),new Error("面板授权已过期,请重新打开。");F.grant=Ee,p({...Ee,context:Ce(Ee.context),src:St(Ee.src,se,ye)}),qe=setTimeout(()=>{Se(new Error("面板未能完成加载,请重新打开。若仍无法加载,可检查面板文件或使用桌面客户端。"))},45e3),tt=ow({instanceId:Ee.instanceId,expiresAt:Ee.expiresAt,workspace:se,projectId:ye,onEvents:yt,onTerminal:Se,onStatus:Q})}).catch(Ee=>{!Te&&!we.signal.aborted&&(b(!1),ge(Ee))}),()=>{Te=!0,te.current?.cancel(),window.removeEventListener("message",Ze),window.removeEventListener("focus",oe),window.removeEventListener("online",oe),document.removeEventListener("visibilitychange",_e),tt?.stop(),we.abort();for(const Ee of Le)Ee.abort();qe&&clearTimeout(qe),F.grant&&P(F.grant),J.current.onDirtyChange?.(!1),xe.current===M&&(xe.current=void 0)}},[t.id,t.revision,i,k]),w.useEffect(()=>{!h||!m.current?.contentWindow||m.current.contentWindow.postMessage({type:"codeshell-panel:event",instanceId:h.instanceId,event:"context.changed",payload:{...h.context,...typeof h.context.sessionId=="string"?{busy:l}:{}}},"*")},[l,h]),c.jsxs("section",{className:"panel-host",children:[c.jsxs("header",{className:"panel-host-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{children:t.title["zh-CN"]||t.title.default}),c.jsxs("p",{children:["v",t.version," · 运行于当前工作区"]})]}),c.jsx("button",{onClick:a,children:"返回面板"})]}),(h?.limitations??t.compatibility.reasons).length>0&&c.jsxs("details",{className:"panel-host-limitations",open:!0,children:[c.jsx("summary",{children:"部分功能可用"}),c.jsx("p",{children:"面板界面可以使用;以下功能尚未接入网页,使用时会显示具体限制。"}),c.jsx("ul",{children:(h?.limitations??t.compatibility.reasons).map(se=>c.jsx("li",{children:se},se))})]}),j&&c.jsx("p",{className:"panel-host-notice",role:"status",children:j}),N&&c.jsxs("div",{className:"panel-host-notice panel-host-directory",role:"status",children:[c.jsxs("p",{children:["文件保存在服务器目录:",N.path]}),N.url&&c.jsx("a",{href:N.url,target:"_blank",rel:"noopener noreferrer",children:"查看并下载文件"})]}),R&&c.jsxs("section",{className:"panel-host-preview","aria-label":"文件预览",tabIndex:-1,ref:T,children:[c.jsxs("header",{children:[c.jsx("h2",{children:R.name}),c.jsx("button",{onClick:()=>O(void 0),children:"关闭预览"})]}),!Y&&R.kind==="video"&&c.jsx("video",{src:R.url,controls:!0,playsInline:!0,preload:"metadata",onError:()=>re(!0)},R.url),!Y&&R.kind==="audio"&&c.jsx("audio",{src:R.url,controls:!0,preload:"metadata",onError:()=>re(!0)},R.url),!Y&&R.kind==="image"&&c.jsx("img",{src:R.url,alt:R.name,onError:()=>re(!0)},R.url),(Y||R.kind==="file")&&c.jsx("p",{role:"status",children:"当前浏览器无法预览此文件。可以保存后打开;若保存失败,请重新打开面板检查访问权限。"}),c.jsx("a",{href:R.downloadUrl,download:R.name,children:"保存到此设备"})]}),V&&c.jsx("p",{className:"panel-host-notice",role:"status",children:V}),x&&c.jsxs("div",{className:"panel-host-error",role:"alert",children:[c.jsx("p",{children:x}),c.jsx("button",{disabled:y,onClick:()=>L(se=>se+1),children:"重新打开面板"})]}),y&&c.jsx("p",{className:"panel-host-loading",role:"status",children:"正在打开面板…"}),$&&c.jsx(fw,{request:$}),z&&c.jsx(pw,{request:z}),B&&c.jsxs("section",{className:"panel-host-confirm",ref:ae,tabIndex:-1,onKeyDown:se=>{se.key==="Escape"&&!he&&(se.preventDefault(),B.finish(!1))},"aria-label":B.effect.effect==="external.open"?"确认打开外部链接":B.effect.effect==="host.confirm"?"确认面板操作":"确认发送面板任务",children:[c.jsx("h2",{children:B.effect.effect==="external.open"?"面板请求打开网页":B.effect.effect==="host.confirm"?B.effect.title:"面板请求向当前对话发送任务"}),B.effect.effect==="external.open"?c.jsx("p",{className:"panel-host-url",children:B.effect.url}):B.effect.effect==="host.confirm"?c.jsx("pre",{children:B.effect.body}):c.jsx("pre",{children:B.effect.prompt}),I&&c.jsx("p",{role:"alert",children:I}),c.jsxs("div",{className:"panel-host-actions",children:[c.jsx("button",{disabled:he,onClick:()=>B.finish(!1),children:"取消"}),B.effect.effect==="external.open"?c.jsx("a",{href:B.effect.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>B.finish(!0),children:"确认打开网页"}):c.jsx("button",{className:"panel-host-primary",disabled:he,onClick:()=>B.finish(!0),children:he?"正在确认…":B.effect.effect==="host.confirm"?"确认执行":"确认发送任务"})]})]}),h&&c.jsx("iframe",{ref:m,src:h.src,title:`${t.title["zh-CN"]||t.title.default}面板`,sandbox:"allow-scripts allow-downloads",referrerPolicy:"no-referrer",inert:!!B||he||!!$||!!z,onLoad:()=>xe.current?.loaded(),allow:"camera 'none'; microphone 'none'; geolocation 'none'; display-capture 'none'; clipboard-read 'none'; clipboard-write 'none'",className:"panel-host-frame"})]})}function Sw(t,i){const l={};return(t[t.length-1]===""?[...t,""]:t).join((l.padRight?" ":"")+","+(l.padLeft===!1?"":" ")).trim()}const ww=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kw={};function my(t,i){return(kw.jsx?jw:ww).test(t)}const Ew=/[ \t\n\f\r]/g;function Cw(t){return typeof t=="object"?t.type==="text"?gy(t.value):!1:gy(t)}function gy(t){return t.replace(Ew,"")===""}class Ca{constructor(i,l,a){this.normal=l,this.property=i,a&&(this.space=a)}}Ca.prototype.normal={};Ca.prototype.property={};Ca.prototype.space=void 0;function _b(t,i){const l={},a={};for(const o of t)Object.assign(l,o.property),Object.assign(a,o.normal);return new Ca(l,a,i)}function Of(t){return t.toLowerCase()}class gn{constructor(i,l){this.attribute=l,this.property=i}}gn.prototype.attribute="";gn.prototype.booleanish=!1;gn.prototype.boolean=!1;gn.prototype.commaOrSpaceSeparated=!1;gn.prototype.commaSeparated=!1;gn.prototype.defined=!1;gn.prototype.mustUseProperty=!1;gn.prototype.number=!1;gn.prototype.overloadedBoolean=!1;gn.prototype.property="";gn.prototype.spaceSeparated=!1;gn.prototype.space=void 0;let Nw=0;const Ve=Sr(),$t=Sr(),Lf=Sr(),be=Sr(),At=Sr(),gr=Sr(),kn=Sr();function Sr(){return 2**++Nw}const Bf=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ve,booleanish:$t,commaOrSpaceSeparated:kn,commaSeparated:gr,number:be,overloadedBoolean:Lf,spaceSeparated:At},Symbol.toStringTag,{value:"Module"})),hf=Object.keys(Bf);class ad extends gn{constructor(i,l,a,o){let f=-1;if(super(i,l),yy(this,"space",o),typeof a=="number")for(;++f<hf.length;){const u=hf[f];yy(this,hf[f],(a&Bf[u])===Bf[u])}}}ad.prototype.defined=!0;function yy(t,i,l){l&&(t[i]=l)}function pl(t){const i={},l={};for(const[a,o]of Object.entries(t.properties)){const f=new ad(a,t.transform(t.attributes||{},a),o,t.space);t.mustUseProperty&&t.mustUseProperty.includes(a)&&(f.mustUseProperty=!0),i[a]=f,l[Of(a)]=a,l[Of(f.attribute)]=a}return new Ca(i,l,t.space)}const Mb=pl({properties:{ariaActiveDescendant:null,ariaAtomic:$t,ariaAutoComplete:null,ariaBusy:$t,ariaChecked:$t,ariaColCount:be,ariaColIndex:be,ariaColSpan:be,ariaControls:At,ariaCurrent:null,ariaDescribedBy:At,ariaDetails:null,ariaDisabled:$t,ariaDropEffect:At,ariaErrorMessage:null,ariaExpanded:$t,ariaFlowTo:At,ariaGrabbed:$t,ariaHasPopup:null,ariaHidden:$t,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:At,ariaLevel:be,ariaLive:null,ariaModal:$t,ariaMultiLine:$t,ariaMultiSelectable:$t,ariaOrientation:null,ariaOwns:At,ariaPlaceholder:null,ariaPosInSet:be,ariaPressed:$t,ariaReadOnly:$t,ariaRelevant:null,ariaRequired:$t,ariaRoleDescription:At,ariaRowCount:be,ariaRowIndex:be,ariaRowSpan:be,ariaSelected:$t,ariaSetSize:be,ariaSort:null,ariaValueMax:be,ariaValueMin:be,ariaValueNow:be,ariaValueText:null,role:null},transform(t,i){return i==="role"?i:"aria-"+i.slice(4).toLowerCase()}});function Ob(t,i){return i in t?t[i]:i}function Lb(t,i){return Ob(t,i.toLowerCase())}const Aw=pl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:gr,acceptCharset:At,accessKey:At,action:null,allow:null,allowFullScreen:Ve,allowPaymentRequest:Ve,allowUserMedia:Ve,alpha:Ve,alt:null,as:null,async:Ve,autoCapitalize:null,autoComplete:At,autoFocus:Ve,autoPlay:Ve,blocking:At,capture:null,charSet:null,checked:Ve,cite:null,className:At,closedBy:null,colorSpace:null,cols:be,colSpan:be,command:null,commandFor:null,content:null,contentEditable:$t,controls:Ve,controlsList:At,coords:be|gr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ve,defer:Ve,dir:null,dirName:null,disabled:Ve,download:Lf,draggable:$t,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ve,formTarget:null,headers:At,height:be,hidden:Lf,high:be,href:null,hrefLang:null,htmlFor:At,httpEquiv:At,id:null,imageSizes:null,imageSrcSet:null,inert:Ve,inputMode:null,integrity:null,is:null,isMap:Ve,itemId:null,itemProp:At,itemRef:At,itemScope:Ve,itemType:At,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ve,low:be,manifest:null,max:null,maxLength:be,media:null,method:null,min:null,minLength:be,multiple:Ve,muted:Ve,name:null,nonce:null,noModule:Ve,noValidate:Ve,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:Ve,optimum:be,pattern:null,ping:At,placeholder:null,playsInline:Ve,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ve,referrerPolicy:null,rel:At,required:Ve,reversed:Ve,rows:be,rowSpan:be,sandbox:At,scope:null,scoped:Ve,seamless:Ve,selected:Ve,shadowRootClonable:Ve,shadowRootCustomElementRegistry:Ve,shadowRootDelegatesFocus:Ve,shadowRootMode:null,shadowRootSerializable:Ve,shape:null,size:be,sizes:null,slot:null,span:be,spellCheck:$t,src:null,srcDoc:null,srcLang:null,srcSet:null,start:be,step:null,style:null,tabIndex:be,target:null,title:null,translate:null,type:null,typeMustMatch:Ve,useMap:null,value:$t,width:be,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:At,axis:null,background:null,bgColor:null,border:be,borderColor:null,bottomMargin:be,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ve,declare:Ve,event:null,face:null,frame:null,frameBorder:null,hSpace:be,leftMargin:be,link:null,longDesc:null,lowSrc:null,marginHeight:be,marginWidth:be,noResize:Ve,noHref:Ve,noShade:Ve,noWrap:Ve,object:null,profile:null,prompt:null,rev:null,rightMargin:be,rules:null,scheme:null,scrolling:$t,standby:null,summary:null,text:null,topMargin:be,valueType:null,version:null,vAlign:null,vLink:null,vSpace:be,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ve,disablePictureInPicture:Ve,disableRemotePlayback:Ve,exportParts:gr,part:At,prefix:null,property:null,results:be,security:null,unselectable:null},space:"html",transform:Lb}),Tw=pl({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:kn,accentHeight:be,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:be,amplitude:be,arabicForm:null,ascent:be,attributeName:null,attributeType:null,azimuth:be,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:be,by:null,calcMode:null,capHeight:be,className:At,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:be,diffuseConstant:be,direction:null,display:null,dur:null,divisor:be,dominantBaseline:null,download:Ve,dx:null,dy:null,edgeMode:null,editable:null,elevation:be,enableBackground:null,end:null,event:null,exponent:be,externalResourcesRequired:null,fill:null,fillOpacity:be,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:gr,g2:gr,glyphName:gr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:be,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:be,horizOriginX:be,horizOriginY:be,id:null,ideographic:be,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:be,k:be,k1:be,k2:be,k3:be,k4:be,kernelMatrix:kn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:be,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:be,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:be,overlineThickness:be,paintOrder:null,panose1:null,path:null,pathLength:be,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:At,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:be,pointsAtY:be,pointsAtZ:be,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:kn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:kn,rev:kn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:kn,requiredFeatures:kn,requiredFonts:kn,requiredFormats:kn,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:be,specularExponent:be,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:be,strikethroughThickness:be,string:null,stroke:null,strokeDashArray:kn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:be,strokeOpacity:be,strokeWidth:null,style:null,surfaceScale:be,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:kn,tabIndex:be,tableValues:null,target:null,targetX:be,targetY:be,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:kn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:be,underlineThickness:be,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:be,values:null,vAlphabetic:be,vMathematical:be,vectorEffect:null,vHanging:be,vIdeographic:be,version:null,vertAdvY:be,vertOriginX:be,vertOriginY:be,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:be,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ob}),Bb=pl({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()}}),Ub=pl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Lb}),Ib=pl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,i){return"xml:"+i.slice(3).toLowerCase()}}),Rw={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"},zw=/[A-Z]/g,by=/-[a-z]/g,Dw=/^data[-\w.:]+$/i;function _w(t,i){const l=Of(i);let a=i,o=gn;if(l in t.normal)return t.property[t.normal[l]];if(l.length>4&&l.slice(0,4)==="data"&&Dw.test(i)){if(i.charAt(4)==="-"){const f=i.slice(5).replace(by,Ow);a="data"+f.charAt(0).toUpperCase()+f.slice(1)}else{const f=i.slice(4);if(!by.test(f)){let u=f.replace(zw,Mw);u.charAt(0)!=="-"&&(u="-"+u),i="data"+u}}o=ad}return new o(a,i)}function Mw(t){return"-"+t.toLowerCase()}function Ow(t){return t.charAt(1).toUpperCase()}const Lw=_b([Mb,Aw,Bb,Ub,Ib],"html"),sd=_b([Mb,Tw,Bb,Ub,Ib],"svg");function Bw(t){return t.join(" ").trim()}var ol={},pf,vy;function Uw(){if(vy)return pf;vy=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,l=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,f=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,m=/^\s+|\s+$/g,h=`
|
|
29
|
-
`,p="/",y="*",b="",x="comment",v="declaration";function j(N,A){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];A=A||{};var R=1,O=1;function Y(ee){var K=ee.match(i);K&&(R+=K.length);var z=ee.lastIndexOf(h);O=~z?ee.length-z:O+ee.length}function re(){var ee={line:R,column:O};return function(K){return K.position=new T(ee),I(),K}}function T(ee){this.start=ee,this.end={line:R,column:O},this.source=A.source}T.prototype.content=N;function V(ee){var K=new Error(A.source+":"+R+":"+O+": "+ee);if(K.reason=ee,K.filename=A.source,K.line=R,K.column=O,K.source=N,!A.silent)throw K}function Q(ee){var K=ee.exec(N);if(K){var z=K[0];return Y(z),N=N.slice(z.length),K}}function I(){Q(l)}function C(ee){var K;for(ee=ee||[];K=B();)K!==!1&&ee.push(K);return ee}function B(){var ee=re();if(!(p!=N.charAt(0)||y!=N.charAt(1))){for(var K=2;b!=N.charAt(K)&&(y!=N.charAt(K)||p!=N.charAt(K+1));)++K;if(K+=2,b===N.charAt(K-1))return V("End of comment missing");var z=N.slice(2,K-2);return O+=2,Y(z),N=N.slice(K),O+=2,ee({type:x,comment:z})}}function U(){var ee=re(),K=Q(a);if(K){if(B(),!Q(o))return V("property missing ':'");var z=Q(f),Z=ee({type:v,property:D(K[0].replace(t,b)),value:z?D(z[0].replace(t,b)):b});return Q(u),Z}}function $(){var ee=[];C(ee);for(var K;K=U();)K!==!1&&(ee.push(K),C(ee));return ee}return I(),$()}function D(N){return N?N.replace(m,b):b}return pf=j,pf}var xy;function Iw(){if(xy)return ol;xy=1;var t=ol&&ol.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(ol,"__esModule",{value:!0}),ol.default=l;const i=t(Uw());function l(a,o){let f=null;if(!a||typeof a!="string")return f;const u=(0,i.default)(a),m=typeof o=="function";return u.forEach(h=>{if(h.type!=="declaration")return;const{property:p,value:y}=h;m?o(p,y,h):y&&(f=f||{},f[p]=y)}),f}return ol}var fa={},Sy;function qw(){if(Sy)return fa;Sy=1,Object.defineProperty(fa,"__esModule",{value:!0}),fa.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,i=/-([a-z])/g,l=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,f=function(p){return!p||l.test(p)||t.test(p)},u=function(p,y){return y.toUpperCase()},m=function(p,y){return"".concat(y,"-")},h=function(p,y){return y===void 0&&(y={}),f(p)?p:(p=p.toLowerCase(),y.reactCompat?p=p.replace(o,m):p=p.replace(a,m),p.replace(i,u))};return fa.camelCase=h,fa}var da,wy;function Hw(){if(wy)return da;wy=1;var t=da&&da.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},i=t(Iw()),l=qw();function a(o,f){var u={};return!o||typeof o!="string"||(0,i.default)(o,function(m,h){m&&h&&(u[(0,l.camelCase)(m,f)]=h)}),u}return a.default=a,da=a,da}var Vw=Hw();const Yw=co(Vw),qb=Hb("end"),od=Hb("start");function Hb(t){return i;function i(l){const a=l&&l.position&&l.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 Gw(t){const i=od(t),l=qb(t);if(i&&l)return{start:i,end:l}}function ya(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?jy(t.position):"start"in t||"end"in t?jy(t):"line"in t||"column"in t?Uf(t):""}function Uf(t){return ky(t&&t.line)+":"+ky(t&&t.column)}function jy(t){return Uf(t&&t.start)+"-"+Uf(t&&t.end)}function ky(t){return t&&typeof t=="number"?t:1}class an extends Error{constructor(i,l,a){super(),typeof l=="string"&&(a=l,l=void 0);let o="",f={},u=!1;if(l&&("line"in l&&"column"in l?f={place:l}:"start"in l&&"end"in l?f={place:l}:"type"in l?f={ancestors:[l],place:l.position}:f={...l}),typeof i=="string"?o=i:!f.cause&&i&&(u=!0,o=i.message,f.cause=i),!f.ruleId&&!f.source&&typeof a=="string"){const h=a.indexOf(":");h===-1?f.ruleId=a:(f.source=a.slice(0,h),f.ruleId=a.slice(h+1))}if(!f.place&&f.ancestors&&f.ancestors){const h=f.ancestors[f.ancestors.length-1];h&&(f.place=h.position)}const m=f.place&&"start"in f.place?f.place.start:f.place;this.ancestors=f.ancestors||void 0,this.cause=f.cause||void 0,this.column=m?m.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=m?m.line:void 0,this.name=ya(f.place)||"1:1",this.place=f.place||void 0,this.reason=this.message,this.ruleId=f.ruleId||void 0,this.source=f.source||void 0,this.stack=u&&f.cause&&typeof f.cause.stack=="string"?f.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}an.prototype.file="";an.prototype.name="";an.prototype.reason="";an.prototype.message="";an.prototype.stack="";an.prototype.column=void 0;an.prototype.line=void 0;an.prototype.ancestors=void 0;an.prototype.cause=void 0;an.prototype.fatal=void 0;an.prototype.place=void 0;an.prototype.ruleId=void 0;an.prototype.source=void 0;const ud={}.hasOwnProperty,Fw=new Map,Qw=/[A-Z]/g,$w=new Set(["table","tbody","thead","tfoot","tr"]),Xw=new Set(["td","th"]),Vb="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Kw(t,i){if(!i||i.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const l=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=ij(l,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=nj(l,i.jsx,i.jsxs)}const o={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:a,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:i.passKeys!==!1,passNode:i.passNode||!1,schema:i.space==="svg"?sd:Lw,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:i.tableCellAlignToStyle!==!1},f=Yb(o,t,void 0);return f&&typeof f!="string"?f:o.create(t,o.Fragment,{children:f||void 0},void 0)}function Yb(t,i,l){if(i.type==="element")return Pw(t,i,l);if(i.type==="mdxFlowExpression"||i.type==="mdxTextExpression")return Zw(t,i);if(i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement")return Ww(t,i,l);if(i.type==="mdxjsEsm")return Jw(t,i);if(i.type==="root")return ej(t,i,l);if(i.type==="text")return tj(t,i)}function Pw(t,i,l){const a=t.schema;let o=a;i.tagName.toLowerCase()==="svg"&&a.space==="html"&&(o=sd,t.schema=o),t.ancestors.push(i);const f=Fb(t,i.tagName,!1),u=rj(t,i);let m=fd(t,i);return $w.has(i.tagName)&&(m=m.filter(function(h){return typeof h=="string"?!Cw(h):!0})),Gb(t,u,f,i),cd(u,m),t.ancestors.pop(),t.schema=a,t.create(i,f,u,l)}function Zw(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)}wa(t,i.position)}function Jw(t,i){if(i.data&&i.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(i.data.estree);wa(t,i.position)}function Ww(t,i,l){const a=t.schema;let o=a;i.name==="svg"&&a.space==="html"&&(o=sd,t.schema=o),t.ancestors.push(i);const f=i.name===null?t.Fragment:Fb(t,i.name,!0),u=lj(t,i),m=fd(t,i);return Gb(t,u,f,i),cd(u,m),t.ancestors.pop(),t.schema=a,t.create(i,f,u,l)}function ej(t,i,l){const a={};return cd(a,fd(t,i)),t.create(i,t.Fragment,a,l)}function tj(t,i){return i.value}function Gb(t,i,l,a){typeof l!="string"&&l!==t.Fragment&&t.passNode&&(i.node=a)}function cd(t,i){if(i.length>0){const l=i.length>1?i:i[0];l&&(t.children=l)}}function nj(t,i,l){return a;function a(o,f,u,m){const p=Array.isArray(u.children)?l:i;return m?p(f,u,m):p(f,u)}}function ij(t,i){return l;function l(a,o,f,u){const m=Array.isArray(f.children),h=od(a);return i(o,f,u,m,{columnNumber:h?h.column-1:void 0,fileName:t,lineNumber:h?h.line:void 0},void 0)}}function rj(t,i){const l={};let a,o;for(o in i.properties)if(o!=="children"&&ud.call(i.properties,o)){const f=aj(t,o,i.properties[o]);if(f){const[u,m]=f;t.tableCellAlignToStyle&&u==="align"&&typeof m=="string"&&Xw.has(i.tagName)?a=m:l[u]=m}}if(a){const f=l.style||(l.style={});f[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return l}function lj(t,i){const l={};for(const a of i.attributes)if(a.type==="mdxJsxExpressionAttribute")if(a.data&&a.data.estree&&t.evaluater){const f=a.data.estree.body[0];f.type;const u=f.expression;u.type;const m=u.properties[0];m.type,Object.assign(l,t.evaluater.evaluateExpression(m.argument))}else wa(t,i.position);else{const o=a.name;let f;if(a.value&&typeof a.value=="object")if(a.value.data&&a.value.data.estree&&t.evaluater){const m=a.value.data.estree.body[0];m.type,f=t.evaluater.evaluateExpression(m.expression)}else wa(t,i.position);else f=a.value===null?!0:a.value;l[o]=f}return l}function fd(t,i){const l=[];let a=-1;const o=t.passKeys?new Map:Fw;for(;++a<i.children.length;){const f=i.children[a];let u;if(t.passKeys){const h=f.type==="element"?f.tagName:f.type==="mdxJsxFlowElement"||f.type==="mdxJsxTextElement"?f.name:void 0;if(h){const p=o.get(h)||0;u=h+"-"+p,o.set(h,p+1)}}const m=Yb(t,f,u);m!==void 0&&l.push(m)}return l}function aj(t,i,l){const a=_w(t.schema,i);if(!(l==null||typeof l=="number"&&Number.isNaN(l))){if(Array.isArray(l)&&(l=a.commaSeparated?Sw(l):Bw(l)),a.property==="style"){let o=typeof l=="object"?l:sj(t,String(l));return t.stylePropertyNameCase==="css"&&(o=oj(o)),["style",o]}return[t.elementAttributeNameCase==="react"&&a.space?Rw[a.property]||a.property:a.attribute,l]}}function sj(t,i){try{return Yw(i,{reactCompat:!0})}catch(l){if(t.ignoreInvalidStyle)return{};const a=l,o=new an("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:a,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=t.filePath||void 0,o.url=Vb+"#cannot-parse-style-attribute",o}}function Fb(t,i,l){let a;if(!l)a={type:"Literal",value:i};else if(i.includes(".")){const o=i.split(".");let f=-1,u;for(;++f<o.length;){const m=my(o[f])?{type:"Identifier",name:o[f]}:{type:"Literal",value:o[f]};u=u?{type:"MemberExpression",object:u,property:m,computed:!!(f&&m.type==="Literal"),optional:!1}:m}a=u}else a=my(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};if(a.type==="Literal"){const o=a.value;return ud.call(t.components,o)?t.components[o]:o}if(t.evaluater)return t.evaluater.evaluateExpression(a);wa(t)}function wa(t,i){const l=new an("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw l.file=t.filePath||void 0,l.url=Vb+"#cannot-handle-mdx-estrees-without-createevaluater",l}function oj(t){const i={};let l;for(l in t)ud.call(t,l)&&(i[uj(l)]=t[l]);return i}function uj(t){let i=t.replace(Qw,cj);return i.slice(0,3)==="ms-"&&(i="-"+i),i}function cj(t){return"-"+t.toLowerCase()}const mf={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"]},fj={};function dd(t,i){const l=fj,a=typeof l.includeImageAlt=="boolean"?l.includeImageAlt:!0,o=typeof l.includeHtml=="boolean"?l.includeHtml:!0;return Qb(t,a,o)}function Qb(t,i,l){if(dj(t)){if("value"in t)return t.type==="html"&&!l?"":t.value;if(i&&"alt"in t&&t.alt)return t.alt;if("children"in t)return Ey(t.children,i,l)}return Array.isArray(t)?Ey(t,i,l):""}function Ey(t,i,l){const a=[];let o=-1;for(;++o<t.length;)a[o]=Qb(t[o],i,l);return a.join("")}function dj(t){return!!(t&&typeof t=="object")}const Cy=document.createElement("i");function hd(t){const i="&"+t+";";Cy.innerHTML=i;const l=Cy.textContent;return l.charCodeAt(l.length-1)===59&&t!=="semi"||l===i?!1:l}function En(t,i,l,a){const o=t.length;let f=0,u;if(i<0?i=-i>o?0:o+i:i=i>o?o:i,l=l>0?l:0,a.length<1e4)u=Array.from(a),u.unshift(i,l),t.splice(...u);else for(l&&t.splice(i,l);f<a.length;)u=a.slice(f,f+1e4),u.unshift(i,0),t.splice(...u),f+=1e4,i+=1e4}function Bn(t,i){return t.length>0?(En(t,t.length,0,i),t):i}const Ny={}.hasOwnProperty;function $b(t){const i={};let l=-1;for(;++l<t.length;)hj(i,t[l]);return i}function hj(t,i){let l;for(l in i){const o=(Ny.call(t,l)?t[l]:void 0)||(t[l]={}),f=i[l];let u;if(f)for(u in f){Ny.call(o,u)||(o[u]=[]);const m=f[u];pj(o[u],Array.isArray(m)?m:m?[m]:[])}}}function pj(t,i){let l=-1;const a=[];for(;++l<i.length;)(i[l].add==="after"?t:a).push(i[l]);En(t,0,0,a)}function Xb(t,i){const l=Number.parseInt(t,i);return l<9||l===11||l>13&&l<32||l>126&&l<160||l>55295&&l<57344||l>64975&&l<65008||(l&65535)===65535||(l&65535)===65534||l>1114111?"�":String.fromCodePoint(l)}function Yn(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const on=Xi(/[A-Za-z]/),ln=Xi(/[\dA-Za-z]/),mj=Xi(/[#-'*+\--9=?A-Z^-~]/);function ao(t){return t!==null&&(t<32||t===127)}const If=Xi(/\d/),gj=Xi(/[\dA-Fa-f]/),yj=Xi(/[!-/:-@[-`{-~]/);function Ue(t){return t!==null&&t<-2}function Tt(t){return t!==null&&(t<0||t===32)}function et(t){return t===-2||t===-1||t===32}const po=Xi(new RegExp("\\p{P}|\\p{S}","u")),yr=Xi(/\s/);function Xi(t){return i;function i(l){return l!==null&&l>-1&&t.test(String.fromCharCode(l))}}function ml(t){const i=[];let l=-1,a=0,o=0;for(;++l<t.length;){const f=t.charCodeAt(l);let u="";if(f===37&&ln(t.charCodeAt(l+1))&&ln(t.charCodeAt(l+2)))o=2;else if(f<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(f))||(u=String.fromCharCode(f));else if(f>55295&&f<57344){const m=t.charCodeAt(l+1);f<56320&&m>56319&&m<57344?(u=String.fromCharCode(f,m),o=1):u="�"}else u=String.fromCharCode(f);u&&(i.push(t.slice(a,l),encodeURIComponent(u)),a=l+o+1,u=""),o&&(l+=o,o=0)}return i.join("")+t.slice(a)}function ot(t,i,l,a){const o=a?a-1:Number.POSITIVE_INFINITY;let f=0;return u;function u(h){return et(h)?(t.enter(l),m(h)):i(h)}function m(h){return et(h)&&f++<o?(t.consume(h),m):(t.exit(l),i(h))}}const bj={tokenize:vj};function vj(t){const i=t.attempt(this.parser.constructs.contentInitial,a,o);let l;return i;function a(m){if(m===null){t.consume(m);return}return t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),ot(t,i,"linePrefix")}function o(m){return t.enter("paragraph"),f(m)}function f(m){const h=t.enter("chunkText",{contentType:"text",previous:l});return l&&(l.next=h),l=h,u(m)}function u(m){if(m===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(m);return}return Ue(m)?(t.consume(m),t.exit("chunkText"),f):(t.consume(m),u)}}const xj={tokenize:Sj},Ay={tokenize:wj};function Sj(t){const i=this,l=[];let a=0,o,f,u;return m;function m(O){if(a<l.length){const Y=l[a];return i.containerState=Y[1],t.attempt(Y[0].continuation,h,p)(O)}return p(O)}function h(O){if(a++,i.containerState._closeFlow){i.containerState._closeFlow=void 0,o&&R();const Y=i.events.length;let re=Y,T;for(;re--;)if(i.events[re][0]==="exit"&&i.events[re][1].type==="chunkFlow"){T=i.events[re][1].end;break}A(a);let V=Y;for(;V<i.events.length;)i.events[V][1].end={...T},V++;return En(i.events,re+1,0,i.events.slice(Y)),i.events.length=V,p(O)}return m(O)}function p(O){if(a===l.length){if(!o)return x(O);if(o.currentConstruct&&o.currentConstruct.concrete)return j(O);i.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return i.containerState={},t.check(Ay,y,b)(O)}function y(O){return o&&R(),A(a),x(O)}function b(O){return i.parser.lazy[i.now().line]=a!==l.length,u=i.now().offset,j(O)}function x(O){return i.containerState={},t.attempt(Ay,v,j)(O)}function v(O){return a++,l.push([i.currentConstruct,i.containerState]),x(O)}function j(O){if(O===null){o&&R(),A(0),t.consume(O);return}return o=o||i.parser.flow(i.now()),t.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:f}),D(O)}function D(O){if(O===null){N(t.exit("chunkFlow"),!0),A(0),t.consume(O);return}return Ue(O)?(t.consume(O),N(t.exit("chunkFlow")),a=0,i.interrupt=void 0,m):(t.consume(O),D)}function N(O,Y){const re=i.sliceStream(O);if(Y&&re.push(null),O.previous=f,f&&(f.next=O),f=O,o.defineSkip(O.start),o.write(re),i.parser.lazy[O.start.line]){let T=o.events.length;for(;T--;)if(o.events[T][1].start.offset<u&&(!o.events[T][1].end||o.events[T][1].end.offset>u))return;const V=i.events.length;let Q=V,I,C;for(;Q--;)if(i.events[Q][0]==="exit"&&i.events[Q][1].type==="chunkFlow"){if(I){C=i.events[Q][1].end;break}I=!0}for(A(a),T=V;T<i.events.length;)i.events[T][1].end={...C},T++;En(i.events,Q+1,0,i.events.slice(V)),i.events.length=T}}function A(O){let Y=l.length;for(;Y-- >O;){const re=l[Y];i.containerState=re[1],re[0].exit.call(i,t)}l.length=O}function R(){o.write([null]),f=void 0,o=void 0,i.containerState._closeFlow=void 0}}function wj(t,i,l){return ot(t,t.attempt(this.parser.constructs.document,i,l),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function dl(t){if(t===null||Tt(t)||yr(t))return 1;if(po(t))return 2}function mo(t,i,l){const a=[];let o=-1;for(;++o<t.length;){const f=t[o].resolveAll;f&&!a.includes(f)&&(i=f(i,l),a.push(f))}return i}const qf={name:"attention",resolveAll:jj,tokenize:kj};function jj(t,i){let l=-1,a,o,f,u,m,h,p,y;for(;++l<t.length;)if(t[l][0]==="enter"&&t[l][1].type==="attentionSequence"&&t[l][1]._close){for(a=l;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[l][1]).charCodeAt(0)){if((t[a][1]._close||t[l][1]._open)&&(t[l][1].end.offset-t[l][1].start.offset)%3&&!((t[a][1].end.offset-t[a][1].start.offset+t[l][1].end.offset-t[l][1].start.offset)%3))continue;h=t[a][1].end.offset-t[a][1].start.offset>1&&t[l][1].end.offset-t[l][1].start.offset>1?2:1;const b={...t[a][1].end},x={...t[l][1].start};Ty(b,-h),Ty(x,h),u={type:h>1?"strongSequence":"emphasisSequence",start:b,end:{...t[a][1].end}},m={type:h>1?"strongSequence":"emphasisSequence",start:{...t[l][1].start},end:x},f={type:h>1?"strongText":"emphasisText",start:{...t[a][1].end},end:{...t[l][1].start}},o={type:h>1?"strong":"emphasis",start:{...u.start},end:{...m.end}},t[a][1].end={...u.start},t[l][1].start={...m.end},p=[],t[a][1].end.offset-t[a][1].start.offset&&(p=Bn(p,[["enter",t[a][1],i],["exit",t[a][1],i]])),p=Bn(p,[["enter",o,i],["enter",u,i],["exit",u,i],["enter",f,i]]),p=Bn(p,mo(i.parser.constructs.insideSpan.null,t.slice(a+1,l),i)),p=Bn(p,[["exit",f,i],["enter",m,i],["exit",m,i],["exit",o,i]]),t[l][1].end.offset-t[l][1].start.offset?(y=2,p=Bn(p,[["enter",t[l][1],i],["exit",t[l][1],i]])):y=0,En(t,a-1,l-a+3,p),l=a+p.length-y-2;break}}for(l=-1;++l<t.length;)t[l][1].type==="attentionSequence"&&(t[l][1].type="data");return t}function kj(t,i){const l=this.parser.constructs.attentionMarkers.null,a=this.previous,o=dl(a);let f;return u;function u(h){return f=h,t.enter("attentionSequence"),m(h)}function m(h){if(h===f)return t.consume(h),m;const p=t.exit("attentionSequence"),y=dl(h),b=!y||y===2&&o||l.includes(h),x=!o||o===2&&y||l.includes(a);return p._open=!!(f===42?b:b&&(o||!x)),p._close=!!(f===42?x:x&&(y||!b)),i(h)}}function Ty(t,i){t.column+=i,t.offset+=i,t._bufferIndex+=i}const Ej={name:"autolink",tokenize:Cj};function Cj(t,i,l){let a=0;return o;function o(v){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(v),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),f}function f(v){return on(v)?(t.consume(v),u):v===64?l(v):p(v)}function u(v){return v===43||v===45||v===46||ln(v)?(a=1,m(v)):p(v)}function m(v){return v===58?(t.consume(v),a=0,h):(v===43||v===45||v===46||ln(v))&&a++<32?(t.consume(v),m):(a=0,p(v))}function h(v){return v===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(v),t.exit("autolinkMarker"),t.exit("autolink"),i):v===null||v===32||v===60||ao(v)?l(v):(t.consume(v),h)}function p(v){return v===64?(t.consume(v),y):mj(v)?(t.consume(v),p):l(v)}function y(v){return ln(v)?b(v):l(v)}function b(v){return v===46?(t.consume(v),a=0,y):v===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(v),t.exit("autolinkMarker"),t.exit("autolink"),i):x(v)}function x(v){if((v===45||ln(v))&&a++<63){const j=v===45?x:b;return t.consume(v),j}return l(v)}}const Na={partial:!0,tokenize:Nj};function Nj(t,i,l){return a;function a(f){return et(f)?ot(t,o,"linePrefix")(f):o(f)}function o(f){return f===null||Ue(f)?i(f):l(f)}}const Kb={continuation:{tokenize:Tj},exit:Rj,name:"blockQuote",tokenize:Aj};function Aj(t,i,l){const a=this;return o;function o(u){if(u===62){const m=a.containerState;return m.open||(t.enter("blockQuote",{_container:!0}),m.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(u),t.exit("blockQuoteMarker"),f}return l(u)}function f(u){return et(u)?(t.enter("blockQuotePrefixWhitespace"),t.consume(u),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),i):(t.exit("blockQuotePrefix"),i(u))}}function Tj(t,i,l){const a=this;return o;function o(u){return et(u)?ot(t,f,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):f(u)}function f(u){return t.attempt(Kb,i,l)(u)}}function Rj(t){t.exit("blockQuote")}const Pb={name:"characterEscape",tokenize:zj};function zj(t,i,l){return a;function a(f){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(f),t.exit("escapeMarker"),o}function o(f){return yj(f)?(t.enter("characterEscapeValue"),t.consume(f),t.exit("characterEscapeValue"),t.exit("characterEscape"),i):l(f)}}const Zb={name:"characterReference",tokenize:Dj};function Dj(t,i,l){const a=this;let o=0,f,u;return m;function m(b){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),h}function h(b){return b===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(b),t.exit("characterReferenceMarkerNumeric"),p):(t.enter("characterReferenceValue"),f=31,u=ln,y(b))}function p(b){return b===88||b===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(b),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),f=6,u=gj,y):(t.enter("characterReferenceValue"),f=7,u=If,y(b))}function y(b){if(b===59&&o){const x=t.exit("characterReferenceValue");return u===ln&&!hd(a.sliceSerialize(x))?l(b):(t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),t.exit("characterReference"),i)}return u(b)&&o++<f?(t.consume(b),y):l(b)}}const Ry={partial:!0,tokenize:Mj},zy={concrete:!0,name:"codeFenced",tokenize:_j};function _j(t,i,l){const a=this,o={partial:!0,tokenize:re};let f=0,u=0,m;return h;function h(T){return p(T)}function p(T){const V=a.events[a.events.length-1];return f=V&&V[1].type==="linePrefix"?V[2].sliceSerialize(V[1],!0).length:0,m=T,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),y(T)}function y(T){return T===m?(u++,t.consume(T),y):u<3?l(T):(t.exit("codeFencedFenceSequence"),et(T)?ot(t,b,"whitespace")(T):b(T))}function b(T){return T===null||Ue(T)?(t.exit("codeFencedFence"),a.interrupt?i(T):t.check(Ry,D,Y)(T)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),x(T))}function x(T){return T===null||Ue(T)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),b(T)):et(T)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),ot(t,v,"whitespace")(T)):T===96&&T===m?l(T):(t.consume(T),x)}function v(T){return T===null||Ue(T)?b(T):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),j(T))}function j(T){return T===null||Ue(T)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),b(T)):T===96&&T===m?l(T):(t.consume(T),j)}function D(T){return t.attempt(o,Y,N)(T)}function N(T){return t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),A}function A(T){return f>0&&et(T)?ot(t,R,"linePrefix",f+1)(T):R(T)}function R(T){return T===null||Ue(T)?t.check(Ry,D,Y)(T):(t.enter("codeFlowValue"),O(T))}function O(T){return T===null||Ue(T)?(t.exit("codeFlowValue"),R(T)):(t.consume(T),O)}function Y(T){return t.exit("codeFenced"),i(T)}function re(T,V,Q){let I=0;return C;function C(K){return T.enter("lineEnding"),T.consume(K),T.exit("lineEnding"),B}function B(K){return T.enter("codeFencedFence"),et(K)?ot(T,U,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):U(K)}function U(K){return K===m?(T.enter("codeFencedFenceSequence"),$(K)):Q(K)}function $(K){return K===m?(I++,T.consume(K),$):I>=u?(T.exit("codeFencedFenceSequence"),et(K)?ot(T,ee,"whitespace")(K):ee(K)):Q(K)}function ee(K){return K===null||Ue(K)?(T.exit("codeFencedFence"),V(K)):Q(K)}}}function Mj(t,i,l){const a=this;return o;function o(u){return u===null?l(u):(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),f)}function f(u){return a.parser.lazy[a.now().line]?l(u):i(u)}}const gf={name:"codeIndented",tokenize:Lj},Oj={partial:!0,tokenize:Bj};function Lj(t,i,l){const a=this;return o;function o(p){return t.enter("codeIndented"),ot(t,f,"linePrefix",5)(p)}function f(p){const y=a.events[a.events.length-1];return y&&y[1].type==="linePrefix"&&y[2].sliceSerialize(y[1],!0).length>=4?u(p):l(p)}function u(p){return p===null?h(p):Ue(p)?t.attempt(Oj,u,h)(p):(t.enter("codeFlowValue"),m(p))}function m(p){return p===null||Ue(p)?(t.exit("codeFlowValue"),u(p)):(t.consume(p),m)}function h(p){return t.exit("codeIndented"),i(p)}}function Bj(t,i,l){const a=this;return o;function o(u){return a.parser.lazy[a.now().line]?l(u):Ue(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),o):ot(t,f,"linePrefix",5)(u)}function f(u){const m=a.events[a.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?i(u):Ue(u)?o(u):l(u)}}const Uj={name:"codeText",previous:qj,resolve:Ij,tokenize:Hj};function Ij(t){let i=t.length-4,l=3,a,o;if((t[l][1].type==="lineEnding"||t[l][1].type==="space")&&(t[i][1].type==="lineEnding"||t[i][1].type==="space")){for(a=l;++a<i;)if(t[a][1].type==="codeTextData"){t[l][1].type="codeTextPadding",t[i][1].type="codeTextPadding",l+=2,i-=2;break}}for(a=l-1,i++;++a<=i;)o===void 0?a!==i&&t[a][1].type!=="lineEnding"&&(o=a):(a===i||t[a][1].type==="lineEnding")&&(t[o][1].type="codeTextData",a!==o+2&&(t[o][1].end=t[a-1][1].end,t.splice(o+2,a-o-2),i-=a-o-2,a=o+2),o=void 0);return t}function qj(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Hj(t,i,l){let a=0,o,f;return u;function u(b){return t.enter("codeText"),t.enter("codeTextSequence"),m(b)}function m(b){return b===96?(t.consume(b),a++,m):(t.exit("codeTextSequence"),h(b))}function h(b){return b===null?l(b):b===32?(t.enter("space"),t.consume(b),t.exit("space"),h):b===96?(f=t.enter("codeTextSequence"),o=0,y(b)):Ue(b)?(t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),h):(t.enter("codeTextData"),p(b))}function p(b){return b===null||b===32||b===96||Ue(b)?(t.exit("codeTextData"),h(b)):(t.consume(b),p)}function y(b){return b===96?(t.consume(b),o++,y):o===a?(t.exit("codeTextSequence"),t.exit("codeText"),i(b)):(f.type="codeTextData",p(b))}}class Vj{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,l){const a=l??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,l,a){const o=l||0;this.setCursor(Math.trunc(i));const f=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return a&&ha(this.left,a),f.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),ha(this.left,i)}unshift(i){this.setCursor(0),this.right.push(i)}unshiftMany(i){this.setCursor(0),ha(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 l=this.left.splice(i,Number.POSITIVE_INFINITY);ha(this.right,l.reverse())}else{const l=this.right.splice(this.left.length+this.right.length-i,Number.POSITIVE_INFINITY);ha(this.left,l.reverse())}}}function ha(t,i){let l=0;if(i.length<1e4)t.push(...i);else for(;l<i.length;)t.push(...i.slice(l,l+1e4)),l+=1e4}function Jb(t){const i={};let l=-1,a,o,f,u,m,h,p;const y=new Vj(t);for(;++l<y.length;){for(;l in i;)l=i[l];if(a=y.get(l),l&&a[1].type==="chunkFlow"&&y.get(l-1)[1].type==="listItemPrefix"&&(h=a[1]._tokenizer.events,f=0,f<h.length&&h[f][1].type==="lineEndingBlank"&&(f+=2),f<h.length&&h[f][1].type==="content"))for(;++f<h.length&&h[f][1].type!=="content";)h[f][1].type==="chunkText"&&(h[f][1]._isInFirstContentOfListItem=!0,f++);if(a[0]==="enter")a[1].contentType&&(Object.assign(i,Yj(y,l)),l=i[l],p=!0);else if(a[1]._container){for(f=l,o=void 0;f--;)if(u=y.get(f),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(o&&(y.get(o)[1].type="lineEndingBlank"),u[1].type="lineEnding",o=f);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;o&&(a[1].end={...y.get(o)[1].start},m=y.slice(o,l),m.unshift(a),y.splice(o,l-o+1,m))}}return En(t,0,Number.POSITIVE_INFINITY,y.slice(0)),!p}function Yj(t,i){const l=t.get(i)[1],a=t.get(i)[2];let o=i-1;const f=[];let u=l._tokenizer;u||(u=a.parser[l.contentType](l.start),l._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const m=u.events,h=[],p={};let y,b,x=-1,v=l,j=0,D=0;const N=[D];for(;v;){for(;t.get(++o)[1]!==v;);f.push(o),v._tokenizer||(y=a.sliceStream(v),v.next||y.push(null),b&&u.defineSkip(v.start),v._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(y),v._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),b=v,v=v.next}for(v=l;++x<m.length;)m[x][0]==="exit"&&m[x-1][0]==="enter"&&m[x][1].type===m[x-1][1].type&&m[x][1].start.line!==m[x][1].end.line&&(D=x+1,N.push(D),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(u.events=[],v?(v._tokenizer=void 0,v.previous=void 0):N.pop(),x=N.length;x--;){const A=m.slice(N[x],N[x+1]),R=f.pop();h.push([R,R+A.length-1]),t.splice(R,2,A)}for(h.reverse(),x=-1;++x<h.length;)p[j+h[x][0]]=j+h[x][1],j+=h[x][1]-h[x][0]-1;return p}const Gj={resolve:Qj,tokenize:$j},Fj={partial:!0,tokenize:Xj};function Qj(t){return Jb(t),t}function $j(t,i){let l;return a;function a(m){return t.enter("content"),l=t.enter("chunkContent",{contentType:"content"}),o(m)}function o(m){return m===null?f(m):Ue(m)?t.check(Fj,u,f)(m):(t.consume(m),o)}function f(m){return t.exit("chunkContent"),t.exit("content"),i(m)}function u(m){return t.consume(m),t.exit("chunkContent"),l.next=t.enter("chunkContent",{contentType:"content",previous:l}),l=l.next,o}}function Xj(t,i,l){const a=this;return o;function o(u){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),ot(t,f,"linePrefix")}function f(u){if(u===null||Ue(u))return l(u);const m=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?i(u):t.interrupt(a.parser.constructs.flow,l,i)(u)}}function Wb(t,i,l,a,o,f,u,m,h){const p=h||Number.POSITIVE_INFINITY;let y=0;return b;function b(A){return A===60?(t.enter(a),t.enter(o),t.enter(f),t.consume(A),t.exit(f),x):A===null||A===32||A===41||ao(A)?l(A):(t.enter(a),t.enter(u),t.enter(m),t.enter("chunkString",{contentType:"string"}),D(A))}function x(A){return A===62?(t.enter(f),t.consume(A),t.exit(f),t.exit(o),t.exit(a),i):(t.enter(m),t.enter("chunkString",{contentType:"string"}),v(A))}function v(A){return A===62?(t.exit("chunkString"),t.exit(m),x(A)):A===null||A===60||Ue(A)?l(A):(t.consume(A),A===92?j:v)}function j(A){return A===60||A===62||A===92?(t.consume(A),v):v(A)}function D(A){return!y&&(A===null||A===41||Tt(A))?(t.exit("chunkString"),t.exit(m),t.exit(u),t.exit(a),i(A)):y<p&&A===40?(t.consume(A),y++,D):A===41?(t.consume(A),y--,D):A===null||A===32||A===40||ao(A)?l(A):(t.consume(A),A===92?N:D)}function N(A){return A===40||A===41||A===92?(t.consume(A),D):D(A)}}function ev(t,i,l,a,o,f){const u=this;let m=0,h;return p;function p(v){return t.enter(a),t.enter(o),t.consume(v),t.exit(o),t.enter(f),y}function y(v){return m>999||v===null||v===91||v===93&&!h||v===94&&!m&&"_hiddenFootnoteSupport"in u.parser.constructs?l(v):v===93?(t.exit(f),t.enter(o),t.consume(v),t.exit(o),t.exit(a),i):Ue(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),y):(t.enter("chunkString",{contentType:"string"}),b(v))}function b(v){return v===null||v===91||v===93||Ue(v)||m++>999?(t.exit("chunkString"),y(v)):(t.consume(v),h||(h=!et(v)),v===92?x:b)}function x(v){return v===91||v===92||v===93?(t.consume(v),m++,b):b(v)}}function tv(t,i,l,a,o,f){let u;return m;function m(x){return x===34||x===39||x===40?(t.enter(a),t.enter(o),t.consume(x),t.exit(o),u=x===40?41:x,h):l(x)}function h(x){return x===u?(t.enter(o),t.consume(x),t.exit(o),t.exit(a),i):(t.enter(f),p(x))}function p(x){return x===u?(t.exit(f),h(u)):x===null?l(x):Ue(x)?(t.enter("lineEnding"),t.consume(x),t.exit("lineEnding"),ot(t,p,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),y(x))}function y(x){return x===u||x===null||Ue(x)?(t.exit("chunkString"),p(x)):(t.consume(x),x===92?b:y)}function b(x){return x===u||x===92?(t.consume(x),y):y(x)}}function ba(t,i){let l;return a;function a(o){return Ue(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),l=!0,a):et(o)?ot(t,a,l?"linePrefix":"lineSuffix")(o):i(o)}}const Kj={name:"definition",tokenize:Zj},Pj={partial:!0,tokenize:Jj};function Zj(t,i,l){const a=this;let o;return f;function f(v){return t.enter("definition"),u(v)}function u(v){return ev.call(a,t,m,l,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function m(v){return o=Yn(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),v===58?(t.enter("definitionMarker"),t.consume(v),t.exit("definitionMarker"),h):l(v)}function h(v){return Tt(v)?ba(t,p)(v):p(v)}function p(v){return Wb(t,y,l,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function y(v){return t.attempt(Pj,b,b)(v)}function b(v){return et(v)?ot(t,x,"whitespace")(v):x(v)}function x(v){return v===null||Ue(v)?(t.exit("definition"),a.parser.defined.push(o),i(v)):l(v)}}function Jj(t,i,l){return a;function a(m){return Tt(m)?ba(t,o)(m):l(m)}function o(m){return tv(t,f,l,"definitionTitle","definitionTitleMarker","definitionTitleString")(m)}function f(m){return et(m)?ot(t,u,"whitespace")(m):u(m)}function u(m){return m===null||Ue(m)?i(m):l(m)}}const Wj={name:"hardBreakEscape",tokenize:ek};function ek(t,i,l){return a;function a(f){return t.enter("hardBreakEscape"),t.consume(f),o}function o(f){return Ue(f)?(t.exit("hardBreakEscape"),i(f)):l(f)}}const tk={name:"headingAtx",resolve:nk,tokenize:ik};function nk(t,i){let l=t.length-2,a=3,o,f;return t[a][1].type==="whitespace"&&(a+=2),l-2>a&&t[l][1].type==="whitespace"&&(l-=2),t[l][1].type==="atxHeadingSequence"&&(a===l-1||l-4>a&&t[l-2][1].type==="whitespace")&&(l-=a+1===l?2:4),l>a&&(o={type:"atxHeadingText",start:t[a][1].start,end:t[l][1].end},f={type:"chunkText",start:t[a][1].start,end:t[l][1].end,contentType:"text"},En(t,a,l-a+1,[["enter",o,i],["enter",f,i],["exit",f,i],["exit",o,i]])),t}function ik(t,i,l){let a=0;return o;function o(y){return t.enter("atxHeading"),f(y)}function f(y){return t.enter("atxHeadingSequence"),u(y)}function u(y){return y===35&&a++<6?(t.consume(y),u):y===null||Tt(y)?(t.exit("atxHeadingSequence"),m(y)):l(y)}function m(y){return y===35?(t.enter("atxHeadingSequence"),h(y)):y===null||Ue(y)?(t.exit("atxHeading"),i(y)):et(y)?ot(t,m,"whitespace")(y):(t.enter("atxHeadingText"),p(y))}function h(y){return y===35?(t.consume(y),h):(t.exit("atxHeadingSequence"),m(y))}function p(y){return y===null||y===35||Tt(y)?(t.exit("atxHeadingText"),m(y)):(t.consume(y),p)}}const rk=["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"],Dy=["pre","script","style","textarea"],lk={concrete:!0,name:"htmlFlow",resolveTo:ok,tokenize:uk},ak={partial:!0,tokenize:fk},sk={partial:!0,tokenize:ck};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 uk(t,i,l){const a=this;let o,f,u,m,h;return p;function p(_){return y(_)}function y(_){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(_),b}function b(_){return _===33?(t.consume(_),x):_===47?(t.consume(_),f=!0,D):_===63?(t.consume(_),o=3,a.interrupt?i:k):on(_)?(t.consume(_),u=String.fromCharCode(_),N):l(_)}function x(_){return _===45?(t.consume(_),o=2,v):_===91?(t.consume(_),o=5,m=0,j):on(_)?(t.consume(_),o=4,a.interrupt?i:k):l(_)}function v(_){return _===45?(t.consume(_),a.interrupt?i:k):l(_)}function j(_){const te="CDATA[";return _===te.charCodeAt(m++)?(t.consume(_),m===te.length?a.interrupt?i:U:j):l(_)}function D(_){return on(_)?(t.consume(_),u=String.fromCharCode(_),N):l(_)}function N(_){if(_===null||_===47||_===62||Tt(_)){const te=_===47,xe=u.toLowerCase();return!te&&!f&&Dy.includes(xe)?(o=1,a.interrupt?i(_):U(_)):rk.includes(u.toLowerCase())?(o=6,te?(t.consume(_),A):a.interrupt?i(_):U(_)):(o=7,a.interrupt&&!a.parser.lazy[a.now().line]?l(_):f?R(_):O(_))}return _===45||ln(_)?(t.consume(_),u+=String.fromCharCode(_),N):l(_)}function A(_){return _===62?(t.consume(_),a.interrupt?i:U):l(_)}function R(_){return et(_)?(t.consume(_),R):C(_)}function O(_){return _===47?(t.consume(_),C):_===58||_===95||on(_)?(t.consume(_),Y):et(_)?(t.consume(_),O):C(_)}function Y(_){return _===45||_===46||_===58||_===95||ln(_)?(t.consume(_),Y):re(_)}function re(_){return _===61?(t.consume(_),T):et(_)?(t.consume(_),re):O(_)}function T(_){return _===null||_===60||_===61||_===62||_===96?l(_):_===34||_===39?(t.consume(_),h=_,V):et(_)?(t.consume(_),T):Q(_)}function V(_){return _===h?(t.consume(_),h=null,I):_===null||Ue(_)?l(_):(t.consume(_),V)}function Q(_){return _===null||_===34||_===39||_===47||_===60||_===61||_===62||_===96||Tt(_)?re(_):(t.consume(_),Q)}function I(_){return _===47||_===62||et(_)?O(_):l(_)}function C(_){return _===62?(t.consume(_),B):l(_)}function B(_){return _===null||Ue(_)?U(_):et(_)?(t.consume(_),B):l(_)}function U(_){return _===45&&o===2?(t.consume(_),z):_===60&&o===1?(t.consume(_),Z):_===62&&o===4?(t.consume(_),L):_===63&&o===3?(t.consume(_),k):_===93&&o===5?(t.consume(_),me):Ue(_)&&(o===6||o===7)?(t.exit("htmlFlowData"),t.check(ak,J,$)(_)):_===null||Ue(_)?(t.exit("htmlFlowData"),$(_)):(t.consume(_),U)}function $(_){return t.check(sk,ee,J)(_)}function ee(_){return t.enter("lineEnding"),t.consume(_),t.exit("lineEnding"),K}function K(_){return _===null||Ue(_)?$(_):(t.enter("htmlFlowData"),U(_))}function z(_){return _===45?(t.consume(_),k):U(_)}function Z(_){return _===47?(t.consume(_),u="",he):U(_)}function he(_){if(_===62){const te=u.toLowerCase();return Dy.includes(te)?(t.consume(_),L):U(_)}return on(_)&&u.length<8?(t.consume(_),u+=String.fromCharCode(_),he):U(_)}function me(_){return _===93?(t.consume(_),k):U(_)}function k(_){return _===62?(t.consume(_),L):_===45&&o===2?(t.consume(_),k):U(_)}function L(_){return _===null||Ue(_)?(t.exit("htmlFlowData"),J(_)):(t.consume(_),L)}function J(_){return t.exit("htmlFlow"),i(_)}}function ck(t,i,l){const a=this;return o;function o(u){return Ue(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),f):l(u)}function f(u){return a.parser.lazy[a.now().line]?l(u):i(u)}}function fk(t,i,l){return a;function a(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),t.attempt(Na,i,l)}}const dk={name:"htmlText",tokenize:hk};function hk(t,i,l){const a=this;let o,f,u;return m;function m(k){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(k),h}function h(k){return k===33?(t.consume(k),p):k===47?(t.consume(k),re):k===63?(t.consume(k),O):on(k)?(t.consume(k),Q):l(k)}function p(k){return k===45?(t.consume(k),y):k===91?(t.consume(k),f=0,j):on(k)?(t.consume(k),R):l(k)}function y(k){return k===45?(t.consume(k),v):l(k)}function b(k){return k===null?l(k):k===45?(t.consume(k),x):Ue(k)?(u=b,Z(k)):(t.consume(k),b)}function x(k){return k===45?(t.consume(k),v):b(k)}function v(k){return k===62?z(k):k===45?x(k):b(k)}function j(k){const L="CDATA[";return k===L.charCodeAt(f++)?(t.consume(k),f===L.length?D:j):l(k)}function D(k){return k===null?l(k):k===93?(t.consume(k),N):Ue(k)?(u=D,Z(k)):(t.consume(k),D)}function N(k){return k===93?(t.consume(k),A):D(k)}function A(k){return k===62?z(k):k===93?(t.consume(k),A):D(k)}function R(k){return k===null||k===62?z(k):Ue(k)?(u=R,Z(k)):(t.consume(k),R)}function O(k){return k===null?l(k):k===63?(t.consume(k),Y):Ue(k)?(u=O,Z(k)):(t.consume(k),O)}function Y(k){return k===62?z(k):O(k)}function re(k){return on(k)?(t.consume(k),T):l(k)}function T(k){return k===45||ln(k)?(t.consume(k),T):V(k)}function V(k){return Ue(k)?(u=V,Z(k)):et(k)?(t.consume(k),V):z(k)}function Q(k){return k===45||ln(k)?(t.consume(k),Q):k===47||k===62||Tt(k)?I(k):l(k)}function I(k){return k===47?(t.consume(k),z):k===58||k===95||on(k)?(t.consume(k),C):Ue(k)?(u=I,Z(k)):et(k)?(t.consume(k),I):z(k)}function C(k){return k===45||k===46||k===58||k===95||ln(k)?(t.consume(k),C):B(k)}function B(k){return k===61?(t.consume(k),U):Ue(k)?(u=B,Z(k)):et(k)?(t.consume(k),B):I(k)}function U(k){return k===null||k===60||k===61||k===62||k===96?l(k):k===34||k===39?(t.consume(k),o=k,$):Ue(k)?(u=U,Z(k)):et(k)?(t.consume(k),U):(t.consume(k),ee)}function $(k){return k===o?(t.consume(k),o=void 0,K):k===null?l(k):Ue(k)?(u=$,Z(k)):(t.consume(k),$)}function ee(k){return k===null||k===34||k===39||k===60||k===61||k===96?l(k):k===47||k===62||Tt(k)?I(k):(t.consume(k),ee)}function K(k){return k===47||k===62||Tt(k)?I(k):l(k)}function z(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),i):l(k)}function Z(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),he}function he(k){return et(k)?ot(t,me,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):me(k)}function me(k){return t.enter("htmlTextData"),u(k)}}const pd={name:"labelEnd",resolveAll:yk,resolveTo:bk,tokenize:vk},pk={tokenize:xk},mk={tokenize:Sk},gk={tokenize:wk};function yk(t){let i=-1;const l=[];for(;++i<t.length;){const a=t[i][1];if(l.push(t[i]),a.type==="labelImage"||a.type==="labelLink"||a.type==="labelEnd"){const o=a.type==="labelImage"?4:2;a.type="data",i+=o}}return t.length!==l.length&&En(t,0,t.length,l),t}function bk(t,i){let l=t.length,a=0,o,f,u,m;for(;l--;)if(o=t[l][1],f){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;t[l][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(u){if(t[l][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(f=l,o.type!=="labelLink")){a=2;break}}else o.type==="labelEnd"&&(u=l);const h={type:t[f][1].type==="labelLink"?"link":"image",start:{...t[f][1].start},end:{...t[t.length-1][1].end}},p={type:"label",start:{...t[f][1].start},end:{...t[u][1].end}},y={type:"labelText",start:{...t[f+a+2][1].end},end:{...t[u-2][1].start}};return m=[["enter",h,i],["enter",p,i]],m=Bn(m,t.slice(f+1,f+a+3)),m=Bn(m,[["enter",y,i]]),m=Bn(m,mo(i.parser.constructs.insideSpan.null,t.slice(f+a+4,u-3),i)),m=Bn(m,[["exit",y,i],t[u-2],t[u-1],["exit",p,i]]),m=Bn(m,t.slice(u+1)),m=Bn(m,[["exit",h,i]]),En(t,f,t.length,m),t}function vk(t,i,l){const a=this;let o=a.events.length,f,u;for(;o--;)if((a.events[o][1].type==="labelImage"||a.events[o][1].type==="labelLink")&&!a.events[o][1]._balanced){f=a.events[o][1];break}return m;function m(x){return f?f._inactive?b(x):(u=a.parser.defined.includes(Yn(a.sliceSerialize({start:f.end,end:a.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(x),t.exit("labelMarker"),t.exit("labelEnd"),h):l(x)}function h(x){return x===40?t.attempt(pk,y,u?y:b)(x):x===91?t.attempt(mk,y,u?p:b)(x):u?y(x):b(x)}function p(x){return t.attempt(gk,y,b)(x)}function y(x){return i(x)}function b(x){return f._balanced=!0,l(x)}}function xk(t,i,l){return a;function a(b){return t.enter("resource"),t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),o}function o(b){return Tt(b)?ba(t,f)(b):f(b)}function f(b){return b===41?y(b):Wb(t,u,m,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function u(b){return Tt(b)?ba(t,h)(b):y(b)}function m(b){return l(b)}function h(b){return b===34||b===39||b===40?tv(t,p,l,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):y(b)}function p(b){return Tt(b)?ba(t,y)(b):y(b)}function y(b){return b===41?(t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),t.exit("resource"),i):l(b)}}function Sk(t,i,l){const a=this;return o;function o(m){return ev.call(a,t,f,u,"reference","referenceMarker","referenceString")(m)}function f(m){return a.parser.defined.includes(Yn(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?i(m):l(m)}function u(m){return l(m)}}function wk(t,i,l){return a;function a(f){return t.enter("reference"),t.enter("referenceMarker"),t.consume(f),t.exit("referenceMarker"),o}function o(f){return f===93?(t.enter("referenceMarker"),t.consume(f),t.exit("referenceMarker"),t.exit("reference"),i):l(f)}}const jk={name:"labelStartImage",resolveAll:pd.resolveAll,tokenize:kk};function kk(t,i,l){const a=this;return o;function o(m){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(m),t.exit("labelImageMarker"),f}function f(m){return m===91?(t.enter("labelMarker"),t.consume(m),t.exit("labelMarker"),t.exit("labelImage"),u):l(m)}function u(m){return m===94&&"_hiddenFootnoteSupport"in a.parser.constructs?l(m):i(m)}}const Ek={name:"labelStartLink",resolveAll:pd.resolveAll,tokenize:Ck};function Ck(t,i,l){const a=this;return o;function o(u){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(u),t.exit("labelMarker"),t.exit("labelLink"),f}function f(u){return u===94&&"_hiddenFootnoteSupport"in a.parser.constructs?l(u):i(u)}}const yf={name:"lineEnding",tokenize:Nk};function Nk(t,i){return l;function l(a){return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),ot(t,i,"linePrefix")}}const to={name:"thematicBreak",tokenize:Ak};function Ak(t,i,l){let a=0,o;return f;function f(p){return t.enter("thematicBreak"),u(p)}function u(p){return o=p,m(p)}function m(p){return p===o?(t.enter("thematicBreakSequence"),h(p)):a>=3&&(p===null||Ue(p))?(t.exit("thematicBreak"),i(p)):l(p)}function h(p){return p===o?(t.consume(p),a++,h):(t.exit("thematicBreakSequence"),et(p)?ot(t,m,"whitespace")(p):m(p))}}const mn={continuation:{tokenize:Dk},exit:Mk,name:"list",tokenize:zk},Tk={partial:!0,tokenize:Ok},Rk={partial:!0,tokenize:_k};function zk(t,i,l){const a=this,o=a.events[a.events.length-1];let f=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,u=0;return m;function m(v){const j=a.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!a.containerState.marker||v===a.containerState.marker:If(v)){if(a.containerState.type||(a.containerState.type=j,t.enter(j,{_container:!0})),j==="listUnordered")return t.enter("listItemPrefix"),v===42||v===45?t.check(to,l,p)(v):p(v);if(!a.interrupt||v===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),h(v)}return l(v)}function h(v){return If(v)&&++u<10?(t.consume(v),h):(!a.interrupt||u<2)&&(a.containerState.marker?v===a.containerState.marker:v===41||v===46)?(t.exit("listItemValue"),p(v)):l(v)}function p(v){return t.enter("listItemMarker"),t.consume(v),t.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||v,t.check(Na,a.interrupt?l:y,t.attempt(Tk,x,b))}function y(v){return a.containerState.initialBlankLine=!0,f++,x(v)}function b(v){return et(v)?(t.enter("listItemPrefixWhitespace"),t.consume(v),t.exit("listItemPrefixWhitespace"),x):l(v)}function x(v){return a.containerState.size=f+a.sliceSerialize(t.exit("listItemPrefix"),!0).length,i(v)}}function Dk(t,i,l){const a=this;return a.containerState._closeFlow=void 0,t.check(Na,o,f);function o(m){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,ot(t,i,"listItemIndent",a.containerState.size+1)(m)}function f(m){return a.containerState.furtherBlankLines||!et(m)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,u(m)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,t.attempt(Rk,i,u)(m))}function u(m){return a.containerState._closeFlow=!0,a.interrupt=void 0,ot(t,t.attempt(mn,i,l),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m)}}function _k(t,i,l){const a=this;return ot(t,o,"listItemIndent",a.containerState.size+1);function o(f){const u=a.events[a.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===a.containerState.size?i(f):l(f)}}function Mk(t){t.exit(this.containerState.type)}function Ok(t,i,l){const a=this;return ot(t,o,"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(f){const u=a.events[a.events.length-1];return!et(f)&&u&&u[1].type==="listItemPrefixWhitespace"?i(f):l(f)}}const _y={name:"setextUnderline",resolveTo:Lk,tokenize:Bk};function Lk(t,i){let l=t.length,a,o,f;for(;l--;)if(t[l][0]==="enter"){if(t[l][1].type==="content"){a=l;break}t[l][1].type==="paragraph"&&(o=l)}else t[l][1].type==="content"&&t.splice(l,1),!f&&t[l][1].type==="definition"&&(f=l);const u={type:"setextHeading",start:{...t[a][1].start},end:{...t[t.length-1][1].end}};return t[o][1].type="setextHeadingText",f?(t.splice(o,0,["enter",u,i]),t.splice(f+1,0,["exit",t[a][1],i]),t[a][1].end={...t[f][1].end}):t[a][1]=u,t.push(["exit",u,i]),t}function Bk(t,i,l){const a=this;let o;return f;function f(p){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"),o=p,u(p)):l(p)}function u(p){return t.enter("setextHeadingLineSequence"),m(p)}function m(p){return p===o?(t.consume(p),m):(t.exit("setextHeadingLineSequence"),et(p)?ot(t,h,"lineSuffix")(p):h(p))}function h(p){return p===null||Ue(p)?(t.exit("setextHeadingLine"),i(p)):l(p)}}const Uk={tokenize:Ik};function Ik(t){const i=this,l=t.attempt(Na,a,t.attempt(this.parser.constructs.flowInitial,o,ot(t,t.attempt(this.parser.constructs.flow,o,t.attempt(Gj,o)),"linePrefix")));return l;function a(f){if(f===null){t.consume(f);return}return t.enter("lineEndingBlank"),t.consume(f),t.exit("lineEndingBlank"),i.currentConstruct=void 0,l}function o(f){if(f===null){t.consume(f);return}return t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),i.currentConstruct=void 0,l}}const qk={resolveAll:iv()},Hk=nv("string"),Vk=nv("text");function nv(t){return{resolveAll:iv(t==="text"?Yk:void 0),tokenize:i};function i(l){const a=this,o=this.parser.constructs[t],f=l.attempt(o,u,m);return u;function u(y){return p(y)?f(y):m(y)}function m(y){if(y===null){l.consume(y);return}return l.enter("data"),l.consume(y),h}function h(y){return p(y)?(l.exit("data"),f(y)):(l.consume(y),h)}function p(y){if(y===null)return!0;const b=o[y];let x=-1;if(b)for(;++x<b.length;){const v=b[x];if(!v.previous||v.previous.call(a,a.previous))return!0}return!1}}}function iv(t){return i;function i(l,a){let o=-1,f;for(;++o<=l.length;)f===void 0?l[o]&&l[o][1].type==="data"&&(f=o,o++):(!l[o]||l[o][1].type!=="data")&&(o!==f+2&&(l[f][1].end=l[o-1][1].end,l.splice(f+2,o-f-2),o=f+2),f=void 0);return t?t(l,a):l}}function Yk(t,i){let l=0;for(;++l<=t.length;)if((l===t.length||t[l][1].type==="lineEnding")&&t[l-1][1].type==="data"){const a=t[l-1][1],o=i.sliceStream(a);let f=o.length,u=-1,m=0,h;for(;f--;){const p=o[f];if(typeof p=="string"){for(u=p.length;p.charCodeAt(u-1)===32;)m++,u--;if(u)break;u=-1}else if(p===-2)h=!0,m++;else if(p!==-1){f++;break}}if(i._contentTypeTextTrailing&&l===t.length&&(m=0),m){const p={type:l===t.length||h||m<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:f?u:a.start._bufferIndex+u,_index:a.start._index+f,line:a.end.line,column:a.end.column-m,offset:a.end.offset-m},end:{...a.end}};a.end={...p.start},a.start.offset===a.end.offset?Object.assign(a,p):(t.splice(l,0,["enter",p,i],["exit",p,i]),l+=2)}l++}return t}const Gk={42:mn,43:mn,45:mn,48:mn,49:mn,50:mn,51:mn,52:mn,53:mn,54:mn,55:mn,56:mn,57:mn,62:Kb},Fk={91:Kj},Qk={[-2]:gf,[-1]:gf,32:gf},$k={35:tk,42:to,45:[_y,to],60:lk,61:_y,95:to,96:zy,126:zy},Xk={38:Zb,92:Pb},Kk={[-5]:yf,[-4]:yf,[-3]:yf,33:jk,38:Zb,42:qf,60:[Ej,dk],91:Ek,92:[Wj,Pb],93:pd,95:qf,96:Uj},Pk={null:[qf,qk]},Zk={null:[42,95]},Jk={null:[]},Wk=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Zk,contentInitial:Fk,disable:Jk,document:Gk,flow:$k,flowInitial:Qk,insideSpan:Pk,string:Xk,text:Kk},Symbol.toStringTag,{value:"Module"}));function eE(t,i,l){let a={_bufferIndex:-1,_index:0,line:l&&l.line||1,column:l&&l.column||1,offset:l&&l.offset||0};const o={},f=[];let u=[],m=[];const h={attempt:V(re),check:V(T),consume:R,enter:O,exit:Y,interrupt:V(T,{interrupt:!0})},p={code:null,containerState:{},defineSkip:D,events:[],now:j,parser:t,previous:null,sliceSerialize:x,sliceStream:v,write:b};let y=i.tokenize.call(p,h);return i.resolveAll&&f.push(i),p;function b(B){return u=Bn(u,B),N(),u[u.length-1]!==null?[]:(Q(i,0),p.events=mo(f,p.events,p),p.events)}function x(B,U){return nE(v(B),U)}function v(B){return tE(u,B)}function j(){const{_bufferIndex:B,_index:U,line:$,column:ee,offset:K}=a;return{_bufferIndex:B,_index:U,line:$,column:ee,offset:K}}function D(B){o[B.line]=B.column,C()}function N(){let B;for(;a._index<u.length;){const U=u[a._index];if(typeof U=="string")for(B=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===B&&a._bufferIndex<U.length;)A(U.charCodeAt(a._bufferIndex));else A(U)}}function A(B){y=y(B)}function R(B){Ue(B)?(a.line++,a.column=1,a.offset+=B===-3?2:1,C()):B!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===u[a._index].length&&(a._bufferIndex=-1,a._index++)),p.previous=B}function O(B,U){const $=U||{};return $.type=B,$.start=j(),p.events.push(["enter",$,p]),m.push($),$}function Y(B){const U=m.pop();return U.end=j(),p.events.push(["exit",U,p]),U}function re(B,U){Q(B,U.from)}function T(B,U){U.restore()}function V(B,U){return $;function $(ee,K,z){let Z,he,me,k;return Array.isArray(ee)?J(ee):"tokenize"in ee?J([ee]):L(ee);function L(ae){return se;function se(ye){const F=ye!==null&&ae[ye],we=ye!==null&&ae.null,Le=[...Array.isArray(F)?F:F?[F]:[],...Array.isArray(we)?we:we?[we]:[]];return J(Le)(ye)}}function J(ae){return Z=ae,he=0,ae.length===0?z:_(ae[he])}function _(ae){return se;function se(ye){return k=I(),me=ae,ae.partial||(p.currentConstruct=ae),ae.name&&p.parser.constructs.disable.null.includes(ae.name)?xe():ae.tokenize.call(U?Object.assign(Object.create(p),U):p,h,te,xe)(ye)}}function te(ae){return B(me,k),K}function xe(ae){return k.restore(),++he<Z.length?_(Z[he]):z}}}function Q(B,U){B.resolveAll&&!f.includes(B)&&f.push(B),B.resolve&&En(p.events,U,p.events.length-U,B.resolve(p.events.slice(U),p)),B.resolveTo&&(p.events=B.resolveTo(p.events,p))}function I(){const B=j(),U=p.previous,$=p.currentConstruct,ee=p.events.length,K=Array.from(m);return{from:ee,restore:z};function z(){a=B,p.previous=U,p.currentConstruct=$,p.events.length=ee,m=K,C()}}function C(){a.line in o&&a.column<2&&(a.column=o[a.line],a.offset+=o[a.line]-1)}}function tE(t,i){const l=i.start._index,a=i.start._bufferIndex,o=i.end._index,f=i.end._bufferIndex;let u;if(l===o)u=[t[l].slice(a,f)];else{if(u=t.slice(l,o),a>-1){const m=u[0];typeof m=="string"?u[0]=m.slice(a):u.shift()}f>0&&u.push(t[o].slice(0,f))}return u}function nE(t,i){let l=-1;const a=[];let o;for(;++l<t.length;){const f=t[l];let u;if(typeof f=="string")u=f;else switch(f){case-5:{u="\r";break}case-4:{u=`
|
|
30
|
-
`;break}case-3:{u=`\r
|
|
31
|
-
`;break}case-2:{u=i?" ":" ";break}case-1:{if(!i&&o)continue;u=" ";break}default:u=String.fromCharCode(f)}o=f===-2,a.push(u)}return a.join("")}function iE(t){const a={constructs:$b([Wk,...(t||{}).extensions||[]]),content:o(bj),defined:[],document:o(xj),flow:o(Uk),lazy:{},string:o(Hk),text:o(Vk)};return a;function o(f){return u;function u(m){return eE(a,f,m)}}}function rE(t){for(;!Jb(t););return t}const My=/[\0\t\n\r]/g;function lE(){let t=1,i="",l=!0,a;return o;function o(f,u,m){const h=[];let p,y,b,x,v;for(f=i+(typeof f=="string"?f.toString():new TextDecoder(u||void 0).decode(f)),b=0,i="",l&&(f.charCodeAt(0)===65279&&b++,l=void 0);b<f.length;){if(My.lastIndex=b,p=My.exec(f),x=p&&p.index!==void 0?p.index:f.length,v=f.charCodeAt(x),!p){i=f.slice(b);break}if(v===10&&b===x&&a)h.push(-3),a=void 0;else switch(a&&(h.push(-5),a=void 0),b<x&&(h.push(f.slice(b,x)),t+=x-b),v){case 0:{h.push(65533),t++;break}case 9:{for(y=Math.ceil(t/4)*4,h.push(-2);t++<y;)h.push(-1);break}case 10:{h.push(-4),t=1;break}default:a=!0,t=1}b=x+1}return m&&(a&&h.push(-5),i&&h.push(i),h.push(null)),h}}const aE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function sE(t){return t.replace(aE,oE)}function oE(t,i,l){if(i)return i;if(l.charCodeAt(0)===35){const o=l.charCodeAt(1),f=o===120||o===88;return Xb(l.slice(f?2:1),f?16:10)}return hd(l)||t}const rv={}.hasOwnProperty;function uE(t,i,l){return i&&typeof i=="object"&&(l=i,i=void 0),cE(l)(rE(iE(l).document().write(lE()(t,i,!0))))}function cE(t){const i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:f(qe),autolinkProtocol:I,autolinkEmail:I,atxHeading:f(ut),blockQuote:f(we),characterEscape:I,characterReference:I,codeFenced:f(Le),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:f(Le,u),codeText:f(Ae,u),codeTextData:I,data:I,codeFlowValue:I,definition:f(Te),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:f(tt),hardBreakEscape:f(Ge),hardBreakTrailing:f(Ge),htmlFlow:f(Lt,u),htmlFlowData:I,htmlText:f(Lt,u),htmlTextData:I,image:f(ct),label:u,link:f(qe),listItem:f(Fe),listItemValue:x,listOrdered:f(ht,b),listUnordered:f(ht),paragraph:f(nt),reference:_,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:f(ut),strong:f(Et),thematicBreak:f(bt)},exit:{atxHeading:h(),atxHeadingSequence:re,autolink:h(),autolinkEmail:F,autolinkProtocol:ye,blockQuote:h(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:xe,characterReferenceMarkerNumeric:xe,characterReferenceValue:ae,characterReference:se,codeFenced:h(N),codeFencedFence:D,codeFencedFenceInfo:v,codeFencedFenceMeta:j,codeFlowValue:C,codeIndented:h(A),codeText:h(K),codeTextData:C,data:C,definition:h(),definitionDestinationString:Y,definitionLabelString:R,definitionTitleString:O,emphasis:h(),hardBreakEscape:h(U),hardBreakTrailing:h(U),htmlFlow:h($),htmlFlowData:C,htmlText:h(ee),htmlTextData:C,image:h(Z),label:me,labelText:he,lineEnding:B,link:h(z),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:te,resourceDestinationString:k,resourceTitleString:L,resource:J,setextHeading:h(Q),setextHeadingLineSequence:V,setextHeadingText:T,strong:h(),thematicBreak:h()}};lv(i,(t||{}).mdastExtensions||[]);const l={};return a;function a(M){let P={type:"root",children:[]};const ge={stack:[P],tokenStack:[],config:i,enter:m,exit:p,buffer:u,resume:y,data:l},Se=[];let Ce=-1;for(;++Ce<M.length;)if(M[Ce][1].type==="listOrdered"||M[Ce][1].type==="listUnordered")if(M[Ce][0]==="enter")Se.push(Ce);else{const Re=Se.pop();Ce=o(M,Re,Ce)}for(Ce=-1;++Ce<M.length;){const Re=i[M[Ce][0]];rv.call(Re,M[Ce][1].type)&&Re[M[Ce][1].type].call(Object.assign({sliceSerialize:M[Ce][2].sliceSerialize},ge),M[Ce][1])}if(ge.tokenStack.length>0){const Re=ge.tokenStack[ge.tokenStack.length-1];(Re[1]||Oy).call(ge,void 0,Re[0])}for(P.position={start:Qi(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Qi(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},Ce=-1;++Ce<i.transforms.length;)P=i.transforms[Ce](P)||P;return P}function o(M,P,ge){let Se=P-1,Ce=-1,Re=!1,Qe,yt,pt,mt;for(;++Se<=ge;){const Ze=M[Se];switch(Ze[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ze[0]==="enter"?Ce++:Ce--,mt=void 0;break}case"lineEndingBlank":{Ze[0]==="enter"&&(Qe&&!mt&&!Ce&&!pt&&(pt=Se),mt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:mt=void 0}if(!Ce&&Ze[0]==="enter"&&Ze[1].type==="listItemPrefix"||Ce===-1&&Ze[0]==="exit"&&(Ze[1].type==="listUnordered"||Ze[1].type==="listOrdered")){if(Qe){let oe=Se;for(yt=void 0;oe--;){const _e=M[oe];if(_e[1].type==="lineEnding"||_e[1].type==="lineEndingBlank"){if(_e[0]==="exit")continue;yt&&(M[yt][1].type="lineEndingBlank",Re=!0),_e[1].type="lineEnding",yt=oe}else if(!(_e[1].type==="linePrefix"||_e[1].type==="blockQuotePrefix"||_e[1].type==="blockQuotePrefixWhitespace"||_e[1].type==="blockQuoteMarker"||_e[1].type==="listItemIndent"))break}pt&&(!yt||pt<yt)&&(Qe._spread=!0),Qe.end=Object.assign({},yt?M[yt][1].start:Ze[1].end),M.splice(yt||Se,0,["exit",Qe,Ze[2]]),Se++,ge++}if(Ze[1].type==="listItemPrefix"){const oe={type:"listItem",_spread:!1,start:Object.assign({},Ze[1].start),end:void 0};Qe=oe,M.splice(Se,0,["enter",oe,Ze[2]]),Se++,ge++,pt=void 0,mt=!0}}}return M[P][1]._spread=Re,ge}function f(M,P){return ge;function ge(Se){m.call(this,M(Se),Se),P&&P.call(this,Se)}}function u(){this.stack.push({type:"fragment",children:[]})}function m(M,P,ge){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([P,ge||void 0]),M.position={start:Qi(P.start),end:void 0}}function h(M){return P;function P(ge){M&&M.call(this,ge),p.call(this,ge)}}function p(M,P){const ge=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==M.type&&(P?P.call(this,M,Se[0]):(Se[1]||Oy).call(this,M,Se[0]));else throw new Error("Cannot close `"+M.type+"` ("+ya({start:M.start,end:M.end})+"): it’s not open");ge.position.end=Qi(M.end)}function y(){return dd(this.stack.pop())}function b(){this.data.expectingFirstListItemValue=!0}function x(M){if(this.data.expectingFirstListItemValue){const P=this.stack[this.stack.length-2];P.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function v(){const M=this.resume(),P=this.stack[this.stack.length-1];P.lang=M}function j(){const M=this.resume(),P=this.stack[this.stack.length-1];P.meta=M}function D(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const M=this.resume(),P=this.stack[this.stack.length-1];P.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function A(){const M=this.resume(),P=this.stack[this.stack.length-1];P.value=M.replace(/(\r?\n|\r)$/g,"")}function R(M){const P=this.resume(),ge=this.stack[this.stack.length-1];ge.label=P,ge.identifier=Yn(this.sliceSerialize(M)).toLowerCase()}function O(){const M=this.resume(),P=this.stack[this.stack.length-1];P.title=M}function Y(){const M=this.resume(),P=this.stack[this.stack.length-1];P.url=M}function re(M){const P=this.stack[this.stack.length-1];if(!P.depth){const ge=this.sliceSerialize(M).length;P.depth=ge}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function V(M){const P=this.stack[this.stack.length-1];P.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function Q(){this.data.setextHeadingSlurpLineEnding=void 0}function I(M){const ge=this.stack[this.stack.length-1].children;let Se=ge[ge.length-1];(!Se||Se.type!=="text")&&(Se=lt(),Se.position={start:Qi(M.start),end:void 0},ge.push(Se)),this.stack.push(Se)}function C(M){const P=this.stack.pop();P.value+=this.sliceSerialize(M),P.position.end=Qi(M.end)}function B(M){const P=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=P.children[P.children.length-1];ge.position.end=Qi(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(P.type)&&(I.call(this,M),C.call(this,M))}function U(){this.data.atHardBreak=!0}function $(){const M=this.resume(),P=this.stack[this.stack.length-1];P.value=M}function ee(){const M=this.resume(),P=this.stack[this.stack.length-1];P.value=M}function K(){const M=this.resume(),P=this.stack[this.stack.length-1];P.value=M}function z(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const P=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=P,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function Z(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const P=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=P,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function he(M){const P=this.sliceSerialize(M),ge=this.stack[this.stack.length-2];ge.label=sE(P),ge.identifier=Yn(P).toLowerCase()}function me(){const M=this.stack[this.stack.length-1],P=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const Se=M.children;ge.children=Se}else ge.alt=P}function k(){const M=this.resume(),P=this.stack[this.stack.length-1];P.url=M}function L(){const M=this.resume(),P=this.stack[this.stack.length-1];P.title=M}function J(){this.data.inReference=void 0}function _(){this.data.referenceType="collapsed"}function te(M){const P=this.resume(),ge=this.stack[this.stack.length-1];ge.label=P,ge.identifier=Yn(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function xe(M){this.data.characterReferenceType=M.type}function ae(M){const P=this.sliceSerialize(M),ge=this.data.characterReferenceType;let Se;ge?(Se=Xb(P,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=hd(P);const Ce=this.stack[this.stack.length-1];Ce.value+=Se}function se(M){const P=this.stack.pop();P.position.end=Qi(M.end)}function ye(M){C.call(this,M);const P=this.stack[this.stack.length-1];P.url=this.sliceSerialize(M)}function F(M){C.call(this,M);const P=this.stack[this.stack.length-1];P.url="mailto:"+this.sliceSerialize(M)}function we(){return{type:"blockquote",children:[]}}function Le(){return{type:"code",lang:null,meta:null,value:""}}function Ae(){return{type:"inlineCode",value:""}}function Te(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function tt(){return{type:"emphasis",children:[]}}function ut(){return{type:"heading",depth:0,children:[]}}function Ge(){return{type:"break"}}function Lt(){return{type:"html",value:""}}function ct(){return{type:"image",title:null,url:"",alt:null}}function qe(){return{type:"link",title:null,url:"",children:[]}}function ht(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Fe(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function nt(){return{type:"paragraph",children:[]}}function Et(){return{type:"strong",children:[]}}function lt(){return{type:"text",value:""}}function bt(){return{type:"thematicBreak"}}}function Qi(t){return{line:t.line,column:t.column,offset:t.offset}}function lv(t,i){let l=-1;for(;++l<i.length;){const a=i[l];Array.isArray(a)?lv(t,a):fE(t,a)}}function fE(t,i){let l;for(l in i)if(rv.call(i,l))switch(l){case"canContainEols":{const a=i[l];a&&t[l].push(...a);break}case"transforms":{const a=i[l];a&&t[l].push(...a);break}case"enter":case"exit":{const a=i[l];a&&Object.assign(t[l],a);break}}}function Oy(t,i){throw t?new Error("Cannot close `"+t.type+"` ("+ya({start:t.start,end:t.end})+"): a different token (`"+i.type+"`, "+ya({start:i.start,end:i.end})+") is open"):new Error("Cannot close document, a token (`"+i.type+"`, "+ya({start:i.start,end:i.end})+") is still open")}function dE(t){const i=this;i.parser=l;function l(a){return uE(a,{...i.data("settings"),...t,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})}}function hE(t,i){const l={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(i),!0)};return t.patch(i,l),t.applyData(i,l)}function pE(t,i){const l={type:"element",tagName:"br",properties:{},children:[]};return t.patch(i,l),[t.applyData(i,l),{type:"text",value:`
|
|
32
|
-
`}]}function mE(t,i){const l=i.value?i.value+`
|
|
33
|
-
`:"",a={},o=i.lang?i.lang.split(/\s+/):[];o.length>0&&(a.className=["language-"+o[0]]);let f={type:"element",tagName:"code",properties:a,children:[{type:"text",value:l}]};return i.meta&&(f.data={meta:i.meta}),t.patch(i,f),f=t.applyData(i,f),f={type:"element",tagName:"pre",properties:{},children:[f]},t.patch(i,f),f}function gE(t,i){const l={type:"element",tagName:"del",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function yE(t,i){const l={type:"element",tagName:"em",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function bE(t,i){const l=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",a=String(i.identifier).toUpperCase(),o=ml(a.toLowerCase()),f=t.footnoteOrder.indexOf(a);let u,m=t.footnoteCounts.get(a);m===void 0?(m=0,t.footnoteOrder.push(a),u=t.footnoteOrder.length):u=f+1,m+=1,t.footnoteCounts.set(a,m);const h={type:"element",tagName:"a",properties:{href:"#"+l+"fn-"+o,id:l+"fnref-"+o+(m>1?"-"+m:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};t.patch(i,h);const p={type:"element",tagName:"sup",properties:{},children:[h]};return t.patch(i,p),t.applyData(i,p)}function vE(t,i){const l={type:"element",tagName:"h"+i.depth,properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function xE(t,i){if(t.options.allowDangerousHtml){const l={type:"raw",value:i.value};return t.patch(i,l),t.applyData(i,l)}}function av(t,i){const l=i.referenceType;let a="]";if(l==="collapsed"?a+="[]":l==="full"&&(a+="["+(i.label||i.identifier)+"]"),i.type==="imageReference")return[{type:"text",value:"!["+i.alt+a}];const o=t.all(i),f=o[0];f&&f.type==="text"?f.value="["+f.value:o.unshift({type:"text",value:"["});const u=o[o.length-1];return u&&u.type==="text"?u.value+=a:o.push({type:"text",value:a}),o}function SE(t,i){const l=String(i.identifier).toUpperCase(),a=t.definitionById.get(l);if(!a)return av(t,i);const o={src:ml(a.url||""),alt:i.alt};a.title!==null&&a.title!==void 0&&(o.title=a.title);const f={type:"element",tagName:"img",properties:o,children:[]};return t.patch(i,f),t.applyData(i,f)}function wE(t,i){const l={src:ml(i.url)};i.alt!==null&&i.alt!==void 0&&(l.alt=i.alt),i.title!==null&&i.title!==void 0&&(l.title=i.title);const a={type:"element",tagName:"img",properties:l,children:[]};return t.patch(i,a),t.applyData(i,a)}function jE(t,i){const l={type:"text",value:i.value.replace(/\r?\n|\r/g," ")};t.patch(i,l);const a={type:"element",tagName:"code",properties:{},children:[l]};return t.patch(i,a),t.applyData(i,a)}function kE(t,i){const l=String(i.identifier).toUpperCase(),a=t.definitionById.get(l);if(!a)return av(t,i);const o={href:ml(a.url||"")};a.title!==null&&a.title!==void 0&&(o.title=a.title);const f={type:"element",tagName:"a",properties:o,children:t.all(i)};return t.patch(i,f),t.applyData(i,f)}function EE(t,i){const l={href:ml(i.url)};i.title!==null&&i.title!==void 0&&(l.title=i.title);const a={type:"element",tagName:"a",properties:l,children:t.all(i)};return t.patch(i,a),t.applyData(i,a)}function CE(t,i,l){const a=t.all(i),o=l?NE(l):sv(i),f={},u=[];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:[]}),f.className=["task-list-item"]}let m=-1;for(;++m<a.length;){const y=a[m];(o||m!==0||y.type!=="element"||y.tagName!=="p")&&u.push({type:"text",value:`
|
|
34
|
-
`}),y.type==="element"&&y.tagName==="p"&&!o?u.push(...y.children):u.push(y)}const h=a[a.length-1];h&&(o||h.type!=="element"||h.tagName!=="p")&&u.push({type:"text",value:`
|
|
35
|
-
`});const p={type:"element",tagName:"li",properties:f,children:u};return t.patch(i,p),t.applyData(i,p)}function NE(t){let i=!1;if(t.type==="list"){i=t.spread||!1;const l=t.children;let a=-1;for(;!i&&++a<l.length;)i=sv(l[a])}return i}function sv(t){const i=t.spread;return i??t.children.length>1}function AE(t,i){const l={},a=t.all(i);let o=-1;for(typeof i.start=="number"&&i.start!==1&&(l.start=i.start);++o<a.length;){const u=a[o];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){l.className=["contains-task-list"];break}}const f={type:"element",tagName:i.ordered?"ol":"ul",properties:l,children:t.wrap(a,!0)};return t.patch(i,f),t.applyData(i,f)}function TE(t,i){const l={type:"element",tagName:"p",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function RE(t,i){const l={type:"root",children:t.wrap(t.all(i))};return t.patch(i,l),t.applyData(i,l)}function zE(t,i){const l={type:"element",tagName:"strong",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function DE(t,i){const l=t.all(i),a=l.shift(),o=[];if(a){const u={type:"element",tagName:"thead",properties:{},children:t.wrap([a],!0)};t.patch(i.children[0],u),o.push(u)}if(l.length>0){const u={type:"element",tagName:"tbody",properties:{},children:t.wrap(l,!0)},m=od(i.children[1]),h=qb(i.children[i.children.length-1]);m&&h&&(u.position={start:m,end:h}),o.push(u)}const f={type:"element",tagName:"table",properties:{},children:t.wrap(o,!0)};return t.patch(i,f),t.applyData(i,f)}function _E(t,i,l){const a=l?l.children:void 0,f=(a?a.indexOf(i):1)===0?"th":"td",u=l&&l.type==="table"?l.align:void 0,m=u?u.length:i.children.length;let h=-1;const p=[];for(;++h<m;){const b=i.children[h],x={},v=u?u[h]:void 0;v&&(x.align=v);let j={type:"element",tagName:f,properties:x,children:[]};b&&(j.children=t.all(b),t.patch(b,j),j=t.applyData(b,j)),p.push(j)}const y={type:"element",tagName:"tr",properties:{},children:t.wrap(p,!0)};return t.patch(i,y),t.applyData(i,y)}function ME(t,i){const l={type:"element",tagName:"td",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}const Ly=9,By=32;function OE(t){const i=String(t),l=/\r?\n|\r/g;let a=l.exec(i),o=0;const f=[];for(;a;)f.push(Uy(i.slice(o,a.index),o>0,!0),a[0]),o=a.index+a[0].length,a=l.exec(i);return f.push(Uy(i.slice(o),o>0,!1)),f.join("")}function Uy(t,i,l){let a=0,o=t.length;if(i){let f=t.codePointAt(a);for(;f===Ly||f===By;)a++,f=t.codePointAt(a)}if(l){let f=t.codePointAt(o-1);for(;f===Ly||f===By;)o--,f=t.codePointAt(o-1)}return o>a?t.slice(a,o):""}function LE(t,i){const l={type:"text",value:OE(String(i.value))};return t.patch(i,l),t.applyData(i,l)}function BE(t,i){const l={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(i,l),t.applyData(i,l)}const UE={blockquote:hE,break:pE,code:mE,delete:gE,emphasis:yE,footnoteReference:bE,heading:vE,html:xE,imageReference:SE,image:wE,inlineCode:jE,linkReference:kE,link:EE,listItem:CE,list:AE,paragraph:TE,root:RE,strong:zE,table:DE,tableCell:ME,tableRow:_E,text:LE,thematicBreak:BE,toml:Ks,yaml:Ks,definition:Ks,footnoteDefinition:Ks};function Ks(){}const ov=-1,go=0,va=1,so=2,md=3,gd=4,yd=5,bd=6,uv=7,cv=8,IE=typeof self=="object"?self:globalThis,Iy=(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 IE[t](i)},qE=(t,i)=>{const l=(o,f)=>(t.set(f,o),o),a=o=>{if(t.has(o))return t.get(o);const[f,u]=i[o];switch(f){case go:case ov:return l(u,o);case va:{const m=l([],o);for(const h of u)m.push(a(h));return m}case so:{const m=l({},o);for(const[h,p]of u)m[a(h)]=a(p);return m}case md:return l(new Date(u),o);case gd:{const{source:m,flags:h}=u;return l(new RegExp(m,h),o)}case yd:{const m=l(new Map,o);for(const[h,p]of u)m.set(a(h),a(p));return m}case bd:{const m=l(new Set,o);for(const h of u)m.add(a(h));return m}case uv:{const{name:m,message:h}=u;return l(Iy(m,h),o)}case cv:return l(BigInt(u),o);case"BigInt":return l(Object(BigInt(u)),o);case"ArrayBuffer":return l(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:m}=new Uint8Array(u);return l(new DataView(m),u)}}return l(Iy(f,u),o)};return a},qy=t=>qE(new Map,t)(0),ul="",{toString:HE}={},{keys:VE}=Object,pa=t=>{const i=typeof t;if(i!=="object"||!t)return[go,i];const l=HE.call(t).slice(8,-1);switch(l){case"Array":return[va,ul];case"Object":return[so,ul];case"Date":return[md,ul];case"RegExp":return[gd,ul];case"Map":return[yd,ul];case"Set":return[bd,ul];case"DataView":return[va,l]}return l.includes("Array")?[va,l]:l.includes("Error")?[uv,l]:[so,l]},Ps=([t,i])=>t===go&&(i==="function"||i==="symbol"),YE=(t,i,l,a)=>{const o=(u,m)=>{const h=a.push(u)-1;return l.set(m,h),h},f=u=>{if(l.has(u))return l.get(u);let[m,h]=pa(u);switch(m){case go:{let y=u;switch(h){case"bigint":m=cv,y=u.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+h);y=null;break;case"undefined":return o([ov],u)}return o([m,y],u)}case va:{if(h){let x=u;return h==="DataView"?x=new Uint8Array(u.buffer):h==="ArrayBuffer"&&(x=new Uint8Array(u)),o([h,[...x]],u)}const y=[],b=o([m,y],u);for(const x of u)y.push(f(x));return b}case so:{if(h)switch(h){case"BigInt":return o([h,u.toString()],u);case"Boolean":case"Number":case"String":return o([h,u.valueOf()],u)}if(i&&"toJSON"in u)return f(u.toJSON());const y=[],b=o([m,y],u);for(const x of VE(u))(t||!Ps(pa(u[x])))&&y.push([f(x),f(u[x])]);return b}case md:return o([m,u.toISOString()],u);case gd:{const{source:y,flags:b}=u;return o([m,{source:y,flags:b}],u)}case yd:{const y=[],b=o([m,y],u);for(const[x,v]of u)(t||!(Ps(pa(x))||Ps(pa(v))))&&y.push([f(x),f(v)]);return b}case bd:{const y=[],b=o([m,y],u);for(const x of u)(t||!Ps(pa(x)))&&y.push(f(x));return b}}const{message:p}=u;return o([m,{name:h,message:p}],u)};return f},Hy=(t,{json:i,lossy:l}={})=>{const a=[];return YE(!(i||l),!!i,new Map,a)(t),a},oo=typeof structuredClone=="function"?(t,i)=>i&&("json"in i||"lossy"in i)?qy(Hy(t,i)):structuredClone(t):(t,i)=>qy(Hy(t,i));function GE(t,i){const l=[{type:"text",value:"↩"}];return i>1&&l.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(i)}]}),l}function FE(t,i){return"Back to reference "+(t+1)+(i>1?"-"+i:"")}function QE(t){const i=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",l=t.options.footnoteBackContent||GE,a=t.options.footnoteBackLabel||FE,o=t.options.footnoteLabel||"Footnotes",f=t.options.footnoteLabelTagName||"h2",u=t.options.footnoteLabelProperties||{className:["sr-only"]},m=[];let h=-1;for(;++h<t.footnoteOrder.length;){const p=t.footnoteById.get(t.footnoteOrder[h]);if(!p)continue;const y=t.all(p),b=String(p.identifier).toUpperCase(),x=ml(b.toLowerCase());let v=0;const j=[],D=t.footnoteCounts.get(b);for(;D!==void 0&&++v<=D;){j.length>0&&j.push({type:"text",value:" "});let R=typeof l=="string"?l:l(h,v);typeof R=="string"&&(R={type:"text",value:R}),j.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+x+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof a=="string"?a:a(h,v),className:["data-footnote-backref"]},children:Array.isArray(R)?R:[R]})}const N=y[y.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const R=N.children[N.children.length-1];R&&R.type==="text"?R.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...j)}else y.push(...j);const A={type:"element",tagName:"li",properties:{id:i+"fn-"+x},children:t.wrap(y,!0)};t.patch(p,A),m.push(A)}if(m.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:f,properties:{...oo(u),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
36
|
-
`},{type:"element",tagName:"ol",properties:{},children:t.wrap(m,!0)},{type:"text",value:`
|
|
37
|
-
`}]}}const yo=(function(t){if(t==null)return PE;if(typeof t=="function")return bo(t);if(typeof t=="object")return Array.isArray(t)?$E(t):XE(t);if(typeof t=="string")return KE(t);throw new Error("Expected function, string, or object as test")});function $E(t){const i=[];let l=-1;for(;++l<t.length;)i[l]=yo(t[l]);return bo(a);function a(...o){let f=-1;for(;++f<i.length;)if(i[f].apply(this,o))return!0;return!1}}function XE(t){const i=t;return bo(l);function l(a){const o=a;let f;for(f in t)if(o[f]!==i[f])return!1;return!0}}function KE(t){return bo(i);function i(l){return l&&l.type===t}}function bo(t){return i;function i(l,a,o){return!!(ZE(l)&&t.call(this,l,typeof a=="number"?a:void 0,o||void 0))}}function PE(){return!0}function ZE(t){return t!==null&&typeof t=="object"&&"type"in t}const fv=[],JE=!0,Hf=!1,WE="skip";function dv(t,i,l,a){let o;typeof i=="function"&&typeof l!="function"?(a=l,l=i):o=i;const f=yo(o),u=a?-1:1;m(t,void 0,[])();function m(h,p,y){const b=h&&typeof h=="object"?h:{};if(typeof b.type=="string"){const v=typeof b.tagName=="string"?b.tagName:typeof b.name=="string"?b.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(h.type+(v?"<"+v+">":""))+")"})}return x;function x(){let v=fv,j,D,N;if((!i||f(h,p,y[y.length-1]||void 0))&&(v=eC(l(h,y)),v[0]===Hf))return v;if("children"in h&&h.children){const A=h;if(A.children&&v[0]!==WE)for(D=(a?A.children.length:-1)+u,N=y.concat(A);D>-1&&D<A.children.length;){const R=A.children[D];if(j=m(R,D,N)(),j[0]===Hf)return j;D=typeof j[1]=="number"?j[1]:D+u}}return v}}}function eC(t){return Array.isArray(t)?t:typeof t=="number"?[JE,t]:t==null?fv:[t]}function vd(t,i,l,a){let o,f,u;typeof i=="function"&&typeof l!="function"?(f=void 0,u=i,o=l):(f=i,u=l,o=a),dv(t,f,m,o);function m(h,p){const y=p[p.length-1],b=y?y.children.indexOf(h):void 0;return u(h,b,y)}}const Vf={}.hasOwnProperty,tC={};function nC(t,i){const l=i||tC,a=new Map,o=new Map,f=new Map,u={...UE,...l.handlers},m={all:p,applyData:rC,definitionById:a,footnoteById:o,footnoteCounts:f,footnoteOrder:[],handlers:u,one:h,options:l,patch:iC,wrap:aC};return vd(t,function(y){if(y.type==="definition"||y.type==="footnoteDefinition"){const b=y.type==="definition"?a:o,x=String(y.identifier).toUpperCase();b.has(x)||b.set(x,y)}}),m;function h(y,b){const x=y.type,v=m.handlers[x];if(Vf.call(m.handlers,x)&&v)return v(m,y,b);if(m.options.passThrough&&m.options.passThrough.includes(x)){if("children"in y){const{children:D,...N}=y,A=oo(N);return A.children=m.all(y),A}return oo(y)}return(m.options.unknownHandler||lC)(m,y,b)}function p(y){const b=[];if("children"in y){const x=y.children;let v=-1;for(;++v<x.length;){const j=m.one(x[v],y);if(j){if(v&&x[v-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=Vy(j.value)),!Array.isArray(j)&&j.type==="element")){const D=j.children[0];D&&D.type==="text"&&(D.value=Vy(D.value))}Array.isArray(j)?b.push(...j):b.push(j)}}}return b}}function iC(t,i){t.position&&(i.position=Gw(t))}function rC(t,i){let l=i;if(t&&t.data){const a=t.data.hName,o=t.data.hChildren,f=t.data.hProperties;if(typeof a=="string")if(l.type==="element")l.tagName=a;else{const u="children"in l?l.children:[l];l={type:"element",tagName:a,properties:{},children:u}}l.type==="element"&&f&&Object.assign(l.properties,oo(f)),"children"in l&&l.children&&o!==null&&o!==void 0&&(l.children=o)}return l}function lC(t,i){const l=i.data||{},a="value"in i&&!(Vf.call(l,"hProperties")||Vf.call(l,"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 aC(t,i){const l=[];let a=-1;for(i&&l.push({type:"text",value:`
|
|
38
|
-
`});++a<t.length;)a&&l.push({type:"text",value:`
|
|
39
|
-
`}),l.push(t[a]);return i&&t.length>0&&l.push({type:"text",value:`
|
|
40
|
-
`}),l}function Vy(t){let i=0,l=t.charCodeAt(i);for(;l===9||l===32;)i++,l=t.charCodeAt(i);return t.slice(i)}function Yy(t,i){const l=nC(t,i),a=l.one(t,void 0),o=QE(l),f=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return o&&f.children.push({type:"text",value:`
|
|
41
|
-
`},o),f}function sC(t,i){return t&&"run"in t?async function(l,a){const o=Yy(l,{file:a,...i});await t.run(o,a)}:function(l,a){return Yy(l,{file:a,...t||i})}}function Gy(t){if(t)throw t}var bf,Fy;function oC(){if(Fy)return bf;Fy=1;var t=Object.prototype.hasOwnProperty,i=Object.prototype.toString,l=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(p){return typeof Array.isArray=="function"?Array.isArray(p):i.call(p)==="[object Array]"},f=function(p){if(!p||i.call(p)!=="[object Object]")return!1;var y=t.call(p,"constructor"),b=p.constructor&&p.constructor.prototype&&t.call(p.constructor.prototype,"isPrototypeOf");if(p.constructor&&!y&&!b)return!1;var x;for(x in p);return typeof x>"u"||t.call(p,x)},u=function(p,y){l&&y.name==="__proto__"?l(p,y.name,{enumerable:!0,configurable:!0,value:y.newValue,writable:!0}):p[y.name]=y.newValue},m=function(p,y){if(y==="__proto__")if(t.call(p,y)){if(a)return a(p,y).value}else return;return p[y]};return bf=function h(){var p,y,b,x,v,j,D=arguments[0],N=1,A=arguments.length,R=!1;for(typeof D=="boolean"&&(R=D,D=arguments[1]||{},N=2),(D==null||typeof D!="object"&&typeof D!="function")&&(D={});N<A;++N)if(p=arguments[N],p!=null)for(y in p)b=m(D,y),x=m(p,y),D!==x&&(R&&x&&(f(x)||(v=o(x)))?(v?(v=!1,j=b&&o(b)?b:[]):j=b&&f(b)?b:{},u(D,{name:y,newValue:h(R,j,x)})):typeof x<"u"&&u(D,{name:y,newValue:x}));return D},bf}var uC=oC();const vf=co(uC);function Yf(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 cC(){const t=[],i={run:l,use:a};return i;function l(...o){let f=-1;const u=o.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);m(null,...o);function m(h,...p){const y=t[++f];let b=-1;if(h){u(h);return}for(;++b<o.length;)(p[b]===null||p[b]===void 0)&&(p[b]=o[b]);o=p,y?fC(y,m)(...p):u(null,...p)}}function a(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return t.push(o),i}}function fC(t,i){let l;return a;function a(...u){const m=t.length>u.length;let h;m&&u.push(o);try{h=t.apply(this,u)}catch(p){const y=p;if(m&&l)throw y;return o(y)}m||(h&&h.then&&typeof h.then=="function"?h.then(f,o):h instanceof Error?o(h):f(h))}function o(u,...m){l||(l=!0,i(u,...m))}function f(u){o(null,u)}}const Zn={basename:dC,dirname:hC,extname:pC,join:mC,sep:"/"};function dC(t,i){if(i!==void 0&&typeof i!="string")throw new TypeError('"ext" argument must be a string');Aa(t);let l=0,a=-1,o=t.length,f;if(i===void 0||i.length===0||i.length>t.length){for(;o--;)if(t.codePointAt(o)===47){if(f){l=o+1;break}}else a<0&&(f=!0,a=o+1);return a<0?"":t.slice(l,a)}if(i===t)return"";let u=-1,m=i.length-1;for(;o--;)if(t.codePointAt(o)===47){if(f){l=o+1;break}}else u<0&&(f=!0,u=o+1),m>-1&&(t.codePointAt(o)===i.codePointAt(m--)?m<0&&(a=o):(m=-1,a=u));return l===a?a=u:a<0&&(a=t.length),t.slice(l,a)}function hC(t){if(Aa(t),t.length===0)return".";let i=-1,l=t.length,a;for(;--l;)if(t.codePointAt(l)===47){if(a){i=l;break}}else a||(a=!0);return i<0?t.codePointAt(0)===47?"/":".":i===1&&t.codePointAt(0)===47?"//":t.slice(0,i)}function pC(t){Aa(t);let i=t.length,l=-1,a=0,o=-1,f=0,u;for(;i--;){const m=t.codePointAt(i);if(m===47){if(u){a=i+1;break}continue}l<0&&(u=!0,l=i+1),m===46?o<0?o=i:f!==1&&(f=1):o>-1&&(f=-1)}return o<0||l<0||f===0||f===1&&o===l-1&&o===a+1?"":t.slice(o,l)}function mC(...t){let i=-1,l;for(;++i<t.length;)Aa(t[i]),t[i]&&(l=l===void 0?t[i]:l+"/"+t[i]);return l===void 0?".":gC(l)}function gC(t){Aa(t);const i=t.codePointAt(0)===47;let l=yC(t,!i);return l.length===0&&!i&&(l="."),l.length>0&&t.codePointAt(t.length-1)===47&&(l+="/"),i?"/"+l:l}function yC(t,i){let l="",a=0,o=-1,f=0,u=-1,m,h;for(;++u<=t.length;){if(u<t.length)m=t.codePointAt(u);else{if(m===47)break;m=47}if(m===47){if(!(o===u-1||f===1))if(o!==u-1&&f===2){if(l.length<2||a!==2||l.codePointAt(l.length-1)!==46||l.codePointAt(l.length-2)!==46){if(l.length>2){if(h=l.lastIndexOf("/"),h!==l.length-1){h<0?(l="",a=0):(l=l.slice(0,h),a=l.length-1-l.lastIndexOf("/")),o=u,f=0;continue}}else if(l.length>0){l="",a=0,o=u,f=0;continue}}i&&(l=l.length>0?l+"/..":"..",a=2)}else l.length>0?l+="/"+t.slice(o+1,u):l=t.slice(o+1,u),a=u-o-1;o=u,f=0}else m===46&&f>-1?f++:f=-1}return l}function Aa(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const bC={cwd:vC};function vC(){return"/"}function Gf(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function xC(t){if(typeof t=="string")t=new URL(t);else if(!Gf(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 SC(t)}function SC(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 l=-1;for(;++l<i.length;)if(i.codePointAt(l)===37&&i.codePointAt(l+1)===50){const a=i.codePointAt(l+2);if(a===70||a===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(i)}const xf=["history","path","basename","stem","extname","dirname"];class hv{constructor(i){let l;i?Gf(i)?l={path:i}:typeof i=="string"||wC(i)?l={value:i}:l=i:l={},this.cwd="cwd"in l?"":bC.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<xf.length;){const f=xf[a];f in l&&l[f]!==void 0&&l[f]!==null&&(this[f]=f==="history"?[...l[f]]:l[f])}let o;for(o in l)xf.includes(o)||(this[o]=l[o])}get basename(){return typeof this.path=="string"?Zn.basename(this.path):void 0}set basename(i){wf(i,"basename"),Sf(i,"basename"),this.path=Zn.join(this.dirname||"",i)}get dirname(){return typeof this.path=="string"?Zn.dirname(this.path):void 0}set dirname(i){Qy(this.basename,"dirname"),this.path=Zn.join(i||"",this.basename)}get extname(){return typeof this.path=="string"?Zn.extname(this.path):void 0}set extname(i){if(Sf(i,"extname"),Qy(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=Zn.join(this.dirname,this.stem+(i||""))}get path(){return this.history[this.history.length-1]}set path(i){Gf(i)&&(i=xC(i)),wf(i,"path"),this.path!==i&&this.history.push(i)}get stem(){return typeof this.path=="string"?Zn.basename(this.path,this.extname):void 0}set stem(i){wf(i,"stem"),Sf(i,"stem"),this.path=Zn.join(this.dirname||"",i+(this.extname||""))}fail(i,l,a){const o=this.message(i,l,a);throw o.fatal=!0,o}info(i,l,a){const o=this.message(i,l,a);return o.fatal=void 0,o}message(i,l,a){const o=new an(i,l,a);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(i){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(i||void 0).decode(this.value)}}function Sf(t,i){if(t&&t.includes(Zn.sep))throw new Error("`"+i+"` cannot be a path: did not expect `"+Zn.sep+"`")}function wf(t,i){if(!t)throw new Error("`"+i+"` cannot be empty")}function Qy(t,i){if(!t)throw new Error("Setting `"+i+"` requires `path` to be set too")}function wC(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const jC=(function(t){const a=this.constructor.prototype,o=a[t],f=function(){return o.apply(f,arguments)};return Object.setPrototypeOf(f,a),f}),kC={}.hasOwnProperty;class xd extends jC{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=cC()}copy(){const i=new xd;let l=-1;for(;++l<this.attachers.length;){const a=this.attachers[l];i.use(...a)}return i.data(vf(!0,{},this.namespace)),i}data(i,l){return typeof i=="string"?arguments.length===2?(Ef("data",this.frozen),this.namespace[i]=l,this):kC.call(this.namespace,i)&&this.namespace[i]||void 0:i?(Ef("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[l,...a]=this.attachers[this.freezeIndex];if(a[0]===!1)continue;a[0]===!0&&(a[0]=void 0);const o=l.call(i,...a);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(i){this.freeze();const l=Zs(i),a=this.parser||this.Parser;return jf("parse",a),a(String(l),l)}process(i,l){const a=this;return this.freeze(),jf("process",this.parser||this.Parser),kf("process",this.compiler||this.Compiler),l?o(void 0,l):new Promise(o);function o(f,u){const m=Zs(i),h=a.parse(m);a.run(h,m,function(y,b,x){if(y||!b||!x)return p(y);const v=b,j=a.stringify(v,x);NC(j)?x.value=j:x.result=j,p(y,x)});function p(y,b){y||!b?u(y):f?f(b):l(void 0,b)}}}processSync(i){let l=!1,a;return this.freeze(),jf("processSync",this.parser||this.Parser),kf("processSync",this.compiler||this.Compiler),this.process(i,o),Xy("processSync","process",l),a;function o(f,u){l=!0,Gy(f),a=u}}run(i,l,a){$y(i),this.freeze();const o=this.transformers;return!a&&typeof l=="function"&&(a=l,l=void 0),a?f(void 0,a):new Promise(f);function f(u,m){const h=Zs(l);o.run(i,h,p);function p(y,b,x){const v=b||i;y?m(y):u?u(v):a(void 0,v,x)}}}runSync(i,l){let a=!1,o;return this.run(i,l,f),Xy("runSync","run",a),o;function f(u,m){Gy(u),o=m,a=!0}}stringify(i,l){this.freeze();const a=Zs(l),o=this.compiler||this.Compiler;return kf("stringify",o),$y(i),o(i,a)}use(i,...l){const a=this.attachers,o=this.namespace;if(Ef("use",this.frozen),i!=null)if(typeof i=="function")h(i,l);else if(typeof i=="object")Array.isArray(i)?m(i):u(i);else throw new TypeError("Expected usable value, not `"+i+"`");return this;function f(p){if(typeof p=="function")h(p,[]);else if(typeof p=="object")if(Array.isArray(p)){const[y,...b]=p;h(y,b)}else u(p);else throw new TypeError("Expected usable value, not `"+p+"`")}function u(p){if(!("plugins"in p)&&!("settings"in p))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");m(p.plugins),p.settings&&(o.settings=vf(!0,o.settings,p.settings))}function m(p){let y=-1;if(p!=null)if(Array.isArray(p))for(;++y<p.length;){const b=p[y];f(b)}else throw new TypeError("Expected a list of plugins, not `"+p+"`")}function h(p,y){let b=-1,x=-1;for(;++b<a.length;)if(a[b][0]===p){x=b;break}if(x===-1)a.push([p,...y]);else if(y.length>0){let[v,...j]=y;const D=a[x][1];Yf(D)&&Yf(v)&&(v=vf(!0,D,v)),a[x]=[p,v,...j]}}}}const EC=new xd().freeze();function jf(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function kf(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Ef(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 $y(t){if(!Yf(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Xy(t,i,l){if(!l)throw new Error("`"+t+"` finished async. Use `"+i+"` instead")}function Zs(t){return CC(t)?t:new hv(t)}function CC(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function NC(t){return typeof t=="string"||AC(t)}function AC(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const TC="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ky=[],Py={allowDangerousHtml:!0},RC=/^(https?|ircs?|mailto|xmpp)$/i,zC=[{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 DC(t){const i=_C(t),l=MC(t);return OC(i.runSync(i.parse(l),l),t)}function _C(t){const i=t.rehypePlugins||Ky,l=t.remarkPlugins||Ky,a=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...Py}:Py;return EC().use(dE).use(l).use(sC,a).use(i)}function MC(t){const i=t.children||"",l=new hv;return typeof i=="string"&&(l.value=i),l}function OC(t,i){const l=i.allowedElements,a=i.allowElement,o=i.components,f=i.disallowedElements,u=i.skipHtml,m=i.unwrapDisallowed,h=i.urlTransform||LC;for(const y of zC)Object.hasOwn(i,y.from)&&(""+y.from+(y.to?"use `"+y.to+"` instead":"remove it")+TC+y.id,void 0);return i.className&&(t={type:"element",tagName:"div",properties:{className:i.className},children:t.type==="root"?t.children:[t]}),vd(t,p),Kw(t,{Fragment:c.Fragment,components:o,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function p(y,b,x){if(y.type==="raw"&&x&&typeof b=="number")return u?x.children.splice(b,1):x.children[b]={type:"text",value:y.value},b;if(y.type==="element"){let v;for(v in mf)if(Object.hasOwn(mf,v)&&Object.hasOwn(y.properties,v)){const j=y.properties[v],D=mf[v];(D===null||D.includes(y.tagName))&&(y.properties[v]=h(String(j||""),v,y))}}if(y.type==="element"){let v=l?!l.includes(y.tagName):f?f.includes(y.tagName):!1;if(!v&&a&&typeof b=="number"&&(v=!a(y,b,x)),v&&x&&typeof b=="number")return m&&y.children?x.children.splice(b,1,...y.children):x.children.splice(b,1),b}}}function LC(t){const i=t.indexOf(":"),l=t.indexOf("?"),a=t.indexOf("#"),o=t.indexOf("/");return i===-1||o!==-1&&i>o||l!==-1&&i>l||a!==-1&&i>a||RC.test(t.slice(0,i))?t:""}function Zy(t,i){const l=String(t);if(typeof i!="string")throw new TypeError("Expected character");let a=0,o=l.indexOf(i);for(;o!==-1;)a++,o=l.indexOf(i,o+i.length);return a}function BC(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function UC(t,i,l){const o=yo((l||{}).ignore||[]),f=IC(i);let u=-1;for(;++u<f.length;)dv(t,"text",m);function m(p,y){let b=-1,x;for(;++b<y.length;){const v=y[b],j=x?x.children:void 0;if(o(v,j?j.indexOf(v):void 0,x))return;x=v}if(x)return h(p,y)}function h(p,y){const b=y[y.length-1],x=f[u][0],v=f[u][1];let j=0;const N=b.children.indexOf(p);let A=!1,R=[];x.lastIndex=0;let O=x.exec(p.value);for(;O;){const Y=O.index,re={index:O.index,input:O.input,stack:[...y,p]};let T=v(...O,re);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?x.lastIndex=Y+1:(j!==Y&&R.push({type:"text",value:p.value.slice(j,Y)}),Array.isArray(T)?R.push(...T):T&&R.push(T),j=Y+O[0].length,A=!0),!x.global)break;O=x.exec(p.value)}return A?(j<p.value.length&&R.push({type:"text",value:p.value.slice(j)}),b.children.splice(N,1,...R)):R=[p],N+R.length}}function IC(t){const i=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const l=!t[0]||Array.isArray(t[0])?t:[t];let a=-1;for(;++a<l.length;){const o=l[a];i.push([qC(o[0]),HC(o[1])])}return i}function qC(t){return typeof t=="string"?new RegExp(BC(t),"g"):t}function HC(t){return typeof t=="function"?t:function(){return t}}const Cf="phrasing",Nf=["autolink","link","image","label"];function VC(){return{transforms:[KC],enter:{literalAutolink:GC,literalAutolinkEmail:Af,literalAutolinkHttp:Af,literalAutolinkWww:Af},exit:{literalAutolink:XC,literalAutolinkEmail:$C,literalAutolinkHttp:FC,literalAutolinkWww:QC}}}function YC(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Cf,notInConstruct:Nf},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Cf,notInConstruct:Nf},{character:":",before:"[ps]",after:"\\/",inConstruct:Cf,notInConstruct:Nf}]}}function GC(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function Af(t){this.config.enter.autolinkProtocol.call(this,t)}function FC(t){this.config.exit.autolinkProtocol.call(this,t)}function QC(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 $C(t){this.config.exit.autolinkEmail.call(this,t)}function XC(t){this.exit(t)}function KC(t){UC(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,PC],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),ZC]],{ignore:["link","linkReference"]})}function PC(t,i,l,a,o){let f="";if(!pv(o)||(/^w/i.test(i)&&(l=i+l,i="",f="http://"),!JC(l)))return!1;const u=WC(l+a);if(!u[0])return!1;const m={type:"link",title:null,url:f+i+u[0],children:[{type:"text",value:i+u[0]}]};return u[1]?[m,{type:"text",value:u[1]}]:m}function ZC(t,i,l,a){return!pv(a,!0)||/[-\d_]$/.test(l)?!1:{type:"link",title:null,url:"mailto:"+i+"@"+l,children:[{type:"text",value:i+"@"+l}]}}function JC(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 WC(t){const i=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!i)return[t,void 0];t=t.slice(0,i.index);let l=i[0],a=l.indexOf(")");const o=Zy(t,"(");let f=Zy(t,")");for(;a!==-1&&o>f;)t+=l.slice(0,a+1),l=l.slice(a+1),a=l.indexOf(")"),f++;return[t,l]}function pv(t,i){const l=t.input.charCodeAt(t.index-1);return(t.index===0||yr(l)||po(l))&&(!i||l!==47)}mv.peek=o2;function e2(){this.buffer()}function t2(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function n2(){this.buffer()}function i2(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function r2(t){const i=this.resume(),l=this.stack[this.stack.length-1];l.type,l.identifier=Yn(this.sliceSerialize(t)).toLowerCase(),l.label=i}function l2(t){this.exit(t)}function a2(t){const i=this.resume(),l=this.stack[this.stack.length-1];l.type,l.identifier=Yn(this.sliceSerialize(t)).toLowerCase(),l.label=i}function s2(t){this.exit(t)}function o2(){return"["}function mv(t,i,l,a){const o=l.createTracker(a);let f=o.move("[^");const u=l.enter("footnoteReference"),m=l.enter("reference");return f+=o.move(l.safe(l.associationId(t),{after:"]",before:f})),m(),u(),f+=o.move("]"),f}function u2(){return{enter:{gfmFootnoteCallString:e2,gfmFootnoteCall:t2,gfmFootnoteDefinitionLabelString:n2,gfmFootnoteDefinition:i2},exit:{gfmFootnoteCallString:r2,gfmFootnoteCall:l2,gfmFootnoteDefinitionLabelString:a2,gfmFootnoteDefinition:s2}}}function c2(t){let i=!1;return t&&t.firstLineBlank&&(i=!0),{handlers:{footnoteDefinition:l,footnoteReference:mv},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function l(a,o,f,u){const m=f.createTracker(u);let h=m.move("[^");const p=f.enter("footnoteDefinition"),y=f.enter("label");return h+=m.move(f.safe(f.associationId(a),{before:h,after:"]"})),y(),h+=m.move("]:"),a.children&&a.children.length>0&&(m.shift(4),h+=m.move((i?`
|
|
42
|
-
`:" ")+f.indentLines(f.containerFlow(a,m.current()),i?gv:f2))),p(),h}}function f2(t,i,l){return i===0?t:gv(t,i,l)}function gv(t,i,l){return(l?"":" ")+t}const d2=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];yv.peek=y2;function h2(){return{canContainEols:["delete"],enter:{strikethrough:m2},exit:{strikethrough:g2}}}function p2(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:d2}],handlers:{delete:yv}}}function m2(t){this.enter({type:"delete",children:[]},t)}function g2(t){this.exit(t)}function yv(t,i,l,a){const o=l.createTracker(a),f=l.enter("strikethrough");let u=o.move("~~");return u+=l.containerPhrasing(t,{...o.current(),before:u,after:"~"}),u+=o.move("~~"),f(),u}function y2(){return"~"}function b2(t){return t.length}function v2(t,i){const l=i||{},a=(l.align||[]).concat(),o=l.stringLength||b2,f=[],u=[],m=[],h=[];let p=0,y=-1;for(;++y<t.length;){const D=[],N=[];let A=-1;for(t[y].length>p&&(p=t[y].length);++A<t[y].length;){const R=x2(t[y][A]);if(l.alignDelimiters!==!1){const O=o(R);N[A]=O,(h[A]===void 0||O>h[A])&&(h[A]=O)}D.push(R)}u[y]=D,m[y]=N}let b=-1;if(typeof a=="object"&&"length"in a)for(;++b<p;)f[b]=Jy(a[b]);else{const D=Jy(a);for(;++b<p;)f[b]=D}b=-1;const x=[],v=[];for(;++b<p;){const D=f[b];let N="",A="";D===99?(N=":",A=":"):D===108?N=":":D===114&&(A=":");let R=l.alignDelimiters===!1?1:Math.max(1,h[b]-N.length-A.length);const O=N+"-".repeat(R)+A;l.alignDelimiters!==!1&&(R=N.length+R+A.length,R>h[b]&&(h[b]=R),v[b]=R),x[b]=O}u.splice(1,0,x),m.splice(1,0,v),y=-1;const j=[];for(;++y<u.length;){const D=u[y],N=m[y];b=-1;const A=[];for(;++b<p;){const R=D[b]||"";let O="",Y="";if(l.alignDelimiters!==!1){const re=h[b]-(N[b]||0),T=f[b];T===114?O=" ".repeat(re):T===99?re%2?(O=" ".repeat(re/2+.5),Y=" ".repeat(re/2-.5)):(O=" ".repeat(re/2),Y=O):Y=" ".repeat(re)}l.delimiterStart!==!1&&!b&&A.push("|"),l.padding!==!1&&!(l.alignDelimiters===!1&&R==="")&&(l.delimiterStart!==!1||b)&&A.push(" "),l.alignDelimiters!==!1&&A.push(O),A.push(R),l.alignDelimiters!==!1&&A.push(Y),l.padding!==!1&&A.push(" "),(l.delimiterEnd!==!1||b!==p-1)&&A.push("|")}j.push(l.delimiterEnd===!1?A.join("").replace(/ +$/,""):A.join(""))}return j.join(`
|
|
43
|
-
`)}function x2(t){return t==null?"":String(t)}function Jy(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 S2(t,i,l,a){const o=l.enter("blockquote"),f=l.createTracker(a);f.move("> "),f.shift(2);const u=l.indentLines(l.containerFlow(t,f.current()),w2);return o(),u}function w2(t,i,l){return">"+(l?"":" ")+t}function j2(t,i){return Wy(t,i.inConstruct,!0)&&!Wy(t,i.notInConstruct,!1)}function Wy(t,i,l){if(typeof i=="string"&&(i=[i]),!i||i.length===0)return l;let a=-1;for(;++a<i.length;)if(t.includes(i[a]))return!0;return!1}function eb(t,i,l,a){let o=-1;for(;++o<l.unsafe.length;)if(l.unsafe[o].character===`
|
|
44
|
-
`&&j2(l.stack,l.unsafe[o]))return/[ \t]/.test(a.before)?"":" ";return`\\
|
|
45
|
-
`}function k2(t,i){const l=String(t);let a=l.indexOf(i),o=a,f=0,u=0;if(typeof i!="string")throw new TypeError("Expected substring");for(;a!==-1;)a===o?++f>u&&(u=f):f=1,o=a+i.length,a=l.indexOf(i,o);return u}function E2(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 C2(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 N2(t,i,l,a){const o=C2(l),f=t.value||"",u=o==="`"?"GraveAccent":"Tilde";if(E2(t,l)){const b=l.enter("codeIndented"),x=l.indentLines(f,A2);return b(),x}const m=l.createTracker(a),h=o.repeat(Math.max(k2(f,o)+1,3)),p=l.enter("codeFenced");let y=m.move(h);if(t.lang){const b=l.enter(`codeFencedLang${u}`);y+=m.move(l.safe(t.lang,{before:y,after:" ",encode:["`"],...m.current()})),b()}if(t.lang&&t.meta){const b=l.enter(`codeFencedMeta${u}`);y+=m.move(" "),y+=m.move(l.safe(t.meta,{before:y,after:`
|
|
46
|
-
`,encode:["`"],...m.current()})),b()}return y+=m.move(`
|
|
47
|
-
`),f&&(y+=m.move(f+`
|
|
48
|
-
`)),y+=m.move(h),p(),y}function A2(t,i,l){return(l?"":" ")+t}function Sd(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 T2(t,i,l,a){const o=Sd(l),f=o==='"'?"Quote":"Apostrophe",u=l.enter("definition");let m=l.enter("label");const h=l.createTracker(a);let p=h.move("[");return p+=h.move(l.safe(l.associationId(t),{before:p,after:"]",...h.current()})),p+=h.move("]: "),m(),!t.url||/[\0- \u007F]/.test(t.url)?(m=l.enter("destinationLiteral"),p+=h.move("<"),p+=h.move(l.safe(t.url,{before:p,after:">",...h.current()})),p+=h.move(">")):(m=l.enter("destinationRaw"),p+=h.move(l.safe(t.url,{before:p,after:t.title?" ":`
|
|
49
|
-
`,...h.current()}))),m(),t.title&&(m=l.enter(`title${f}`),p+=h.move(" "+o),p+=h.move(l.safe(t.title,{before:p,after:o,...h.current()})),p+=h.move(o),m()),u(),p}function R2(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 ja(t){return"&#x"+t.toString(16).toUpperCase()+";"}function uo(t,i,l){const a=dl(t),o=dl(i);return a===void 0?o===void 0?l==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:a===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}bv.peek=z2;function bv(t,i,l,a){const o=R2(l),f=l.enter("emphasis"),u=l.createTracker(a),m=u.move(o);let h=u.move(l.containerPhrasing(t,{after:o,before:m,...u.current()}));const p=h.charCodeAt(0),y=uo(a.before.charCodeAt(a.before.length-1),p,o);y.inside&&(h=ja(p)+h.slice(1));const b=h.charCodeAt(h.length-1),x=uo(a.after.charCodeAt(0),b,o);x.inside&&(h=h.slice(0,-1)+ja(b));const v=u.move(o);return f(),l.attentionEncodeSurroundingInfo={after:x.outside,before:y.outside},m+h+v}function z2(t,i,l){return l.options.emphasis||"*"}function D2(t,i){let l=!1;return vd(t,function(a){if("value"in a&&/\r?\n|\r/.test(a.value)||a.type==="break")return l=!0,Hf}),!!((!t.depth||t.depth<3)&&dd(t)&&(i.options.setext||l))}function _2(t,i,l,a){const o=Math.max(Math.min(6,t.depth||1),1),f=l.createTracker(a);if(D2(t,l)){const y=l.enter("headingSetext"),b=l.enter("phrasing"),x=l.containerPhrasing(t,{...f.current(),before:`
|
|
50
|
-
`,after:`
|
|
51
|
-
`});return b(),y(),x+`
|
|
52
|
-
`+(o===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(`
|
|
53
|
-
`))+1))}const u="#".repeat(o),m=l.enter("headingAtx"),h=l.enter("phrasing");f.move(u+" ");let p=l.containerPhrasing(t,{before:"# ",after:`
|
|
54
|
-
`,...f.current()});return/^[\t ]/.test(p)&&(p=ja(p.charCodeAt(0))+p.slice(1)),p=p?u+" "+p:u,l.options.closeAtx&&(p+=" "+u),h(),m(),p}vv.peek=M2;function vv(t){return t.value||""}function M2(){return"<"}xv.peek=O2;function xv(t,i,l,a){const o=Sd(l),f=o==='"'?"Quote":"Apostrophe",u=l.enter("image");let m=l.enter("label");const h=l.createTracker(a);let p=h.move("![");return p+=h.move(l.safe(t.alt,{before:p,after:"]",...h.current()})),p+=h.move("]("),m(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(m=l.enter("destinationLiteral"),p+=h.move("<"),p+=h.move(l.safe(t.url,{before:p,after:">",...h.current()})),p+=h.move(">")):(m=l.enter("destinationRaw"),p+=h.move(l.safe(t.url,{before:p,after:t.title?" ":")",...h.current()}))),m(),t.title&&(m=l.enter(`title${f}`),p+=h.move(" "+o),p+=h.move(l.safe(t.title,{before:p,after:o,...h.current()})),p+=h.move(o),m()),p+=h.move(")"),u(),p}function O2(){return"!"}Sv.peek=L2;function Sv(t,i,l,a){const o=t.referenceType,f=l.enter("imageReference");let u=l.enter("label");const m=l.createTracker(a);let h=m.move("![");const p=l.safe(t.alt,{before:h,after:"]",...m.current()});h+=m.move(p+"]["),u();const y=l.stack;l.stack=[],u=l.enter("reference");const b=l.safe(l.associationId(t),{before:h,after:"]",...m.current()});return u(),l.stack=y,f(),o==="full"||!p||p!==b?h+=m.move(b+"]"):o==="shortcut"?h=h.slice(0,-1):h+=m.move("]"),h}function L2(){return"!"}wv.peek=B2;function wv(t,i,l){let a=t.value||"",o="`",f=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(a);)o+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++f<l.unsafe.length;){const u=l.unsafe[f],m=l.compilePattern(u);let h;if(u.atBreak)for(;h=m.exec(a);){let p=h.index;a.charCodeAt(p)===10&&a.charCodeAt(p-1)===13&&p--,a=a.slice(0,p)+" "+a.slice(h.index+1)}}return o+a+o}function B2(){return"`"}function jv(t,i){const l=dd(t);return!!(!i.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(l===t.url||"mailto:"+l===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}kv.peek=U2;function kv(t,i,l,a){const o=Sd(l),f=o==='"'?"Quote":"Apostrophe",u=l.createTracker(a);let m,h;if(jv(t,l)){const y=l.stack;l.stack=[],m=l.enter("autolink");let b=u.move("<");return b+=u.move(l.containerPhrasing(t,{before:b,after:">",...u.current()})),b+=u.move(">"),m(),l.stack=y,b}m=l.enter("link"),h=l.enter("label");let p=u.move("[");return p+=u.move(l.containerPhrasing(t,{before:p,after:"](",...u.current()})),p+=u.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=l.enter("destinationLiteral"),p+=u.move("<"),p+=u.move(l.safe(t.url,{before:p,after:">",...u.current()})),p+=u.move(">")):(h=l.enter("destinationRaw"),p+=u.move(l.safe(t.url,{before:p,after:t.title?" ":")",...u.current()}))),h(),t.title&&(h=l.enter(`title${f}`),p+=u.move(" "+o),p+=u.move(l.safe(t.title,{before:p,after:o,...u.current()})),p+=u.move(o),h()),p+=u.move(")"),m(),p}function U2(t,i,l){return jv(t,l)?"<":"["}Ev.peek=I2;function Ev(t,i,l,a){const o=t.referenceType,f=l.enter("linkReference");let u=l.enter("label");const m=l.createTracker(a);let h=m.move("[");const p=l.containerPhrasing(t,{before:h,after:"]",...m.current()});h+=m.move(p+"]["),u();const y=l.stack;l.stack=[],u=l.enter("reference");const b=l.safe(l.associationId(t),{before:h,after:"]",...m.current()});return u(),l.stack=y,f(),o==="full"||!p||p!==b?h+=m.move(b+"]"):o==="shortcut"?h=h.slice(0,-1):h+=m.move("]"),h}function I2(){return"["}function wd(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 q2(t){const i=wd(t),l=t.options.bulletOther;if(!l)return i==="*"?"-":"*";if(l!=="*"&&l!=="+"&&l!=="-")throw new Error("Cannot serialize items with `"+l+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(l===i)throw new Error("Expected `bullet` (`"+i+"`) and `bulletOther` (`"+l+"`) to be different");return l}function H2(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 Cv(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 V2(t,i,l,a){const o=l.enter("list"),f=l.bulletCurrent;let u=t.ordered?H2(l):wd(l);const m=t.ordered?u==="."?")":".":q2(l);let h=i&&l.bulletLastUsed?u===l.bulletLastUsed:!1;if(!t.ordered){const y=t.children?t.children[0]:void 0;if((u==="*"||u==="-")&&y&&(!y.children||!y.children[0])&&l.stack[l.stack.length-1]==="list"&&l.stack[l.stack.length-2]==="listItem"&&l.stack[l.stack.length-3]==="list"&&l.stack[l.stack.length-4]==="listItem"&&l.indexStack[l.indexStack.length-1]===0&&l.indexStack[l.indexStack.length-2]===0&&l.indexStack[l.indexStack.length-3]===0&&(h=!0),Cv(l)===u&&y){let b=-1;for(;++b<t.children.length;){const x=t.children[b];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(u=m),l.bulletCurrent=u;const p=l.containerFlow(t,a);return l.bulletLastUsed=u,l.bulletCurrent=f,o(),p}function Y2(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 G2(t,i,l,a){const o=Y2(l);let f=l.bulletCurrent||wd(l);i&&i.type==="list"&&i.ordered&&(f=(typeof i.start=="number"&&i.start>-1?i.start:1)+(l.options.incrementListMarker===!1?0:i.children.indexOf(t))+f);let u=f.length+1;(o==="tab"||o==="mixed"&&(i&&i.type==="list"&&i.spread||t.spread))&&(u=Math.ceil(u/4)*4);const m=l.createTracker(a);m.move(f+" ".repeat(u-f.length)),m.shift(u);const h=l.enter("listItem"),p=l.indentLines(l.containerFlow(t,m.current()),y);return h(),p;function y(b,x,v){return x?(v?"":" ".repeat(u))+b:(v?f:f+" ".repeat(u-f.length))+b}}function F2(t,i,l,a){const o=l.enter("paragraph"),f=l.enter("phrasing"),u=l.containerPhrasing(t,a);return f(),o(),u}const Q2=yo(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function $2(t,i,l,a){return(t.children.some(function(u){return Q2(u)})?l.containerPhrasing:l.containerFlow).call(l,t,a)}function X2(t){const i=t.options.strong||"*";if(i!=="*"&&i!=="_")throw new Error("Cannot serialize strong with `"+i+"` for `options.strong`, expected `*`, or `_`");return i}Nv.peek=K2;function Nv(t,i,l,a){const o=X2(l),f=l.enter("strong"),u=l.createTracker(a),m=u.move(o+o);let h=u.move(l.containerPhrasing(t,{after:o,before:m,...u.current()}));const p=h.charCodeAt(0),y=uo(a.before.charCodeAt(a.before.length-1),p,o);y.inside&&(h=ja(p)+h.slice(1));const b=h.charCodeAt(h.length-1),x=uo(a.after.charCodeAt(0),b,o);x.inside&&(h=h.slice(0,-1)+ja(b));const v=u.move(o+o);return f(),l.attentionEncodeSurroundingInfo={after:x.outside,before:y.outside},m+h+v}function K2(t,i,l){return l.options.strong||"*"}function P2(t,i,l,a){return l.safe(t.value,a)}function Z2(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 J2(t,i,l){const a=(Cv(l)+(l.options.ruleSpaces?" ":"")).repeat(Z2(l));return l.options.ruleSpaces?a.slice(0,-1):a}const Av={blockquote:S2,break:eb,code:N2,definition:T2,emphasis:bv,hardBreak:eb,heading:_2,html:vv,image:xv,imageReference:Sv,inlineCode:wv,link:kv,linkReference:Ev,list:V2,listItem:G2,paragraph:F2,root:$2,strong:Nv,text:P2,thematicBreak:J2};function W2(){return{enter:{table:eN,tableData:tb,tableHeader:tb,tableRow:nN},exit:{codeText:iN,table:tN,tableData:Tf,tableHeader:Tf,tableRow:Tf}}}function eN(t){const i=t._align;this.enter({type:"table",align:i.map(function(l){return l==="none"?null:l}),children:[]},t),this.data.inTable=!0}function tN(t){this.exit(t),this.data.inTable=void 0}function nN(t){this.enter({type:"tableRow",children:[]},t)}function Tf(t){this.exit(t)}function tb(t){this.enter({type:"tableCell",children:[]},t)}function iN(t){let i=this.resume();this.data.inTable&&(i=i.replace(/\\([\\|])/g,rN));const l=this.stack[this.stack.length-1];l.type,l.value=i,this.exit(t)}function rN(t,i){return i==="|"?i:t}function lN(t){const i=t||{},l=i.tableCellPadding,a=i.tablePipeAlign,o=i.stringLength,f=l?" ":"|";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:x,table:u,tableCell:h,tableRow:m}};function u(v,j,D,N){return p(y(v,D,N),v.align)}function m(v,j,D,N){const A=b(v,D,N),R=p([A]);return R.slice(0,R.indexOf(`
|
|
56
|
-
`))}function h(v,j,D,N){const A=D.enter("tableCell"),R=D.enter("phrasing"),O=D.containerPhrasing(v,{...N,before:f,after:f});return R(),A(),O}function p(v,j){return v2(v,{align:j,alignDelimiters:a,padding:l,stringLength:o})}function y(v,j,D){const N=v.children;let A=-1;const R=[],O=j.enter("table");for(;++A<N.length;)R[A]=b(N[A],j,D);return O(),R}function b(v,j,D){const N=v.children;let A=-1;const R=[],O=j.enter("tableRow");for(;++A<N.length;)R[A]=h(N[A],v,j,D);return O(),R}function x(v,j,D){let N=Av.inlineCode(v,j,D);return D.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function aN(){return{exit:{taskListCheckValueChecked:nb,taskListCheckValueUnchecked:nb,paragraph:oN}}}function sN(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:uN}}}function nb(t){const i=this.stack[this.stack.length-2];i.type,i.checked=t.type==="taskListCheckValueChecked"}function oN(t){const i=this.stack[this.stack.length-2];if(i&&i.type==="listItem"&&typeof i.checked=="boolean"){const l=this.stack[this.stack.length-1];l.type;const a=l.children[0];if(a&&a.type==="text"){const o=i.children;let f=-1,u;for(;++f<o.length;){const m=o[f];if(m.type==="paragraph"){u=m;break}}u===l&&(a.value=a.value.slice(1),a.value.length===0?l.children.shift():l.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,l.position.start=Object.assign({},a.position.start)))}}this.exit(t)}function uN(t,i,l,a){const o=t.children[0],f=typeof t.checked=="boolean"&&o&&o.type==="paragraph",u="["+(t.checked?"x":" ")+"] ",m=l.createTracker(a);f&&m.move(u);let h=Av.listItem(t,i,l,{...a,...m.current()});return f&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),h;function p(y){return y+u}}function cN(){return[VC(),u2(),h2(),W2(),aN()]}function fN(t){return{extensions:[YC(),c2(t),p2(),lN(t),sN()]}}const dN={tokenize:bN,partial:!0},Tv={tokenize:vN,partial:!0},Rv={tokenize:xN,partial:!0},zv={tokenize:SN,partial:!0},hN={tokenize:wN,partial:!0},Dv={name:"wwwAutolink",tokenize:gN,previous:Mv},_v={name:"protocolAutolink",tokenize:yN,previous:Ov},Si={name:"emailAutolink",tokenize:mN,previous:Lv},Jn={};function pN(){return{text:Jn}}let hr=48;for(;hr<123;)Jn[hr]=Si,hr++,hr===58?hr=65:hr===91&&(hr=97);Jn[43]=Si;Jn[45]=Si;Jn[46]=Si;Jn[95]=Si;Jn[72]=[Si,_v];Jn[104]=[Si,_v];Jn[87]=[Si,Dv];Jn[119]=[Si,Dv];function mN(t,i,l){const a=this;let o,f;return u;function u(b){return!Ff(b)||!Lv.call(a,a.previous)||jd(a.events)?l(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),m(b))}function m(b){return Ff(b)?(t.consume(b),m):b===64?(t.consume(b),h):l(b)}function h(b){return b===46?t.check(hN,y,p)(b):b===45||b===95||ln(b)?(f=!0,t.consume(b),h):y(b)}function p(b){return t.consume(b),o=!0,h}function y(b){return f&&o&&on(a.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),i(b)):l(b)}}function gN(t,i,l){const a=this;return o;function o(u){return u!==87&&u!==119||!Mv.call(a,a.previous)||jd(a.events)?l(u):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(dN,t.attempt(Tv,t.attempt(Rv,f),l),l)(u))}function f(u){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),i(u)}}function yN(t,i,l){const a=this;let o="",f=!1;return u;function u(b){return(b===72||b===104)&&Ov.call(a,a.previous)&&!jd(a.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),o+=String.fromCodePoint(b),t.consume(b),m):l(b)}function m(b){if(on(b)&&o.length<5)return o+=String.fromCodePoint(b),t.consume(b),m;if(b===58){const x=o.toLowerCase();if(x==="http"||x==="https")return t.consume(b),h}return l(b)}function h(b){return b===47?(t.consume(b),f?p:(f=!0,h)):l(b)}function p(b){return b===null||ao(b)||Tt(b)||yr(b)||po(b)?l(b):t.attempt(Tv,t.attempt(Rv,y),l)(b)}function y(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),i(b)}}function bN(t,i,l){let a=0;return o;function o(u){return(u===87||u===119)&&a<3?(a++,t.consume(u),o):u===46&&a===3?(t.consume(u),f):l(u)}function f(u){return u===null?l(u):i(u)}}function vN(t,i,l){let a,o,f;return u;function u(p){return p===46||p===95?t.check(zv,h,m)(p):p===null||Tt(p)||yr(p)||p!==45&&po(p)?h(p):(f=!0,t.consume(p),u)}function m(p){return p===95?a=!0:(o=a,a=void 0),t.consume(p),u}function h(p){return o||a||!f?l(p):i(p)}}function xN(t,i){let l=0,a=0;return o;function o(u){return u===40?(l++,t.consume(u),o):u===41&&a<l?f(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?t.check(zv,i,f)(u):u===null||Tt(u)||yr(u)?i(u):(t.consume(u),o)}function f(u){return u===41&&a++,t.consume(u),o}}function SN(t,i,l){return a;function a(m){return m===33||m===34||m===39||m===41||m===42||m===44||m===46||m===58||m===59||m===63||m===95||m===126?(t.consume(m),a):m===38?(t.consume(m),f):m===93?(t.consume(m),o):m===60||m===null||Tt(m)||yr(m)?i(m):l(m)}function o(m){return m===null||m===40||m===91||Tt(m)||yr(m)?i(m):a(m)}function f(m){return on(m)?u(m):l(m)}function u(m){return m===59?(t.consume(m),a):on(m)?(t.consume(m),u):l(m)}}function wN(t,i,l){return a;function a(f){return t.consume(f),o}function o(f){return ln(f)?l(f):i(f)}}function Mv(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Tt(t)}function Ov(t){return!on(t)}function Lv(t){return!(t===47||Ff(t))}function Ff(t){return t===43||t===45||t===46||t===95||ln(t)}function jd(t){let i=t.length,l=!1;for(;i--;){const a=t[i][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){l=!0;break}if(a._gfmAutolinkLiteralWalkedInto){l=!1;break}}return t.length>0&&!l&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),l}const jN={tokenize:zN,partial:!0};function kN(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:AN,continuation:{tokenize:TN},exit:RN}},text:{91:{name:"gfmFootnoteCall",tokenize:NN},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:EN,resolveTo:CN}}}}function EN(t,i,l){const a=this;let o=a.events.length;const f=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let u;for(;o--;){const h=a.events[o][1];if(h.type==="labelImage"){u=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return m;function m(h){if(!u||!u._balanced)return l(h);const p=Yn(a.sliceSerialize({start:u.end,end:a.now()}));return p.codePointAt(0)!==94||!f.includes(p.slice(1))?l(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),i(h))}}function CN(t,i){let l=t.length;for(;l--;)if(t[l][1].type==="labelImage"&&t[l][0]==="enter"){t[l][1];break}t[l+1][1].type="data",t[l+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},t[l+3][1].start),end:Object.assign({},t[t.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},t[l+3][1].end),end:Object.assign({},t[l+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const f={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},t[t.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},f.start),end:Object.assign({},f.end)},m=[t[l+1],t[l+2],["enter",a,i],t[l+3],t[l+4],["enter",o,i],["exit",o,i],["enter",f,i],["enter",u,i],["exit",u,i],["exit",f,i],t[t.length-2],t[t.length-1],["exit",a,i]];return t.splice(l,t.length-l+1,...m),t}function NN(t,i,l){const a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let f=0,u;return m;function m(b){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),h}function h(b){return b!==94?l(b):(t.enter("gfmFootnoteCallMarker"),t.consume(b),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",p)}function p(b){if(f>999||b===93&&!u||b===null||b===91||Tt(b))return l(b);if(b===93){t.exit("chunkString");const x=t.exit("gfmFootnoteCallString");return o.includes(Yn(a.sliceSerialize(x)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),i):l(b)}return Tt(b)||(u=!0),f++,t.consume(b),b===92?y:p}function y(b){return b===91||b===92||b===93?(t.consume(b),f++,p):p(b)}}function AN(t,i,l){const a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let f,u=0,m;return h;function h(j){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(j){return j===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",y):l(j)}function y(j){if(u>999||j===93&&!m||j===null||j===91||Tt(j))return l(j);if(j===93){t.exit("chunkString");const D=t.exit("gfmFootnoteDefinitionLabelString");return f=Yn(a.sliceSerialize(D)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),x}return Tt(j)||(m=!0),u++,t.consume(j),j===92?b:y}function b(j){return j===91||j===92||j===93?(t.consume(j),u++,y):y(j)}function x(j){return j===58?(t.enter("definitionMarker"),t.consume(j),t.exit("definitionMarker"),o.includes(f)||o.push(f),ot(t,v,"gfmFootnoteDefinitionWhitespace")):l(j)}function v(j){return i(j)}}function TN(t,i,l){return t.check(Na,i,t.attempt(jN,i,l))}function RN(t){t.exit("gfmFootnoteDefinition")}function zN(t,i,l){const a=this;return ot(t,o,"gfmFootnoteDefinitionIndent",5);function o(f){const u=a.events[a.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?i(f):l(f)}}function DN(t){let l=(t||{}).singleTilde;const a={name:"strikethrough",tokenize:f,resolveAll:o};return l==null&&(l=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function o(u,m){let h=-1;for(;++h<u.length;)if(u[h][0]==="enter"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._close){let p=h;for(;p--;)if(u[p][0]==="exit"&&u[p][1].type==="strikethroughSequenceTemporary"&&u[p][1]._open&&u[h][1].end.offset-u[h][1].start.offset===u[p][1].end.offset-u[p][1].start.offset){u[h][1].type="strikethroughSequence",u[p][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},u[p][1].start),end:Object.assign({},u[h][1].end)},b={type:"strikethroughText",start:Object.assign({},u[p][1].end),end:Object.assign({},u[h][1].start)},x=[["enter",y,m],["enter",u[p][1],m],["exit",u[p][1],m],["enter",b,m]],v=m.parser.constructs.insideSpan.null;v&&En(x,x.length,0,mo(v,u.slice(p+1,h),m)),En(x,x.length,0,[["exit",b,m],["enter",u[h][1],m],["exit",u[h][1],m],["exit",y,m]]),En(u,p-1,h-p+3,x),h=p+x.length-2;break}}for(h=-1;++h<u.length;)u[h][1].type==="strikethroughSequenceTemporary"&&(u[h][1].type="data");return u}function f(u,m,h){const p=this.previous,y=this.events;let b=0;return x;function x(j){return p===126&&y[y.length-1][1].type!=="characterEscape"?h(j):(u.enter("strikethroughSequenceTemporary"),v(j))}function v(j){const D=dl(p);if(j===126)return b>1?h(j):(u.consume(j),b++,v);if(b<2&&!l)return h(j);const N=u.exit("strikethroughSequenceTemporary"),A=dl(j);return N._open=!A||A===2&&!!D,N._close=!D||D===2&&!!A,m(j)}}}class _N{constructor(){this.map=[]}add(i,l,a){MN(this,i,l,a)}consume(i){if(this.map.sort(function(f,u){return f[0]-u[0]}),this.map.length===0)return;let l=this.map.length;const a=[];for(;l>0;)l-=1,a.push(i.slice(this.map[l][0]+this.map[l][1]),this.map[l][2]),i.length=this.map[l][0];a.push(i.slice()),i.length=0;let o=a.pop();for(;o;){for(const f of o)i.push(f);o=a.pop()}this.map.length=0}}function MN(t,i,l,a){let o=0;if(!(l===0&&a.length===0)){for(;o<t.map.length;){if(t.map[o][0]===i){t.map[o][1]+=l,t.map[o][2].push(...a);return}o+=1}t.map.push([i,l,a])}}function ON(t,i){let l=!1;const a=[];for(;i<t.length;){const o=t[i];if(l){if(o[0]==="enter")o[1].type==="tableContent"&&a.push(t[i+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(t[i-1][1].type==="tableDelimiterMarker"){const f=a.length-1;a[f]=a[f]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(l=!0);i+=1}return a}function LN(){return{flow:{null:{name:"table",tokenize:BN,resolveAll:UN}}}}function BN(t,i,l){const a=this;let o=0,f=0,u;return m;function m(C){let B=a.events.length-1;for(;B>-1;){const ee=a.events[B][1].type;if(ee==="lineEnding"||ee==="linePrefix")B--;else break}const U=B>-1?a.events[B][1].type:null,$=U==="tableHead"||U==="tableRow"?T:h;return $===T&&a.parser.lazy[a.now().line]?l(C):$(C)}function h(C){return t.enter("tableHead"),t.enter("tableRow"),p(C)}function p(C){return C===124||(u=!0,f+=1),y(C)}function y(C){return C===null?l(C):Ue(C)?f>1?(f=0,a.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),v):l(C):et(C)?ot(t,y,"whitespace")(C):(f+=1,u&&(u=!1,o+=1),C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),u=!0,y):(t.enter("data"),b(C)))}function b(C){return C===null||C===124||Tt(C)?(t.exit("data"),y(C)):(t.consume(C),C===92?x:b)}function x(C){return C===92||C===124?(t.consume(C),b):b(C)}function v(C){return a.interrupt=!1,a.parser.lazy[a.now().line]?l(C):(t.enter("tableDelimiterRow"),u=!1,et(C)?ot(t,j,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):j(C))}function j(C){return C===45||C===58?N(C):C===124?(u=!0,t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),D):re(C)}function D(C){return et(C)?ot(t,N,"whitespace")(C):N(C)}function N(C){return C===58?(f+=1,u=!0,t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),A):C===45?(f+=1,A(C)):C===null||Ue(C)?Y(C):re(C)}function A(C){return C===45?(t.enter("tableDelimiterFiller"),R(C)):re(C)}function R(C){return C===45?(t.consume(C),R):C===58?(u=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),O):(t.exit("tableDelimiterFiller"),O(C))}function O(C){return et(C)?ot(t,Y,"whitespace")(C):Y(C)}function Y(C){return C===124?j(C):C===null||Ue(C)?!u||o!==f?re(C):(t.exit("tableDelimiterRow"),t.exit("tableHead"),i(C)):re(C)}function re(C){return l(C)}function T(C){return t.enter("tableRow"),V(C)}function V(C){return C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),V):C===null||Ue(C)?(t.exit("tableRow"),i(C)):et(C)?ot(t,V,"whitespace")(C):(t.enter("data"),Q(C))}function Q(C){return C===null||C===124||Tt(C)?(t.exit("data"),V(C)):(t.consume(C),C===92?I:Q)}function I(C){return C===92||C===124?(t.consume(C),Q):Q(C)}}function UN(t,i){let l=-1,a=!0,o=0,f=[0,0,0,0],u=[0,0,0,0],m=!1,h=0,p,y,b;const x=new _N;for(;++l<t.length;){const v=t[l],j=v[1];v[0]==="enter"?j.type==="tableHead"?(m=!1,h!==0&&(ib(x,i,h,p,y),y=void 0,h=0),p={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},x.add(l,0,[["enter",p,i]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(a=!0,b=void 0,f=[0,0,0,0],u=[0,l+1,0,0],m&&(m=!1,y={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},x.add(l,0,[["enter",y,i]])),o=j.type==="tableDelimiterRow"?2:y?3:1):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(a=!1,u[2]===0&&(f[1]!==0&&(u[0]=u[1],b=Js(x,i,f,o,void 0,b),f=[0,0,0,0]),u[2]=l)):j.type==="tableCellDivider"&&(a?a=!1:(f[1]!==0&&(u[0]=u[1],b=Js(x,i,f,o,void 0,b)),f=u,u=[f[1],l,0,0])):j.type==="tableHead"?(m=!0,h=l):j.type==="tableRow"||j.type==="tableDelimiterRow"?(h=l,f[1]!==0?(u[0]=u[1],b=Js(x,i,f,o,l,b)):u[1]!==0&&(b=Js(x,i,u,o,l,b)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(u[3]=l)}for(h!==0&&ib(x,i,h,p,y),x.consume(i.events),l=-1;++l<i.events.length;){const v=i.events[l];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=ON(i.events,l))}return t}function Js(t,i,l,a,o,f){const u=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",m="tableContent";l[0]!==0&&(f.end=Object.assign({},cl(i.events,l[0])),t.add(l[0],0,[["exit",f,i]]));const h=cl(i.events,l[1]);if(f={type:u,start:Object.assign({},h),end:Object.assign({},h)},t.add(l[1],0,[["enter",f,i]]),l[2]!==0){const p=cl(i.events,l[2]),y=cl(i.events,l[3]),b={type:m,start:Object.assign({},p),end:Object.assign({},y)};if(t.add(l[2],0,[["enter",b,i]]),a!==2){const x=i.events[l[2]],v=i.events[l[3]];if(x[1].end=Object.assign({},v[1].end),x[1].type="chunkText",x[1].contentType="text",l[3]>l[2]+1){const j=l[2]+1,D=l[3]-l[2]-1;t.add(j,D,[])}}t.add(l[3]+1,0,[["exit",b,i]])}return o!==void 0&&(f.end=Object.assign({},cl(i.events,o)),t.add(o,0,[["exit",f,i]]),f=void 0),f}function ib(t,i,l,a,o){const f=[],u=cl(i.events,l);o&&(o.end=Object.assign({},u),f.push(["exit",o,i])),a.end=Object.assign({},u),f.push(["exit",a,i]),t.add(l+1,0,f)}function cl(t,i){const l=t[i],a=l[0]==="enter"?"start":"end";return l[1][a]}const IN={name:"tasklistCheck",tokenize:HN};function qN(){return{text:{91:IN}}}function HN(t,i,l){const a=this;return o;function o(h){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?l(h):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),f)}function f(h){return Tt(h)?(t.enter("taskListCheckValueUnchecked"),t.consume(h),t.exit("taskListCheckValueUnchecked"),u):h===88||h===120?(t.enter("taskListCheckValueChecked"),t.consume(h),t.exit("taskListCheckValueChecked"),u):l(h)}function u(h){return h===93?(t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),m):l(h)}function m(h){return Ue(h)?i(h):et(h)?t.check({tokenize:VN},i,l)(h):l(h)}}function VN(t,i,l){return ot(t,a,"whitespace");function a(o){return o===null?l(o):i(o)}}function YN(t){return $b([pN(),kN(),DN(t),LN(),qN()])}const GN={};function FN(t){const i=this,l=t||GN,a=i.data(),o=a.micromarkExtensions||(a.micromarkExtensions=[]),f=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),u=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);o.push(YN(l)),f.push(cN()),u.push(fN(l))}function Qf(t){const i=t.trim();if(!(!i||/[\u0000-\u0020\u007f]/.test(i)))try{const l=new URL(i);if(l.protocol==="https:"||l.protocol==="http:"||l.protocol==="mailto:")return i}catch{}}function $f(t){return!!t&&!/[\u0000-\u001f\u007f]/.test(t)&&!/^[a-z][a-z\d+.-]*:/i.test(t)&&!t.startsWith("//")}function rb(t){if(!$f(t))return;const i=t.split(/[?#]/,1)[0];if(i)try{const l=decodeURIComponent(i);return $f(l)?l:void 0}catch{return}}async function QN(t){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(t);return}const i=document.activeElement,l=document.createElement("textarea");l.value=t,l.setAttribute("aria-label","复制内容"),l.style.cssText="position:fixed;left:-10000px;top:0",document.body.append(l);try{if(l.select(),!document.execCommand("copy"))throw new Error("复制不可用")}finally{l.remove(),i instanceof HTMLElement&&i.focus({preventScroll:!0})}}function vo({text:t,label:i="复制"}){const[l,a]=w.useState("idle"),o=w.useRef(!0),f=w.useRef(void 0);w.useEffect(()=>(o.current=!0,()=>{o.current=!1,clearTimeout(f.current)}),[]);const u=async()=>{clearTimeout(f.current);try{await QN(t),o.current&&a("copied")}catch{o.current&&a("error")}o.current&&(f.current=setTimeout(()=>a("idle"),2500))};return c.jsx("button",{className:"message-copy",onClick:()=>{u()},"aria-label":i,title:i,children:l==="copied"?"已复制":l==="error"?"复制失败":i})}function Xf(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(Xf).join(""):w.isValidElement(t)?Xf(t.props.children):""}function $N({children:t}){const i=w.Children.toArray(t).find(f=>w.isValidElement(f)),a=(w.isValidElement(i)?i.props.className??"":"").match(/(?:^|\s)language-([\w+-]+)/)?.[1]??"代码",o=Xf(t).replace(/\n$/,"");return c.jsxs("div",{className:"message-code-block",children:[c.jsxs("div",{className:"message-code-heading",children:[c.jsx("span",{children:a}),c.jsx(vo,{text:o,label:"复制代码"})]}),c.jsx("pre",{tabIndex:0,children:t})]})}function XN(t){return{a:({href:i,children:l,title:a})=>{const o=Qf(i??"");if(o)return c.jsx("a",{href:o,title:a,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:l});const f=i?rb(i):void 0;return f?c.jsxs("span",{className:"message-file-reference",title:f,children:[t?c.jsx("button",{className:"message-file-open",onClick:()=>t(f),children:l}):l,c.jsx(vo,{text:f,label:"复制路径"})]}):c.jsx("span",{children:l})},img:({src:i,alt:l})=>{const a=Qf(typeof i=="string"?i:""),o=typeof i=="string"?rb(i):void 0;return a?c.jsxs("a",{className:"message-image-reference",href:a,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:[l||"图片",c.jsx("span",{children:"打开图片 ↗"})]}):o&&t?c.jsxs("button",{className:"message-image-reference",title:o,onClick:()=>t(o),children:[l||"图片",c.jsx("span",{children:"查看图片"})]}):c.jsxs("span",{className:"message-image-reference",children:[l||"图片",c.jsx("span",{children:"图片路径不可直接访问"})]})},pre:({children:i})=>c.jsx($N,{children:i}),table:({children:i})=>c.jsx("div",{className:"message-table-scroll",role:"region","aria-label":"表格",tabIndex:0,children:c.jsx("table",{children:i})})}}const KN=w.memo(function({text:i,reasoning:l="",streaming:a=!1,onOpenFile:o}){const f=w.useMemo(()=>XN(o),[o]);return c.jsxs("div",{className:"message-content",children:[l?c.jsxs("details",{className:"message-reasoning",children:[c.jsx("summary",{children:a&&!i?"思考中…":"思考过程"}),c.jsx("pre",{children:l})]}):null,a?c.jsxs("div",{className:"message-streaming",children:[i||(l?"":"正在思考…"),c.jsx("span",{className:"cursor","aria-hidden":"true",children:"▍"})]}):i?c.jsx(DC,{remarkPlugins:[FN],skipHtml:!0,urlTransform:u=>Qf(u)??($f(u)?u:""),components:f,children:i}):null,!a&&i?c.jsx("div",{className:"message-actions",children:c.jsx(vo,{text:i,label:"复制回复"})}):null]})});function PN(t){const i=t.args??{},l=t.summary||[i.description,i.command,i.file_path,i.path,i.query,i.url].find(a=>typeof a=="string"&&a.trim());return typeof l=="string"?l.replace(/\s+/g," ").slice(0,180):""}const ZN=w.memo(function({item:i,running:l}){const a=PN(i),o=i.done?i.error?"失败":"已完成":l?"执行中":"未完成";return c.jsxs("details",{className:`message-tool-card${i.error?" message-tool-error":""}`,children:[c.jsxs("summary",{children:[c.jsx("span",{className:"message-tool-indicator","aria-hidden":"true",children:i.done?i.error?"!":"✓":"·"}),c.jsx("span",{className:"message-tool-name",children:i.name}),c.jsx("span",{className:"message-tool-summary",children:a}),c.jsx("span",{className:"message-tool-status",children:o})]}),i.args&&Object.keys(i.args).length?c.jsxs("div",{className:"message-tool-section",children:[c.jsx("strong",{children:"参数"}),c.jsx("pre",{tabIndex:0,children:JSON.stringify(i.args,null,2)})]}):null,c.jsxs("div",{className:"message-tool-section",children:[c.jsxs("div",{className:"message-tool-result-heading",children:[c.jsx("strong",{children:"结果"}),i.result?c.jsx(vo,{text:i.result,label:"复制结果"}):null]}),c.jsx("pre",{tabIndex:0,children:i.result??(i.done?"工具没有返回文本内容。":l?"等待工具返回结果…":"这次工具调用没有保存结果。")})]})]})});function JN(t){return{running:"运行中",completed:"已完成",error:"失败",recorded:"历史记录"}[t]??t}function WN(t){const i=new URLSearchParams(t).get("session");return i&&/^[a-zA-Z0-9_-]{1,128}$/.test(i)?i:null}function Bv(t,i){return!i||!t.hubEpoch||t.hubSequence===void 0?!0:t.hubEpoch===i.epoch&&t.hubSequence>i.sequence}function lb(t,i=[]){let l=Eb(t.transcript);for(const o of t.liveStream?.events??[])l=mr(l,o.event);t.running?l={...l,run:"running"}:t.running===!1&&(l.run==="running"||l.run==="waiting")&&(l={...l,run:"idle"});let a=t.streamCursor;for(const o of i)Bv(o,a)&&(l=mr(l,o.event),o.hubEpoch&&o.hubSequence!==void 0&&(a={epoch:o.hubEpoch,sequence:o.hubSequence}));return{chat:l,cursor:a,truncated:t.liveStream?.truncated??!1}}async function eA(t,i,l,a,o,f=()=>!0){let u=t.outputJournal??await i({});if(!f())throw new Error("Output recovery cancelled");if(u.status==="unavailable"){const v=o?await o():t.outputCoverage;if(!f())throw new Error("Output recovery cancelled");for(const j of[t.outputCoverage,v])ua({unpaired:j?.unpaired,inputIds:j?.inputIds},{},()=>!1);if(v?.outputCursor||a?.()||l.some(j=>j.event.outputCursor)){if(u=await i({}),u.status==="unavailable")throw new Error("Output recovery journal is unavailable")}else{if(v?.journalIdentity||t.outputCoverage?.journalIdentity)throw new Error("Output recovery journal is unavailable");return null}}if(u.status!=="ok"||!u.legacyBaseThroughEventId||t.transcript[0]?.type!=="session_meta")throw new Error("Output recovery has no complete legacy base");const m=t.transcript.findIndex(v=>v.id===u.legacyBaseThroughEventId);if(m<0)throw new Error("Output recovery legacy anchor was not retained");let h=Eb(t.transcript.slice(0,m+1)),p={incomplete:!1},y=0;const b=async()=>{for(;;){if(!f()||++y>2048)throw new Error("Output recovery exceeded its page budget");const v=RS(p,u,j=>{h=mr(h,j)});if(p.incomplete)throw new Error("Output recovery is incomplete");if(v)break;u=await i({after:p.cursor,through:p.through})}};await b();for(let v=0;v<8;v++){const j=o?await o():t.outputCoverage;if(!f())throw new Error("Output recovery cancelled");ua({...j,inputIds:void 0},u,()=>!0);let D;for(const A of[j?.outputCursor,a?.(),...l.map(R=>R.event.outputCursor)]){if(typeof A!="string")continue;const R=D?ga(A,D):1;if(R===void 0)throw new Error("Output recovery journal changed");R>0&&(D=A)}if(typeof D!="string"){j&&ua(j,u,A=>h.items.some(R=>R.kind==="user"&&R.clientMessageId===A));break}const N=ga(D,p.cursor);if(N===void 0)throw new Error("Output recovery journal changed");if(N<=0){j&&ua(j,u,A=>h.items.some(R=>R.kind==="user"&&R.clientMessageId===A));break}if(v===7)throw new Error("Output recovery could not catch up within its round budget");p={incomplete:!1,cursor:p.appliedCursor},u=await i({after:p.cursor,through:D}),await b()}const x=new rd;for(const v of l)x.observe(v.event);ua({unpaired:x.incomplete,inputIds:x.inputIds},u,v=>h.items.some(j=>j.kind==="user"&&j.clientMessageId===v),{requireIdentity:!1});for(const v of l){const j=v.event.outputCursor;if(typeof j=="string"){const D=ga(j,p.cursor);if(D===void 0)throw new Error("Output recovery journal changed");if(D<=0)continue;p.cursor=j}else if(v.event.type==="session_title"){h=mr(h,v.event);continue}else{if(v.event.type==="session_user_message"&&typeof v.event.clientMessageId=="string"&&h.items.some(D=>D.kind==="user"&&D.clientMessageId===v.event.clientMessageId))continue;throw new Error("Output recovery received an unpaired legacy event")}h=mr(h,v.event)}return{chat:h,outputCursor:p.cursor}}function Uv(t,i){if(t?.title)return t.title;const l=t?.items.find(a=>a.kind==="user");if(l&&l.kind==="user"&&l.text.trim()){const a=l.text.trim().split(`
|
|
57
|
-
`)[0];return a.length>32?`${a.slice(0,32)}…`:a}return l?.kind==="user"&&l.attachments?.length?`附件:${l.attachments[0].name}`:i.slice(0,8)}function tA(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(l=>!l.sessionId||l.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 nA({controller:t,onBackToProjects:i,projectName:l}){const{connection:a,sessions:o,activeId:f,chat:u,draft:m,files:h,uploading:p,workerNote:y,replayNote:b,error:x,workspaceCwd:v,workspaceName:j,configuration:D,configurationVersion:N,sessionsVersion:A,localDrafts:R,running:O,title:Y,approvalCount:re,onAuthLost:T,refreshSessions:V,refreshConfiguration:Q,session:I}=t,C=t.workspaceApi,B=t.host==="desktop"?"桌面":"服务端",[U,$]=w.useState(!1),ee=w.useRef(null),K=w.useRef(null),[z,Z]=w.useState(()=>new URLSearchParams(window.location?.search??"").get("view")==="links"?"links":"chat"),[he,me]=w.useState(),[k,L]=w.useState(),[J,_]=w.useState(0),[te,xe]=w.useState(!1),[ae,se]=w.useState(null),[ye,F]=w.useState("overview"),[we,Le]=w.useState(()=>window.matchMedia("(max-width: 760px)").matches),[Ae,Te]=w.useState(()=>!window.matchMedia("(max-width: 760px)").matches),tt=w.useRef(null),ut=w.useRef(null),Ge=w.useRef(!1),Lt=w.useRef(null),ct=w.useRef(null),qe=w.useRef(!0);w.useEffect(()=>{me(void 0),Z(oe=>oe==="panel"?"panels":oe)},[t.workspaceKey]),w.useEffect(()=>{we&&!Ae&&Ge.current&&!U&&ut.current?.focus(),Ge.current=Ae},[we,Ae,U]),w.useEffect(()=>{const oe=window.matchMedia("(max-width: 760px)"),_e=()=>{Le(oe.matches),Te(!oe.matches)};return oe.addEventListener("change",_e),()=>oe.removeEventListener("change",_e)},[]),w.useEffect(()=>{if(!we||!Ae)return;const oe=tt.current;oe?.querySelector("button")?.focus();const _e=Ee=>{if(!document.querySelector("dialog[open]")){if(Ee.key==="Escape"&&!Ee.isComposing)Ee.preventDefault(),Te(!1),ut.current?.focus();else if(Ee.key==="Tab"){const Me=Array.from(oe?.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), textarea:not(:disabled), a[href], summary, [tabindex]:not([tabindex="-1"])')??[]).filter(ve=>ve.getClientRects().length>0),ze=Me?.[0],W=Me?.[Me.length-1];Ee.shiftKey&&document.activeElement===ze?(Ee.preventDefault(),W?.focus()):!Ee.shiftKey&&document.activeElement===W&&(Ee.preventDefault(),ze?.focus())}}};return document.addEventListener("keydown",_e),()=>document.removeEventListener("keydown",_e)},[we,Ae]),w.useLayoutEffect(()=>{const oe=ct.current;!oe||z!=="chat"||(oe.style.height="auto",oe.style.height=`${Math.min(180,Math.max(64,oe.scrollHeight))}px`)},[m,z]),w.useLayoutEffect(()=>{const oe=Lt.current;oe&&qe.current&&z==="chat"&&(oe.scrollTop=oe.scrollHeight)},[u.items,t.approvals.length,z]);const ht=()=>{we&&(Te(!1),ut.current?.focus())},Fe=oe=>{if(z==="settings"&&ye===oe){ht();return}nt(()=>{F(oe),Z("settings"),ht()})},nt=oe=>{te?se(()=>oe):oe()},Et=oe=>nt(()=>{L(oe),_(_e=>_e+1),Z("files"),ht()}),lt=w.useRef(Et);lt.current=Et;const bt=w.useCallback(oe=>lt.current(oe),[]);w.useEffect(()=>{if(!te&&!t.uploadBusy&&!t.hasUnsent)return;const oe=_e=>{_e.preventDefault(),_e.returnValue=""};return window.addEventListener("beforeunload",oe),()=>window.removeEventListener("beforeunload",oe)},[te,t.uploadBusy,t.hasUnsent]);const M=oe=>nt(()=>{Z("chat"),ht(),qe.current=!0,oe()}),P=oe=>M(()=>{t.selectSession(oe)}),ge=()=>M(t.newSession),Se=()=>{qe.current=!0,t.send()},Ce=t.stop,Re=t.approvals.filter(oe=>!oe.sessionId||oe.sessionId===f),Qe=t.approvals.filter(oe=>oe.sessionId&&oe.sessionId!==f),yt=u.items.length===0&&Re.length===0,pt=D?.connections.find(oe=>oe.id===D.defaults.text),mt=a==="open"?"已连接":a==="connecting"?"连接中":"正在重连",Ze=z==="chat"?Y:z==="files"?"工作区文件":z==="history"?"历史对话":z==="links"?"Link":z==="panels"||z==="panel"?he&&z==="panel"?he.panel.title["zh-CN"]||he.panel.title.default:"面板":ye==="skills"?"Skills":"设置";return c.jsxs("div",{className:`shell${Ae?" sidebar-open":""}`,children:[we&&Ae?c.jsx("div",{className:"sidebar-backdrop",onClick:()=>{Te(!1),ut.current?.focus()},"aria-hidden":"true"}):null,c.jsxs("aside",{id:"workbench-sidebar",ref:tt,className:"rail",hidden:!Ae,role:we?"dialog":void 0,"aria-modal":we&&Ae?!0:void 0,"aria-label":"工作台导航",children:[c.jsxs("div",{className:"rail-head",children:[c.jsx("span",{className:"brand-mark",children:c.jsx(Mt,{name:"brand"})}),c.jsx("strong",{children:"CodeShell"}),c.jsx("span",{className:"hub-badge",children:t.host==="desktop"?"Desktop":C?"Hub":"Web"}),c.jsx("button",{className:"icon-button sidebar-close","aria-label":"收起侧栏",onClick:()=>{Te(!1),ut.current?.focus()},children:c.jsx(Mt,{name:"sidebar"})})]}),c.jsx(ed,{discover:t.workspaceApi,navigate:oe=>{const _e=()=>window.location.assign(oe);te||t.hasUnsent||t.uploadBusy?se(()=>_e):_e()}}),c.jsxs("nav",{className:"workbench-nav","aria-label":"主要功能",children:[i?c.jsxs("button",{className:"nav-button",title:l,onClick:()=>{te||t.hasUnsent||t.uploadBusy?se(()=>i):i()},children:[c.jsx(Mt,{name:"folder"}),c.jsx("span",{children:"返回项目列表"})]}):null,c.jsxs("button",{className:"nav-button new-chat-button",onClick:ge,children:[c.jsx(Mt,{name:"plus"}),c.jsx("span",{children:"新对话"})]}),c.jsxs("button",{className:`nav-button${z==="chat"?" active":""}`,onClick:()=>{nt(()=>{Z("chat"),ht()})},"aria-current":z==="chat"?"page":void 0,children:[c.jsx(Mt,{name:"chat"}),c.jsx("span",{children:"对话"})]}),C?c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:`nav-button${z==="history"?" active":""}`,onClick:()=>nt(()=>{Z("history"),ht()}),"aria-current":z==="history"?"page":void 0,children:[c.jsx(Mt,{name:"history"}),c.jsx("span",{children:"历史对话"})]}),c.jsxs("button",{className:`nav-button${z==="files"?" active":""}`,onClick:()=>Et(),"aria-current":z==="files"?"page":void 0,children:[c.jsx(Mt,{name:"folder"}),c.jsx("span",{children:"文件"})]}),c.jsxs("button",{className:`nav-button${z==="settings"&&ye==="skills"?" active":""}`,onClick:()=>Fe("skills"),"aria-current":z==="settings"&&ye==="skills"?"page":void 0,children:[c.jsx(Mt,{name:"skills"}),c.jsx("span",{children:"Skills"})]}),c.jsxs("button",{className:`nav-button${z==="panels"||z==="panel"?" active":""}`,onClick:()=>nt(()=>{Z("panels"),ht()}),"aria-current":z==="panels"||z==="panel"?"page":void 0,children:[c.jsx(Mt,{name:"panels"}),c.jsx("span",{children:"面板"})]}),c.jsxs("button",{className:`nav-button${z==="links"?" active":""}`,onClick:()=>nt(()=>{Z("links"),ht()}),"aria-current":z==="links"?"page":void 0,children:[c.jsx(Mt,{name:"links"}),c.jsx("span",{children:"Link"})]}),c.jsxs("button",{className:`nav-button${z==="settings"&&ye!=="skills"?" active":""}`,onClick:()=>Fe("overview"),"aria-current":z==="settings"&&ye!=="skills"?"page":void 0,children:[c.jsx(Mt,{name:"settings"}),c.jsx("span",{children:"设置"})]})]}):null]}),c.jsx("div",{className:"rail-section-label",children:"工作区"}),C?c.jsxs("button",{className:"workspace-button",title:v??void 0,onClick:()=>Et(),children:[c.jsx(Mt,{name:"folder"}),c.jsx("span",{children:l??j}),c.jsx(Mt,{name:"chevron"})]}):c.jsxs("div",{className:"workspace-button",title:v??void 0,children:[c.jsx(Mt,{name:"folder"}),c.jsx("span",{children:l??j})]}),c.jsxs("div",{className:"rail-section-label history-label",children:[c.jsx("span",{children:"最近对话"}),c.jsx("span",{children:o.length})]}),t.renderSidebar?.({guard:nt,conversation:M}),c.jsxs("ul",{className:"sessions","aria-label":"最近对话",children:[R.map(({sessionId:oe,draft:_e})=>c.jsx("li",{children:c.jsxs("button",{className:oe===f&&z==="chat"?"session active":"session",onClick:()=>{P(oe)},children:[c.jsx("span",{className:"session-title",children:_e.text.trim()||`附件:${_e.files[0]?.name??"新对话"}`}),c.jsx("span",{className:"session-meta",children:"草稿"})]})},`draft-${oe}`)),o.map(oe=>c.jsx("li",{children:c.jsxs("button",{className:oe.sessionId===f&&z==="chat"?"session active":"session",onClick:()=>{P(oe.sessionId)},"aria-current":oe.sessionId===f&&z==="chat"?"page":void 0,children:[c.jsx("span",{className:"session-title",children:oe.sessionId===f?oe.customTitle||u.title||oe.title||Uv(u,oe.sessionId):oe.title||oe.preview?.trim()||oe.sessionId.slice(0,8)}),c.jsxs("span",{className:"session-meta",children:[t.unreadSessionIds?.has(oe.sessionId)&&oe.sessionId!==f?c.jsxs("span",{className:"session-unread","aria-label":"有新消息",children:["●"," "]}):null,re(oe.sessionId)?`${re(oe.sessionId)} 项待审批`:oe.running?"进行中":rA(oe.status),t.showTurnCounts!==!1?c.jsxs("span",{children:[" · ",oe.turnCount," 轮"]}):null]})]})},oe.sessionId)),o.length===0&&R.length===0?c.jsx("li",{className:"empty",children:"开始对话后,记录会保存在这里。"}):null]}),c.jsxs("div",{className:"rail-footer",children:[c.jsxs("div",{className:"host-label",children:[c.jsx("span",{className:`dot ${a}`}),c.jsxs("span",{children:[B,mt]})]}),t.host==="hub"?c.jsxs("button",{className:"account-button",onClick:()=>{ht(),$(!0)},children:[c.jsx("span",{className:"account-avatar",children:(I?.username||"C").slice(0,1).toUpperCase()}),c.jsxs("span",{className:"account-copy",children:[c.jsx("strong",{children:I?.username||"账号"}),c.jsx("span",{children:"设备与退出"})]}),c.jsx(Mt,{name:"chevron"})]}):null,t.logout?c.jsxs("button",{className:"account-button",onClick:t.logout,children:[c.jsx("span",{className:"account-avatar",children:(t.accountName||"D").slice(0,1)}),c.jsxs("span",{className:"account-copy",children:[c.jsx("strong",{children:t.accountName||"已配对设备"}),c.jsx("span",{children:"退出此设备"})]})]}):null]})]}),c.jsxs("main",{className:"workbench-main",inert:we&&Ae?!0:void 0,children:[c.jsxs("header",{className:"workbench-topbar",children:[c.jsx("button",{ref:ut,className:"icon-button","aria-label":Ae?"收起侧栏":"展开侧栏","aria-expanded":Ae,"aria-controls":"workbench-sidebar",onClick:()=>Te(oe=>!oe),children:c.jsx(Mt,{name:"sidebar"})}),c.jsxs("div",{className:"topbar-context",children:[c.jsx("span",{className:"topbar-project","aria-label":"当前项目",title:l??j,children:l??j}),c.jsx("span",{className:"topbar-title",title:Ze,children:Ze})]}),c.jsxs("span",{className:"connection-pill",title:`任务在${B}工作区执行`,children:[c.jsx("span",{className:`dot ${a}`}),c.jsx("span",{children:B})]})]}),y?c.jsx("div",{className:"banner",children:y}):null,b?c.jsx("div",{className:"banner",children:b}):null,x?c.jsxs("div",{className:"banner form-error",role:"alert",children:[x,c.jsx("button",{className:"ghost","aria-label":"关闭错误提示",onClick:t.clearError,children:"×"})]}):null,Qe.length?c.jsxs("div",{className:"banner",children:["其他会话有待处理审批。",Qe.map(oe=>c.jsxs("button",{className:"ghost",onClick:()=>{P(oe.sessionId)},children:["打开 ",oe.sessionId.slice(0,8)]},oe.id))]}):null,a!=="open"?c.jsxs("div",{className:"banner",children:["连接",a==="connecting"?"中…":"已断开,重连中…"]}):null,z!=="chat"&&Re.length>0?c.jsxs("div",{className:"banner",children:["当前对话需要你的确认。",c.jsx("button",{className:"ghost",onClick:()=>nt(()=>Z("chat")),children:"返回对话"})]}):null,c.jsxs("section",{className:`chat${yt?" chat-empty":""}`,hidden:z!=="chat","aria-label":"对话",children:[c.jsx("div",{className:"messages",ref:Lt,onScroll:oe=>{const _e=oe.currentTarget;qe.current=_e.scrollHeight-_e.scrollTop-_e.clientHeight<100},children:c.jsxs("div",{className:"transcript",children:[t.chatControls,t.loading?c.jsx("div",{className:"banner",role:"status",children:"正在恢复会话记录…"}):null,u.goal?c.jsxs("div",{className:"banner goal",children:[c.jsx("span",{children:u.goal}),t.goalActions]}):null,u.items.map(oe=>{switch(oe.kind){case"user":return c.jsxs("div",{className:"msg user",children:[oe.text,oe.attachments?.map((_e,Ee)=>C&&_e.path?c.jsxs("button",{className:"attachment attachment-open",onClick:()=>Et(_e.path),children:["📎 ",_e.name]},Ee):c.jsxs("span",{className:"attachment",children:["📎 ",_e.name]},Ee))]},oe.id);case"assistant":return oe.done&&!oe.text&&!oe.reasoning?null:c.jsx("div",{className:"msg assistant",children:c.jsx(KN,{text:oe.text,reasoning:oe.reasoning,streaming:!oe.done,onOpenFile:C?bt:void 0})},oe.id);case"tool":return c.jsx("div",{className:`msg tool${oe.error?" tool-error":""}`,children:c.jsx(ZN,{item:oe,running:O})},oe.id);case"subagent":return c.jsxs("div",{className:"msg info",children:["↳ ",oe.label," · ",JN(oe.status)]},oe.id);case"system":return c.jsx("div",{className:"msg info",children:oe.text},oe.id);case"system_error":return c.jsx("div",{className:"msg error",children:oe.text},oe.id);default:return null}}),t.approvalContent,yt?c.jsxs("div",{className:"empty-chat",children:[c.jsx("span",{className:"welcome-mark",children:c.jsx(Mt,{name:"brand"})}),c.jsx("h1",{children:"今天想完成什么?"}),c.jsx("p",{children:"从一个问题或想法开始,让 CodeShell 帮你一步步完成。"}),c.jsxs("span",{className:"welcome-workspace",children:[c.jsx(Mt,{name:"folder"}),l??j]})]}):null]})}),t.readOnlyNote?c.jsx("div",{className:"banner",children:t.readOnlyNote}):null,c.jsxs("div",{className:"composer-wrap",children:[c.jsxs("footer",{className:"composer",children:[h.length||p&&t.host==="hub"?c.jsxs("div",{className:"attachments","aria-live":"polite",children:[h.map(oe=>c.jsxs("span",{className:"attachment",children:[c.jsx(Mt,{name:"attachment"}),oe.name,c.jsx("button",{className:"ghost","aria-label":`移除 ${oe.name}`,onClick:()=>{t.removeFile(oe.id)},children:"×"})]},oe.id)),p&&t.host==="hub"?c.jsx("span",{children:"正在上传…"}):null]}):null,c.jsx("textarea",{ref:ct,"aria-label":"任务内容",value:m,disabled:t.readOnly,rows:2,placeholder:"描述你的任务,或提出一个问题…",onChange:oe=>{t.setDraft(oe.target.value)},onKeyDown:oe=>{oe.key==="Enter"&&!oe.shiftKey&&!oe.nativeEvent.isComposing&&(oe.preventDefault(),Se())}}),c.jsxs("div",{className:"composer-toolbar",children:[C?c.jsxs(c.Fragment,{children:[c.jsx("input",{hidden:!0,multiple:!0,type:"file",accept:t.attachmentAccept,ref:ee,onChange:oe=>{const _e=oe.currentTarget;Promise.resolve(t.addFiles(_e.files)).finally(()=>{_e.value=""})}}),c.jsx("button",{className:"icon-button attach-button","aria-label":"添加附件",title:"添加附件",disabled:t.uploadBusy||a!=="open"||t.readOnly,onClick:()=>ee.current?.click(),children:c.jsx(Mt,{name:"plus"})}),t.cameraAttachments?c.jsxs(c.Fragment,{children:[c.jsx("input",{hidden:!0,type:"file",accept:"image/*",capture:"environment",ref:K,onChange:oe=>{const _e=oe.currentTarget;Promise.resolve(t.addFiles(_e.files)).finally(()=>{_e.value=""})}}),c.jsx("button",{className:"icon-button attach-button","aria-label":"拍照",title:"拍照",disabled:t.uploadBusy||a!=="open"||t.readOnly,onClick:()=>K.current?.click(),children:c.jsx(Mt,{name:"camera"})})]}):null,c.jsxs("button",{className:"model-button",title:"打开模型设置",onClick:()=>Fe("models"),children:[c.jsx("span",{children:pt?.model||"配置模型"}),c.jsx(Mt,{name:"chevron"})]})]}):null,c.jsx("span",{className:"composer-run-status",role:"status",children:t.uncertain?"正在核对消息…":p?t.host==="desktop"?"正在发送…":"正在上传附件…":Re.length?"等待你的确认":O?"正在处理…":""}),O?c.jsx("button",{className:"stop composer-submit","aria-label":"停止",title:"停止",onClick:Ce,disabled:a!=="open",children:c.jsx(Mt,{name:"stop"})}):c.jsx("button",{className:"send composer-submit","aria-label":"发送",title:"发送",onClick:Se,disabled:a!=="open"||p||t.uncertain||t.readOnly||!m.trim()&&!h.length,children:c.jsx(Mt,{name:"send"})})]})]}),c.jsxs("div",{className:"composer-caption",children:[c.jsxs("span",{children:["任务在",B,"工作区执行"]}),c.jsx("span",{children:"Enter 发送 · Shift + Enter 换行"})]})]})]}),z==="settings"&&C?c.jsx(aS,{host:t.host==="desktop"?"desktop":"hub",section:ye,onSectionChange:Fe,onAuthLost:T,onConfigurationChange:()=>{Q()},configurationVersion:N,onDirtyChange:xe},`${t.workspaceKey}:settings`):null,z==="files"&&C?c.jsx(hS,{initialPath:k,openVersion:J,onAuthLost:T},`${t.workspaceKey}:files`):null,z==="history"&&C?c.jsx(pS,{onAuthLost:T,onOpen:oe=>{P(oe)},onChanged:()=>{V()},version:A,onDirtyChange:xe},`${t.workspaceKey}:history`):null,z==="links"&&C?c.jsx(aw,{onAuthLost:T,onDirtyChange:xe,hostLabel:B,configurationVersion:N},`${t.workspaceKey}:links`):null,z==="panels"&&C?c.jsx(sw,{onAuthLost:T,onDirtyChange:xe,onChanged:()=>{Q()},hostLabel:B,configurationVersion:N,onOpen:oe=>nt(()=>{me({panel:oe,workspaceKey:t.workspaceKey}),Z("panel"),ht()})},`${t.workspaceKey}:panels`):null,z==="panel"&&C&&he?.workspaceKey===t.workspaceKey?c.jsx(xw,{panel:he.panel,sessionId:f,busy:O||p||t.uncertain,onAuthLost:T,onDirtyChange:xe,onClose:()=>nt(()=>Z("panels")),onSubmitPrompt:async oe=>tA(t,{...oe,workspaceKey:he.workspaceKey})},`${t.workspaceKey}:panel:${he.panel.id}:${f}`):null]}),ae?c.jsx(iA,{onStay:()=>se(null),onLeave:()=>{const oe=ae;se(null),xe(!1),oe()}}):null,U&&t.host==="hub"?c.jsx(N1,{session:I,onClose:()=>$(!1),onAuthLost:T}):null]})}function iA({onStay:t,onLeave:i}){const l=w.useRef(null);return w.useEffect(()=>{const a=document.activeElement;return l.current?.showModal(),()=>{l.current?.close(),a?.focus()}},[]),c.jsxs("dialog",{className:"navigation-prompt",ref:l,"aria-labelledby":"navigation-prompt-title",onCancel:a=>{a.preventDefault(),t()},children:[c.jsx("h2",{id:"navigation-prompt-title",children:"还有未保存的修改"}),c.jsx("p",{children:"离开会丢弃未提交的修改;切换项目还会清除未发送的草稿和附件。已经提交的操作可能仍会完成,请等待结果后再离开。"}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button primary",onClick:t,autoFocus:!0,children:"留在此页"}),c.jsx("button",{className:"library-button",onClick:i,children:"放弃修改并离开"})]})]})}function rA(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:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),c.jsx("path",{d:"M15 3v18M15 10h6"})]}),camera:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M3 7h4l2-3h6l2 3h4v13H3Z"}),c.jsx("circle",{cx:"12",cy:"13",r:"4"})]}),links:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-2 2"}),c.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l2-2"})]}),brand:c.jsx(c.Fragment,{children:c.jsx("path",{d:"m5 7 5 5-5 5M13 17h6"})}),sidebar:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),c.jsx("path",{d:"M9 4v16"})]}),plus:c.jsx("path",{d:"M12 5v14M5 12h14"}),chat:c.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:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),c.jsx("path",{d:"M3 3v5h5M12 7v5l3 2"})]}),skills:c.jsx(c.Fragment,{children:c.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:c.jsxs(c.Fragment,{children:[c.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"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),folder:c.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:c.jsx("path",{d:"m9 5 7 7-7 7"}),attachment:c.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:c.jsx("path",{d:"M12 19V5m-6 6 6-6 6 6"}),stop:c.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2",fill:"currentColor",stroke:"none"})};return c.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 vi extends Error{constructor(i,l,a){super(i),this.kind=l,this.code=a,this.name="ProtocolRequestError"}kind;code}const lA=3e4,ab=800,aA=15e3;class sA{constructor(i){this.url=i}url;ws=null;nextId=1;pending=new Map;notificationHandlers=new Set;stateHandlers=new Set;reconnectDelay=ab;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=ab,this.emitState("open"))},i.onmessage=l=>{if(this.ws!==i||this.closedByUser)return;let a;try{if(a=JSON.parse(String(l.data)),!a||typeof a!="object"||Array.isArray(a))return}catch{return}if(a.id!==void 0&&a.method===void 0){const o=this.pending.get(String(a.id));if(!o)return;this.pending.delete(String(a.id)),clearTimeout(o.timer),a.error?o.reject(new vi(a.error.message??"request failed","response",a.error.code)):o.resolve(a.result);return}if(a.method)for(const o of this.notificationHandlers)o(a.method,a.params??{})},i.onclose=l=>{if(this.ws===i){if(this.ws=null,this.emitState("closed"),this.failAllPending(new vi("connection closed","transport")),l.code===4401||l.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,aA))}},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 vi("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,l,a=lA){const o=this.ws;if(!o||o.readyState!==WebSocket.OPEN)return Promise.reject(new vi("not connected","not-sent"));const f=`web-${this.nextId++}`;return new Promise((u,m)=>{const h=a>0?setTimeout(()=>{this.pending.delete(f),m(new vi(`request timed out: ${i}`,"timeout"))},a):void 0;this.pending.set(f,{resolve:u,reject:m,timer:h});try{o.send(JSON.stringify({jsonrpc:"2.0",id:f,method:i,params:l}))}catch(p){clearTimeout(h),this.pending.delete(f),m(new vi(p instanceof Error?p.message:"send failed","not-sent"))}})}run(i){return this.request("agent/run",i,0)}listSessions(){return this.request("agent/query",{type:"sessions"})}sessionDetail(i,l=!1){return this.request("agent/query",{type:"session_detail",sessionId:i,...l?{outputRecovery:!0}:{}})}outputCoverage(i){return this.request("agent/query",{type:"output_coverage",sessionId:i})}outputJournal(i,l={}){return this.request("agent/query",{type:"output_journal",sessionId:i,...l})}approve(i,l,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:l?{approved:!0,...a?{answer:a}:{}}:{approved:!1}})}cancel(i){return this.request("agent/cancel",{sessionId:i})}emitState(i){for(const l of this.stateHandlers)l(i)}failAllPending(i){for(const[,l]of this.pending)clearTimeout(l.timer),l.reject(i);this.pending.clear()}}function oA(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}${St("/ws")}`}function uA(t,i){const{method:l,params:a}=i;if(l==="serve/approvalSnapshot"){if(!Array.isArray(a.approvals))return t;const f={};for(const u of a.approvals)u?.requestId&&u.request&&(f[u.requestId]={payload:u});return f}if(l==="agent/approvalRequest"){const f=a;return!f.requestId||!f.request?t:{...t,[f.requestId]:{...t[f.requestId],payload:f}}}const o=a.requestId;if(typeof o!="string"||!t[o])return t;if(l==="agent/approvalResolved"){const f={...t};return delete f[o],f}return l==="serve/approvalLease"?{...t,[o]:{...t[o],lease:a}}:t}class cA{drafts=new Map;get(i){return this.drafts.get(i)??{text:"",files:[],revision:0}}update(i,l){const a={...l,revision:this.get(i).revision+1};return this.drafts.set(i,a),a}setText(i,l){return this.update(i,{...this.get(i),text:l})}addFile(i,l){const a=this.get(i);return this.update(i,{...a,files:[...a.files,l]})}removeFile(i,l){const a=this.get(i);return this.update(i,{...a,files:a.files.filter(o=>o.id!==l)})}take(i){const l=this.get(i),a=this.update(i,{text:"",files:[]});return{sessionId:i,draft:l,clearedRevision:a.revision}}restore(i){const l=this.get(i.sessionId);return l.revision!==i.clearedRevision||l.text||l.files.length?!1:(this.update(i.sessionId,i.draft),!0)}unsent(){return[...this.drafts].flatMap(([i,l])=>l.text.trim()||l.files.length?[{sessionId:i,draft:l}]:[])}}function fA({payload:t,onDecide:i,busy:l,connected:a}){const[o,f]=w.useState(""),u=t.request.toolName==="__ask_user__",{summary:m,risk:h}=NS(t.request.args,t.request.riskLevel,t.request.toolName);return c.jsxs("div",{className:"approval",children:[c.jsxs("div",{className:"approval-title",children:[u?"Agent 提问":`工具审批:${t.request.toolName}`,u?null:c.jsxs("em",{children:[" · ",h]})]}),t.request.description?c.jsx("div",{className:"approval-desc",children:t.request.description}):null,u?null:c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"approval-summary",children:m}),c.jsxs("details",{className:"approval-raw",children:[c.jsx("summary",{children:"原始参数"}),c.jsx("pre",{className:"approval-args",children:JSON.stringify(t.request.args,null,2)})]})]}),u?c.jsx("textarea",{className:"approval-answer",value:o,placeholder:"输入回答…",onChange:p=>f(p.target.value)}):null,l?c.jsx("span",{className:"muted",role:"status",children:"设备正在处理此审批…"}):null,c.jsxs("div",{className:"approval-actions",children:[c.jsx("button",{className:"send",disabled:l||!a||u&&!o.trim(),onClick:()=>i(t,!0,u?o:void 0),children:u?"回答":"允许"}),c.jsx("button",{className:"stop",disabled:l||!a,onClick:()=>i(t,!1),children:"拒绝"})]})]})}function sb(){return Ea()}const dA=()=>{},hA=async()=>{};function pA({session:t,hub:i=!1,onAuthLost:l=dA,onCheckAuth:a=hA}){const o=w.useRef(null),[f,u]=w.useState("connecting"),[m,h]=w.useState([]),p=w.useRef([]),[y,b]=w.useState(()=>WN(window.location.search)??sb()),[x,v]=w.useState(eo()),[j,D]=w.useReducer(uA,{}),[N,A]=w.useState({}),[R,O]=w.useState(""),[Y,re]=w.useState([]),T=w.useRef(new cA),[V,Q]=w.useState(0),[I,C]=w.useState(null),B=I===y,[U,$]=w.useState(null),[ee,K]=w.useState(null),[z,Z]=w.useState(""),[he,me]=w.useState(Date.now()),[k,L]=w.useState(0),[J,_]=w.useState(null),[te,xe]=w.useState(0),ae=w.useRef(0),se=w.useRef(y),ye=w.useRef(null),F=w.useRef(null),we=w.useRef(!1),Le=w.useRef(new Map),Ae=w.useRef(new Map),Te=w.useRef(new Set),tt=w.useRef(new Set),ut=w.useRef(new Set),Ge=w.useRef(!1),Lt=w.useRef(null),ct=w.useRef(null),qe=w.useCallback(W=>{if(Q(Be=>Be+1),se.current!==W)return;const ve=T.current.get(W);O(ve.text),re(ve.files)},[]);w.useEffect(()=>{const W=new URL(window.location.href);W.searchParams.set("session",y),window.history.replaceState(window.history.state,"",W)},[y]);const ht=w.useCallback((W,ve)=>{const Be=T.current.restore(W.draft);qe(W.draft.sessionId),se.current===W.draft.sessionId&&(v(ke=>({...ke,run:"error",items:ke.items.filter(q=>q.kind!=="user"||q.clientMessageId!==W.clientMessageId)})),Be&&Z(`${ve?`${ve} `:"消息未送达。"}内容和附件已恢复,可以重试。`))},[qe]),Fe=w.useCallback(W=>{Ge.current&&(W instanceof Pe&&W.status===401?l():Z(W instanceof Error?W.message:"操作失败,请重试。"))},[l]),nt=w.useCallback(async()=>{if(!i||!Ge.current)return;const W=++ae.current;try{const ve=await vb();Ge.current&&W===ae.current&&_(ve)}catch(ve){Ge.current&&ve instanceof Pe&&ve.status===401&&l()}},[i,l]),Et=w.useCallback(async()=>{const W=o.current;if(W)try{const ve=i?(await _f()).sessions:(await W.listSessions()).data;if(o.current===W&&Ge.current){const Be=[...ve].sort((ke,q)=>(q.lastActiveAt??q.startedAt)-(ke.lastActiveAt??ke.startedAt));p.current=Be,h(Be)}}catch(ve){Fe(ve)}},[Fe,i]),lt=w.useCallback(async()=>{const W=o.current;if(W)for(const[ve,Be]of Ae.current)try{const ke=await W.sessionDetail(ve);if(!Ge.current||W!==o.current||Ae.current.get(ve)!==Be)continue;lb(ke.data).chat.items.some(je=>je.kind==="user"&&je.clientMessageId===Be.clientMessageId)?Ae.current.delete(ve):ke.data.running||(Ae.current.delete(ve),ht(Be))}catch(ke){if(!Ge.current||W!==o.current||Ae.current.get(ve)!==Be)continue;ke instanceof vi&&ke.kind==="response"&&ke.code===-32001&&ke.message===`Session not found: ${ve}`&&(Ae.current.delete(ve),ht(Be))}},[ht]),bt=w.useCallback(async W=>{const ve=o.current;if(!ve)return;const Be={sessionId:W,events:[],bytes:0};ct.current=Be;try{const ke=await ve.sessionDetail(W,!0);if(!Ge.current||ct.current!==Be||se.current!==W)return;let q=Be.running??ke.data.running;q?tt.current.add(W):q===!1&&tt.current.delete(W);const ce=lb(ke.data,Be.events);let je=ce.chat,Ke=!1,st=!1;try{const Rt=await eA(ke.data,async Ct=>(await ve.outputJournal(W,Ct)).data,Be.events,()=>Be.latestOutputCursor,ke.data.outputCoverage?async()=>(await ve.outputCoverage(W)).data:void 0,()=>Ge.current&&ct.current===Be&&se.current===W);Rt?(je=Rt.chat,F.current=Rt.outputCursor,Ke=!0):F.current=null}catch(Rt){F.current=null,st=!(!ke.data.outputJournal&&Rt instanceof vi&&Rt.kind==="response"&&Rt.code===-32602&&Rt.message==="Unknown query type: output_journal")}if(!Ge.current||ct.current!==Be||se.current!==W)return;q=Be.running??ke.data.running,we.current=st,st||(ye.current=ce.cursor??null),K(st?"部分运行记录无法验证,已保留当前可见内容。请修复会话记录后重试。":!Ke&&(ce.truncated||Be.overflow)?"这次运行的实时记录较长,已恢复已保存的内容;结束后重新打开可查看完整记录。":null),q||Te.current.has(W)?je.run="running":q===!1&&(je.run==="running"||je.run==="waiting")&&(je.run="idle"),v(Rt=>st?Rt:je)}catch(ke){se.current===W&&Fe(ke)}finally{ct.current===Be&&(ct.current=null)}},[Fe]);w.useEffect(()=>{Ge.current=!0;const W=new sA(oA());o.current=W;const ve=W.onAuthLost(l),Be=W.onStateChange(q=>{u(q),q==="open"?($(null),Z(""),Et().then(()=>{const ce=se.current;Ge.current&&o.current===W&&(p.current.some(je=>je.sessionId===ce)||tt.current.has(ce)||Te.current.has(ce)||Ae.current.has(ce))&&bt(ce)}),nt(),lt()):q==="closed"&&(i&&a(),v(ce=>({...ce,run:"idle"})))}),ke=W.onNotification((q,ce)=>{if(q==="serve/sessionsChanged"){Et(),L(je=>je+1);return}if(q==="agent/runAccepted"&&typeof ce.sessionId=="string"){const je=Le.current.get(ce.sessionId);je&&(je.accepted=!0);return}if(q==="serve/configurationChanged"){nt(),xe(je=>je+1);return}if(q==="agent/streamEvent"){const je=ce,{sessionId:Ke,event:st}=je,Rt=Le.current.get(Ke);if(Rt&&["stream_request_start","text_delta","thinking_delta","tool_use_start"].includes(String(st.type))&&(Rt.accepted=!0),Ke===se.current){if(ct.current?.sessionId===Ke){const Ct=ct.current;typeof st.outputCursor=="string"&&(Ct.latestOutputCursor=st.outputCursor);const Wn=new TextEncoder().encode(JSON.stringify(je)).length;for(Ct.events.push(je),Ct.bytes+=Wn;Ct.events.length>2048||Ct.bytes>8*1024*1024;){const Vt=Ct.events.shift();Vt&&(Ct.bytes-=new TextEncoder().encode(JSON.stringify(Vt)).length),Ct.overflow=!0}}if(we.current&&st.type!=="session_title")return;if(typeof st.outputCursor=="string"&&F.current){const Ct=ga(st.outputCursor,F.current);if(Ct===void 0){bt(Ke);return}if(Ct<=0)return;F.current=st.outputCursor}if(!Bv(je,ye.current))return;je.hubEpoch&&je.hubSequence!==void 0&&(ye.current={epoch:je.hubEpoch,sequence:je.hubSequence}),v(Ct=>mr(Ct,st))}st.type==="stream_request_start"&&$(null),st.type==="turn_complete"&&Et();return}if(q==="serve/sessionStatus"){L(st=>st+1);const{sessionId:je,running:Ke}=ce;if(typeof je!="string"||typeof Ke!="boolean")return;ct.current?.sessionId===je&&(ct.current.running=Ke),Ke?tt.current.add(je):tt.current.delete(je),!Ke&&Ae.current.has(je)&<(),je===se.current&&v(st=>Ke?{...st,run:"running"}:st.run==="running"||st.run==="waiting"?{...st,run:"idle"}:st),Et();return}if(q==="agent/approvalRequest"||q==="agent/approvalResolved"||q==="serve/approvalSnapshot"||q==="serve/approvalLease"){D({method:q,params:ce});return}if(q==="serve/workerExit"){tt.current.clear();const je=ce.clean;$(je?"服务进程已退出,发送消息会自动重启":"服务进程异常退出,发送消息会自动重启"),v(Ke=>({...Ke,run:"idle"}))}});return W.connect(),()=>{Ge.current=!1,Lt.current?.abort(),Be(),ke(),ve(),W.close(),o.current=null}},[Et,bt,nt,lt,l,a,i]);const M=Object.values(j).some(W=>W.lease?.holderId&&(W.lease.expiresAt??0)>he);w.useEffect(()=>{if(!M)return;me(Date.now());const W=setInterval(()=>me(Date.now()),1e3);return()=>clearInterval(W)},[M]);const P=async W=>{se.current=W,ye.current=null,F.current=null,we.current=!1,b(W),qe(W),v(eo()),Z(""),K(null),!(!m.some(ve=>ve.sessionId===W)&&!tt.current.has(W)&&T.current.unsent().some(ve=>ve.sessionId===W))&&await bt(W)},ge=()=>{const W=sb();se.current=W,ye.current=null,F.current=null,we.current=!1,ct.current=null,b(W),qe(W),v(eo()),Z(""),K(null)},Se=()=>{const W=T.current.get(se.current),ve=W.text.trim(),Be=o.current;if(!ve&&!W.files.length||!Be||f!=="open"||B)return!1;const ke=se.current;if(Te.current.has(ke)||tt.current.has(ke)||x.run==="running"||x.run==="waiting"||Object.values(j).some(je=>je.payload.sessionId===ke)||Ae.current.has(ke))return!1;se.current=ke,b(ke),Te.current.add(ke);const q={clientMessageId:Ea(),draft:T.current.take(ke),accepted:!1};Le.current.set(ke,q);const ce=q.draft.draft.files;return qe(ke),Z(""),v(je=>({...vS(je,ve,ce.map(Ke=>({name:Ke.name,mime:Ke.mimeType,size:Ke.size})),q.clientMessageId),run:"running"})),Be.run({sessionId:ke,task:ve,clientMessageId:q.clientMessageId,displayText:ve,...ce.length?{uploadIds:ce.map(je=>je.id)}:{}}).catch(je=>{Ge.current&&(Fe(je),je instanceof vi&&(je.kind==="transport"||je.kind==="timeout")?(Ae.current.set(ke,q),Z("连接中断,重新连接后会核对这条消息是否已经送达。")):q.accepted||ht(q,je instanceof Error?je.message==="upload not found or expired"?"附件已失效,请移除后重新上传。":je.message:void 0),se.current===ke&&v(Ke=>({...Ke,run:"error"})))}).finally(()=>{Te.current.delete(ke),Le.current.get(ke)===q&&Le.current.delete(ke),Ge.current&&se.current===ke&&!tt.current.has(ke)&&v(je=>je.run==="running"?{...je,run:"idle"}:je)}),!0},Ce=(W,ve,Be)=>{const ke=o.current;!ke||f!=="open"||ut.current.has(W.requestId)||(ut.current.add(W.requestId),A(q=>({...q,[W.requestId]:!0})),Z(""),ke.approve({...W,sessionId:W.sessionId??se.current??""},ve,Be).then(()=>D({method:"agent/approvalResolved",params:{requestId:W.requestId}})).catch(Fe).finally(()=>{ut.current.delete(W.requestId),A(q=>{const ce={...q};return delete ce[W.requestId],ce})}))},Re=()=>{y&&o.current?.cancel(y).catch(Fe)},Qe=async W=>{if(!W?.length||Lt.current)return;const ve=new AbortController,Be=no();Lt.current=ve,C(se.current),Z("");const ke=se.current;try{for(const q of Array.from(W)){if(!Ge.current||ve.signal.aborted)break;const ce=await l1(q,{signal:ve.signal,scope:Be});Ge.current&&!ve.signal.aborted&&(T.current.addFile(ke,ce),qe(ke))}}catch(q){Fe(q)}finally{Lt.current===ve&&(Lt.current=null),Ge.current&&C(null)}},yt=Object.values(j).filter(W=>!W.payload.sessionId||W.payload.sessionId===y),pt=W=>Object.values(j).filter(ve=>ve.payload.sessionId===W).length,mt=x.run==="running"||x.run==="waiting"||yt.length>0,Ze=w.useMemo(()=>T.current.unsent().filter(W=>!m.some(ve=>ve.sessionId===W.sessionId)),[V,m]),oe=J?.workspace.path??m.find(W=>W.sessionId===y)?.cwd??m[0]?.cwd??null,_e=oe?.split(/[\\/]/).filter(Boolean).pop()??"服务端工作区",Ee=x.items.length===0&&yt.length===0,Me=m.find(W=>W.sessionId===y),ze=Ee?"新对话":Me?.customTitle||x.title||Me?.title||Me?.preview?.trim()||Uv(x,y??"新对话");return{host:i?"hub":"legacy",workspaceApi:i,connection:f,session:t,activeId:y,chat:x,sessions:m,workspaceCwd:oe,workspaceName:_e,title:ze,workspaceKey:oe??"hub",configuration:J,configurationVersion:te,sessionsVersion:k,draft:R,files:Y,uploading:B,uploadBusy:I!==null,hasUnsent:T.current.unsent().length>0,localDrafts:Ze,uncertain:Ae.current.has(y),running:mt,approvals:Object.values(j).map(W=>({id:W.payload.requestId,sessionId:W.payload.sessionId})),approvalCount:pt,approvalContent:yt.map(W=>c.jsx(fA,{payload:W.payload,onDecide:Ce,busy:!!N[W.payload.requestId]||!!(W.lease?.holderId&&(W.lease.expiresAt??0)>he),connected:f==="open"},W.payload.requestId)),workerNote:U,replayNote:ee,error:z,clearError:()=>Z(""),setDraft:W=>{T.current.setText(se.current,W),qe(se.current)},removeFile:W=>{T.current.removeFile(se.current,W),qe(se.current)},selectSession:P,newSession:ge,send:Se,stop:Re,addFiles:Qe,refreshSessions:Et,refreshConfiguration:nt,onAuthLost:l}}function ob({onBackToProjects:t,projectName:i,...l}){return c.jsx(nA,{controller:pA(l),onBackToProjects:t,projectName:i})}function Iv(t){if(!t||typeof t!="object")return!1;const i=t;return xa(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 mA(t){const i=t;if(!i||i.runtime!=="docker"||typeof i.available!="boolean"||!Array.isArray(i.projects)||!i.projects.every(Iv)||new Set(i.projects.map(l=>l.id)).size!==i.projects.length||i.error!==void 0&&typeof i.error!="string")throw new Error("服务端返回了无效的项目列表,请重试。");return i}function ub(){return new URL(window.location.href).searchParams.get("project")}function ma(t,i=!1){const l=new URL(window.location.href);t?l.searchParams.set("project",t):l.searchParams.delete("project"),i||l.searchParams.delete("session"),window.history.replaceState(window.history.state,"",l)}const gA={stopped:"已停止",starting:"正在启动",running:"运行中",stopping:"正在停止",error:"启动失败"};function yA({children:t,onAuthLost:i}){const[l,a]=w.useState(null),[o,f]=w.useState(!1),[u,m]=w.useState(null),[h,p]=w.useState(""),[y,b]=w.useState(!0),[x,v]=w.useState(null),[j,D]=w.useState(""),[N,A]=w.useState(null),R=w.useRef(null),O=w.useRef(ub()),Y=w.useRef(u),re=w.useRef(l),T=w.useRef(0),V=w.useRef(0),Q=w.useRef(null),I=w.useRef(i),C=w.useRef(!1);I.current=i,Y.current=u,re.current=l;const B=w.useCallback(z=>{if(z.status!=="running")return;const Z=ub()===z.id;Ys(),Vs(z.id),ma(z.id,Z),O.current=null,Y.current=z,m(z),p("")},[]),U=w.useCallback(()=>{O.current=null,Y.current=null,m(null),Vs(null),Ys(),ma(null)},[]),$=w.useCallback(async z=>{if(C.current)return;const Z=++V.current,he=T.current;try{const me=mA(await He("/api/v1/projects",{signal:z}));if(z?.aborted||Z!==V.current||he!==T.current)return;a(me),re.current=me,b(!1),p("");const k=Y.current;if(k){const J=me.projects.find(_=>_.id===k.id);(!J||J.status!=="running"||J.generation!==k.generation)&&(U(),p("项目运行状态已经变化,请重新打开项目。未发送的内容不会带入其他项目。"));return}if(!O.current)return;const L=me.projects.find(J=>J.id===O.current);L?L.status==="running"&&me.available&&B(L):(O.current=null,ma(null),p("链接中的项目不存在或当前账号无权访问,请选择一个项目。"))}catch(me){if(z?.aborted||Z!==V.current||he!==T.current)return;b(!1),me instanceof Pe&&me.status===404&&!re.current?(Vs(null),Ys(),C.current=!0,f(!0)):me instanceof Pe&&me.status===401?I.current():p(me instanceof Error?me.message:"无法读取项目,请重试。")}},[U,B]);w.useEffect(()=>{T.current++;const z=new AbortController;$(z.signal);const Z=()=>{$(z.signal)},he=()=>{document.visibilityState==="visible"&&Z()};return window.addEventListener("focus",Z),document.addEventListener("visibilitychange",he),()=>{T.current++,z.abort(),Q.current?.abort(),window.removeEventListener("focus",Z),document.removeEventListener("visibilitychange",he),Vs(null),Ys()}},[$]);const ee=l?.projects.some(z=>z.status==="starting"||z.status==="stopping");w.useEffect(()=>{if(o||!l)return;const z=new AbortController,Z=setInterval(()=>{$(z.signal)},ee?2e3:1e4);return()=>{clearInterval(Z),z.abort()}},[o,!!l,ee,$]),w.useEffect(()=>{if(!N)return;const z=document.activeElement,Z=R.current;return Z?.showModal?.(),()=>{Z?.close?.(),z?.focus()}},[N]);const K=async(z,Z)=>{if(Q.current||z==="create"&&!j.trim())return;const he=new AbortController;Q.current=he,v(Z?.id??"create"),p(""),V.current++;try{const me=await He(z==="create"?"/api/v1/projects":`/api/v1/projects/${Z.id}/${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z==="create"?{name:j.trim()}:{}),signal:he.signal});if(he.signal.aborted)return;if(!Iv(me.project)||Z&&Z.id!==me.project.id)throw new Error("服务端返回了无效的项目状态,请刷新列表。");const k=me.project;a(L=>L&&{...L,projects:L.projects.some(J=>J.id===k.id)?L.projects.map(J=>J.id===k.id?k:J):[...L.projects,k]}),z==="create"&&D(""),z==="start"&&(O.current=k.id,ma(k.id),k.status==="running"&&B(k)),z==="stop"&&(O.current===k.id&&(O.current=null,ma(null)),A(null)),await $(he.signal)}catch(me){if(he.signal.aborted)return;me instanceof Pe&&me.status===401?I.current():p(me instanceof Error?me.message:"项目操作失败,请重试。")}finally{Q.current===he&&(Q.current=null),he.signal.aborted||v(null)}};return o?c.jsx(w.Fragment,{children:t(null)},"single-project"):u?c.jsxs(w.Fragment,{children:[h?c.jsxs("div",{className:"project-connection-note",role:"status",children:["项目状态暂时无法刷新,当前工作台会保留。",h]}):null,t(u,U)]},`${u.id}:${u.generation}`):c.jsxs("main",{className:"projects-page",children:[c.jsxs("header",{className:"projects-header",children:[c.jsxs("div",{className:"auth-brand",children:["CodeShell ",c.jsx("span",{children:"Hub"})]}),c.jsx(ed,{}),c.jsx("h1",{children:"你的项目"}),c.jsx("p",{children:"每个项目有独立的运行环境、文件、会话和配置。启动后进入同一个工作台。"})]}),y?c.jsx("p",{role:"status",children:"正在读取项目…"}):null,h?c.jsxs("div",{className:"form-error",role:"alert",children:[h,c.jsx("button",{className:"library-button",onClick:()=>{$()},children:"刷新项目"})]}):null,l?c.jsxs(c.Fragment,{children:[l.available?null:c.jsxs("p",{className:"form-error",role:"alert",children:["项目运行环境暂不可用。",l.error||"请检查服务端 Docker 是否已启动。"]}),c.jsxs("form",{className:"project-create",onSubmit:z=>{z.preventDefault(),K("create")},children:[c.jsxs("label",{children:["新项目名称",c.jsx("input",{value:j,maxLength:80,required:!0,placeholder:"例如:个人网站",onChange:z=>D(z.target.value)})]}),c.jsx("button",{className:"library-button primary",disabled:!!x||!j.trim(),type:"submit",children:x==="create"?"正在创建…":"创建项目"})]}),c.jsxs("section",{className:"projects-grid","aria-label":"项目列表",children:[l.projects.length===0?c.jsx("p",{className:"project-empty",children:"创建第一个项目,开始配置模型、添加技能和使用面板。"}):null,l.projects.map(z=>c.jsxs("article",{className:"project-card",children:[c.jsxs("div",{className:"project-card-heading",children:[c.jsx("h2",{children:z.name}),c.jsx("span",{className:`project-status ${z.status}`,children:gA[z.status]})]}),c.jsxs("p",{className:"project-date",children:["创建于 ",new Date(z.createdAt).toLocaleDateString()]}),z.error?c.jsx("p",{className:"form-error",role:"alert",children:z.error}):null,c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button primary",disabled:!!x||!l.available||z.status==="starting"||z.status==="stopping",onClick:()=>z.status==="running"?B(z):void K("start",z),children:x===z.id||z.status==="starting"||z.status==="stopping"?"正在处理…":z.status==="running"?"打开项目":"启动并打开"}),z.status==="running"?c.jsx("button",{className:"library-button",disabled:!!x,onClick:()=>A(z),children:"停止项目"}):null]})]},z.id))]})]}):null,N?c.jsxs("dialog",{className:"project-stop-confirm",ref:R,role:"alertdialog","aria-modal":"true","aria-labelledby":"project-stop-title",onCancel:z=>{z.preventDefault(),x||A(null)},children:[c.jsxs("h2",{id:"project-stop-title",children:["停止 ",N.name,"?"]}),c.jsx("p",{children:"正在运行的任务和面板进程会中断。项目文件和配置保留,可稍后重新启动。"}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button primary",disabled:!!x,onClick:()=>A(null),children:"继续运行"}),c.jsx("button",{className:"library-button",disabled:!!x,onClick:()=>{K("stop",N)},children:"确认停止"})]})]}):null]})}function bA({setupToken:t}){const[i,l]=w.useState("checking"),[a,o]=w.useState(),[f,u]=w.useState(""),[m,h]=w.useState(""),[p,y]=w.useState(""),[b,x]=w.useState(t),[v,j]=w.useState(""),[D,N]=w.useState(!1),A=w.useRef(!1),R=w.useRef(0),O=w.useRef(i);O.current=i;const Y=w.useCallback(Q=>{A.current&&(o(Q?.session),l(Q===null?"legacy":Q.initialized?Q.authenticated?"authenticated":"login":"setup"),j(""),Q?.initialized&&x(""))},[]),re=w.useCallback(async()=>{const Q=++R.current;try{const I=await i1();Q===R.current&&Y(I)}catch(I){if(!A.current||Q!==R.current||O.current==="authenticated"||O.current==="legacy")return;l("error"),j(I instanceof Error?I.message:"无法连接服务端")}},[Y]);w.useEffect(()=>{A.current=!0,re();const Q=()=>{re()},I=()=>{document.visibilityState==="visible"&&re()};return window.addEventListener("focus",Q),document.addEventListener("visibilitychange",I),()=>{A.current=!1,window.removeEventListener("focus",Q),document.removeEventListener("visibilitychange",I)}},[re]);const T=w.useCallback(()=>{R.current++,o(void 0),l("login"),h(""),j("登录已过期或此设备已被撤销,请重新登录。")},[]),V=async Q=>{if(Q.preventDefault(),!D){R.current++,N(!0),j("");try{const I=await hb(`/api/v1/auth/${i==="setup"?"setup":"login"}`,{username:f.trim(),password:m,deviceName:p.trim()||void 0,...i==="setup"?{token:b.trim()}:{}});if(!I.authenticated)throw new Error("登录失败,请重试。");R.current++,h(""),x(""),Y({initialized:!0,authenticated:!0,session:I.session})}catch(I){j(I instanceof Error?I.message:"登录失败,请重试。"),I instanceof Pe&&I.status===409&&re()}finally{N(!1)}}};return i==="authenticated"?c.jsx(yA,{onAuthLost:T,children:(Q,I)=>c.jsx(ob,{session:a,hub:!0,onAuthLost:T,onCheckAuth:re,projectName:Q?.name,onBackToProjects:I})}):i==="legacy"?c.jsx(ob,{session:a,hub:!1,onAuthLost:T,onCheckAuth:re}):c.jsx("main",{className:"auth-page",children:c.jsxs("section",{className:"auth-card",children:[c.jsx(ed,{discover:!1}),c.jsxs("div",{className:"auth-brand",children:["CodeShell ",c.jsx("span",{children:"Hub"})]}),i==="checking"?c.jsx("p",{role:"status",children:"正在连接你的工作空间…"}):null,i==="error"?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"form-error",role:"alert",children:v}),c.jsx("button",{className:"send",onClick:()=>{re()},children:"重试连接"})]}):null,i==="setup"||i==="login"?c.jsxs("form",{onSubmit:Q=>{V(Q)},children:[c.jsx("h1",{children:i==="setup"?"创建管理员账号":"登录工作空间"}),c.jsx("p",{children:i==="setup"?"首次启动需要服务端提供的初始化令牌。创建后,可在其他设备使用此账号登录。":"连接服务端,继续你的会话与任务。"}),i==="setup"?c.jsxs("label",{children:["初始化令牌",c.jsx("input",{type:"password",autoComplete:"off",required:!0,value:b,onChange:Q=>x(Q.target.value)})]}):null,c.jsxs("label",{children:["用户名",c.jsx("input",{autoComplete:"username",required:!0,maxLength:64,value:f,onChange:Q=>u(Q.target.value)})]}),c.jsxs("label",{children:["密码",c.jsx("input",{type:"password",autoComplete:i==="setup"?"new-password":"current-password",required:!0,maxLength:256,minLength:i==="setup"?12:void 0,value:m,onChange:Q=>h(Q.target.value)})]}),i==="setup"?c.jsx("small",{children:"密码至少 12 个字符。"}):null,c.jsxs("label",{children:["设备名称 ",c.jsx("span",{children:"(可选)"}),c.jsx("input",{autoComplete:"off",maxLength:100,placeholder:"例如:我的笔记本",value:p,onChange:Q=>y(Q.target.value)})]}),v?c.jsx("p",{className:"form-error",role:"alert",children:v}):null,c.jsx("button",{className:"send",type:"submit",disabled:D,children:D?"正在连接…":i==="setup"?"创建并进入":"登录"})]}):null]})})}function vA(t="/"){"serviceWorker"in navigator&&window.isSecureContext&&navigator.serviceWorker.register(`${t}sw.js`).catch(()=>{})}const cb=g1(),xA=r1(window.location,window.history);j1.createRoot(document.getElementById("root")).render(c.jsx(w.StrictMode,{children:cb?c.jsx(y1,{callback:cb}):c.jsx(bA,{setupToken:xA})}));vA("/");
|