@cjhyy/code-shell-web 0.9.27 → 0.9.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ (function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const 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 ao(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Cc={exports:{}},ra={};var cg;function G0(){if(cg)return ra;cg=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 p in o)p!=="key"&&(f[p]=o[p])}else f=o;return o=f.ref,{$$typeof:t,type:a,key:u,ref:o!==void 0?o:null,props:f}}return ra.Fragment=i,ra.jsx=l,ra.jsxs=l,ra}var fg;function F0(){return fg||(fg=1,Cc.exports=G0()),Cc.exports}var c=F0(),Ec={exports:{}},He={};var dg;function Q0(){if(dg)return He;dg=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"),p=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function x(O){return O===null||typeof O!="object"?null:(O=v&&O[v]||O["@@iterator"],typeof O=="function"?O:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,D={};function R(O,J,A){this.props=O,this.context=J,this.refs=D,this.updater=A||k}R.prototype.isReactComponent={},R.prototype.setState=function(O,J){if(typeof O!="object"&&typeof O!="function"&&O!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,O,J,"setState")},R.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function z(){}z.prototype=R.prototype;function L(O,J,A){this.props=O,this.context=J,this.refs=D,this.updater=A||k}var G=L.prototype=new z;G.constructor=L,_(G,R.prototype),G.isPureReactComponent=!0;var ae=Array.isArray;function T(){}var V={H:null,A:null,T:null,S:null},$=Object.prototype.hasOwnProperty;function q(O,J,A){var le=A.ref;return{$$typeof:t,type:O,key:J,ref:le!==void 0?le:null,props:A}}function E(O,J){return q(O.type,J,O.props)}function B(O){return typeof O=="object"&&O!==null&&O.$$typeof===t}function H(O){var J={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(A){return J[A]})}var Z=/\/+/g;function ee(O,J){return typeof O=="object"&&O!==null&&O.key!=null?H(""+O.key):J.toString(36)}function W(O){switch(O.status){case"fulfilled":return O.value;case"rejected":throw O.reason;default:switch(typeof O.status=="string"?O.then(T,T):(O.status="pending",O.then(function(J){O.status==="pending"&&(O.status="fulfilled",O.value=J)},function(J){O.status==="pending"&&(O.status="rejected",O.reason=J)})),O.status){case"fulfilled":return O.value;case"rejected":throw O.reason}}throw O}function N(O,J,A,le,me){var te=typeof O;(te==="undefined"||te==="boolean")&&(O=null);var se=!1;if(O===null)se=!0;else switch(te){case"bigint":case"string":case"number":se=!0;break;case"object":switch(O.$$typeof){case t:case i:se=!0;break;case y:return se=O._init,N(se(O._payload),J,A,le,me)}}if(se)return me=me(O),se=le===""?"."+ee(O,0):le,ae(me)?(A="",se!=null&&(A=se.replace(Z,"$&/")+"/"),N(me,J,A,"",function(Se){return Se})):me!=null&&(B(me)&&(me=E(me,A+(me.key==null||O&&O.key===me.key?"":(""+me.key).replace(Z,"$&/")+"/")+se)),J.push(me)),1;se=0;var we=le===""?".":le+":";if(ae(O))for(var F=0;F<O.length;F++)le=O[F],te=we+ee(le,F),se+=N(le,J,A,te,me);else if(F=x(O),typeof F=="function")for(O=F.call(O),F=0;!(le=O.next()).done;)le=le.value,te=we+ee(le,F++),se+=N(le,J,A,te,me);else if(te==="object"){if(typeof O.then=="function")return N(W(O),J,A,le,me);throw J=String(O),Error("Objects are not valid as a React child (found: "+(J==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":J)+"). If you meant to render a collection of children, use an array instead.")}return se}function X(O,J,A){if(O==null)return O;var le=[],me=0;return N(O,le,"","",function(te){return J.call(A,te,me++)}),le}function pe(O){if(O._status===-1){var J=O._result;J=J(),J.then(function(A){(O._status===0||O._status===-1)&&(O._status=1,O._result=A)},function(A){(O._status===0||O._status===-1)&&(O._status=2,O._result=A)}),O._status===-1&&(O._status=0,O._result=J)}if(O._status===1)return O._result.default;throw O._result}var ye=typeof reportError=="function"?reportError:function(O){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var J=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof O=="object"&&O!==null&&typeof O.message=="string"?String(O.message):String(O),error:O});if(!window.dispatchEvent(J))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",O);return}console.error(O)},j={map:X,forEach:function(O,J,A){X(O,function(){J.apply(this,arguments)},A)},count:function(O){var J=0;return X(O,function(){J++}),J},toArray:function(O){return X(O,function(J){return J})||[]},only:function(O){if(!B(O))throw Error("React.Children.only expected to receive a single React element child.");return O}};return He.Activity=b,He.Children=j,He.Component=R,He.Fragment=l,He.Profiler=o,He.PureComponent=L,He.StrictMode=a,He.Suspense=h,He.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=V,He.__COMPILER_RUNTIME={__proto__:null,c:function(O){return V.H.useMemoCache(O)}},He.cache=function(O){return function(){return O.apply(null,arguments)}},He.cacheSignal=function(){return null},He.cloneElement=function(O,J,A){if(O==null)throw Error("The argument must be a React element, but you passed "+O+".");var le=_({},O.props),me=O.key;if(J!=null)for(te in J.key!==void 0&&(me=""+J.key),J)!$.call(J,te)||te==="key"||te==="__self"||te==="__source"||te==="ref"&&J.ref===void 0||(le[te]=J[te]);var te=arguments.length-2;if(te===1)le.children=A;else if(1<te){for(var se=Array(te),we=0;we<te;we++)se[we]=arguments[we+2];le.children=se}return q(O.type,me,le)},He.createContext=function(O){return O={$$typeof:u,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null},O.Provider=O,O.Consumer={$$typeof:f,_context:O},O},He.createElement=function(O,J,A){var le,me={},te=null;if(J!=null)for(le in J.key!==void 0&&(te=""+J.key),J)$.call(J,le)&&le!=="key"&&le!=="__self"&&le!=="__source"&&(me[le]=J[le]);var se=arguments.length-2;if(se===1)me.children=A;else if(1<se){for(var we=Array(se),F=0;F<se;F++)we[F]=arguments[F+2];me.children=we}if(O&&O.defaultProps)for(le in se=O.defaultProps,se)me[le]===void 0&&(me[le]=se[le]);return q(O,te,me)},He.createRef=function(){return{current:null}},He.forwardRef=function(O){return{$$typeof:p,render:O}},He.isValidElement=B,He.lazy=function(O){return{$$typeof:y,_payload:{_status:-1,_result:O},_init:pe}},He.memo=function(O,J){return{$$typeof:m,type:O,compare:J===void 0?null:J}},He.startTransition=function(O){var J=V.T,A={};V.T=A;try{var le=O(),me=V.S;me!==null&&me(A,le),typeof le=="object"&&le!==null&&typeof le.then=="function"&&le.then(T,ye)}catch(te){ye(te)}finally{J!==null&&A.types!==null&&(J.types=A.types),V.T=J}},He.unstable_useCacheRefresh=function(){return V.H.useCacheRefresh()},He.use=function(O){return V.H.use(O)},He.useActionState=function(O,J,A){return V.H.useActionState(O,J,A)},He.useCallback=function(O,J){return V.H.useCallback(O,J)},He.useContext=function(O){return V.H.useContext(O)},He.useDebugValue=function(){},He.useDeferredValue=function(O,J){return V.H.useDeferredValue(O,J)},He.useEffect=function(O,J){return V.H.useEffect(O,J)},He.useEffectEvent=function(O){return V.H.useEffectEvent(O)},He.useId=function(){return V.H.useId()},He.useImperativeHandle=function(O,J,A){return V.H.useImperativeHandle(O,J,A)},He.useInsertionEffect=function(O,J){return V.H.useInsertionEffect(O,J)},He.useLayoutEffect=function(O,J){return V.H.useLayoutEffect(O,J)},He.useMemo=function(O,J){return V.H.useMemo(O,J)},He.useOptimistic=function(O,J){return V.H.useOptimistic(O,J)},He.useReducer=function(O,J,A){return V.H.useReducer(O,J,A)},He.useRef=function(O){return V.H.useRef(O)},He.useState=function(O){return V.H.useState(O)},He.useSyncExternalStore=function(O,J,A){return V.H.useSyncExternalStore(O,J,A)},He.useTransition=function(){return V.H.useTransition()},He.version="19.2.6",He}var hg;function Qf(){return hg||(hg=1,Ec.exports=Q0()),Ec.exports}var $0=Qf();const w=ao($0);let Sa,so=null;const X0=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,sb=/^\/p\/([0-9a-f-]{36})(\/.*)$/;function ya(t){return typeof t=="string"&&X0.test(t)}function Us(t){if(t!==null&&!ya(t))throw new Error("项目标识无效。");so=t}function ba(){return so}function Js(){return{workspace:Sa??"",projectId:so}}function qs(t){Sa=void 0}function Ws(){return Sa}function pg(t=Sa){return t?{"X-CodeShell-Workspace":encodeURIComponent(t)}:{}}function ob(t){return/^\/api\/v1\/(?:auth|projects|environment)(?:\/|\?|$)/.test(t)||/^\/api\/v1\/desktop\/session(?:\?|$)/.test(t)}function K0(t){const i=sb.exec(t);return!!i&&ya(i[1])}function St(t,i=Sa,l=so){const a=sb.exec(t),o=a?a[2]:t;if(a&&!ya(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(ob(o))return o;if(a)return t;if(l!==null&&!ya(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 Xe extends Error{constructor(i,l,a,o){super(i),this.status=l,this.code=a,this.retryAfterMs=o}status;code;retryAfterMs}async function Ue(t,i={},l){const a=l?pg(l.workspace):pg(),o={...i};if(Object.keys(a).length&&!ob(t)&&!K0(t)&&!t.includes("workspace=")){const p=new Headers(i.headers);for(const[h,m]of Object.entries(a))p.has(h)||p.set(h,m);o.headers=p}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 p=typeof u.error=="string"?u.error:u.error?.message;throw new Xe(p??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 ub(t,i={}){return Ue(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async function Z0(){try{const t=await Ue("/api/v1/auth/status");if(typeof t.initialized!="boolean"||typeof t.authenticated!="boolean")throw new Error("服务端返回了无效的登录状态,请稍后重试。");return t}catch(t){if(t instanceof Xe&&t.status===404)return null;throw t}}function P0(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 wa(){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 J0(t,i={}){const l=i.scope??Js();return Ue(St(`/api/v1/uploads/${wa()}`,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 W0(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 Nc(t,i){const l=t.authModes?.filter(a=>a.available&&(!i||a.methodId===i));return l?.find(a=>a.preferred)??l?.[0]}function bi(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 e1=new Set(["redirect","device-code","qr-code","credential-input","local-session","consent","processing"]);function t1(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=bi(t);if(t.state==="pending"&&(!l||!e1.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 n1{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=bi(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(t1(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=bi(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:Is(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:Is(o)})}}async respond(i){const l=this.value.authorization,a=l&&bi(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:Is(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:Is(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 Is(t){return t instanceof Error?t:new Error("连接操作失败,请重试。")}const Ef="codeshell.remote-link.authorization.v1",$f="/api/v1/links/authorizations/",Nf="[a-f0-9-]{36}",i1=new RegExp(`^(?:/p/${Nf})?${$f}${Nf}$`);function Xf(t){return t==="/link/callback"?"/":t==="/mobile/link/callback"?"/mobile/":void 0}function r1(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 l1(t,i,l,a=window.location.origin,o=window.sessionStorage){const f=bi(t);if(f?.kind!=="redirect"||!new RegExp(`^${Nf}$`).test(t.id))throw new Error("授权请求无效。");const u=r1(f.authorizationUrl,i),p=u.searchParams.get("state"),h=u.searchParams.get("redirect_uri"),m=Date.parse(f.expiresAt),y=h?Xf(new URL(h,a).pathname):void 0;if(!p||!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(m)||m<=Date.now())throw new Error("授权回调地址或有效期无效,请检查服务配置。");const b=St($f+t.id,l.workspace,l.projectId),v=new URLSearchParams({view:"links",...l.projectId?{project:l.projectId}:{},...y==="/mobile/"?{workspace:l.workspace}:{}});return o.setItem(Ef,JSON.stringify({target:b,state:p,redirectUri:h,returnUrl:`${y}?${v}`,expiresAt:m,providerId:t.providerId})),u.href}function a1(t,i,l){const a=Xf(t.pathname);if(!a)return;const o=t.href;i.replaceState(i.state,"",t.pathname);try{const f=l.getItem(Ef);l.removeItem(Ef);const u=JSON.parse(f??"null");if(!u||!Number.isFinite(u.expiresAt)||u.expiresAt<=Date.now())throw new Error;const p=new URL(o),h=new URL(u.target,t.origin),m=new URL(u.returnUrl,t.origin);if(u.redirectUri!==`${t.origin}${t.pathname}`||p.origin!==t.origin||p.hash||p.searchParams.getAll("state").length!==1||p.searchParams.get("state")!==u.state||h.origin!==t.origin||!i1.test(h.pathname)||h.hash||h.username||h.password||[...h.searchParams.keys()].some(y=>y!=="workspace")||h.searchParams.getAll("workspace").length>1||m.origin!==t.origin||m.pathname!==a||m.username||m.password||m.hash||[...m.searchParams.keys()].some(y=>!(a==="/mobile/"?["workspace","view"]:["project","view"]).includes(y))||m.searchParams.getAll("view").length!==1||m.searchParams.get("view")!=="links"||a==="/mobile/"&&(!h.pathname.startsWith($f)||m.searchParams.getAll("workspace").length!==1||m.searchParams.get("workspace")!==(h.searchParams.get("workspace")??"")))throw new Error;return{callbackUrl:o,pending:u,denied:p.searchParams.has("error")}}catch{return{error:"找不到匹配的授权,或授权已过期。请返回原项目重新连接。",home:a}}}async function s1(t){const i=new URL(t.pending.target,window.location.origin),l=cb(i);return t.denied?(await Ue(t.pending.target,{method:"DELETE"},l),{id:"",providerId:t.pending.providerId??"",state:"cancelled"}):(i.pathname+="/complete",Ue(i.pathname+i.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:t.callbackUrl})},l))}function cb(t){return{workspace:t.searchParams.get("workspace")??"",projectId:/^\/p\/([a-f0-9-]{36})\//.exec(t.pathname)?.[1]??null}}function o1(t){const i=new URL(t.pending.target,window.location.origin);return Ue(t.pending.target,{},cb(i))}function u1(){const t=Xf(window.location.pathname);if(t)try{return a1(window.location,window.history,window.sessionStorage)}catch{return window.history.replaceState(window.history.state,"",window.location.pathname),{error:"浏览器无法读取原授权记录。请允许此站点保存临时数据后重新连接。",home:t}}}function c1({callback:t}){const i=w.useRef(void 0),[l,a]=w.useState(),[o,f]=w.useState("error"in t?t.error:""),[u,p]=w.useState(!1),h=b=>f(b instanceof Xe&&b.status===401?"原登录已失效。请返回工作台登录,并重新发起授权。":b instanceof Error?b.message:"无法确认授权结果,请检查结果或返回项目重新连接。"),m=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??=s1(t),i.current.then(v=>{b&&m(v)},v=>{b&&h(v)}),()=>{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||(p(!0),o1(t).then(m,h).finally(()=>p(!1)))},children:u?"正在查询…":"检查授权结果"}),!y&&c.jsx("a",{href:"error"in t?t.home??"/":t.pending.returnUrl,children:"返回原项目"})]})})}var Ac={exports:{}},la={},Tc={exports:{}},zc={};var mg;function f1(){return mg||(mg=1,(function(t){function i(N,X){var pe=N.length;N.push(X);e:for(;0<pe;){var ye=pe-1>>>1,j=N[ye];if(0<o(j,X))N[ye]=X,N[pe]=j,pe=ye;else break e}}function l(N){return N.length===0?null:N[0]}function a(N){if(N.length===0)return null;var X=N[0],pe=N.pop();if(pe!==X){N[0]=pe;e:for(var ye=0,j=N.length,O=j>>>1;ye<O;){var J=2*(ye+1)-1,A=N[J],le=J+1,me=N[le];if(0>o(A,pe))le<j&&0>o(me,A)?(N[ye]=me,N[le]=pe,ye=le):(N[ye]=A,N[J]=pe,ye=J);else if(le<j&&0>o(me,pe))N[ye]=me,N[le]=pe,ye=le;else break e}}return X}function o(N,X){var pe=N.sortIndex-X.sortIndex;return pe!==0?pe:N.id-X.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,p=u.now();t.unstable_now=function(){return u.now()-p}}var h=[],m=[],y=1,b=null,v=3,x=!1,k=!1,_=!1,D=!1,R=typeof setTimeout=="function"?setTimeout:null,z=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function G(N){for(var X=l(m);X!==null;){if(X.callback===null)a(m);else if(X.startTime<=N)a(m),X.sortIndex=X.expirationTime,i(h,X);else break;X=l(m)}}function ae(N){if(_=!1,G(N),!k)if(l(h)!==null)k=!0,T||(T=!0,H());else{var X=l(m);X!==null&&W(ae,X.startTime-N)}}var T=!1,V=-1,$=5,q=-1;function E(){return D?!0:!(t.unstable_now()-q<$)}function B(){if(D=!1,T){var N=t.unstable_now();q=N;var X=!0;try{e:{k=!1,_&&(_=!1,z(V),V=-1),x=!0;var pe=v;try{t:{for(G(N),b=l(h);b!==null&&!(b.expirationTime>N&&E());){var ye=b.callback;if(typeof ye=="function"){b.callback=null,v=b.priorityLevel;var j=ye(b.expirationTime<=N);if(N=t.unstable_now(),typeof j=="function"){b.callback=j,G(N),X=!0;break t}b===l(h)&&a(h),G(N)}else a(h);b=l(h)}if(b!==null)X=!0;else{var O=l(m);O!==null&&W(ae,O.startTime-N),X=!1}}break e}finally{b=null,v=pe,x=!1}X=void 0}}finally{X?H():T=!1}}}var H;if(typeof L=="function")H=function(){L(B)};else if(typeof MessageChannel<"u"){var Z=new MessageChannel,ee=Z.port2;Z.port1.onmessage=B,H=function(){ee.postMessage(null)}}else H=function(){R(B,0)};function W(N,X){V=R(function(){N(t.unstable_now())},X)}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(N){N.callback=null},t.unstable_forceFrameRate=function(N){0>N||125<N?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<N?Math.floor(1e3/N):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_next=function(N){switch(v){case 1:case 2:case 3:var X=3;break;default:X=v}var pe=v;v=X;try{return N()}finally{v=pe}},t.unstable_requestPaint=function(){D=!0},t.unstable_runWithPriority=function(N,X){switch(N){case 1:case 2:case 3:case 4:case 5:break;default:N=3}var pe=v;v=N;try{return X()}finally{v=pe}},t.unstable_scheduleCallback=function(N,X,pe){var ye=t.unstable_now();switch(typeof pe=="object"&&pe!==null?(pe=pe.delay,pe=typeof pe=="number"&&0<pe?ye+pe:ye):pe=ye,N){case 1:var j=-1;break;case 2:j=250;break;case 5:j=1073741823;break;case 4:j=1e4;break;default:j=5e3}return j=pe+j,N={id:y++,callback:X,priorityLevel:N,startTime:pe,expirationTime:j,sortIndex:-1},pe>ye?(N.sortIndex=pe,i(m,N),l(h)===null&&N===l(m)&&(_?(z(V),V=-1):_=!0,W(ae,pe-ye))):(N.sortIndex=j,i(h,N),k||x||(k=!0,T||(T=!0,H()))),N},t.unstable_shouldYield=E,t.unstable_wrapCallback=function(N){var X=v;return function(){var pe=v;v=X;try{return N.apply(this,arguments)}finally{v=pe}}}})(zc)),zc}var gg;function d1(){return gg||(gg=1,Tc.exports=f1()),Tc.exports}var Rc={exports:{}},tn={};var yg;function h1(){if(yg)return tn;yg=1;var t=Qf();function i(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+h+"; visit "+m+" 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,m,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:h,containerInfo:m,implementation:y}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(h,m){if(h==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return tn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,tn.createPortal=function(h,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(i(299));return f(h,m,null,y)},tn.flushSync=function(h){var m=u.T,y=a.p;try{if(u.T=null,a.p=2,h)return h()}finally{u.T=m,a.p=y,a.d.f()}},tn.preconnect=function(h,m){typeof h=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,a.d.C(h,m))},tn.prefetchDNS=function(h){typeof h=="string"&&a.d.D(h)},tn.preinit=function(h,m){if(typeof h=="string"&&m&&typeof m.as=="string"){var y=m.as,b=p(y,m.crossOrigin),v=typeof m.integrity=="string"?m.integrity:void 0,x=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?a.d.S(h,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:b,integrity:v,fetchPriority:x}):y==="script"&&a.d.X(h,{crossOrigin:b,integrity:v,fetchPriority:x,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},tn.preinitModule=function(h,m){if(typeof h=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=p(m.as,m.crossOrigin);a.d.M(h,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&a.d.M(h)},tn.preload=function(h,m){if(typeof h=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,b=p(y,m.crossOrigin);a.d.L(h,y,{crossOrigin:b,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},tn.preloadModule=function(h,m){if(typeof h=="string")if(m){var y=p(m.as,m.crossOrigin);a.d.m(h,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else a.d.m(h)},tn.requestFormReset=function(h){a.d.r(h)},tn.unstable_batchedUpdates=function(h,m){return h(m)},tn.useFormState=function(h,m,y){return u.H.useFormState(h,m,y)},tn.useFormStatus=function(){return u.H.useHostTransitionStatus()},tn.version="19.2.6",tn}var bg;function fb(){if(bg)return Rc.exports;bg=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(),Rc.exports=h1(),Rc.exports}var vg;function p1(){if(vg)return la;vg=1;var t=d1(),i=Qf(),l=fb();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 p(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 m(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,C=d.child;C;){if(C===r){S=!0,r=d,s=g;break}if(C===s){S=!0,s=d,r=g;break}C=C.sibling}if(!S){for(C=g.child;C;){if(C===r){S=!0,r=g,s=d;break}if(C===s){S=!0,s=g,r=d;break}C=C.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,v=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),L=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),ae=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),E=Symbol.for("react.memo_cache_sentinel"),B=Symbol.iterator;function H(e){return e===null||typeof e!="object"?null:(e=B&&e[B]||e["@@iterator"],typeof e=="function"?e:null)}var Z=Symbol.for("react.client.reference");function ee(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Z?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case _:return"Fragment";case R:return"Profiler";case D:return"StrictMode";case ae:return"Suspense";case T:return"SuspenseList";case q:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case L:return e.displayName||"Context";case z:return(e._context.displayName||"Context")+".Consumer";case G: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 $:n=e._payload,e=e._init;try{return ee(e(n))}catch{}}return null}var W=Array.isArray,N=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,pe={pending:!1,data:null,method:null,action:null},ye=[],j=-1;function O(e){return{current:e}}function J(e){0>j||(e.current=ye[j],ye[j]=null,j--)}function A(e,n){j++,ye[j]=e.current,e.current=n}var le=O(null),me=O(null),te=O(null),se=O(null);function we(e,n){switch(A(te,n),A(me,e),A(le,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Mm(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Mm(n),e=_m(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}J(le),A(le,e)}function F(){J(le),J(me),J(te)}function Se(e){e.memoizedState!==null&&A(se,e);var n=le.current,r=_m(n,e.type);n!==r&&(A(me,e),A(le,r))}function Ne(e){me.current===e&&(J(le),J(me)),se.current===e&&(J(se),ea._currentValue=pe)}var Te,Ge;function et(e){if(Te===void 0)try{throw Error()}catch(r){var n=r.stack.trim().match(/\n( *(at )?)/);Te=n&&n[1]||"",Ge=-1<r.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+Te+e+Ge}var dt=!1;function Fe(e,n){if(!e||dt)return"";dt=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var s={DetermineComponentFrameRoot:function(){try{if(n){var he=function(){throw Error()};if(Object.defineProperty(he.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(he,[])}catch(oe){var re=oe}Reflect.construct(e,[],he)}else{try{he.call()}catch(oe){re=oe}e.call(he.prototype)}}else{try{throw Error()}catch(oe){re=oe}(he=e())&&typeof he.catch=="function"&&he.catch(function(){})}}catch(oe){if(oe&&re&&typeof oe.stack=="string")return[oe.stack,re.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],C=g[1];if(S&&C){var I=S.split(`
4
+ `),ie=C.split(`
5
+ `);for(d=s=0;s<I.length&&!I[s].includes("DetermineComponentFrameRoot");)s++;for(;d<ie.length&&!ie[d].includes("DetermineComponentFrameRoot");)d++;if(s===I.length||d===ie.length)for(s=I.length-1,d=ie.length-1;1<=s&&0<=d&&I[s]!==ie[d];)d--;for(;1<=s&&0<=d;s--,d--)if(I[s]!==ie[d]){if(s!==1||d!==1)do if(s--,d--,0>d||I[s]!==ie[d]){var ue=`
6
+ `+I[s].replace(" at new "," at ");return e.displayName&&ue.includes("<anonymous>")&&(ue=ue.replace("<anonymous>",e.displayName)),ue}while(1<=s&&0<=d);break}}}finally{dt=!1,Error.prepareStackTrace=r}return(r=e?e.displayName||e.name:"")?et(r):""}function Ct(e,n){switch(e.tag){case 26:case 27:case 5:return et(e.type);case 16:return et("Lazy");case 13:return e.child!==n&&n!==null?et("Suspense Fallback"):et("Suspense");case 19:return et("SuspenseList");case 0:case 15:return Fe(e.type,!1);case 11:return Fe(e.type.render,!1);case 1:return Fe(e.type,!0);case 31:return et("Activity");default:return""}}function ht(e){try{var n="",r=null;do n+=Ct(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,pt=t.unstable_scheduleCallback,Ve=t.unstable_cancelCallback,tt=t.unstable_shouldYield,zt=t.unstable_requestPaint,rt=t.unstable_now,yt=t.unstable_getCurrentPriorityLevel,M=t.unstable_ImmediatePriority,K=t.unstable_UserBlockingPriority,ge=t.unstable_NormalPriority,be=t.unstable_LowPriority,Ee=t.unstable_IdlePriority,Le=t.log,Ke=t.unstable_setDisableYieldValue,bt=null,mt=null;function lt(e){if(typeof Le=="function"&&Ke(e),mt&&typeof mt.setStrictMode=="function")try{mt.setStrictMode(bt,e)}catch{}}var Ze=Math.clz32?Math.clz32:ze,Q=Math.log,ve=Math.LN2;function ze(e){return e>>>=0,e===0?32:31-(Q(e)/ve|0)|0}var De=256,$e=262144,ce=4194304;function ke(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Me(e,n,r){var s=e.pendingLanes;if(s===0)return 0;var d=0,g=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var C=s&134217727;return C!==0?(s=C&~g,s!==0?d=ke(s):(S&=C,S!==0?d=ke(S):r||(r=C&~e,r!==0&&(d=ke(r))))):(C=s&~g,C!==0?d=ke(C):S!==0?d=ke(S):r||(r=s&~e,r!==0&&(d=ke(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 de(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function U(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 je(){var e=ce;return ce<<=1,(ce&62914560)===0&&(ce=4194304),e}function Ce(e){for(var n=[],r=0;31>r;r++)n.push(e);return n}function st(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ut(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 C=e.entanglements,I=e.expirationTimes,ie=e.hiddenUpdates;for(r=S&~r;0<r;){var ue=31-Ze(r),he=1<<ue;C[ue]=0,I[ue]=-1;var re=ie[ue];if(re!==null)for(ie[ue]=null,ue=0;ue<re.length;ue++){var oe=re[ue];oe!==null&&(oe.lane&=-536870913)}r&=~he}s!==0&&Ut(e,s,0),g!==0&&d===0&&e.tag!==0&&(e.suspendedLanes|=g&~(S&~n))}function Ut(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 Et(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 Gn(e,n){var r=n&-n;return r=(r&42)!==0?1:Ht(r),(r&(e.suspendedLanes|n))!==0?0:r}function Ht(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 xi(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function pl(){var e=X.p;return e!==0?e:(e=window.event,e===void 0?32:ig(e.type))}function xr(e,n){var r=X.p;try{return X.p=e,n()}finally{X.p=r}}var ln=Math.random().toString(36).slice(2),Zt="__reactFiber$"+ln,on="__reactProps$"+ln,Sr="__reactContainer$"+ln,go="__reactEvents$"+ln,Mv="__reactListeners$"+ln,_v="__reactHandles$"+ln,xd="__reactResources$"+ln,ml="__reactMarker$"+ln;function yo(e){delete e[Zt],delete e[on],delete e[go],delete e[Mv],delete e[_v]}function wr(e){var n=e[Zt];if(n)return n;for(var r=e.parentNode;r;){if(n=r[Sr]||r[Zt]){if(r=n.alternate,n.child!==null||r!==null&&r.child!==null)for(e=Hm(e);e!==null;){if(r=e[Zt])return r;e=Hm(e)}return n}e=r,r=e.parentNode}return null}function jr(e){if(e=e[Zt]||e[Sr]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function gl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(a(33))}function kr(e){var n=e[xd];return n||(n=e[xd]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Xt(e){e[ml]=!0}var Sd=new Set,wd={};function Xi(e,n){Cr(e,n),Cr(e+"Capture",n)}function Cr(e,n){for(wd[e]=n,e=0;e<n.length;e++)Sd.add(n[e])}var Ov=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]*$"),jd={},kd={};function Lv(e){return qe.call(kd,e)?!0:qe.call(jd,e)?!1:Ov.test(e)?kd[e]=!0:(jd[e]=!0,!1)}function Ea(e,n,r){if(Lv(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 Na(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 Jn(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 Cd(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Bv(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 bo(e){if(!e._valueTracker){var n=Cd(e)?"checked":"value";e._valueTracker=Bv(e,n,""+e[n])}}function Ed(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var r=n.getValue(),s="";return e&&(s=Cd(e)?e.checked?"true":"false":e.value),e=s,e!==r?(n.setValue(e),!0):!1}function Aa(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 Uv=/[\n"\\]/g;function An(e){return e.replace(Uv,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function vo(e,n,r,s,d,g,S,C){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?xo(e,S,Nn(n)):r!=null?xo(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"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?e.name=""+Nn(C):e.removeAttribute("name")}function Nd(e,n,r,s,d,g,S,C){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)){bo(e);return}r=r!=null?""+Nn(r):"",n=n!=null?""+Nn(n):r,C||n===e.value||(e.value=n),e.defaultValue=n}s=s??d,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=C?e.checked:!!s,e.defaultChecked=!!s,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),bo(e)}function xo(e,n,r){n==="number"&&Aa(e.ownerDocument)===e||e.defaultValue===""+r||(e.defaultValue=""+r)}function Er(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 Ad(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 Td(e,n,r,s){if(n==null){if(s!=null){if(r!=null)throw Error(a(92));if(W(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),bo(e)}function Nr(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 zd(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 Rd(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&&zd(e,d,s)}else for(var g in n)n.hasOwnProperty(g)&&zd(e,g,n[g])}function So(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 Iv=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"]]),Hv=/^[\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 Ta(e){return Hv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Wn(){}var wo=null;function jo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ar=null,Tr=null;function Dd(e){var n=jr(e);if(n&&(e=n.stateNode)){var r=e[on]||null;e:switch(e=n.stateNode,n.type){case"input":if(vo(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[on]||null;if(!d)throw Error(a(90));vo(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&&Ed(s)}break e;case"textarea":Ad(e,r.value,r.defaultValue);break e;case"select":n=r.value,n!=null&&Er(e,!!r.multiple,n,!1)}}}var ko=!1;function Md(e,n,r){if(ko)return e(n,r);ko=!0;try{var s=e(n);return s}finally{if(ko=!1,(Ar!==null||Tr!==null)&&(gs(),Ar&&(n=Ar,e=Tr,Tr=Ar=null,Dd(n),e)))for(n=0;n<e.length;n++)Dd(e[n])}}function yl(e,n){var r=e.stateNode;if(r===null)return null;var s=r[on]||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 ei=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Co=!1;if(ei)try{var bl={};Object.defineProperty(bl,"passive",{get:function(){Co=!0}}),window.addEventListener("test",bl,bl),window.removeEventListener("test",bl,bl)}catch{Co=!1}var Si=null,Eo=null,za=null;function _d(){if(za)return za;var e,n=Eo,r=n.length,s,d="value"in Si?Si.value:Si.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 za=d.slice(e,1<s?1-s:void 0)}function Ra(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 Da(){return!0}function Od(){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 C in e)e.hasOwnProperty(C)&&(r=e[C],this[C]=r?r(g):g[C]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Da:Od,this.isPropagationStopped=Od,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=Da)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=Da)},persist:function(){},isPersistent:Da}),n}var Ki={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ma=un(Ki),vl=b({},Ki,{view:0,detail:0}),Vv=un(vl),No,Ao,xl,_a=b({},vl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zo,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!==xl&&(xl&&e.type==="mousemove"?(No=e.screenX-xl.screenX,Ao=e.screenY-xl.screenY):Ao=No=0,xl=e),No)},movementY:function(e){return"movementY"in e?e.movementY:Ao}}),Ld=un(_a),Yv=b({},_a,{dataTransfer:0}),Gv=un(Yv),Fv=b({},vl,{relatedTarget:0}),To=un(Fv),Qv=b({},Ki,{animationName:0,elapsedTime:0,pseudoElement:0}),$v=un(Qv),Xv=b({},Ki,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Kv=un(Xv),Zv=b({},Ki,{data:0}),Bd=un(Zv),Pv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Jv={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"},Wv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ex(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Wv[e])?!!n[e]:!1}function zo(){return ex}var tx=b({},vl,{key:function(e){if(e.key){var n=Pv[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=Ra(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Jv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zo,charCode:function(e){return e.type==="keypress"?Ra(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ra(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),nx=un(tx),ix=b({},_a,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ud=un(ix),rx=b({},vl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zo}),lx=un(rx),ax=b({},Ki,{propertyName:0,elapsedTime:0,pseudoElement:0}),sx=un(ax),ox=b({},_a,{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}),ux=un(ox),cx=b({},Ki,{newState:0,oldState:0}),fx=un(cx),dx=[9,13,27,32],Ro=ei&&"CompositionEvent"in window,Sl=null;ei&&"documentMode"in document&&(Sl=document.documentMode);var hx=ei&&"TextEvent"in window&&!Sl,qd=ei&&(!Ro||Sl&&8<Sl&&11>=Sl),Id=" ",Hd=!1;function Vd(e,n){switch(e){case"keyup":return dx.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var zr=!1;function px(e,n){switch(e){case"compositionend":return Yd(n);case"keypress":return n.which!==32?null:(Hd=!0,Id);case"textInput":return e=n.data,e===Id&&Hd?null:e;default:return null}}function mx(e,n){if(zr)return e==="compositionend"||!Ro&&Vd(e,n)?(e=_d(),za=Eo=Si=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 qd&&n.locale!=="ko"?null:n.data;default:return null}}var gx={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 Gd(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!gx[e.type]:n==="textarea"}function Fd(e,n,r,s){Ar?Tr?Tr.push(s):Tr=[s]:Ar=s,n=js(n,"onChange"),0<n.length&&(r=new Ma("onChange","change",null,r,s),e.push({event:r,listeners:n}))}var wl=null,jl=null;function yx(e){Nm(e,0)}function Oa(e){var n=gl(e);if(Ed(n))return e}function Qd(e,n){if(e==="change")return n}var $d=!1;if(ei){var Do;if(ei){var Mo="oninput"in document;if(!Mo){var Xd=document.createElement("div");Xd.setAttribute("oninput","return;"),Mo=typeof Xd.oninput=="function"}Do=Mo}else Do=!1;$d=Do&&(!document.documentMode||9<document.documentMode)}function Kd(){wl&&(wl.detachEvent("onpropertychange",Zd),jl=wl=null)}function Zd(e){if(e.propertyName==="value"&&Oa(jl)){var n=[];Fd(n,jl,e,jo(e)),Md(yx,n)}}function bx(e,n,r){e==="focusin"?(Kd(),wl=n,jl=r,wl.attachEvent("onpropertychange",Zd)):e==="focusout"&&Kd()}function vx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Oa(jl)}function xx(e,n){if(e==="click")return Oa(n)}function Sx(e,n){if(e==="input"||e==="change")return Oa(n)}function wx(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var bn=typeof Object.is=="function"?Object.is:wx;function kl(e,n){if(bn(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)||!bn(e[d],n[d]))return!1}return!0}function Pd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Jd(e,n){var r=Pd(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=Pd(r)}}function Wd(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Wd(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function eh(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=Aa(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=Aa(e.document)}return n}function _o(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 jx=ei&&"documentMode"in document&&11>=document.documentMode,Rr=null,Oo=null,Cl=null,Lo=!1;function th(e,n,r){var s=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Lo||Rr==null||Rr!==Aa(s)||(s=Rr,"selectionStart"in s&&_o(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&&kl(Cl,s)||(Cl=s,s=js(Oo,"onSelect"),0<s.length&&(n=new Ma("onSelect","select",null,n,r),e.push({event:n,listeners:s}),n.target=Rr)))}function Zi(e,n){var r={};return r[e.toLowerCase()]=n.toLowerCase(),r["Webkit"+e]="webkit"+n,r["Moz"+e]="moz"+n,r}var Dr={animationend:Zi("Animation","AnimationEnd"),animationiteration:Zi("Animation","AnimationIteration"),animationstart:Zi("Animation","AnimationStart"),transitionrun:Zi("Transition","TransitionRun"),transitionstart:Zi("Transition","TransitionStart"),transitioncancel:Zi("Transition","TransitionCancel"),transitionend:Zi("Transition","TransitionEnd")},Bo={},nh={};ei&&(nh=document.createElement("div").style,"AnimationEvent"in window||(delete Dr.animationend.animation,delete Dr.animationiteration.animation,delete Dr.animationstart.animation),"TransitionEvent"in window||delete Dr.transitionend.transition);function Pi(e){if(Bo[e])return Bo[e];if(!Dr[e])return e;var n=Dr[e],r;for(r in n)if(n.hasOwnProperty(r)&&r in nh)return Bo[e]=n[r];return e}var ih=Pi("animationend"),rh=Pi("animationiteration"),lh=Pi("animationstart"),kx=Pi("transitionrun"),Cx=Pi("transitionstart"),Ex=Pi("transitioncancel"),ah=Pi("transitionend"),sh=new Map,Uo="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(" ");Uo.push("scrollEnd");function Un(e,n){sh.set(e,n),Xi(n,[e])}var La=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,qo=0;function Ba(){for(var e=Mr,n=qo=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&&oh(r,d,g)}}function Ua(e,n,r,s){Tn[Mr++]=e,Tn[Mr++]=n,Tn[Mr++]=r,Tn[Mr++]=s,qo|=s,e.lanes|=s,e=e.alternate,e!==null&&(e.lanes|=s)}function Io(e,n,r,s){return Ua(e,n,r,s),qa(e)}function Ji(e,n){return Ua(e,null,null,n),qa(e)}function oh(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 qa(e){if(50<$l)throw $l=0,Ku=null,Error(a(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var _r={};function Nx(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 vn(e,n,r,s){return new Nx(e,n,r,s)}function Ho(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ti(e,n){var r=e.alternate;return r===null?(r=vn(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 uh(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 Ia(e,n,r,s,d,g){var S=0;if(s=e,typeof e=="function")Ho(e)&&(S=1);else if(typeof e=="string")S=D0(e,r,le.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case q:return e=vn(31,r,n,d),e.elementType=q,e.lanes=g,e;case _:return Wi(r.children,d,g,n);case D:S=8,d|=24;break;case R:return e=vn(12,r,n,d|2),e.elementType=R,e.lanes=g,e;case ae:return e=vn(13,r,n,d),e.elementType=ae,e.lanes=g,e;case T:return e=vn(19,r,n,d),e.elementType=T,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case L:S=10;break e;case z:S=9;break e;case G:S=11;break e;case V:S=14;break e;case $:S=16,s=null;break e}S=29,r=Error(a(130,e===null?"null":typeof e,"")),s=null}return n=vn(S,r,n,d),n.elementType=e,n.type=s,n.lanes=g,n}function Wi(e,n,r,s){return e=vn(7,e,s,n),e.lanes=r,e}function Vo(e,n,r){return e=vn(6,e,null,n),e.lanes=r,e}function ch(e){var n=vn(18,null,null,0);return n.stateNode=e,n}function Yo(e,n,r){return n=vn(4,e.children!==null?e.children:[],e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var fh=new WeakMap;function zn(e,n){if(typeof e=="object"&&e!==null){var r=fh.get(e);return r!==void 0?r:(n={value:e,source:n,stack:ht(n)},fh.set(e,n),n)}return{value:e,source:n,stack:ht(n)}}var Or=[],Lr=0,Ha=null,El=0,Rn=[],Dn=0,wi=null,Fn=1,Qn="";function ni(e,n){Or[Lr++]=El,Or[Lr++]=Ha,Ha=e,El=n}function dh(e,n,r){Rn[Dn++]=Fn,Rn[Dn++]=Qn,Rn[Dn++]=wi,wi=e;var s=Fn;e=Qn;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,Fn=1<<32-Ze(n)+d|r<<d|s,Qn=g+e}else Fn=1<<g|r<<d|s,Qn=e}function Go(e){e.return!==null&&(ni(e,1),dh(e,1,0))}function Fo(e){for(;e===Ha;)Ha=Or[--Lr],Or[Lr]=null,El=Or[--Lr],Or[Lr]=null;for(;e===wi;)wi=Rn[--Dn],Rn[Dn]=null,Qn=Rn[--Dn],Rn[Dn]=null,Fn=Rn[--Dn],Rn[Dn]=null}function hh(e,n){Rn[Dn++]=Fn,Rn[Dn++]=Qn,Rn[Dn++]=wi,Fn=n.id,Qn=n.overflow,wi=e}var Pt=null,Rt=null,at=!1,ji=null,Mn=!1,Qo=Error(a(519));function ki(e){var n=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Nl(zn(n,e)),Qo}function ph(e){var n=e.stateNode,r=e.type,s=e.memoizedProps;switch(n[Zt]=e,n[on]=s,r){case"dialog":Je("cancel",n),Je("close",n);break;case"iframe":case"object":case"embed":Je("load",n);break;case"video":case"audio":for(r=0;r<Kl.length;r++)Je(Kl[r],n);break;case"source":Je("error",n);break;case"img":case"image":case"link":Je("error",n),Je("load",n);break;case"details":Je("toggle",n);break;case"input":Je("invalid",n),Nd(n,s.value,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name,!0);break;case"select":Je("invalid",n);break;case"textarea":Je("invalid",n),Td(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||Rm(n.textContent,r)?(s.popover!=null&&(Je("beforetoggle",n),Je("toggle",n)),s.onScroll!=null&&Je("scroll",n),s.onScrollEnd!=null&&Je("scrollend",n),s.onClick!=null&&(n.onclick=Wn),n=!0):n=!1,n||ki(e,!0)}function mh(e){for(Pt=e.return;Pt;)switch(Pt.tag){case 5:case 31:case 13:Mn=!1;return;case 27:case 3:Mn=!0;return;default:Pt=Pt.return}}function Br(e){if(e!==Pt)return!1;if(!at)return mh(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")||cc(e.type,e.memoizedProps)),r=!r),r&&Rt&&ki(e),mh(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Rt=Im(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Rt=Im(e)}else n===27?(n=Rt,Ui(e.type)?(e=mc,mc=null,Rt=e):Rt=n):Rt=Pt?On(e.stateNode.nextSibling):null;return!0}function er(){Rt=Pt=null,at=!1}function $o(){var e=ji;return e!==null&&(hn===null?hn=e:hn.push.apply(hn,e),ji=null),e}function Nl(e){ji===null?ji=[e]:ji.push(e)}var Xo=O(null),tr=null,ii=null;function Ci(e,n,r){A(Xo,n._currentValue),n._currentValue=r}function ri(e){e._currentValue=Xo.current,J(Xo)}function Ko(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 Zo(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 C=g;g=d;for(var I=0;I<n.length;I++)if(C.context===n[I]){g.lanes|=r,C=g.alternate,C!==null&&(C.lanes|=r),Ko(g.return,r,e),s||(S=null);break e}g=C.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),Ko(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 Ur(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 C=d.type;bn(d.pendingProps.value,S.value)||(e!==null?e.push(C):e=[C])}}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(ea):e=[ea])}d=d.return}e!==null&&Zo(n,e,r,s),n.flags|=262144}function Va(e){for(e=e.firstContext;e!==null;){if(!bn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function nr(e){tr=e,ii=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Jt(e){return gh(tr,e)}function Ya(e,n){return tr===null&&nr(e),gh(e,n)}function gh(e,n){var r=n._currentValue;if(n={context:n,memoizedValue:r,next:null},ii===null){if(e===null)throw Error(a(308));ii=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else ii=ii.next=n;return r}var Ax=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()})}},Tx=t.unstable_scheduleCallback,zx=t.unstable_NormalPriority,Vt={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Po(){return{controller:new Ax,data:new Map,refCount:0}}function Al(e){e.refCount--,e.refCount===0&&Tx(zx,function(){e.controller.abort()})}var Tl=null,Jo=0,qr=0,Ir=null;function Rx(e,n){if(Tl===null){var r=Tl=[];Jo=0,qr=tc(),Ir={status:"pending",value:void 0,then:function(s){r.push(s)}}}return Jo++,n.then(yh,yh),n}function yh(){if(--Jo===0&&Tl!==null){Ir!==null&&(Ir.status="fulfilled");var e=Tl;Tl=null,qr=0,Ir=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Dx(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 bh=N.S;N.S=function(e,n){tm=rt(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&Rx(e,n),bh!==null&&bh(e,n)};var ir=O(null);function Wo(){var e=ir.current;return e!==null?e:Nt.pooledCache}function Ga(e,n){n===null?A(ir,ir.current):A(ir,n.pool)}function vh(){var e=Wo();return e===null?null:{parent:Vt._currentValue,pool:e}}var Hr=Error(a(460)),eu=Error(a(474)),Fa=Error(a(542)),Qa={then:function(){}};function xh(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Sh(e,n,r){switch(r=e[r],r===void 0?e.push(n):r!==n&&(n.then(Wn,Wn),n=r),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,jh(e),e;default:if(typeof n.status=="string")n.then(Wn,Wn);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,jh(e),e}throw lr=n,Hr}}function rr(e){try{var n=e._init;return n(e._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(lr=r,Hr):r}}var lr=null;function wh(){if(lr===null)throw Error(a(459));var e=lr;return lr=null,e}function jh(e){if(e===Hr||e===Fa)throw Error(a(483))}var Vr=null,zl=0;function $a(e){var n=zl;return zl+=1,Vr===null&&(Vr=[]),Sh(Vr,e,n)}function Rl(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Xa(e,n){throw n.$$typeof===v?Error(a(525)):(e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function kh(e){function n(P,Y){if(e){var ne=P.deletions;ne===null?(P.deletions=[Y],P.flags|=16):ne.push(Y)}}function r(P,Y){if(!e)return null;for(;Y!==null;)n(P,Y),Y=Y.sibling;return null}function s(P){for(var Y=new Map;P!==null;)P.key!==null?Y.set(P.key,P):Y.set(P.index,P),P=P.sibling;return Y}function d(P,Y){return P=ti(P,Y),P.index=0,P.sibling=null,P}function g(P,Y,ne){return P.index=ne,e?(ne=P.alternate,ne!==null?(ne=ne.index,ne<Y?(P.flags|=67108866,Y):ne):(P.flags|=67108866,Y)):(P.flags|=1048576,Y)}function S(P){return e&&P.alternate===null&&(P.flags|=67108866),P}function C(P,Y,ne,fe){return Y===null||Y.tag!==6?(Y=Vo(ne,P.mode,fe),Y.return=P,Y):(Y=d(Y,ne),Y.return=P,Y)}function I(P,Y,ne,fe){var _e=ne.type;return _e===_?ue(P,Y,ne.props.children,fe,ne.key):Y!==null&&(Y.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===$&&rr(_e)===Y.type)?(Y=d(Y,ne.props),Rl(Y,ne),Y.return=P,Y):(Y=Ia(ne.type,ne.key,ne.props,null,P.mode,fe),Rl(Y,ne),Y.return=P,Y)}function ie(P,Y,ne,fe){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==ne.containerInfo||Y.stateNode.implementation!==ne.implementation?(Y=Yo(ne,P.mode,fe),Y.return=P,Y):(Y=d(Y,ne.children||[]),Y.return=P,Y)}function ue(P,Y,ne,fe,_e){return Y===null||Y.tag!==7?(Y=Wi(ne,P.mode,fe,_e),Y.return=P,Y):(Y=d(Y,ne),Y.return=P,Y)}function he(P,Y,ne){if(typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint")return Y=Vo(""+Y,P.mode,ne),Y.return=P,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case x:return ne=Ia(Y.type,Y.key,Y.props,null,P.mode,ne),Rl(ne,Y),ne.return=P,ne;case k:return Y=Yo(Y,P.mode,ne),Y.return=P,Y;case $:return Y=rr(Y),he(P,Y,ne)}if(W(Y)||H(Y))return Y=Wi(Y,P.mode,ne,null),Y.return=P,Y;if(typeof Y.then=="function")return he(P,$a(Y),ne);if(Y.$$typeof===L)return he(P,Ya(P,Y),ne);Xa(P,Y)}return null}function re(P,Y,ne,fe){var _e=Y!==null?Y.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return _e!==null?null:C(P,Y,""+ne,fe);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case x:return ne.key===_e?I(P,Y,ne,fe):null;case k:return ne.key===_e?ie(P,Y,ne,fe):null;case $:return ne=rr(ne),re(P,Y,ne,fe)}if(W(ne)||H(ne))return _e!==null?null:ue(P,Y,ne,fe,null);if(typeof ne.then=="function")return re(P,Y,$a(ne),fe);if(ne.$$typeof===L)return re(P,Y,Ya(P,ne),fe);Xa(P,ne)}return null}function oe(P,Y,ne,fe,_e){if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return P=P.get(ne)||null,C(Y,P,""+fe,_e);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case x:return P=P.get(fe.key===null?ne:fe.key)||null,I(Y,P,fe,_e);case k:return P=P.get(fe.key===null?ne:fe.key)||null,ie(Y,P,fe,_e);case $:return fe=rr(fe),oe(P,Y,ne,fe,_e)}if(W(fe)||H(fe))return P=P.get(ne)||null,ue(Y,P,fe,_e,null);if(typeof fe.then=="function")return oe(P,Y,ne,$a(fe),_e);if(fe.$$typeof===L)return oe(P,Y,ne,Ya(Y,fe),_e);Xa(Y,fe)}return null}function Ae(P,Y,ne,fe){for(var _e=null,ct=null,Re=Y,Qe=Y=0,it=null;Re!==null&&Qe<ne.length;Qe++){Re.index>Qe?(it=Re,Re=null):it=Re.sibling;var ft=re(P,Re,ne[Qe],fe);if(ft===null){Re===null&&(Re=it);break}e&&Re&&ft.alternate===null&&n(P,Re),Y=g(ft,Y,Qe),ct===null?_e=ft:ct.sibling=ft,ct=ft,Re=it}if(Qe===ne.length)return r(P,Re),at&&ni(P,Qe),_e;if(Re===null){for(;Qe<ne.length;Qe++)Re=he(P,ne[Qe],fe),Re!==null&&(Y=g(Re,Y,Qe),ct===null?_e=Re:ct.sibling=Re,ct=Re);return at&&ni(P,Qe),_e}for(Re=s(Re);Qe<ne.length;Qe++)it=oe(Re,P,Qe,ne[Qe],fe),it!==null&&(e&&it.alternate!==null&&Re.delete(it.key===null?Qe:it.key),Y=g(it,Y,Qe),ct===null?_e=it:ct.sibling=it,ct=it);return e&&Re.forEach(function(Yi){return n(P,Yi)}),at&&ni(P,Qe),_e}function Be(P,Y,ne,fe){if(ne==null)throw Error(a(151));for(var _e=null,ct=null,Re=Y,Qe=Y=0,it=null,ft=ne.next();Re!==null&&!ft.done;Qe++,ft=ne.next()){Re.index>Qe?(it=Re,Re=null):it=Re.sibling;var Yi=re(P,Re,ft.value,fe);if(Yi===null){Re===null&&(Re=it);break}e&&Re&&Yi.alternate===null&&n(P,Re),Y=g(Yi,Y,Qe),ct===null?_e=Yi:ct.sibling=Yi,ct=Yi,Re=it}if(ft.done)return r(P,Re),at&&ni(P,Qe),_e;if(Re===null){for(;!ft.done;Qe++,ft=ne.next())ft=he(P,ft.value,fe),ft!==null&&(Y=g(ft,Y,Qe),ct===null?_e=ft:ct.sibling=ft,ct=ft);return at&&ni(P,Qe),_e}for(Re=s(Re);!ft.done;Qe++,ft=ne.next())ft=oe(Re,P,Qe,ft.value,fe),ft!==null&&(e&&ft.alternate!==null&&Re.delete(ft.key===null?Qe:ft.key),Y=g(ft,Y,Qe),ct===null?_e=ft:ct.sibling=ft,ct=ft);return e&&Re.forEach(function(Y0){return n(P,Y0)}),at&&ni(P,Qe),_e}function kt(P,Y,ne,fe){if(typeof ne=="object"&&ne!==null&&ne.type===_&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case x:e:{for(var _e=ne.key;Y!==null;){if(Y.key===_e){if(_e=ne.type,_e===_){if(Y.tag===7){r(P,Y.sibling),fe=d(Y,ne.props.children),fe.return=P,P=fe;break e}}else if(Y.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===$&&rr(_e)===Y.type){r(P,Y.sibling),fe=d(Y,ne.props),Rl(fe,ne),fe.return=P,P=fe;break e}r(P,Y);break}else n(P,Y);Y=Y.sibling}ne.type===_?(fe=Wi(ne.props.children,P.mode,fe,ne.key),fe.return=P,P=fe):(fe=Ia(ne.type,ne.key,ne.props,null,P.mode,fe),Rl(fe,ne),fe.return=P,P=fe)}return S(P);case k:e:{for(_e=ne.key;Y!==null;){if(Y.key===_e)if(Y.tag===4&&Y.stateNode.containerInfo===ne.containerInfo&&Y.stateNode.implementation===ne.implementation){r(P,Y.sibling),fe=d(Y,ne.children||[]),fe.return=P,P=fe;break e}else{r(P,Y);break}else n(P,Y);Y=Y.sibling}fe=Yo(ne,P.mode,fe),fe.return=P,P=fe}return S(P);case $:return ne=rr(ne),kt(P,Y,ne,fe)}if(W(ne))return Ae(P,Y,ne,fe);if(H(ne)){if(_e=H(ne),typeof _e!="function")throw Error(a(150));return ne=_e.call(ne),Be(P,Y,ne,fe)}if(typeof ne.then=="function")return kt(P,Y,$a(ne),fe);if(ne.$$typeof===L)return kt(P,Y,Ya(P,ne),fe);Xa(P,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint"?(ne=""+ne,Y!==null&&Y.tag===6?(r(P,Y.sibling),fe=d(Y,ne),fe.return=P,P=fe):(r(P,Y),fe=Vo(ne,P.mode,fe),fe.return=P,P=fe),S(P)):r(P,Y)}return function(P,Y,ne,fe){try{zl=0;var _e=kt(P,Y,ne,fe);return Vr=null,_e}catch(Re){if(Re===Hr||Re===Fa)throw Re;var ct=vn(29,Re,null,P.mode);return ct.lanes=fe,ct.return=P,ct}}}var ar=kh(!0),Ch=kh(!1),Ei=!1;function tu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function nu(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 Ni(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ai(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=qa(e),oh(e,null,r),n}return Ua(e,s,n,r),qa(e)}function Dl(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,Et(e,r)}}function iu(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 ru=!1;function Ml(){if(ru){var e=Ir;if(e!==null)throw e}}function _l(e,n,r,s){ru=!1;var d=e.updateQueue;Ei=!1;var g=d.firstBaseUpdate,S=d.lastBaseUpdate,C=d.shared.pending;if(C!==null){d.shared.pending=null;var I=C,ie=I.next;I.next=null,S===null?g=ie:S.next=ie,S=I;var ue=e.alternate;ue!==null&&(ue=ue.updateQueue,C=ue.lastBaseUpdate,C!==S&&(C===null?ue.firstBaseUpdate=ie:C.next=ie,ue.lastBaseUpdate=I))}if(g!==null){var he=d.baseState;S=0,ue=ie=I=null,C=g;do{var re=C.lane&-536870913,oe=re!==C.lane;if(oe?(nt&re)===re:(s&re)===re){re!==0&&re===qr&&(ru=!0),ue!==null&&(ue=ue.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Ae=e,Be=C;re=n;var kt=r;switch(Be.tag){case 1:if(Ae=Be.payload,typeof Ae=="function"){he=Ae.call(kt,he,re);break e}he=Ae;break e;case 3:Ae.flags=Ae.flags&-65537|128;case 0:if(Ae=Be.payload,re=typeof Ae=="function"?Ae.call(kt,he,re):Ae,re==null)break e;he=b({},he,re);break e;case 2:Ei=!0}}re=C.callback,re!==null&&(e.flags|=64,oe&&(e.flags|=8192),oe=d.callbacks,oe===null?d.callbacks=[re]:oe.push(re))}else oe={lane:re,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ue===null?(ie=ue=oe,I=he):ue=ue.next=oe,S|=re;if(C=C.next,C===null){if(C=d.shared.pending,C===null)break;oe=C,C=oe.next,oe.next=null,d.lastBaseUpdate=oe,d.shared.pending=null}}while(!0);ue===null&&(I=he),d.baseState=I,d.firstBaseUpdate=ie,d.lastBaseUpdate=ue,g===null&&(d.shared.lanes=0),Mi|=S,e.lanes=S,e.memoizedState=he}}function Eh(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function Nh(e,n){var r=e.callbacks;if(r!==null)for(e.callbacks=null,e=0;e<r.length;e++)Eh(r[e],n)}var Yr=O(null),Ka=O(0);function Ah(e,n){e=hi,A(Ka,e),A(Yr,n),hi=e|n.baseLanes}function lu(){A(Ka,hi),A(Yr,Yr.current)}function au(){hi=Ka.current,J(Yr),J(Ka)}var xn=O(null),_n=null;function Ti(e){var n=e.alternate;A(qt,qt.current&1),A(xn,e),_n===null&&(n===null||Yr.current!==null||n.memoizedState!==null)&&(_n=e)}function su(e){A(qt,qt.current),A(xn,e),_n===null&&(_n=e)}function Th(e){e.tag===22?(A(qt,qt.current),A(xn,e),_n===null&&(_n=e)):zi()}function zi(){A(qt,qt.current),A(xn,xn.current)}function Sn(e){J(xn),_n===e&&(_n=null),J(qt)}var qt=O(0);function Za(e){for(var n=e;n!==null;){if(n.tag===13){var r=n.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||hc(r)||pc(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 li=0,Ye=null,wt=null,Yt=null,Pa=!1,Gr=!1,sr=!1,Ja=0,Ol=0,Fr=null,Mx=0;function Lt(){throw Error(a(321))}function ou(e,n){if(n===null)return!1;for(var r=0;r<n.length&&r<e.length;r++)if(!bn(e[r],n[r]))return!1;return!0}function uu(e,n,r,s,d,g){return li=g,Ye=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,N.H=e===null||e.memoizedState===null?dp:ku,sr=!1,g=r(s,d),sr=!1,Gr&&(g=Rh(n,r,s,d)),zh(e),g}function zh(e){N.H=Ul;var n=wt!==null&&wt.next!==null;if(li=0,Yt=wt=Ye=null,Pa=!1,Ol=0,Fr=null,n)throw Error(a(300));e===null||Gt||(e=e.dependencies,e!==null&&Va(e)&&(Gt=!0))}function Rh(e,n,r,s){Ye=e;var d=0;do{if(Gr&&(Fr=null),Ol=0,Gr=!1,25<=d)throw Error(a(301));if(d+=1,Yt=wt=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}N.H=hp,g=n(r,s)}while(Gr);return g}function _x(){var e=N.H,n=e.useState()[0];return n=typeof n.then=="function"?Ll(n):n,e=e.useState()[0],(wt!==null?wt.memoizedState:null)!==e&&(Ye.flags|=1024),n}function cu(){var e=Ja!==0;return Ja=0,e}function fu(e,n,r){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r}function du(e){if(Pa){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Pa=!1}li=0,Yt=wt=Ye=null,Gr=!1,Ol=Ja=0,Fr=null}function an(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Yt===null?Ye.memoizedState=Yt=e:Yt=Yt.next=e,Yt}function It(){if(wt===null){var e=Ye.alternate;e=e!==null?e.memoizedState:null}else e=wt.next;var n=Yt===null?Ye.memoizedState:Yt.next;if(n!==null)Yt=n,wt=e;else{if(e===null)throw Ye.alternate===null?Error(a(467)):Error(a(310));wt=e,e={memoizedState:wt.memoizedState,baseState:wt.baseState,baseQueue:wt.baseQueue,queue:wt.queue,next:null},Yt===null?Ye.memoizedState=Yt=e:Yt=Yt.next=e}return Yt}function Wa(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ll(e){var n=Ol;return Ol+=1,Fr===null&&(Fr=[]),e=Sh(Fr,e,n),n=Ye,(Yt===null?n.memoizedState:Yt.next)===null&&(n=n.alternate,N.H=n===null||n.memoizedState===null?dp:ku),e}function es(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Ll(e);if(e.$$typeof===L)return Jt(e)}throw Error(a(438,String(e)))}function hu(e){var n=null,r=Ye.updateQueue;if(r!==null&&(n=r.memoCache),n==null){var s=Ye.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=Wa(),Ye.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]=E;return n.index++,r}function ai(e,n){return typeof n=="function"?n(e):n}function ts(e){var n=It();return pu(n,wt,e)}function pu(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 C=S=null,I=null,ie=n,ue=!1;do{var he=ie.lane&-536870913;if(he!==ie.lane?(nt&he)===he:(li&he)===he){var re=ie.revertLane;if(re===0)I!==null&&(I=I.next={lane:0,revertLane:0,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),he===qr&&(ue=!0);else if((li&re)===re){ie=ie.next,re===qr&&(ue=!0);continue}else he={lane:0,revertLane:ie.revertLane,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},I===null?(C=I=he,S=g):I=I.next=he,Ye.lanes|=re,Mi|=re;he=ie.action,sr&&r(g,he),g=ie.hasEagerState?ie.eagerState:r(g,he)}else re={lane:he,revertLane:ie.revertLane,gesture:ie.gesture,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},I===null?(C=I=re,S=g):I=I.next=re,Ye.lanes|=he,Mi|=he;ie=ie.next}while(ie!==null&&ie!==n);if(I===null?S=g:I.next=C,!bn(g,e.memoizedState)&&(Gt=!0,ue&&(r=Ir,r!==null)))throw r;e.memoizedState=g,e.baseState=S,e.baseQueue=I,s.lastRenderedState=g}return d===null&&(s.lanes=0),[e.memoizedState,s.dispatch]}function mu(e){var n=It(),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);bn(g,n.memoizedState)||(Gt=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),r.lastRenderedState=g}return[g,s]}function Dh(e,n,r){var s=Ye,d=It(),g=at;if(g){if(r===void 0)throw Error(a(407));r=r()}else r=n();var S=!bn((wt||d).memoizedState,r);if(S&&(d.memoizedState=r,Gt=!0),d=d.queue,bu(Oh.bind(null,s,d,e),[e]),d.getSnapshot!==n||S||Yt!==null&&Yt.memoizedState.tag&1){if(s.flags|=2048,Qr(9,{destroy:void 0},_h.bind(null,s,d,r,n),null),Nt===null)throw Error(a(349));g||(li&127)!==0||Mh(s,n,r)}return r}function Mh(e,n,r){e.flags|=16384,e={getSnapshot:n,value:r},n=Ye.updateQueue,n===null?(n=Wa(),Ye.updateQueue=n,n.stores=[e]):(r=n.stores,r===null?n.stores=[e]:r.push(e))}function _h(e,n,r,s){n.value=r,n.getSnapshot=s,Lh(n)&&Bh(e)}function Oh(e,n,r){return r(function(){Lh(n)&&Bh(e)})}function Lh(e){var n=e.getSnapshot;e=e.value;try{var r=n();return!bn(e,r)}catch{return!0}}function Bh(e){var n=Ji(e,2);n!==null&&pn(n,e,2)}function gu(e){var n=an();if(typeof e=="function"){var r=e;if(e=r(),sr){lt(!0);try{r()}finally{lt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ai,lastRenderedState:e},n}function Uh(e,n,r,s){return e.baseState=r,pu(e,wt,typeof s=="function"?s:ai)}function Ox(e,n,r,s,d){if(rs(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)}};N.T!==null?r(!0):g.isTransition=!1,s(g),r=n.pending,r===null?(g.next=n.pending=g,qh(n,g)):(g.next=r.next,n.pending=r.next=g)}}function qh(e,n){var r=n.action,s=n.payload,d=e.state;if(n.isTransition){var g=N.T,S={};N.T=S;try{var C=r(d,s),I=N.S;I!==null&&I(S,C),Ih(e,n,C)}catch(ie){yu(e,n,ie)}finally{g!==null&&S.types!==null&&(g.types=S.types),N.T=g}}else try{g=r(d,s),Ih(e,n,g)}catch(ie){yu(e,n,ie)}}function Ih(e,n,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(s){Hh(e,n,s)},function(s){return yu(e,n,s)}):Hh(e,n,r)}function Hh(e,n,r){n.status="fulfilled",n.value=r,Vh(n),e.state=r,n=e.pending,n!==null&&(r=n.next,r===n?e.pending=null:(r=r.next,n.next=r,qh(e,r)))}function yu(e,n,r){var s=e.pending;if(e.pending=null,s!==null){s=s.next;do n.status="rejected",n.reason=r,Vh(n),n=n.next;while(n!==s)}e.action=null}function Vh(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function Yh(e,n){return n}function Gh(e,n){if(at){var r=Nt.formState;if(r!==null){e:{var s=Ye;if(at){if(Rt){t:{for(var d=Rt,g=Mn;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){Rt=On(d.nextSibling),s=d.data==="F!";break e}}ki(s)}s=!1}s&&(n=r[0])}}return r=an(),r.memoizedState=r.baseState=n,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yh,lastRenderedState:n},r.queue=s,r=up.bind(null,Ye,s),s.dispatch=r,s=gu(!1),g=ju.bind(null,Ye,!1,s.queue),s=an(),d={state:n,dispatch:null,action:e,pending:null},s.queue=d,r=Ox.bind(null,Ye,d,g,r),d.dispatch=r,s.memoizedState=e,[n,r,!1]}function Fh(e){var n=It();return Qh(n,wt,e)}function Qh(e,n,r){if(n=pu(e,n,Yh)[0],e=ts(ai)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var s=Ll(n)}catch(S){throw S===Hr?Fa:S}else s=n;n=It();var d=n.queue,g=d.dispatch;return r!==n.memoizedState&&(Ye.flags|=2048,Qr(9,{destroy:void 0},Lx.bind(null,d,r),null)),[s,g,e]}function Lx(e,n){e.action=n}function $h(e){var n=It(),r=wt;if(r!==null)return Qh(n,r,e);It(),n=n.memoizedState,r=It();var s=r.queue.dispatch;return r.memoizedState=e,[n,s,!1]}function Qr(e,n,r,s){return e={tag:e,create:r,deps:s,inst:n,next:null},n=Ye.updateQueue,n===null&&(n=Wa(),Ye.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 Xh(){return It().memoizedState}function ns(e,n,r,s){var d=an();Ye.flags|=e,d.memoizedState=Qr(1|n,{destroy:void 0},r,s===void 0?null:s)}function is(e,n,r,s){var d=It();s=s===void 0?null:s;var g=d.memoizedState.inst;wt!==null&&s!==null&&ou(s,wt.memoizedState.deps)?d.memoizedState=Qr(n,g,r,s):(Ye.flags|=e,d.memoizedState=Qr(1|n,g,r,s))}function Kh(e,n){ns(8390656,8,e,n)}function bu(e,n){is(2048,8,e,n)}function Bx(e){Ye.flags|=4;var n=Ye.updateQueue;if(n===null)n=Wa(),Ye.updateQueue=n,n.events=[e];else{var r=n.events;r===null?n.events=[e]:r.push(e)}}function Zh(e){var n=It().memoizedState;return Bx({ref:n,nextImpl:e}),function(){if((gt&2)!==0)throw Error(a(440));return n.impl.apply(void 0,arguments)}}function Ph(e,n){return is(4,2,e,n)}function Jh(e,n){return is(4,4,e,n)}function Wh(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 ep(e,n,r){r=r!=null?r.concat([e]):null,is(4,4,Wh.bind(null,n,e),r)}function vu(){}function tp(e,n){var r=It();n=n===void 0?null:n;var s=r.memoizedState;return n!==null&&ou(n,s[1])?s[0]:(r.memoizedState=[e,n],e)}function np(e,n){var r=It();n=n===void 0?null:n;var s=r.memoizedState;if(n!==null&&ou(n,s[1]))return s[0];if(s=e(),sr){lt(!0);try{e()}finally{lt(!1)}}return r.memoizedState=[s,n],s}function xu(e,n,r){return r===void 0||(li&1073741824)!==0&&(nt&261930)===0?e.memoizedState=n:(e.memoizedState=r,e=im(),Ye.lanes|=e,Mi|=e,r)}function ip(e,n,r,s){return bn(r,n)?r:Yr.current!==null?(e=xu(e,r,s),bn(e,n)||(Gt=!0),e):(li&42)===0||(li&1073741824)!==0&&(nt&261930)===0?(Gt=!0,e.memoizedState=r):(e=im(),Ye.lanes|=e,Mi|=e,n)}function rp(e,n,r,s,d){var g=X.p;X.p=g!==0&&8>g?g:8;var S=N.T,C={};N.T=C,ju(e,!1,n,r);try{var I=d(),ie=N.S;if(ie!==null&&ie(C,I),I!==null&&typeof I=="object"&&typeof I.then=="function"){var ue=Dx(I,s);Bl(e,n,ue,kn(e))}else Bl(e,n,s,kn(e))}catch(he){Bl(e,n,{then:function(){},status:"rejected",reason:he},kn())}finally{X.p=g,S!==null&&C.types!==null&&(S.types=C.types),N.T=S}}function Ux(){}function Su(e,n,r,s){if(e.tag!==5)throw Error(a(476));var d=lp(e).queue;rp(e,d,n,pe,r===null?Ux:function(){return ap(e),r(s)})}function lp(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:pe,baseState:pe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ai,lastRenderedState:pe},next:null};var r={};return n.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ai,lastRenderedState:r},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function ap(e){var n=lp(e);n.next===null&&(n=e.alternate.memoizedState),Bl(e,n.next.queue,{},kn())}function wu(){return Jt(ea)}function sp(){return It().memoizedState}function op(){return It().memoizedState}function qx(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var r=kn();e=Ni(r);var s=Ai(n,e,r);s!==null&&(pn(s,n,r),Dl(s,n,r)),n={cache:Po()},e.payload=n;return}n=n.return}}function Ix(e,n,r){var s=kn();r={lane:s,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},rs(e)?cp(n,r):(r=Io(e,n,r,s),r!==null&&(pn(r,e,s),fp(r,n,s)))}function up(e,n,r){var s=kn();Bl(e,n,r,s)}function Bl(e,n,r,s){var d={lane:s,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(rs(e))cp(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,C=g(S,r);if(d.hasEagerState=!0,d.eagerState=C,bn(C,S))return Ua(e,n,d,0),Nt===null&&Ba(),!1}catch{}if(r=Io(e,n,d,s),r!==null)return pn(r,e,s),fp(r,n,s),!0}return!1}function ju(e,n,r,s){if(s={lane:2,revertLane:tc(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},rs(e)){if(n)throw Error(a(479))}else n=Io(e,r,s,2),n!==null&&pn(n,e,2)}function rs(e){var n=e.alternate;return e===Ye||n!==null&&n===Ye}function cp(e,n){Gr=Pa=!0;var r=e.pending;r===null?n.next=n:(n.next=r.next,r.next=n),e.pending=n}function fp(e,n,r){if((r&4194048)!==0){var s=n.lanes;s&=e.pendingLanes,r|=s,n.lanes=r,Et(e,r)}}var Ul={readContext:Jt,use:es,useCallback:Lt,useContext:Lt,useEffect:Lt,useImperativeHandle:Lt,useLayoutEffect:Lt,useInsertionEffect:Lt,useMemo:Lt,useReducer:Lt,useRef:Lt,useState:Lt,useDebugValue:Lt,useDeferredValue:Lt,useTransition:Lt,useSyncExternalStore:Lt,useId:Lt,useHostTransitionStatus:Lt,useFormState:Lt,useActionState:Lt,useOptimistic:Lt,useMemoCache:Lt,useCacheRefresh:Lt};Ul.useEffectEvent=Lt;var dp={readContext:Jt,use:es,useCallback:function(e,n){return an().memoizedState=[e,n===void 0?null:n],e},useContext:Jt,useEffect:Kh,useImperativeHandle:function(e,n,r){r=r!=null?r.concat([e]):null,ns(4194308,4,Wh.bind(null,n,e),r)},useLayoutEffect:function(e,n){return ns(4194308,4,e,n)},useInsertionEffect:function(e,n){ns(4,2,e,n)},useMemo:function(e,n){var r=an();n=n===void 0?null:n;var s=e();if(sr){lt(!0);try{e()}finally{lt(!1)}}return r.memoizedState=[s,n],s},useReducer:function(e,n,r){var s=an();if(r!==void 0){var d=r(n);if(sr){lt(!0);try{r(n)}finally{lt(!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=Ix.bind(null,Ye,e),[s.memoizedState,e]},useRef:function(e){var n=an();return e={current:e},n.memoizedState=e},useState:function(e){e=gu(e);var n=e.queue,r=up.bind(null,Ye,n);return n.dispatch=r,[e.memoizedState,r]},useDebugValue:vu,useDeferredValue:function(e,n){var r=an();return xu(r,e,n)},useTransition:function(){var e=gu(!1);return e=rp.bind(null,Ye,e.queue,!0,!1),an().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,r){var s=Ye,d=an();if(at){if(r===void 0)throw Error(a(407));r=r()}else{if(r=n(),Nt===null)throw Error(a(349));(nt&127)!==0||Mh(s,n,r)}d.memoizedState=r;var g={value:r,getSnapshot:n};return d.queue=g,Kh(Oh.bind(null,s,g,e),[e]),s.flags|=2048,Qr(9,{destroy:void 0},_h.bind(null,s,g,r,n),null),r},useId:function(){var e=an(),n=Nt.identifierPrefix;if(at){var r=Qn,s=Fn;r=(s&~(1<<32-Ze(s)-1)).toString(32)+r,n="_"+n+"R_"+r,r=Ja++,0<r&&(n+="H"+r.toString(32)),n+="_"}else r=Mx++,n="_"+n+"r_"+r.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:wu,useFormState:Gh,useActionState:Gh,useOptimistic:function(e){var n=an();n.memoizedState=n.baseState=e;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=r,n=ju.bind(null,Ye,!0,r),r.dispatch=n,[e,n]},useMemoCache:hu,useCacheRefresh:function(){return an().memoizedState=qx.bind(null,Ye)},useEffectEvent:function(e){var n=an(),r={impl:e};return n.memoizedState=r,function(){if((gt&2)!==0)throw Error(a(440));return r.impl.apply(void 0,arguments)}}},ku={readContext:Jt,use:es,useCallback:tp,useContext:Jt,useEffect:bu,useImperativeHandle:ep,useInsertionEffect:Ph,useLayoutEffect:Jh,useMemo:np,useReducer:ts,useRef:Xh,useState:function(){return ts(ai)},useDebugValue:vu,useDeferredValue:function(e,n){var r=It();return ip(r,wt.memoizedState,e,n)},useTransition:function(){var e=ts(ai)[0],n=It().memoizedState;return[typeof e=="boolean"?e:Ll(e),n]},useSyncExternalStore:Dh,useId:sp,useHostTransitionStatus:wu,useFormState:Fh,useActionState:Fh,useOptimistic:function(e,n){var r=It();return Uh(r,wt,e,n)},useMemoCache:hu,useCacheRefresh:op};ku.useEffectEvent=Zh;var hp={readContext:Jt,use:es,useCallback:tp,useContext:Jt,useEffect:bu,useImperativeHandle:ep,useInsertionEffect:Ph,useLayoutEffect:Jh,useMemo:np,useReducer:mu,useRef:Xh,useState:function(){return mu(ai)},useDebugValue:vu,useDeferredValue:function(e,n){var r=It();return wt===null?xu(r,e,n):ip(r,wt.memoizedState,e,n)},useTransition:function(){var e=mu(ai)[0],n=It().memoizedState;return[typeof e=="boolean"?e:Ll(e),n]},useSyncExternalStore:Dh,useId:sp,useHostTransitionStatus:wu,useFormState:$h,useActionState:$h,useOptimistic:function(e,n){var r=It();return wt!==null?Uh(r,wt,e,n):(r.baseState=e,[e,r.queue.dispatch])},useMemoCache:hu,useCacheRefresh:op};hp.useEffectEvent=Zh;function Cu(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 Eu={enqueueSetState:function(e,n,r){e=e._reactInternals;var s=kn(),d=Ni(s);d.payload=n,r!=null&&(d.callback=r),n=Ai(e,d,s),n!==null&&(pn(n,e,s),Dl(n,e,s))},enqueueReplaceState:function(e,n,r){e=e._reactInternals;var s=kn(),d=Ni(s);d.tag=1,d.payload=n,r!=null&&(d.callback=r),n=Ai(e,d,s),n!==null&&(pn(n,e,s),Dl(n,e,s))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var r=kn(),s=Ni(r);s.tag=2,n!=null&&(s.callback=n),n=Ai(e,s,r),n!==null&&(pn(n,e,r),Dl(n,e,r))}};function pp(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?!kl(r,s)||!kl(d,g):!0}function mp(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&&Eu.enqueueReplaceState(n,n.state,null)}function or(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 gp(e){La(e)}function yp(e){console.error(e)}function bp(e){La(e)}function ls(e,n){try{var r=e.onUncaughtError;r(n.value,{componentStack:n.stack})}catch(s){setTimeout(function(){throw s})}}function vp(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 Nu(e,n,r){return r=Ni(r),r.tag=3,r.payload={element:null},r.callback=function(){ls(e,n)},r}function xp(e){return e=Ni(e),e.tag=3,e}function Sp(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(){vp(n,r,s)}}var S=r.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){vp(n,r,s),typeof d!="function"&&(_i===null?_i=new Set([this]):_i.add(this));var C=s.stack;this.componentDidCatch(s.value,{componentStack:C!==null?C:""})})}function Hx(e,n,r,s,d){if(r.flags|=32768,s!==null&&typeof s=="object"&&typeof s.then=="function"){if(n=r.alternate,n!==null&&Ur(n,r,d,!0),r=xn.current,r!==null){switch(r.tag){case 31:case 13:return _n===null?ys():r.alternate===null&&Bt===0&&(Bt=3),r.flags&=-257,r.flags|=65536,r.lanes=d,s===Qa?r.flags|=16384:(n=r.updateQueue,n===null?r.updateQueue=new Set([s]):n.add(s),Ju(e,s,d)),!1;case 22:return r.flags|=65536,s===Qa?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)),Ju(e,s,d)),!1}throw Error(a(435,r.tag))}return Ju(e,s,d),ys(),!1}if(at)return n=xn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=d,s!==Qo&&(e=Error(a(422),{cause:s}),Nl(zn(e,r)))):(s!==Qo&&(n=Error(a(423),{cause:s}),Nl(zn(n,r))),e=e.current.alternate,e.flags|=65536,d&=-d,e.lanes|=d,s=zn(s,r),d=Nu(e.stateNode,s,d),iu(e,d),Bt!==4&&(Bt=2)),!1;var g=Error(a(520),{cause:s});if(g=zn(g,r),Ql===null?Ql=[g]:Ql.push(g),Bt!==4&&(Bt=2),n===null)return!0;s=zn(s,r),r=n;do{switch(r.tag){case 3:return r.flags|=65536,e=d&-d,r.lanes|=e,e=Nu(r.stateNode,s,e),iu(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"&&(_i===null||!_i.has(g))))return r.flags|=65536,d&=-d,r.lanes|=d,d=xp(d),Sp(d,e,r,s),iu(r,d),!1}r=r.return}while(r!==null);return!1}var Au=Error(a(461)),Gt=!1;function Wt(e,n,r,s){n.child=e===null?Ch(n,null,r,s):ar(n,e.child,r,s)}function wp(e,n,r,s,d){r=r.render;var g=n.ref;if("ref"in s){var S={};for(var C in s)C!=="ref"&&(S[C]=s[C])}else S=s;return nr(n),s=uu(e,n,r,S,g,d),C=cu(),e!==null&&!Gt?(fu(e,n,d),si(e,n,d)):(at&&C&&Go(n),n.flags|=1,Wt(e,n,s,d),n.child)}function jp(e,n,r,s,d){if(e===null){var g=r.type;return typeof g=="function"&&!Ho(g)&&g.defaultProps===void 0&&r.compare===null?(n.tag=15,n.type=g,kp(e,n,g,s,d)):(e=Ia(r.type,null,s,n,n.mode,d),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Lu(e,d)){var S=g.memoizedProps;if(r=r.compare,r=r!==null?r:kl,r(S,s)&&e.ref===n.ref)return si(e,n,d)}return n.flags|=1,e=ti(g,s),e.ref=n.ref,e.return=n,n.child=e}function kp(e,n,r,s,d){if(e!==null){var g=e.memoizedProps;if(kl(g,s)&&e.ref===n.ref)if(Gt=!1,n.pendingProps=s=g,Lu(e,d))(e.flags&131072)!==0&&(Gt=!0);else return n.lanes=e.lanes,si(e,n,d)}return Tu(e,n,r,s,d)}function Cp(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 Ep(e,n,g,r,s)}if((r&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ga(n,g!==null?g.cachePool:null),g!==null?Ah(n,g):lu(),Th(n);else return s=n.lanes=536870912,Ep(e,n,g!==null?g.baseLanes|r:r,r,s)}else g!==null?(Ga(n,g.cachePool),Ah(n,g),zi(),n.memoizedState=null):(e!==null&&Ga(n,null),lu(),zi());return Wt(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 Ep(e,n,r,s,d){var g=Wo();return g=g===null?null:{parent:Vt._currentValue,pool:g},n.memoizedState={baseLanes:r,cachePool:g},e!==null&&Ga(n,null),lu(),Th(n),e!==null&&Ur(e,n,s,!0),n.childLanes=d,null}function as(e,n){return n=os({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Np(e,n,r){return ar(n,e.child,null,r),e=as(n,n.pendingProps),e.flags|=2,Sn(n),n.memoizedState=null,e}function Vx(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=as(n,s),n.lanes=536870912,ql(null,e);if(su(n),(e=Rt)?(e=qm(e,Mn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:wi!==null?{id:Fn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},r=ch(e),r.return=n,n.child=r,Pt=n,Rt=null)):e=null,e===null)throw ki(n);return n.lanes=536870912,null}return as(n,s)}var g=e.memoizedState;if(g!==null){var S=g.dehydrated;if(su(n),d)if(n.flags&256)n.flags&=-257,n=Np(e,n,r);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(a(558));else if(Gt||Ur(e,n,r,!1),d=(r&e.childLanes)!==0,Gt||d){if(s=Nt,s!==null&&(S=Gn(s,r),S!==0&&S!==g.retryLane))throw g.retryLane=S,Ji(e,S),pn(s,e,S),Au;ys(),n=Np(e,n,r)}else e=g.treeContext,Rt=On(S.nextSibling),Pt=n,at=!0,ji=null,Mn=!1,e!==null&&hh(n,e),n=as(n,s),n.flags|=4096;return n}return e=ti(e.child,{mode:s.mode,children:s.children}),e.ref=n.ref,n.child=e,e.return=n,e}function ss(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 Tu(e,n,r,s,d){return nr(n),r=uu(e,n,r,s,void 0,d),s=cu(),e!==null&&!Gt?(fu(e,n,d),si(e,n,d)):(at&&s&&Go(n),n.flags|=1,Wt(e,n,r,d),n.child)}function Ap(e,n,r,s,d,g){return nr(n),n.updateQueue=null,r=Rh(n,s,r,d),zh(e),s=cu(),e!==null&&!Gt?(fu(e,n,g),si(e,n,g)):(at&&s&&Go(n),n.flags|=1,Wt(e,n,r,g),n.child)}function Tp(e,n,r,s,d){if(nr(n),n.stateNode===null){var g=_r,S=r.contextType;typeof S=="object"&&S!==null&&(g=Jt(S)),g=new r(s,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Eu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=s,g.state=n.memoizedState,g.refs={},tu(n),S=r.contextType,g.context=typeof S=="object"&&S!==null?Jt(S):_r,g.state=n.memoizedState,S=r.getDerivedStateFromProps,typeof S=="function"&&(Cu(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&&Eu.enqueueReplaceState(g,g.state,null),_l(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 C=n.memoizedProps,I=or(r,C);g.props=I;var ie=g.context,ue=r.contextType;S=_r,typeof ue=="object"&&ue!==null&&(S=Jt(ue));var he=r.getDerivedStateFromProps;ue=typeof he=="function"||typeof g.getSnapshotBeforeUpdate=="function",C=n.pendingProps!==C,ue||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(C||ie!==S)&&mp(n,g,s,S),Ei=!1;var re=n.memoizedState;g.state=re,_l(n,s,g,d),Ml(),ie=n.memoizedState,C||re!==ie||Ei?(typeof he=="function"&&(Cu(n,r,he,s),ie=n.memoizedState),(I=Ei||pp(n,r,I,s,re,ie,S))?(ue||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=I):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),s=!1)}else{g=n.stateNode,nu(e,n),S=n.memoizedProps,ue=or(r,S),g.props=ue,he=n.pendingProps,re=g.context,ie=r.contextType,I=_r,typeof ie=="object"&&ie!==null&&(I=Jt(ie)),C=r.getDerivedStateFromProps,(ie=typeof C=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==he||re!==I)&&mp(n,g,s,I),Ei=!1,re=n.memoizedState,g.state=re,_l(n,s,g,d),Ml();var oe=n.memoizedState;S!==he||re!==oe||Ei||e!==null&&e.dependencies!==null&&Va(e.dependencies)?(typeof C=="function"&&(Cu(n,r,C,s),oe=n.memoizedState),(ue=Ei||pp(n,r,ue,s,re,oe,I)||e!==null&&e.dependencies!==null&&Va(e.dependencies))?(ie||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(s,oe,I),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(s,oe,I)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(n.flags|=1024),n.memoizedProps=s,n.memoizedState=oe),g.props=s,g.state=oe,g.context=I,s=ue):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(n.flags|=1024),s=!1)}return g=s,ss(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=ar(n,e.child,null,d),n.child=ar(n,null,r,d)):Wt(e,n,r,d),n.memoizedState=g.state,e=n.child):e=si(e,n,d),e}function zp(e,n,r,s){return er(),n.flags|=256,Wt(e,n,r,s),n.child}var zu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ru(e){return{baseLanes:e,cachePool:vh()}}function Du(e,n,r){return e=e!==null?e.childLanes&~r:0,n&&(e|=jn),e}function Rp(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?Ti(n):zi(),(e=Rt)?(e=qm(e,Mn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:wi!==null?{id:Fn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},r=ch(e),r.return=n,n.child=r,Pt=n,Rt=null)):e=null,e===null)throw ki(n);return pc(e)?n.lanes=32:n.lanes=536870912,null}var C=s.children;return s=s.fallback,d?(zi(),d=n.mode,C=os({mode:"hidden",children:C},d),s=Wi(s,d,r,null),C.return=n,s.return=n,C.sibling=s,n.child=C,s=n.child,s.memoizedState=Ru(r),s.childLanes=Du(e,S,r),n.memoizedState=zu,ql(null,s)):(Ti(n),Mu(n,C))}var I=e.memoizedState;if(I!==null&&(C=I.dehydrated,C!==null)){if(g)n.flags&256?(Ti(n),n.flags&=-257,n=_u(e,n,r)):n.memoizedState!==null?(zi(),n.child=e.child,n.flags|=128,n=null):(zi(),C=s.fallback,d=n.mode,s=os({mode:"visible",children:s.children},d),C=Wi(C,d,r,null),C.flags|=2,s.return=n,C.return=n,s.sibling=C,n.child=s,ar(n,e.child,null,r),s=n.child,s.memoizedState=Ru(r),s.childLanes=Du(e,S,r),n.memoizedState=zu,n=ql(null,s));else if(Ti(n),pc(C)){if(S=C.nextSibling&&C.nextSibling.dataset,S)var ie=S.dgst;S=ie,s=Error(a(419)),s.stack="",s.digest=S,Nl({value:s,source:null,stack:null}),n=_u(e,n,r)}else if(Gt||Ur(e,n,r,!1),S=(r&e.childLanes)!==0,Gt||S){if(S=Nt,S!==null&&(s=Gn(S,r),s!==0&&s!==I.retryLane))throw I.retryLane=s,Ji(e,s),pn(S,e,s),Au;hc(C)||ys(),n=_u(e,n,r)}else hc(C)?(n.flags|=192,n.child=e.child,n=null):(e=I.treeContext,Rt=On(C.nextSibling),Pt=n,at=!0,ji=null,Mn=!1,e!==null&&hh(n,e),n=Mu(n,s.children),n.flags|=4096);return n}return d?(zi(),C=s.fallback,d=n.mode,I=e.child,ie=I.sibling,s=ti(I,{mode:"hidden",children:s.children}),s.subtreeFlags=I.subtreeFlags&65011712,ie!==null?C=ti(ie,C):(C=Wi(C,d,r,null),C.flags|=2),C.return=n,s.return=n,s.sibling=C,n.child=s,ql(null,s),s=n.child,C=e.child.memoizedState,C===null?C=Ru(r):(d=C.cachePool,d!==null?(I=Vt._currentValue,d=d.parent!==I?{parent:I,pool:I}:d):d=vh(),C={baseLanes:C.baseLanes|r,cachePool:d}),s.memoizedState=C,s.childLanes=Du(e,S,r),n.memoizedState=zu,ql(e.child,s)):(Ti(n),r=e.child,e=r.sibling,r=ti(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 Mu(e,n){return n=os({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function os(e,n){return e=vn(22,e,null,n),e.lanes=0,e}function _u(e,n,r){return ar(n,e.child,null,r),e=Mu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Dp(e,n,r){e.lanes|=n;var s=e.alternate;s!==null&&(s.lanes|=n),Ko(e.return,n,r)}function Ou(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 Mp(e,n,r){var s=n.pendingProps,d=s.revealOrder,g=s.tail;s=s.children;var S=qt.current,C=(S&2)!==0;if(C?(S=S&1|2,n.flags|=128):S&=1,A(qt,S),Wt(e,n,s,r),s=at?El:0,!C&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Dp(e,r,n);else if(e.tag===19)Dp(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&&Za(e)===null&&(d=r),r=r.sibling;r=d,r===null?(d=n.child,n.child=null):(d=r.sibling,r.sibling=null),Ou(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&&Za(e)===null){n.child=d;break}e=d.sibling,d.sibling=r,r=d,d=e}Ou(n,!0,r,null,g,s);break;case"together":Ou(n,!1,null,null,void 0,s);break;default:n.memoizedState=null}return n.child}function si(e,n,r){if(e!==null&&(n.dependencies=e.dependencies),Mi|=n.lanes,(r&n.childLanes)===0)if(e!==null){if(Ur(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=ti(e,e.pendingProps),n.child=r,r.return=n;e.sibling!==null;)e=e.sibling,r=r.sibling=ti(e,e.pendingProps),r.return=n;r.sibling=null}return n.child}function Lu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&Va(e)))}function Yx(e,n,r){switch(n.tag){case 3:we(n,n.stateNode.containerInfo),Ci(n,Vt,e.memoizedState.cache),er();break;case 27:case 5:Se(n);break;case 4:we(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,su(n),null;break;case 13:var s=n.memoizedState;if(s!==null)return s.dehydrated!==null?(Ti(n),n.flags|=128,null):(r&n.child.childLanes)!==0?Rp(e,n,r):(Ti(n),e=si(e,n,r),e!==null?e.sibling:null);Ti(n);break;case 19:var d=(e.flags&128)!==0;if(s=(r&n.childLanes)!==0,s||(Ur(e,n,r,!1),s=(r&n.childLanes)!==0),d){if(s)return Mp(e,n,r);n.flags|=128}if(d=n.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),A(qt,qt.current),s)break;return null;case 22:return n.lanes=0,Cp(e,n,r,n.pendingProps);case 24:Ci(n,Vt,e.memoizedState.cache)}return si(e,n,r)}function _p(e,n,r){if(e!==null)if(e.memoizedProps!==n.pendingProps)Gt=!0;else{if(!Lu(e,r)&&(n.flags&128)===0)return Gt=!1,Yx(e,n,r);Gt=(e.flags&131072)!==0}else Gt=!1,at&&(n.flags&1048576)!==0&&dh(n,El,n.index);switch(n.lanes=0,n.tag){case 16:e:{var s=n.pendingProps;if(e=rr(n.elementType),n.type=e,typeof e=="function")Ho(e)?(s=or(e,s),n.tag=1,n=Tp(null,n,e,s,r)):(n.tag=0,n=Tu(null,n,e,s,r));else{if(e!=null){var d=e.$$typeof;if(d===G){n.tag=11,n=wp(null,n,e,s,r);break e}else if(d===V){n.tag=14,n=jp(null,n,e,s,r);break e}}throw n=ee(e)||e,Error(a(306,n,""))}}return n;case 0:return Tu(e,n,n.type,n.pendingProps,r);case 1:return s=n.type,d=or(s,n.pendingProps),Tp(e,n,s,d,r);case 3:e:{if(we(n,n.stateNode.containerInfo),e===null)throw Error(a(387));s=n.pendingProps;var g=n.memoizedState;d=g.element,nu(e,n),_l(n,s,null,r);var S=n.memoizedState;if(s=S.cache,Ci(n,Vt,s),s!==g.cache&&Zo(n,[Vt],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=zp(e,n,s,r);break e}else if(s!==d){d=zn(Error(a(424)),n),Nl(d),n=zp(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,Rt=On(e.firstChild),Pt=n,at=!0,ji=null,Mn=!0,r=Ch(n,null,s,r),n.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(er(),s===d){n=si(e,n,r);break e}Wt(e,n,s,r)}n=n.child}return n;case 26:return ss(e,n),e===null?(r=Fm(n.type,null,n.pendingProps,null))?n.memoizedState=r:at||(r=n.type,e=n.pendingProps,s=ks(te.current).createElement(r),s[Zt]=n,s[on]=e,en(s,r,e),Xt(s),n.stateNode=s):n.memoizedState=Fm(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Se(n),e===null&&at&&(s=n.stateNode=Vm(n.type,n.pendingProps,te.current),Pt=n,Mn=!0,d=Rt,Ui(n.type)?(mc=d,Rt=On(s.firstChild)):Rt=d),Wt(e,n,n.pendingProps.children,r),ss(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&at&&((d=s=Rt)&&(s=v0(s,n.type,n.pendingProps,Mn),s!==null?(n.stateNode=s,Pt=n,Rt=On(s.firstChild),Mn=!1,d=!0):d=!1),d||ki(n)),Se(n),d=n.type,g=n.pendingProps,S=e!==null?e.memoizedProps:null,s=g.children,cc(d,g)?s=null:S!==null&&cc(d,S)&&(n.flags|=32),n.memoizedState!==null&&(d=uu(e,n,_x,null,null,r),ea._currentValue=d),ss(e,n),Wt(e,n,s,r),n.child;case 6:return e===null&&at&&((e=r=Rt)&&(r=x0(r,n.pendingProps,Mn),r!==null?(n.stateNode=r,Pt=n,Rt=null,e=!0):e=!1),e||ki(n)),null;case 13:return Rp(e,n,r);case 4:return we(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=ar(n,null,s,r):Wt(e,n,s,r),n.child;case 11:return wp(e,n,n.type,n.pendingProps,r);case 7:return Wt(e,n,n.pendingProps,r),n.child;case 8:return Wt(e,n,n.pendingProps.children,r),n.child;case 12:return Wt(e,n,n.pendingProps.children,r),n.child;case 10:return s=n.pendingProps,Ci(n,n.type,s.value),Wt(e,n,s.children,r),n.child;case 9:return d=n.type._context,s=n.pendingProps.children,nr(n),d=Jt(d),s=s(d),n.flags|=1,Wt(e,n,s,r),n.child;case 14:return jp(e,n,n.type,n.pendingProps,r);case 15:return kp(e,n,n.type,n.pendingProps,r);case 19:return Mp(e,n,r);case 31:return Vx(e,n,r);case 22:return Cp(e,n,r,n.pendingProps);case 24:return nr(n),s=Jt(Vt),e===null?(d=Wo(),d===null&&(d=Nt,g=Po(),d.pooledCache=g,g.refCount++,g!==null&&(d.pooledCacheLanes|=r),d=g),n.memoizedState={parent:s,cache:d},tu(n),Ci(n,Vt,d)):((e.lanes&r)!==0&&(nu(e,n),_l(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,Vt,s)):(s=g.cache,Ci(n,Vt,s),s!==d.cache&&Zo(n,[Vt],r,!0))),Wt(e,n,n.pendingProps.children,r),n.child;case 29:throw n.pendingProps}throw Error(a(156,n.tag))}function oi(e){e.flags|=4}function Bu(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(sm())e.flags|=8192;else throw lr=Qa,eu}else e.flags&=-16777217}function Op(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Zm(n))if(sm())e.flags|=8192;else throw lr=Qa,eu}function us(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?je():536870912,e.lanes|=n,Zr|=n)}function Il(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 Gx(e,n,r){var s=n.pendingProps;switch(Fo(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),ri(Vt),F(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Br(n)?oi(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,$o())),Dt(n),null;case 26:var d=n.type,g=n.memoizedState;return e===null?(oi(n),g!==null?(Dt(n),Op(n,g)):(Dt(n),Bu(n,d,null,s,r))):g?g!==e.memoizedState?(oi(n),Dt(n),Op(n,g)):(Dt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==s&&oi(n),Dt(n),Bu(n,d,e,s,r)),null;case 27:if(Ne(n),r=te.current,d=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==s&&oi(n);else{if(!s){if(n.stateNode===null)throw Error(a(166));return Dt(n),null}e=le.current,Br(n)?ph(n):(e=Vm(d,s,r),n.stateNode=e,oi(n))}return Dt(n),null;case 5:if(Ne(n),d=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==s&&oi(n);else{if(!s){if(n.stateNode===null)throw Error(a(166));return Dt(n),null}if(g=le.current,Br(n))ph(n);else{var S=ks(te.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[Zt]=n,g[on]=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(en(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&&oi(n)}}return Dt(n),Bu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,r),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==s&&oi(n);else{if(typeof s!="string"&&n.stateNode===null)throw Error(a(166));if(e=te.current,Br(n)){if(e=n.stateNode,r=n.memoizedProps,s=null,d=Pt,d!==null)switch(d.tag){case 27:case 5:s=d.memoizedProps}e[Zt]=n,e=!!(e.nodeValue===r||s!==null&&s.suppressHydrationWarning===!0||Rm(e.nodeValue,r)),e||ki(n,!0)}else e=ks(e).createTextNode(s),e[Zt]=n,n.stateNode=e}return Dt(n),null;case 31:if(r=n.memoizedState,e===null||e.memoizedState!==null){if(s=Br(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[Zt]=n}else er(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Dt(n),e=!1}else r=$o(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),e=!0;if(!e)return n.flags&256?(Sn(n),n):(Sn(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=Br(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[Zt]=n}else er(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Dt(n),d=!1}else d=$o(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=d),d=!0;if(!d)return n.flags&256?(Sn(n),n):(Sn(n),null)}return Sn(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),us(n,n.updateQueue),Dt(n),null);case 4:return F(),e===null&&lc(n.stateNode.containerInfo),Dt(n),null;case 10:return ri(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)Il(s,!1);else{if(Bt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=Za(e),g!==null){for(n.flags|=128,Il(s,!1),e=g.updateQueue,n.updateQueue=e,us(n,e),n.subtreeFlags=0,e=r,r=n.child;r!==null;)uh(r,e),r=r.sibling;return A(qt,qt.current&1|2),at&&ni(n,s.treeForkCount),n.child}e=e.sibling}s.tail!==null&&rt()>ps&&(n.flags|=128,d=!0,Il(s,!1),n.lanes=4194304)}else{if(!d)if(e=Za(g),e!==null){if(n.flags|=128,d=!0,e=e.updateQueue,n.updateQueue=e,us(n,e),Il(s,!0),s.tail===null&&s.tailMode==="hidden"&&!g.alternate&&!at)return Dt(n),null}else 2*rt()-s.renderingStartTime>ps&&r!==536870912&&(n.flags|=128,d=!0,Il(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=rt(),e.sibling=null,r=qt.current,A(qt,d?r&1|2:r&1),at&&ni(n,s.treeForkCount),e):(Dt(n),null);case 22:case 23:return Sn(n),au(),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&&us(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(ir),null;case 24:return r=null,e!==null&&(r=e.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),ri(Vt),Dt(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function Fx(e,n){switch(Fo(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ri(Vt),F(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return Ne(n),null;case 31:if(n.memoizedState!==null){if(Sn(n),n.alternate===null)throw Error(a(340));er()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Sn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));er()}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 ri(n.type),null;case 22:case 23:return Sn(n),au(),e!==null&&J(ir),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return ri(Vt),null;case 25:return null;default:return null}}function Lp(e,n){switch(Fo(n),n.tag){case 3:ri(Vt),F();break;case 26:case 27:case 5:Ne(n);break;case 4:F();break;case 31:n.memoizedState!==null&&Sn(n);break;case 13:Sn(n);break;case 19:J(qt);break;case 10:ri(n.type);break;case 22:case 23:Sn(n),au(),e!==null&&J(ir);break;case 24:ri(Vt)}}function Hl(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(C){xt(n,n.return,C)}}function Ri(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,C=S.destroy;if(C!==void 0){S.destroy=void 0,d=n;var I=r,ie=C;try{ie()}catch(ue){xt(d,I,ue)}}}s=s.next}while(s!==g)}}catch(ue){xt(n,n.return,ue)}}function Bp(e){var n=e.updateQueue;if(n!==null){var r=e.stateNode;try{Nh(n,r)}catch(s){xt(e,e.return,s)}}}function Up(e,n,r){r.props=or(e.type,e.memoizedProps),r.state=e.memoizedState;try{r.componentWillUnmount()}catch(s){xt(e,n,s)}}function Vl(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 $n(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 qp(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 Uu(e,n,r){try{var s=e.stateNode;h0(s,e.type,r,n),s[on]=n}catch(d){xt(e,e.return,d)}}function Ip(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ui(e.type)||e.tag===4}function qu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ip(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&&Ui(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 Iu(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=Wn));else if(s!==4&&(s===27&&Ui(e.type)&&(r=e.stateNode,n=null),e=e.child,e!==null))for(Iu(e,n,r),e=e.sibling;e!==null;)Iu(e,n,r),e=e.sibling}function cs(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&&Ui(e.type)&&(r=e.stateNode),e=e.child,e!==null))for(cs(e,n,r),e=e.sibling;e!==null;)cs(e,n,r),e=e.sibling}function Hp(e){var n=e.stateNode,r=e.memoizedProps;try{for(var s=e.type,d=n.attributes;d.length;)n.removeAttributeNode(d[0]);en(n,s,r),n[Zt]=e,n[on]=r}catch(g){xt(e,e.return,g)}}var ui=!1,Ft=!1,Hu=!1,Vp=typeof WeakSet=="function"?WeakSet:Set,Kt=null;function Qx(e,n){if(e=e.containerInfo,oc=Rs,e=eh(e),_o(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,C=-1,I=-1,ie=0,ue=0,he=e,re=null;t:for(;;){for(var oe;he!==r||d!==0&&he.nodeType!==3||(C=S+d),he!==g||s!==0&&he.nodeType!==3||(I=S+s),he.nodeType===3&&(S+=he.nodeValue.length),(oe=he.firstChild)!==null;)re=he,he=oe;for(;;){if(he===e)break t;if(re===r&&++ie===d&&(C=S),re===g&&++ue===s&&(I=S),(oe=he.nextSibling)!==null)break;he=re,re=he.parentNode}he=oe}r=C===-1||I===-1?null:{start:C,end:I}}else r=null}r=r||{start:0,end:0}}else r=null;for(uc={focusedElem:e,selectionRange:r},Rs=!1,Kt=n;Kt!==null;)if(n=Kt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Kt=e;else for(;Kt!==null;){switch(n=Kt,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 Ae=or(r.type,d);e=s.getSnapshotBeforeUpdate(Ae,g),s.__reactInternalSnapshotBeforeUpdate=e}catch(Be){xt(r,r.return,Be)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,r=e.nodeType,r===9)dc(e);else if(r===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":dc(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,Kt=e;break}Kt=n.return}}function Yp(e,n,r){var s=r.flags;switch(r.tag){case 0:case 11:case 15:fi(e,r),s&4&&Hl(5,r);break;case 1:if(fi(e,r),s&4)if(e=r.stateNode,n===null)try{e.componentDidMount()}catch(S){xt(r,r.return,S)}else{var d=or(r.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(d,n,e.__reactInternalSnapshotBeforeUpdate)}catch(S){xt(r,r.return,S)}}s&64&&Bp(r),s&512&&Vl(r,r.return);break;case 3:if(fi(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{Nh(e,n)}catch(S){xt(r,r.return,S)}}break;case 27:n===null&&s&4&&Hp(r);case 26:case 5:fi(e,r),n===null&&s&4&&qp(r),s&512&&Vl(r,r.return);break;case 12:fi(e,r);break;case 31:fi(e,r),s&4&&Qp(e,r);break;case 13:fi(e,r),s&4&&$p(e,r),s&64&&(e=r.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(r=t0.bind(null,r),S0(e,r))));break;case 22:if(s=r.memoizedState!==null||ui,!s){n=n!==null&&n.memoizedState!==null||Ft,d=ui;var g=Ft;ui=s,(Ft=n)&&!g?di(e,r,(r.subtreeFlags&8772)!==0):fi(e,r),ui=d,Ft=g}break;case 30:break;default:fi(e,r)}}function Gp(e){var n=e.alternate;n!==null&&(e.alternate=null,Gp(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&yo(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 Mt=null,cn=!1;function ci(e,n,r){for(r=r.child;r!==null;)Fp(e,n,r),r=r.sibling}function Fp(e,n,r){if(mt&&typeof mt.onCommitFiberUnmount=="function")try{mt.onCommitFiberUnmount(bt,r)}catch{}switch(r.tag){case 26:Ft||$n(r,n),ci(e,n,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:Ft||$n(r,n);var s=Mt,d=cn;Ui(r.type)&&(Mt=r.stateNode,cn=!1),ci(e,n,r),Pl(r.stateNode),Mt=s,cn=d;break;case 5:Ft||$n(r,n);case 6:if(s=Mt,d=cn,Mt=null,ci(e,n,r),Mt=s,cn=d,Mt!==null)if(cn)try{(Mt.nodeType===9?Mt.body:Mt.nodeName==="HTML"?Mt.ownerDocument.body:Mt).removeChild(r.stateNode)}catch(g){xt(r,n,g)}else try{Mt.removeChild(r.stateNode)}catch(g){xt(r,n,g)}break;case 18:Mt!==null&&(cn?(e=Mt,Bm(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,r.stateNode),rl(e)):Bm(Mt,r.stateNode));break;case 4:s=Mt,d=cn,Mt=r.stateNode.containerInfo,cn=!0,ci(e,n,r),Mt=s,cn=d;break;case 0:case 11:case 14:case 15:Ri(2,r,n),Ft||Ri(4,r,n),ci(e,n,r);break;case 1:Ft||($n(r,n),s=r.stateNode,typeof s.componentWillUnmount=="function"&&Up(r,n,s)),ci(e,n,r);break;case 21:ci(e,n,r);break;case 22:Ft=(s=Ft)||r.memoizedState!==null,ci(e,n,r),Ft=s;break;default:ci(e,n,r)}}function Qp(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{rl(e)}catch(r){xt(n,n.return,r)}}}function $p(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{rl(e)}catch(r){xt(n,n.return,r)}}function $x(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new Vp),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new Vp),n;default:throw Error(a(435,e.tag))}}function fs(e,n){var r=$x(e);n.forEach(function(s){if(!r.has(s)){r.add(s);var d=n0.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,C=S;e:for(;C!==null;){switch(C.tag){case 27:if(Ui(C.type)){Mt=C.stateNode,cn=!1;break e}break;case 5:Mt=C.stateNode,cn=!1;break e;case 3:case 4:Mt=C.stateNode.containerInfo,cn=!0;break e}C=C.return}if(Mt===null)throw Error(a(160));Fp(g,S,d),Mt=null,cn=!1,g=d.alternate,g!==null&&(g.return=null),d.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Xp(n,e),n=n.sibling}var qn=null;function Xp(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&&(Ri(3,e,e.return),Hl(3,e),Ri(5,e,e.return));break;case 1:fn(n,e),dn(e),s&512&&(Ft||r===null||$n(r,r.return)),s&64&&ui&&(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=qn;if(fn(n,e),dn(e),s&512&&(Ft||r===null||$n(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[ml]||g[Zt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=d.createElement(s),d.head.insertBefore(g,d.querySelector("head > title"))),en(g,s,r),g[Zt]=e,Xt(g),s=g;break e;case"link":var S=Xm("link","href",d).get(s+(r.href||""));if(S){for(var C=0;C<S.length;C++)if(g=S[C],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(C,1);break t}}g=d.createElement(s),en(g,s,r),d.head.appendChild(g);break;case"meta":if(S=Xm("meta","content",d).get(s+(r.content||""))){for(C=0;C<S.length;C++)if(g=S[C],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(C,1);break t}}g=d.createElement(s),en(g,s,r),d.head.appendChild(g);break;default:throw Error(a(468,s))}g[Zt]=e,Xt(g),s=g}e.stateNode=s}else Km(d,e.type,e.stateNode);else e.stateNode=$m(d,s,e.memoizedProps);else g!==s?(g===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):g.count--,s===null?Km(d,e.type,e.stateNode):$m(d,s,e.memoizedProps)):s===null&&e.stateNode!==null&&Uu(e,e.memoizedProps,r.memoizedProps)}break;case 27:fn(n,e),dn(e),s&512&&(Ft||r===null||$n(r,r.return)),r!==null&&s&4&&Uu(e,e.memoizedProps,r.memoizedProps);break;case 5:if(fn(n,e),dn(e),s&512&&(Ft||r===null||$n(r,r.return)),e.flags&32){d=e.stateNode;try{Nr(d,"")}catch(Ae){xt(e,e.return,Ae)}}s&4&&e.stateNode!=null&&(d=e.memoizedProps,Uu(e,d,r!==null?r.memoizedProps:d)),s&1024&&(Hu=!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(Ae){xt(e,e.return,Ae)}}break;case 3:if(Ns=null,d=qn,qn=Cs(n.containerInfo),fn(n,e),qn=d,dn(e),s&4&&r!==null&&r.memoizedState.isDehydrated)try{rl(n.containerInfo)}catch(Ae){xt(e,e.return,Ae)}Hu&&(Hu=!1,Kp(e));break;case 4:s=qn,qn=Cs(e.stateNode.containerInfo),fn(n,e),dn(e),qn=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,fs(e,s)));break;case 13:fn(n,e),dn(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(hs=rt()),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,fs(e,s)));break;case 22:d=e.memoizedState!==null;var I=r!==null&&r.memoizedState!==null,ie=ui,ue=Ft;if(ui=ie||d,Ft=ue||I,fn(n,e),Ft=ue,ui=ie,dn(e),s&8192)e:for(n=e.stateNode,n._visibility=d?n._visibility&-2:n._visibility|1,d&&(r===null||I||ui||Ft||ur(e)),r=null,n=e;;){if(n.tag===5||n.tag===26){if(r===null){I=r=n;try{if(g=I.stateNode,d)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{C=I.stateNode;var he=I.memoizedProps.style,re=he!=null&&he.hasOwnProperty("display")?he.display:null;C.style.display=re==null||typeof re=="boolean"?"":(""+re).trim()}}catch(Ae){xt(I,I.return,Ae)}}}else if(n.tag===6){if(r===null){I=n;try{I.stateNode.nodeValue=d?"":I.memoizedProps}catch(Ae){xt(I,I.return,Ae)}}}else if(n.tag===18){if(r===null){I=n;try{var oe=I.stateNode;d?Um(oe,!0):Um(I.stateNode,!1)}catch(Ae){xt(I,I.return,Ae)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;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,fs(e,r))));break;case 19:fn(n,e),dn(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,fs(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(Ip(s)){r=s;break}s=s.return}if(r==null)throw Error(a(160));switch(r.tag){case 27:var d=r.stateNode,g=qu(e);cs(e,g,d);break;case 5:var S=r.stateNode;r.flags&32&&(Nr(S,""),r.flags&=-33);var C=qu(e);cs(e,C,S);break;case 3:case 4:var I=r.stateNode.containerInfo,ie=qu(e);Iu(e,ie,I);break;default:throw Error(a(161))}}catch(ue){xt(e,e.return,ue)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Kp(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;Kp(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function fi(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Yp(e,n.alternate,n),n=n.sibling}function ur(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Ri(4,n,n.return),ur(n);break;case 1:$n(n,n.return);var r=n.stateNode;typeof r.componentWillUnmount=="function"&&Up(n,n.return,r),ur(n);break;case 27:Pl(n.stateNode);case 26:case 5:$n(n,n.return),ur(n);break;case 22:n.memoizedState===null&&ur(n);break;case 30:ur(n);break;default:ur(n)}e=e.sibling}}function di(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:di(d,g,r),Hl(4,g);break;case 1:if(di(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 C=s.stateNode;try{var I=d.shared.hiddenCallbacks;if(I!==null)for(d.shared.hiddenCallbacks=null,d=0;d<I.length;d++)Eh(I[d],C)}catch(ie){xt(s,s.return,ie)}}r&&S&64&&Bp(g),Vl(g,g.return);break;case 27:Hp(g);case 26:case 5:di(d,g,r),r&&s===null&&S&4&&qp(g),Vl(g,g.return);break;case 12:di(d,g,r);break;case 31:di(d,g,r),r&&S&4&&Qp(d,g);break;case 13:di(d,g,r),r&&S&4&&$p(d,g);break;case 22:g.memoizedState===null&&di(d,g,r),Vl(g,g.return);break;case 30:break;default:di(d,g,r)}n=n.sibling}}function Vu(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&&Al(r))}function Yu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Al(e))}function In(e,n,r,s){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Zp(e,n,r,s),n=n.sibling}function Zp(e,n,r,s){var d=n.flags;switch(n.tag){case 0:case 11:case 15:In(e,n,r,s),d&2048&&Hl(9,n);break;case 1:In(e,n,r,s);break;case 3:In(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&&Al(e)));break;case 12:if(d&2048){In(e,n,r,s),e=n.stateNode;try{var g=n.memoizedProps,S=g.id,C=g.onPostCommit;typeof C=="function"&&C(S,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(I){xt(n,n.return,I)}}else In(e,n,r,s);break;case 31:In(e,n,r,s);break;case 13:In(e,n,r,s);break;case 23:break;case 22:g=n.stateNode,S=n.alternate,n.memoizedState!==null?g._visibility&2?In(e,n,r,s):Yl(e,n):g._visibility&2?In(e,n,r,s):(g._visibility|=2,$r(e,n,r,s,(n.subtreeFlags&10256)!==0||!1)),d&2048&&Vu(S,n);break;case 24:In(e,n,r,s),d&2048&&Yu(n.alternate,n);break;default:In(e,n,r,s)}}function $r(e,n,r,s,d){for(d=d&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,S=n,C=r,I=s,ie=S.flags;switch(S.tag){case 0:case 11:case 15:$r(g,S,C,I,d),Hl(8,S);break;case 23:break;case 22:var ue=S.stateNode;S.memoizedState!==null?ue._visibility&2?$r(g,S,C,I,d):Yl(g,S):(ue._visibility|=2,$r(g,S,C,I,d)),d&&ie&2048&&Vu(S.alternate,S);break;case 24:$r(g,S,C,I,d),d&&ie&2048&&Yu(S.alternate,S);break;default:$r(g,S,C,I,d)}n=n.sibling}}function Yl(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:Yl(r,s),d&2048&&Vu(s.alternate,s);break;case 24:Yl(r,s),d&2048&&Yu(s.alternate,s);break;default:Yl(r,s)}n=n.sibling}}var Gl=8192;function Xr(e,n,r){if(e.subtreeFlags&Gl)for(e=e.child;e!==null;)Pp(e,n,r),e=e.sibling}function Pp(e,n,r){switch(e.tag){case 26:Xr(e,n,r),e.flags&Gl&&e.memoizedState!==null&&M0(r,qn,e.memoizedState,e.memoizedProps);break;case 5:Xr(e,n,r);break;case 3:case 4:var s=qn;qn=Cs(e.stateNode.containerInfo),Xr(e,n,r),qn=s;break;case 22:e.memoizedState===null&&(s=e.alternate,s!==null&&s.memoizedState!==null?(s=Gl,Gl=16777216,Xr(e,n,r),Gl=s):Xr(e,n,r));break;default:Xr(e,n,r)}}function Jp(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 Fl(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];Kt=s,em(s,e)}Jp(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Wp(e),e=e.sibling}function Wp(e){switch(e.tag){case 0:case 11:case 15:Fl(e),e.flags&2048&&Ri(9,e,e.return);break;case 3:Fl(e);break;case 12:Fl(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,ds(e)):Fl(e);break;default:Fl(e)}}function ds(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];Kt=s,em(s,e)}Jp(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Ri(8,n,n.return),ds(n);break;case 22:r=n.stateNode,r._visibility&2&&(r._visibility&=-3,ds(n));break;default:ds(n)}e=e.sibling}}function em(e,n){for(;Kt!==null;){var r=Kt;switch(r.tag){case 0:case 11:case 15:Ri(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:Al(r.memoizedState.cache)}if(s=r.child,s!==null)s.return=r,Kt=s;else e:for(r=e;Kt!==null;){s=Kt;var d=s.sibling,g=s.return;if(Gp(s),s===r){Kt=null;break e}if(d!==null){d.return=g,Kt=d;break e}Kt=g}}}var Xx={getCacheForType:function(e){var n=Jt(Vt),r=n.data.get(e);return r===void 0&&(r=e(),n.data.set(e,r)),r},cacheSignal:function(){return Jt(Vt).controller.signal}},Kx=typeof WeakMap=="function"?WeakMap:Map,gt=0,Nt=null,Pe=null,nt=0,vt=0,wn=null,Di=!1,Kr=!1,Gu=!1,hi=0,Bt=0,Mi=0,cr=0,Fu=0,jn=0,Zr=0,Ql=null,hn=null,Qu=!1,hs=0,tm=0,ps=1/0,ms=null,_i=null,$t=0,Oi=null,Pr=null,pi=0,$u=0,Xu=null,nm=null,$l=0,Ku=null;function kn(){return(gt&2)!==0&&nt!==0?nt&-nt:N.T!==null?tc():pl()}function im(){if(jn===0)if((nt&536870912)===0||at){var e=$e;$e<<=1,($e&3932160)===0&&($e=262144),jn=e}else jn=536870912;return e=xn.current,e!==null&&(e.flags|=32),jn}function pn(e,n,r){(e===Nt&&(vt===2||vt===9)||e.cancelPendingCommit!==null)&&(Jr(e,0),Li(e,nt,jn,!1)),st(e,r),((gt&2)===0||e!==Nt)&&(e===Nt&&((gt&2)===0&&(cr|=r),Bt===4&&Li(e,nt,jn,!1)),Xn(e))}function rm(e,n,r){if((gt&6)!==0)throw Error(a(327));var s=!r&&(n&127)===0&&(n&e.expiredLanes)===0||de(e,n),d=s?Jx(e,n):Pu(e,n,!0),g=s;do{if(d===0){Kr&&!s&&Li(e,n,0,!1);break}else{if(r=e.current.alternate,g&&!Zx(r)){d=Pu(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 C=e;d=Ql;var I=C.current.memoizedState.isDehydrated;if(I&&(Jr(C,S).flags|=256),S=Pu(C,S,!1),S!==2){if(Gu&&!I){C.errorRecoveryDisabledLanes|=g,cr|=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){Jr(e,0),Li(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:Li(s,n,jn,!Di);break e;case 2:hn=null;break;case 3:case 5:break;default:throw Error(a(329))}if((n&62914560)===n&&(d=hs+300-rt(),10<d)){if(Li(s,n,jn,!Di),Me(s,0,!0)!==0)break e;pi=n,s.timeoutHandle=Om(lm.bind(null,s,r,hn,ms,Qu,n,jn,cr,Zr,Di,g,"Throttled",-0,0),d);break e}lm(s,r,hn,ms,Qu,n,jn,cr,Zr,Di,g,null,-0,0)}}break}while(!0);Xn(e)}function lm(e,n,r,s,d,g,S,C,I,ie,ue,he,re,oe){if(e.timeoutHandle=-1,he=n.subtreeFlags,he&8192||(he&16785408)===16785408){he={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Wn},Pp(n,g,he);var Ae=(g&62914560)===g?hs-rt():(g&4194048)===g?tm-rt():0;if(Ae=_0(he,Ae),Ae!==null){pi=g,e.cancelPendingCommit=Ae(hm.bind(null,e,n,g,r,s,d,S,C,I,ue,he,null,re,oe)),Li(e,g,S,!ie);return}}hm(e,n,g,r,s,d,S,C,I)}function Zx(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(!bn(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 Li(e,n,r,s){n&=~Fu,n&=~cr,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&&Ut(e,r,n)}function gs(){return(gt&6)===0?(Xl(0),!1):!0}function Zu(){if(Pe!==null){if(vt===0)var e=Pe.return;else e=Pe,ii=tr=null,du(e),Vr=null,zl=0,e=Pe;for(;e!==null;)Lp(e.alternate,e),e=e.return;Pe=null}}function Jr(e,n){var r=e.timeoutHandle;r!==-1&&(e.timeoutHandle=-1,g0(r)),r=e.cancelPendingCommit,r!==null&&(e.cancelPendingCommit=null,r()),pi=0,Zu(),Nt=e,Pe=r=ti(e.current,null),nt=n,vt=0,wn=null,Di=!1,Kr=de(e,n),Gu=!1,Zr=jn=Fu=cr=Mi=Bt=0,hn=Ql=null,Qu=!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 hi=n,Ba(),r}function am(e,n){Ye=null,N.H=Ul,n===Hr||n===Fa?(n=wh(),vt=3):n===eu?(n=wh(),vt=4):vt=n===Au?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,wn=n,Pe===null&&(Bt=1,ls(e,zn(n,e.current)))}function sm(){var e=xn.current;return e===null?!0:(nt&4194048)===nt?_n===null:(nt&62914560)===nt||(nt&536870912)!==0?e===_n:!1}function om(){var e=N.H;return N.H=Ul,e===null?Ul:e}function um(){var e=N.A;return N.A=Xx,e}function ys(){Bt=4,Di||(nt&4194048)!==nt&&xn.current!==null||(Kr=!0),(Mi&134217727)===0&&(cr&134217727)===0||Nt===null||Li(Nt,nt,jn,!1)}function Pu(e,n,r){var s=gt;gt|=2;var d=om(),g=um();(Nt!==e||nt!==n)&&(ms=null,Jr(e,n)),n=!1;var S=Bt;e:do try{if(vt!==0&&Pe!==null){var C=Pe,I=wn;switch(vt){case 8:Zu(),S=6;break e;case 3:case 2:case 9:case 6:xn.current===null&&(n=!0);var ie=vt;if(vt=0,wn=null,Wr(e,C,I,ie),r&&Kr){S=0;break e}break;default:ie=vt,vt=0,wn=null,Wr(e,C,I,ie)}}Px(),S=Bt;break}catch(ue){am(e,ue)}while(!0);return n&&e.shellSuspendCounter++,ii=tr=null,gt=s,N.H=d,N.A=g,Pe===null&&(Nt=null,nt=0,Ba()),S}function Px(){for(;Pe!==null;)cm(Pe)}function Jx(e,n){var r=gt;gt|=2;var s=om(),d=um();Nt!==e||nt!==n?(ms=null,ps=rt()+500,Jr(e,n)):Kr=de(e,n);e:do try{if(vt!==0&&Pe!==null){n=Pe;var g=wn;t:switch(vt){case 1:vt=0,wn=null,Wr(e,n,g,1);break;case 2:case 9:if(xh(g)){vt=0,wn=null,fm(n);break}n=function(){vt!==2&&vt!==9||Nt!==e||(vt=7),Xn(e)},g.then(n,n);break e;case 3:vt=7;break e;case 4:vt=5;break e;case 7:xh(g)?(vt=0,wn=null,fm(n)):(vt=0,wn=null,Wr(e,n,g,7));break;case 5:var S=null;switch(Pe.tag){case 26:S=Pe.memoizedState;case 5:case 27:var C=Pe;if(S?Zm(S):C.stateNode.complete){vt=0,wn=null;var I=C.sibling;if(I!==null)Pe=I;else{var ie=C.return;ie!==null?(Pe=ie,bs(ie)):Pe=null}break t}}vt=0,wn=null,Wr(e,n,g,5);break;case 6:vt=0,wn=null,Wr(e,n,g,6);break;case 8:Zu(),Bt=6;break e;default:throw Error(a(462))}}Wx();break}catch(ue){am(e,ue)}while(!0);return ii=tr=null,N.H=s,N.A=d,gt=r,Pe!==null?0:(Nt=null,nt=0,Ba(),Bt)}function Wx(){for(;Pe!==null&&!tt();)cm(Pe)}function cm(e){var n=_p(e.alternate,e,hi);e.memoizedProps=e.pendingProps,n===null?bs(e):Pe=n}function fm(e){var n=e,r=n.alternate;switch(n.tag){case 15:case 0:n=Ap(r,n,n.pendingProps,n.type,void 0,nt);break;case 11:n=Ap(r,n,n.pendingProps,n.type.render,n.ref,nt);break;case 5:du(n);default:Lp(r,n),n=Pe=uh(n,hi),n=_p(r,n,hi)}e.memoizedProps=e.pendingProps,n===null?bs(e):Pe=n}function Wr(e,n,r,s){ii=tr=null,du(n),Vr=null,zl=0;var d=n.return;try{if(Hx(e,d,n,r,nt)){Bt=1,ls(e,zn(r,e.current)),Pe=null;return}}catch(g){if(d!==null)throw Pe=d,g;Bt=1,ls(e,zn(r,e.current)),Pe=null;return}n.flags&32768?(at||s===1?e=!0:Kr||(nt&536870912)!==0?e=!1:(Di=e=!0,(s===2||s===9||s===3||s===6)&&(s=xn.current,s!==null&&s.tag===13&&(s.flags|=16384))),dm(n,e)):bs(n)}function bs(e){var n=e;do{if((n.flags&32768)!==0){dm(n,Di);return}e=n.return;var r=Gx(n.alternate,n,hi);if(r!==null){Pe=r;return}if(n=n.sibling,n!==null){Pe=n;return}Pe=n=e}while(n!==null);Bt===0&&(Bt=5)}function dm(e,n){do{var r=Fx(e.alternate,e);if(r!==null){r.flags&=32767,Pe=r;return}if(r=e.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!n&&(e=e.sibling,e!==null)){Pe=e;return}Pe=e=r}while(e!==null);Bt=6,Pe=null}function hm(e,n,r,s,d,g,S,C,I){e.cancelPendingCommit=null;do vs();while($t!==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|=qo,ut(e,r,g,S,C,I),e===Nt&&(Pe=Nt=null,nt=0),Pr=n,Oi=e,pi=r,$u=g,Xu=d,nm=s,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,i0(ge,function(){return bm(),null})):(e.callbackNode=null,e.callbackPriority=0),s=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||s){s=N.T,N.T=null,d=X.p,X.p=2,S=gt,gt|=4;try{Qx(e,n,r)}finally{gt=S,X.p=d,N.T=s}}$t=1,pm(),mm(),gm()}}function pm(){if($t===1){$t=0;var e=Oi,n=Pr,r=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||r){r=N.T,N.T=null;var s=X.p;X.p=2;var d=gt;gt|=4;try{Xp(n,e);var g=uc,S=eh(e.containerInfo),C=g.focusedElem,I=g.selectionRange;if(S!==C&&C&&C.ownerDocument&&Wd(C.ownerDocument.documentElement,C)){if(I!==null&&_o(C)){var ie=I.start,ue=I.end;if(ue===void 0&&(ue=ie),"selectionStart"in C)C.selectionStart=ie,C.selectionEnd=Math.min(ue,C.value.length);else{var he=C.ownerDocument||document,re=he&&he.defaultView||window;if(re.getSelection){var oe=re.getSelection(),Ae=C.textContent.length,Be=Math.min(I.start,Ae),kt=I.end===void 0?Be:Math.min(I.end,Ae);!oe.extend&&Be>kt&&(S=kt,kt=Be,Be=S);var P=Jd(C,Be),Y=Jd(C,kt);if(P&&Y&&(oe.rangeCount!==1||oe.anchorNode!==P.node||oe.anchorOffset!==P.offset||oe.focusNode!==Y.node||oe.focusOffset!==Y.offset)){var ne=he.createRange();ne.setStart(P.node,P.offset),oe.removeAllRanges(),Be>kt?(oe.addRange(ne),oe.extend(Y.node,Y.offset)):(ne.setEnd(Y.node,Y.offset),oe.addRange(ne))}}}}for(he=[],oe=C;oe=oe.parentNode;)oe.nodeType===1&&he.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<he.length;C++){var fe=he[C];fe.element.scrollLeft=fe.left,fe.element.scrollTop=fe.top}}Rs=!!oc,uc=oc=null}finally{gt=d,X.p=s,N.T=r}}e.current=n,$t=2}}function mm(){if($t===2){$t=0;var e=Oi,n=Pr,r=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||r){r=N.T,N.T=null;var s=X.p;X.p=2;var d=gt;gt|=4;try{Yp(e,n.alternate,n)}finally{gt=d,X.p=s,N.T=r}}$t=3}}function gm(){if($t===4||$t===3){$t=0,zt();var e=Oi,n=Pr,r=pi,s=nm;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?$t=5:($t=0,Pr=Oi=null,ym(e,e.pendingLanes));var d=e.pendingLanes;if(d===0&&(_i=null),xi(r),n=n.stateNode,mt&&typeof mt.onCommitFiberRoot=="function")try{mt.onCommitFiberRoot(bt,n,void 0,(n.current.flags&128)===128)}catch{}if(s!==null){n=N.T,d=X.p,X.p=2,N.T=null;try{for(var g=e.onRecoverableError,S=0;S<s.length;S++){var C=s[S];g(C.value,{componentStack:C.stack})}}finally{N.T=n,X.p=d}}(pi&3)!==0&&vs(),Xn(e),d=e.pendingLanes,(r&261930)!==0&&(d&42)!==0?e===Ku?$l++:($l=0,Ku=e):$l=0,Xl(0)}}function ym(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,Al(n)))}function vs(){return pm(),mm(),gm(),bm()}function bm(){if($t!==5)return!1;var e=Oi,n=$u;$u=0;var r=xi(pi),s=N.T,d=X.p;try{X.p=32>r?32:r,N.T=null,r=Xu,Xu=null;var g=Oi,S=pi;if($t=0,Pr=Oi=null,pi=0,(gt&6)!==0)throw Error(a(331));var C=gt;if(gt|=4,Wp(g.current),Zp(g,g.current,S,r),gt=C,Xl(0,!1),mt&&typeof mt.onPostCommitFiberRoot=="function")try{mt.onPostCommitFiberRoot(bt,g)}catch{}return!0}finally{X.p=d,N.T=s,ym(e,n)}}function vm(e,n,r){n=zn(r,n),n=Nu(e.stateNode,n,2),e=Ai(e,n,2),e!==null&&(st(e,2),Xn(e))}function xt(e,n,r){if(e.tag===3)vm(e,e,r);else for(;n!==null;){if(n.tag===3){vm(n,e,r);break}else if(n.tag===1){var s=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(_i===null||!_i.has(s))){e=zn(r,e),r=xp(2),s=Ai(n,r,2),s!==null&&(Sp(r,s,n,e),st(s,2),Xn(s));break}}n=n.return}}function Ju(e,n,r){var s=e.pingCache;if(s===null){s=e.pingCache=new Kx;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)||(Gu=!0,d.add(r),e=e0.bind(null,e,n,r),n.then(e,e))}function e0(e,n,r){var s=e.pingCache;s!==null&&s.delete(n),e.pingedLanes|=e.suspendedLanes&r,e.warmLanes&=~r,Nt===e&&(nt&r)===r&&(Bt===4||Bt===3&&(nt&62914560)===nt&&300>rt()-hs?(gt&2)===0&&Jr(e,0):Fu|=r,Zr===nt&&(Zr=0)),Xn(e)}function xm(e,n){n===0&&(n=je()),e=Ji(e,n),e!==null&&(st(e,n),Xn(e))}function t0(e){var n=e.memoizedState,r=0;n!==null&&(r=n.retryLane),xm(e,r)}function n0(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),xm(e,r)}function i0(e,n){return pt(e,n)}var xs=null,el=null,Wu=!1,Ss=!1,ec=!1,Bi=0;function Xn(e){e!==el&&e.next===null&&(el===null?xs=el=e:el=el.next=e),Ss=!0,Wu||(Wu=!0,l0())}function Xl(e,n){if(!ec&&Ss){ec=!0;do for(var r=!1,s=xs;s!==null;){if(e!==0){var d=s.pendingLanes;if(d===0)var g=0;else{var S=s.suspendedLanes,C=s.pingedLanes;g=(1<<31-Ze(42|e)+1)-1,g&=d&~(S&~C),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(r=!0,km(s,g))}else g=nt,g=Me(s,s===Nt?g:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(g&3)===0||de(s,g)||(r=!0,km(s,g));s=s.next}while(r);ec=!1}}function r0(){Sm()}function Sm(){Ss=Wu=!1;var e=0;Bi!==0&&m0()&&(e=Bi);for(var n=rt(),r=null,s=xs;s!==null;){var d=s.next,g=wm(s,n);g===0?(s.next=null,r===null?xs=d:r.next=d,d===null&&(el=r)):(r=s,(e!==0||(g&3)!==0)&&(Ss=!0)),s=d}$t!==0&&$t!==5||Xl(e),Bi!==0&&(Bi=0)}function wm(e,n){for(var r=e.suspendedLanes,s=e.pingedLanes,d=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var S=31-Ze(g),C=1<<S,I=d[S];I===-1?((C&r)===0||(C&s)!==0)&&(d[S]=U(C,n)):I<=n&&(e.expiredLanes|=C),g&=~C}if(n=Nt,r=nt,r=Me(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&&Ve(s),e.callbackNode=null,e.callbackPriority=0;if((r&3)===0||de(e,r)){if(n=r&-r,n===e.callbackPriority)return n;switch(s!==null&&Ve(s),xi(r)){case 2:case 8:r=K;break;case 32:r=ge;break;case 268435456:r=Ee;break;default:r=ge}return s=jm.bind(null,e),r=pt(r,s),e.callbackPriority=n,e.callbackNode=r,n}return s!==null&&s!==null&&Ve(s),e.callbackPriority=2,e.callbackNode=null,2}function jm(e,n){if($t!==0&&$t!==5)return e.callbackNode=null,e.callbackPriority=0,null;var r=e.callbackNode;if(vs()&&e.callbackNode!==r)return null;var s=nt;return s=Me(e,e===Nt?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s===0?null:(rm(e,s,n),wm(e,rt()),e.callbackNode!=null&&e.callbackNode===r?jm.bind(null,e):null)}function km(e,n){if(vs())return null;rm(e,n,!0)}function l0(){y0(function(){(gt&6)!==0?pt(M,r0):Sm()})}function tc(){if(Bi===0){var e=qr;e===0&&(e=De,De<<=1,(De&261888)===0&&(De=256)),Bi=e}return Bi}function Cm(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ta(""+e)}function Em(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 a0(e,n,r,s,d){if(n==="submit"&&r&&r.stateNode===d){var g=Cm((d[on]||null).action),S=s.submitter;S&&(n=(n=S[on]||null)?Cm(n.formAction):S.getAttribute("formAction"),n!==null&&(g=n,S=null));var C=new Ma("action","action",null,s,d);e.push({event:C,listeners:[{instance:null,listener:function(){if(s.defaultPrevented){if(Bi!==0){var I=S?Em(d,S):new FormData(d);Su(r,{pending:!0,data:I,method:d.method,action:g},null,I)}}else typeof g=="function"&&(C.preventDefault(),I=S?Em(d,S):new FormData(d),Su(r,{pending:!0,data:I,method:d.method,action:g},g,I))},currentTarget:d}]})}}for(var nc=0;nc<Uo.length;nc++){var ic=Uo[nc],s0=ic.toLowerCase(),o0=ic[0].toUpperCase()+ic.slice(1);Un(s0,"on"+o0)}Un(ih,"onAnimationEnd"),Un(rh,"onAnimationIteration"),Un(lh,"onAnimationStart"),Un("dblclick","onDoubleClick"),Un("focusin","onFocus"),Un("focusout","onBlur"),Un(kx,"onTransitionRun"),Un(Cx,"onTransitionStart"),Un(Ex,"onTransitionCancel"),Un(ah,"onTransitionEnd"),Cr("onMouseEnter",["mouseout","mouseover"]),Cr("onMouseLeave",["mouseout","mouseover"]),Cr("onPointerEnter",["pointerout","pointerover"]),Cr("onPointerLeave",["pointerout","pointerover"]),Xi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Xi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Xi("onBeforeInput",["compositionend","keypress","textInput","paste"]),Xi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Xi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Xi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Kl="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(" "),u0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Kl));function Nm(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 C=s[S],I=C.instance,ie=C.currentTarget;if(C=C.listener,I!==g&&d.isPropagationStopped())break e;g=C,d.currentTarget=ie;try{g(d)}catch(ue){La(ue)}d.currentTarget=null,g=I}else for(S=0;S<s.length;S++){if(C=s[S],I=C.instance,ie=C.currentTarget,C=C.listener,I!==g&&d.isPropagationStopped())break e;g=C,d.currentTarget=ie;try{g(d)}catch(ue){La(ue)}d.currentTarget=null,g=I}}}}function Je(e,n){var r=n[go];r===void 0&&(r=n[go]=new Set);var s=e+"__bubble";r.has(s)||(Am(n,e,2,!1),r.add(s))}function rc(e,n,r){var s=0;n&&(s|=4),Am(r,e,s,n)}var ws="_reactListening"+Math.random().toString(36).slice(2);function lc(e){if(!e[ws]){e[ws]=!0,Sd.forEach(function(r){r!=="selectionchange"&&(u0.has(r)||rc(r,!1,e),rc(r,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[ws]||(n[ws]=!0,rc("selectionchange",!1,n))}}function Am(e,n,r,s){switch(ig(n)){case 2:var d=B0;break;case 8:d=U0;break;default:d=xc}r=d.bind(null,n,r,e),d=void 0,!Co||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 ac(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 C=s.stateNode.containerInfo;if(C===d)break;if(S===4)for(S=s.return;S!==null;){var I=S.tag;if((I===3||I===4)&&S.stateNode.containerInfo===d)return;S=S.return}for(;C!==null;){if(S=wr(C),S===null)return;if(I=S.tag,I===5||I===6||I===26||I===27){s=g=S;continue e}C=C.parentNode}}s=s.return}Md(function(){var ie=g,ue=jo(r),he=[];e:{var re=sh.get(e);if(re!==void 0){var oe=Ma,Ae=e;switch(e){case"keypress":if(Ra(r)===0)break e;case"keydown":case"keyup":oe=nx;break;case"focusin":Ae="focus",oe=To;break;case"focusout":Ae="blur",oe=To;break;case"beforeblur":case"afterblur":oe=To;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":oe=Ld;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":oe=Gv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":oe=lx;break;case ih:case rh:case lh:oe=$v;break;case ah:oe=sx;break;case"scroll":case"scrollend":oe=Vv;break;case"wheel":oe=ux;break;case"copy":case"cut":case"paste":oe=Kv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":oe=Ud;break;case"toggle":case"beforetoggle":oe=fx}var Be=(n&4)!==0,kt=!Be&&(e==="scroll"||e==="scrollend"),P=Be?re!==null?re+"Capture":null:re;Be=[];for(var Y=ie,ne;Y!==null;){var fe=Y;if(ne=fe.stateNode,fe=fe.tag,fe!==5&&fe!==26&&fe!==27||ne===null||P===null||(fe=yl(Y,P),fe!=null&&Be.push(Zl(Y,fe,ne))),kt)break;Y=Y.return}0<Be.length&&(re=new oe(re,Ae,null,r,ue),he.push({event:re,listeners:Be}))}}if((n&7)===0){e:{if(re=e==="mouseover"||e==="pointerover",oe=e==="mouseout"||e==="pointerout",re&&r!==wo&&(Ae=r.relatedTarget||r.fromElement)&&(wr(Ae)||Ae[Sr]))break e;if((oe||re)&&(re=ue.window===ue?ue:(re=ue.ownerDocument)?re.defaultView||re.parentWindow:window,oe?(Ae=r.relatedTarget||r.toElement,oe=ie,Ae=Ae?wr(Ae):null,Ae!==null&&(kt=f(Ae),Be=Ae.tag,Ae!==kt||Be!==5&&Be!==27&&Be!==6)&&(Ae=null)):(oe=null,Ae=ie),oe!==Ae)){if(Be=Ld,fe="onMouseLeave",P="onMouseEnter",Y="mouse",(e==="pointerout"||e==="pointerover")&&(Be=Ud,fe="onPointerLeave",P="onPointerEnter",Y="pointer"),kt=oe==null?re:gl(oe),ne=Ae==null?re:gl(Ae),re=new Be(fe,Y+"leave",oe,r,ue),re.target=kt,re.relatedTarget=ne,fe=null,wr(ue)===ie&&(Be=new Be(P,Y+"enter",Ae,r,ue),Be.target=ne,Be.relatedTarget=kt,fe=Be),kt=fe,oe&&Ae)t:{for(Be=c0,P=oe,Y=Ae,ne=0,fe=P;fe;fe=Be(fe))ne++;fe=0;for(var _e=Y;_e;_e=Be(_e))fe++;for(;0<ne-fe;)P=Be(P),ne--;for(;0<fe-ne;)Y=Be(Y),fe--;for(;ne--;){if(P===Y||Y!==null&&P===Y.alternate){Be=P;break t}P=Be(P),Y=Be(Y)}Be=null}else Be=null;oe!==null&&Tm(he,re,oe,Be,!1),Ae!==null&&kt!==null&&Tm(he,kt,Ae,Be,!0)}}e:{if(re=ie?gl(ie):window,oe=re.nodeName&&re.nodeName.toLowerCase(),oe==="select"||oe==="input"&&re.type==="file")var ct=Qd;else if(Gd(re))if($d)ct=Sx;else{ct=vx;var Re=bx}else oe=re.nodeName,!oe||oe.toLowerCase()!=="input"||re.type!=="checkbox"&&re.type!=="radio"?ie&&So(ie.elementType)&&(ct=Qd):ct=xx;if(ct&&(ct=ct(e,ie))){Fd(he,ct,r,ue);break e}Re&&Re(e,re,ie),e==="focusout"&&ie&&re.type==="number"&&ie.memoizedProps.value!=null&&xo(re,"number",re.value)}switch(Re=ie?gl(ie):window,e){case"focusin":(Gd(Re)||Re.contentEditable==="true")&&(Rr=Re,Oo=ie,Cl=null);break;case"focusout":Cl=Oo=Rr=null;break;case"mousedown":Lo=!0;break;case"contextmenu":case"mouseup":case"dragend":Lo=!1,th(he,r,ue);break;case"selectionchange":if(jx)break;case"keydown":case"keyup":th(he,r,ue)}var Qe;if(Ro)e:{switch(e){case"compositionstart":var it="onCompositionStart";break e;case"compositionend":it="onCompositionEnd";break e;case"compositionupdate":it="onCompositionUpdate";break e}it=void 0}else zr?Vd(e,r)&&(it="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&(it="onCompositionStart");it&&(qd&&r.locale!=="ko"&&(zr||it!=="onCompositionStart"?it==="onCompositionEnd"&&zr&&(Qe=_d()):(Si=ue,Eo="value"in Si?Si.value:Si.textContent,zr=!0)),Re=js(ie,it),0<Re.length&&(it=new Bd(it,e,null,r,ue),he.push({event:it,listeners:Re}),Qe?it.data=Qe:(Qe=Yd(r),Qe!==null&&(it.data=Qe)))),(Qe=hx?px(e,r):mx(e,r))&&(it=js(ie,"onBeforeInput"),0<it.length&&(Re=new Bd("onBeforeInput","beforeinput",null,r,ue),he.push({event:Re,listeners:it}),Re.data=Qe)),a0(he,e,ie,r,ue)}Nm(he,n)})}function Zl(e,n,r){return{instance:e,listener:n,currentTarget:r}}function js(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=yl(e,r),d!=null&&s.unshift(Zl(e,d,g)),d=yl(e,n),d!=null&&s.push(Zl(e,d,g))),e.tag===3)return s;e=e.return}return[]}function c0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Tm(e,n,r,s,d){for(var g=n._reactName,S=[];r!==null&&r!==s;){var C=r,I=C.alternate,ie=C.stateNode;if(C=C.tag,I!==null&&I===s)break;C!==5&&C!==26&&C!==27||ie===null||(I=ie,d?(ie=yl(r,g),ie!=null&&S.unshift(Zl(r,ie,I))):d||(ie=yl(r,g),ie!=null&&S.push(Zl(r,ie,I)))),r=r.return}S.length!==0&&e.push({event:n,listeners:S})}var f0=/\r\n?/g,d0=/\u0000|\uFFFD/g;function zm(e){return(typeof e=="string"?e:""+e).replace(f0,`
9
+ `).replace(d0,"")}function Rm(e,n){return n=zm(n),zm(e)===n}function jt(e,n,r,s,d,g){switch(r){case"children":typeof s=="string"?n==="body"||n==="textarea"&&s===""||Nr(e,s):(typeof s=="number"||typeof s=="bigint")&&n!=="body"&&Nr(e,""+s);break;case"className":Na(e,"class",s);break;case"tabIndex":Na(e,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":Na(e,r,s);break;case"style":Rd(e,s,g);break;case"data":if(n!=="object"){Na(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=Ta(""+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=Ta(""+s),e.setAttribute(r,s);break;case"onClick":s!=null&&(e.onclick=Wn);break;case"onScroll":s!=null&&Je("scroll",e);break;case"onScrollEnd":s!=null&&Je("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=Ta(""+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":Je("beforetoggle",e),Je("toggle",e),Ea(e,"popover",s);break;case"xlinkActuate":Jn(e,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":Jn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":Jn(e,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":Jn(e,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":Jn(e,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":Jn(e,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":Jn(e,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":Jn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":Jn(e,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":Ea(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=Iv.get(r)||r,Ea(e,r,s))}}function sc(e,n,r,s,d,g){switch(r){case"style":Rd(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"?Nr(e,s):(typeof s=="number"||typeof s=="bigint")&&Nr(e,""+s);break;case"onScroll":s!=null&&Je("scroll",e);break;case"onScrollEnd":s!=null&&Je("scrollend",e);break;case"onClick":s!=null&&(e.onclick=Wn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!wd.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[on]||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,""):Ea(e,r,s)}}}function en(e,n,r){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Je("error",e),Je("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":Je("invalid",e);var C=g=S=d=null,I=null,ie=null;for(s in r)if(r.hasOwnProperty(s)){var ue=r[s];if(ue!=null)switch(s){case"name":d=ue;break;case"type":S=ue;break;case"checked":I=ue;break;case"defaultChecked":ie=ue;break;case"value":g=ue;break;case"defaultValue":C=ue;break;case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(a(137,n));break;default:jt(e,n,s,ue,r,null)}}Nd(e,g,C,I,ie,S,d,!1);return;case"select":Je("invalid",e),s=S=g=null;for(d in r)if(r.hasOwnProperty(d)&&(C=r[d],C!=null))switch(d){case"value":g=C;break;case"defaultValue":S=C;break;case"multiple":s=C;default:jt(e,n,d,C,r,null)}n=g,r=S,e.multiple=!!s,n!=null?Er(e,!!s,n,!1):r!=null&&Er(e,!!s,r,!0);return;case"textarea":Je("invalid",e),g=d=s=null;for(S in r)if(r.hasOwnProperty(S)&&(C=r[S],C!=null))switch(S){case"value":s=C;break;case"defaultValue":d=C;break;case"children":g=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(a(91));break;default:jt(e,n,S,C,r,null)}Td(e,s,d,g);return;case"option":for(I in r)r.hasOwnProperty(I)&&(s=r[I],s!=null)&&(I==="selected"?e.selected=s&&typeof s!="function"&&typeof s!="symbol":jt(e,n,I,s,r,null));return;case"dialog":Je("beforetoggle",e),Je("toggle",e),Je("cancel",e),Je("close",e);break;case"iframe":case"object":Je("load",e);break;case"video":case"audio":for(s=0;s<Kl.length;s++)Je(Kl[s],e);break;case"image":Je("error",e),Je("load",e);break;case"details":Je("toggle",e);break;case"embed":case"source":case"link":Je("error",e),Je("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(So(n)){for(ue in r)r.hasOwnProperty(ue)&&(s=r[ue],s!==void 0&&sc(e,n,ue,s,r,void 0));return}}for(C in r)r.hasOwnProperty(C)&&(s=r[C],s!=null&&jt(e,n,C,s,r,null))}function h0(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,C=null,I=null,ie=null,ue=null;for(oe in r){var he=r[oe];if(r.hasOwnProperty(oe)&&he!=null)switch(oe){case"checked":break;case"value":break;case"defaultValue":I=he;default:s.hasOwnProperty(oe)||jt(e,n,oe,null,s,he)}}for(var re in s){var oe=s[re];if(he=r[re],s.hasOwnProperty(re)&&(oe!=null||he!=null))switch(re){case"type":g=oe;break;case"name":d=oe;break;case"checked":ie=oe;break;case"defaultChecked":ue=oe;break;case"value":S=oe;break;case"defaultValue":C=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(a(137,n));break;default:oe!==he&&jt(e,n,re,oe,s,he)}}vo(e,S,C,I,ie,ue,g,d);return;case"select":oe=S=C=re=null;for(g in r)if(I=r[g],r.hasOwnProperty(g)&&I!=null)switch(g){case"value":break;case"multiple":oe=I;default:s.hasOwnProperty(g)||jt(e,n,g,null,s,I)}for(d in s)if(g=s[d],I=r[d],s.hasOwnProperty(d)&&(g!=null||I!=null))switch(d){case"value":re=g;break;case"defaultValue":C=g;break;case"multiple":S=g;default:g!==I&&jt(e,n,d,g,s,I)}n=C,r=S,s=oe,re!=null?Er(e,!!r,re,!1):!!s!=!!r&&(n!=null?Er(e,!!r,n,!0):Er(e,!!r,r?[]:"",!1));return;case"textarea":oe=re=null;for(C in r)if(d=r[C],r.hasOwnProperty(C)&&d!=null&&!s.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:jt(e,n,C,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":re=d;break;case"defaultValue":oe=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)}Ad(e,re,oe);return;case"option":for(var Ae in r)re=r[Ae],r.hasOwnProperty(Ae)&&re!=null&&!s.hasOwnProperty(Ae)&&(Ae==="selected"?e.selected=!1:jt(e,n,Ae,null,s,re));for(I in s)re=s[I],oe=r[I],s.hasOwnProperty(I)&&re!==oe&&(re!=null||oe!=null)&&(I==="selected"?e.selected=re&&typeof re!="function"&&typeof re!="symbol":jt(e,n,I,re,s,oe));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Be in r)re=r[Be],r.hasOwnProperty(Be)&&re!=null&&!s.hasOwnProperty(Be)&&jt(e,n,Be,null,s,re);for(ie in s)if(re=s[ie],oe=r[ie],s.hasOwnProperty(ie)&&re!==oe&&(re!=null||oe!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(a(137,n));break;default:jt(e,n,ie,re,s,oe)}return;default:if(So(n)){for(var kt in r)re=r[kt],r.hasOwnProperty(kt)&&re!==void 0&&!s.hasOwnProperty(kt)&&sc(e,n,kt,void 0,s,re);for(ue in s)re=s[ue],oe=r[ue],!s.hasOwnProperty(ue)||re===oe||re===void 0&&oe===void 0||sc(e,n,ue,re,s,oe);return}}for(var P in r)re=r[P],r.hasOwnProperty(P)&&re!=null&&!s.hasOwnProperty(P)&&jt(e,n,P,null,s,re);for(he in s)re=s[he],oe=r[he],!s.hasOwnProperty(he)||re===oe||re==null&&oe==null||jt(e,n,he,re,s,oe)}function Dm(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function p0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,r=performance.getEntriesByType("resource"),s=0;s<r.length;s++){var d=r[s],g=d.transferSize,S=d.initiatorType,C=d.duration;if(g&&C&&Dm(S)){for(S=0,C=d.responseEnd,s+=1;s<r.length;s++){var I=r[s],ie=I.startTime;if(ie>C)break;var ue=I.transferSize,he=I.initiatorType;ue&&Dm(he)&&(I=I.responseEnd,S+=ue*(I<C?1:(C-ie)/(I-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 oc=null,uc=null;function ks(e){return e.nodeType===9?e:e.ownerDocument}function Mm(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 _m(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 cc(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 fc=null;function m0(){var e=window.event;return e&&e.type==="popstate"?e===fc?!1:(fc=e,!0):(fc=null,!1)}var Om=typeof setTimeout=="function"?setTimeout:void 0,g0=typeof clearTimeout=="function"?clearTimeout:void 0,Lm=typeof Promise=="function"?Promise:void 0,y0=typeof queueMicrotask=="function"?queueMicrotask:typeof Lm<"u"?function(e){return Lm.resolve(null).then(e).catch(b0)}:Om;function b0(e){setTimeout(function(){throw e})}function Ui(e){return e==="head"}function Bm(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),rl(n);return}s--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")s++;else if(r==="html")Pl(e.ownerDocument.documentElement);else if(r==="head"){r=e.ownerDocument.head,Pl(r);for(var g=r.firstChild;g;){var S=g.nextSibling,C=g.nodeName;g[ml]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&g.rel.toLowerCase()==="stylesheet"||r.removeChild(g),g=S}}else r==="body"&&Pl(e.ownerDocument.body);r=d}while(r);rl(n)}function Um(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 dc(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":dc(r),yo(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}e.removeChild(r)}}function v0(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[ml])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 x0(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 qm(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 hc(e){return e.data==="$?"||e.data==="$~"}function pc(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function S0(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 mc=null;function Im(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 Hm(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 Vm(e,n,r){switch(n=ks(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 Pl(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);yo(e)}var Ln=new Map,Ym=new Set;function Cs(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var mi=X.d;X.d={f:w0,r:j0,D:k0,C:C0,L:E0,m:N0,X:T0,S:A0,M:z0};function w0(){var e=mi.f(),n=gs();return e||n}function j0(e){var n=jr(e);n!==null&&n.tag===5&&n.type==="form"?ap(n):mi.r(e)}var tl=typeof document>"u"?null:document;function Gm(e,n,r){var s=tl;if(s&&typeof n=="string"&&n){var d=An(n);d='link[rel="'+e+'"][href="'+d+'"]',typeof r=="string"&&(d+='[crossorigin="'+r+'"]'),Ym.has(d)||(Ym.add(d),e={rel:e,crossOrigin:r,href:n},s.querySelector(d)===null&&(n=s.createElement("link"),en(n,"link",e),Xt(n),s.head.appendChild(n)))}}function k0(e){mi.D(e),Gm("dns-prefetch",e,null)}function C0(e,n){mi.C(e,n),Gm("preconnect",e,n)}function E0(e,n,r){mi.L(e,n,r);var s=tl;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=nl(e);break;case"script":g=il(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(Jl(g))||n==="script"&&s.querySelector(Wl(g))||(n=s.createElement("link"),en(n,"link",e),Xt(n),s.head.appendChild(n)))}}function N0(e,n){mi.m(e,n);var r=tl;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=il(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(Wl(g)))return}s=r.createElement("link"),en(s,"link",e),Xt(s),r.head.appendChild(s)}}}function A0(e,n,r){mi.S(e,n,r);var s=tl;if(s&&e){var d=kr(s).hoistableStyles,g=nl(e);n=n||"default";var S=d.get(g);if(!S){var C={loading:0,preload:null};if(S=s.querySelector(Jl(g)))C.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":n},r),(r=Ln.get(g))&&gc(e,r);var I=S=s.createElement("link");Xt(I),en(I,"link",e),I._p=new Promise(function(ie,ue){I.onload=ie,I.onerror=ue}),I.addEventListener("load",function(){C.loading|=1}),I.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Es(S,n,s)}S={type:"stylesheet",instance:S,count:1,state:C},d.set(g,S)}}}function T0(e,n){mi.X(e,n);var r=tl;if(r&&e){var s=kr(r).hoistableScripts,d=il(e),g=s.get(d);g||(g=r.querySelector(Wl(d)),g||(e=b({src:e,async:!0},n),(n=Ln.get(d))&&yc(e,n),g=r.createElement("script"),Xt(g),en(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},s.set(d,g))}}function z0(e,n){mi.M(e,n);var r=tl;if(r&&e){var s=kr(r).hoistableScripts,d=il(e),g=s.get(d);g||(g=r.querySelector(Wl(d)),g||(e=b({src:e,async:!0,type:"module"},n),(n=Ln.get(d))&&yc(e,n),g=r.createElement("script"),Xt(g),en(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},s.set(d,g))}}function Fm(e,n,r,s){var d=(d=te.current)?Cs(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=nl(r.href),r=kr(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=nl(r.href);var g=kr(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(Jl(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||R0(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=il(r),r=kr(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 nl(e){return'href="'+An(e)+'"'}function Jl(e){return'link[rel="stylesheet"]['+e+"]"}function Qm(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function R0(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}),en(n,"link",r),Xt(n),e.head.appendChild(n))}function il(e){return'[src="'+An(e)+'"]'}function Wl(e){return"script[async]"+e}function $m(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,Xt(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"),Xt(s),en(s,"style",d),Es(s,r.precedence,e),n.instance=s;case"stylesheet":d=nl(r.href);var g=e.querySelector(Jl(d));if(g)return n.state.loading|=4,n.instance=g,Xt(g),g;s=Qm(r),(d=Ln.get(d))&&gc(s,d),g=(e.ownerDocument||e).createElement("link"),Xt(g);var S=g;return S._p=new Promise(function(C,I){S.onload=C,S.onerror=I}),en(g,"link",s),n.state.loading|=4,Es(g,r.precedence,e),n.instance=g;case"script":return g=il(r.src),(d=e.querySelector(Wl(g)))?(n.instance=d,Xt(d),d):(s=r,(d=Ln.get(g))&&(s=b({},r),yc(s,d)),e=e.ownerDocument||e,d=e.createElement("script"),Xt(d),en(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,Es(s,r.precedence,e));return n.instance}function Es(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 C=s[S];if(C.dataset.precedence===n)g=C;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 gc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function yc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var Ns=null;function Xm(e,n,r){if(Ns===null){var s=new Map,d=Ns=new Map;d.set(r,s)}else d=Ns,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[ml]||g[Zt]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(n)||"";S=e+S;var C=s.get(S);C?C.push(g):s.set(S,[g])}}return s}function Km(e,n,r){e=e.ownerDocument||e,e.head.insertBefore(r,n==="title"?e.querySelector("head > title"):null)}function D0(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 Zm(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function M0(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=nl(s.href),g=n.querySelector(Jl(d));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=As.bind(e),n.then(e,e)),r.state.loading|=4,r.instance=g,Xt(g);return}g=n.ownerDocument||n,s=Qm(s),(d=Ln.get(d))&&gc(s,d),g=g.createElement("link"),Xt(g);var S=g;S._p=new Promise(function(C,I){S.onload=C,S.onerror=I}),en(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=As.bind(e),n.addEventListener("load",r),n.addEventListener("error",r))}}var bc=0;function _0(e,n){return e.stylesheets&&e.count===0&&zs(e,e.stylesheets),0<e.count||0<e.imgCount?function(r){var s=setTimeout(function(){if(e.stylesheets&&zs(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&bc===0&&(bc=62500*p0());var d=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&zs(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>bc?50:800)+n);return e.unsuspend=r,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(d)}}:null}function As(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)zs(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Ts=null;function zs(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Ts=new Map,n.forEach(O0,e),Ts=null,As.call(e))}function O0(e,n){if(!(n.state.loading&4)){var r=Ts.get(e);if(r)var s=r.get(null);else{r=new Map,Ts.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=As.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 ea={$$typeof:L,Provider:null,Consumer:null,_currentValue:pe,_currentValue2:pe,_threadCount:0};function L0(e,n,r,s,d,g,S,C,I){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=Ce(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ce(0),this.hiddenUpdates=Ce(null),this.identifierPrefix=s,this.onUncaughtError=d,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=I,this.incompleteTransitions=new Map}function Pm(e,n,r,s,d,g,S,C,I,ie,ue,he){return e=new L0(e,n,r,S,I,ie,ue,he,C),n=1,g===!0&&(n|=24),g=vn(3,null,null,n),e.current=g,g.stateNode=e,n=Po(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:s,isDehydrated:r,cache:n},tu(g),e}function Jm(e){return e?(e=_r,e):_r}function Wm(e,n,r,s,d,g){d=Jm(d),s.context===null?s.context=d:s.pendingContext=d,s=Ni(n),s.payload={element:r},g=g===void 0?null:g,g!==null&&(s.callback=g),r=Ai(e,s,n),r!==null&&(pn(r,e,n),Dl(r,e,n))}function eg(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<n?r:n}}function vc(e,n){eg(e,n),(e=e.alternate)&&eg(e,n)}function tg(e){if(e.tag===13||e.tag===31){var n=Ji(e,67108864);n!==null&&pn(n,e,67108864),vc(e,67108864)}}function ng(e){if(e.tag===13||e.tag===31){var n=kn();n=Ht(n);var r=Ji(e,n);r!==null&&pn(r,e,n),vc(e,n)}}var Rs=!0;function B0(e,n,r,s){var d=N.T;N.T=null;var g=X.p;try{X.p=2,xc(e,n,r,s)}finally{X.p=g,N.T=d}}function U0(e,n,r,s){var d=N.T;N.T=null;var g=X.p;try{X.p=8,xc(e,n,r,s)}finally{X.p=g,N.T=d}}function xc(e,n,r,s){if(Rs){var d=Sc(s);if(d===null)ac(e,n,s,Ds,r),rg(e,s);else if(I0(d,e,n,r,s))s.stopPropagation();else if(rg(e,s),n&4&&-1<q0.indexOf(e)){for(;d!==null;){var g=jr(d);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=ke(g.pendingLanes);if(S!==0){var C=g;for(C.pendingLanes|=2,C.entangledLanes|=2;S;){var I=1<<31-Ze(S);C.entanglements[1]|=I,S&=~I}Xn(g),(gt&6)===0&&(ps=rt()+500,Xl(0))}}break;case 31:case 13:C=Ji(g,2),C!==null&&pn(C,g,2),gs(),vc(g,2)}if(g=Sc(s),g===null&&ac(e,n,s,Ds,r),g===d)break;d=g}d!==null&&s.stopPropagation()}else ac(e,n,s,null,r)}}function Sc(e){return e=jo(e),wc(e)}var Ds=null;function wc(e){if(Ds=null,e=wr(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=p(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 Ds=e,null}function ig(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(yt()){case M:return 2;case K:return 8;case ge:case be:return 32;case Ee:return 268435456;default:return 32}default:return 32}}var jc=!1,qi=null,Ii=null,Hi=null,ta=new Map,na=new Map,Vi=[],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 rg(e,n){switch(e){case"focusin":case"focusout":qi=null;break;case"dragenter":case"dragleave":Ii=null;break;case"mouseover":case"mouseout":Hi=null;break;case"pointerover":case"pointerout":ta.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":na.delete(n.pointerId)}}function ia(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=jr(n),n!==null&&tg(n)),e):(e.eventSystemFlags|=s,n=e.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),e)}function I0(e,n,r,s,d){switch(n){case"focusin":return qi=ia(qi,e,n,r,s,d),!0;case"dragenter":return Ii=ia(Ii,e,n,r,s,d),!0;case"mouseover":return Hi=ia(Hi,e,n,r,s,d),!0;case"pointerover":var g=d.pointerId;return ta.set(g,ia(ta.get(g)||null,e,n,r,s,d)),!0;case"gotpointercapture":return g=d.pointerId,na.set(g,ia(na.get(g)||null,e,n,r,s,d)),!0}return!1}function lg(e){var n=wr(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,xr(e.priority,function(){ng(r)});return}}else if(n===31){if(n=p(r),n!==null){e.blockedOn=n,xr(e.priority,function(){ng(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 Ms(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var r=Sc(e.nativeEvent);if(r===null){r=e.nativeEvent;var s=new r.constructor(r.type,r);wo=s,r.target.dispatchEvent(s),wo=null}else return n=jr(r),n!==null&&tg(n),e.blockedOn=r,!1;n.shift()}return!0}function ag(e,n,r){Ms(e)&&r.delete(n)}function H0(){jc=!1,qi!==null&&Ms(qi)&&(qi=null),Ii!==null&&Ms(Ii)&&(Ii=null),Hi!==null&&Ms(Hi)&&(Hi=null),ta.forEach(ag),na.forEach(ag)}function _s(e,n){e.blockedOn===n&&(e.blockedOn=null,jc||(jc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,H0)))}var Os=null;function sg(e){Os!==e&&(Os=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Os===e&&(Os=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(wc(s||r)===null)continue;break}var g=jr(r);g!==null&&(e.splice(n,3),n-=3,Su(g,{pending:!0,data:d,method:r.method,action:s},s,d))}}))}function rl(e){function n(I){return _s(I,e)}qi!==null&&_s(qi,e),Ii!==null&&_s(Ii,e),Hi!==null&&_s(Hi,e),ta.forEach(n),na.forEach(n);for(var r=0;r<Vi.length;r++){var s=Vi[r];s.blockedOn===e&&(s.blockedOn=null)}for(;0<Vi.length&&(r=Vi[0],r.blockedOn===null);)lg(r),r.blockedOn===null&&Vi.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[on]||null;if(typeof g=="function")S||sg(r);else if(S){var C=null;if(g&&g.hasAttribute("formAction")){if(d=g,S=g[on]||null)C=S.formAction;else if(wc(d)!==null)continue}else C=S.action;typeof C=="function"?r[s+1]=C:(r.splice(s,3),s-=3),sg(r)}}}function og(){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 kc(e){this._internalRoot=e}Ls.prototype.render=kc.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));var r=n.current,s=kn();Wm(r,s,e,n,null,null)},Ls.prototype.unmount=kc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Wm(e.current,2,null,e,null,null),gs(),n[Sr]=null}};function Ls(e){this._internalRoot=e}Ls.prototype.unstable_scheduleHydration=function(e){if(e){var n=pl();e={blockedOn:null,target:e,priority:n};for(var r=0;r<Vi.length&&n!==0&&n<Vi[r].priority;r++);Vi.splice(r,0,e),r===0&&lg(e)}};var ug=i.version;if(ug!=="19.2.6")throw Error(a(527,ug,"19.2.6"));X.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=m(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var V0={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:N,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Bs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bs.isDisabled&&Bs.supportsFiber)try{bt=Bs.inject(V0),mt=Bs}catch{}}return la.createRoot=function(e,n){if(!o(e))throw Error(a(299));var r=!1,s="",d=gp,g=yp,S=bp;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=Pm(e,1,!1,null,null,r,s,null,d,g,S,og),e[Sr]=n.current,lc(e),new kc(n)},la.hydrateRoot=function(e,n,r){if(!o(e))throw Error(a(299));var s=!1,d="",g=gp,S=yp,C=bp,I=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&&(C=r.onRecoverableError),r.formState!==void 0&&(I=r.formState)),n=Pm(e,1,!0,n,r??null,s,d,I,g,S,C,og),n.context=Jm(null),r=n.current,s=kn(),s=Ht(s),d=Ni(s),d.callback=null,Ai(r,d,s),r=s,n.current.lanes=r,st(n,r),Xn(n),e[Sr]=n.current,lc(e),new Ls(n)},la.version="19.2.6",la}var xg;function m1(){if(xg)return Ac.exports;xg=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(),Ac.exports=p1(),Ac.exports}var g1=m1();const y1=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;function db(t){if(!t||typeof t!="object")return!1;const i=t;return i.version===1&&typeof i.id=="string"&&y1.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 Kf="codeshell.environments.v1",hb=32;function Zf(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 pb(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&&!db({version:1,id:i.environmentId,name:"Host",kind:"hub",entryPath:"/"}))throw new Error("无效的环境身份。");return{address:Zf(i.address),name:i.name.trim(),...i.environmentId?{environmentId:i.environmentId}:{}}}function eo(t){const i=t.getItem(Kf);if(i===null)return[];if(i.length>1e5)throw new Error("连接记录过大,请清理当前工作台的连接记录。");const l=JSON.parse(i);if(!Array.isArray(l)||l.length>hb)throw new Error("连接记录格式无效。");return l.map(pb)}function Sg(t,i){const l=pb(i),a=eo(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>hb)throw new Error("最多保存 32 个环境,请先移除不再使用的连接。");return t.setItem(Kf,JSON.stringify(f)),f}function b1(t,i){const l=eo(t).filter(a=>a.address!==Zf(i));return t.setItem(Kf,JSON.stringify(l)),l}function v1(t,i,l){const a=t.find(o=>o.address===i+l.entryPath);if(a?.environmentId&&a.environmentId!==l.id)throw new Error("当前地址对应的环境已变化,请核对项目后重新保存连接。")}function Pf({discover:t=!0,navigate:i}){const[l,a]=w.useState(!1),[o,f]=w.useState(),[u,p]=w.useState([]),[h,m]=w.useState(""),[y,b]=w.useState(""),[v,x]=w.useState(""),k=w.useRef(null),_=w.useRef(null);w.useEffect(()=>{try{p(eo(window.localStorage))}catch{x("无法读取连接记录。当前项目仍可使用。")}},[]),w.useEffect(()=>{if(!t)return;const z=new AbortController;return Ue("/api/v1/environment",{signal:z.signal}).then(L=>{if(!z.signal.aborted){if(!db(L))throw new Error("环境信息无效,请更新工作台后重试。");f(L),v1(eo(window.localStorage),window.location.origin,L)}}).catch(L=>{z.signal.aborted||L instanceof Xe&&[401,404].includes(L.status)||x(L instanceof Error?L.message:"无法读取环境信息。")}),()=>z.abort()},[t]),w.useEffect(()=>{l&&(k.current?.showModal(),_.current?.focus())},[l]);const D=z=>{try{p(z()),x("")}catch(L){x(L instanceof Error?L.message:"保存连接失败。")}},R=z=>{const L=Zf(z);a(!1),i?i(L):window.location.assign(L)};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:k,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:_,type:"button",className:"ghost",onClick:()=>a(!1),children:"关闭"})]}),c.jsx("p",{children:"打开目标环境后选择项目。切换入口不会移动文件或正在运行的任务。"}),c.jsxs("p",{className:"environment-location",children:["当前地址:",window.location.origin]}),v?c.jsx("p",{role:"alert",className:"form-error",children:v}):null,o?c.jsx("button",{type:"button",className:"library-button",onClick:()=>D(()=>Sg(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(z=>c.jsxs("li",{children:[c.jsxs("div",{children:[c.jsx("strong",{children:z.name}),c.jsx("small",{children:z.address})]}),c.jsx("button",{type:"button",className:"library-button",onClick:()=>R(z.address),children:"打开"}),c.jsx("button",{type:"button",className:"ghost","aria-label":`移除 ${z.name}`,onClick:()=>D(()=>b1(window.localStorage,z.address)),children:"移除"})]},z.address))}),c.jsxs("form",{onSubmit:z=>{z.preventDefault(),D(()=>Sg(window.localStorage,{name:h,address:y.trim()}))},children:[c.jsxs("label",{children:["连接名称",c.jsx("input",{required:!0,maxLength:80,value:h,onChange:z=>m(z.target.value),placeholder:"例如:家里的电脑"})]}),c.jsxs("label",{children:["工作台地址",c.jsx("input",{required:!0,type:"url",maxLength:2048,value:y,onChange:z=>b(z.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 x1({session:t,onClose:i,onAuthLost:l}){const[a,o]=w.useState([]),[f,u]=w.useState(""),[p,h]=w.useState("loading"),m=w.useRef(null),y=w.useCallback(x=>{x instanceof Xe&&x.status===401?l():u(x instanceof Error?x.message:"操作失败,请重试。")},[l]);w.useEffect(()=>{let x=!0;return m.current?.showModal(),Ue("/api/v1/auth/sessions").then(k=>{x&&o(k.sessions)}).catch(k=>{x&&y(k)}).finally(()=>{x&&h(null)}),()=>{x=!1}},[y]);const b=async x=>{h(x.id),u("");try{await Ue(`/api/v1/auth/sessions/${encodeURIComponent(x.id)}`,{method:"DELETE"}),x.current?l():o(k=>k.filter(_=>_.id!==x.id))}catch(k){y(k)}finally{h(null)}},v=async()=>{h("logout"),u("");try{await ub("/api/v1/auth/logout"),l()}catch(x){y(x)}finally{h(null)}};return c.jsxs("dialog",{className:"devices-dialog",ref:m,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,p==="loading"?c.jsx("p",{role:"status",children:"正在读取设备…"}):null,c.jsx("ul",{className:"device-list",children:a.map(x=>c.jsxs("li",{children:[c.jsxs("div",{children:[c.jsxs("strong",{children:[x.deviceName||"未命名设备",x.current?"(当前)":""]}),c.jsxs("span",{children:["最近活动 ",new Date(x.lastSeenAt).toLocaleString()]})]}),c.jsx("button",{className:"ghost",disabled:p!==null,onClick:()=>{b(x)},children:p===x.id?"处理中…":"撤销登录"})]},x.id))}),c.jsx("button",{className:"stop",disabled:p!==null,onClick:()=>{v()},children:"退出当前设备"})]})}function Dc(t){return{expectedRevision:t?t.revision:null,id:t?.id??"",catalogId:t?.catalogId??"",model:t?.model??"",baseUrl:t?.baseUrl??"",apiKey:""}}function S1(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 Jf(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 mb(t){return Jf(await Ue("/api/v1/configuration",{signal:t}))}async function Wf(t,i,l){return Jf(await Ue(`/api/v1/configuration/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:l}))}function w1(t,i){return Wf("connections",S1(t),i)}function j1(t,i){return Wf("defaults",t,i)}function k1(t,i,l){return Wf("skills",{name:t,enabled:i},l)}function gb(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 C1(t,i,l,a){return Jf(await Ue("/api/v1/configuration/connections",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,...i?{replacementText:i}:{},...a?{expectedRevision:a}:{}}),signal:l}))}async function E1(t,i){const l=wa(),a=St("/api/v1/configuration/connections/probe"),o=St("/api/v1/configuration/connections/probe/cancel");let f;try{f=await Ue(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,requestId:l}),signal:i})}catch(u){throw i?.aborted&&await Ue(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 ed="/api/v1/skills";async function wg(t){const i=await Ue(ed,{signal:t});if(!i||!Array.isArray(i.skills)||!Array.isArray(i.directories))throw new Error("Skills 列表读取失败,请刷新重试。");return i}async function N1(t,i){const l=await Ue(`${ed}/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 gr(t,i,l,a){return Ue(`${ed}${t}`,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(l),signal:a})}const A1=(t,i,l)=>gr("/local","POST",{name:t,content:i},l),T1=(t,i,l,a)=>gr("/local","PUT",{name:t,content:i,revision:l},a),z1=(t,i,l)=>gr("/local","DELETE",{name:t,revision:i},l),R1=(t,i)=>gr("/github/preview","POST",{url:t.trim()},i),D1=(t,i,l,a)=>gr("/github/install","POST",{reviewToken:t,pathInRepo:i,name:l.trim()},a),M1=(t,i,l)=>gr("/github/update-preview","POST",{name:t,revision:i},l),_1=(t,i)=>gr("/github/update","POST",{reviewToken:t},i);function Hs(t){return`---
10
+ name: ${t||"my-skill"}
11
+ description: 描述这个 Skill 适合处理什么任务
12
+ ---
13
+
14
+ # 工作方式
15
+
16
+ 在这里写下具体步骤、输入要求和完成标准。
17
+ `}function Af(t){return/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(t)&&!t.includes("..")}function O1(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 jg={project:"工作区",user:"用户级",plugin:"插件","panel-app":"Panel App"};function L1({onAuthLost:t,onChanged:i,onDirtyChange:l,configurationVersion:a=0}){const[o,f]=w.useState(null),[u,p]=w.useState(null),[h,m]=w.useState(""),[y,b]=w.useState("all"),[v,x]=w.useState(""),[k,_]=w.useState(""),[D,R]=w.useState(""),[z,L]=w.useState(0),[G,ae]=w.useState(!1),[T,V]=w.useState(!1),$=w.useRef(null),q=w.useRef(null),E=w.useRef(!1),B=w.useRef({onAuthLost:t,onChanged:i});B.current={onAuthLost:t,onChanged:i};const H=w.useRef(null),Z=w.useRef(null),ee=w.useCallback(j=>{j instanceof Xe&&j.status===401?B.current.onAuthLost():_(j instanceof Error?j.message:"操作失败,请重试。")},[]);w.useEffect(()=>()=>{$.current?.abort(),q.current?.abort()},[]),w.useEffect(()=>{if($.current){E.current=!0;return}const j=new AbortController;return q.current=j,wg(j.signal).then(O=>{j.signal.aborted||f(O)}).catch(O=>{j.signal.aborted||ee(O)}),()=>j.abort()},[z,a,ee]),w.useEffect(()=>{u&&H.current?.focus()},[u?.kind]);const W=j=>{Z.current=document.activeElement,_(""),R(""),ae(!1),V(!1),p(j)},N=()=>{p(null),ae(!1),V(!1),_(""),Z.current?.focus()},X=()=>{if(!$.current){if(G){V(!0);return}N()}},pe=async(j,O,J=!1)=>{if($.current)return;q.current?.abort();const A=new AbortController;$.current=A,x(j),_(""),R("");try{const le=await O(A.signal);if(A.signal.aborted)return;if(J){try{const me=await wg(A.signal);A.signal.aborted||f(me)}catch(me){if(me instanceof Xe&&me.status===401)throw me;A.signal.aborted||_("操作已完成,但列表刷新失败。请点击刷新查看最新状态。")}if(A.signal.aborted)return;R(le.message||"设置已保存,下次任务生效。"),B.current.onChanged?.()}return le}catch(le){A.signal.aborted||ee(le);return}finally{$.current===A&&($.current=null),A.signal.aborted||(x(""),E.current&&(E.current=!1,L(le=>le+1)))}};w.useEffect(()=>(l?.(G||!!v),()=>l?.(!1)),[G,v,l]);const ye=O1(o?.skills??[],h,y);return c.jsxs("section",{className:"hub-skills","aria-labelledby":"skills-title",onKeyDown:j=>{j.key==="Escape"&&u&&!v&&(j.preventDefault(),X())},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:!!v||!!u,onClick:()=>W({kind:"import"}),children:"从 GitHub 导入"}),c.jsx("button",{className:"config-button config-button-primary",disabled:!!v||!!u,onClick:()=>W({kind:"create"}),children:"+ 创建 Skill"})]})]}),k&&c.jsx("div",{className:"config-message config-error",role:"alert",children:k}),D&&c.jsx("div",{className:"config-message config-success",role:"status",children:D}),v&&c.jsxs("p",{className:"skills-progress",role:"status",children:[v,"…"]}),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:H,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:!!v,onClick:X,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:N,children:"放弃修改并关闭"})]})]}),(u.kind==="create"||u.kind==="detail")&&c.jsx(B1,{detail:u.kind==="detail"?u.detail:void 0,busy:!!v,run:pe,onSaved:N,onDirtyChange:ae},u.kind==="detail"?u.detail.name+u.detail.revision:"create"),u.kind==="import"&&c.jsx(U1,{preview:u.preview,busy:!!v,run:pe,onPreview:j=>p({kind:"import",preview:j}),onInstalled:N},u.preview?.reviewToken??"url"),u.kind==="update"&&c.jsx(q1,{preview:u.preview,busy:!!v,run:pe,onUpdated:N}),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:!!v,onClick:X,children:"取消"}),c.jsx("button",{className:"config-button skills-danger",disabled:!!v,onClick:()=>{pe("正在移除 Skill",j=>z1(u.skill.name,u.skill.revision,j),!0).then(j=>{j&&N()})},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:j=>m(j.target.value),placeholder:"搜索名称或用途…"})]}),c.jsxs("select",{"aria-label":"Skill 来源",value:y,onChange:j=>b(j.target.value),children:[c.jsx("option",{value:"all",children:"全部来源"}),Object.entries(jg).map(([j,O])=>c.jsx("option",{value:j,children:O},j))]}),c.jsx("button",{className:"config-button config-button-quiet",disabled:!!v,onClick:()=>{_(""),L(j=>j+1)},children:"刷新"})]}),!o&&!k?c.jsx("p",{className:"config-help",children:"正在读取 Skills…"}):o?c.jsxs("p",{className:"skills-count",children:[ye.length===o.skills.length?`${ye.length} 个 Skill`:`显示 ${ye.length} / ${o.skills.length} 个 Skill`," · ",o.skills.filter(j=>j.enabled).length," 个已启用"]}):null,o&&!ye.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:ye.map(j=>c.jsxs("article",{className:"skills-card",children:[c.jsxs("div",{className:"skills-card-heading",children:[c.jsxs("div",{children:[c.jsx("h2",{children:j.name}),c.jsx("span",{className:"config-badge",children:jg[j.source]}),j.origin&&c.jsx("span",{className:"config-badge",children:"GitHub"})]}),c.jsx("button",{className:"config-switch",role:"switch","aria-checked":j.enabled,"aria-label":`${j.enabled?"停用":"启用"} ${j.name}`,disabled:!!v||!!j.disabledReason,title:j.disabledReason,onClick:()=>{pe("正在更新 Skill",async O=>(await k1(j.name,!j.enabled,O),{ok:!0,name:j.name,message:j.enabled?"Skill 已停用,下次任务生效。":"Skill 已启用,下次任务生效。"}),!0)},children:c.jsx("span",{})})]}),c.jsx("p",{children:j.description||"暂未填写用途描述。"}),j.origin&&c.jsxs("p",{className:"skills-source",children:[j.origin.url.replace("https://github.com/","")," · ",j.origin.ref," ·"," ",j.origin.commit.slice(0,8)]}),j.readOnlyReason&&c.jsx("p",{className:"config-help",children:j.readOnlyReason}),j.disabledReason&&c.jsx("p",{className:"config-help",children:j.disabledReason}),c.jsxs("footer",{className:"skills-actions",children:[c.jsx("button",{className:"config-button config-button-quiet",disabled:!!v||!!u,onClick:()=>{Z.current=document.activeElement,pe("正在读取 Skill",O=>N1(j.name,O)).then(O=>{O&&W({kind:"detail",detail:O})})},children:j.editable?"查看与编辑":"查看说明"}),j.editable&&j.origin&&c.jsx("button",{className:"config-button config-button-quiet",disabled:!!v||!!u,onClick:()=>{pe("正在检查来源更新",O=>M1(j.name,j.revision,O)).then(O=>{O?.changed?W({kind:"update",preview:O}):O&&R(`${j.name} 已是最新版本。`)})},children:"检查更新"}),j.removable&&c.jsx("button",{className:"config-button config-button-quiet skills-remove",disabled:!!v||!!u,onClick:()=>W({kind:"remove",skill:j}),children:"移除"})]})]},j.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(j=>c.jsx("li",{children:c.jsx("code",{children:j})},j))})]})]})}function B1({detail:t,busy:i,run:l,onSaved:a,onDirtyChange:o}){const[f,u]=w.useState(t?.name??"my-skill"),[p,h]=w.useState(t?.content??Hs("my-skill")),m=p!==t?.content,y=!t||t.editable;return w.useEffect(()=>{o(y&&(t?p!==t.content:f!=="my-skill"||p!==Hs("my-skill")))},[p,f,t,y,o]),c.jsx("form",{className:"skills-editor",onSubmit:b=>{b.preventDefault(),l(t?"正在保存 Skill":"正在创建 Skill",v=>t?T1(t.name,p,t.revision,v):A1(f.trim(),p,v),!0).then(v=>{v&&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 v=b.target.value;p===Hs(f)&&h(Hs(v)),u(v)},"aria-describedby":"skill-name-help","aria-label":"Skill 名称"}),c.jsx("small",{id:"skill-name-help",children:"字母、数字、短横线、下划线或点;创建后名称保持不变。"}),!Af(f)&&c.jsx("span",{className:"skills-field-error",children:"请输入有效名称。"})]}),c.jsxs("label",{children:[c.jsxs("span",{children:[y?"SKILL.md":"说明",t&&y&&m&&c.jsx("small",{className:"skills-unsaved",children:"未保存"})]}),c.jsx("textarea",{value:p,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:!p.trim()||!t&&!Af(f)||!!t&&!m,children:t?"保存修改":"创建 Skill"})]})]})})}function U1({preview:t,busy:i,run:l,onPreview:a,onInstalled:o}){const[f,u]=w.useState(""),[p,h]=w.useState(t?.skills[0]?.pathInRepo??""),[m,y]=w.useState(t?.skills[0]?.name??"");return t?c.jsxs("form",{className:"skills-import-preview",onSubmit:b=>{b.preventDefault(),l("正在导入 Skill 与资源",v=>D1(t.reviewToken,p,m,v),!0).then(v=>{v&&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:p===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:m,onChange:b=>y(b.target.value)})]}),c.jsx("p",{className:"config-help",children:"将导入预览时的确定版本。不会执行其中的脚本。"}),c.jsx("button",{className:"config-button config-button-primary",disabled:!p||!Af(m),type:"submit",children:"确认导入到工作区"})]})]})]}):c.jsxs("form",{className:"skills-import-url",onSubmit:b=>{b.preventDefault(),l("正在检查 GitHub 来源",v=>R1(f,v)).then(v=>{v&&a(v)})},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=>_1(t.reviewToken,o),!0).then(o=>{o&&a()})},children:"确认更新到预览版本"})]})}function I1(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 Mc(t){return t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean)}function H1(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 kg(t){try{return new URL(t).origin}catch{return""}}function V1(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:kg(t.url)!==kg(i.url??""));return!!l&&a}function Y1(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,p]of[["env","环境变量"],["headers","请求头"],["envHeaders","环境变量请求头"]]){const h=H1(t[u],p);Object.keys(h).length&&(l[u]=h)}const a=Mc(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?Mc(t.allowedTools):void 0;(!i||JSON.stringify(o)!==JSON.stringify(i.allowedTools))&&(l.allowedTools=o??null);const f=Mc(t.disabledTools);return(!i||JSON.stringify(f)!==JSON.stringify(i.disabledTools))&&(l.disabledTools=f),t.reuseStoredSecrets&&(l.reuseStoredSecrets=!0),l}function yb(t){if(!t||typeof t.workspacePath!="string"||!Array.isArray(t.servers)||!Array.isArray(t.removed))throw new Error("服务端返回了无效的 MCP 配置,请刷新重试。");return t}const fl=(t,i="")=>`/api/v1/mcp/servers/${encodeURIComponent(t)}${i}`;async function G1(t){return yb(await Ue("/api/v1/mcp",{signal:t}))}async function oo(t,i,l,a){return yb(await Ue(t,{method:i,headers:{"Content-Type":"application/json"},...l===void 0?{}:{body:JSON.stringify(l)},signal:a}))}function F1(t,i,l){return oo(i?fl(i.name):"/api/v1/mcp/servers",i?"PUT":"POST",Y1(t,i),l)}function Q1(t,i,l){return oo(fl(t,"/enabled"),"PUT",{enabled:i},l)}function $1(t,i){return oo(fl(t),"DELETE",void 0,i)}function Cg(t,i){return oo(fl(t,"/inherit"),"POST",{},i)}async function X1(t,i){const l=await Ue(fl(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 Eg(t,i,l){return Ue(St(fl(t,"/cancel-probe"),i,l),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",keepalive:!0})}const K1={local:"工作区本地",project:"工作区配置",user:"用户级",managed:"启动配置",plugin:"插件提供"};function Z1({onAuthLost:t,onConfigurationChange:i,configurationVersion:l=0,onDirtyChange:a}){const[o,f]=w.useState(null),[u,p]=w.useState(!0),[h,m]=w.useState(!1),[y,b]=w.useState(!1),[v,x]=w.useState(""),[k,_]=w.useState(""),[D,R]=w.useState(null),[z,L]=w.useState(null),[G,ae]=w.useState(""),[T,V]=w.useState({}),[$,q]=w.useState(null),[E,B]=w.useState(0),H=w.useRef({onAuthLost:t,onConfigurationChange:i,onDirtyChange:a});H.current={onAuthLost:t,onConfigurationChange:i,onDirtyChange:a};const Z=w.useRef(!1),ee=w.useRef(null),W=w.useRef(null),N=w.useRef(null),X=w.useRef(0),pe=w.useRef(!1),ye=w.useRef(l);w.useEffect(()=>{H.current.onDirtyChange?.(y||h)},[y,h]);const j=w.useCallback(F=>{F instanceof Xe&&F.status===401?H.current.onAuthLost():x(F instanceof Error?F.message:"MCP 操作失败,请重试。")},[]);w.useEffect(()=>(Z.current=!0,()=>{Z.current=!1,H.current.onDirtyChange?.(!1),W.current?.abort();const F=N.current;F&&(F.controller.abort(),Eg(F.name,F.workspace,F.projectId).catch(()=>{}))}),[]),w.useEffect(()=>{ye.current!==l&&(ye.current=l,W.current?pe.current=!0:B(F=>F+1))},[l]),w.useEffect(()=>{const F=new AbortController;ee.current=F;const Se=Date.now(),Ne=++X.current;return p(!0),x(""),G1(F.signal).then(Te=>{!F.signal.aborted&&Ne===X.current&&(f(Te),V(Ge=>Object.fromEntries(Object.entries(Ge).filter(([,et])=>Date.parse(et.checkedAt)>=Se))))}).catch(Te=>{!F.signal.aborted&&Ne===X.current&&j(Te)}).finally(()=>{!F.signal.aborted&&Ne===X.current&&p(!1)}),()=>F.abort()},[E,j]);const O=async(F,Se="MCP 设置已保存,任务进程会加载新的配置。")=>{if(W.current||N.current)return!1;ee.current?.abort();const Ne=++X.current,Te=new AbortController;W.current=Te,m(!0),p(!1),x(""),_("");try{const Ge=await F(Te.signal);return!Z.current||Te.signal.aborted||Ne!==X.current?!1:(f(Ge),V({}),_(Se),H.current.onConfigurationChange?.(),!0)}catch(Ge){return Z.current&&!Te.signal.aborted&&j(Ge),!1}finally{W.current===Te&&(W.current=null),Z.current&&!Te.signal.aborted&&(m(!1),pe.current&&(pe.current=!1,B(Ge=>Ge+1)))}},J=async F=>{if(N.current||W.current)return;const Se=new AbortController;N.current={name:F,controller:Se,workspace:Ws()??"",projectId:ba()},q(F),x(""),_(""),V(Ne=>{const Te={...Ne};return delete Te[F],Te});try{const Ne=await X1(F,Se.signal);Z.current&&!Se.signal.aborted&&V(Te=>({...Te,[F]:Ne}))}catch(Ne){Z.current&&!Se.signal.aborted&&j(Ne)}finally{N.current?.controller===Se&&(N.current=null),Z.current&&q(null)}},A=async()=>{const F=N.current;if(F)try{await Eg(F.name,F.workspace,F.projectId)}catch(Se){Z.current&&j(Se)}finally{F.controller.abort(),N.current===F&&(N.current=null),Z.current&&(q(null),V(Se=>({...Se,[F.name]:{name:F.name,status:"cancelled",checkedAt:new Date().toISOString(),durationMs:0,error:{code:"cancelled",message:"测试已取消。"}}})))}},le=h||u||$!==null,me=G.trim().toLocaleLowerCase(),te=[...o?.servers??[]];D?.kind==="edit"&&!te.some(F=>F.name===D.name)&&te.push(D.original);const se=te.filter(F=>!me||F.name.toLocaleLowerCase().includes(me)||D?.kind==="edit"&&D.name===F.name),we=D?.kind==="edit"?te.find(F=>F.name===D.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:G,onChange:F=>ae(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:le,onClick:()=>B(F=>F+1),children:"刷新 MCP"}),c.jsx("button",{className:"config-button",disabled:le||D!==null,onClick:()=>R({kind:"new"}),children:"+ 添加服务"})]})]}),v&&c.jsx("p",{className:"config-message config-error",role:"alert",children:v}),k&&c.jsx("p",{className:"config-message config-success",role:"status",children:k}),h&&c.jsx("p",{className:"config-help",role:"status",children:"正在保存 MCP 配置…"}),u&&!o&&c.jsx("p",{className:"config-help",role:"status",children:"正在读取 MCP 配置…"}),D?.kind==="new"&&c.jsxs("div",{className:"config-card hub-mcp-editor-card",children:[c.jsx("h2",{children:"添加 MCP 服务"}),c.jsx(Ng,{disabled:le,save:O,onDone:()=>R(null),onProbe:F=>{J(F)},onDirtyChange:b})]}),!se.length&&o&&D?.kind!=="new"&&c.jsxs("div",{className:"config-empty",children:[c.jsx("span",{"aria-hidden":"true",children:"⌘"}),c.jsx("h3",{children:me?"没有匹配的服务":"连接你的工具与数据"}),c.jsx("p",{children:me?"试试其他服务名称。":"添加运行 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 服务"," ","· ",K1[F.scope]]})]}),c.jsx("button",{className:"config-switch",type:"button",role:"switch","aria-checked":F.enabled,"aria-label":`${F.enabled?"停用":"启用"} MCP ${F.name}`,disabled:le||F.pluginDisabled,onClick:()=>{O(Se=>Q1(F.name,!F.enabled,Se))},children:c.jsx("span",{})})]}),D?.kind==="edit"&&D.name===F.name&&we?c.jsx(Ng,{server:we,disabled:le,save:O,onDone:()=>R(null),onProbe:Se=>{J(Se)},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:[$===F.name?c.jsx("button",{className:"config-button",onClick:()=>{A()},children:"取消测试"}):c.jsx("button",{className:"config-button",disabled:le||F.pluginDisabled||F.transport==="inprocess",onClick:()=>{J(F.name)},children:"测试连接"}),F.editable&&c.jsx("button",{className:"config-button config-button-quiet",disabled:le||D!==null,onClick:()=>{L(null),R({kind:"edit",name:F.name,original:F})},children:"编辑"}),F.hasLocalOverride&&c.jsx("button",{className:"config-button config-button-quiet",disabled:le,onClick:()=>{O(Se=>Cg(F.name,Se),"已移除本地覆盖,恢复继承配置。")},children:"恢复继承"}),F.deletable&&c.jsx("button",{className:"config-button config-button-quiet hub-mcp-remove",disabled:le||D!==null,onClick:()=>L(F.name),children:"移除"})]}),z===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:le,onClick:()=>L(null),children:"取消"}),c.jsx("button",{className:"config-button hub-mcp-remove",disabled:le,onClick:async()=>{await O(Se=>$1(F.name,Se),"已从当前工作区移除服务。")&&L(null)},children:"确认移除"})]})]}),$===F.name&&c.jsx("p",{className:"hub-mcp-probing",role:"status",children:"正在建立测试连接并读取工具列表…"}),T[F.name]&&c.jsx(P1,{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:le,onClick:()=>{O(Se=>Cg(F.name,Se),"已恢复继承的 MCP 配置。")},children:"恢复继承"})]},F.name))]}),c.jsx("p",{className:"config-help hub-mcp-explanation",children:"连接使用运行 CodeShell 的设备上的网络、环境和凭据。测试只建立一次短连接并读取工具列表,完成后关闭;不会调用工具或改变启用状态。"})]})}function Ng({server:t,disabled:i,save:l,onDone:a,onProbe:o,onDirtyChange:f}){const u=w.useRef(t).current,[p,h]=w.useState(()=>I1(u)),m=w.useRef(JSON.stringify(p)).current,y=JSON.stringify(p)!==m;w.useEffect(()=>{f(y)},[y,f]),w.useEffect(()=>()=>f(!1),[f]);const[b,v]=w.useState(""),x=(D,R)=>h(z=>({...z,[D]:R})),k=V1(p,u),_=p.transport==="stdio";return c.jsx("form",{className:"hub-mcp-editor",onSubmit:async D=>{D.preventDefault(),v("");const R=D.nativeEvent.submitter?.getAttribute("data-probe")==="true";try{await l(z=>F1(p,u,z))&&(a(),R&&o(p.name.trim()))}catch(z){v(z instanceof Error?z.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:p.name,onChange:D=>x("name",D.target.value),placeholder:"例如 workspace-tools"})]}),c.jsxs("label",{children:[c.jsx("span",{children:"连接方式"}),c.jsxs("select",{"aria-label":"连接方式",value:p.transport,onChange:D=>x("transport",D.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 配置)"})]})]}),_?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:p.command,onChange:D=>x("command",D.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:p.clearArgs,value:p.args,onChange:D=>x("args",D.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:p.clearArgs,onChange:D=>x("clearArgs",D.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:p.url,onChange:D=>x("url",D.target.value),placeholder:"https://example.com/mcp"}),u?.urlHasHiddenParts&&c.jsx("small",{children:"已有地址的查询参数已隐藏;不修改地址时会保留。"})]})]}),_?c.jsx(_c,{title:"环境变量",rows:p.env,onChange:D=>x("env",D)}):c.jsx(_c,{title:"请求头",rows:p.headers,onChange:D=>x("headers",D)}),c.jsxs("details",{className:"hub-mcp-advanced",children:[c.jsx("summary",{children:"高级配置"}),c.jsx("div",{className:"config-form-grid",children:_?c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"转发运行环境变量"}),c.jsx("textarea",{"aria-label":"转发运行环境变量",rows:2,value:p.envVars,onChange:D=>x("envVars",D.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:p.bearerTokenEnvVar,onChange:D=>x("bearerTokenEnvVar",D.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:p.credentialRef,onChange:D=>x("credentialRef",D.target.value),placeholder:"可选",autoComplete:"off"}),c.jsx("small",{children:"引用已有凭据;优先于 Bearer 环境变量。"})]})]})}),!_&&c.jsx(_c,{title:"环境变量请求头",rows:p.envHeaders,onChange:D=>x("envHeaders",D),visibleValues:!0}),c.jsxs("label",{className:"hub-mcp-check",children:[c.jsx("input",{type:"checkbox",checked:p.restrictTools,onChange:D=>x("restrictTools",D.target.checked)}),c.jsx("span",{children:"只允许指定工具"})]}),c.jsxs("div",{className:"config-form-grid",children:[p.restrictTools&&c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"允许的工具名称"}),c.jsx("textarea",{rows:2,value:p.allowedTools,onChange:D=>x("allowedTools",D.target.value),placeholder:"每行一个精确工具名称;留空则不开放任何工具"})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"停用的工具名称"}),c.jsx("textarea",{rows:2,value:p.disabledTools,onChange:D=>x("disabledTools",D.target.value),placeholder:"每行一个精确工具名称,可留空"})]})]})]}),c.jsxs("label",{className:"hub-mcp-check",children:[c.jsx("input",{type:"checkbox",checked:p.enabled,onChange:D=>x("enabled",D.target.checked)}),c.jsx("span",{children:"启用服务,让任务可以使用这些工具"})]}),k&&c.jsxs("label",{className:"hub-mcp-check hub-mcp-reuse",children:[c.jsx("input",{type:"checkbox",required:!0,checked:p.reuseStoredSecrets,onChange:D=>x("reuseStoredSecrets",D.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 _c({title:t,rows:i,onChange:l,visibleValues:a=!1}){const o=(f,u)=>l(i.map(p=>p.id===f?{...p,...u}:p));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:wa(),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 P1({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 J1={overview:{title:"设置",description:"管理当前工作区的模型、Skills 和工具连接。"},models:{title:"模型与连接",description:"选择默认模型,管理工作区使用的服务商连接与凭据。"},skills:{title:"Skills",description:"让 CodeShell 按照你熟悉的工作方式完成任务。"},mcp:{title:"MCP 工具",description:"管理工具连接,测试连接并查看可用工具。"}};function W1(t){return t.section==="skills"?c.jsx(L1,{onAuthLost:t.onAuthLost,onDirtyChange:t.onDirtyChange,onChanged:t.onConfigurationChange,configurationVersion:t.configurationVersion}):c.jsx(eS,{...t})}function eS({host:t="hub",section:i,onSectionChange:l,onAuthLost:a,onDirtyChange:o,onConfigurationChange:f,configurationVersion:u=0}){const[p,h]=w.useState(null),[m,y]=w.useState(!0),[b,v]=w.useState(""),[x,k]=w.useState(""),[_,D]=w.useState(null),[R,z]=w.useState(0),L=w.useRef({onAuthLost:a,onConfigurationChange:f});L.current={onAuthLost:a,onConfigurationChange:f};const G=w.useRef(!1),ae=w.useRef(0),T=w.useRef(null),V=w.useRef(null),$=w.useRef(!1),q=w.useRef(u),E=w.useCallback(Z=>{Z instanceof Xe&&Z.status===401?L.current.onAuthLost():v(gb(Z))},[]);w.useEffect(()=>{u!==q.current&&(q.current=u,V.current?$.current=!0:z(Z=>Z+1))},[u]),w.useEffect(()=>(G.current=!0,()=>{G.current=!1,V.current?.abort()}),[]),w.useEffect(()=>{const Z=new AbortController;T.current=Z;const ee=++ae.current;return y(!0),v(""),mb(Z.signal).then(W=>{!Z.signal.aborted&&ee===ae.current&&h(W)}).catch(W=>{!Z.signal.aborted&&ee===ae.current&&E(W)}).finally(()=>{!Z.signal.aborted&&ee===ae.current&&y(!1)}),()=>Z.abort()},[R,E]);const B=async(Z,ee)=>{if(V.current)return!1;T.current?.abort();const W=++ae.current,N=new AbortController;V.current=N,y(!1),D(Z),v(""),k("");try{const X=await ee(N.signal);return!G.current||N.signal.aborted||W!==ae.current?!1:(h(X),k(X.restartRequired?"设置已保存,重启服务后生效。":"设置已保存,下次运行任务时生效。"),L.current.onConfigurationChange?.(),!0)}catch(X){return X instanceof Xe&&X.status===409&&($.current=!0),G.current&&!N.signal.aborted&&E(X),!1}finally{V.current===N&&(V.current=null),G.current&&!N.signal.aborted&&(D(null),$.current&&($.current=!1,z(X=>X+1)))}},H=J1[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:H.title}),c.jsx("p",{children:H.description})]}),c.jsx("button",{className:"config-button config-button-quiet",disabled:m||_!==null,onClick:()=>{k(""),z(Z=>Z+1)},children:m?"读取中…":"刷新"})]}),b&&c.jsx("div",{className:"config-message config-error",role:"alert",children:b}),x&&c.jsx("div",{className:"config-message config-success",role:"status",children:x}),_&&c.jsxs("p",{className:"config-loading",role:"status",children:["正在保存",_,"…"]}),!p&&m?c.jsx("p",{className:"config-loading",role:"status",children:"正在读取工作区设置…"}):null,p&&c.jsxs(c.Fragment,{children:[i==="overview"&&c.jsx(tS,{host:t,configuration:p,onSectionChange:l}),i==="models"&&c.jsx(nS,{configuration:p,disabled:_!==null||m,saving:_!==null,save:B,onDirtyChange:o,onAuthLost:a}),i==="mcp"&&c.jsx(Z1,{onAuthLost:a,onDirtyChange:o,onConfigurationChange:f,configurationVersion:u}),c.jsx("p",{className:"config-scope-note",children:"配置作用于当前工作区,所有连接到这里的设备共用。"})]})]})}function tS({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 p=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:p},u.section):c.jsx("div",{className:"config-overview-row",children:p},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 nS({configuration:t,disabled:i,saving:l,save:a,onDirtyChange:o,onAuthLost:f}){const[u,p]=w.useState(null),[h,m]=w.useState(null),[y,b]=w.useState(""),[v,x]=w.useState(!1),[k,_]=w.useState(!1),[D,R]=w.useState(null),[z,L]=w.useState({}),G=w.useRef(null),ae=t.connections.filter(E=>E.tag==="text"),T=t.connections.length-ae.length,V=i||!!D;w.useEffect(()=>{h&&!t.connections.some(E=>E.id===h.id)&&m(null)},[t.connections,h]),w.useEffect(()=>()=>G.current?.abort(),[]);const $=w.useRef(new Map);w.useEffect(()=>{const E=new Map(t.connections.map(H=>[H.id,H.revision??JSON.stringify(H)])),B=new Set([...$.current].filter(([H,Z])=>E.get(H)!==Z).map(([H])=>H));$.current=E,D&&B.has(D)&&G.current?.abort(),B.size&&L(H=>Object.fromEntries(Object.entries(H).filter(([Z])=>!B.has(Z))))},[t,D]),w.useEffect(()=>(o?.(v||k||l||!!D),()=>o?.(!1)),[v,k,l,D,o]);const q=async E=>{if(G.current)return;const B=new AbortController;G.current=B,R(E.id),L(H=>({...H,[E.id]:"正在发送一条简短测试请求…"}));try{const H=await E1(E.id,B.signal);B.signal.aborted||L(Z=>({...Z,[E.id]:H}))}catch(H){B.signal.aborted||(H instanceof Xe&&H.status===401?f():L(Z=>({...Z,[E.id]:gb(H)})))}finally{G.current===B&&(G.current=null,R(null))}};return c.jsxs(c.Fragment,{children:[c.jsx(iS,{configuration:t,disabled:V,save:a,onDirtyChange:_}),c.jsxs("div",{className:"config-section-heading",children:[c.jsxs("h2",{children:["文字模型连接 ",c.jsx("span",{className:"config-count",children:ae.length})]}),c.jsxs("button",{className:"config-button",disabled:V||u!==null||h!==null||!t.catalog.length,onClick:()=>p("__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(rS,{connection:u==="__new__"?void 0:u,configuration:t,disabled:V,save:a,onDone:()=>p(null),onDirtyChange:x},u==="__new__"?"new":u.id)]}),!ae.length&&u!=="__new__"&&c.jsx(lS,{title:"还没有文字模型连接",description:"添加服务商地址、模型名称和 API Key,再选择一个默认模型。"}),c.jsx("div",{className:"config-connection-list",children:ae.map(E=>{const B=t.catalog.find(N=>N.id===E.catalogId),H=h?.id===E.id,Z=H&&h?.revision!==E.revision,ee=t.defaults.text===E.id&&ae.length>1,W=z[E.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:E.id}),c.jsx("span",{children:B?.displayName??E.catalogId})]}),t.defaults.text===E.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:()=>p(E),children:"编辑"})]}),c.jsxs("dl",{className:"config-connection-facts",children:[c.jsxs("div",{children:[c.jsx("dt",{children:"模型"}),c.jsx("dd",{children:E.model||"未填写"})]}),c.jsxs("div",{children:[c.jsx("dt",{children:"服务地址"}),c.jsx("dd",{children:E.baseUrl||B?.defaultBaseUrl||"服务商默认地址"})]}),c.jsxs("div",{children:[c.jsx("dt",{children:"API Key"}),c.jsx("dd",{children:E.hasApiKey?"•••••••• · 已配置":E.needsKey?"未配置":"无需 API Key"})]})]}),c.jsxs("div",{className:"config-model-actions",children:[D===E.id?c.jsx("button",{className:"config-button",onClick:()=>{G.current?.abort(),L(N=>({...N,[E.id]:"已取消连接测试。"}))},children:"取消测试"}):c.jsx("button",{className:"config-button",disabled:V||u!==null||h!==null,onClick:()=>{q(E)},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:()=>{m(E),b("")},children:"删除"})]}),W&&c.jsxs("div",{className:`config-probe-result ${typeof W!="string"&&W.ok?"is-success":""}`,role:"status",children:[c.jsx("span",{children:typeof W=="string"?W:W.message}),typeof W!="string"&&c.jsxs("small",{children:[Math.max(.01,W.latencyMs/1e3).toFixed(2)," 秒 ·"," ",new Date(W.checkedAt).toLocaleTimeString()]})]}),H&&c.jsxs("div",{className:"config-remove-confirm",children:[c.jsxs("h3",{children:["删除连接 ",E.id,"?"]}),c.jsx("p",{children:"连接会从当前工作区移除,已有对话记录会保留。"}),Z&&c.jsx("p",{role:"alert",children:"连接已被其他设备更新,请取消后重新检查再删除。"}),ae.length===1&&c.jsx("p",{children:"这是最后一个文字模型连接。删除后需重新添加连接才能继续对话。"}),ee&&c.jsxs("label",{children:[c.jsx("span",{children:"替代默认模型"}),c.jsxs("select",{"aria-label":"替代默认模型",value:y,onChange:N=>b(N.target.value),disabled:V,children:[c.jsx("option",{value:"",children:"请选择其他连接"}),ae.filter(N=>N.id!==E.id).map(N=>c.jsxs("option",{value:N.id,children:[N.id," · ",N.model]},N.id))]})]}),c.jsxs("div",{className:"config-form-actions",children:[c.jsx("button",{className:"config-button",disabled:V,onClick:()=>m(null),children:"取消删除"}),c.jsx("button",{className:"config-button config-button-danger",disabled:V||Z||ee&&!y,onClick:()=>{a("删除连接",N=>C1(E.id,y||void 0,N,h?.revision)).then(N=>{N&&m(null)})},children:"确认删除连接"})]})]})]},E.id)})}),T>0&&c.jsxs("p",{className:"config-help",children:["另有 ",T," 个其他类型的模型连接,保留在工作区配置中。目前此处提供文字模型编辑。"]})]})}function iS({configuration:t,disabled:i,save:l,onDirtyChange:a}){const[o,f]=w.useState(t.defaults.text??""),[u,p]=w.useState(t.defaults.auxText??""),h=w.useRef(t.defaults);w.useEffect(()=>{const b=h.current;h.current=t.defaults,f(v=>v===(b.text??"")?t.defaults.text??"":v),p(v=>v===(b.auxText??"")?t.defaults.auxText??"":v)},[t.defaults]);const m=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("默认模型",v=>j1({text:o,auxText:u||null},v))},children:c.jsxs("fieldset",{disabled:i||!m.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&&!m.some(b=>b.id===o)&&c.jsxs("option",{value:o,disabled:!0,children:[o,"(连接不可用)"]}),m.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=>p(b.target.value),"aria-label":"默认辅助模型",children:[c.jsx("option",{value:"",children:"跟随对话模型"}),u&&!m.some(b=>b.id===u)&&c.jsxs("option",{value:u,disabled:!0,children:[u,"(连接不可用)"]}),m.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 rS({connection:t,configuration:i,disabled:l,save:a,onDone:o,onDirtyChange:f}){const[u,p]=w.useState(()=>{const z=Dc(t);return t||(z.catalogId=i.catalog[0]?.id??""),z}),h=w.useRef(u),m=JSON.stringify(u)!==JSON.stringify(h.current),[y,b]=w.useState(!1),v=t?i.connections.find(z=>z.id===t.id):void 0,x=!!t&&(!v||u.expectedRevision!==v.revision);w.useEffect(()=>{if(!m&&v&&u.expectedRevision!==v.revision){const z=Dc(v);h.current=z,p(z)}},[m,v,u.expectedRevision]);const k=()=>{if(!v)return;const z=Dc(v);h.current=z,p(z),b(!1)};w.useEffect(()=>(f(m),()=>f(!1)),[m,f]);const _=i.catalog.find(z=>z.id===u.catalogId),D=!t&&i.connections.some(z=>z.id===u.id.trim()),R=(z,L)=>p(G=>({...G,[z]:L}));return c.jsx("form",{className:"config-connection-editor",onSubmit:async z=>{z.preventDefault(),!x&&await a("模型连接",L=>w1(u,L))&&o()},children:c.jsxs("fieldset",{disabled:l,children:[c.jsx("legend",{className:"config-sr-only",children:t?`编辑 ${t.id}`:"新模型连接"}),x&&c.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[c.jsx("p",{children:v?"其他设备已更新这个连接。你的草稿已保留,请检查最新设置后再保存。":"这个连接已被其他设备删除。草稿仍保留,你可以复制内容后关闭编辑。"}),v&&c.jsx("button",{className:"config-button",type:"button",onClick:k,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:z=>R("id",z.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:z=>R("catalogId",z.target.value),children:[t&&!_&&c.jsx("option",{value:u.catalogId,children:u.catalogId}),i.catalog.map(z=>c.jsx("option",{value:z.id,children:z.displayName},z.id))]})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"模型名称"}),c.jsx("input",{required:!0,maxLength:240,value:u.model,onChange:z=>R("model",z.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:z=>R("baseUrl",z.target.value),placeholder:_?.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:_?.needsKey&&!t?.hasApiKey,value:u.apiKey,onChange:z=>R("apiKey",z.target.value),placeholder:t?.hasApiKey?"留空保留现有 API Key":_?.needsKey?"输入 API Key":"可选",autoComplete:"new-password",spellCheck:!1}),c.jsx("small",{children:t?.hasApiKey?"现有密钥保留在运行 CodeShell 的设备上,输入新值可替换。":"密钥保存在当前工作区配置中。"})]})]}),D&&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:()=>m?b(!0):o(),children:"取消"}),c.jsx("button",{type:"submit",className:"config-button config-button-primary",disabled:D||x,children:"保存连接"})]})]})})}function lS({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 Oc(t,i=!1){return St(`/api/v1/files/content?path=${encodeURIComponent(t)}${i?"&inline=true":""}`)}function Ag(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function aS({initialPath:t,openVersion:i=0,onAuthLost:l}){const[a,o]=w.useState(""),[f,u]=w.useState(null),[p,h]=w.useState(null),[m,y]=w.useState(!1),[b,v]=w.useState(!1),[x,k]=w.useState(""),[_,D]=w.useState(0),[R,z]=w.useState(""),L=w.useRef(null),G=w.useRef(l);G.current=l;const ae=w.useCallback(q=>{q instanceof Xe&&q.status===401?G.current():k(q instanceof Error?q.message:"文件读取失败,请重试。")},[]);w.useEffect(()=>{const q=new AbortController;return y(!0),k(""),Ue(`/api/v1/files?path=${encodeURIComponent(a)}`,{signal:q.signal}).then(E=>{q.signal.aborted||u(E)}).catch(E=>{q.signal.aborted||ae(E)}).finally(()=>{q.signal.aborted||y(!1)}),()=>q.abort()},[a,_,ae]);const T=w.useCallback((q,E=!1)=>{L.current?.abort();const B=new AbortController;L.current=B,h(null),v(!0),k(""),Ue(`${Oc(q)}&preview=true`,{signal:B.signal}).then(H=>{B.signal.aborted||(E&&o(H.path.split("/").slice(0,-1).join("/")),h(H))}).catch(H=>{B.signal.aborted||ae(H)}).finally(()=>{B.signal.aborted||v(!1)})},[ae]);w.useEffect(()=>{t&&T(t,!0)},[t,i,T]),w.useEffect(()=>()=>L.current?.abort(),[]);const V=q=>{L.current?.abort(),v(!1),h(null),o(q),z("")},$=f?.files.filter(q=>q.name.toLocaleLowerCase().includes(R.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:()=>{D(q=>q+1),p&&T(p.path)},children:"刷新"})]}),x?c.jsx("div",{className:"library-error",role:"alert",children:x}):null,c.jsxs("nav",{className:"file-breadcrumbs","aria-label":"文件位置",children:[c.jsx("button",{onClick:()=>V(""),children:"工作区"}),(f?.path??a).split("/").filter(Boolean).map((q,E,B)=>c.jsxs(w.Fragment,{children:[c.jsx("span",{"aria-hidden":"true",children:"/"}),c.jsx("button",{onClick:()=>V(B.slice(0,E+1).join("/")),children:q})]},E))]}),c.jsxs("div",{className:`file-columns${p||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:R,onChange:q=>z(q.target.value)})]}),c.jsx("div",{className:"file-entries","aria-busy":m,children:m?c.jsx("p",{className:"library-empty",role:"status",children:"正在读取文件…"}):$.length===0?c.jsx("p",{className:"library-empty",children:R?"没有匹配的文件。":"这个文件夹还没有文件。"}):$.map(q=>c.jsxs("button",{className:`file-entry${p?.path===q.path?" selected":""}`,onClick:()=>q.kind==="directory"?V(q.path):T(q.path),children:[c.jsx("span",{className:"file-glyph","aria-hidden":"true",children:q.kind==="directory"?"▱":"▤"}),c.jsx("span",{className:"file-entry-name",children:q.name}),c.jsx("span",{className:"file-entry-size",children:q.kind==="directory"?"文件夹":Ag(q.size)})]},q.path))}),f?.truncated?c.jsx("p",{className:"library-hint",children:"这里只显示前 500 项。可以进入子文件夹继续查看。"}):null]}),b||p?c.jsxs("article",{className:"file-preview","aria-label":"文件预览",children:[c.jsxs("header",{children:[c.jsxs("div",{children:[c.jsx("strong",{children:p?.name??"正在打开…"}),p?c.jsx("span",{children:Ag(p.size)}):null]}),c.jsxs("div",{className:"library-actions",children:[p?c.jsx("a",{className:"library-button",href:Oc(p.path),download:!0,children:"下载"}):null,c.jsx("button",{className:"library-button",onClick:()=>{L.current?.abort(),v(!1),h(null)},children:"关闭预览"})]})]}),b?c.jsx("p",{className:"library-empty",role:"status",children:"正在读取内容…"}):p?.kind==="text"?c.jsxs(c.Fragment,{children:[c.jsx("pre",{tabIndex:0,children:p.content}),p.truncated?c.jsx("p",{className:"library-hint",children:"预览显示前 512 KB,下载可获取完整内容。"}):null]}):p?.kind==="image"?c.jsx("img",{src:Oc(p.path,!0),alt:p.name,onError:()=>k("图片无法预览,可以下载后打开。")}):c.jsx("div",{className:"library-empty",children:"这个文件暂不支持直接预览,可以下载后打开。"})]}):null]})]})}async function Tf(t={}){const i=new URLSearchParams({archived:t.archived??"false",limit:"50"});return t.query&&i.set("query",t.query),t.cursor&&i.set("cursor",t.cursor),Ue(`/api/v1/sessions?${i}`,{signal:t.signal})}function Tg(t,i="markdown"){return St(`/api/v1/sessions/${encodeURIComponent(t)}/export?format=${i}`)}function sS({onAuthLost:t,onOpen:i,onChanged:l,version:a=0,onDirtyChange:o}){const[f,u]=w.useState(""),[p,h]=w.useState(""),[m,y]=w.useState("false"),[b,v]=w.useState([]),[x,k]=w.useState(null),[_,D]=w.useState(!0),[R,z]=w.useState(!1),[L,G]=w.useState(""),[ae,T]=w.useState(""),[V,$]=w.useState(0),[q,E]=w.useState(""),[B,H]=w.useState(null),Z=w.useRef(null),ee=w.useRef(null),W=w.useRef(null),N=w.useRef(null);w.useEffect(()=>{B?.id&&Z.current?.focus()},[B?.id]),w.useEffect(()=>{B?.error&&ee.current?.focus()},[B?.error]);const X=()=>{H(null),requestAnimationFrame(()=>{W.current?.isConnected?W.current.focus():N.current?.focus()})};w.useEffect(()=>{o?.(!!B||!!q)},[B,q,o]),w.useEffect(()=>()=>o?.(!1),[o]);const pe=w.useRef(null),ye=w.useRef(null),j=w.useRef({onAuthLost:t,onChanged:l,onOpen:i});j.current={onAuthLost:t,onChanged:l,onOpen:i};const O=w.useCallback(te=>{te instanceof Xe&&te.status===401?j.current.onAuthLost():G(te instanceof Error?te.message:"会话操作失败,请重试。")},[]);w.useEffect(()=>{const te=setTimeout(()=>h(f.trim()),200);return()=>clearTimeout(te)},[f]),w.useEffect(()=>{pe.current?.abort();const te=new AbortController;return pe.current=te,D(!0),z(!1),G(""),Tf({query:p,archived:m,signal:te.signal}).then(se=>{te.signal.aborted||(v(se.sessions),k(se.nextCursor))}).catch(se=>{te.signal.aborted||O(se)}).finally(()=>{te.signal.aborted||D(!1)}),()=>te.abort()},[p,m,a,V,O]),w.useEffect(()=>()=>{pe.current?.abort(),ye.current?.abort()},[]);const J=()=>{if(!x||R||_)return;const te=new AbortController;pe.current?.abort(),pe.current=te,z(!0),Tf({query:p,archived:m,cursor:x,signal:te.signal}).then(se=>{te.signal.aborted||(v(we=>{const F=new Set(we.map(Se=>Se.sessionId));return[...we,...se.sessions.filter(Se=>!F.has(Se.sessionId))]}),k(se.nextCursor))}).catch(se=>{te.signal.aborted||O(se)}).finally(()=>{te.signal.aborted||z(!1)})},A=async(te,se,we=!1)=>{if(ye.current)return;const F=new AbortController;ye.current=F,E(te),G(""),T(""),"title"in se&&H(Se=>Se&&{...Se,error:""});try{if(await Ue(`/api/v1/sessions/${encodeURIComponent(te)}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(se),signal:F.signal}),F.signal.aborted)return;"title"in se?(X(),T(se.title?"标题已保存。":"已恢复自动标题。")):T(se.archived?"对话已归档,可以在“已归档”中恢复。":"对话已恢复。"),$(Se=>Se+1),j.current.onChanged?.(),we&&j.current.onOpen(te)}catch(Se){F.signal.aborted||("title"in se&&!(Se instanceof Xe&&Se.status===401)?H(Ne=>Ne?.id===te?{...Ne,error:Se instanceof Error?Se.message:"标题保存失败,请重试。",conflict:Se instanceof Xe&&Se.status===409,unavailable:Se instanceof Xe&&Se.status===404}:Ne):O(Se))}finally{ye.current===F&&(ye.current=null),F.signal.aborted||E("")}},le=async()=>{if(!B||ye.current)return;const te=B.id,se=new AbortController;ye.current=se,E(te),H(we=>we&&{...we,error:""});try{const we=await Ue(`/api/v1/sessions/${encodeURIComponent(te)}`,{signal:se.signal});if(se.signal.aborted)return;H(F=>F?.id===te?{...F,expectedTitle:we.customTitle,reviewedTitle:we.title,conflict:!1,unavailable:!1,error:""}:F),Z.current?.focus()}catch(we){se.signal.aborted||(we instanceof Xe&&we.status===401?O(we):H(F=>F?.id===te?{...F,error:we instanceof Error?we.message:"无法读取最新标题,请重试。",unavailable:we instanceof Xe&&we.status===404}:F))}finally{ye.current===se&&(ye.current=null),se.signal.aborted||E("")}},me=te=>te.archivedAt?void A(te.sessionId,{archived:!1},!0):j.current.onOpen(te.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:()=>$(te=>te+1),children:"刷新"})]}),L?c.jsx("div",{className:"library-error",role:"alert",children:L}):null,ae?c.jsx("p",{className:"library-hint",role:"status",children:ae}):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:N,type:"search",placeholder:"搜索对话标题…",value:f,onChange:te=>u(te.target.value)})]}),c.jsxs("label",{children:[c.jsx("span",{className:"sr-only",children:"对话范围"}),c.jsxs("select",{value:m,onChange:te=>y(te.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:te=>{te.preventDefault(),!q&&!B.conflict&&!B.unavailable&&A(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]}),!_&&!b.some(te=>te.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:Z,className:"library-title-input",value:B.title,maxLength:1024,"aria-describedby":B.error?"session-title-error":void 0,onChange:te=>{const se=te.target.value;H(we=>we&&{...we,title:se})},readOnly:!!q})]}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{type:"submit",className:"library-button primary",disabled:!!q||B.conflict||B.unavailable,children:q?"处理中…":B.reviewedTitle?"确认保存我的标题":"保存标题"}),B.conflict||B.unavailable?c.jsx("button",{type:"button",className:"library-button",disabled:!!q,onClick:()=>{le()},children:"读取最新标题"}):null,c.jsx("button",{type:"button",className:"library-button",disabled:!!q,onClick:X,children:"取消"}),B.expectedTitle?c.jsx("button",{type:"button",className:"library-button",disabled:!!q||B.conflict||B.unavailable,onClick:()=>{A(B.id,{title:"",expectedTitle:B.expectedTitle})},children:"使用自动标题"}):null]})]}):null,c.jsx("div",{className:"session-history-list","aria-busy":_,children:_?c.jsx("p",{className:"library-empty",role:"status",children:"正在读取对话…"}):b.length===0?c.jsx("p",{className:"library-empty",children:p?"没有找到匹配的对话。":m==="true"?"还没有归档的对话。":"还没有保存的对话,开始一条新对话后会显示在这里。"}):b.map(te=>c.jsxs("article",{className:"session-history-row",children:[c.jsxs("div",{className:"session-history-info",children:[c.jsx("button",{className:"session-history-title",onClick:()=>me(te),children:te.title}),te.preview&&te.preview!==te.title?c.jsx("p",{children:te.preview.slice(0,150)}):null,c.jsxs("div",{className:"session-history-meta",children:[c.jsx("span",{children:new Date(te.lastActiveAt||te.startedAt).toLocaleString()}),c.jsxs("span",{children:[te.turnCount," 轮"]}),te.running?c.jsx("span",{children:"正在运行"}):te.archivedAt?c.jsx("span",{children:"已归档"}):null]})]}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button",disabled:!!q||!!B,onClick:se=>{W.current=se.currentTarget,T(""),H({id:te.sessionId,title:te.title,originalTitle:te.title,expectedTitle:te.customTitle})},children:B?.id===te.sessionId?"正在编辑":"重命名"}),c.jsx("button",{className:"library-button",disabled:!!q||te.running,onClick:()=>{A(te.sessionId,{archived:!te.archivedAt})},children:q===te.sessionId?"处理中…":te.archivedAt?"恢复":"归档"}),te.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:Tg(te.sessionId),download:!0,children:"Markdown 文档"}),c.jsx("a",{href:Tg(te.sessionId,"json"),download:!0,children:"完整 JSON 记录"})]})]})]})]},te.sessionId))}),x&&!_?c.jsx("div",{className:"session-load-more",children:c.jsx("button",{className:"library-button",disabled:R,onClick:J,children:R?"读取中…":"加载更多"})}):null]})}var oS=fb();function to(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ks(t){return typeof t=="string"?t:""}function bb(t){return Array.isArray(t)?t.map(to).filter(i=>i!==void 0):[]}function uS(t){return typeof t=="string"?t:bb(t).filter(i=>i.type==="text").map(i=>Ks(i.text)).join("")}function aa(t){return t.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function Lc(t){const i=t.replace(/\\/g,"/").split("/").filter(Boolean).pop()||"附件";return t.includes(".code-shell/attachments/")?i.replace(/^[a-f0-9]{16}-/,""):i}function Bc(t){const i=typeof t=="number"?t:Number(t);return Number.isSafeInteger(i)&&i>=0?i:0}function vb(t,i={}){const l=[],a=h=>/^(?:[a-zA-Z]:[\\/]|[\\/])/.test(h)||!i.cwd?h:`${i.cwd.replace(/[\\/]$/,"")}/${h}`,o=[];let f=uS(t.content);f=f.replace(/<attached-file\s+path="([^"]*)">\s*([\s\S]*?)<\/attached-file>/g,(h,m,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:Lc(aa(m)),path:aa(m),...i.includeAbsolutePaths?{absPath:y.match(/^absolutePath:\s*(.+)$/m)[1].trim()}:{},size:Bc(y.match(/^size:\s*(\d+)\s*$/m)?.[1]),...b?{mime:b}:{}}),""}),f=f.replace(/<attached-directory\s+path="([^"]*)"[^>]*>[\s\S]*?<\/attached-directory>/g,(h,m)=>(l.push({name:`${Lc(aa(m))}/`,path:aa(m),...i.includeAbsolutePaths?{absPath:a(aa(m))}:{},size:0}),"")),f=f.replace(/<attached-image-paths>\s*([\s\S]*?)<\/attached-image-paths>\s*(?:\(上面附带的图片在工作区的真实路径[^\n]*\))?/g,(h,m)=>(o.push(...m.split(`
21
+ `).map(y=>y.trim()).filter(Boolean)),""));const u=bb(t.content).filter(h=>h.type==="image");for(let h=0;h<Math.max(u.length,o.length);h++){const m=to(u[h]?.source),y=Ks(m?.data).replace(/\s/g,"");l.push({name:o[h]?Lc(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)):Bc(m?.byteLength),...typeof m?.media_type=="string"?{mime:m.media_type}:{}})}const p=Array.isArray(t.attachments)?t.attachments.flatMap(h=>{const m=to(h),y=Ks(m?.name)||Ks(m?.originalName);return y?[{name:y,size:Bc(m?.size),...typeof m?.mime=="string"?{mime:m.mime}:{},...typeof m?.path=="string"?{path:m.path}:{}}]:[]}):[];return{text:typeof t.displayText=="string"?t.displayText:f.trim(),attachments:p.length?p:l}}function xb(t){if(t.type!=="session_user_message"&&t.type!=="steer_injected")return t;const i=to(t.transcriptMessage);return i?{...t,...vb(i,{includeAbsolutePaths:!0,...typeof i.cwd=="string"?{cwd:i.cwd}:{}})}:t}function zg(t){return t.replace(/<system-reminder>[\s\S]*?<\/system-reminder>\s*/g,"")}function Zs(){return{items:[],run:"idle",seq:0,liveByAgent:{}}}function sa(t){return t.agentId??""}function Vs(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 cS(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 fS(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 hr(t,i){const l=fS(i);if(!l)return t;const{sessionId:a}=l,o=xb(l.event),f=o.type;let u=t;a&&a!==u.sessionId&&(u={...u,sessionId:a});const p=h=>{const m=u.seq+1;return[`${h}-${m}`,{...u,seq:m}]};switch(f){case"stream_request_start":{const h=sa(o),[m,y]=p("a"),b={kind:"assistant",id:m,text:"",reasoning:"",done:!1,agentId:o.agentId,...typeof o.messageId=="string"?{messageId:o.messageId}:{}};return{...y,items:[...y.items,b],liveByAgent:{...y.liveByAgent,[h]:m},run:"running"}}case"text_delta":{const h=o.text??"",m=sa(o),y=u.liveByAgent[m];if(y&&u.items.find(_=>_.id===y&&_.kind==="assistant"))return{...u,run:"running",items:u.items.map(_=>_.id===y&&_.kind==="assistant"?{..._,text:_.text+h}:_)};const[v,x]=p("a"),k={kind:"assistant",id:v,text:h,reasoning:"",done:!1,agentId:o.agentId};return{...x,items:[...x.items,k],liveByAgent:{...x.liveByAgent,[m]:v},run:"running"}}case"thinking_delta":{const h=o.text??"",m=sa(o),y=u.liveByAgent[m];if(y&&u.items.some(k=>k.id===y&&k.kind==="assistant"))return{...u,run:"running",items:u.items.map(k=>k.id===y&&k.kind==="assistant"?{...k,reasoning:k.reasoning+h}:k)};const[b,v]=p("a"),x={kind:"assistant",id:b,text:"",reasoning:h,done:!1,agentId:o.agentId};return{...v,items:[...v.items,x],liveByAgent:{...v.liveByAgent,[m]:b},run:"running"}}case"tool_use_start":{const h=o.toolCall;if(!h||u.items.some(v=>v.kind==="tool"&&v.id===h.id))return u;const m=u.orphanResults?.[h.id],y={kind:"tool",id:h.id,name:h.toolName,args:h.args,summary:h.summary,done:!!m,result:m?.result,error:m?.error,agentId:o.agentId};let b=u.orphanResults;if(m){const{[h.id]:v,...x}=u.orphanResults;b=Object.keys(x).length>0?x:void 0}return{...u,run:"running",items:[...u.items,y],orphanResults:b}}case"tool_use_args_delta":{const h=o.toolCallId,m=o.args;return!h||!m?u:{...u,items:u.items.map(y=>y.kind==="tool"&&y.id===h?{...y,args:{...y.args??{},...m}}: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:zg(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??"",m=zg(h),y=!!o.isError;let b=-1;for(let k=u.items.length-1;k>=0;k--)if(u.items[k].kind==="tool"&&!u.items[k].done){b=k;break}if(b===-1)return u;const v=u.items.slice(),x=v[b];return v[b]={...x,done:!0,result:m,summary:m||x.summary,error:y},{...u,items:v}}case"tool_summary":{const h=o.summary??"",m=Array.isArray(o.toolCallIds)?o.toolCallIds.filter(_=>typeof _=="string"):[],b=m.length>0?m[m.length-1]:void 0,v=o.agentId;if(b){let _=!1;const D=u.items.map(R=>R.kind!=="tool"||R.id!==b||R.agentId!==v?R:(_=!0,{...R,summary:h}));return _?{...u,items:D}:u}if(v){let _=-1;for(let R=u.items.length-1;R>=0;R--){const z=u.items[R];if(z.kind==="tool"&&z.agentId===v){_=R;break}}if(_===-1)return u;const D=u.items.slice();return D[_]={...D[_],summary:h},{...u,items:D}}let x=-1;for(let _=u.items.length-1;_>=0;_--){const D=u.items[_];if(D.kind==="tool"&&D.agentId===void 0){x=_;break}}if(x===-1)return u;const k=u.items.slice();return k[x]={...k[x],summary:h},{...u,items:k}}case"tombstone":{if(typeof o.messageId!="string")return u;const h=new Set(u.items.filter(m=>m.kind==="assistant"&&m.messageId===o.messageId||m.kind==="tool"&&m.id===o.messageId).map(m=>m.id));return h.size?{...u,items:u.items.filter(m=>!h.has(m.id)),liveByAgent:Object.fromEntries(Object.entries(u.liveByAgent).filter(([,m])=>!h.has(m)))}:u}case"assistant_message":{const h=sa(o);if(!(h in u.liveByAgent))return u;const{[h]:m,...y}=u.liveByAgent,b=u.items.map(v=>v.kind==="assistant"&&!v.done&&(v.agentId??"")===h?{...v,done:!0}:v);return{...u,liveByAgent:y,items:b}}case"turn_complete":{const h=o.reason??"completed",m=sa(o),{[m]:y,...b}=u.liveByAgent,v=u.items.map(x=>x.kind==="assistant"&&!x.done&&(x.agentId??"")===m?{...x,done:!0}:x);return o.agentId?{...u,liveByAgent:b,items:v}:{...u,liveByAgent:b,items:v,run:cS(h)}}case"goal_set":{const h=o.objective??"",m=!!o.paused;return u.goal&&u.goalId===o.goalId&&Vs(u,o)?u:{...u,goal:h?`◎ ${h}${m?" (已暂停)":""}`:"◎ 目标",goalId:o.goalId,goalPaused:m,goalRevision:o.revision}}case"goal_updated":{if(u.goal&&Vs(u,o,!0))return u;const h=o.goalId,m=o.objective??"",y=!!o.paused;return{...u,goal:m?`◎ ${m}${y?" (已暂停)":""}`:u.goal,goalId:h??u.goalId,goalPaused:y,goalRevision:o.revision??u.goalRevision}}case"goal_cleared":return u.goal&&Vs(u,o)?u:{...u,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};case"goal_progress":{if(u.goal&&Vs(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 m=o.round,y=m?`目标 · 第 ${m} 轮 (${h})`:`目标 (${h})`;return{...u,goal:y,goalRevision:o.revision??u.goalRevision}}case"task_update":{const h=o.agentId;if(!h)return u;const m=o.tasks??[],y=m.filter(k=>k.status==="completed").length,b=`任务 ${y}/${m.length}`,v=u.items.findIndex(k=>k.kind==="subagent"&&k.agentId===h),x={kind:"subagent",id:`sub-${h}`,agentId:h,label:b,status:m.length>0&&y===m.length?"completed":"running"};if(v>=0){const k=u.items.slice();return k[v]=x,{...u,items:k}}return{...u,items:[...u.items,x]}}case"agent_start":{const h=o.agentId;if(!h)return u;const m={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,m]}}case"agent_end":{const h=o.agentId;return{...u,items:u.items.map(m=>m.kind==="subagent"&&m.agentId===h?{...m,status:o.error?"error":"completed"}:m)}}case"error":{const[h,m]=p("err");return{...m,run:"error",liveByAgent:{},items:[...m.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,m=Array.isArray(o.attachments)?o.attachments.map(v=>v).filter(v=>!!v&&typeof v.name=="string"&&typeof v.size=="number"&&Number.isFinite(v.size)&&v.size>=0).map(v=>({name:v.name,size:v.size,...typeof v.mime=="string"?{mime:v.mime}:{},...typeof v.path=="string"?{path:v.path}:{}})):void 0;if(h&&u.items.some(v=>v.kind==="user"&&v.clientMessageId===h))return m?.length?{...u,items:u.items.map(v=>v.kind==="user"&&v.clientMessageId===h?{...v,attachments:m.map((x,k)=>{const _=v.attachments?.[k];return _?.name===x.name?{..._,...x}:x})}:v)}:u;const[y,b]=p("u");return{...b,items:[...b.items,{kind:"user",id:y,text:o.text??"",...m?.length?{attachments:m}:{},...h?{clientMessageId:h}:{}}]}}case"assistant_text":{const[h,m]=p("a");return{...m,run:"running",items:[...m.items,{kind:"assistant",id:h,text:o.text??"",reasoning:"",done:!0,agentId:o.agentId}]}}default:return u}}function dS(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 hS="codeshell.uiLanguage";function pS(){try{const t=globalThis.localStorage?.getItem(hS);if(t==="zh"||t==="en")return t}catch{}return"zh"}const mS={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)"}}}},Rg=mS;function Dg(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 gS(t,i){return i?t.replace(/\{(\w+)\}/g,(l,a)=>a in i?String(i[a]):l):t}function yS(t,i,l){const a=Dg(Rg[t],i)??Dg(Rg.zh,i)??i;return gS(a,l)}function bS(t,i){return yS(pS(),t,i)}const vS=["command","file_path","path","url","pattern","query"];function xS(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=bS("mobile.approval.readSourceSummary",{source:o,scope:f,resource:u});else for(const h of vS){const m=t?.[h];if(typeof m=="string"&&m.length>0){a=m;break}}a||(a=JSON.stringify(t??{}));let p;return i==="low"||i==="medium"||i==="high"?p=i:i===void 0||i===""?p="medium":p="high",{summary:a,risk:p}}function gi(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ot(t){return typeof t=="string"?t:""}function zf(t){return Array.isArray(t)?t.map(gi).filter(i=>i!==void 0):[]}function Mg(t){return typeof t=="string"?t:zf(t).filter(i=>i.type==="text").map(i=>Ot(i.text)).join("")}function _g(t){return gi(t.data)??gi(t.message)??t}function SS(t){const i=[],l=new Set,a=new Set,o=new Map;for(const p of t){const h=gi(p);if(!h)continue;const m=_g(h);h.type==="tool_use"&&Ot(m.toolCallId)&&o.set(Ot(m.toolCallId),{name:Ot(m.toolName)||"工具",args:gi(m.args)??{}});for(const y of zf(m.content))y.type==="tool_use"&&Ot(y.id)&&o.set(Ot(y.id),{name:Ot(y.name)||"工具",args:gi(y.input)??{}})}const f=(p,h,m,y)=>{p&&(a.has(p)?i.push({type:"tool_use_args_delta",toolCallId:p,args:m,...y?{agentId:y}:{}}):(a.add(p),i.push({type:"tool_use_start",toolCall:{id:p,toolName:h||"工具",args:m},...y?{agentId:y}:{}})))},u=(p,h,m)=>{if(!p)return;const y=o.get(p);a.has(p)||f(p,y?.name||Ot(h.toolName)||"工具",y?.args??{},m);const b=typeof h.result=="string"?h.result:Mg(h.content??h.contentBlocks),v=Ot(h.error);i.push({type:"tool_result",result:{id:p,result:b||v,...v?{error:v}:{},isError:h.isError===!0||h.is_error===!0||!!v},...m?{agentId:m}:{}})};for(const p of t){const h=gi(p);if(!h)continue;const m=Ot(h.id);if(m&&l.has(m))continue;m&&l.add(m);const y=_g(h),b=Ot(y.agentId)||void 0;switch(typeof h.type=="string"?h.type:typeof y.role=="string"?"message":""){case"message":{const x=zf(y.content);if(y.role==="user"){if(y.injected===!0||y.authority==="agent"||y.authority==="system"||y.authority==="policy")break;const k=vb(y);if(k.text.startsWith("<system-reminder>"))break;(k.text||k.attachments.length)&&i.push({type:"user_message",...k,...typeof y.clientMessageId=="string"?{clientMessageId:y.clientMessageId}:{}});for(const _ of x)_.type==="tool_result"&&u(Ot(_.tool_use_id),_,b)}else if(y.role==="assistant"){const k=Mg(y.content),_=x.filter(D=>D.type==="reasoning").map(D=>Ot(D.reasoningContent)||Ot(D.text)).join("");if(k||_){const D=b?{agentId:b}:{};i.push({type:"stream_request_start",...D}),_&&i.push({type:"thinking_delta",text:_,...D}),k&&i.push({type:"text_delta",text:k,...D}),i.push({type:"assistant_message",...D})}for(const D of x)D.type==="tool_use"&&f(Ot(D.id),Ot(D.name),gi(D.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),gi(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 Sb(t){let i=Zs();for(const l of SS(t))i=hr(i,l);return{...i,run:i.run==="error"?"error":"idle",liveByAgent:{}}}const wS=16*1024*1024;function dr(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 jS(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 Rf(t,i){try{const l=dr(t),a=dr(i);return l.identity===a.identity?Math.sign(l.sequence-a.sequence):void 0}catch{return}}function kS(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=dr(i.from);const o=dr(i.through),f=dr(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,p=t.appliedCursor??i.from;const h=[];for(const y of i.frames){const b=dr(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 v=y.event;if(y.fragment){const x=y.fragment;if(!u){if(x.index!==0||!Number.isSafeInteger(x.total)||x.total<2||x.total>256)throw new Error("Output fragment has no beginning");u={id:x.id,total:x.total,next:0,bytes:0,chunks:[]}}if(x.id!==u.id||x.total!==u.total||x.index!==u.next)throw new Error("Output fragment has a gap");const k=jS(x.data);if(u.bytes+=k.length,u.bytes>wS)throw new Error("Output fragment exceeds its budget");if(u.chunks.push(k),u.next++,u.next===u.total){const _=new Uint8Array(u.bytes);let D=0;for(const R of u.chunks)_.set(R,D),D+=R.length;v=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(_)),u=void 0}}else if(u)throw new Error("Output fragment was interrupted");if(v){if(typeof v!="object"||typeof v.type!="string"||v.outputRecovery==="incomplete")throw new Error("Invalid output event");h.push({...xb(v),outputCursor:y.cursor}),p=y.cursor}a=b}const m=dr(i.next);if(m.identity!==a.identity||m.sequence!==a.sequence||m.offset!==a.offset||(i.frames.at(-1)?.cursor??i.from)!==i.next||i.complete!==(i.next===i.through)||i.complete&&u||!i.complete&&!i.frames.length)throw new Error("Output recovery page did not establish coverage");t.cursor=i.next,t.appliedCursor=p,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}}var ll={},Uc,Og;function CS(){return Og||(Og=1,Uc=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Uc}var qc={},Gi={},Lg;function yr(){if(Lg)return Gi;Lg=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 Gi.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},Gi.getSymbolTotalCodewords=function(a){return i[a]},Gi.getBCHDigit=function(l){let a=0;for(;l!==0;)a++,l>>>=1;return a},Gi.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');t=a},Gi.isKanjiModeEnabled=function(){return typeof t<"u"},Gi.toSJIS=function(a){return t(a)},Gi}var Ic={},Bg;function td(){return Bg||(Bg=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}}})(Ic)),Ic}var Hc,Ug;function ES(){if(Ug)return Hc;Ug=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++}},Hc=t,Hc}var Vc,qg;function NS(){if(qg)return Vc;qg=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]},Vc=t,Vc}var Yc={},Ig;function AS(){return Ig||(Ig=1,(function(t){const i=yr().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,p=[f-7];for(let h=1;h<o-1;h++)p[h]=p[h-1]-u;return p.push(6),p.reverse()},t.getPositions=function(a){const o=[],f=t.getRowColCoords(a),u=f.length;for(let p=0;p<u;p++)for(let h=0;h<u;h++)p===0&&h===0||p===0&&h===u-1||p===u-1&&h===0||o.push([f[p],f[h]]);return o}})(Yc)),Yc}var Gc={},Hg;function TS(){if(Hg)return Gc;Hg=1;const t=yr().getSymbolSize,i=7;return Gc.getPositions=function(a){const o=t(a);return[[0,0],[o-i,0],[0,o-i]]},Gc}var Fc={},Vg;function zS(){return Vg||(Vg=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,p=0,h=0,m=null,y=null;for(let b=0;b<f;b++){p=h=0,m=y=null;for(let v=0;v<f;v++){let x=o.get(b,v);x===m?p++:(p>=5&&(u+=i.N1+(p-5)),m=x,p=1),x=o.get(v,b),x===y?h++:(h>=5&&(u+=i.N1+(h-5)),y=x,h=1)}p>=5&&(u+=i.N1+(p-5)),h>=5&&(u+=i.N1+(h-5))}return u},t.getPenaltyN2=function(o){const f=o.size;let u=0;for(let p=0;p<f-1;p++)for(let h=0;h<f-1;h++){const m=o.get(p,h)+o.get(p,h+1)+o.get(p+1,h)+o.get(p+1,h+1);(m===4||m===0)&&u++}return u*i.N2},t.getPenaltyN3=function(o){const f=o.size;let u=0,p=0,h=0;for(let m=0;m<f;m++){p=h=0;for(let y=0;y<f;y++)p=p<<1&2047|o.get(m,y),y>=10&&(p===1488||p===93)&&u++,h=h<<1&2047|o.get(y,m),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 p=0;p<u;p++)for(let h=0;h<u;h++)f.isReserved(h,p)||f.xor(h,p,l(o,h,p))},t.getBestMask=function(o,f){const u=Object.keys(t.Patterns).length;let p=0,h=1/0;for(let m=0;m<u;m++){f(m),t.applyMask(m,o);const y=t.getPenaltyN1(o)+t.getPenaltyN2(o)+t.getPenaltyN3(o)+t.getPenaltyN4(o);t.applyMask(m,o),y<h&&(h=y,p=m)}return p}})(Fc)),Fc}var Ys={},Yg;function wb(){if(Yg)return Ys;Yg=1;const t=td(),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 Ys.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}},Ys.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}},Ys}var Qc={},oa={},Gg;function RS(){if(Gg)return oa;Gg=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]})(),oa.log=function(a){if(a<1)throw new Error("log("+a+")");return i[a]},oa.exp=function(a){return t[a]},oa.mul=function(a,o){return a===0||o===0?0:t[i[a]+i[o]]},oa}var Fg;function DS(){return Fg||(Fg=1,(function(t){const i=RS();t.mul=function(a,o){const f=new Uint8Array(a.length+o.length-1);for(let u=0;u<a.length;u++)for(let p=0;p<o.length;p++)f[u+p]^=i.mul(a[u],o[p]);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 p=0;for(;p<f.length&&f[p]===0;)p++;f=f.slice(p)}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}})(Qc)),Qc}var $c,Qg;function MS(){if(Qg)return $c;Qg=1;const t=DS();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 p=new Uint8Array(this.degree);return p.set(f,u),p}return f},$c=i,$c}var Xc={},Kc={},Zc={},$g;function jb(){return $g||($g=1,Zc.isValid=function(i){return!isNaN(i)&&i>=1&&i<=40}),Zc}var Kn={},Xg;function kb(){if(Xg)return Kn;Xg=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
+ ]))+`;Kn.KANJI=new RegExp(l,"g"),Kn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Kn.BYTE=new RegExp(a,"g"),Kn.NUMERIC=new RegExp(t,"g"),Kn.ALPHANUMERIC=new RegExp(i,"g");const o=new RegExp("^"+l+"$"),f=new RegExp("^"+t+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Kn.testKanji=function(h){return o.test(h)},Kn.testNumeric=function(h){return f.test(h)},Kn.testAlphanumeric=function(h){return u.test(h)},Kn}var Kg;function br(){return Kg||(Kg=1,(function(t){const i=jb(),l=kb();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}}})(Kc)),Kc}var Zg;function _S(){return Zg||(Zg=1,(function(t){const i=yr(),l=wb(),a=td(),o=br(),f=jb(),u=7973,p=i.getBCHDigit(u);function h(v,x,k){for(let _=1;_<=40;_++)if(x<=t.getCapacity(_,k,v))return _}function m(v,x){return o.getCharCountIndicator(v,x)+4}function y(v,x){let k=0;return v.forEach(function(_){const D=m(_.mode,x);k+=D+_.getBitsLength()}),k}function b(v,x){for(let k=1;k<=40;k++)if(y(v,k)<=t.getCapacity(k,x,o.MIXED))return k}t.from=function(x,k){return f.isValid(x)?parseInt(x,10):k},t.getCapacity=function(x,k,_){if(!f.isValid(x))throw new Error("Invalid QR Code version");typeof _>"u"&&(_=o.BYTE);const D=i.getSymbolTotalCodewords(x),R=l.getTotalCodewordsCount(x,k),z=(D-R)*8;if(_===o.MIXED)return z;const L=z-m(_,x);switch(_){case o.NUMERIC:return Math.floor(L/10*3);case o.ALPHANUMERIC:return Math.floor(L/11*2);case o.KANJI:return Math.floor(L/13);case o.BYTE:default:return Math.floor(L/8)}},t.getBestVersionForData=function(x,k){let _;const D=a.from(k,a.M);if(Array.isArray(x)){if(x.length>1)return b(x,D);if(x.length===0)return 1;_=x[0]}else _=x;return h(_.mode,_.getLength(),D)},t.getEncodedBits=function(x){if(!f.isValid(x)||x<7)throw new Error("Invalid QR Code version");let k=x<<12;for(;i.getBCHDigit(k)-p>=0;)k^=u<<i.getBCHDigit(k)-p;return x<<12|k}})(Xc)),Xc}var Pc={},Pg;function OS(){if(Pg)return Pc;Pg=1;const t=yr(),i=1335,l=21522,a=t.getBCHDigit(i);return Pc.getEncodedBits=function(f,u){const p=f.bit<<3|u;let h=p<<10;for(;t.getBCHDigit(h)-a>=0;)h^=i<<t.getBCHDigit(h)-a;return(p<<10|h)^l},Pc}var Jc={},Wc,Jg;function LS(){if(Jg)return Wc;Jg=1;const t=br();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 p=this.data.length-o;p>0&&(f=this.data.substr(o),u=parseInt(f,10),a.put(u,p*3+1))},Wc=i,Wc}var ef,Wg;function BS(){if(Wg)return ef;Wg=1;const t=br(),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)},ef=l,ef}var tf,ey;function US(){if(ey)return tf;ey=1;const t=br();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)},tf=i,tf}var nf,ty;function qS(){if(ty)return nf;ty=1;const t=br(),i=yr();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)}},nf=l,nf}var rf={exports:{}},ny;function IS(){return ny||(ny=1,(function(t){var i={single_source_shortest_paths:function(l,a,o){var f={},u={};u[a]=0;var p=i.PriorityQueue.make();p.push(a,0);for(var h,m,y,b,v,x,k,_,D;!p.empty();){h=p.pop(),m=h.value,b=h.cost,v=l[m]||{};for(y in v)v.hasOwnProperty(y)&&(x=v[y],k=b+x,_=u[y],D=typeof u[y]>"u",(D||_>k)&&(u[y]=k,p.push(y,k),f[y]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var R=["Could not find a path from ",a," to ",o,"."].join("");throw new Error(R)}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})(rf)),rf.exports}var iy;function HS(){return iy||(iy=1,(function(t){const i=br(),l=LS(),a=BS(),o=US(),f=qS(),u=kb(),p=yr(),h=IS();function m(R){return unescape(encodeURIComponent(R)).length}function y(R,z,L){const G=[];let ae;for(;(ae=R.exec(L))!==null;)G.push({data:ae[0],index:ae.index,mode:z,length:ae[0].length});return G}function b(R){const z=y(u.NUMERIC,i.NUMERIC,R),L=y(u.ALPHANUMERIC,i.ALPHANUMERIC,R);let G,ae;return p.isKanjiModeEnabled()?(G=y(u.BYTE,i.BYTE,R),ae=y(u.KANJI,i.KANJI,R)):(G=y(u.BYTE_KANJI,i.BYTE,R),ae=[]),z.concat(L,G,ae).sort(function(V,$){return V.index-$.index}).map(function(V){return{data:V.data,mode:V.mode,length:V.length}})}function v(R,z){switch(z){case i.NUMERIC:return l.getBitsLength(R);case i.ALPHANUMERIC:return a.getBitsLength(R);case i.KANJI:return f.getBitsLength(R);case i.BYTE:return o.getBitsLength(R)}}function x(R){return R.reduce(function(z,L){const G=z.length-1>=0?z[z.length-1]:null;return G&&G.mode===L.mode?(z[z.length-1].data+=L.data,z):(z.push(L),z)},[])}function k(R){const z=[];for(let L=0;L<R.length;L++){const G=R[L];switch(G.mode){case i.NUMERIC:z.push([G,{data:G.data,mode:i.ALPHANUMERIC,length:G.length},{data:G.data,mode:i.BYTE,length:G.length}]);break;case i.ALPHANUMERIC:z.push([G,{data:G.data,mode:i.BYTE,length:G.length}]);break;case i.KANJI:z.push([G,{data:G.data,mode:i.BYTE,length:m(G.data)}]);break;case i.BYTE:z.push([{data:G.data,mode:i.BYTE,length:m(G.data)}])}}return z}function _(R,z){const L={},G={start:{}};let ae=["start"];for(let T=0;T<R.length;T++){const V=R[T],$=[];for(let q=0;q<V.length;q++){const E=V[q],B=""+T+q;$.push(B),L[B]={node:E,lastCount:0},G[B]={};for(let H=0;H<ae.length;H++){const Z=ae[H];L[Z]&&L[Z].node.mode===E.mode?(G[Z][B]=v(L[Z].lastCount+E.length,E.mode)-v(L[Z].lastCount,E.mode),L[Z].lastCount+=E.length):(L[Z]&&(L[Z].lastCount=E.length),G[Z][B]=v(E.length,E.mode)+4+i.getCharCountIndicator(E.mode,z))}}ae=$}for(let T=0;T<ae.length;T++)G[ae[T]].end=0;return{map:G,table:L}}function D(R,z){let L;const G=i.getBestModeForData(R);if(L=i.from(z,G),L!==i.BYTE&&L.bit<G.bit)throw new Error('"'+R+'" cannot be encoded with mode '+i.toString(L)+`.
24
+ Suggested mode is: `+i.toString(G));switch(L===i.KANJI&&!p.isKanjiModeEnabled()&&(L=i.BYTE),L){case i.NUMERIC:return new l(R);case i.ALPHANUMERIC:return new a(R);case i.KANJI:return new f(R);case i.BYTE:return new o(R)}}t.fromArray=function(z){return z.reduce(function(L,G){return typeof G=="string"?L.push(D(G,null)):G.data&&L.push(D(G.data,G.mode)),L},[])},t.fromString=function(z,L){const G=b(z,p.isKanjiModeEnabled()),ae=k(G),T=_(ae,L),V=h.find_path(T.map,"start","end"),$=[];for(let q=1;q<V.length-1;q++)$.push(T.table[V[q]].node);return t.fromArray(x($))},t.rawSplit=function(z){return t.fromArray(b(z,p.isKanjiModeEnabled()))}})(Jc)),Jc}var ry;function VS(){if(ry)return qc;ry=1;const t=yr(),i=td(),l=ES(),a=NS(),o=AS(),f=TS(),u=zS(),p=wb(),h=MS(),m=_S(),y=OS(),b=br(),v=HS();function x(T,V){const $=T.size,q=f.getPositions(V);for(let E=0;E<q.length;E++){const B=q[E][0],H=q[E][1];for(let Z=-1;Z<=7;Z++)if(!(B+Z<=-1||$<=B+Z))for(let ee=-1;ee<=7;ee++)H+ee<=-1||$<=H+ee||(Z>=0&&Z<=6&&(ee===0||ee===6)||ee>=0&&ee<=6&&(Z===0||Z===6)||Z>=2&&Z<=4&&ee>=2&&ee<=4?T.set(B+Z,H+ee,!0,!0):T.set(B+Z,H+ee,!1,!0))}}function k(T){const V=T.size;for(let $=8;$<V-8;$++){const q=$%2===0;T.set($,6,q,!0),T.set(6,$,q,!0)}}function _(T,V){const $=o.getPositions(V);for(let q=0;q<$.length;q++){const E=$[q][0],B=$[q][1];for(let H=-2;H<=2;H++)for(let Z=-2;Z<=2;Z++)H===-2||H===2||Z===-2||Z===2||H===0&&Z===0?T.set(E+H,B+Z,!0,!0):T.set(E+H,B+Z,!1,!0)}}function D(T,V){const $=T.size,q=m.getEncodedBits(V);let E,B,H;for(let Z=0;Z<18;Z++)E=Math.floor(Z/3),B=Z%3+$-8-3,H=(q>>Z&1)===1,T.set(E,B,H,!0),T.set(B,E,H,!0)}function R(T,V,$){const q=T.size,E=y.getEncodedBits(V,$);let B,H;for(B=0;B<15;B++)H=(E>>B&1)===1,B<6?T.set(B,8,H,!0):B<8?T.set(B+1,8,H,!0):T.set(q-15+B,8,H,!0),B<8?T.set(8,q-B-1,H,!0):B<9?T.set(8,15-B-1+1,H,!0):T.set(8,15-B-1,H,!0);T.set(q-8,8,1,!0)}function z(T,V){const $=T.size;let q=-1,E=$-1,B=7,H=0;for(let Z=$-1;Z>0;Z-=2)for(Z===6&&Z--;;){for(let ee=0;ee<2;ee++)if(!T.isReserved(E,Z-ee)){let W=!1;H<V.length&&(W=(V[H]>>>B&1)===1),T.set(E,Z-ee,W),B--,B===-1&&(H++,B=7)}if(E+=q,E<0||$<=E){E-=q,q=-q;break}}}function L(T,V,$){const q=new l;$.forEach(function(ee){q.put(ee.mode.bit,4),q.put(ee.getLength(),b.getCharCountIndicator(ee.mode,T)),ee.write(q)});const E=t.getSymbolTotalCodewords(T),B=p.getTotalCodewordsCount(T,V),H=(E-B)*8;for(q.getLengthInBits()+4<=H&&q.put(0,4);q.getLengthInBits()%8!==0;)q.putBit(0);const Z=(H-q.getLengthInBits())/8;for(let ee=0;ee<Z;ee++)q.put(ee%2?17:236,8);return G(q,T,V)}function G(T,V,$){const q=t.getSymbolTotalCodewords(V),E=p.getTotalCodewordsCount(V,$),B=q-E,H=p.getBlocksCount(V,$),Z=q%H,ee=H-Z,W=Math.floor(q/H),N=Math.floor(B/H),X=N+1,pe=W-N,ye=new h(pe);let j=0;const O=new Array(H),J=new Array(H);let A=0;const le=new Uint8Array(T.buffer);for(let F=0;F<H;F++){const Se=F<ee?N:X;O[F]=le.slice(j,j+Se),J[F]=ye.encode(O[F]),j+=Se,A=Math.max(A,Se)}const me=new Uint8Array(q);let te=0,se,we;for(se=0;se<A;se++)for(we=0;we<H;we++)se<O[we].length&&(me[te++]=O[we][se]);for(se=0;se<pe;se++)for(we=0;we<H;we++)me[te++]=J[we][se];return me}function ae(T,V,$,q){let E;if(Array.isArray(T))E=v.fromArray(T);else if(typeof T=="string"){let W=V;if(!W){const N=v.rawSplit(T);W=m.getBestVersionForData(N,$)}E=v.fromString(T,W||40)}else throw new Error("Invalid data");const B=m.getBestVersionForData(E,$);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 H=L(V,$,E),Z=t.getSymbolSize(V),ee=new a(Z);return x(ee,V),k(ee),_(ee,V),R(ee,$,0),V>=7&&D(ee,V),z(ee,H),isNaN(q)&&(q=u.getBestMask(ee,R.bind(null,ee,$))),u.applyMask(q,ee),R(ee,$,q),{modules:ee,version:V,errorCorrectionLevel:$,maskPattern:q,segments:E}}return qc.create=function(V,$){if(typeof V>"u"||V==="")throw new Error("No input text");let q=i.M,E,B;return typeof $<"u"&&(q=i.from($.errorCorrectionLevel,i.M),E=m.from($.version),B=u.from($.maskPattern),$.toSJISFunc&&t.setToSJISFunction($.toSJISFunc)),ae(V,E,q,B)},qc}var lf={},af={},ly;function Cb(){return ly||(ly=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,p=o.modules.data,h=t.getScale(u,f),m=Math.floor((u+f.margin*2)*h),y=f.margin*h,b=[f.color.light,f.color.dark];for(let v=0;v<m;v++)for(let x=0;x<m;x++){let k=(v*m+x)*4,_=f.color.light;if(v>=y&&x>=y&&v<m-y&&x<m-y){const D=Math.floor((v-y)/h),R=Math.floor((x-y)/h);_=b[p[D*u+R]?1:0]}a[k++]=_.r,a[k++]=_.g,a[k++]=_.b,a[k]=_.a}}})(af)),af}var ay;function YS(){return ay||(ay=1,(function(t){const i=Cb();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,p){let h=p,m=u;typeof h>"u"&&(!u||!u.getContext)&&(h=u,u=void 0),u||(m=a()),h=i.getOptions(h);const y=i.getImageWidth(f.modules.size,h),b=m.getContext("2d"),v=b.createImageData(y,y);return i.qrToImageData(v.data,f,h),l(b,m,y),b.putImageData(v,0,0),m},t.renderToDataURL=function(f,u,p){let h=p;typeof h>"u"&&(!u||!u.getContext)&&(h=u,u=void 0),h||(h={});const m=t.render(f,u,h),y=h.type||"image/png",b=h.rendererOpts||{};return m.toDataURL(y,b.quality)}})(lf)),lf}var sf={},sy;function GS(){if(sy)return sf;sy=1;const t=Cb();function i(o,f){const u=o.a/255,p=f+'="'+o.hex+'"';return u<1?p+" "+f+'-opacity="'+u.toFixed(2).slice(1)+'"':p}function l(o,f,u){let p=o+f;return typeof u<"u"&&(p+=" "+u),p}function a(o,f,u){let p="",h=0,m=!1,y=0;for(let b=0;b<o.length;b++){const v=Math.floor(b%f),x=Math.floor(b/f);!v&&!m&&(m=!0),o[b]?(y++,b>0&&v>0&&o[b-1]||(p+=m?l("M",v+u,.5+x+u):l("m",h,0),h=0,m=!1),v+1<f&&o[b+1]||(p+=l("h",y),y=0)):h++}return p}return sf.render=function(f,u,p){const h=t.getOptions(u),m=f.modules.size,y=f.modules.data,b=m+h.margin*2,v=h.color.light.a?"<path "+i(h.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",x="<path "+i(h.color.dark,"stroke")+' d="'+a(y,m,h.margin)+'"/>',k='viewBox="0 0 '+b+" "+b+'"',D='<svg xmlns="http://www.w3.org/2000/svg" '+(h.width?'width="'+h.width+'" height="'+h.width+'" ':"")+k+' shape-rendering="crispEdges">'+v+x+`</svg>
28
+ `;return typeof p=="function"&&p(null,D),D},sf}var oy;function FS(){if(oy)return ll;oy=1;const t=CS(),i=VS(),l=YS(),a=GS();function o(f,u,p,h,m){const y=[].slice.call(arguments,1),b=y.length,v=typeof y[b-1]=="function";if(!v&&!t())throw new Error("Callback required as last argument");if(v){if(b<2)throw new Error("Too few arguments provided");b===2?(m=p,p=u,u=h=void 0):b===3&&(u.getContext&&typeof m>"u"?(m=h,h=void 0):(m=h,h=p,p=u,u=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(p=u,u=h=void 0):b===2&&!u.getContext&&(h=p,p=u,u=void 0),new Promise(function(x,k){try{const _=i.create(p,h);x(f(_,u,h))}catch(_){k(_)}})}try{const x=i.create(p,h);m(null,f(x,u,h))}catch(x){m(x)}}return ll.create=i.create,ll.toCanvas=o.bind(null,l.render),ll.toDataURL=o.bind(null,l.renderToDataURL),ll.toString=o.bind(null,function(f,u,p){return a.render(f,p)}),ll}var QS=FS();const $S=ao(QS),XS={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 KS(t){const i={...XS,...t.labels},l=bi(t.authorization),[a,o]=w.useState({}),[f,u]=w.useState({}),[p,h]=w.useState(),[m,y]=w.useState(!1),[b,v]=w.useState(Date.now()),x=Math.min(t.authorization.expiresAt?Date.parse(t.authorization.expiresAt):1/0,l?Date.parse(l.expiresAt):1/0),k=l?.kind==="qr-code"&&l.qr?Date.parse(l.qr.challengeExpiresAt):1/0,_=l?.kind==="qr-code"&&l.phase!=="expired"?l.qr?.payload:void 0;if(w.useEffect(()=>{o({}),u({})},[t.authorization.id,l?.id]),w.useEffect(()=>{v(Date.now());const T=[x,k].filter(V=>Number.isFinite(V)&&V>Date.now()).map(V=>setTimeout(()=>v(Date.now()),V-Date.now()+1));return()=>{for(const V of T)clearTimeout(V)}},[x,k]),w.useEffect(()=>{let T=!0;if(h(void 0),y(!1),!_||_.length>4096||k<=Date.now()){_&&_.length>4096&&y(!0);return}return $S.toDataURL(_,{width:220,margin:2,errorCorrectionLevel:"M"}).then(V=>{T&&h(V)}).catch(()=>{T&&y(!0)}),()=>{T=!1}},[_,k]),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(x)||x<=b)return c.jsx("p",{className:"link-authorization-status",role:"status",children:i.expired});const D=!!t.busy,R=(T,V)=>t.onRespond({stepId:l.id,operation:T,...V?{input:V}:{}}),z=T=>{if(t.canOpenUrl===!1)return null;const V=W0(T);return V?c.jsxs("button",{type:"button",disabled:D,onClick:()=>t.onOpenUrl(V),children:[i.openPage," ↗"]}):c.jsx("p",{role:"alert",children:i.invalidUrl})},L=c.jsxs("p",{className:"link-authorization-expires",children:[i.expiresAt," ",new Date(x).toLocaleTimeString()]}),G=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,ae=()=>{switch(l.kind){case"redirect":return c.jsxs("div",{className:"link-authorization-step",role:"status",children:[c.jsx("p",{children:i.waitingBrowser}),z(l.authorizationUrl),L]});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}),z(l.verificationUriComplete??l.verificationUri)]}),L]});case"qr-code":{const T=l.phase==="expired"||k<=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&&p&&c.jsx("img",{width:220,height:220,src:p,alt:i.qrAlt}),!T&&m&&c.jsx("p",{role:"alert",children:i.qrError}),!T&&l.qr?.instructions.map((V,$)=>c.jsx("p",{children:V},$)),l.canRefresh&&c.jsx("button",{type:"button",disabled:D,onClick:()=>R("refresh-qr"),children:i.refreshQr}),L]})}case"credential-input":return c.jsxs("form",{className:"link-authorization-step link-authorization-fields",onSubmit:T=>{if(T.preventDefault(),D)return;const V={};for(const $ of l.fields)V[$.id]=a[$.id]??"";o({}),R("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:D,onChange:V=>o($=>({...$,[T.id]:V.target.value}))})]},T.id)),c.jsx("button",{type:"submit",disabled:D||l.fields.some(T=>T.required&&!a[T.id]?.trim()),children:i.submit}),L]});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:D,onClick:()=>R("detect-session"),children:i.detectSession}),!l.session.authenticated&&l.session.canLogin&&c.jsx("button",{type:"button",disabled:D,onClick:()=>R("login-session"),children:i.loginSession}),l.session.authenticated&&c.jsx("button",{type:"button",disabled:D,onClick:()=>R("bind-session"),children:i.bindSession})]}),L]});case"consent":{const T=f.permissions??l.permissions.filter(q=>q.required).map(q=>q.id),V=(q,E,B,H)=>u(Z=>({...Z,[q]:B?[...new Set([...H,E])]:H.filter(ee=>ee!==E)})),$=l.resourceGroups.some(q=>{const E=(f[q.id]??[]).length;return E<(q.minSelected??0)||E>(q.maxSelected??1/0)||q.truncated});return c.jsxs("form",{className:"link-authorization-step link-authorization-consent",onSubmit:q=>{q.preventDefault(),!D&&!$&&R("confirm",{...f,permissions:T})},children:[c.jsx("p",{children:c.jsx("strong",{children:l.account.label})}),c.jsx("div",{children:l.permissions.map(q=>c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:q.required||T.includes(q.id),disabled:D||q.required,onChange:E=>V("permissions",q.id,E.target.checked,T)}),q.label,q.description&&c.jsx("small",{children:q.description})]},q.id))}),l.resourceGroups.map(q=>c.jsxs("fieldset",{children:[c.jsx("legend",{children:q.label}),q.items.map(E=>c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:(f[q.id]??[]).includes(E.id),disabled:D,onChange:B=>V(q.id,E.id,B.target.checked,f[q.id]??[])}),E.label,E.description&&c.jsx("small",{children:E.description})]},E.id)),q.truncated&&c.jsx("p",{children:i.resourcesTruncated})]},q.id)),c.jsx("button",{type:"submit",disabled:D||$,children:i.confirm}),L]})}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:[G,ae()]})}const Hn="/api/v1/links",ZS={connected:"已连接",expired:"授权已过期",invalid:"需要重新连接",unavailable:"凭据不可用"};function al(t){try{const i=new URL(t??"");return i.protocol==="https:"&&!i.username&&!i.password?i.href:void 0}catch{return}}function PS({onAuthLost:t,onDirtyChange:i,hostLabel:l="服务端",configurationVersion:a=0}){const[o,f]=w.useState(),[u,p]=w.useState(),[h,m]=w.useState(""),[y,b]=w.useState(""),[v,x]=w.useState(""),[k,_]=w.useState(!0),[D,R]=w.useState(!1),[z,L]=w.useState(),[G,ae]=w.useState(),[T,V]=w.useState(),[$,q]=w.useState(),E=w.useRef(new Map),B=w.useRef(new Set),[H,Z]=w.useState(),ee=w.useMemo(()=>new n1({begin:async(M,K)=>{const ge=Js(),{workspace:be,projectId:Ee}=ge,Le=await Ue(St(`${Hn}/authorizations`,be,Ee),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M,authModeId:K})},ge);return E.current.set(Le.id,{target:St(`${Hn}/authorizations/${encodeURIComponent(Le.id)}`,be,Ee),scope:ge}),Le},status:M=>{const K=E.current.get(M);return Ue(K.target,{},K.scope)},respond:(M,K)=>{const ge=E.current.get(M),be=new URL(ge.target,window.location.origin);return be.pathname+="/responses",Ue(be.pathname+be.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(K)},ge.scope)},cancel:async M=>{if(B.current.has(M))return;const K=E.current.get(M);K&&(await Ue(K.target,{method:"DELETE",keepalive:!0},K.scope),E.current.delete(M))}}),[]),W=w.useSyncExternalStore(ee.subscribe,ee.getSnapshot),N=o?.capabilities.authorizationSteps===1&&!!u?.provider.authModes,X=N&&W.authorization?.state==="pending",[pe,ye]=w.useState(0),j=w.useRef(!1),O=w.useRef(0),J=w.useRef(null),A=w.useRef(void 0),le=w.useRef(void 0),me=w.useRef(void 0),te=w.useRef(void 0),se=w.useRef({onAuthLost:t,onDirtyChange:i});se.current={onAuthLost:t,onDirtyChange:i};const we=D||W.busy||X||T?.state==="pending"||!!(u&&(u.token||u.label!==(u.original?.label??u.provider.displayName))),F=w.useCallback(M=>{M instanceof Xe&&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?.(we)},[we]),w.useEffect(()=>{j.current=!0;const M=++O.current;return()=>{j.current=!1,se.current.onDirtyChange?.(!1),A.current?.abort(),queueMicrotask(()=>{O.current===M&&ee.dispose()}),le.current&&Ue(le.current,{method:"DELETE",keepalive:!0},me.current).catch(()=>{})}},[ee]),w.useEffect(()=>{const M=new AbortController;return te.current=M,_(!0),Ue(Hn,{signal:M.signal}).then(K=>{M.signal.aborted||f(K)}).catch(K=>{M.signal.aborted||F(K)}).finally(()=>{M.signal.aborted||_(!1)}),()=>M.abort()},[pe,a,F]),w.useEffect(()=>{N&&(W.error&&F(W.error),W.authorization?.state==="connected"&&W.authorization.connection&&(p(void 0),x("授权完成,连接已保存。"),ye(M=>M+1)))},[N,W.authorization,W.error,F]),w.useEffect(()=>{if(!o?.remoteCleanupPending)return;const M=setInterval(()=>ye(K=>K+1),3e4);return()=>clearInterval(M)},[o?.remoteCleanupPending]),w.useEffect(()=>{if(T?.state!=="pending"||!le.current)return;const M=le.current,K=me.current,ge=new AbortController;let be;const Ee=async()=>{try{const Le=await Ue(M,{signal:ge.signal},K);if(ge.signal.aborted||le.current!==M)return;V(Le),Le.state==="connected"?(le.current=void 0,p(void 0),x("授权完成,连接已保存。"),ye(Ke=>Ke+1)):Le.state!=="pending"?(le.current=void 0,b(Le.state==="cancelled"?"授权已取消。":"授权未完成或已过期,请重新开始。")):be=setTimeout(()=>{Ee()},2e3)}catch(Le){if(ge.signal.aborted||le.current!==M)return;F(Le),Le instanceof Xe&&[401,404].includes(Le.status)?(le.current=void 0,V(Ke=>Ke?{...Ke,state:"failed"}:void 0)):be=setTimeout(()=>{Ee()},4e3)}};return be=setTimeout(()=>{Ee()},1e3),()=>{ge.abort(),clearTimeout(be)}},[T?.id,T?.state,F]);async function Se(M,K){if(A.current)return;const ge=new AbortController;A.current=ge,te.current?.abort(),R(!0),_(!1),b(""),x("");try{const be=await M(ge.signal);j.current&&!ge.signal.aborted&&K(be)}catch(be){j.current&&!ge.signal.aborted&&(F(be),be instanceof Xe&&[409,503].includes(be.status)&&ye(Ee=>Ee+1))}finally{A.current===ge&&(A.current=void 0),j.current&&R(!1)}}function Ne(M,K,ge,be,Ee){return Ue(M,{method:K,headers:{"Content-Type":"application/json"},body:JSON.stringify(ge),signal:be},Ee)}function Te(){return{providerId:u.provider.id,methodId:u.methodId,label:u.label.trim(),expectedRevision:u.original?.revision??null,...u.original?{connectionId:u.original.id}:{}}}function Ge(){p(void 0),ae(void 0),x("连接已保存。"),ye(M=>M+1)}function et(M,K){if(D||W.busy||X||T?.state==="pending"||we&&!window.confirm("放弃当前未保存的连接修改?"))return;ee.reset();const ge=K?Nc(M,K.methodId):Nc(M),be=K?M.connectionMethods.find(Le=>Le.id===K.methodId):M.connectionMethods.find(Le=>Le.id===ge?.methodId)??M.connectionMethods.find(Le=>Le.executionRuntime==="local"&&Le.availability==="available");if(!be){b("当前环境未提供此连接的授权方式,请检查服务器连接设置。");return}const Ee={provider:M,original:K,methodId:be.id,label:K?.label??M.displayName,token:""};p(Ee),ae(void 0),V(void 0),q(ge?.id),b(""),x(""),!K&&o?.capabilities.authorizationSteps===1&&ge&&dt(Ee,ge)}async function dt(M,K){if(!K.available||!M.label.trim()||ee.getSnapshot().authorization?.state==="pending"&&(await ee.cancel(),ee.getSnapshot().authorization?.state==="pending"))return;b(""),q(K.id),p({...M,methodId:K.methodId});const ge={workspace:Ws()??"",projectId:ba()},be=await ee.begin({providerId:M.provider.id,methodId:K.methodId,label:M.label.trim(),expectedRevision:M.original?.revision??null,...M.original?{connectionId:M.original.id}:{}},K.id);if(!(be?.state!=="pending"||bi(be)?.kind!=="redirect"))try{if(o?.capabilities.browserHandoff===1){const Ke=E.current.get(be.id),bt=new URL(Ke.target,window.location.origin);bt.pathname+="/browser";const mt=await Ue(bt.pathname+bt.search,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},Ke.scope),lt=new URL(mt.launchUrl);if(lt.origin!==window.location.origin||lt.pathname!=="/link/authorize"||lt.username||lt.password||lt.hash||lt.searchParams.size!==1||!/^[A-Za-z0-9_-]{43}$/.test(lt.searchParams.get("ticket")??""))throw new Error("授权浏览器入口无效,请重新连接。");ee.getSnapshot().authorization?.id===be.id&&ee.getSnapshot().authorization?.state==="pending"&&Z({id:be.id,url:lt.href});return}const Ee=o?.remoteServer?.issuer;if(!Ee)throw new Error("当前 Host 尚未配置授权服务。");const Le=l1(be,Ee,ge);B.current.add(be.id),oS.flushSync(()=>{p(void 0),se.current.onDirtyChange?.(!1)}),window.location.assign(Le)}catch(Ee){await ee.cancel(),F(Ee)}}async function Fe(){if(X){await ee.cancel(),ee.getSnapshot().authorization?.state==="cancelled"&&x("授权已取消。");return}if(!le.current)return;const M=le.current,K=me.current;await Se(ge=>Ue(M,{method:"DELETE",signal:ge},K),()=>{le.current=void 0,V(void 0),x("授权已取消。")})}function Ct(){N?ee.cancel().then(()=>{ee.getSnapshot().authorization?.state!=="pending"&&p(void 0)}):!Ve&&(!we||window.confirm("放弃未保存的连接修改?"))&&p(void 0)}function ht(M,K=Js()){if(N&&ee.getSnapshot().authorization?.state==="pending"&&u?.original?.id===M.id){ee.cancel().then(()=>{ee.getSnapshot().authorization?.state!=="pending"&&ht(M,K)});return}const ge=u?.original?.id===M.id&&T?.state==="pending"?le.current:void 0,be=St(`${Hn}/connections/${encodeURIComponent(M.id)}`,K.workspace,K.projectId),Ee=me.current;Se(async Le=>{if(ge){try{await Ue(ge,{method:"DELETE",signal:Le},Ee)}catch(Ke){if(!(Ke instanceof Xe&&Ke.status===404))throw Ke}j.current&&!Le.aborted&&le.current===ge&&(le.current=void 0,V(void 0))}return Ne(be,"DELETE",{expectedRevision:M.revision},Le,K)},()=>{u?.original?.id===M.id&&p(void 0),L(void 0),ye(Le=>Le+1),x("连接已断开。")})}const qe=u?.provider.connectionMethods.find(M=>M.id===u.methodId),pt=T?.state==="pending",Ve=D||W.busy||pt||X,tt=h.trim().toLowerCase(),zt=(o?.providers??[]).filter(M=>(o?.capabilities.authorizationSteps!==1||M.authModes?.some(K=>K.available))&&`${M.displayName} ${M.description.zh}`.toLowerCase().includes(tt)),rt=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),yt=u&&o&&(u.original?rt?.revision!==u.original.revision:!!rt);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(""),ye(M=>M+1)},disabled:D||k,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}),v&&c.jsx("p",{className:"links-notice",role:"status",children:v}),k&&!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 K=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:[K?.displayName??M.providerId," ·"," ",M.account?.label??M.account?.id??"已授权账号"]}),c.jsx("span",{className:`links-state ${M.status==="connected"?"ready":""}`,children:ZS[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:Ve||!K,onClick:()=>K&&et(K,M),children:"管理连接"}),c.jsx("button",{disabled:D,onClick:()=>L(M),children:"断开"})]}):c.jsx("small",{children:"项目配置管理"})})]},M.id)})}),z&&c.jsxs("div",{className:"links-confirm",role:"alertdialog","aria-label":"断开连接",children:[c.jsxs("p",{children:["断开「",z.label,"」后,后续任务将无法使用这个连接,正在执行的请求会尝试停止。"]}),c.jsx("button",{disabled:D,onClick:()=>ht(z),children:"确认断开"}),c.jsx("button",{disabled:D,onClick:()=>L(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(),Ct()),M.key!=="Tab")return;const K=J.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), a[href], summary");if(!K?.length)return;const ge=K[0],be=K[K.length-1];M.shiftKey&&document.activeElement===ge?(M.preventDefault(),be.focus()):!M.shiftKey&&document.activeElement===be&&(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:!N&&Ve,onClick:Ct,children:"关闭"})]}),c.jsxs("label",{children:["连接名称",c.jsx("input",{maxLength:100,value:u.label,disabled:Ve,onChange:M=>p({...u,label:M.target.value})})]}),yt&&c.jsxs("div",{className:"links-conflict",role:"alert",children:[c.jsx("p",{children:"这个连接已在其他设备创建、修改或删除。你的输入仍然保留,请先载入最新版本。"}),c.jsx("button",{disabled:Ve,onClick:()=>p({...u,original:rt||void 0}),children:"载入最新版本,保留输入"})]}),N?c.jsxs("div",{className:"links-authorization",children:[c.jsx("p",{className:"links-muted",children:qe.executionRuntime==="server"?"由 Link 服务保存授权并访问已选择的资源。":`连接保存到当前项目所属的${l}。`}),W.authorization?c.jsx(KS,{authorization:W.authorization,busy:W.busy||!!yt||o?.capabilities.browserHandoff===1&&bi(W.authorization)?.kind==="redirect"&&H?.id!==W.authorization.id,onRespond:M=>{ee.respond(M)},onOpenUrl:M=>{const ge=o?.capabilities.browserHandoff===1&&bi(W.authorization)?.kind==="redirect"?H&&H.id===W.authorization?.id?H.url:void 0:M;ge&&window.open(ge,"_blank","noopener,noreferrer")},onCopy:M=>{navigator.clipboard?.writeText(M).catch(F)}}):c.jsx("button",{disabled:W.busy||!!yt||!u.label.trim(),onClick:()=>{const M=u.provider.authModes?.find(K=>K.id===$&&K.available)??Nc(u.provider,u.methodId);M&&dt(u,M)},children:W.busy?"正在连接…":u.original?"重新连接":"开始连接"}),c.jsxs("div",{className:"links-actions",children:[X&&c.jsx("button",{disabled:W.busy,onClick:()=>{Fe()},children:"取消授权"}),W.authorization&&W.authorization.state!=="pending"&&c.jsx("button",{disabled:W.busy||!!yt||!u.label.trim(),onClick:()=>{const M=u.provider.authModes?.find(K=>K.id===$&&K.available);M&&dt(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:W.busy||!M.available||!!yt||!u.label.trim(),title:M.unavailableReason,onClick:()=>{dt(u,M)},children:[M.label,M.id===$?" · 当前":""]},M.id))})]}),u.original&&c.jsx("button",{disabled:Ve||!!yt||!u.label.trim(),onClick:()=>{Se(M=>Ne(`${Hn}/connections/${encodeURIComponent(u.original.id)}`,"PATCH",{label:u.label.trim(),expectedRevision:u.original.revision},M),Ge)},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:Ve||!u.label.trim()||!!yt,onClick:()=>{const M=Ws()??"",K=ba(),ge={workspace:M,projectId:K},be=St(`${Hn}/authorizations/device`,M,K);Se(Ee=>Ne(be,"POST",Te(),Ee,ge),Ee=>{le.current=St(`${Hn}/authorizations/${encodeURIComponent(Ee.id)}`,M,K),me.current=ge,V(Ee)})},children:"开始授权"}):c.jsxs("p",{className:"links-muted",children:["这台",l,"尚未配置此服务的浏览器授权,可使用下面的连接方式。"]}),pt&&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:al(T.prompt.verificationUriComplete??T.prompt.verificationUri)&&c.jsx("a",{href:al(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:D,onClick:()=>{Fe()},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:Ve,onClick:()=>{Se(M=>Ue(`${Hn}/providers/${encodeURIComponent(u.provider.id)}/cli`,{signal:M}),ae)},children:"检查登录状态"}),G&&c.jsx("p",{role:"status",children:G.authenticated?`已登录${G.account?`:${G.account}`:""}`:G.installed?"已安装,尚未登录。请在运行服务的机器上登录。":"尚未安装。"}),G?.authenticated&&c.jsx("button",{disabled:Ve||!u.label.trim()||!!yt,onClick:()=>{Se(M=>Ne(`${Hn}/connections/cli`,"POST",Te(),M),Ge)},children:"绑定这个登录"})]}),qe.authKind==="token"&&c.jsxs("form",{className:"links-auth-option",onSubmit:M=>{M.preventDefault(),!(Ve||yt)&&Se(K=>u.original&&!u.token.trim()?Ne(`${Hn}/connections/${encodeURIComponent(u.original.id)}`,"PATCH",{label:u.label.trim(),expectedRevision:u.original.revision},K):Ne(`${Hn}/connections/token`,"POST",{...Te(),token:u.token.trim()},K),Ge)},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:[al(qe.authGuide.createCredentialUrl)&&c.jsx("a",{href:al(qe.authGuide.createCredentialUrl),target:"_blank",rel:"noreferrer",children:"创建凭据 ↗"}),al(qe.authGuide.docsUrl)&&c.jsx("a",{href:al(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,K)=>c.jsx("li",{children:M.zh},K))})]})]}),c.jsxs("label",{children:[qe.tokenLabel??u.provider.tokenLabel,c.jsx("input",{type:"password",autoComplete:"off",value:u.token,disabled:Ve,placeholder:u.original?"留空保留当前授权,仅修改名称":qe.tokenPlaceholder??u.provider.tokenPlaceholder,onChange:M=>p({...u,token:M.target.value}),required:!u.original,maxLength:16384})]}),c.jsx("button",{type:"submit",className:"send",disabled:Ve||!!yt||!u.label.trim(),children:D?"正在验证并保存…":u.token.trim()||!u.original?"验证并保存":"保存名称"})]})]}),c.jsxs("details",{children:[c.jsxs("summary",{children:[N?"服务支持的操作":"可用操作","(",u.provider.actions.length,")"]}),N&&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=>m(M.target.value)})]}),c.jsx("div",{className:"links-providers",children:zt.map(M=>{const K=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:Ve||o?.capabilities.authorizationSteps!==1&&!!(K&&!K.editable),onClick:()=>et(M,o?.capabilities.authorizationSteps===1?void 0:K),children:o?.capabilities.authorizationSteps===1?"添加连接":K?K.editable?"管理连接":"项目配置管理":"添加连接"})]},M.id)})}),o&&zt.length===0&&c.jsx("p",{className:"links-muted",children:"没有匹配的服务。"})]})}const of="/api/v1/panels",uy="https://github.com/cjhyy/codeshell-panel-apps.git",cy={"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 Gs({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 JS({onAuthLost:t,onDirtyChange:i,onChanged:l,onOpen:a,hostLabel:o="服务端",configurationVersion:f=0}){const[u,p]=w.useState(),[h,m]=w.useState(""),[y,b]=w.useState(""),[v,x]=w.useState(""),[k,_]=w.useState(""),[D,R]=w.useState(),[z,L]=w.useState(),[G,ae]=w.useState(),[T,V]=w.useState(),[$,q]=w.useState(!1),[E,B]=w.useState(),[H,Z]=w.useState(),[ee,W]=w.useState(!1),[N,X]=w.useState(!0),[pe,ye]=w.useState(!1),[j,O]=w.useState(),[J,A]=w.useState(!0),[le,me]=w.useState(""),[te,se]=w.useState(""),[we,F]=w.useState(""),[Se,Ne]=w.useState(0),Te=w.useRef(!1),Ge=w.useRef(void 0),et=w.useRef(void 0),dt=w.useRef(!1),Fe=w.useRef(void 0),Ct=w.useRef(null),ht=w.useRef({onAuthLost:t,onDirtyChange:i,onChanged:l,onOpen:a});ht.current={onAuthLost:t,onDirtyChange:i,onChanged:l,onOpen:a};function qe(U){fetch(U.target,{method:"DELETE",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviewToken:U.token}),keepalive:!0,signal:AbortSignal.timeout(5e3)}).catch(()=>{})}const pt=!!(le||z||G||H||j||h.trim()||y.trim()||v.trim()),Ve=w.useCallback(U=>{U instanceof Xe&&U.status===401?ht.current.onAuthLost():se(U instanceof Error?U.message:"面板操作失败,请重试。")},[]);w.useEffect(()=>(Te.current=!0,()=>{Te.current=!1,Ge.current?.abort(),et.current?.abort(),Fe.current&&(qe(Fe.current),Fe.current=void 0),ht.current.onDirtyChange?.(!1)}),[]),w.useEffect(()=>{ht.current.onDirtyChange?.(pt)},[pt]),w.useEffect(()=>{if(Ge.current){dt.current=!0;return}const U=new AbortController;return et.current=U,A(!0),Ue(St(of),{signal:U.signal}).then(je=>{U.signal.aborted||p(je)}).catch(je=>{U.signal.aborted||Ve(je)}).finally(()=>{U.signal.aborted||A(!1)}),()=>U.abort()},[Se,f,Ve]),w.useEffect(()=>{z&&Ct.current?.focus()},[z?.reviewToken]);async function tt(U,je,Ce,st,ut=!1,Ut){if(Ge.current||!Te.current)return;const Et=new AbortController;Ge.current=Et,et.current?.abort(),A(!1),me(U),se(""),F("");const Gn=St(`${of}${je}`);try{const Ht=await Ue(Gn,{method:Ce,headers:{"Content-Type":"application/json"},body:JSON.stringify(st),signal:Et.signal});if(Et.signal.aborted||!Te.current){Ut?.(Ht);return}return ut&&(dt.current=!0,ht.current.onChanged?.()),Ht}catch(Ht){if(Et.signal.aborted||!Te.current)return;Ht instanceof Xe&&(Ht.status===409||Ht.status===410)&&(z&&W(!0),T&&q(!0),dt.current=!0),Ve(Ht);return}finally{Ge.current===Et&&(Ge.current=void 0),Te.current&&!Et.signal.aborted&&(me(""),dt.current&&(dt.current=!1,Ne(Ht=>Ht+1)))}}const zt=async U=>{if(!await Ke())return;ae(void 0),V(void 0),Z(void 0),L(void 0),O(void 0),R(void 0);const je=await tt("正在读取仓库…","/github/discover","POST",{url:U.url,...U.ref?{ref:U.ref}:{},...U.subdir?{subdir:U.subdir}:{}});je&&R(je)},rt=async U=>{if(!await Ke())return;ae(void 0),V(void 0);const je=await tt("正在准备安装审阅…","/preview","POST",{source:U});je&&(O(void 0),B(U),L(je),W(!1),ye(!1),X(!!u?.hasProject&&je.compatibility.supported))},yt=async U=>{if(!await Ke())return;ae(void 0),V(void 0);const je=await tt("正在检查更新…",`/${encodeURIComponent(U.id)}/update-preview`,"POST",{expectedRevision:U.revision});je&&(O(void 0),B(void 0),L(je),W(!1),ye(U.bound),X(U.bound&&je.compatibility.supported))},M=()=>{if(z)if(z.kind==="update"){const U=u?.panels.find(je=>je.id===z.preview.id);U?yt(U):(se("此面板已被卸载,请重新从 GitHub 选择安装。"),L(void 0))}else E&&rt(E)},K=()=>{Z(void 0),R(void 0),m(""),b(""),x("")},ge=async()=>{if(L(void 0),!H||H.position+1>=H.candidates.length){K();return}const U=H.position+1;Z({...H,position:U}),await rt(H.candidates[U].source)},be=async U=>{U.length&&(Z({candidates:U,position:0}),await rt(U[0].source))},Ee=async()=>{if(!z||ee)return;if(z.expiresAt<=Date.now()){W(!0),se("安装审阅已过期,请重新审阅后继续。");return}await tt(z.kind==="update"?"正在更新面板…":"正在安装面板…","/install","POST",{reviewToken:z.reviewToken,bind:N},!0)&&(F(`${Vn(z.preview.title)} 已${z.kind==="update"?"更新":"安装"}${N?"并绑定当前工作区":""}。`),L(void 0),H?await ge():K())},Le=async U=>{const je=await tt(U.bound?"正在解除绑定…":"正在绑定工作区…",`/${encodeURIComponent(U.id)}/binding`,"PATCH",{bound:!U.bound,expectedRevision:U.revision},!0);je&&(p(je),F(`${Vn(U.title)} 已${U.bound?"解除当前工作区绑定":"绑定当前工作区"}。`))},Ke=async()=>T?(await tt("正在关闭版本审阅…","/restore/review","DELETE",{reviewToken:T.reviewToken}))?.cancelled?(Fe.current=void 0,V(void 0),!0):!1:!0,bt=async()=>{await Ke()&&ae(void 0)},mt=async U=>{if(!await Ke())return;L(void 0),O(void 0),V(void 0),ae(void 0);const je=await tt("正在检查保留版本…",`/${encodeURIComponent(U.id)}/versions`,"POST",{expectedRevision:U.revision});je&&(ae(je),q(!1))},lt=async U=>{if(!G||!await Ke())return;const je=St(`${of}/restore/review`),Ce=await tt("正在审阅项目版本…",`/${encodeURIComponent(G.appId)}/restore-preview`,"POST",{packageDigest:U,expectedRevision:G.expectedRevision},!1,st=>qe({target:je,token:st.reviewToken}));if(Ce){if(!Te.current){qe({target:je,token:Ce.reviewToken});return}Fe.current={target:je,token:Ce.reviewToken},V(Ce),q(!1)}},Ze=async()=>{if(!T||de)return;if(T.expiresAt<=Date.now()){q(!0),se("版本审阅已过期,请重新选择版本。");return}await tt("正在恢复项目版本…","/restore","POST",{reviewToken:T.reviewToken},!0)&&(Fe.current=void 0,F(`${Vn(T.title)} 的项目版本已恢复为 v${T.version}。`),ae(void 0),V(void 0))},Q=async()=>{if(!j||u?.panels.find(je=>je.id===j.id)?.revision!==j.revision)return;(await tt("正在卸载面板…",`/${encodeURIComponent(j.id)}`,"DELETE",{expectedRevision:j.revision},!0))?.removed&&(F(`${Vn(j.title)} 已卸载。`),O(void 0))},ve=!!le||!u||!!H,ze=k.trim().toLowerCase(),De=(u?.panels??[]).filter(U=>[Vn(U.title),U.id,U.description??"",U.source.label].join(" ").toLowerCase().includes(ze)),$e=D?.panels.filter(U=>!u?.panels.some(je=>je.id===U.id)&&!u?.issues?.some(je=>je.id===U.id)&&D.panels.filter(je=>je.id===U.id).length===1)??[],ce=j&&u?.panels.find(U=>U.id===j.id),ke=!!j&&ce?.revision!==j.revision,Me=z?.kind==="update"?u?.panels.find(U=>U.id===z.preview.id):void 0,de=$||!!G&&(u?.panels.find(U=>U.id===G.appId)?.revision??u?.issues?.find(U=>U.id===G.appId)?.revision)!==G.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:!!le||J,onClick:()=>Ne(U=>U+1),children:J?"正在刷新…":"刷新"})]}),c.jsxs("p",{className:"panels-muted",children:["面板安装在",o,"上,文件和任务操作使用当前工作区。"]}),u&&!u.hasProject&&c.jsx("div",{className:"panels-warning",children:"请先选择一个项目,才能绑定和打开面板。"}),te&&c.jsx("p",{role:"alert",className:"error",children:te}),we&&c.jsx("p",{role:"status",className:"panels-notice",children:we}),le&&c.jsx("p",{role:"status",className:"panels-muted",children:le}),u?.issues?.filter(U=>U.id.toLowerCase().includes(ze)).map(U=>c.jsxs("section",{className:"panels-warning","aria-label":"需要修复的面板",children:[c.jsx("h2",{children:U.id}),c.jsxs("p",{children:["项目记录版本:",U.version??"未记录","。安装包缺失或无法校验,面板暂不可用。"]}),c.jsx("p",{children:"项目数据和任务记录仍保留。可检查宿主保留的版本,审阅权限后恢复。"}),c.jsx("button",{disabled:!!le||!U.bound||!u.canRestorePackages,onClick:()=>{mt(U)},children:"检查可用版本"})]},U.id)),G&&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(G.title)," · 项目版本"]}),c.jsxs("p",{children:["项目记录版本:",G.current.version]})]}),c.jsx("button",{disabled:!!le,onClick:()=>{bt()},children:"关闭版本记录"})]}),c.jsx("p",{children:"选择宿主已保留的程序版本,仅切换当前项目。其他项目继续使用各自版本。"}),c.jsx("p",{className:"panels-warning",children:"切换程序版本不会恢复旧数据。请先备份项目,确认该版本支持当前文档格式;任务与产物记录会保留。"}),G.current.unavailable&&c.jsx("p",{role:"status",children:"当前安装包不可用,无法读取原权限;恢复前需重新审阅目标版本的全部权限。"}),G.unavailablePackages>0&&c.jsxs("p",{role:"status",children:["有 ",G.unavailablePackages," 个保留包无法校验,暂不能选择。"]}),!G.versions.length&&c.jsx("p",{children:"没有可用的保留版本。"}),c.jsx("div",{className:"panels-grid",children:G.versions.map(U=>c.jsxs("article",{className:"panels-card",children:[c.jsxs("h3",{children:["v",U.version]}),c.jsxs("small",{children:["内容编号 ",U.packageDigest.slice(0,12)]}),c.jsx(Gs,{value:U.compatibility}),c.jsx("button",{disabled:!!le||!U.compatibility.supported||U.packageDigest===G.current.packageDigest,onClick:()=>{lt(U.packageDigest)},children:U.packageDigest===G.current.packageDigest?"当前项目版本":`审阅 v${U.version}`})]},U.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(U=>c.jsxs("div",{className:"panels-permission",children:[c.jsx("span",{children:cy[U]??U}),T.addedPermissions.includes(U)&&c.jsx("strong",{children:T.current.unavailable?"需重新确认":"新增权限"})]},U)),c.jsx(Gs,{value:T.compatibility}),de&&c.jsx("p",{role:"alert",children:"项目或审阅已变化,请关闭版本记录并重新读取。"}),c.jsx("button",{disabled:!!le||de||!T.compatibility.supported,onClick:()=>{Ze()},children:"确认权限并恢复项目版本"})]})]}),H&&c.jsxs("section",{className:"panels-confirm","aria-label":"逐个审阅面板",children:[c.jsxs("p",{children:["正在审阅第 ",H.position+1," / ",H.candidates.length," 个面板:",Vn(H.candidates[H.position].title),"。每个面板都需要单独确认安装。"]}),c.jsxs("div",{className:"panels-actions",children:[!z&&c.jsx("button",{disabled:!!le,onClick:()=>{rt(H.candidates[H.position].source)},children:"重新读取此面板"}),c.jsx("button",{disabled:!!le,onClick:()=>{ge()},children:"跳过此面板"}),c.jsx("button",{disabled:!!le,onClick:()=>{Z(void 0),L(void 0),se("")},children:"取消逐个审阅"})]})]}),z&&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:Ct,tabIndex:-1,children:z.kind==="update"?"审阅面板更新":"审阅面板安装"}),c.jsxs("p",{children:[Vn(z.preview.title)," · ",z.preview.id," · v",z.preview.version]})]}),c.jsx("button",{disabled:!!le,onClick:()=>{Z(void 0),L(void 0),se("")},children:"取消审阅"})]}),z.preview.description&&c.jsx("p",{children:z.preview.description}),Me&&c.jsxs("p",{className:"panels-warning",children:["当前版本 v",Me.version," → 更新后 v",z.preview.version,Me.source.commit&&c.jsxs(c.Fragment,{children:[c.jsx("br",{}),"当前提交 ",c.jsx("code",{children:Me.source.commit.slice(0,12)})," → 更新提交"," ",c.jsx("code",{children:z.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:z.source.url}),c.jsx("dt",{children:"分支 / 标签"}),c.jsx("dd",{children:z.source.ref}),c.jsx("dt",{children:"已锁定提交"}),c.jsx("dd",{children:c.jsx("code",{children:z.source.commit})}),c.jsx("dt",{children:"面板目录"}),c.jsx("dd",{children:z.source.subdir||"仓库根目录"}),c.jsx("dt",{children:"界面入口"}),c.jsx("dd",{children:c.jsx("code",{children:z.preview.entry})})]})]}),c.jsxs("section",{children:[c.jsx("h3",{children:"面板请求的权限"}),z.preview.permissions.length===0?c.jsx("p",{className:"panels-muted",children:"未申请宿主权限。"}):z.preview.permissions.map(U=>c.jsxs("div",{className:"panels-permission",children:[c.jsx("span",{children:cy[U]??U}),c.jsx("small",{children:U})]},U))]}),c.jsxs("section",{children:[c.jsx("h3",{children:"随面板安装的工具与 Skills"}),z.preview.agent?.tools.length||z.preview.agent?.skills.length?c.jsxs("div",{className:"panels-badges",children:[z.preview.agent?.tools.map(U=>c.jsxs("span",{className:"panels-badge",title:U.description,children:[U.name," · ",U.readOnly?"只读":"可修改数据"]},U.name)),z.preview.agent?.skills.map(U=>c.jsxs("span",{className:"panels-badge",children:["Skill · ",U.split("/").at(-2)??U]},U))]}):c.jsx("p",{className:"panels-muted",children:"此面板没有额外的 Agent 工具或 Skills。"})]}),c.jsx(Gs,{value:z.compatibility}),z.preview.warnings.length>0&&c.jsx("div",{className:"panels-warning",children:c.jsx("ul",{children:z.preview.warnings.map(U=>c.jsx("li",{children:U},U))})}),c.jsxs("footer",{children:[!z.compatibility.supported&&c.jsxs("p",{className:"panels-muted",children:["可以安装到",o,",但当前 Web 工作台无法绑定或打开它。"]}),pe?c.jsx("p",{className:"panels-muted",children:"已绑定当前工作区,更新将保留绑定。"}):c.jsxs("label",{className:"panels-check",children:[c.jsx("input",{type:"checkbox",checked:N,disabled:!!le||!u?.hasProject||!z.compatibility.supported,onChange:U=>X(U.target.checked)}),"绑定当前工作区"]}),ee?c.jsxs("div",{className:"panels-actions",children:[c.jsx("span",{className:"panels-muted",children:"安装内容或本地版本已变化,请重新审阅。"}),c.jsx("button",{disabled:!!le,onClick:M,children:"重新审阅"})]}):c.jsx("button",{className:"panels-primary",disabled:!!le,onClick:()=>{Ee()},children:z.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:k,onChange:U=>_(U.target.value)})]}),!u&&c.jsx("p",{className:"panels-muted",children:J?"正在读取面板…":"暂时无法读取面板,请刷新重试。"}),u&&De.length===0&&!u.issues?.some(U=>U.id.toLowerCase().includes(ze))&&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:De.map(U=>c.jsxs("article",{className:"panels-card",children:[c.jsxs("div",{className:"panels-card-heading",children:[c.jsx("h3",{children:Vn(U.title)}),c.jsxs("span",{className:"panels-badge",children:["v",U.version]})]}),c.jsx("small",{children:U.id}),U.description&&c.jsx("p",{children:U.description}),c.jsx("div",{className:"panels-badges",children:c.jsx("span",{className:`panels-badge ${U.enabled&&U.compatibility.supported?"panels-badge-ready":""}`,children:U.globalDisabled?"已全局停用":U.bound?"已绑定当前工作区":"未绑定当前工作区"})}),c.jsxs("dl",{children:[c.jsx("dt",{children:"来源"}),c.jsx("dd",{children:U.source.label}),U.source.ref&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:"分支 / 标签"}),c.jsx("dd",{children:U.source.ref})]})]}),c.jsx(Gs,{value:U.compatibility}),U.globalDisabled&&c.jsx("p",{className:"panels-muted",children:"请在宿主配置中启用此面板后使用。"}),c.jsxs("div",{className:"panels-actions",children:[c.jsx("button",{className:"panels-primary",disabled:ve||!U.enabled||!U.compatibility.supported,onClick:()=>ht.current.onOpen(U),children:"打开面板"}),c.jsx("button",{disabled:ve||!u?.hasProject||!U.bound&&(U.globalDisabled||!U.compatibility.supported),onClick:()=>{Le(U)},children:U.bound?"解除绑定":"绑定工作区"}),U.updatable&&c.jsx("button",{disabled:ve,onClick:()=>{yt(U)},children:"检查更新"}),u?.canRestorePackages&&U.bound&&c.jsx("button",{disabled:ve,onClick:()=>{mt(U)},children:"项目版本"}),c.jsx("button",{className:"panels-danger",disabled:ve,onClick:async()=>{!await Ke()||!Te.current||(O(U),L(void 0),ae(void 0),V(void 0),se(""),F(""))},children:"卸载"})]})]},U.id))}),j&&c.jsxs("section",{className:"panels-confirm","aria-label":"确认卸载面板",children:[c.jsxs("p",{children:["卸载「",Vn(j.title),"」v",j.version,"?面板将从",o,"移除,其他工作区也将无法打开它。"]}),c.jsxs("div",{className:"panels-actions",children:[c.jsx("button",{disabled:!!le,onClick:()=>O(void 0),children:"取消卸载"}),ke&&c.jsx("span",{className:"panels-muted",children:ce?"面板已被其他设备修改,请查看最新版本后重新确认。":"此面板已被其他设备卸载。"}),ke&&ce&&c.jsx("button",{disabled:!!le||J,onClick:()=>{O(ce),se("")},children:"查看最新版本"}),c.jsx("button",{className:"panels-danger",disabled:!!le||J||ke,onClick:()=>{Q()},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:ve,onClick:()=>{m(uy),b(""),x(""),zt({url:uy})},children:"浏览官方仓库"})]}),c.jsxs("form",{onSubmit:U=>{U.preventDefault(),h.trim()&&zt({url:h.trim(),...y.trim()?{ref:y.trim()}:{},...v.trim()?{subdir:v.trim()}:{}})},children:[c.jsxs("label",{children:["GitHub 仓库地址",c.jsx("input",{type:"url",placeholder:"https://github.com/owner/repository",value:h,required:!0,disabled:!!le||!!H,onChange:U=>{m(U.target.value),R(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:!!le||!!H,onChange:U=>{b(U.target.value),R(void 0)}})]}),c.jsxs("label",{children:["子目录(可选)",c.jsx("input",{value:v,placeholder:"例如 apps/my-panel",disabled:!!le||!!H,onChange:U=>{x(U.target.value),R(void 0)}})]})]})]}),c.jsxs("div",{className:"panels-actions",children:[c.jsx("button",{type:"submit",disabled:ve||!h.trim(),children:"读取仓库"}),(h||y||v||D)&&c.jsx("button",{type:"button",disabled:!!le,onClick:()=>{K(),L(void 0)},children:"清除"})]})]}),D&&c.jsxs("div",{className:"panels-candidates",children:[c.jsxs("h3",{children:["找到 ",D.panels.length," 个面板"]}),c.jsxs("p",{className:"panels-muted",children:[D.source.url," · ",D.source.ref," ·"," ",c.jsx("code",{children:D.source.commit.slice(0,12)})]}),D.panels.length===0&&c.jsx("p",{className:"panels-muted",children:"仓库中没有找到可安装的面板。请检查地址和子目录。"}),$e.length>1&&c.jsxs("div",{className:"panels-actions panels-batch-start",children:[c.jsxs("button",{disabled:ve,onClick:()=>{be($e)},children:["逐个审阅未安装面板(",$e.length,")"]}),c.jsx("small",{children:"按顺序确认,可随时跳过或停止。"})]}),c.jsx("div",{className:"panels-grid",children:D.panels.map(U=>{const je=u?.panels.find(Ce=>Ce.id===U.id);return c.jsxs("article",{className:"panels-card",children:[c.jsxs("div",{className:"panels-card-heading",children:[c.jsx("h3",{children:Vn(U.title)}),c.jsxs("span",{className:"panels-badge",children:["v",U.version]})]}),U.description&&c.jsx("p",{children:U.description}),c.jsx("small",{children:U.subdir==="."?"仓库根目录":U.subdir}),c.jsx("div",{className:"panels-actions",children:c.jsx("button",{disabled:ve||!!(je&&!je.updatable),onClick:()=>je?void yt(je):void rt(U.source),children:je?je.updatable?"已安装 · 检查更新":"已从其他来源安装":"审阅安装"})})]},`${U.id}:${U.subdir}`)})}),D.issues.length>0&&c.jsxs("div",{className:"panels-warning",children:[c.jsx("strong",{children:"部分目录无法作为面板安装"}),c.jsx("ul",{children:D.issues.map(U=>c.jsxs("li",{children:[U.subdir,":",U.error]},U.subdir))})]})]})]})]})}function WS(t){const i=t.projectId===void 0?ba():t.projectId,l=`/api/v1/panels/runtime/${encodeURIComponent(t.instanceId)}`,a=new Set,o=new Set;let f=!1,u=t.expiresAt,p=u-6e4,h,m=0,y=0,b=0,v,x;const k=(E,B)=>{const H=setTimeout(()=>{a.delete(H),f||E()},Math.max(0,Math.min(B,2147483647)));return a.add(H),H},_=E=>{E!==void 0&&(clearTimeout(E),a.delete(E))},D=()=>{if(!f){f=!0;for(const E of a)clearTimeout(E);a.clear();for(const E of o)E.abort();o.clear()}},R=E=>{f||(D(),t.onTerminal(E))},z=()=>R(new Error("面板连接已到期,请重新打开继续使用。")),L=E=>E instanceof Xe&&[401,403,410].includes(E.status),G=()=>{f||t.onStatus(m||y?"面板连接暂时中断,正在重试;当前内容会保留。":"")},ae=async(E,B="GET")=>{const H=new AbortController;o.add(H);const Z=k(()=>H.abort(),8e3);try{return await Ue(St(`${l}${E}`,t.workspace,i),{method:B,...B==="POST"?{headers:{"Content-Type":"application/json"},body:"{}"}:{},signal:H.signal})}finally{_(Z),o.delete(H)}},T=()=>{_(v),v=k(()=>{Date.now()>=u?z():T()},u-Date.now())},V=()=>{_(x),m<5&&(x=k($,p-Date.now()))};function $(){if(!f){if(Date.now()>=u){z();return}h||m>=5||Date.now()<p||(h=(async()=>{try{const E=await ae("/renew","POST");if(f)return;if(!E||typeof E!="object"||!("expiresAt"in E)||typeof E.expiresAt!="number"||!Number.isFinite(E.expiresAt)||E.expiresAt<=Date.now()+6e4)throw new Error("面板续期响应无效。");u=E.expiresAt,p=u-6e4,m=0,T(),G()}catch(E){if(f)return;if(L(E)){R(E);return}m++,p=Date.now()+Math.min(5e3*2**(m-1),3e4),G()}finally{h=void 0,f||V()}})())}}async function q(){try{const E=await ae(`/events?after=${b}`);if(f)return;if(!E||typeof E!="object"||!("cursor"in E)||!("events"in E))throw new Error("面板事件响应无效。");if(!Number.isSafeInteger(E.cursor)||E.cursor<b||!Array.isArray(E.events)||E.events.length>2048)throw new Error("面板事件响应无效。");const B=[];let H=b;for(const Z of E.events){if(!Z||typeof Z!="object"||!Number.isSafeInteger(Z.id)||Z.id<=H||Z.id>E.cursor||typeof Z.event!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,100}$/.test(Z.event))throw new Error("面板事件响应无效。");H=Z.id,B.push(Z)}t.onEvents(B),b=E.cursor,y=0,G()}catch(E){if(f)return;if(L(E)){R(E);return}y++,G()}finally{f||k(()=>{q()},Math.min(1e3*2**y,5e3))}}return T(),V(),q(),{stop:D,refresh:$}}function ew(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=[],p=0,h="",m=t.signal.aborted;const y=k=>{i={...i,...k},m||t.onChange({...i})},b=()=>{a?.getTracks().forEach(k=>k.stop()),a=void 0,f&&clearInterval(f),f=void 0},v=()=>{try{o?.state!=="inactive"&&o?.stop()}finally{b()}},x=()=>{if(!m){m=!0,l++,o&&(o.ondataavailable=null,o.onstop=null,o.onerror=null);try{v()}finally{b()}u=[],i={phase:"closed",elapsedSeconds:0,message:"录音已关闭。"},t.signal.removeEventListener("abort",x)}};return m?i={phase:"closed",elapsedSeconds:0,message:"录音授权已结束。"}:t.signal.addEventListener("abort",x,{once:!0}),{snapshot:()=>({...i}),async start(){if(m||t.signal.aborted)throw new Error("录音授权已结束。");if(["requesting","recording"].includes(i.phase))throw new Error("已有录音正在进行。");const k=++l,_=()=>!m&&k===l&&!t.signal.aborted;u=[],p=0,h="",y({phase:"requesting",elapsedSeconds:0,blob:void 0,message:"正在等待麦克风授权…"});try{const D=await(t.getStream?t.getStream():navigator.mediaDevices.getUserMedia({audio:!0,video:!1}));if(!_()){D.getTracks().forEach(G=>G.stop());return}a=D;const R=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(G=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(G));o=t.makeRecorder?t.makeRecorder(a):new MediaRecorder(a,{...R?{mimeType:R}:{},audioBitsPerSecond:128e3});const z=o;z.ondataavailable=G=>{!_()||!G.data.size||(u.push(G.data),p+=G.data.size,p>t.maxBytes&&(h="录音超过大小限制;可以下载备份,或重新录制较短的音频。",v()))},z.onerror=()=>{if(_()){h="录音设备发生错误;请检查麦克风后重新录制。";try{v()}catch{b()}y({phase:"error",message:h})}},z.onstop=()=>{if(!_())return;b();const G=new Blob(u,{type:z.mimeType.split(";")[0]||"audio/webm"});u=[],y({phase:G.size&&!h?"review":"error",blob:G.size?G:void 0,message:h||(G.size?"录音已停止。可以试听,再保存到当前项目。":"没有录到声音,请重新录制。")})};const L=Date.now();z.start(250),y({phase:"recording",message:"正在使用这台设备的麦克风录音。"}),f=setInterval(()=>{if(!_())return;const G=Math.floor((Date.now()-L)/1e3);y({elapsedSeconds:G}),G>=t.maxDurationSeconds&&v()},250)}catch(D){if(b(),!_())return;y({phase:"error",message:D instanceof Error&&["NotAllowedError","SecurityError"].includes(D.name)?"麦克风未获授权,请检查浏览器和系统的麦克风权限。":"无法启动录音,请确认安全连接、麦克风和浏览器录音支持。"})}},stop:v,close:x}}function tw(t){let i,l=!1,a;const o=()=>t.signal.throwIfAborted(),f=async(p,h)=>{o();const m=await t.call(p,h);return o(),m},u=p=>{const h=p;if(!h||typeof h.sessionId!="string"||!/^upload-[a-f0-9-]{36}$/.test(h.sessionId)||i&&i!==h.sessionId||h.mimeType!==t.blob.type||!["uploading","finished"].includes(String(h.state))||!Number.isSafeInteger(h.receivedBytes)||Number(h.receivedBytes)<0||Number(h.receivedBytes)>t.blob.size||!Number.isSafeInteger(h.nextSequence)||Number(h.nextSequence)<0||!Number.isSafeInteger(h.maxChunkBytes)||Number(h.maxChunkBytes)<1||Number(h.maxChunkBytes)>32768)throw new Error("录音上传状态无效,请保留本机备份后重新打开面板。");return h};return{async save(){if(o(),l)throw new Error("录音正在保存,请稍候。");if(!t.blob.size||t.blob.size>25*1024*1024||!["audio/webm","audio/mp4","audio/ogg","audio/wav"].includes(t.blob.type))throw new Error("录音格式或大小无效。");l=!0;try{if(!a){const m=await t.blob.arrayBuffer();o(),a=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",m)),y=>y.toString(16).padStart(2,"0")).join(""),o()}let p=u(i?await f("resources.upload.get",{sessionId:i}):await f("resources.upload.begin",{name:t.name,mimeType:t.blob.type,expectedBytes:t.blob.size,expectedSha256:a}));for(i=p.sessionId,t.onProgress(p.receivedBytes);p.receivedBytes<t.blob.size;){if(p.state!=="uploading")throw new Error("录音上传已结束,文件大小不匹配。");const m=p.receivedBytes,y=new Uint8Array(await t.blob.slice(m,m+p.maxChunkBytes).arrayBuffer());o();const b=u(await f("resources.upload.write",{sessionId:i,sequence:p.nextSequence,offset:m,dataBase64:btoa(String.fromCharCode(...y))}));if(b.receivedBytes!==m+y.length||b.nextSequence!==p.nextSequence+1)throw new Error("录音上传进度不匹配,请重试保存以核对服务端状态。");p=b,t.onProgress(p.receivedBytes)}const h=await f("resources.upload.finish",{sessionId:i});if(!h?.asset||h.asset.id!==`asset-${a}`||h.asset.bytes!==t.blob.size||h.asset.mimeType!==t.blob.type)throw new Error("录音保存回执不匹配,请保留本机备份并重试。");return h}finally{l=!1}}}}function nw({request:t}){const[i,l]=w.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"}),[a,o]=w.useState(""),[f,u]=w.useState(!1),[p,h]=w.useState(0),[m,y]=w.useState(""),b=w.useRef(null),v=w.useRef(void 0),x=w.useRef(void 0),k=w.useRef(void 0);w.useEffect(()=>{const R=new AbortController;k.current=R;const z=AbortSignal.any([t.signal,R.signal]);return v.current=ew({...t,signal:z,onChange:l}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{R.abort(),v.current?.close(),v.current=void 0,x.current=void 0}},[t]),w.useEffect(()=>{if(!i.blob){y("");return}const R=URL.createObjectURL(i.blob);return y(R),()=>URL.revokeObjectURL(R)},[i.blob]);const _=i.blob?.type==="audio/mp4"?"m4a":i.blob?.type==="audio/ogg"?"ogg":"webm",D=async()=>{const R=i.blob,z=k.current;if(!R||!z||f||i.phase!=="review")return;const L=AbortSignal.any([t.signal,z.signal]);u(!0),o("");try{x.current?.blob!==R&&(x.current={blob:R,transfer:tw({blob:R,name:`recording.${_}`,signal:L,call:(ae,T)=>t.call(ae,T,L),onProgress:h})});const G=await x.current.transfer.save();L.throwIfAborted(),t.finish(G)}catch(G){L.aborted||o(`${G instanceof Error?G.message:"保存失败。"} 录音仍保留在本页,可重试保存或下载备份。`)}finally{L.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} 秒`]}),m&&c.jsx("audio",{controls:!0,src:m}),a&&c.jsx("p",{role:"alert",children:a}),f&&c.jsxs("p",{role:"status",children:["正在保存录音:",Math.round(p/(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(""),v.current?.start().catch(R=>o(String(R)))},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:()=>{D()},children:f?"正在保存…":"保存到当前项目"}),m&&c.jsx("button",{disabled:f,onClick:()=>{o(""),x.current=void 0,v.current?.start().catch(R=>o(String(R)))},children:"丢弃并重新录制"}),m&&c.jsx("a",{href:m,download:`recording.${_}`,children:"下载本机备份"})]})]})}const Qi="/api/v1/panels/runtime";function gn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function iw(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 rw(t,i){const l=`${Qi}/${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 lw(t,i,l){if(!gn(t)||t.effect!=="resources.open"||!gn(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!==`${Qi}/${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 aw(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 sw(t){return gn(t)?typeof t.instanceId=="string"&&/^[A-Za-z0-9_-]{20,128}$/.test(t.instanceId)&&aw(t.src)&&typeof t.expiresAt=="number"&&Number.isFinite(t.expiresAt)&&gn(t.context)&&Array.isArray(t.limitations)&&t.limitations.every(i=>typeof i=="string"):!1}function ow({panel:t,sessionId:i,busy:l,onClose:a,onAuthLost:o,onDirtyChange:f,onSubmitPrompt:u}){const p=w.useRef(null),[h,m]=w.useState(),[y,b]=w.useState(!0),[v,x]=w.useState(""),[k,_]=w.useState(""),[D,R]=w.useState(),[z,L]=w.useState(),[G,ae]=w.useState(!1),T=w.useRef(null);w.useEffect(()=>{z&&(T.current?.focus(),T.current?.scrollIntoView?.({block:"nearest"}))},[z]);const[V,$]=w.useState(""),[q,E]=w.useState(""),[B,H]=w.useState(),[Z,ee]=w.useState(),W=w.useRef(void 0),[N,X]=w.useState(!1),[pe,ye]=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 O=w.useRef(!1),J=w.useRef(void 0),A=w.useRef(void 0),le=w.useRef(null);return w.useEffect(()=>{j.current.onDirtyChange?.(!!B||N||!!Z),B&&(le.current?.focus(),le.current?.scrollIntoView?.({block:"nearest"}))},[B,N,Z]),w.useEffect(()=>{const me=Ws()??"",te=ba(),se={workspace:me,grant:void 0},we=new AbortController,F=new Set,Se=new Set;let Ne=!1,Te;const Ge=[],et=[],dt=new Set,Fe=new Set;let Ct,ht=!1,qe=!1,pt=!1,Ve=!1;const tt=()=>{const Q=p.current?.contentWindow;if(!(Ne||!se.grant||!Q||!Ve))for(const ve of Ge.splice(0))ve.event==="tools.invoke"&&gn(ve.payload)&&typeof ve.payload.requestId=="string"&&/^[A-Za-z0-9_-]{1,128}$/.test(ve.payload.requestId)&&Fe.add(ve.payload.requestId),Q.postMessage({type:"codeshell-panel:event",instanceId:se.grant.instanceId,event:ve.event,payload:ve.payload},"*")},zt=()=>{Ne||!pt||!Ve||!se.grant||(Ct&&clearTimeout(Ct),b(!1),tt())},rt={loaded:()=>{pt=!0,zt()}};A.current=rt,m(void 0),b(!0),x(""),_(""),R(void 0),L(void 0),ae(!1),$(""),E(""),H(void 0),X(!1),ee(void 0);const yt=Q=>{ht||(ht=!0,Ue(St(`${Qi}/${encodeURIComponent(Q.instanceId)}`,me,te),{method:"DELETE",keepalive:!0}).catch(()=>{}))},M=Q=>{Ne||(Q instanceof Xe&&Q.status===401&&!O.current&&(O.current=!0,j.current.onAuthLost()),x(Q instanceof Error?Q.message:"面板连接失败,请重新打开。"))},K=Q=>{if(Ne||!se.grant)return;const ve=se.grant;se.grant=void 0,Te?.stop(),J.current?.cancel(),et.length=0,Ge.length=0,yt(ve);for(const ze of F)ze.abort();Ct&&clearTimeout(Ct),m(void 0),R(void 0),L(void 0),b(!1),X(!1),$(""),M(Q)},ge=Q=>({...Q,...typeof Q.sessionId=="string"?{busy:j.current.busy}:{}}),be=(Q,ve,ze,De,$e)=>{Ne||!se.grant||Q!==p.current?.contentWindow||Q.postMessage({type:"codeshell-panel:response",instanceId:se.grant.instanceId,requestId:ve,...De?{error:De,...$e?.code?{code:$e.code}:{},...$e?.retryAfterMs!==void 0?{retryAfterMs:$e.retryAfterMs}:{}}:{result:ze}},"*")},Ee=()=>{if(Ne||!se.grant||J.current||W.current||qe)return;const Q=et.shift();if(!Q)return;if(Q.expiresAt<=Date.now()){Ee();return}let ve=!1;const ze={effect:Q,cancel:()=>{J.current===ze&&(clearTimeout(De),J.current=void 0,Ne||(H(void 0),E(""),X(!1)))},finish:$e=>{if(Ne||!se.grant||J.current!==ze||ve)return;ve=!0,X(!0),E("");const ce=new AbortController;F.add(ce);const ke=setTimeout(()=>ce.abort(),8e3);Ue(St(`${Qi}/${se.grant.instanceId}/confirm`,me,te),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:Q.requestId,allowed:$e}),signal:ce.signal}).then(Me=>{if(!(Ne||J.current!==ze)){if(typeof Me.allowed!="boolean")throw new Error("确认响应无效。");$e&&Me.allowed===!1&&_("此确认已超时或被取消,操作未获准执行,请在面板中重新发起。"),!$e&&Me.allowed===!0&&_("该操作此前已获准执行,请在面板中查看进度或停止。"),ze.cancel(),Ee()}}).catch(Me=>{if(!(Ne||J.current!==ze)){if(Me instanceof Xe&&[401,403,410].includes(Me.status)){K(Me);return}if(Me instanceof Xe&&Me.status===409){ze.cancel(),_("面板操作确认已失效,请在面板中重新发起。"),Ee();return}E("暂未收到确认结果。可以重试本次确认,或取消尚未执行的请求。")}}).finally(()=>{clearTimeout(ke),F.delete(ce),ve=!1,!Ne&&J.current===ze&&X(!1)})}},De=setTimeout(()=>{ze.cancel(),!Ne&&se.grant&&(_("面板操作确认已超时,请在面板中重新发起。"),Ee())},Q.expiresAt-Date.now());J.current=ze,H(ze),E("")},Le=Q=>{for(const ve of Q){if(ve.event!=="host.confirm"){Ge.push(ve);continue}const ze=ve.payload;if(!gn(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("面板操作确认格式无效。");dt.has(ze.requestId)||(dt.add(ze.requestId),et.push({effect:"host.confirm",requestId:ze.requestId,title:ze.title,body:ze.body,expiresAt:Date.now()+5e4}))}if(Ge.length>2048||et.length>32){K(new Error("面板状态积压过多,请重新打开面板。"));return}Ee(),tt()},Ke=Q=>new Promise(ve=>{if(J.current||W.current||qe){ve(!1);return}const ze={effect:Q,finish:$e=>{J.current===ze&&(clearTimeout(De),J.current=void 0,Ne||H(void 0),ve($e),queueMicrotask(Ee))},cancel:()=>ze.finish(!1)},De=setTimeout(()=>ze.finish(!1),55e3);J.current=ze,H(ze)}),bt=async Q=>{const ve=p.current?.contentWindow,ze=se.grant,De=Q.data;if(Ne||!ve||Q.source!==ve||Q.origin!=="null"||!ze||!gn(De)||De.instanceId!==ze.instanceId)return;if(De.type==="codeshell-panel:ready"){Ve=!0,zt();return}if(De.type==="codeshell-panel:tool-result"){if(typeof De.requestId!="string"||!Fe.has(De.requestId)||F.size>=32)return;let de;try{if(de=JSON.stringify({requestId:De.requestId,...typeof De.error=="string"?{error:De.error}:{result:De.result}}),new TextEncoder().encode(de).length>512*1024)return}catch{return}Fe.delete(De.requestId);const U=new AbortController;F.add(U);const je=setTimeout(()=>U.abort(),8e3);try{await Ue(St(`${Qi}/${ze.instanceId}/tool-results`,me,te),{method:"POST",headers:{"Content-Type":"application/json"},body:de,signal:U.signal})}catch(Ce){!Ne&&se.grant&&(Ce instanceof Xe&&[401,410].includes(Ce.status)?K(Ce):_("面板工具结果未能送达,请在对话中重新发起操作。"))}finally{clearTimeout(je),F.delete(U)}return}if(De.type!=="codeshell-panel:call"||typeof De.requestId!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(De.requestId))return;const $e=De.requestId;if(Se.has($e)){be(ve,$e,void 0,"此请求已经处理,请重新发起。");return}if(Se.size>=8192||F.size>=32){be(ve,$e,void 0,"面板请求过于频繁,请稍后重试。");return}if(Se.add($e),typeof De.method!="string"||!/^[A-Za-z][A-Za-z0-9.]{0,63}$/.test(De.method)){be(ve,$e,void 0,"面板方法无效。");return}let ce;try{if(ce=JSON.stringify({method:De.method,params:De.params}),new TextEncoder().encode(ce).length>3*1024*1024)throw new Error("too large")}catch{be(ve,$e,void 0,"面板请求内容过大或格式无效。");return}const ke=new AbortController;let Me=!1;F.add(ke);try{const de=await Ue(St(`${Qi}/${ze.instanceId}/call`,me,te),{method:"POST",headers:{"Content-Type":"application/json"},body:ce,signal:ke.signal});if(Ne||ke.signal.aborted)return;if(De.method==="context.get"&&(Ve=!0,zt()),De.method==="external.open"){const U=gn(de)&&de.effect===De.method?iw(de.url):void 0;if(!U)throw new Error("面板返回的外部链接无效。");if(!await Ke({effect:"external.open",url:U}))throw new Error("你取消了打开链接,或确认已超时。");be(ve,$e,{opened:!0})}else if(De.method==="agent.submitPrompt"){if(!gn(de)||de.effect!==De.method||typeof de.prompt!="string"||!de.prompt.trim()||de.prompt.length>2e4||de.sessionId!==i)throw new Error("面板任务与当前对话不匹配,请重新打开面板。");if(!await Ke({effect:"agent.submitPrompt",prompt:de.prompt,sessionId:i}))throw new Error("你取消了发送任务,或确认已超时。");if(Ne||ke.signal.aborted)return;Me=!0,qe=!0,X(!0);const U=await j.current.onSubmitPrompt({prompt:de.prompt,sessionId:i});if(Ne||ke.signal.aborted)return;_("面板任务已提交到当前对话,可切换到对话查看进度。"),be(ve,$e,U)}else if(De.method==="resources.recordAudio"){if(!gn(de)||de.effect!==De.method||!Number.isInteger(de.maxDurationSeconds)||Number(de.maxDurationSeconds)<1||Number(de.maxDurationSeconds)>600||!Number.isInteger(de.maxBytes)||Number(de.maxBytes)<1||Number(de.maxBytes)>25*1024*1024)throw new Error("录音请求无效。");if(W.current||J.current||qe)throw new Error("请先完成当前的录音或确认操作。");const U=await new Promise((je,Ce)=>{let st=!1;const ut=(Ht,xi)=>{st||(st=!0,clearTimeout(Et),ke.signal.removeEventListener("abort",Ut),W.current===Gn&&(W.current=void 0,Ne||ee(void 0)),xi?Ce(xi):je(Ht),Ee())},Ut=()=>ut(void 0,new Error("录音已关闭或授权已结束。")),Et=setTimeout(()=>ut(void 0,new Error("录音操作已超时,请重新打开。")),25*6e4),Gn={signal:ke.signal,maxDurationSeconds:Number(de.maxDurationSeconds),maxBytes:Number(de.maxBytes),call:async(Ht,xi,pl)=>{const xr=pl?AbortSignal.any([ke.signal,pl]):ke.signal;if(xr.throwIfAborted(),Ne||se.grant!==ze)throw new Error("当前项目授权已结束。");try{const ln=await Ue(St(`${Qi}/${ze.instanceId}/call`,me,te),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:Ht,params:xi}),signal:xr});if(xr.throwIfAborted(),Ne||se.grant!==ze)throw new Error("当前项目授权已结束。");return ln}catch(ln){throw ln instanceof Xe&&[401,403,410].includes(ln.status)&&K(ln),ln}},finish:ut};W.current=Gn,ke.signal.addEventListener("abort",Ut,{once:!0}),ee(Gn)});be(ve,$e,U)}else if(De.method==="resources.open"){L(void 0),ae(!1);const U=lw(de,ze.instanceId,gn(De.params)?De.params.assetId:void 0);if(!U)throw new Error("面板文件预览链接无效,请重新打开文件。");L({...U,url:St(U.url,me,te),downloadUrl:St(`${U.url}?download=1`,me,te)}),be(ve,$e,{opened:!0})}else if(De.method==="filesystem.openDirectory"){if(R(void 0),!gn(de)||de.effect!==De.method||typeof de.path!="string")throw new Error("面板目录信息无效。");if(de.url!==void 0&&!rw(de.url,ze.instanceId))throw new Error("面板目录链接无效,请重新打开目录。");R({path:de.path,...typeof de.url=="string"?{url:St(de.url,me,te)}:{}}),be(ve,$e,{opened:!1,path:de.path})}else if(De.method==="notifications.send"){if(!gn(de)||de.effect!==De.method||typeof de.title!="string"||de.title.length>160||typeof de.body!="string"||de.body.length>2e3)throw new Error("面板通知格式无效。");_(`${de.title}${de.body?`:${de.body}`:""}`),be(ve,$e,{sent:!0})}else be(ve,$e,De.method==="context.get"&&gn(de)?ge(de):de)}catch(de){!Ne&&!ke.signal.aborted&&(de instanceof Xe&&[401,410].includes(de.status)&&K(de),(De.method==="agent.submitPrompt"||De.method==="external.open")&&_(de instanceof Error?de.message:"面板操作未完成。"),be(ve,$e,void 0,de instanceof Error?de.message:"面板请求失败。",de instanceof Xe?{code:de.code,retryAfterMs:de.retryAfterMs}:void 0))}finally{F.delete(ke),Me&&(qe=!1,Ne||X(!1),Ee())}},mt=Q=>{bt(Q)};window.addEventListener("message",mt);const lt=()=>Te?.refresh(),Ze=()=>{document.visibilityState==="visible"&&lt()};return window.addEventListener("focus",lt),window.addEventListener("online",lt),document.addEventListener("visibilitychange",Ze),Ue(St(`${Qi}/prepare`,me,te),{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(Q=>{if(!sw(Q))throw new Error("面板启动信息无效,请刷新面板列表后重试。");if(Ne||we.signal.aborted){yt(Q);return}if(Q.expiresAt<=Date.now())throw yt(Q),new Error("面板授权已过期,请重新打开。");se.grant=Q,m({...Q,src:St(Q.src,me,te)}),Ct=setTimeout(()=>{K(new Error("面板未能完成加载,请重新打开。若仍无法加载,可检查面板文件或使用桌面客户端。"))},45e3),Te=WS({instanceId:Q.instanceId,expiresAt:Q.expiresAt,workspace:me,projectId:te,onEvents:Le,onTerminal:K,onStatus:$})}).catch(Q=>{!Ne&&!we.signal.aborted&&(b(!1),M(Q))}),()=>{Ne=!0,J.current?.cancel(),window.removeEventListener("message",mt),window.removeEventListener("focus",lt),window.removeEventListener("online",lt),document.removeEventListener("visibilitychange",Ze),Te?.stop(),we.abort();for(const Q of F)Q.abort();Ct&&clearTimeout(Ct),se.grant&&yt(se.grant),j.current.onDirtyChange?.(!1),A.current===rt&&(A.current=void 0)}},[t.id,t.revision,i,pe]),w.useEffect(()=>{!h||!p.current?.contentWindow||p.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(me=>c.jsx("li",{children:me},me))})]}),k&&c.jsx("p",{className:"panel-host-notice",role:"status",children:k}),D&&c.jsxs("div",{className:"panel-host-notice panel-host-directory",role:"status",children:[c.jsxs("p",{children:["文件保存在服务器目录:",D.path]}),D.url&&c.jsx("a",{href:D.url,target:"_blank",rel:"noopener noreferrer",children:"查看并下载文件"})]}),z&&c.jsxs("section",{className:"panel-host-preview","aria-label":"文件预览",tabIndex:-1,ref:T,children:[c.jsxs("header",{children:[c.jsx("h2",{children:z.name}),c.jsx("button",{onClick:()=>L(void 0),children:"关闭预览"})]}),!G&&z.kind==="video"&&c.jsx("video",{src:z.url,controls:!0,playsInline:!0,preload:"metadata",onError:()=>ae(!0)},z.url),!G&&z.kind==="audio"&&c.jsx("audio",{src:z.url,controls:!0,preload:"metadata",onError:()=>ae(!0)},z.url),!G&&z.kind==="image"&&c.jsx("img",{src:z.url,alt:z.name,onError:()=>ae(!0)},z.url),(G||z.kind==="file")&&c.jsx("p",{role:"status",children:"当前浏览器无法预览此文件。可以保存后打开;若保存失败,请重新打开面板检查访问权限。"}),c.jsx("a",{href:z.downloadUrl,download:z.name,children:"保存到此设备"})]}),V&&c.jsx("p",{className:"panel-host-notice",role:"status",children:V}),v&&c.jsxs("div",{className:"panel-host-error",role:"alert",children:[c.jsx("p",{children:v}),c.jsx("button",{disabled:y,onClick:()=>ye(me=>me+1),children:"重新打开面板"})]}),y&&c.jsx("p",{className:"panel-host-loading",role:"status",children:"正在打开面板…"}),Z&&c.jsx(nw,{request:Z}),B&&c.jsxs("section",{className:"panel-host-confirm",ref:le,tabIndex:-1,onKeyDown:me=>{me.key==="Escape"&&!N&&(me.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}),q&&c.jsx("p",{role:"alert",children:q}),c.jsxs("div",{className:"panel-host-actions",children:[c.jsx("button",{disabled:N,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:N,onClick:()=>B.finish(!0),children:N?"正在确认…":B.effect.effect==="host.confirm"?"确认执行":"确认发送任务"})]})]}),h&&c.jsx("iframe",{ref:p,src:h.src,title:`${t.title["zh-CN"]||t.title.default}面板`,sandbox:"allow-scripts allow-downloads",referrerPolicy:"no-referrer",inert:!!B||N||!!Z,onLoad:()=>A.current?.loaded(),allow:"camera 'none'; microphone 'none'; geolocation 'none'; display-capture 'none'; clipboard-read 'none'; clipboard-write 'none'",className:"panel-host-frame"})]})}function uw(t,i){const l={};return(t[t.length-1]===""?[...t,""]:t).join((l.padRight?" ":"")+","+(l.padLeft===!1?"":" ")).trim()}const cw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dw={};function fy(t,i){return(dw.jsx?fw:cw).test(t)}const hw=/[ \t\n\f\r]/g;function pw(t){return typeof t=="object"?t.type==="text"?dy(t.value):!1:dy(t)}function dy(t){return t.replace(hw,"")===""}class ja{constructor(i,l,a){this.normal=l,this.property=i,a&&(this.space=a)}}ja.prototype.normal={};ja.prototype.property={};ja.prototype.space=void 0;function Eb(t,i){const l={},a={};for(const o of t)Object.assign(l,o.property),Object.assign(a,o.normal);return new ja(l,a,i)}function Df(t){return t.toLowerCase()}class yn{constructor(i,l){this.attribute=l,this.property=i}}yn.prototype.attribute="";yn.prototype.booleanish=!1;yn.prototype.boolean=!1;yn.prototype.commaOrSpaceSeparated=!1;yn.prototype.commaSeparated=!1;yn.prototype.defined=!1;yn.prototype.mustUseProperty=!1;yn.prototype.number=!1;yn.prototype.overloadedBoolean=!1;yn.prototype.property="";yn.prototype.spaceSeparated=!1;yn.prototype.space=void 0;let mw=0;const Ie=vr(),Qt=vr(),Mf=vr(),xe=vr(),At=vr(),pr=vr(),Cn=vr();function vr(){return 2**++mw}const _f=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:Qt,commaOrSpaceSeparated:Cn,commaSeparated:pr,number:xe,overloadedBoolean:Mf,spaceSeparated:At},Symbol.toStringTag,{value:"Module"})),uf=Object.keys(_f);class nd extends yn{constructor(i,l,a,o){let f=-1;if(super(i,l),hy(this,"space",o),typeof a=="number")for(;++f<uf.length;){const u=uf[f];hy(this,uf[f],(a&_f[u])===_f[u])}}}nd.prototype.defined=!0;function hy(t,i,l){l&&(t[i]=l)}function dl(t){const i={},l={};for(const[a,o]of Object.entries(t.properties)){const f=new nd(a,t.transform(t.attributes||{},a),o,t.space);t.mustUseProperty&&t.mustUseProperty.includes(a)&&(f.mustUseProperty=!0),i[a]=f,l[Df(a)]=a,l[Df(f.attribute)]=a}return new ja(i,l,t.space)}const Nb=dl({properties:{ariaActiveDescendant:null,ariaAtomic:Qt,ariaAutoComplete:null,ariaBusy:Qt,ariaChecked:Qt,ariaColCount:xe,ariaColIndex:xe,ariaColSpan:xe,ariaControls:At,ariaCurrent:null,ariaDescribedBy:At,ariaDetails:null,ariaDisabled:Qt,ariaDropEffect:At,ariaErrorMessage:null,ariaExpanded:Qt,ariaFlowTo:At,ariaGrabbed:Qt,ariaHasPopup:null,ariaHidden:Qt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:At,ariaLevel:xe,ariaLive:null,ariaModal:Qt,ariaMultiLine:Qt,ariaMultiSelectable:Qt,ariaOrientation:null,ariaOwns:At,ariaPlaceholder:null,ariaPosInSet:xe,ariaPressed:Qt,ariaReadOnly:Qt,ariaRelevant:null,ariaRequired:Qt,ariaRoleDescription:At,ariaRowCount:xe,ariaRowIndex:xe,ariaRowSpan:xe,ariaSelected:Qt,ariaSetSize:xe,ariaSort:null,ariaValueMax:xe,ariaValueMin:xe,ariaValueNow:xe,ariaValueText:null,role:null},transform(t,i){return i==="role"?i:"aria-"+i.slice(4).toLowerCase()}});function Ab(t,i){return i in t?t[i]:i}function Tb(t,i){return Ab(t,i.toLowerCase())}const gw=dl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:pr,acceptCharset:At,accessKey:At,action:null,allow:null,allowFullScreen:Ie,allowPaymentRequest:Ie,allowUserMedia:Ie,alpha:Ie,alt:null,as:null,async:Ie,autoCapitalize:null,autoComplete:At,autoFocus:Ie,autoPlay:Ie,blocking:At,capture:null,charSet:null,checked:Ie,cite:null,className:At,closedBy:null,colorSpace:null,cols:xe,colSpan:xe,command:null,commandFor:null,content:null,contentEditable:Qt,controls:Ie,controlsList:At,coords:xe|pr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ie,defer:Ie,dir:null,dirName:null,disabled:Ie,download:Mf,draggable:Qt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ie,formTarget:null,headers:At,height:xe,hidden:Mf,high:xe,href:null,hrefLang:null,htmlFor:At,httpEquiv:At,id:null,imageSizes:null,imageSrcSet:null,inert:Ie,inputMode:null,integrity:null,is:null,isMap:Ie,itemId:null,itemProp:At,itemRef:At,itemScope:Ie,itemType:At,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ie,low:xe,manifest:null,max:null,maxLength:xe,media:null,method:null,min:null,minLength:xe,multiple:Ie,muted:Ie,name:null,nonce:null,noModule:Ie,noValidate:Ie,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:Ie,optimum:xe,pattern:null,ping:At,placeholder:null,playsInline:Ie,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ie,referrerPolicy:null,rel:At,required:Ie,reversed:Ie,rows:xe,rowSpan:xe,sandbox:At,scope:null,scoped:Ie,seamless:Ie,selected:Ie,shadowRootClonable:Ie,shadowRootCustomElementRegistry:Ie,shadowRootDelegatesFocus:Ie,shadowRootMode:null,shadowRootSerializable:Ie,shape:null,size:xe,sizes:null,slot:null,span:xe,spellCheck:Qt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:xe,step:null,style:null,tabIndex:xe,target:null,title:null,translate:null,type:null,typeMustMatch:Ie,useMap:null,value:Qt,width:xe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:At,axis:null,background:null,bgColor:null,border:xe,borderColor:null,bottomMargin:xe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ie,declare:Ie,event:null,face:null,frame:null,frameBorder:null,hSpace:xe,leftMargin:xe,link:null,longDesc:null,lowSrc:null,marginHeight:xe,marginWidth:xe,noResize:Ie,noHref:Ie,noShade:Ie,noWrap:Ie,object:null,profile:null,prompt:null,rev:null,rightMargin:xe,rules:null,scheme:null,scrolling:Qt,standby:null,summary:null,text:null,topMargin:xe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:xe,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ie,disablePictureInPicture:Ie,disableRemotePlayback:Ie,exportParts:pr,part:At,prefix:null,property:null,results:xe,security:null,unselectable:null},space:"html",transform:Tb}),yw=dl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Cn,accentHeight:xe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:xe,amplitude:xe,arabicForm:null,ascent:xe,attributeName:null,attributeType:null,azimuth:xe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:xe,by:null,calcMode:null,capHeight:xe,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:xe,diffuseConstant:xe,direction:null,display:null,dur:null,divisor:xe,dominantBaseline:null,download:Ie,dx:null,dy:null,edgeMode:null,editable:null,elevation:xe,enableBackground:null,end:null,event:null,exponent:xe,externalResourcesRequired:null,fill:null,fillOpacity:xe,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:pr,g2:pr,glyphName:pr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:xe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:xe,horizOriginX:xe,horizOriginY:xe,id:null,ideographic:xe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:xe,k:xe,k1:xe,k2:xe,k3:xe,k4:xe,kernelMatrix:Cn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:xe,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:xe,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:xe,overlineThickness:xe,paintOrder:null,panose1:null,path:null,pathLength:xe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:At,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:xe,pointsAtY:xe,pointsAtZ:xe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Cn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Cn,rev:Cn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Cn,requiredFeatures:Cn,requiredFonts:Cn,requiredFormats:Cn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:xe,specularExponent:xe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:xe,strikethroughThickness:xe,string:null,stroke:null,strokeDashArray:Cn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:xe,strokeOpacity:xe,strokeWidth:null,style:null,surfaceScale:xe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Cn,tabIndex:xe,tableValues:null,target:null,targetX:xe,targetY:xe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Cn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:xe,underlineThickness:xe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:xe,values:null,vAlphabetic:xe,vMathematical:xe,vectorEffect:null,vHanging:xe,vIdeographic:xe,version:null,vertAdvY:xe,vertOriginX:xe,vertOriginY:xe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:xe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ab}),zb=dl({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()}}),Rb=dl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Tb}),Db=dl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,i){return"xml:"+i.slice(3).toLowerCase()}}),bw={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"},vw=/[A-Z]/g,py=/-[a-z]/g,xw=/^data[-\w.:]+$/i;function Sw(t,i){const l=Df(i);let a=i,o=yn;if(l in t.normal)return t.property[t.normal[l]];if(l.length>4&&l.slice(0,4)==="data"&&xw.test(i)){if(i.charAt(4)==="-"){const f=i.slice(5).replace(py,jw);a="data"+f.charAt(0).toUpperCase()+f.slice(1)}else{const f=i.slice(4);if(!py.test(f)){let u=f.replace(vw,ww);u.charAt(0)!=="-"&&(u="-"+u),i="data"+u}}o=nd}return new o(a,i)}function ww(t){return"-"+t.toLowerCase()}function jw(t){return t.charAt(1).toUpperCase()}const kw=Eb([Nb,gw,zb,Rb,Db],"html"),id=Eb([Nb,yw,zb,Rb,Db],"svg");function Cw(t){return t.join(" ").trim()}var sl={},cf,my;function Ew(){if(my)return cf;my=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,l=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,f=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,p=/^\s+|\s+$/g,h=`
29
+ `,m="/",y="*",b="",v="comment",x="declaration";function k(D,R){if(typeof D!="string")throw new TypeError("First argument must be a string");if(!D)return[];R=R||{};var z=1,L=1;function G(ee){var W=ee.match(i);W&&(z+=W.length);var N=ee.lastIndexOf(h);L=~N?ee.length-N:L+ee.length}function ae(){var ee={line:z,column:L};return function(W){return W.position=new T(ee),q(),W}}function T(ee){this.start=ee,this.end={line:z,column:L},this.source=R.source}T.prototype.content=D;function V(ee){var W=new Error(R.source+":"+z+":"+L+": "+ee);if(W.reason=ee,W.filename=R.source,W.line=z,W.column=L,W.source=D,!R.silent)throw W}function $(ee){var W=ee.exec(D);if(W){var N=W[0];return G(N),D=D.slice(N.length),W}}function q(){$(l)}function E(ee){var W;for(ee=ee||[];W=B();)W!==!1&&ee.push(W);return ee}function B(){var ee=ae();if(!(m!=D.charAt(0)||y!=D.charAt(1))){for(var W=2;b!=D.charAt(W)&&(y!=D.charAt(W)||m!=D.charAt(W+1));)++W;if(W+=2,b===D.charAt(W-1))return V("End of comment missing");var N=D.slice(2,W-2);return L+=2,G(N),D=D.slice(W),L+=2,ee({type:v,comment:N})}}function H(){var ee=ae(),W=$(a);if(W){if(B(),!$(o))return V("property missing ':'");var N=$(f),X=ee({type:x,property:_(W[0].replace(t,b)),value:N?_(N[0].replace(t,b)):b});return $(u),X}}function Z(){var ee=[];E(ee);for(var W;W=H();)W!==!1&&(ee.push(W),E(ee));return ee}return q(),Z()}function _(D){return D?D.replace(p,b):b}return cf=k,cf}var gy;function Nw(){if(gy)return sl;gy=1;var t=sl&&sl.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(sl,"__esModule",{value:!0}),sl.default=l;const i=t(Ew());function l(a,o){let f=null;if(!a||typeof a!="string")return f;const u=(0,i.default)(a),p=typeof o=="function";return u.forEach(h=>{if(h.type!=="declaration")return;const{property:m,value:y}=h;p?o(m,y,h):y&&(f=f||{},f[m]=y)}),f}return sl}var ua={},yy;function Aw(){if(yy)return ua;yy=1,Object.defineProperty(ua,"__esModule",{value:!0}),ua.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,i=/-([a-z])/g,l=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,f=function(m){return!m||l.test(m)||t.test(m)},u=function(m,y){return y.toUpperCase()},p=function(m,y){return"".concat(y,"-")},h=function(m,y){return y===void 0&&(y={}),f(m)?m:(m=m.toLowerCase(),y.reactCompat?m=m.replace(o,p):m=m.replace(a,p),m.replace(i,u))};return ua.camelCase=h,ua}var ca,by;function Tw(){if(by)return ca;by=1;var t=ca&&ca.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},i=t(Nw()),l=Aw();function a(o,f){var u={};return!o||typeof o!="string"||(0,i.default)(o,function(p,h){p&&h&&(u[(0,l.camelCase)(p,f)]=h)}),u}return a.default=a,ca=a,ca}var zw=Tw();const Rw=ao(zw),Mb=_b("end"),rd=_b("start");function _b(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 Dw(t){const i=rd(t),l=Mb(t);if(i&&l)return{start:i,end:l}}function pa(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?vy(t.position):"start"in t||"end"in t?vy(t):"line"in t||"column"in t?Of(t):""}function Of(t){return xy(t&&t.line)+":"+xy(t&&t.column)}function vy(t){return Of(t&&t.start)+"-"+Of(t&&t.end)}function xy(t){return t&&typeof t=="number"?t:1}class rn 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 p=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=p?p.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=p?p.line:void 0,this.name=pa(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}}rn.prototype.file="";rn.prototype.name="";rn.prototype.reason="";rn.prototype.message="";rn.prototype.stack="";rn.prototype.column=void 0;rn.prototype.line=void 0;rn.prototype.ancestors=void 0;rn.prototype.cause=void 0;rn.prototype.fatal=void 0;rn.prototype.place=void 0;rn.prototype.ruleId=void 0;rn.prototype.source=void 0;const ld={}.hasOwnProperty,Mw=new Map,_w=/[A-Z]/g,Ow=new Set(["table","tbody","thead","tfoot","tr"]),Lw=new Set(["td","th"]),Ob="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Bw(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=Fw(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=Gw(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"?id:kw,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:i.tableCellAlignToStyle!==!1},f=Lb(o,t,void 0);return f&&typeof f!="string"?f:o.create(t,o.Fragment,{children:f||void 0},void 0)}function Lb(t,i,l){if(i.type==="element")return Uw(t,i,l);if(i.type==="mdxFlowExpression"||i.type==="mdxTextExpression")return qw(t,i);if(i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement")return Hw(t,i,l);if(i.type==="mdxjsEsm")return Iw(t,i);if(i.type==="root")return Vw(t,i,l);if(i.type==="text")return Yw(t,i)}function Uw(t,i,l){const a=t.schema;let o=a;i.tagName.toLowerCase()==="svg"&&a.space==="html"&&(o=id,t.schema=o),t.ancestors.push(i);const f=Ub(t,i.tagName,!1),u=Qw(t,i);let p=sd(t,i);return Ow.has(i.tagName)&&(p=p.filter(function(h){return typeof h=="string"?!pw(h):!0})),Bb(t,u,f,i),ad(u,p),t.ancestors.pop(),t.schema=a,t.create(i,f,u,l)}function qw(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)}va(t,i.position)}function Iw(t,i){if(i.data&&i.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(i.data.estree);va(t,i.position)}function Hw(t,i,l){const a=t.schema;let o=a;i.name==="svg"&&a.space==="html"&&(o=id,t.schema=o),t.ancestors.push(i);const f=i.name===null?t.Fragment:Ub(t,i.name,!0),u=$w(t,i),p=sd(t,i);return Bb(t,u,f,i),ad(u,p),t.ancestors.pop(),t.schema=a,t.create(i,f,u,l)}function Vw(t,i,l){const a={};return ad(a,sd(t,i)),t.create(i,t.Fragment,a,l)}function Yw(t,i){return i.value}function Bb(t,i,l,a){typeof l!="string"&&l!==t.Fragment&&t.passNode&&(i.node=a)}function ad(t,i){if(i.length>0){const l=i.length>1?i:i[0];l&&(t.children=l)}}function Gw(t,i,l){return a;function a(o,f,u,p){const m=Array.isArray(u.children)?l:i;return p?m(f,u,p):m(f,u)}}function Fw(t,i){return l;function l(a,o,f,u){const p=Array.isArray(f.children),h=rd(a);return i(o,f,u,p,{columnNumber:h?h.column-1:void 0,fileName:t,lineNumber:h?h.line:void 0},void 0)}}function Qw(t,i){const l={};let a,o;for(o in i.properties)if(o!=="children"&&ld.call(i.properties,o)){const f=Xw(t,o,i.properties[o]);if(f){const[u,p]=f;t.tableCellAlignToStyle&&u==="align"&&typeof p=="string"&&Lw.has(i.tagName)?a=p:l[u]=p}}if(a){const f=l.style||(l.style={});f[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return l}function $w(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 p=u.properties[0];p.type,Object.assign(l,t.evaluater.evaluateExpression(p.argument))}else va(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 p=a.value.data.estree.body[0];p.type,f=t.evaluater.evaluateExpression(p.expression)}else va(t,i.position);else f=a.value===null?!0:a.value;l[o]=f}return l}function sd(t,i){const l=[];let a=-1;const o=t.passKeys?new Map:Mw;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 m=o.get(h)||0;u=h+"-"+m,o.set(h,m+1)}}const p=Lb(t,f,u);p!==void 0&&l.push(p)}return l}function Xw(t,i,l){const a=Sw(t.schema,i);if(!(l==null||typeof l=="number"&&Number.isNaN(l))){if(Array.isArray(l)&&(l=a.commaSeparated?uw(l):Cw(l)),a.property==="style"){let o=typeof l=="object"?l:Kw(t,String(l));return t.stylePropertyNameCase==="css"&&(o=Zw(o)),["style",o]}return[t.elementAttributeNameCase==="react"&&a.space?bw[a.property]||a.property:a.attribute,l]}}function Kw(t,i){try{return Rw(i,{reactCompat:!0})}catch(l){if(t.ignoreInvalidStyle)return{};const a=l,o=new rn("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=Ob+"#cannot-parse-style-attribute",o}}function Ub(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 p=fy(o[f])?{type:"Identifier",name:o[f]}:{type:"Literal",value:o[f]};u=u?{type:"MemberExpression",object:u,property:p,computed:!!(f&&p.type==="Literal"),optional:!1}:p}a=u}else a=fy(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};if(a.type==="Literal"){const o=a.value;return ld.call(t.components,o)?t.components[o]:o}if(t.evaluater)return t.evaluater.evaluateExpression(a);va(t)}function va(t,i){const l=new rn("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=Ob+"#cannot-handle-mdx-estrees-without-createevaluater",l}function Zw(t){const i={};let l;for(l in t)ld.call(t,l)&&(i[Pw(l)]=t[l]);return i}function Pw(t){let i=t.replace(_w,Jw);return i.slice(0,3)==="ms-"&&(i="-"+i),i}function Jw(t){return"-"+t.toLowerCase()}const ff={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"]},Ww={};function od(t,i){const l=Ww,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(ej(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 Sy(t.children,i,l)}return Array.isArray(t)?Sy(t,i,l):""}function Sy(t,i,l){const a=[];let o=-1;for(;++o<t.length;)a[o]=qb(t[o],i,l);return a.join("")}function ej(t){return!!(t&&typeof t=="object")}const wy=document.createElement("i");function ud(t){const i="&"+t+";";wy.innerHTML=i;const l=wy.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 jy={}.hasOwnProperty;function Ib(t){const i={};let l=-1;for(;++l<t.length;)tj(i,t[l]);return i}function tj(t,i){let l;for(l in i){const o=(jy.call(t,l)?t[l]:void 0)||(t[l]={}),f=i[l];let u;if(f)for(u in f){jy.call(o,u)||(o[u]=[]);const p=f[u];nj(o[u],Array.isArray(p)?p:p?[p]:[])}}}function nj(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 Hb(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 sn=$i(/[A-Za-z]/),nn=$i(/[\dA-Za-z]/),ij=$i(/[#-'*+\--9=?A-Z^-~]/);function no(t){return t!==null&&(t<32||t===127)}const Lf=$i(/\d/),rj=$i(/[\dA-Fa-f]/),lj=$i(/[!-/:-@[-`{-~]/);function Oe(t){return t!==null&&t<-2}function Tt(t){return t!==null&&(t<0||t===32)}function We(t){return t===-2||t===-1||t===32}const uo=$i(new RegExp("\\p{P}|\\p{S}","u")),mr=$i(/\s/);function $i(t){return i;function i(l){return l!==null&&l>-1&&t.test(String.fromCharCode(l))}}function hl(t){const i=[];let l=-1,a=0,o=0;for(;++l<t.length;){const f=t.charCodeAt(l);let u="";if(f===37&&nn(t.charCodeAt(l+1))&&nn(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 p=t.charCodeAt(l+1);f<56320&&p>56319&&p<57344?(u=String.fromCharCode(f,p),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 We(h)?(t.enter(l),p(h)):i(h)}function p(h){return We(h)&&f++<o?(t.consume(h),p):(t.exit(l),i(h))}}const aj={tokenize:sj};function sj(t){const i=t.attempt(this.parser.constructs.contentInitial,a,o);let l;return i;function a(p){if(p===null){t.consume(p);return}return t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),ot(t,i,"linePrefix")}function o(p){return t.enter("paragraph"),f(p)}function f(p){const h=t.enter("chunkText",{contentType:"text",previous:l});return l&&(l.next=h),l=h,u(p)}function u(p){if(p===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(p);return}return Oe(p)?(t.consume(p),t.exit("chunkText"),f):(t.consume(p),u)}}const oj={tokenize:uj},ky={tokenize:cj};function uj(t){const i=this,l=[];let a=0,o,f,u;return p;function p(L){if(a<l.length){const G=l[a];return i.containerState=G[1],t.attempt(G[0].continuation,h,m)(L)}return m(L)}function h(L){if(a++,i.containerState._closeFlow){i.containerState._closeFlow=void 0,o&&z();const G=i.events.length;let ae=G,T;for(;ae--;)if(i.events[ae][0]==="exit"&&i.events[ae][1].type==="chunkFlow"){T=i.events[ae][1].end;break}R(a);let V=G;for(;V<i.events.length;)i.events[V][1].end={...T},V++;return En(i.events,ae+1,0,i.events.slice(G)),i.events.length=V,m(L)}return p(L)}function m(L){if(a===l.length){if(!o)return v(L);if(o.currentConstruct&&o.currentConstruct.concrete)return k(L);i.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return i.containerState={},t.check(ky,y,b)(L)}function y(L){return o&&z(),R(a),v(L)}function b(L){return i.parser.lazy[i.now().line]=a!==l.length,u=i.now().offset,k(L)}function v(L){return i.containerState={},t.attempt(ky,x,k)(L)}function x(L){return a++,l.push([i.currentConstruct,i.containerState]),v(L)}function k(L){if(L===null){o&&z(),R(0),t.consume(L);return}return o=o||i.parser.flow(i.now()),t.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:f}),_(L)}function _(L){if(L===null){D(t.exit("chunkFlow"),!0),R(0),t.consume(L);return}return Oe(L)?(t.consume(L),D(t.exit("chunkFlow")),a=0,i.interrupt=void 0,p):(t.consume(L),_)}function D(L,G){const ae=i.sliceStream(L);if(G&&ae.push(null),L.previous=f,f&&(f.next=L),f=L,o.defineSkip(L.start),o.write(ae),i.parser.lazy[L.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 $=V,q,E;for(;$--;)if(i.events[$][0]==="exit"&&i.events[$][1].type==="chunkFlow"){if(q){E=i.events[$][1].end;break}q=!0}for(R(a),T=V;T<i.events.length;)i.events[T][1].end={...E},T++;En(i.events,$+1,0,i.events.slice(V)),i.events.length=T}}function R(L){let G=l.length;for(;G-- >L;){const ae=l[G];i.containerState=ae[1],ae[0].exit.call(i,t)}l.length=L}function z(){o.write([null]),f=void 0,o=void 0,i.containerState._closeFlow=void 0}}function cj(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 cl(t){if(t===null||Tt(t)||mr(t))return 1;if(uo(t))return 2}function co(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 Bf={name:"attention",resolveAll:fj,tokenize:dj};function fj(t,i){let l=-1,a,o,f,u,p,h,m,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},v={...t[l][1].start};Cy(b,-h),Cy(v,h),u={type:h>1?"strongSequence":"emphasisSequence",start:b,end:{...t[a][1].end}},p={type:h>1?"strongSequence":"emphasisSequence",start:{...t[l][1].start},end:v},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:{...p.end}},t[a][1].end={...u.start},t[l][1].start={...p.end},m=[],t[a][1].end.offset-t[a][1].start.offset&&(m=Bn(m,[["enter",t[a][1],i],["exit",t[a][1],i]])),m=Bn(m,[["enter",o,i],["enter",u,i],["exit",u,i],["enter",f,i]]),m=Bn(m,co(i.parser.constructs.insideSpan.null,t.slice(a+1,l),i)),m=Bn(m,[["exit",f,i],["enter",p,i],["exit",p,i],["exit",o,i]]),t[l][1].end.offset-t[l][1].start.offset?(y=2,m=Bn(m,[["enter",t[l][1],i],["exit",t[l][1],i]])):y=0,En(t,a-1,l-a+3,m),l=a+m.length-y-2;break}}for(l=-1;++l<t.length;)t[l][1].type==="attentionSequence"&&(t[l][1].type="data");return t}function dj(t,i){const l=this.parser.constructs.attentionMarkers.null,a=this.previous,o=cl(a);let f;return u;function u(h){return f=h,t.enter("attentionSequence"),p(h)}function p(h){if(h===f)return t.consume(h),p;const m=t.exit("attentionSequence"),y=cl(h),b=!y||y===2&&o||l.includes(h),v=!o||o===2&&y||l.includes(a);return m._open=!!(f===42?b:b&&(o||!v)),m._close=!!(f===42?v:v&&(y||!b)),i(h)}}function Cy(t,i){t.column+=i,t.offset+=i,t._bufferIndex+=i}const hj={name:"autolink",tokenize:pj};function pj(t,i,l){let a=0;return o;function o(x){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),f}function f(x){return sn(x)?(t.consume(x),u):x===64?l(x):m(x)}function u(x){return x===43||x===45||x===46||nn(x)?(a=1,p(x)):m(x)}function p(x){return x===58?(t.consume(x),a=0,h):(x===43||x===45||x===46||nn(x))&&a++<32?(t.consume(x),p):(a=0,m(x))}function h(x){return x===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.exit("autolink"),i):x===null||x===32||x===60||no(x)?l(x):(t.consume(x),h)}function m(x){return x===64?(t.consume(x),y):ij(x)?(t.consume(x),m):l(x)}function y(x){return nn(x)?b(x):l(x)}function b(x){return x===46?(t.consume(x),a=0,y):x===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.exit("autolink"),i):v(x)}function v(x){if((x===45||nn(x))&&a++<63){const k=x===45?v:b;return t.consume(x),k}return l(x)}}const ka={partial:!0,tokenize:mj};function mj(t,i,l){return a;function a(f){return We(f)?ot(t,o,"linePrefix")(f):o(f)}function o(f){return f===null||Oe(f)?i(f):l(f)}}const Vb={continuation:{tokenize:yj},exit:bj,name:"blockQuote",tokenize:gj};function gj(t,i,l){const a=this;return o;function o(u){if(u===62){const p=a.containerState;return p.open||(t.enter("blockQuote",{_container:!0}),p.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(u),t.exit("blockQuoteMarker"),f}return l(u)}function f(u){return We(u)?(t.enter("blockQuotePrefixWhitespace"),t.consume(u),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),i):(t.exit("blockQuotePrefix"),i(u))}}function yj(t,i,l){const a=this;return o;function o(u){return We(u)?ot(t,f,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):f(u)}function f(u){return t.attempt(Vb,i,l)(u)}}function bj(t){t.exit("blockQuote")}const Yb={name:"characterEscape",tokenize:vj};function vj(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 lj(f)?(t.enter("characterEscapeValue"),t.consume(f),t.exit("characterEscapeValue"),t.exit("characterEscape"),i):l(f)}}const Gb={name:"characterReference",tokenize:xj};function xj(t,i,l){const a=this;let o=0,f,u;return p;function p(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"),m):(t.enter("characterReferenceValue"),f=31,u=nn,y(b))}function m(b){return b===88||b===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(b),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),f=6,u=rj,y):(t.enter("characterReferenceValue"),f=7,u=Lf,y(b))}function y(b){if(b===59&&o){const v=t.exit("characterReferenceValue");return u===nn&&!ud(a.sliceSerialize(v))?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 Ey={partial:!0,tokenize:wj},Ny={concrete:!0,name:"codeFenced",tokenize:Sj};function Sj(t,i,l){const a=this,o={partial:!0,tokenize:ae};let f=0,u=0,p;return h;function h(T){return m(T)}function m(T){const V=a.events[a.events.length-1];return f=V&&V[1].type==="linePrefix"?V[2].sliceSerialize(V[1],!0).length:0,p=T,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),y(T)}function y(T){return T===p?(u++,t.consume(T),y):u<3?l(T):(t.exit("codeFencedFenceSequence"),We(T)?ot(t,b,"whitespace")(T):b(T))}function b(T){return T===null||Oe(T)?(t.exit("codeFencedFence"),a.interrupt?i(T):t.check(Ey,_,G)(T)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),v(T))}function v(T){return T===null||Oe(T)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),b(T)):We(T)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),ot(t,x,"whitespace")(T)):T===96&&T===p?l(T):(t.consume(T),v)}function x(T){return T===null||Oe(T)?b(T):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),k(T))}function k(T){return T===null||Oe(T)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),b(T)):T===96&&T===p?l(T):(t.consume(T),k)}function _(T){return t.attempt(o,G,D)(T)}function D(T){return t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),R}function R(T){return f>0&&We(T)?ot(t,z,"linePrefix",f+1)(T):z(T)}function z(T){return T===null||Oe(T)?t.check(Ey,_,G)(T):(t.enter("codeFlowValue"),L(T))}function L(T){return T===null||Oe(T)?(t.exit("codeFlowValue"),z(T)):(t.consume(T),L)}function G(T){return t.exit("codeFenced"),i(T)}function ae(T,V,$){let q=0;return E;function E(W){return T.enter("lineEnding"),T.consume(W),T.exit("lineEnding"),B}function B(W){return T.enter("codeFencedFence"),We(W)?ot(T,H,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):H(W)}function H(W){return W===p?(T.enter("codeFencedFenceSequence"),Z(W)):$(W)}function Z(W){return W===p?(q++,T.consume(W),Z):q>=u?(T.exit("codeFencedFenceSequence"),We(W)?ot(T,ee,"whitespace")(W):ee(W)):$(W)}function ee(W){return W===null||Oe(W)?(T.exit("codeFencedFence"),V(W)):$(W)}}}function wj(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 df={name:"codeIndented",tokenize:kj},jj={partial:!0,tokenize:Cj};function kj(t,i,l){const a=this;return o;function o(m){return t.enter("codeIndented"),ot(t,f,"linePrefix",5)(m)}function f(m){const y=a.events[a.events.length-1];return y&&y[1].type==="linePrefix"&&y[2].sliceSerialize(y[1],!0).length>=4?u(m):l(m)}function u(m){return m===null?h(m):Oe(m)?t.attempt(jj,u,h)(m):(t.enter("codeFlowValue"),p(m))}function p(m){return m===null||Oe(m)?(t.exit("codeFlowValue"),u(m)):(t.consume(m),p)}function h(m){return t.exit("codeIndented"),i(m)}}function Cj(t,i,l){const a=this;return o;function o(u){return a.parser.lazy[a.now().line]?l(u):Oe(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),o):ot(t,f,"linePrefix",5)(u)}function f(u){const p=a.events[a.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?i(u):Oe(u)?o(u):l(u)}}const Ej={name:"codeText",previous:Aj,resolve:Nj,tokenize:Tj};function Nj(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 Aj(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Tj(t,i,l){let a=0,o,f;return u;function u(b){return t.enter("codeText"),t.enter("codeTextSequence"),p(b)}function p(b){return b===96?(t.consume(b),a++,p):(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)):Oe(b)?(t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),h):(t.enter("codeTextData"),m(b))}function m(b){return b===null||b===32||b===96||Oe(b)?(t.exit("codeTextData"),h(b)):(t.consume(b),m)}function y(b){return b===96?(t.consume(b),o++,y):o===a?(t.exit("codeTextSequence"),t.exit("codeText"),i(b)):(f.type="codeTextData",m(b))}}class zj{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&&fa(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),fa(this.left,i)}unshift(i){this.setCursor(0),this.right.push(i)}unshiftMany(i){this.setCursor(0),fa(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);fa(this.right,l.reverse())}else{const l=this.right.splice(this.left.length+this.right.length-i,Number.POSITIVE_INFINITY);fa(this.left,l.reverse())}}}function fa(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 Fb(t){const i={};let l=-1,a,o,f,u,p,h,m;const y=new zj(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,Rj(y,l)),l=i[l],m=!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},p=y.slice(o,l),p.unshift(a),y.splice(o,l-o+1,p))}}return En(t,0,Number.POSITIVE_INFINITY,y.slice(0)),!m}function Rj(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 p=u.events,h=[],m={};let y,b,v=-1,x=l,k=0,_=0;const D=[_];for(;x;){for(;t.get(++o)[1]!==x;);f.push(o),x._tokenizer||(y=a.sliceStream(x),x.next||y.push(null),b&&u.defineSkip(x.start),x._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(y),x._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),b=x,x=x.next}for(x=l;++v<p.length;)p[v][0]==="exit"&&p[v-1][0]==="enter"&&p[v][1].type===p[v-1][1].type&&p[v][1].start.line!==p[v][1].end.line&&(_=v+1,D.push(_),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(u.events=[],x?(x._tokenizer=void 0,x.previous=void 0):D.pop(),v=D.length;v--;){const R=p.slice(D[v],D[v+1]),z=f.pop();h.push([z,z+R.length-1]),t.splice(z,2,R)}for(h.reverse(),v=-1;++v<h.length;)m[k+h[v][0]]=k+h[v][1],k+=h[v][1]-h[v][0]-1;return m}const Dj={resolve:_j,tokenize:Oj},Mj={partial:!0,tokenize:Lj};function _j(t){return Fb(t),t}function Oj(t,i){let l;return a;function a(p){return t.enter("content"),l=t.enter("chunkContent",{contentType:"content"}),o(p)}function o(p){return p===null?f(p):Oe(p)?t.check(Mj,u,f)(p):(t.consume(p),o)}function f(p){return t.exit("chunkContent"),t.exit("content"),i(p)}function u(p){return t.consume(p),t.exit("chunkContent"),l.next=t.enter("chunkContent",{contentType:"content",previous:l}),l=l.next,o}}function Lj(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||Oe(u))return l(u);const p=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?i(u):t.interrupt(a.parser.constructs.flow,l,i)(u)}}function Qb(t,i,l,a,o,f,u,p,h){const m=h||Number.POSITIVE_INFINITY;let y=0;return b;function b(R){return R===60?(t.enter(a),t.enter(o),t.enter(f),t.consume(R),t.exit(f),v):R===null||R===32||R===41||no(R)?l(R):(t.enter(a),t.enter(u),t.enter(p),t.enter("chunkString",{contentType:"string"}),_(R))}function v(R){return R===62?(t.enter(f),t.consume(R),t.exit(f),t.exit(o),t.exit(a),i):(t.enter(p),t.enter("chunkString",{contentType:"string"}),x(R))}function x(R){return R===62?(t.exit("chunkString"),t.exit(p),v(R)):R===null||R===60||Oe(R)?l(R):(t.consume(R),R===92?k:x)}function k(R){return R===60||R===62||R===92?(t.consume(R),x):x(R)}function _(R){return!y&&(R===null||R===41||Tt(R))?(t.exit("chunkString"),t.exit(p),t.exit(u),t.exit(a),i(R)):y<m&&R===40?(t.consume(R),y++,_):R===41?(t.consume(R),y--,_):R===null||R===32||R===40||no(R)?l(R):(t.consume(R),R===92?D:_)}function D(R){return R===40||R===41||R===92?(t.consume(R),_):_(R)}}function $b(t,i,l,a,o,f){const u=this;let p=0,h;return m;function m(x){return t.enter(a),t.enter(o),t.consume(x),t.exit(o),t.enter(f),y}function y(x){return p>999||x===null||x===91||x===93&&!h||x===94&&!p&&"_hiddenFootnoteSupport"in u.parser.constructs?l(x):x===93?(t.exit(f),t.enter(o),t.consume(x),t.exit(o),t.exit(a),i):Oe(x)?(t.enter("lineEnding"),t.consume(x),t.exit("lineEnding"),y):(t.enter("chunkString",{contentType:"string"}),b(x))}function b(x){return x===null||x===91||x===93||Oe(x)||p++>999?(t.exit("chunkString"),y(x)):(t.consume(x),h||(h=!We(x)),x===92?v:b)}function v(x){return x===91||x===92||x===93?(t.consume(x),p++,b):b(x)}}function Xb(t,i,l,a,o,f){let u;return p;function p(v){return v===34||v===39||v===40?(t.enter(a),t.enter(o),t.consume(v),t.exit(o),u=v===40?41:v,h):l(v)}function h(v){return v===u?(t.enter(o),t.consume(v),t.exit(o),t.exit(a),i):(t.enter(f),m(v))}function m(v){return v===u?(t.exit(f),h(u)):v===null?l(v):Oe(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),ot(t,m,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),y(v))}function y(v){return v===u||v===null||Oe(v)?(t.exit("chunkString"),m(v)):(t.consume(v),v===92?b:y)}function b(v){return v===u||v===92?(t.consume(v),y):y(v)}}function ma(t,i){let l;return a;function a(o){return Oe(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),l=!0,a):We(o)?ot(t,a,l?"linePrefix":"lineSuffix")(o):i(o)}}const Bj={name:"definition",tokenize:qj},Uj={partial:!0,tokenize:Ij};function qj(t,i,l){const a=this;let o;return f;function f(x){return t.enter("definition"),u(x)}function u(x){return $b.call(a,t,p,l,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function p(x){return o=Yn(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),x===58?(t.enter("definitionMarker"),t.consume(x),t.exit("definitionMarker"),h):l(x)}function h(x){return Tt(x)?ma(t,m)(x):m(x)}function m(x){return Qb(t,y,l,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function y(x){return t.attempt(Uj,b,b)(x)}function b(x){return We(x)?ot(t,v,"whitespace")(x):v(x)}function v(x){return x===null||Oe(x)?(t.exit("definition"),a.parser.defined.push(o),i(x)):l(x)}}function Ij(t,i,l){return a;function a(p){return Tt(p)?ma(t,o)(p):l(p)}function o(p){return Xb(t,f,l,"definitionTitle","definitionTitleMarker","definitionTitleString")(p)}function f(p){return We(p)?ot(t,u,"whitespace")(p):u(p)}function u(p){return p===null||Oe(p)?i(p):l(p)}}const Hj={name:"hardBreakEscape",tokenize:Vj};function Vj(t,i,l){return a;function a(f){return t.enter("hardBreakEscape"),t.consume(f),o}function o(f){return Oe(f)?(t.exit("hardBreakEscape"),i(f)):l(f)}}const Yj={name:"headingAtx",resolve:Gj,tokenize:Fj};function Gj(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 Fj(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"),p(y)):l(y)}function p(y){return y===35?(t.enter("atxHeadingSequence"),h(y)):y===null||Oe(y)?(t.exit("atxHeading"),i(y)):We(y)?ot(t,p,"whitespace")(y):(t.enter("atxHeadingText"),m(y))}function h(y){return y===35?(t.consume(y),h):(t.exit("atxHeadingSequence"),p(y))}function m(y){return y===null||y===35||Tt(y)?(t.exit("atxHeadingText"),p(y)):(t.consume(y),m)}}const Qj=["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"],Ay=["pre","script","style","textarea"],$j={concrete:!0,name:"htmlFlow",resolveTo:Zj,tokenize:Pj},Xj={partial:!0,tokenize:Wj},Kj={partial:!0,tokenize:Jj};function Zj(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 Pj(t,i,l){const a=this;let o,f,u,p,h;return m;function m(A){return y(A)}function y(A){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(A),b}function b(A){return A===33?(t.consume(A),v):A===47?(t.consume(A),f=!0,_):A===63?(t.consume(A),o=3,a.interrupt?i:j):sn(A)?(t.consume(A),u=String.fromCharCode(A),D):l(A)}function v(A){return A===45?(t.consume(A),o=2,x):A===91?(t.consume(A),o=5,p=0,k):sn(A)?(t.consume(A),o=4,a.interrupt?i:j):l(A)}function x(A){return A===45?(t.consume(A),a.interrupt?i:j):l(A)}function k(A){const le="CDATA[";return A===le.charCodeAt(p++)?(t.consume(A),p===le.length?a.interrupt?i:H:k):l(A)}function _(A){return sn(A)?(t.consume(A),u=String.fromCharCode(A),D):l(A)}function D(A){if(A===null||A===47||A===62||Tt(A)){const le=A===47,me=u.toLowerCase();return!le&&!f&&Ay.includes(me)?(o=1,a.interrupt?i(A):H(A)):Qj.includes(u.toLowerCase())?(o=6,le?(t.consume(A),R):a.interrupt?i(A):H(A)):(o=7,a.interrupt&&!a.parser.lazy[a.now().line]?l(A):f?z(A):L(A))}return A===45||nn(A)?(t.consume(A),u+=String.fromCharCode(A),D):l(A)}function R(A){return A===62?(t.consume(A),a.interrupt?i:H):l(A)}function z(A){return We(A)?(t.consume(A),z):E(A)}function L(A){return A===47?(t.consume(A),E):A===58||A===95||sn(A)?(t.consume(A),G):We(A)?(t.consume(A),L):E(A)}function G(A){return A===45||A===46||A===58||A===95||nn(A)?(t.consume(A),G):ae(A)}function ae(A){return A===61?(t.consume(A),T):We(A)?(t.consume(A),ae):L(A)}function T(A){return A===null||A===60||A===61||A===62||A===96?l(A):A===34||A===39?(t.consume(A),h=A,V):We(A)?(t.consume(A),T):$(A)}function V(A){return A===h?(t.consume(A),h=null,q):A===null||Oe(A)?l(A):(t.consume(A),V)}function $(A){return A===null||A===34||A===39||A===47||A===60||A===61||A===62||A===96||Tt(A)?ae(A):(t.consume(A),$)}function q(A){return A===47||A===62||We(A)?L(A):l(A)}function E(A){return A===62?(t.consume(A),B):l(A)}function B(A){return A===null||Oe(A)?H(A):We(A)?(t.consume(A),B):l(A)}function H(A){return A===45&&o===2?(t.consume(A),N):A===60&&o===1?(t.consume(A),X):A===62&&o===4?(t.consume(A),O):A===63&&o===3?(t.consume(A),j):A===93&&o===5?(t.consume(A),ye):Oe(A)&&(o===6||o===7)?(t.exit("htmlFlowData"),t.check(Xj,J,Z)(A)):A===null||Oe(A)?(t.exit("htmlFlowData"),Z(A)):(t.consume(A),H)}function Z(A){return t.check(Kj,ee,J)(A)}function ee(A){return t.enter("lineEnding"),t.consume(A),t.exit("lineEnding"),W}function W(A){return A===null||Oe(A)?Z(A):(t.enter("htmlFlowData"),H(A))}function N(A){return A===45?(t.consume(A),j):H(A)}function X(A){return A===47?(t.consume(A),u="",pe):H(A)}function pe(A){if(A===62){const le=u.toLowerCase();return Ay.includes(le)?(t.consume(A),O):H(A)}return sn(A)&&u.length<8?(t.consume(A),u+=String.fromCharCode(A),pe):H(A)}function ye(A){return A===93?(t.consume(A),j):H(A)}function j(A){return A===62?(t.consume(A),O):A===45&&o===2?(t.consume(A),j):H(A)}function O(A){return A===null||Oe(A)?(t.exit("htmlFlowData"),J(A)):(t.consume(A),O)}function J(A){return t.exit("htmlFlow"),i(A)}}function Jj(t,i,l){const a=this;return o;function o(u){return Oe(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 Wj(t,i,l){return a;function a(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),t.attempt(ka,i,l)}}const ek={name:"htmlText",tokenize:tk};function tk(t,i,l){const a=this;let o,f,u;return p;function p(j){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(j),h}function h(j){return j===33?(t.consume(j),m):j===47?(t.consume(j),ae):j===63?(t.consume(j),L):sn(j)?(t.consume(j),$):l(j)}function m(j){return j===45?(t.consume(j),y):j===91?(t.consume(j),f=0,k):sn(j)?(t.consume(j),z):l(j)}function y(j){return j===45?(t.consume(j),x):l(j)}function b(j){return j===null?l(j):j===45?(t.consume(j),v):Oe(j)?(u=b,X(j)):(t.consume(j),b)}function v(j){return j===45?(t.consume(j),x):b(j)}function x(j){return j===62?N(j):j===45?v(j):b(j)}function k(j){const O="CDATA[";return j===O.charCodeAt(f++)?(t.consume(j),f===O.length?_:k):l(j)}function _(j){return j===null?l(j):j===93?(t.consume(j),D):Oe(j)?(u=_,X(j)):(t.consume(j),_)}function D(j){return j===93?(t.consume(j),R):_(j)}function R(j){return j===62?N(j):j===93?(t.consume(j),R):_(j)}function z(j){return j===null||j===62?N(j):Oe(j)?(u=z,X(j)):(t.consume(j),z)}function L(j){return j===null?l(j):j===63?(t.consume(j),G):Oe(j)?(u=L,X(j)):(t.consume(j),L)}function G(j){return j===62?N(j):L(j)}function ae(j){return sn(j)?(t.consume(j),T):l(j)}function T(j){return j===45||nn(j)?(t.consume(j),T):V(j)}function V(j){return Oe(j)?(u=V,X(j)):We(j)?(t.consume(j),V):N(j)}function $(j){return j===45||nn(j)?(t.consume(j),$):j===47||j===62||Tt(j)?q(j):l(j)}function q(j){return j===47?(t.consume(j),N):j===58||j===95||sn(j)?(t.consume(j),E):Oe(j)?(u=q,X(j)):We(j)?(t.consume(j),q):N(j)}function E(j){return j===45||j===46||j===58||j===95||nn(j)?(t.consume(j),E):B(j)}function B(j){return j===61?(t.consume(j),H):Oe(j)?(u=B,X(j)):We(j)?(t.consume(j),B):q(j)}function H(j){return j===null||j===60||j===61||j===62||j===96?l(j):j===34||j===39?(t.consume(j),o=j,Z):Oe(j)?(u=H,X(j)):We(j)?(t.consume(j),H):(t.consume(j),ee)}function Z(j){return j===o?(t.consume(j),o=void 0,W):j===null?l(j):Oe(j)?(u=Z,X(j)):(t.consume(j),Z)}function ee(j){return j===null||j===34||j===39||j===60||j===61||j===96?l(j):j===47||j===62||Tt(j)?q(j):(t.consume(j),ee)}function W(j){return j===47||j===62||Tt(j)?q(j):l(j)}function N(j){return j===62?(t.consume(j),t.exit("htmlTextData"),t.exit("htmlText"),i):l(j)}function X(j){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(j),t.exit("lineEnding"),pe}function pe(j){return We(j)?ot(t,ye,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):ye(j)}function ye(j){return t.enter("htmlTextData"),u(j)}}const cd={name:"labelEnd",resolveAll:lk,resolveTo:ak,tokenize:sk},nk={tokenize:ok},ik={tokenize:uk},rk={tokenize:ck};function lk(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 ak(t,i){let l=t.length,a=0,o,f,u,p;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}},m={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 p=[["enter",h,i],["enter",m,i]],p=Bn(p,t.slice(f+1,f+a+3)),p=Bn(p,[["enter",y,i]]),p=Bn(p,co(i.parser.constructs.insideSpan.null,t.slice(f+a+4,u-3),i)),p=Bn(p,[["exit",y,i],t[u-2],t[u-1],["exit",m,i]]),p=Bn(p,t.slice(u+1)),p=Bn(p,[["exit",h,i]]),En(t,f,t.length,p),t}function sk(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 p;function p(v){return f?f._inactive?b(v):(u=a.parser.defined.includes(Yn(a.sliceSerialize({start:f.end,end:a.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(v),t.exit("labelMarker"),t.exit("labelEnd"),h):l(v)}function h(v){return v===40?t.attempt(nk,y,u?y:b)(v):v===91?t.attempt(ik,y,u?m:b)(v):u?y(v):b(v)}function m(v){return t.attempt(rk,y,b)(v)}function y(v){return i(v)}function b(v){return f._balanced=!0,l(v)}}function ok(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)?ma(t,f)(b):f(b)}function f(b){return b===41?y(b):Qb(t,u,p,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function u(b){return Tt(b)?ma(t,h)(b):y(b)}function p(b){return l(b)}function h(b){return b===34||b===39||b===40?Xb(t,m,l,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):y(b)}function m(b){return Tt(b)?ma(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 uk(t,i,l){const a=this;return o;function o(p){return $b.call(a,t,f,u,"reference","referenceMarker","referenceString")(p)}function f(p){return a.parser.defined.includes(Yn(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?i(p):l(p)}function u(p){return l(p)}}function ck(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 fk={name:"labelStartImage",resolveAll:cd.resolveAll,tokenize:dk};function dk(t,i,l){const a=this;return o;function o(p){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(p),t.exit("labelImageMarker"),f}function f(p){return p===91?(t.enter("labelMarker"),t.consume(p),t.exit("labelMarker"),t.exit("labelImage"),u):l(p)}function u(p){return p===94&&"_hiddenFootnoteSupport"in a.parser.constructs?l(p):i(p)}}const hk={name:"labelStartLink",resolveAll:cd.resolveAll,tokenize:pk};function pk(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 hf={name:"lineEnding",tokenize:mk};function mk(t,i){return l;function l(a){return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),ot(t,i,"linePrefix")}}const Ps={name:"thematicBreak",tokenize:gk};function gk(t,i,l){let a=0,o;return f;function f(m){return t.enter("thematicBreak"),u(m)}function u(m){return o=m,p(m)}function p(m){return m===o?(t.enter("thematicBreakSequence"),h(m)):a>=3&&(m===null||Oe(m))?(t.exit("thematicBreak"),i(m)):l(m)}function h(m){return m===o?(t.consume(m),a++,h):(t.exit("thematicBreakSequence"),We(m)?ot(t,p,"whitespace")(m):p(m))}}const mn={continuation:{tokenize:xk},exit:wk,name:"list",tokenize:vk},yk={partial:!0,tokenize:jk},bk={partial:!0,tokenize:Sk};function vk(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 p;function p(x){const k=a.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!a.containerState.marker||x===a.containerState.marker:Lf(x)){if(a.containerState.type||(a.containerState.type=k,t.enter(k,{_container:!0})),k==="listUnordered")return t.enter("listItemPrefix"),x===42||x===45?t.check(Ps,l,m)(x):m(x);if(!a.interrupt||x===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),h(x)}return l(x)}function h(x){return Lf(x)&&++u<10?(t.consume(x),h):(!a.interrupt||u<2)&&(a.containerState.marker?x===a.containerState.marker:x===41||x===46)?(t.exit("listItemValue"),m(x)):l(x)}function m(x){return t.enter("listItemMarker"),t.consume(x),t.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||x,t.check(ka,a.interrupt?l:y,t.attempt(yk,v,b))}function y(x){return a.containerState.initialBlankLine=!0,f++,v(x)}function b(x){return We(x)?(t.enter("listItemPrefixWhitespace"),t.consume(x),t.exit("listItemPrefixWhitespace"),v):l(x)}function v(x){return a.containerState.size=f+a.sliceSerialize(t.exit("listItemPrefix"),!0).length,i(x)}}function xk(t,i,l){const a=this;return a.containerState._closeFlow=void 0,t.check(ka,o,f);function o(p){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,ot(t,i,"listItemIndent",a.containerState.size+1)(p)}function f(p){return a.containerState.furtherBlankLines||!We(p)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,u(p)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,t.attempt(bk,i,u)(p))}function u(p){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)(p)}}function Sk(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 wk(t){t.exit(this.containerState.type)}function jk(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!We(f)&&u&&u[1].type==="listItemPrefixWhitespace"?i(f):l(f)}}const Ty={name:"setextUnderline",resolveTo:kk,tokenize:Ck};function kk(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 Ck(t,i,l){const a=this;let o;return f;function f(m){let y=a.events.length,b;for(;y--;)if(a.events[y][1].type!=="lineEnding"&&a.events[y][1].type!=="linePrefix"&&a.events[y][1].type!=="content"){b=a.events[y][1].type==="paragraph";break}return!a.parser.lazy[a.now().line]&&(a.interrupt||b)?(t.enter("setextHeadingLine"),o=m,u(m)):l(m)}function u(m){return t.enter("setextHeadingLineSequence"),p(m)}function p(m){return m===o?(t.consume(m),p):(t.exit("setextHeadingLineSequence"),We(m)?ot(t,h,"lineSuffix")(m):h(m))}function h(m){return m===null||Oe(m)?(t.exit("setextHeadingLine"),i(m)):l(m)}}const Ek={tokenize:Nk};function Nk(t){const i=this,l=t.attempt(ka,a,t.attempt(this.parser.constructs.flowInitial,o,ot(t,t.attempt(this.parser.constructs.flow,o,t.attempt(Dj,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 Ak={resolveAll:Zb()},Tk=Kb("string"),zk=Kb("text");function Kb(t){return{resolveAll:Zb(t==="text"?Rk:void 0),tokenize:i};function i(l){const a=this,o=this.parser.constructs[t],f=l.attempt(o,u,p);return u;function u(y){return m(y)?f(y):p(y)}function p(y){if(y===null){l.consume(y);return}return l.enter("data"),l.consume(y),h}function h(y){return m(y)?(l.exit("data"),f(y)):(l.consume(y),h)}function m(y){if(y===null)return!0;const b=o[y];let v=-1;if(b)for(;++v<b.length;){const x=b[v];if(!x.previous||x.previous.call(a,a.previous))return!0}return!1}}}function Zb(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 Rk(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,p=0,h;for(;f--;){const m=o[f];if(typeof m=="string"){for(u=m.length;m.charCodeAt(u-1)===32;)p++,u--;if(u)break;u=-1}else if(m===-2)h=!0,p++;else if(m!==-1){f++;break}}if(i._contentTypeTextTrailing&&l===t.length&&(p=0),p){const m={type:l===t.length||h||p<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:f?u:a.start._bufferIndex+u,_index:a.start._index+f,line:a.end.line,column:a.end.column-p,offset:a.end.offset-p},end:{...a.end}};a.end={...m.start},a.start.offset===a.end.offset?Object.assign(a,m):(t.splice(l,0,["enter",m,i],["exit",m,i]),l+=2)}l++}return t}const Dk={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:Vb},Mk={91:Bj},_k={[-2]:df,[-1]:df,32:df},Ok={35:Yj,42:Ps,45:[Ty,Ps],60:$j,61:Ty,95:Ps,96:Ny,126:Ny},Lk={38:Gb,92:Yb},Bk={[-5]:hf,[-4]:hf,[-3]:hf,33:fk,38:Gb,42:Bf,60:[hj,ek],91:hk,92:[Hj,Yb],93:cd,95:Bf,96:Ej},Uk={null:[Bf,Ak]},qk={null:[42,95]},Ik={null:[]},Hk=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:qk,contentInitial:Mk,disable:Ik,document:Dk,flow:Ok,flowInitial:_k,insideSpan:Uk,string:Lk,text:Bk},Symbol.toStringTag,{value:"Module"}));function Vk(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=[],p=[];const h={attempt:V(ae),check:V(T),consume:z,enter:L,exit:G,interrupt:V(T,{interrupt:!0})},m={code:null,containerState:{},defineSkip:_,events:[],now:k,parser:t,previous:null,sliceSerialize:v,sliceStream:x,write:b};let y=i.tokenize.call(m,h);return i.resolveAll&&f.push(i),m;function b(B){return u=Bn(u,B),D(),u[u.length-1]!==null?[]:($(i,0),m.events=co(f,m.events,m),m.events)}function v(B,H){return Gk(x(B),H)}function x(B){return Yk(u,B)}function k(){const{_bufferIndex:B,_index:H,line:Z,column:ee,offset:W}=a;return{_bufferIndex:B,_index:H,line:Z,column:ee,offset:W}}function _(B){o[B.line]=B.column,E()}function D(){let B;for(;a._index<u.length;){const H=u[a._index];if(typeof H=="string")for(B=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===B&&a._bufferIndex<H.length;)R(H.charCodeAt(a._bufferIndex));else R(H)}}function R(B){y=y(B)}function z(B){Oe(B)?(a.line++,a.column=1,a.offset+=B===-3?2:1,E()):B!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===u[a._index].length&&(a._bufferIndex=-1,a._index++)),m.previous=B}function L(B,H){const Z=H||{};return Z.type=B,Z.start=k(),m.events.push(["enter",Z,m]),p.push(Z),Z}function G(B){const H=p.pop();return H.end=k(),m.events.push(["exit",H,m]),H}function ae(B,H){$(B,H.from)}function T(B,H){H.restore()}function V(B,H){return Z;function Z(ee,W,N){let X,pe,ye,j;return Array.isArray(ee)?J(ee):"tokenize"in ee?J([ee]):O(ee);function O(te){return se;function se(we){const F=we!==null&&te[we],Se=we!==null&&te.null,Ne=[...Array.isArray(F)?F:F?[F]:[],...Array.isArray(Se)?Se:Se?[Se]:[]];return J(Ne)(we)}}function J(te){return X=te,pe=0,te.length===0?N:A(te[pe])}function A(te){return se;function se(we){return j=q(),ye=te,te.partial||(m.currentConstruct=te),te.name&&m.parser.constructs.disable.null.includes(te.name)?me():te.tokenize.call(H?Object.assign(Object.create(m),H):m,h,le,me)(we)}}function le(te){return B(ye,j),W}function me(te){return j.restore(),++pe<X.length?A(X[pe]):N}}}function $(B,H){B.resolveAll&&!f.includes(B)&&f.push(B),B.resolve&&En(m.events,H,m.events.length-H,B.resolve(m.events.slice(H),m)),B.resolveTo&&(m.events=B.resolveTo(m.events,m))}function q(){const B=k(),H=m.previous,Z=m.currentConstruct,ee=m.events.length,W=Array.from(p);return{from:ee,restore:N};function N(){a=B,m.previous=H,m.currentConstruct=Z,m.events.length=ee,p=W,E()}}function E(){a.line in o&&a.column<2&&(a.column=o[a.line],a.offset+=o[a.line]-1)}}function Yk(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 p=u[0];typeof p=="string"?u[0]=p.slice(a):u.shift()}f>0&&u.push(t[o].slice(0,f))}return u}function Gk(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 Fk(t){const a={constructs:Ib([Hk,...(t||{}).extensions||[]]),content:o(aj),defined:[],document:o(oj),flow:o(Ek),lazy:{},string:o(Tk),text:o(zk)};return a;function o(f){return u;function u(p){return Vk(a,f,p)}}}function Qk(t){for(;!Fb(t););return t}const zy=/[\0\t\n\r]/g;function $k(){let t=1,i="",l=!0,a;return o;function o(f,u,p){const h=[];let m,y,b,v,x;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(zy.lastIndex=b,m=zy.exec(f),v=m&&m.index!==void 0?m.index:f.length,x=f.charCodeAt(v),!m){i=f.slice(b);break}if(x===10&&b===v&&a)h.push(-3),a=void 0;else switch(a&&(h.push(-5),a=void 0),b<v&&(h.push(f.slice(b,v)),t+=v-b),x){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=v+1}return p&&(a&&h.push(-5),i&&h.push(i),h.push(null)),h}}const Xk=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Kk(t){return t.replace(Xk,Zk)}function Zk(t,i,l){if(i)return i;if(l.charCodeAt(0)===35){const o=l.charCodeAt(1),f=o===120||o===88;return Hb(l.slice(f?2:1),f?16:10)}return ud(l)||t}const Pb={}.hasOwnProperty;function Pk(t,i,l){return i&&typeof i=="object"&&(l=i,i=void 0),Jk(l)(Qk(Fk(l).document().write($k()(t,i,!0))))}function Jk(t){const i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:f(qe),autolinkProtocol:q,autolinkEmail:q,atxHeading:f(dt),blockQuote:f(Se),characterEscape:q,characterReference:q,codeFenced:f(Ne),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:f(Ne,u),codeText:f(Te,u),codeTextData:q,data:q,codeFlowValue:q,definition:f(Ge),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:f(et),hardBreakEscape:f(Fe),hardBreakTrailing:f(Fe),htmlFlow:f(Ct,u),htmlFlowData:q,htmlText:f(Ct,u),htmlTextData:q,image:f(ht),label:u,link:f(qe),listItem:f(Ve),listItemValue:v,listOrdered:f(pt,b),listUnordered:f(pt),paragraph:f(tt),reference:A,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:f(dt),strong:f(zt),thematicBreak:f(yt)},exit:{atxHeading:h(),atxHeadingSequence:ae,autolink:h(),autolinkEmail:F,autolinkProtocol:we,blockQuote:h(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:me,characterReferenceMarkerNumeric:me,characterReferenceValue:te,characterReference:se,codeFenced:h(D),codeFencedFence:_,codeFencedFenceInfo:x,codeFencedFenceMeta:k,codeFlowValue:E,codeIndented:h(R),codeText:h(W),codeTextData:E,data:E,definition:h(),definitionDestinationString:G,definitionLabelString:z,definitionTitleString:L,emphasis:h(),hardBreakEscape:h(H),hardBreakTrailing:h(H),htmlFlow:h(Z),htmlFlowData:E,htmlText:h(ee),htmlTextData:E,image:h(X),label:ye,labelText:pe,lineEnding:B,link:h(N),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:le,resourceDestinationString:j,resourceTitleString:O,resource:J,setextHeading:h($),setextHeadingLineSequence:V,setextHeadingText:T,strong:h(),thematicBreak:h()}};Jb(i,(t||{}).mdastExtensions||[]);const l={};return a;function a(M){let K={type:"root",children:[]};const ge={stack:[K],tokenStack:[],config:i,enter:p,exit:m,buffer:u,resume:y,data:l},be=[];let Ee=-1;for(;++Ee<M.length;)if(M[Ee][1].type==="listOrdered"||M[Ee][1].type==="listUnordered")if(M[Ee][0]==="enter")be.push(Ee);else{const Le=be.pop();Ee=o(M,Le,Ee)}for(Ee=-1;++Ee<M.length;){const Le=i[M[Ee][0]];Pb.call(Le,M[Ee][1].type)&&Le[M[Ee][1].type].call(Object.assign({sliceSerialize:M[Ee][2].sliceSerialize},ge),M[Ee][1])}if(ge.tokenStack.length>0){const Le=ge.tokenStack[ge.tokenStack.length-1];(Le[1]||Ry).call(ge,void 0,Le[0])}for(K.position={start:Fi(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Fi(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},Ee=-1;++Ee<i.transforms.length;)K=i.transforms[Ee](K)||K;return K}function o(M,K,ge){let be=K-1,Ee=-1,Le=!1,Ke,bt,mt,lt;for(;++be<=ge;){const Ze=M[be];switch(Ze[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ze[0]==="enter"?Ee++:Ee--,lt=void 0;break}case"lineEndingBlank":{Ze[0]==="enter"&&(Ke&&!lt&&!Ee&&!mt&&(mt=be),lt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:lt=void 0}if(!Ee&&Ze[0]==="enter"&&Ze[1].type==="listItemPrefix"||Ee===-1&&Ze[0]==="exit"&&(Ze[1].type==="listUnordered"||Ze[1].type==="listOrdered")){if(Ke){let Q=be;for(bt=void 0;Q--;){const ve=M[Q];if(ve[1].type==="lineEnding"||ve[1].type==="lineEndingBlank"){if(ve[0]==="exit")continue;bt&&(M[bt][1].type="lineEndingBlank",Le=!0),ve[1].type="lineEnding",bt=Q}else if(!(ve[1].type==="linePrefix"||ve[1].type==="blockQuotePrefix"||ve[1].type==="blockQuotePrefixWhitespace"||ve[1].type==="blockQuoteMarker"||ve[1].type==="listItemIndent"))break}mt&&(!bt||mt<bt)&&(Ke._spread=!0),Ke.end=Object.assign({},bt?M[bt][1].start:Ze[1].end),M.splice(bt||be,0,["exit",Ke,Ze[2]]),be++,ge++}if(Ze[1].type==="listItemPrefix"){const Q={type:"listItem",_spread:!1,start:Object.assign({},Ze[1].start),end:void 0};Ke=Q,M.splice(be,0,["enter",Q,Ze[2]]),be++,ge++,mt=void 0,lt=!0}}}return M[K][1]._spread=Le,ge}function f(M,K){return ge;function ge(be){p.call(this,M(be),be),K&&K.call(this,be)}}function u(){this.stack.push({type:"fragment",children:[]})}function p(M,K,ge){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([K,ge||void 0]),M.position={start:Fi(K.start),end:void 0}}function h(M){return K;function K(ge){M&&M.call(this,ge),m.call(this,ge)}}function m(M,K){const ge=this.stack.pop(),be=this.tokenStack.pop();if(be)be[0].type!==M.type&&(K?K.call(this,M,be[0]):(be[1]||Ry).call(this,M,be[0]));else throw new Error("Cannot close `"+M.type+"` ("+pa({start:M.start,end:M.end})+"): it’s not open");ge.position.end=Fi(M.end)}function y(){return od(this.stack.pop())}function b(){this.data.expectingFirstListItemValue=!0}function v(M){if(this.data.expectingFirstListItemValue){const K=this.stack[this.stack.length-2];K.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function x(){const M=this.resume(),K=this.stack[this.stack.length-1];K.lang=M}function k(){const M=this.resume(),K=this.stack[this.stack.length-1];K.meta=M}function _(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function D(){const M=this.resume(),K=this.stack[this.stack.length-1];K.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function R(){const M=this.resume(),K=this.stack[this.stack.length-1];K.value=M.replace(/(\r?\n|\r)$/g,"")}function z(M){const K=this.resume(),ge=this.stack[this.stack.length-1];ge.label=K,ge.identifier=Yn(this.sliceSerialize(M)).toLowerCase()}function L(){const M=this.resume(),K=this.stack[this.stack.length-1];K.title=M}function G(){const M=this.resume(),K=this.stack[this.stack.length-1];K.url=M}function ae(M){const K=this.stack[this.stack.length-1];if(!K.depth){const ge=this.sliceSerialize(M).length;K.depth=ge}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function V(M){const K=this.stack[this.stack.length-1];K.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function q(M){const ge=this.stack[this.stack.length-1].children;let be=ge[ge.length-1];(!be||be.type!=="text")&&(be=rt(),be.position={start:Fi(M.start),end:void 0},ge.push(be)),this.stack.push(be)}function E(M){const K=this.stack.pop();K.value+=this.sliceSerialize(M),K.position.end=Fi(M.end)}function B(M){const K=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=K.children[K.children.length-1];ge.position.end=Fi(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(K.type)&&(q.call(this,M),E.call(this,M))}function H(){this.data.atHardBreak=!0}function Z(){const M=this.resume(),K=this.stack[this.stack.length-1];K.value=M}function ee(){const M=this.resume(),K=this.stack[this.stack.length-1];K.value=M}function W(){const M=this.resume(),K=this.stack[this.stack.length-1];K.value=M}function N(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const K=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=K,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function X(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const K=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=K,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function pe(M){const K=this.sliceSerialize(M),ge=this.stack[this.stack.length-2];ge.label=Kk(K),ge.identifier=Yn(K).toLowerCase()}function ye(){const M=this.stack[this.stack.length-1],K=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const be=M.children;ge.children=be}else ge.alt=K}function j(){const M=this.resume(),K=this.stack[this.stack.length-1];K.url=M}function O(){const M=this.resume(),K=this.stack[this.stack.length-1];K.title=M}function J(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function le(M){const K=this.resume(),ge=this.stack[this.stack.length-1];ge.label=K,ge.identifier=Yn(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function me(M){this.data.characterReferenceType=M.type}function te(M){const K=this.sliceSerialize(M),ge=this.data.characterReferenceType;let be;ge?(be=Hb(K,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):be=ud(K);const Ee=this.stack[this.stack.length-1];Ee.value+=be}function se(M){const K=this.stack.pop();K.position.end=Fi(M.end)}function we(M){E.call(this,M);const K=this.stack[this.stack.length-1];K.url=this.sliceSerialize(M)}function F(M){E.call(this,M);const K=this.stack[this.stack.length-1];K.url="mailto:"+this.sliceSerialize(M)}function Se(){return{type:"blockquote",children:[]}}function Ne(){return{type:"code",lang:null,meta:null,value:""}}function Te(){return{type:"inlineCode",value:""}}function Ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function et(){return{type:"emphasis",children:[]}}function dt(){return{type:"heading",depth:0,children:[]}}function Fe(){return{type:"break"}}function Ct(){return{type:"html",value:""}}function ht(){return{type:"image",title:null,url:"",alt:null}}function qe(){return{type:"link",title:null,url:"",children:[]}}function pt(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Ve(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function tt(){return{type:"paragraph",children:[]}}function zt(){return{type:"strong",children:[]}}function rt(){return{type:"text",value:""}}function yt(){return{type:"thematicBreak"}}}function Fi(t){return{line:t.line,column:t.column,offset:t.offset}}function Jb(t,i){let l=-1;for(;++l<i.length;){const a=i[l];Array.isArray(a)?Jb(t,a):Wk(t,a)}}function Wk(t,i){let l;for(l in i)if(Pb.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 Ry(t,i){throw t?new Error("Cannot close `"+t.type+"` ("+pa({start:t.start,end:t.end})+"): a different token (`"+i.type+"`, "+pa({start:i.start,end:i.end})+") is open"):new Error("Cannot close document, a token (`"+i.type+"`, "+pa({start:i.start,end:i.end})+") is still open")}function eC(t){const i=this;i.parser=l;function l(a){return Pk(a,{...i.data("settings"),...t,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})}}function tC(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 nC(t,i){const l={type:"element",tagName:"br",properties:{},children:[]};return t.patch(i,l),[t.applyData(i,l),{type:"text",value:`
32
+ `}]}function iC(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 rC(t,i){const l={type:"element",tagName:"del",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function lC(t,i){const l={type:"element",tagName:"em",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function aC(t,i){const l=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",a=String(i.identifier).toUpperCase(),o=hl(a.toLowerCase()),f=t.footnoteOrder.indexOf(a);let u,p=t.footnoteCounts.get(a);p===void 0?(p=0,t.footnoteOrder.push(a),u=t.footnoteOrder.length):u=f+1,p+=1,t.footnoteCounts.set(a,p);const h={type:"element",tagName:"a",properties:{href:"#"+l+"fn-"+o,id:l+"fnref-"+o+(p>1?"-"+p:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};t.patch(i,h);const m={type:"element",tagName:"sup",properties:{},children:[h]};return t.patch(i,m),t.applyData(i,m)}function sC(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 oC(t,i){if(t.options.allowDangerousHtml){const l={type:"raw",value:i.value};return t.patch(i,l),t.applyData(i,l)}}function Wb(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 uC(t,i){const l=String(i.identifier).toUpperCase(),a=t.definitionById.get(l);if(!a)return Wb(t,i);const o={src:hl(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 cC(t,i){const l={src:hl(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 fC(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 dC(t,i){const l=String(i.identifier).toUpperCase(),a=t.definitionById.get(l);if(!a)return Wb(t,i);const o={href:hl(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 hC(t,i){const l={href:hl(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 pC(t,i,l){const a=t.all(i),o=l?mC(l):ev(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 p=-1;for(;++p<a.length;){const y=a[p];(o||p!==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 m={type:"element",tagName:"li",properties:f,children:u};return t.patch(i,m),t.applyData(i,m)}function mC(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=ev(l[a])}return i}function ev(t){const i=t.spread;return i??t.children.length>1}function gC(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 yC(t,i){const l={type:"element",tagName:"p",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function bC(t,i){const l={type:"root",children:t.wrap(t.all(i))};return t.patch(i,l),t.applyData(i,l)}function vC(t,i){const l={type:"element",tagName:"strong",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function xC(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)},p=rd(i.children[1]),h=Mb(i.children[i.children.length-1]);p&&h&&(u.position={start:p,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 SC(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,p=u?u.length:i.children.length;let h=-1;const m=[];for(;++h<p;){const b=i.children[h],v={},x=u?u[h]:void 0;x&&(v.align=x);let k={type:"element",tagName:f,properties:v,children:[]};b&&(k.children=t.all(b),t.patch(b,k),k=t.applyData(b,k)),m.push(k)}const y={type:"element",tagName:"tr",properties:{},children:t.wrap(m,!0)};return t.patch(i,y),t.applyData(i,y)}function wC(t,i){const l={type:"element",tagName:"td",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}const Dy=9,My=32;function jC(t){const i=String(t),l=/\r?\n|\r/g;let a=l.exec(i),o=0;const f=[];for(;a;)f.push(_y(i.slice(o,a.index),o>0,!0),a[0]),o=a.index+a[0].length,a=l.exec(i);return f.push(_y(i.slice(o),o>0,!1)),f.join("")}function _y(t,i,l){let a=0,o=t.length;if(i){let f=t.codePointAt(a);for(;f===Dy||f===My;)a++,f=t.codePointAt(a)}if(l){let f=t.codePointAt(o-1);for(;f===Dy||f===My;)o--,f=t.codePointAt(o-1)}return o>a?t.slice(a,o):""}function kC(t,i){const l={type:"text",value:jC(String(i.value))};return t.patch(i,l),t.applyData(i,l)}function CC(t,i){const l={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(i,l),t.applyData(i,l)}const EC={blockquote:tC,break:nC,code:iC,delete:rC,emphasis:lC,footnoteReference:aC,heading:sC,html:oC,imageReference:uC,image:cC,inlineCode:fC,linkReference:dC,link:hC,listItem:pC,list:gC,paragraph:yC,root:bC,strong:vC,table:xC,tableCell:wC,tableRow:SC,text:kC,thematicBreak:CC,toml:Fs,yaml:Fs,definition:Fs,footnoteDefinition:Fs};function Fs(){}const tv=-1,fo=0,ga=1,io=2,fd=3,dd=4,hd=5,pd=6,nv=7,iv=8,NC=typeof self=="object"?self:globalThis,Oy=(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 NC[t](i)},AC=(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 fo:case tv:return l(u,o);case ga:{const p=l([],o);for(const h of u)p.push(a(h));return p}case io:{const p=l({},o);for(const[h,m]of u)p[a(h)]=a(m);return p}case fd:return l(new Date(u),o);case dd:{const{source:p,flags:h}=u;return l(new RegExp(p,h),o)}case hd:{const p=l(new Map,o);for(const[h,m]of u)p.set(a(h),a(m));return p}case pd:{const p=l(new Set,o);for(const h of u)p.add(a(h));return p}case nv:{const{name:p,message:h}=u;return l(Oy(p,h),o)}case iv: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:p}=new Uint8Array(u);return l(new DataView(p),u)}}return l(Oy(f,u),o)};return a},Ly=t=>AC(new Map,t)(0),ol="",{toString:TC}={},{keys:zC}=Object,da=t=>{const i=typeof t;if(i!=="object"||!t)return[fo,i];const l=TC.call(t).slice(8,-1);switch(l){case"Array":return[ga,ol];case"Object":return[io,ol];case"Date":return[fd,ol];case"RegExp":return[dd,ol];case"Map":return[hd,ol];case"Set":return[pd,ol];case"DataView":return[ga,l]}return l.includes("Array")?[ga,l]:l.includes("Error")?[nv,l]:[io,l]},Qs=([t,i])=>t===fo&&(i==="function"||i==="symbol"),RC=(t,i,l,a)=>{const o=(u,p)=>{const h=a.push(u)-1;return l.set(p,h),h},f=u=>{if(l.has(u))return l.get(u);let[p,h]=da(u);switch(p){case fo:{let y=u;switch(h){case"bigint":p=iv,y=u.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+h);y=null;break;case"undefined":return o([tv],u)}return o([p,y],u)}case ga:{if(h){let v=u;return h==="DataView"?v=new Uint8Array(u.buffer):h==="ArrayBuffer"&&(v=new Uint8Array(u)),o([h,[...v]],u)}const y=[],b=o([p,y],u);for(const v of u)y.push(f(v));return b}case io:{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([p,y],u);for(const v of zC(u))(t||!Qs(da(u[v])))&&y.push([f(v),f(u[v])]);return b}case fd:return o([p,u.toISOString()],u);case dd:{const{source:y,flags:b}=u;return o([p,{source:y,flags:b}],u)}case hd:{const y=[],b=o([p,y],u);for(const[v,x]of u)(t||!(Qs(da(v))||Qs(da(x))))&&y.push([f(v),f(x)]);return b}case pd:{const y=[],b=o([p,y],u);for(const v of u)(t||!Qs(da(v)))&&y.push(f(v));return b}}const{message:m}=u;return o([p,{name:h,message:m}],u)};return f},By=(t,{json:i,lossy:l}={})=>{const a=[];return RC(!(i||l),!!i,new Map,a)(t),a},ro=typeof structuredClone=="function"?(t,i)=>i&&("json"in i||"lossy"in i)?Ly(By(t,i)):structuredClone(t):(t,i)=>Ly(By(t,i));function DC(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 MC(t,i){return"Back to reference "+(t+1)+(i>1?"-"+i:"")}function _C(t){const i=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",l=t.options.footnoteBackContent||DC,a=t.options.footnoteBackLabel||MC,o=t.options.footnoteLabel||"Footnotes",f=t.options.footnoteLabelTagName||"h2",u=t.options.footnoteLabelProperties||{className:["sr-only"]},p=[];let h=-1;for(;++h<t.footnoteOrder.length;){const m=t.footnoteById.get(t.footnoteOrder[h]);if(!m)continue;const y=t.all(m),b=String(m.identifier).toUpperCase(),v=hl(b.toLowerCase());let x=0;const k=[],_=t.footnoteCounts.get(b);for(;_!==void 0&&++x<=_;){k.length>0&&k.push({type:"text",value:" "});let z=typeof l=="string"?l:l(h,x);typeof z=="string"&&(z={type:"text",value:z}),k.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+v+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof a=="string"?a:a(h,x),className:["data-footnote-backref"]},children:Array.isArray(z)?z:[z]})}const D=y[y.length-1];if(D&&D.type==="element"&&D.tagName==="p"){const z=D.children[D.children.length-1];z&&z.type==="text"?z.value+=" ":D.children.push({type:"text",value:" "}),D.children.push(...k)}else y.push(...k);const R={type:"element",tagName:"li",properties:{id:i+"fn-"+v},children:t.wrap(y,!0)};t.patch(m,R),p.push(R)}if(p.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:f,properties:{...ro(u),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
36
+ `},{type:"element",tagName:"ol",properties:{},children:t.wrap(p,!0)},{type:"text",value:`
37
+ `}]}}const ho=(function(t){if(t==null)return UC;if(typeof t=="function")return po(t);if(typeof t=="object")return Array.isArray(t)?OC(t):LC(t);if(typeof t=="string")return BC(t);throw new Error("Expected function, string, or object as test")});function OC(t){const i=[];let l=-1;for(;++l<t.length;)i[l]=ho(t[l]);return po(a);function a(...o){let f=-1;for(;++f<i.length;)if(i[f].apply(this,o))return!0;return!1}}function LC(t){const i=t;return po(l);function l(a){const o=a;let f;for(f in t)if(o[f]!==i[f])return!1;return!0}}function BC(t){return po(i);function i(l){return l&&l.type===t}}function po(t){return i;function i(l,a,o){return!!(qC(l)&&t.call(this,l,typeof a=="number"?a:void 0,o||void 0))}}function UC(){return!0}function qC(t){return t!==null&&typeof t=="object"&&"type"in t}const rv=[],IC=!0,Uf=!1,HC="skip";function lv(t,i,l,a){let o;typeof i=="function"&&typeof l!="function"?(a=l,l=i):o=i;const f=ho(o),u=a?-1:1;p(t,void 0,[])();function p(h,m,y){const b=h&&typeof h=="object"?h:{};if(typeof b.type=="string"){const x=typeof b.tagName=="string"?b.tagName:typeof b.name=="string"?b.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(h.type+(x?"<"+x+">":""))+")"})}return v;function v(){let x=rv,k,_,D;if((!i||f(h,m,y[y.length-1]||void 0))&&(x=VC(l(h,y)),x[0]===Uf))return x;if("children"in h&&h.children){const R=h;if(R.children&&x[0]!==HC)for(_=(a?R.children.length:-1)+u,D=y.concat(R);_>-1&&_<R.children.length;){const z=R.children[_];if(k=p(z,_,D)(),k[0]===Uf)return k;_=typeof k[1]=="number"?k[1]:_+u}}return x}}}function VC(t){return Array.isArray(t)?t:typeof t=="number"?[IC,t]:t==null?rv:[t]}function md(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),lv(t,f,p,o);function p(h,m){const y=m[m.length-1],b=y?y.children.indexOf(h):void 0;return u(h,b,y)}}const qf={}.hasOwnProperty,YC={};function GC(t,i){const l=i||YC,a=new Map,o=new Map,f=new Map,u={...EC,...l.handlers},p={all:m,applyData:QC,definitionById:a,footnoteById:o,footnoteCounts:f,footnoteOrder:[],handlers:u,one:h,options:l,patch:FC,wrap:XC};return md(t,function(y){if(y.type==="definition"||y.type==="footnoteDefinition"){const b=y.type==="definition"?a:o,v=String(y.identifier).toUpperCase();b.has(v)||b.set(v,y)}}),p;function h(y,b){const v=y.type,x=p.handlers[v];if(qf.call(p.handlers,v)&&x)return x(p,y,b);if(p.options.passThrough&&p.options.passThrough.includes(v)){if("children"in y){const{children:_,...D}=y,R=ro(D);return R.children=p.all(y),R}return ro(y)}return(p.options.unknownHandler||$C)(p,y,b)}function m(y){const b=[];if("children"in y){const v=y.children;let x=-1;for(;++x<v.length;){const k=p.one(v[x],y);if(k){if(x&&v[x-1].type==="break"&&(!Array.isArray(k)&&k.type==="text"&&(k.value=Uy(k.value)),!Array.isArray(k)&&k.type==="element")){const _=k.children[0];_&&_.type==="text"&&(_.value=Uy(_.value))}Array.isArray(k)?b.push(...k):b.push(k)}}}return b}}function FC(t,i){t.position&&(i.position=Dw(t))}function QC(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,ro(f)),"children"in l&&l.children&&o!==null&&o!==void 0&&(l.children=o)}return l}function $C(t,i){const l=i.data||{},a="value"in i&&!(qf.call(l,"hProperties")||qf.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 XC(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 Uy(t){let i=0,l=t.charCodeAt(i);for(;l===9||l===32;)i++,l=t.charCodeAt(i);return t.slice(i)}function qy(t,i){const l=GC(t,i),a=l.one(t,void 0),o=_C(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 KC(t,i){return t&&"run"in t?async function(l,a){const o=qy(l,{file:a,...i});await t.run(o,a)}:function(l,a){return qy(l,{file:a,...t||i})}}function Iy(t){if(t)throw t}var pf,Hy;function ZC(){if(Hy)return pf;Hy=1;var t=Object.prototype.hasOwnProperty,i=Object.prototype.toString,l=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(m){return typeof Array.isArray=="function"?Array.isArray(m):i.call(m)==="[object Array]"},f=function(m){if(!m||i.call(m)!=="[object Object]")return!1;var y=t.call(m,"constructor"),b=m.constructor&&m.constructor.prototype&&t.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!y&&!b)return!1;var v;for(v in m);return typeof v>"u"||t.call(m,v)},u=function(m,y){l&&y.name==="__proto__"?l(m,y.name,{enumerable:!0,configurable:!0,value:y.newValue,writable:!0}):m[y.name]=y.newValue},p=function(m,y){if(y==="__proto__")if(t.call(m,y)){if(a)return a(m,y).value}else return;return m[y]};return pf=function h(){var m,y,b,v,x,k,_=arguments[0],D=1,R=arguments.length,z=!1;for(typeof _=="boolean"&&(z=_,_=arguments[1]||{},D=2),(_==null||typeof _!="object"&&typeof _!="function")&&(_={});D<R;++D)if(m=arguments[D],m!=null)for(y in m)b=p(_,y),v=p(m,y),_!==v&&(z&&v&&(f(v)||(x=o(v)))?(x?(x=!1,k=b&&o(b)?b:[]):k=b&&f(b)?b:{},u(_,{name:y,newValue:h(z,k,v)})):typeof v<"u"&&u(_,{name:y,newValue:v}));return _},pf}var PC=ZC();const mf=ao(PC);function If(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 JC(){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);p(null,...o);function p(h,...m){const y=t[++f];let b=-1;if(h){u(h);return}for(;++b<o.length;)(m[b]===null||m[b]===void 0)&&(m[b]=o[b]);o=m,y?WC(y,p)(...m):u(null,...m)}}function a(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return t.push(o),i}}function WC(t,i){let l;return a;function a(...u){const p=t.length>u.length;let h;p&&u.push(o);try{h=t.apply(this,u)}catch(m){const y=m;if(p&&l)throw y;return o(y)}p||(h&&h.then&&typeof h.then=="function"?h.then(f,o):h instanceof Error?o(h):f(h))}function o(u,...p){l||(l=!0,i(u,...p))}function f(u){o(null,u)}}const Zn={basename:eE,dirname:tE,extname:nE,join:iE,sep:"/"};function eE(t,i){if(i!==void 0&&typeof i!="string")throw new TypeError('"ext" argument must be a string');Ca(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,p=i.length-1;for(;o--;)if(t.codePointAt(o)===47){if(f){l=o+1;break}}else u<0&&(f=!0,u=o+1),p>-1&&(t.codePointAt(o)===i.codePointAt(p--)?p<0&&(a=o):(p=-1,a=u));return l===a?a=u:a<0&&(a=t.length),t.slice(l,a)}function tE(t){if(Ca(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 nE(t){Ca(t);let i=t.length,l=-1,a=0,o=-1,f=0,u;for(;i--;){const p=t.codePointAt(i);if(p===47){if(u){a=i+1;break}continue}l<0&&(u=!0,l=i+1),p===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 iE(...t){let i=-1,l;for(;++i<t.length;)Ca(t[i]),t[i]&&(l=l===void 0?t[i]:l+"/"+t[i]);return l===void 0?".":rE(l)}function rE(t){Ca(t);const i=t.codePointAt(0)===47;let l=lE(t,!i);return l.length===0&&!i&&(l="."),l.length>0&&t.codePointAt(t.length-1)===47&&(l+="/"),i?"/"+l:l}function lE(t,i){let l="",a=0,o=-1,f=0,u=-1,p,h;for(;++u<=t.length;){if(u<t.length)p=t.codePointAt(u);else{if(p===47)break;p=47}if(p===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 p===46&&f>-1?f++:f=-1}return l}function Ca(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const aE={cwd:sE};function sE(){return"/"}function Hf(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function oE(t){if(typeof t=="string")t=new URL(t);else if(!Hf(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 uE(t)}function uE(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 gf=["history","path","basename","stem","extname","dirname"];class av{constructor(i){let l;i?Hf(i)?l={path:i}:typeof i=="string"||cE(i)?l={value:i}:l=i:l={},this.cwd="cwd"in l?"":aE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<gf.length;){const f=gf[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)gf.includes(o)||(this[o]=l[o])}get basename(){return typeof this.path=="string"?Zn.basename(this.path):void 0}set basename(i){bf(i,"basename"),yf(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){Vy(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(yf(i,"extname"),Vy(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){Hf(i)&&(i=oE(i)),bf(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){bf(i,"stem"),yf(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 rn(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 yf(t,i){if(t&&t.includes(Zn.sep))throw new Error("`"+i+"` cannot be a path: did not expect `"+Zn.sep+"`")}function bf(t,i){if(!t)throw new Error("`"+i+"` cannot be empty")}function Vy(t,i){if(!t)throw new Error("Setting `"+i+"` requires `path` to be set too")}function cE(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const fE=(function(t){const a=this.constructor.prototype,o=a[t],f=function(){return o.apply(f,arguments)};return Object.setPrototypeOf(f,a),f}),dE={}.hasOwnProperty;class gd extends fE{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=JC()}copy(){const i=new gd;let l=-1;for(;++l<this.attachers.length;){const a=this.attachers[l];i.use(...a)}return i.data(mf(!0,{},this.namespace)),i}data(i,l){return typeof i=="string"?arguments.length===2?(Sf("data",this.frozen),this.namespace[i]=l,this):dE.call(this.namespace,i)&&this.namespace[i]||void 0:i?(Sf("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=$s(i),a=this.parser||this.Parser;return vf("parse",a),a(String(l),l)}process(i,l){const a=this;return this.freeze(),vf("process",this.parser||this.Parser),xf("process",this.compiler||this.Compiler),l?o(void 0,l):new Promise(o);function o(f,u){const p=$s(i),h=a.parse(p);a.run(h,p,function(y,b,v){if(y||!b||!v)return m(y);const x=b,k=a.stringify(x,v);mE(k)?v.value=k:v.result=k,m(y,v)});function m(y,b){y||!b?u(y):f?f(b):l(void 0,b)}}}processSync(i){let l=!1,a;return this.freeze(),vf("processSync",this.parser||this.Parser),xf("processSync",this.compiler||this.Compiler),this.process(i,o),Gy("processSync","process",l),a;function o(f,u){l=!0,Iy(f),a=u}}run(i,l,a){Yy(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,p){const h=$s(l);o.run(i,h,m);function m(y,b,v){const x=b||i;y?p(y):u?u(x):a(void 0,x,v)}}}runSync(i,l){let a=!1,o;return this.run(i,l,f),Gy("runSync","run",a),o;function f(u,p){Iy(u),o=p,a=!0}}stringify(i,l){this.freeze();const a=$s(l),o=this.compiler||this.Compiler;return xf("stringify",o),Yy(i),o(i,a)}use(i,...l){const a=this.attachers,o=this.namespace;if(Sf("use",this.frozen),i!=null)if(typeof i=="function")h(i,l);else if(typeof i=="object")Array.isArray(i)?p(i):u(i);else throw new TypeError("Expected usable value, not `"+i+"`");return this;function f(m){if(typeof m=="function")h(m,[]);else if(typeof m=="object")if(Array.isArray(m)){const[y,...b]=m;h(y,b)}else u(m);else throw new TypeError("Expected usable value, not `"+m+"`")}function u(m){if(!("plugins"in m)&&!("settings"in m))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");p(m.plugins),m.settings&&(o.settings=mf(!0,o.settings,m.settings))}function p(m){let y=-1;if(m!=null)if(Array.isArray(m))for(;++y<m.length;){const b=m[y];f(b)}else throw new TypeError("Expected a list of plugins, not `"+m+"`")}function h(m,y){let b=-1,v=-1;for(;++b<a.length;)if(a[b][0]===m){v=b;break}if(v===-1)a.push([m,...y]);else if(y.length>0){let[x,...k]=y;const _=a[v][1];If(_)&&If(x)&&(x=mf(!0,_,x)),a[v]=[m,x,...k]}}}}const hE=new gd().freeze();function vf(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function xf(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Sf(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 Yy(t){if(!If(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Gy(t,i,l){if(!l)throw new Error("`"+t+"` finished async. Use `"+i+"` instead")}function $s(t){return pE(t)?t:new av(t)}function pE(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function mE(t){return typeof t=="string"||gE(t)}function gE(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const yE="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Fy=[],Qy={allowDangerousHtml:!0},bE=/^(https?|ircs?|mailto|xmpp)$/i,vE=[{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 xE(t){const i=SE(t),l=wE(t);return jE(i.runSync(i.parse(l),l),t)}function SE(t){const i=t.rehypePlugins||Fy,l=t.remarkPlugins||Fy,a=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...Qy}:Qy;return hE().use(eC).use(l).use(KC,a).use(i)}function wE(t){const i=t.children||"",l=new av;return typeof i=="string"&&(l.value=i),l}function jE(t,i){const l=i.allowedElements,a=i.allowElement,o=i.components,f=i.disallowedElements,u=i.skipHtml,p=i.unwrapDisallowed,h=i.urlTransform||kE;for(const y of vE)Object.hasOwn(i,y.from)&&(""+y.from+(y.to?"use `"+y.to+"` instead":"remove it")+yE+y.id,void 0);return i.className&&(t={type:"element",tagName:"div",properties:{className:i.className},children:t.type==="root"?t.children:[t]}),md(t,m),Bw(t,{Fragment:c.Fragment,components:o,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function m(y,b,v){if(y.type==="raw"&&v&&typeof b=="number")return u?v.children.splice(b,1):v.children[b]={type:"text",value:y.value},b;if(y.type==="element"){let x;for(x in ff)if(Object.hasOwn(ff,x)&&Object.hasOwn(y.properties,x)){const k=y.properties[x],_=ff[x];(_===null||_.includes(y.tagName))&&(y.properties[x]=h(String(k||""),x,y))}}if(y.type==="element"){let x=l?!l.includes(y.tagName):f?f.includes(y.tagName):!1;if(!x&&a&&typeof b=="number"&&(x=!a(y,b,v)),x&&v&&typeof b=="number")return p&&y.children?v.children.splice(b,1,...y.children):v.children.splice(b,1),b}}}function kE(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||bE.test(t.slice(0,i))?t:""}function $y(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 CE(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function EE(t,i,l){const o=ho((l||{}).ignore||[]),f=NE(i);let u=-1;for(;++u<f.length;)lv(t,"text",p);function p(m,y){let b=-1,v;for(;++b<y.length;){const x=y[b],k=v?v.children:void 0;if(o(x,k?k.indexOf(x):void 0,v))return;v=x}if(v)return h(m,y)}function h(m,y){const b=y[y.length-1],v=f[u][0],x=f[u][1];let k=0;const D=b.children.indexOf(m);let R=!1,z=[];v.lastIndex=0;let L=v.exec(m.value);for(;L;){const G=L.index,ae={index:L.index,input:L.input,stack:[...y,m]};let T=x(...L,ae);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?v.lastIndex=G+1:(k!==G&&z.push({type:"text",value:m.value.slice(k,G)}),Array.isArray(T)?z.push(...T):T&&z.push(T),k=G+L[0].length,R=!0),!v.global)break;L=v.exec(m.value)}return R?(k<m.value.length&&z.push({type:"text",value:m.value.slice(k)}),b.children.splice(D,1,...z)):z=[m],D+z.length}}function NE(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([AE(o[0]),TE(o[1])])}return i}function AE(t){return typeof t=="string"?new RegExp(CE(t),"g"):t}function TE(t){return typeof t=="function"?t:function(){return t}}const wf="phrasing",jf=["autolink","link","image","label"];function zE(){return{transforms:[BE],enter:{literalAutolink:DE,literalAutolinkEmail:kf,literalAutolinkHttp:kf,literalAutolinkWww:kf},exit:{literalAutolink:LE,literalAutolinkEmail:OE,literalAutolinkHttp:ME,literalAutolinkWww:_E}}}function RE(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:wf,notInConstruct:jf},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:wf,notInConstruct:jf},{character:":",before:"[ps]",after:"\\/",inConstruct:wf,notInConstruct:jf}]}}function DE(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function kf(t){this.config.enter.autolinkProtocol.call(this,t)}function ME(t){this.config.exit.autolinkProtocol.call(this,t)}function _E(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 OE(t){this.config.exit.autolinkEmail.call(this,t)}function LE(t){this.exit(t)}function BE(t){EE(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,UE],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),qE]],{ignore:["link","linkReference"]})}function UE(t,i,l,a,o){let f="";if(!sv(o)||(/^w/i.test(i)&&(l=i+l,i="",f="http://"),!IE(l)))return!1;const u=HE(l+a);if(!u[0])return!1;const p={type:"link",title:null,url:f+i+u[0],children:[{type:"text",value:i+u[0]}]};return u[1]?[p,{type:"text",value:u[1]}]:p}function qE(t,i,l,a){return!sv(a,!0)||/[-\d_]$/.test(l)?!1:{type:"link",title:null,url:"mailto:"+i+"@"+l,children:[{type:"text",value:i+"@"+l}]}}function IE(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 HE(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=$y(t,"(");let f=$y(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 sv(t,i){const l=t.input.charCodeAt(t.index-1);return(t.index===0||mr(l)||uo(l))&&(!i||l!==47)}ov.peek=ZE;function VE(){this.buffer()}function YE(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function GE(){this.buffer()}function FE(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function QE(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 $E(t){this.exit(t)}function XE(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 KE(t){this.exit(t)}function ZE(){return"["}function ov(t,i,l,a){const o=l.createTracker(a);let f=o.move("[^");const u=l.enter("footnoteReference"),p=l.enter("reference");return f+=o.move(l.safe(l.associationId(t),{after:"]",before:f})),p(),u(),f+=o.move("]"),f}function PE(){return{enter:{gfmFootnoteCallString:VE,gfmFootnoteCall:YE,gfmFootnoteDefinitionLabelString:GE,gfmFootnoteDefinition:FE},exit:{gfmFootnoteCallString:QE,gfmFootnoteCall:$E,gfmFootnoteDefinitionLabelString:XE,gfmFootnoteDefinition:KE}}}function JE(t){let i=!1;return t&&t.firstLineBlank&&(i=!0),{handlers:{footnoteDefinition:l,footnoteReference:ov},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function l(a,o,f,u){const p=f.createTracker(u);let h=p.move("[^");const m=f.enter("footnoteDefinition"),y=f.enter("label");return h+=p.move(f.safe(f.associationId(a),{before:h,after:"]"})),y(),h+=p.move("]:"),a.children&&a.children.length>0&&(p.shift(4),h+=p.move((i?`
42
+ `:" ")+f.indentLines(f.containerFlow(a,p.current()),i?uv:WE))),m(),h}}function WE(t,i,l){return i===0?t:uv(t,i,l)}function uv(t,i,l){return(l?"":" ")+t}const e2=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];cv.peek=l2;function t2(){return{canContainEols:["delete"],enter:{strikethrough:i2},exit:{strikethrough:r2}}}function n2(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:e2}],handlers:{delete:cv}}}function i2(t){this.enter({type:"delete",children:[]},t)}function r2(t){this.exit(t)}function cv(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 l2(){return"~"}function a2(t){return t.length}function s2(t,i){const l=i||{},a=(l.align||[]).concat(),o=l.stringLength||a2,f=[],u=[],p=[],h=[];let m=0,y=-1;for(;++y<t.length;){const _=[],D=[];let R=-1;for(t[y].length>m&&(m=t[y].length);++R<t[y].length;){const z=o2(t[y][R]);if(l.alignDelimiters!==!1){const L=o(z);D[R]=L,(h[R]===void 0||L>h[R])&&(h[R]=L)}_.push(z)}u[y]=_,p[y]=D}let b=-1;if(typeof a=="object"&&"length"in a)for(;++b<m;)f[b]=Xy(a[b]);else{const _=Xy(a);for(;++b<m;)f[b]=_}b=-1;const v=[],x=[];for(;++b<m;){const _=f[b];let D="",R="";_===99?(D=":",R=":"):_===108?D=":":_===114&&(R=":");let z=l.alignDelimiters===!1?1:Math.max(1,h[b]-D.length-R.length);const L=D+"-".repeat(z)+R;l.alignDelimiters!==!1&&(z=D.length+z+R.length,z>h[b]&&(h[b]=z),x[b]=z),v[b]=L}u.splice(1,0,v),p.splice(1,0,x),y=-1;const k=[];for(;++y<u.length;){const _=u[y],D=p[y];b=-1;const R=[];for(;++b<m;){const z=_[b]||"";let L="",G="";if(l.alignDelimiters!==!1){const ae=h[b]-(D[b]||0),T=f[b];T===114?L=" ".repeat(ae):T===99?ae%2?(L=" ".repeat(ae/2+.5),G=" ".repeat(ae/2-.5)):(L=" ".repeat(ae/2),G=L):G=" ".repeat(ae)}l.delimiterStart!==!1&&!b&&R.push("|"),l.padding!==!1&&!(l.alignDelimiters===!1&&z==="")&&(l.delimiterStart!==!1||b)&&R.push(" "),l.alignDelimiters!==!1&&R.push(L),R.push(z),l.alignDelimiters!==!1&&R.push(G),l.padding!==!1&&R.push(" "),(l.delimiterEnd!==!1||b!==m-1)&&R.push("|")}k.push(l.delimiterEnd===!1?R.join("").replace(/ +$/,""):R.join(""))}return k.join(`
43
+ `)}function o2(t){return t==null?"":String(t)}function Xy(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 u2(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()),c2);return o(),u}function c2(t,i,l){return">"+(l?"":" ")+t}function f2(t,i){return Ky(t,i.inConstruct,!0)&&!Ky(t,i.notInConstruct,!1)}function Ky(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 Zy(t,i,l,a){let o=-1;for(;++o<l.unsafe.length;)if(l.unsafe[o].character===`
44
+ `&&f2(l.stack,l.unsafe[o]))return/[ \t]/.test(a.before)?"":" ";return`\\
45
+ `}function d2(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 h2(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 p2(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 m2(t,i,l,a){const o=p2(l),f=t.value||"",u=o==="`"?"GraveAccent":"Tilde";if(h2(t,l)){const b=l.enter("codeIndented"),v=l.indentLines(f,g2);return b(),v}const p=l.createTracker(a),h=o.repeat(Math.max(d2(f,o)+1,3)),m=l.enter("codeFenced");let y=p.move(h);if(t.lang){const b=l.enter(`codeFencedLang${u}`);y+=p.move(l.safe(t.lang,{before:y,after:" ",encode:["`"],...p.current()})),b()}if(t.lang&&t.meta){const b=l.enter(`codeFencedMeta${u}`);y+=p.move(" "),y+=p.move(l.safe(t.meta,{before:y,after:`
46
+ `,encode:["`"],...p.current()})),b()}return y+=p.move(`
47
+ `),f&&(y+=p.move(f+`
48
+ `)),y+=p.move(h),m(),y}function g2(t,i,l){return(l?"":" ")+t}function yd(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 y2(t,i,l,a){const o=yd(l),f=o==='"'?"Quote":"Apostrophe",u=l.enter("definition");let p=l.enter("label");const h=l.createTracker(a);let m=h.move("[");return m+=h.move(l.safe(l.associationId(t),{before:m,after:"]",...h.current()})),m+=h.move("]: "),p(),!t.url||/[\0- \u007F]/.test(t.url)?(p=l.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(l.safe(t.url,{before:m,after:">",...h.current()})),m+=h.move(">")):(p=l.enter("destinationRaw"),m+=h.move(l.safe(t.url,{before:m,after:t.title?" ":`
49
+ `,...h.current()}))),p(),t.title&&(p=l.enter(`title${f}`),m+=h.move(" "+o),m+=h.move(l.safe(t.title,{before:m,after:o,...h.current()})),m+=h.move(o),p()),u(),m}function b2(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 xa(t){return"&#x"+t.toString(16).toUpperCase()+";"}function lo(t,i,l){const a=cl(t),o=cl(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}}fv.peek=v2;function fv(t,i,l,a){const o=b2(l),f=l.enter("emphasis"),u=l.createTracker(a),p=u.move(o);let h=u.move(l.containerPhrasing(t,{after:o,before:p,...u.current()}));const m=h.charCodeAt(0),y=lo(a.before.charCodeAt(a.before.length-1),m,o);y.inside&&(h=xa(m)+h.slice(1));const b=h.charCodeAt(h.length-1),v=lo(a.after.charCodeAt(0),b,o);v.inside&&(h=h.slice(0,-1)+xa(b));const x=u.move(o);return f(),l.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},p+h+x}function v2(t,i,l){return l.options.emphasis||"*"}function x2(t,i){let l=!1;return md(t,function(a){if("value"in a&&/\r?\n|\r/.test(a.value)||a.type==="break")return l=!0,Uf}),!!((!t.depth||t.depth<3)&&od(t)&&(i.options.setext||l))}function S2(t,i,l,a){const o=Math.max(Math.min(6,t.depth||1),1),f=l.createTracker(a);if(x2(t,l)){const y=l.enter("headingSetext"),b=l.enter("phrasing"),v=l.containerPhrasing(t,{...f.current(),before:`
50
+ `,after:`
51
+ `});return b(),y(),v+`
52
+ `+(o===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
53
+ `))+1))}const u="#".repeat(o),p=l.enter("headingAtx"),h=l.enter("phrasing");f.move(u+" ");let m=l.containerPhrasing(t,{before:"# ",after:`
54
+ `,...f.current()});return/^[\t ]/.test(m)&&(m=xa(m.charCodeAt(0))+m.slice(1)),m=m?u+" "+m:u,l.options.closeAtx&&(m+=" "+u),h(),p(),m}dv.peek=w2;function dv(t){return t.value||""}function w2(){return"<"}hv.peek=j2;function hv(t,i,l,a){const o=yd(l),f=o==='"'?"Quote":"Apostrophe",u=l.enter("image");let p=l.enter("label");const h=l.createTracker(a);let m=h.move("![");return m+=h.move(l.safe(t.alt,{before:m,after:"]",...h.current()})),m+=h.move("]("),p(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(p=l.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(l.safe(t.url,{before:m,after:">",...h.current()})),m+=h.move(">")):(p=l.enter("destinationRaw"),m+=h.move(l.safe(t.url,{before:m,after:t.title?" ":")",...h.current()}))),p(),t.title&&(p=l.enter(`title${f}`),m+=h.move(" "+o),m+=h.move(l.safe(t.title,{before:m,after:o,...h.current()})),m+=h.move(o),p()),m+=h.move(")"),u(),m}function j2(){return"!"}pv.peek=k2;function pv(t,i,l,a){const o=t.referenceType,f=l.enter("imageReference");let u=l.enter("label");const p=l.createTracker(a);let h=p.move("![");const m=l.safe(t.alt,{before:h,after:"]",...p.current()});h+=p.move(m+"]["),u();const y=l.stack;l.stack=[],u=l.enter("reference");const b=l.safe(l.associationId(t),{before:h,after:"]",...p.current()});return u(),l.stack=y,f(),o==="full"||!m||m!==b?h+=p.move(b+"]"):o==="shortcut"?h=h.slice(0,-1):h+=p.move("]"),h}function k2(){return"!"}mv.peek=C2;function mv(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],p=l.compilePattern(u);let h;if(u.atBreak)for(;h=p.exec(a);){let m=h.index;a.charCodeAt(m)===10&&a.charCodeAt(m-1)===13&&m--,a=a.slice(0,m)+" "+a.slice(h.index+1)}}return o+a+o}function C2(){return"`"}function gv(t,i){const l=od(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))}yv.peek=E2;function yv(t,i,l,a){const o=yd(l),f=o==='"'?"Quote":"Apostrophe",u=l.createTracker(a);let p,h;if(gv(t,l)){const y=l.stack;l.stack=[],p=l.enter("autolink");let b=u.move("<");return b+=u.move(l.containerPhrasing(t,{before:b,after:">",...u.current()})),b+=u.move(">"),p(),l.stack=y,b}p=l.enter("link"),h=l.enter("label");let m=u.move("[");return m+=u.move(l.containerPhrasing(t,{before:m,after:"](",...u.current()})),m+=u.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=l.enter("destinationLiteral"),m+=u.move("<"),m+=u.move(l.safe(t.url,{before:m,after:">",...u.current()})),m+=u.move(">")):(h=l.enter("destinationRaw"),m+=u.move(l.safe(t.url,{before:m,after:t.title?" ":")",...u.current()}))),h(),t.title&&(h=l.enter(`title${f}`),m+=u.move(" "+o),m+=u.move(l.safe(t.title,{before:m,after:o,...u.current()})),m+=u.move(o),h()),m+=u.move(")"),p(),m}function E2(t,i,l){return gv(t,l)?"<":"["}bv.peek=N2;function bv(t,i,l,a){const o=t.referenceType,f=l.enter("linkReference");let u=l.enter("label");const p=l.createTracker(a);let h=p.move("[");const m=l.containerPhrasing(t,{before:h,after:"]",...p.current()});h+=p.move(m+"]["),u();const y=l.stack;l.stack=[],u=l.enter("reference");const b=l.safe(l.associationId(t),{before:h,after:"]",...p.current()});return u(),l.stack=y,f(),o==="full"||!m||m!==b?h+=p.move(b+"]"):o==="shortcut"?h=h.slice(0,-1):h+=p.move("]"),h}function N2(){return"["}function bd(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 A2(t){const i=bd(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 T2(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 vv(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 z2(t,i,l,a){const o=l.enter("list"),f=l.bulletCurrent;let u=t.ordered?T2(l):bd(l);const p=t.ordered?u==="."?")":".":A2(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),vv(l)===u&&y){let b=-1;for(;++b<t.children.length;){const v=t.children[b];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(u=p),l.bulletCurrent=u;const m=l.containerFlow(t,a);return l.bulletLastUsed=u,l.bulletCurrent=f,o(),m}function R2(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 D2(t,i,l,a){const o=R2(l);let f=l.bulletCurrent||bd(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 p=l.createTracker(a);p.move(f+" ".repeat(u-f.length)),p.shift(u);const h=l.enter("listItem"),m=l.indentLines(l.containerFlow(t,p.current()),y);return h(),m;function y(b,v,x){return v?(x?"":" ".repeat(u))+b:(x?f:f+" ".repeat(u-f.length))+b}}function M2(t,i,l,a){const o=l.enter("paragraph"),f=l.enter("phrasing"),u=l.containerPhrasing(t,a);return f(),o(),u}const _2=ho(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function O2(t,i,l,a){return(t.children.some(function(u){return _2(u)})?l.containerPhrasing:l.containerFlow).call(l,t,a)}function L2(t){const i=t.options.strong||"*";if(i!=="*"&&i!=="_")throw new Error("Cannot serialize strong with `"+i+"` for `options.strong`, expected `*`, or `_`");return i}xv.peek=B2;function xv(t,i,l,a){const o=L2(l),f=l.enter("strong"),u=l.createTracker(a),p=u.move(o+o);let h=u.move(l.containerPhrasing(t,{after:o,before:p,...u.current()}));const m=h.charCodeAt(0),y=lo(a.before.charCodeAt(a.before.length-1),m,o);y.inside&&(h=xa(m)+h.slice(1));const b=h.charCodeAt(h.length-1),v=lo(a.after.charCodeAt(0),b,o);v.inside&&(h=h.slice(0,-1)+xa(b));const x=u.move(o+o);return f(),l.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},p+h+x}function B2(t,i,l){return l.options.strong||"*"}function U2(t,i,l,a){return l.safe(t.value,a)}function q2(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 I2(t,i,l){const a=(vv(l)+(l.options.ruleSpaces?" ":"")).repeat(q2(l));return l.options.ruleSpaces?a.slice(0,-1):a}const Sv={blockquote:u2,break:Zy,code:m2,definition:y2,emphasis:fv,hardBreak:Zy,heading:S2,html:dv,image:hv,imageReference:pv,inlineCode:mv,link:yv,linkReference:bv,list:z2,listItem:D2,paragraph:M2,root:O2,strong:xv,text:U2,thematicBreak:I2};function H2(){return{enter:{table:V2,tableData:Py,tableHeader:Py,tableRow:G2},exit:{codeText:F2,table:Y2,tableData:Cf,tableHeader:Cf,tableRow:Cf}}}function V2(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 Y2(t){this.exit(t),this.data.inTable=void 0}function G2(t){this.enter({type:"tableRow",children:[]},t)}function Cf(t){this.exit(t)}function Py(t){this.enter({type:"tableCell",children:[]},t)}function F2(t){let i=this.resume();this.data.inTable&&(i=i.replace(/\\([\\|])/g,Q2));const l=this.stack[this.stack.length-1];l.type,l.value=i,this.exit(t)}function Q2(t,i){return i==="|"?i:t}function $2(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:v,table:u,tableCell:h,tableRow:p}};function u(x,k,_,D){return m(y(x,_,D),x.align)}function p(x,k,_,D){const R=b(x,_,D),z=m([R]);return z.slice(0,z.indexOf(`
56
+ `))}function h(x,k,_,D){const R=_.enter("tableCell"),z=_.enter("phrasing"),L=_.containerPhrasing(x,{...D,before:f,after:f});return z(),R(),L}function m(x,k){return s2(x,{align:k,alignDelimiters:a,padding:l,stringLength:o})}function y(x,k,_){const D=x.children;let R=-1;const z=[],L=k.enter("table");for(;++R<D.length;)z[R]=b(D[R],k,_);return L(),z}function b(x,k,_){const D=x.children;let R=-1;const z=[],L=k.enter("tableRow");for(;++R<D.length;)z[R]=h(D[R],x,k,_);return L(),z}function v(x,k,_){let D=Sv.inlineCode(x,k,_);return _.stack.includes("tableCell")&&(D=D.replace(/\|/g,"\\$&")),D}}function X2(){return{exit:{taskListCheckValueChecked:Jy,taskListCheckValueUnchecked:Jy,paragraph:Z2}}}function K2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:P2}}}function Jy(t){const i=this.stack[this.stack.length-2];i.type,i.checked=t.type==="taskListCheckValueChecked"}function Z2(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 p=o[f];if(p.type==="paragraph"){u=p;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 P2(t,i,l,a){const o=t.children[0],f=typeof t.checked=="boolean"&&o&&o.type==="paragraph",u="["+(t.checked?"x":" ")+"] ",p=l.createTracker(a);f&&p.move(u);let h=Sv.listItem(t,i,l,{...a,...p.current()});return f&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),h;function m(y){return y+u}}function J2(){return[zE(),PE(),t2(),H2(),X2()]}function W2(t){return{extensions:[RE(),JE(t),n2(),$2(t),K2()]}}const eN={tokenize:aN,partial:!0},wv={tokenize:sN,partial:!0},jv={tokenize:oN,partial:!0},kv={tokenize:uN,partial:!0},tN={tokenize:cN,partial:!0},Cv={name:"wwwAutolink",tokenize:rN,previous:Nv},Ev={name:"protocolAutolink",tokenize:lN,previous:Av},vi={name:"emailAutolink",tokenize:iN,previous:Tv},Pn={};function nN(){return{text:Pn}}let fr=48;for(;fr<123;)Pn[fr]=vi,fr++,fr===58?fr=65:fr===91&&(fr=97);Pn[43]=vi;Pn[45]=vi;Pn[46]=vi;Pn[95]=vi;Pn[72]=[vi,Ev];Pn[104]=[vi,Ev];Pn[87]=[vi,Cv];Pn[119]=[vi,Cv];function iN(t,i,l){const a=this;let o,f;return u;function u(b){return!Vf(b)||!Tv.call(a,a.previous)||vd(a.events)?l(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),p(b))}function p(b){return Vf(b)?(t.consume(b),p):b===64?(t.consume(b),h):l(b)}function h(b){return b===46?t.check(tN,y,m)(b):b===45||b===95||nn(b)?(f=!0,t.consume(b),h):y(b)}function m(b){return t.consume(b),o=!0,h}function y(b){return f&&o&&sn(a.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),i(b)):l(b)}}function rN(t,i,l){const a=this;return o;function o(u){return u!==87&&u!==119||!Nv.call(a,a.previous)||vd(a.events)?l(u):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(eN,t.attempt(wv,t.attempt(jv,f),l),l)(u))}function f(u){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),i(u)}}function lN(t,i,l){const a=this;let o="",f=!1;return u;function u(b){return(b===72||b===104)&&Av.call(a,a.previous)&&!vd(a.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),o+=String.fromCodePoint(b),t.consume(b),p):l(b)}function p(b){if(sn(b)&&o.length<5)return o+=String.fromCodePoint(b),t.consume(b),p;if(b===58){const v=o.toLowerCase();if(v==="http"||v==="https")return t.consume(b),h}return l(b)}function h(b){return b===47?(t.consume(b),f?m:(f=!0,h)):l(b)}function m(b){return b===null||no(b)||Tt(b)||mr(b)||uo(b)?l(b):t.attempt(wv,t.attempt(jv,y),l)(b)}function y(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),i(b)}}function aN(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 sN(t,i,l){let a,o,f;return u;function u(m){return m===46||m===95?t.check(kv,h,p)(m):m===null||Tt(m)||mr(m)||m!==45&&uo(m)?h(m):(f=!0,t.consume(m),u)}function p(m){return m===95?a=!0:(o=a,a=void 0),t.consume(m),u}function h(m){return o||a||!f?l(m):i(m)}}function oN(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(kv,i,f)(u):u===null||Tt(u)||mr(u)?i(u):(t.consume(u),o)}function f(u){return u===41&&a++,t.consume(u),o}}function uN(t,i,l){return a;function a(p){return p===33||p===34||p===39||p===41||p===42||p===44||p===46||p===58||p===59||p===63||p===95||p===126?(t.consume(p),a):p===38?(t.consume(p),f):p===93?(t.consume(p),o):p===60||p===null||Tt(p)||mr(p)?i(p):l(p)}function o(p){return p===null||p===40||p===91||Tt(p)||mr(p)?i(p):a(p)}function f(p){return sn(p)?u(p):l(p)}function u(p){return p===59?(t.consume(p),a):sn(p)?(t.consume(p),u):l(p)}}function cN(t,i,l){return a;function a(f){return t.consume(f),o}function o(f){return nn(f)?l(f):i(f)}}function Nv(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Tt(t)}function Av(t){return!sn(t)}function Tv(t){return!(t===47||Vf(t))}function Vf(t){return t===43||t===45||t===46||t===95||nn(t)}function vd(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 fN={tokenize:vN,partial:!0};function dN(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:gN,continuation:{tokenize:yN},exit:bN}},text:{91:{name:"gfmFootnoteCall",tokenize:mN},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hN,resolveTo:pN}}}}function hN(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 p;function p(h){if(!u||!u._balanced)return l(h);const m=Yn(a.sliceSerialize({start:u.end,end:a.now()}));return m.codePointAt(0)!==94||!f.includes(m.slice(1))?l(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),i(h))}}function pN(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)},p=[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,...p),t}function mN(t,i,l){const a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let f=0,u;return p;function p(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",m)}function m(b){if(f>999||b===93&&!u||b===null||b===91||Tt(b))return l(b);if(b===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return o.includes(Yn(a.sliceSerialize(v)))?(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:m}function y(b){return b===91||b===92||b===93?(t.consume(b),f++,m):m(b)}}function gN(t,i,l){const a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let f,u=0,p;return h;function h(k){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(k),t.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(k){return k===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(k),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",y):l(k)}function y(k){if(u>999||k===93&&!p||k===null||k===91||Tt(k))return l(k);if(k===93){t.exit("chunkString");const _=t.exit("gfmFootnoteDefinitionLabelString");return f=Yn(a.sliceSerialize(_)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(k),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return Tt(k)||(p=!0),u++,t.consume(k),k===92?b:y}function b(k){return k===91||k===92||k===93?(t.consume(k),u++,y):y(k)}function v(k){return k===58?(t.enter("definitionMarker"),t.consume(k),t.exit("definitionMarker"),o.includes(f)||o.push(f),ot(t,x,"gfmFootnoteDefinitionWhitespace")):l(k)}function x(k){return i(k)}}function yN(t,i,l){return t.check(ka,i,t.attempt(fN,i,l))}function bN(t){t.exit("gfmFootnoteDefinition")}function vN(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 xN(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,p){let h=-1;for(;++h<u.length;)if(u[h][0]==="enter"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._close){let m=h;for(;m--;)if(u[m][0]==="exit"&&u[m][1].type==="strikethroughSequenceTemporary"&&u[m][1]._open&&u[h][1].end.offset-u[h][1].start.offset===u[m][1].end.offset-u[m][1].start.offset){u[h][1].type="strikethroughSequence",u[m][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},u[m][1].start),end:Object.assign({},u[h][1].end)},b={type:"strikethroughText",start:Object.assign({},u[m][1].end),end:Object.assign({},u[h][1].start)},v=[["enter",y,p],["enter",u[m][1],p],["exit",u[m][1],p],["enter",b,p]],x=p.parser.constructs.insideSpan.null;x&&En(v,v.length,0,co(x,u.slice(m+1,h),p)),En(v,v.length,0,[["exit",b,p],["enter",u[h][1],p],["exit",u[h][1],p],["exit",y,p]]),En(u,m-1,h-m+3,v),h=m+v.length-2;break}}for(h=-1;++h<u.length;)u[h][1].type==="strikethroughSequenceTemporary"&&(u[h][1].type="data");return u}function f(u,p,h){const m=this.previous,y=this.events;let b=0;return v;function v(k){return m===126&&y[y.length-1][1].type!=="characterEscape"?h(k):(u.enter("strikethroughSequenceTemporary"),x(k))}function x(k){const _=cl(m);if(k===126)return b>1?h(k):(u.consume(k),b++,x);if(b<2&&!l)return h(k);const D=u.exit("strikethroughSequenceTemporary"),R=cl(k);return D._open=!R||R===2&&!!_,D._close=!_||_===2&&!!R,p(k)}}}class SN{constructor(){this.map=[]}add(i,l,a){wN(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 wN(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 jN(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 kN(){return{flow:{null:{name:"table",tokenize:CN,resolveAll:EN}}}}function CN(t,i,l){const a=this;let o=0,f=0,u;return p;function p(E){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 H=B>-1?a.events[B][1].type:null,Z=H==="tableHead"||H==="tableRow"?T:h;return Z===T&&a.parser.lazy[a.now().line]?l(E):Z(E)}function h(E){return t.enter("tableHead"),t.enter("tableRow"),m(E)}function m(E){return E===124||(u=!0,f+=1),y(E)}function y(E){return E===null?l(E):Oe(E)?f>1?(f=0,a.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(E),t.exit("lineEnding"),x):l(E):We(E)?ot(t,y,"whitespace")(E):(f+=1,u&&(u=!1,o+=1),E===124?(t.enter("tableCellDivider"),t.consume(E),t.exit("tableCellDivider"),u=!0,y):(t.enter("data"),b(E)))}function b(E){return E===null||E===124||Tt(E)?(t.exit("data"),y(E)):(t.consume(E),E===92?v:b)}function v(E){return E===92||E===124?(t.consume(E),b):b(E)}function x(E){return a.interrupt=!1,a.parser.lazy[a.now().line]?l(E):(t.enter("tableDelimiterRow"),u=!1,We(E)?ot(t,k,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):k(E))}function k(E){return E===45||E===58?D(E):E===124?(u=!0,t.enter("tableCellDivider"),t.consume(E),t.exit("tableCellDivider"),_):ae(E)}function _(E){return We(E)?ot(t,D,"whitespace")(E):D(E)}function D(E){return E===58?(f+=1,u=!0,t.enter("tableDelimiterMarker"),t.consume(E),t.exit("tableDelimiterMarker"),R):E===45?(f+=1,R(E)):E===null||Oe(E)?G(E):ae(E)}function R(E){return E===45?(t.enter("tableDelimiterFiller"),z(E)):ae(E)}function z(E){return E===45?(t.consume(E),z):E===58?(u=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(E),t.exit("tableDelimiterMarker"),L):(t.exit("tableDelimiterFiller"),L(E))}function L(E){return We(E)?ot(t,G,"whitespace")(E):G(E)}function G(E){return E===124?k(E):E===null||Oe(E)?!u||o!==f?ae(E):(t.exit("tableDelimiterRow"),t.exit("tableHead"),i(E)):ae(E)}function ae(E){return l(E)}function T(E){return t.enter("tableRow"),V(E)}function V(E){return E===124?(t.enter("tableCellDivider"),t.consume(E),t.exit("tableCellDivider"),V):E===null||Oe(E)?(t.exit("tableRow"),i(E)):We(E)?ot(t,V,"whitespace")(E):(t.enter("data"),$(E))}function $(E){return E===null||E===124||Tt(E)?(t.exit("data"),V(E)):(t.consume(E),E===92?q:$)}function q(E){return E===92||E===124?(t.consume(E),$):$(E)}}function EN(t,i){let l=-1,a=!0,o=0,f=[0,0,0,0],u=[0,0,0,0],p=!1,h=0,m,y,b;const v=new SN;for(;++l<t.length;){const x=t[l],k=x[1];x[0]==="enter"?k.type==="tableHead"?(p=!1,h!==0&&(Wy(v,i,h,m,y),y=void 0,h=0),m={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},v.add(l,0,[["enter",m,i]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(a=!0,b=void 0,f=[0,0,0,0],u=[0,l+1,0,0],p&&(p=!1,y={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},v.add(l,0,[["enter",y,i]])),o=k.type==="tableDelimiterRow"?2:y?3:1):o&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(a=!1,u[2]===0&&(f[1]!==0&&(u[0]=u[1],b=Xs(v,i,f,o,void 0,b),f=[0,0,0,0]),u[2]=l)):k.type==="tableCellDivider"&&(a?a=!1:(f[1]!==0&&(u[0]=u[1],b=Xs(v,i,f,o,void 0,b)),f=u,u=[f[1],l,0,0])):k.type==="tableHead"?(p=!0,h=l):k.type==="tableRow"||k.type==="tableDelimiterRow"?(h=l,f[1]!==0?(u[0]=u[1],b=Xs(v,i,f,o,l,b)):u[1]!==0&&(b=Xs(v,i,u,o,l,b)),o=0):o&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(u[3]=l)}for(h!==0&&Wy(v,i,h,m,y),v.consume(i.events),l=-1;++l<i.events.length;){const x=i.events[l];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=jN(i.events,l))}return t}function Xs(t,i,l,a,o,f){const u=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",p="tableContent";l[0]!==0&&(f.end=Object.assign({},ul(i.events,l[0])),t.add(l[0],0,[["exit",f,i]]));const h=ul(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 m=ul(i.events,l[2]),y=ul(i.events,l[3]),b={type:p,start:Object.assign({},m),end:Object.assign({},y)};if(t.add(l[2],0,[["enter",b,i]]),a!==2){const v=i.events[l[2]],x=i.events[l[3]];if(v[1].end=Object.assign({},x[1].end),v[1].type="chunkText",v[1].contentType="text",l[3]>l[2]+1){const k=l[2]+1,_=l[3]-l[2]-1;t.add(k,_,[])}}t.add(l[3]+1,0,[["exit",b,i]])}return o!==void 0&&(f.end=Object.assign({},ul(i.events,o)),t.add(o,0,[["exit",f,i]]),f=void 0),f}function Wy(t,i,l,a,o){const f=[],u=ul(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 ul(t,i){const l=t[i],a=l[0]==="enter"?"start":"end";return l[1][a]}const NN={name:"tasklistCheck",tokenize:TN};function AN(){return{text:{91:NN}}}function TN(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"),p):l(h)}function p(h){return Oe(h)?i(h):We(h)?t.check({tokenize:zN},i,l)(h):l(h)}}function zN(t,i,l){return ot(t,a,"whitespace");function a(o){return o===null?l(o):i(o)}}function RN(t){return Ib([nN(),dN(),xN(t),kN(),AN()])}const DN={};function MN(t){const i=this,l=t||DN,a=i.data(),o=a.micromarkExtensions||(a.micromarkExtensions=[]),f=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),u=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);o.push(RN(l)),f.push(J2()),u.push(W2(l))}function Yf(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 Gf(t){return!!t&&!/[\u0000-\u001f\u007f]/.test(t)&&!/^[a-z][a-z\d+.-]*:/i.test(t)&&!t.startsWith("//")}function eb(t){if(!Gf(t))return;const i=t.split(/[?#]/,1)[0];if(i)try{const l=decodeURIComponent(i);return Gf(l)?l:void 0}catch{return}}async function _N(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 mo({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 _N(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 Ff(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(Ff).join(""):w.isValidElement(t)?Ff(t.props.children):""}function ON({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=Ff(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(mo,{text:o,label:"复制代码"})]}),c.jsx("pre",{tabIndex:0,children:t})]})}function LN(t){return{a:({href:i,children:l,title:a})=>{const o=Yf(i??"");if(o)return c.jsx("a",{href:o,title:a,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:l});const f=i?eb(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(mo,{text:f,label:"复制路径"})]}):c.jsx("span",{children:l})},img:({src:i,alt:l})=>{const a=Yf(typeof i=="string"?i:""),o=typeof i=="string"?eb(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(ON,{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 BN=w.memo(function({text:i,reasoning:l="",streaming:a=!1,onOpenFile:o}){const f=w.useMemo(()=>LN(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(xE,{remarkPlugins:[MN],skipHtml:!0,urlTransform:u=>Yf(u)??(Gf(u)?u:""),components:f,children:i}):null,!a&&i?c.jsx("div",{className:"message-actions",children:c.jsx(mo,{text:i,label:"复制回复"})}):null]})});function UN(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 qN=w.memo(function({item:i,running:l}){const a=UN(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(mo,{text:i.result,label:"复制结果"}):null]}),c.jsx("pre",{tabIndex:0,children:i.result??(i.done?"工具没有返回文本内容。":l?"等待工具返回结果…":"这次工具调用没有保存结果。")})]})]})});function IN(t){return{running:"运行中",completed:"已完成",error:"失败",recorded:"历史记录"}[t]??t}function HN(t){const i=new URLSearchParams(t).get("session");return i&&/^[a-zA-Z0-9_-]{1,128}$/.test(i)?i:null}function zv(t,i){return!i||!t.hubEpoch||t.hubSequence===void 0?!0:t.hubEpoch===i.epoch&&t.hubSequence>i.sequence}function tb(t,i=[]){let l=Sb(t.transcript);for(const o of t.liveStream?.events??[])l=hr(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)zv(o,a)&&(l=hr(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 VN(t,i,l,a){let o=t.outputJournal??await i({});if(o.status==="unavailable")return null;if(o.status!=="ok"||!o.legacyBaseThroughEventId||t.transcript[0]?.type!=="session_meta")throw new Error("Output recovery has no complete legacy base");const f=t.transcript.findIndex(y=>y.id===o.legacyBaseThroughEventId);if(f<0)throw new Error("Output recovery legacy anchor was not retained");let u=Sb(t.transcript.slice(0,f+1)),p={incomplete:!1},h=0;const m=async()=>{for(;;){if(++h>2048)throw new Error("Output recovery exceeded its page budget");const y=kS(p,o,b=>{u=hr(u,b)});if(p.incomplete)throw new Error("Output recovery is incomplete");if(y)break;o=await i({after:p.cursor,through:p.through})}};await m();for(let y=0;y<8;y++){const b=a?.()??[...l].reverse().find(x=>typeof x.event.outputCursor=="string")?.event.outputCursor;if(typeof b!="string")break;const v=Rf(b,p.cursor);if(v===void 0)throw new Error("Output recovery journal changed");if(v<=0)break;if(y===7)throw new Error("Output recovery could not catch up within its round budget");p={incomplete:!1,cursor:p.appliedCursor},o=await i({after:p.cursor,through:b}),await m()}for(const y of l){const b=y.event.outputCursor;if(typeof b=="string"){const v=Rf(b,p.cursor);if(v===void 0)throw new Error("Output recovery journal changed");if(v<=0)continue;p.cursor=b}else if(y.event.type==="session_title"){u=hr(u,y.event);continue}else{if(y.event.type==="session_user_message"&&typeof y.event.clientMessageId=="string"&&u.items.some(v=>v.kind==="user"&&v.clientMessageId===y.event.clientMessageId))continue;throw new Error("Output recovery received an unpaired legacy event")}u=hr(u,y.event)}return{chat:u,outputCursor:p.cursor}}function Rv(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 YN(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 GN({controller:t,onBackToProjects:i,projectName:l}){const{connection:a,sessions:o,activeId:f,chat:u,draft:p,files:h,uploading:m,workerNote:y,replayNote:b,error:v,workspaceCwd:x,workspaceName:k,configuration:_,configurationVersion:D,sessionsVersion:R,localDrafts:z,running:L,title:G,approvalCount:ae,onAuthLost:T,refreshSessions:V,refreshConfiguration:$,session:q}=t,E=t.workspaceApi,B=t.host==="desktop"?"桌面":"服务端",[H,Z]=w.useState(!1),ee=w.useRef(null),W=w.useRef(null),[N,X]=w.useState(()=>new URLSearchParams(window.location?.search??"").get("view")==="links"?"links":"chat"),[pe,ye]=w.useState(),[j,O]=w.useState(),[J,A]=w.useState(0),[le,me]=w.useState(!1),[te,se]=w.useState(null),[we,F]=w.useState("overview"),[Se,Ne]=w.useState(()=>window.matchMedia("(max-width: 760px)").matches),[Te,Ge]=w.useState(()=>!window.matchMedia("(max-width: 760px)").matches),et=w.useRef(null),dt=w.useRef(null),Fe=w.useRef(!1),Ct=w.useRef(null),ht=w.useRef(null),qe=w.useRef(!0);w.useEffect(()=>{ye(void 0),X(Q=>Q==="panel"?"panels":Q)},[t.workspaceKey]),w.useEffect(()=>{Se&&!Te&&Fe.current&&!H&&dt.current?.focus(),Fe.current=Te},[Se,Te,H]),w.useEffect(()=>{const Q=window.matchMedia("(max-width: 760px)"),ve=()=>{Ne(Q.matches),Ge(!Q.matches)};return Q.addEventListener("change",ve),()=>Q.removeEventListener("change",ve)},[]),w.useEffect(()=>{if(!Se||!Te)return;const Q=et.current;Q?.querySelector("button")?.focus();const ve=ze=>{if(!document.querySelector("dialog[open]")){if(ze.key==="Escape"&&!ze.isComposing)ze.preventDefault(),Ge(!1),dt.current?.focus();else if(ze.key==="Tab"){const De=Array.from(Q?.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), textarea:not(:disabled), a[href], summary, [tabindex]:not([tabindex="-1"])')??[]).filter(ke=>ke.getClientRects().length>0),$e=De?.[0],ce=De?.[De.length-1];ze.shiftKey&&document.activeElement===$e?(ze.preventDefault(),ce?.focus()):!ze.shiftKey&&document.activeElement===ce&&(ze.preventDefault(),$e?.focus())}}};return document.addEventListener("keydown",ve),()=>document.removeEventListener("keydown",ve)},[Se,Te]),w.useLayoutEffect(()=>{const Q=ht.current;!Q||N!=="chat"||(Q.style.height="auto",Q.style.height=`${Math.min(180,Math.max(64,Q.scrollHeight))}px`)},[p,N]),w.useLayoutEffect(()=>{const Q=Ct.current;Q&&qe.current&&N==="chat"&&(Q.scrollTop=Q.scrollHeight)},[u.items,t.approvals.length,N]);const pt=()=>{Se&&(Ge(!1),dt.current?.focus())},Ve=Q=>{if(N==="settings"&&we===Q){pt();return}tt(()=>{F(Q),X("settings"),pt()})},tt=Q=>{le?se(()=>Q):Q()},zt=Q=>tt(()=>{O(Q),A(ve=>ve+1),X("files"),pt()}),rt=w.useRef(zt);rt.current=zt;const yt=w.useCallback(Q=>rt.current(Q),[]);w.useEffect(()=>{if(!le&&!t.uploadBusy&&!t.hasUnsent)return;const Q=ve=>{ve.preventDefault(),ve.returnValue=""};return window.addEventListener("beforeunload",Q),()=>window.removeEventListener("beforeunload",Q)},[le,t.uploadBusy,t.hasUnsent]);const M=Q=>tt(()=>{X("chat"),pt(),qe.current=!0,Q()}),K=Q=>M(()=>{t.selectSession(Q)}),ge=()=>M(t.newSession),be=()=>{qe.current=!0,t.send()},Ee=t.stop,Le=t.approvals.filter(Q=>!Q.sessionId||Q.sessionId===f),Ke=t.approvals.filter(Q=>Q.sessionId&&Q.sessionId!==f),bt=u.items.length===0&&Le.length===0,mt=_?.connections.find(Q=>Q.id===_.defaults.text),lt=a==="open"?"已连接":a==="connecting"?"连接中":"正在重连",Ze=N==="chat"?G:N==="files"?"工作区文件":N==="history"?"历史对话":N==="links"?"Link":N==="panels"||N==="panel"?pe&&N==="panel"?pe.panel.title["zh-CN"]||pe.panel.title.default:"面板":we==="skills"?"Skills":"设置";return c.jsxs("div",{className:`shell${Te?" sidebar-open":""}`,children:[Se&&Te?c.jsx("div",{className:"sidebar-backdrop",onClick:()=>{Ge(!1),dt.current?.focus()},"aria-hidden":"true"}):null,c.jsxs("aside",{id:"workbench-sidebar",ref:et,className:"rail",hidden:!Te,role:Se?"dialog":void 0,"aria-modal":Se&&Te?!0:void 0,"aria-label":"工作台导航",children:[c.jsxs("div",{className:"rail-head",children:[c.jsx("span",{className:"brand-mark",children:c.jsx(_t,{name:"brand"})}),c.jsx("strong",{children:"CodeShell"}),c.jsx("span",{className:"hub-badge",children:t.host==="desktop"?"Desktop":E?"Hub":"Web"}),c.jsx("button",{className:"icon-button sidebar-close","aria-label":"收起侧栏",onClick:()=>{Ge(!1),dt.current?.focus()},children:c.jsx(_t,{name:"sidebar"})})]}),c.jsx(Pf,{discover:t.workspaceApi,navigate:Q=>{const ve=()=>window.location.assign(Q);le||t.hasUnsent||t.uploadBusy?se(()=>ve):ve()}}),c.jsxs("nav",{className:"workbench-nav","aria-label":"主要功能",children:[i?c.jsxs("button",{className:"nav-button",title:l,onClick:()=>{le||t.hasUnsent||t.uploadBusy?se(()=>i):i()},children:[c.jsx(_t,{name:"folder"}),c.jsx("span",{children:"返回项目列表"})]}):null,c.jsxs("button",{className:"nav-button new-chat-button",onClick:ge,children:[c.jsx(_t,{name:"plus"}),c.jsx("span",{children:"新对话"})]}),c.jsxs("button",{className:`nav-button${N==="chat"?" active":""}`,onClick:()=>{tt(()=>{X("chat"),pt()})},"aria-current":N==="chat"?"page":void 0,children:[c.jsx(_t,{name:"chat"}),c.jsx("span",{children:"对话"})]}),E?c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:`nav-button${N==="history"?" active":""}`,onClick:()=>tt(()=>{X("history"),pt()}),"aria-current":N==="history"?"page":void 0,children:[c.jsx(_t,{name:"history"}),c.jsx("span",{children:"历史对话"})]}),c.jsxs("button",{className:`nav-button${N==="files"?" active":""}`,onClick:()=>zt(),"aria-current":N==="files"?"page":void 0,children:[c.jsx(_t,{name:"folder"}),c.jsx("span",{children:"文件"})]}),c.jsxs("button",{className:`nav-button${N==="settings"&&we==="skills"?" active":""}`,onClick:()=>Ve("skills"),"aria-current":N==="settings"&&we==="skills"?"page":void 0,children:[c.jsx(_t,{name:"skills"}),c.jsx("span",{children:"Skills"})]}),c.jsxs("button",{className:`nav-button${N==="panels"||N==="panel"?" active":""}`,onClick:()=>tt(()=>{X("panels"),pt()}),"aria-current":N==="panels"||N==="panel"?"page":void 0,children:[c.jsx(_t,{name:"panels"}),c.jsx("span",{children:"面板"})]}),c.jsxs("button",{className:`nav-button${N==="links"?" active":""}`,onClick:()=>tt(()=>{X("links"),pt()}),"aria-current":N==="links"?"page":void 0,children:[c.jsx(_t,{name:"links"}),c.jsx("span",{children:"Link"})]}),c.jsxs("button",{className:`nav-button${N==="settings"&&we!=="skills"?" active":""}`,onClick:()=>Ve("overview"),"aria-current":N==="settings"&&we!=="skills"?"page":void 0,children:[c.jsx(_t,{name:"settings"}),c.jsx("span",{children:"设置"})]})]}):null]}),c.jsx("div",{className:"rail-section-label",children:"工作区"}),E?c.jsxs("button",{className:"workspace-button",title:x??void 0,onClick:()=>zt(),children:[c.jsx(_t,{name:"folder"}),c.jsx("span",{children:l??k}),c.jsx(_t,{name:"chevron"})]}):c.jsxs("div",{className:"workspace-button",title:x??void 0,children:[c.jsx(_t,{name:"folder"}),c.jsx("span",{children:l??k})]}),c.jsxs("div",{className:"rail-section-label history-label",children:[c.jsx("span",{children:"最近对话"}),c.jsx("span",{children:o.length})]}),t.renderSidebar?.({guard:tt,conversation:M}),c.jsxs("ul",{className:"sessions","aria-label":"最近对话",children:[z.map(({sessionId:Q,draft:ve})=>c.jsx("li",{children:c.jsxs("button",{className:Q===f&&N==="chat"?"session active":"session",onClick:()=>{K(Q)},children:[c.jsx("span",{className:"session-title",children:ve.text.trim()||`附件:${ve.files[0]?.name??"新对话"}`}),c.jsx("span",{className:"session-meta",children:"草稿"})]})},`draft-${Q}`)),o.map(Q=>c.jsx("li",{children:c.jsxs("button",{className:Q.sessionId===f&&N==="chat"?"session active":"session",onClick:()=>{K(Q.sessionId)},"aria-current":Q.sessionId===f&&N==="chat"?"page":void 0,children:[c.jsx("span",{className:"session-title",children:Q.sessionId===f?Q.customTitle||u.title||Q.title||Rv(u,Q.sessionId):Q.title||Q.preview?.trim()||Q.sessionId.slice(0,8)}),c.jsxs("span",{className:"session-meta",children:[t.unreadSessionIds?.has(Q.sessionId)&&Q.sessionId!==f?c.jsxs("span",{className:"session-unread","aria-label":"有新消息",children:["●"," "]}):null,ae(Q.sessionId)?`${ae(Q.sessionId)} 项待审批`:Q.running?"进行中":QN(Q.status),t.showTurnCounts!==!1?c.jsxs("span",{children:[" · ",Q.turnCount," 轮"]}):null]})]})},Q.sessionId)),o.length===0&&z.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,lt]})]}),t.host==="hub"?c.jsxs("button",{className:"account-button",onClick:()=>{pt(),Z(!0)},children:[c.jsx("span",{className:"account-avatar",children:(q?.username||"C").slice(0,1).toUpperCase()}),c.jsxs("span",{className:"account-copy",children:[c.jsx("strong",{children:q?.username||"账号"}),c.jsx("span",{children:"设备与退出"})]}),c.jsx(_t,{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:Se&&Te?!0:void 0,children:[c.jsxs("header",{className:"workbench-topbar",children:[c.jsx("button",{ref:dt,className:"icon-button","aria-label":Te?"收起侧栏":"展开侧栏","aria-expanded":Te,"aria-controls":"workbench-sidebar",onClick:()=>Ge(Q=>!Q),children:c.jsx(_t,{name:"sidebar"})}),c.jsxs("div",{className:"topbar-context",children:[c.jsx("span",{className:"topbar-project","aria-label":"当前项目",title:l??k,children:l??k}),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,v?c.jsxs("div",{className:"banner form-error",role:"alert",children:[v,c.jsx("button",{className:"ghost","aria-label":"关闭错误提示",onClick:t.clearError,children:"×"})]}):null,Ke.length?c.jsxs("div",{className:"banner",children:["其他会话有待处理审批。",Ke.map(Q=>c.jsxs("button",{className:"ghost",onClick:()=>{K(Q.sessionId)},children:["打开 ",Q.sessionId.slice(0,8)]},Q.id))]}):null,a!=="open"?c.jsxs("div",{className:"banner",children:["连接",a==="connecting"?"中…":"已断开,重连中…"]}):null,N!=="chat"&&Le.length>0?c.jsxs("div",{className:"banner",children:["当前对话需要你的确认。",c.jsx("button",{className:"ghost",onClick:()=>tt(()=>X("chat")),children:"返回对话"})]}):null,c.jsxs("section",{className:`chat${bt?" chat-empty":""}`,hidden:N!=="chat","aria-label":"对话",children:[c.jsx("div",{className:"messages",ref:Ct,onScroll:Q=>{const ve=Q.currentTarget;qe.current=ve.scrollHeight-ve.scrollTop-ve.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(Q=>{switch(Q.kind){case"user":return c.jsxs("div",{className:"msg user",children:[Q.text,Q.attachments?.map((ve,ze)=>E&&ve.path?c.jsxs("button",{className:"attachment attachment-open",onClick:()=>zt(ve.path),children:["📎 ",ve.name]},ze):c.jsxs("span",{className:"attachment",children:["📎 ",ve.name]},ze))]},Q.id);case"assistant":return Q.done&&!Q.text&&!Q.reasoning?null:c.jsx("div",{className:"msg assistant",children:c.jsx(BN,{text:Q.text,reasoning:Q.reasoning,streaming:!Q.done,onOpenFile:E?yt:void 0})},Q.id);case"tool":return c.jsx("div",{className:`msg tool${Q.error?" tool-error":""}`,children:c.jsx(qN,{item:Q,running:L})},Q.id);case"subagent":return c.jsxs("div",{className:"msg info",children:["↳ ",Q.label," · ",IN(Q.status)]},Q.id);case"system_error":return c.jsx("div",{className:"msg error",children:Q.text},Q.id);default:return null}}),t.approvalContent,bt?c.jsxs("div",{className:"empty-chat",children:[c.jsx("span",{className:"welcome-mark",children:c.jsx(_t,{name:"brand"})}),c.jsx("h1",{children:"今天想完成什么?"}),c.jsx("p",{children:"从一个问题或想法开始,让 CodeShell 帮你一步步完成。"}),c.jsxs("span",{className:"welcome-workspace",children:[c.jsx(_t,{name:"folder"}),l??k]})]}):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||m&&t.host==="hub"?c.jsxs("div",{className:"attachments","aria-live":"polite",children:[h.map(Q=>c.jsxs("span",{className:"attachment",children:[c.jsx(_t,{name:"attachment"}),Q.name,c.jsx("button",{className:"ghost","aria-label":`移除 ${Q.name}`,onClick:()=>{t.removeFile(Q.id)},children:"×"})]},Q.id)),m&&t.host==="hub"?c.jsx("span",{children:"正在上传…"}):null]}):null,c.jsx("textarea",{ref:ht,"aria-label":"任务内容",value:p,disabled:t.readOnly,rows:2,placeholder:"描述你的任务,或提出一个问题…",onChange:Q=>{t.setDraft(Q.target.value)},onKeyDown:Q=>{Q.key==="Enter"&&!Q.shiftKey&&!Q.nativeEvent.isComposing&&(Q.preventDefault(),be())}}),c.jsxs("div",{className:"composer-toolbar",children:[E?c.jsxs(c.Fragment,{children:[c.jsx("input",{hidden:!0,multiple:!0,type:"file",accept:t.attachmentAccept,ref:ee,onChange:Q=>{const ve=Q.currentTarget;Promise.resolve(t.addFiles(ve.files)).finally(()=>{ve.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(_t,{name:"plus"})}),t.cameraAttachments?c.jsxs(c.Fragment,{children:[c.jsx("input",{hidden:!0,type:"file",accept:"image/*",capture:"environment",ref:W,onChange:Q=>{const ve=Q.currentTarget;Promise.resolve(t.addFiles(ve.files)).finally(()=>{ve.value=""})}}),c.jsx("button",{className:"icon-button attach-button","aria-label":"拍照",title:"拍照",disabled:t.uploadBusy||a!=="open"||t.readOnly,onClick:()=>W.current?.click(),children:c.jsx(_t,{name:"camera"})})]}):null,c.jsxs("button",{className:"model-button",title:"打开模型设置",onClick:()=>Ve("models"),children:[c.jsx("span",{children:mt?.model||"配置模型"}),c.jsx(_t,{name:"chevron"})]})]}):null,c.jsx("span",{className:"composer-run-status",role:"status",children:t.uncertain?"正在核对消息…":m?t.host==="desktop"?"正在发送…":"正在上传附件…":Le.length?"等待你的确认":L?"正在处理…":""}),L?c.jsx("button",{className:"stop composer-submit","aria-label":"停止",title:"停止",onClick:Ee,disabled:a!=="open",children:c.jsx(_t,{name:"stop"})}):c.jsx("button",{className:"send composer-submit","aria-label":"发送",title:"发送",onClick:be,disabled:a!=="open"||m||t.uncertain||t.readOnly||!p.trim()&&!h.length,children:c.jsx(_t,{name:"send"})})]})]}),c.jsxs("div",{className:"composer-caption",children:[c.jsxs("span",{children:["任务在",B,"工作区执行"]}),c.jsx("span",{children:"Enter 发送 · Shift + Enter 换行"})]})]})]}),N==="settings"&&E?c.jsx(W1,{host:t.host==="desktop"?"desktop":"hub",section:we,onSectionChange:Ve,onAuthLost:T,onConfigurationChange:()=>{$()},configurationVersion:D,onDirtyChange:me},`${t.workspaceKey}:settings`):null,N==="files"&&E?c.jsx(aS,{initialPath:j,openVersion:J,onAuthLost:T},`${t.workspaceKey}:files`):null,N==="history"&&E?c.jsx(sS,{onAuthLost:T,onOpen:Q=>{K(Q)},onChanged:()=>{V()},version:R,onDirtyChange:me},`${t.workspaceKey}:history`):null,N==="links"&&E?c.jsx(PS,{onAuthLost:T,onDirtyChange:me,hostLabel:B,configurationVersion:D},`${t.workspaceKey}:links`):null,N==="panels"&&E?c.jsx(JS,{onAuthLost:T,onDirtyChange:me,onChanged:()=>{$()},hostLabel:B,configurationVersion:D,onOpen:Q=>tt(()=>{ye({panel:Q,workspaceKey:t.workspaceKey}),X("panel"),pt()})},`${t.workspaceKey}:panels`):null,N==="panel"&&E&&pe?.workspaceKey===t.workspaceKey?c.jsx(ow,{panel:pe.panel,sessionId:f,busy:L||m||t.uncertain,onAuthLost:T,onDirtyChange:me,onClose:()=>tt(()=>X("panels")),onSubmitPrompt:async Q=>YN(t,{...Q,workspaceKey:pe.workspaceKey})},`${t.workspaceKey}:panel:${pe.panel.id}:${f}`):null]}),te?c.jsx(FN,{onStay:()=>se(null),onLeave:()=>{const Q=te;se(null),me(!1),Q()}}):null,H&&t.host==="hub"?c.jsx(x1,{session:q,onClose:()=>Z(!1),onAuthLost:T}):null]})}function FN({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 QN(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 _t({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 yi extends Error{constructor(i,l,a){super(i),this.kind=l,this.code=a,this.name="ProtocolRequestError"}kind;code}const $N=3e4,nb=800,XN=15e3;class KN{constructor(i){this.url=i}url;ws=null;nextId=1;pending=new Map;notificationHandlers=new Set;stateHandlers=new Set;reconnectDelay=nb;closedByUser=!1;reconnectTimer;authHandlers=new Set;connect(){this.ws||(clearTimeout(this.reconnectTimer),this.closedByUser=!1,this.openSocket())}openSocket(){if(this.closedByUser)return;this.reconnectTimer=void 0,this.emitState("connecting");const i=new WebSocket(this.url);this.ws=i,i.onopen=()=>{this.ws!==i||this.closedByUser||(this.reconnectDelay=nb,this.emitState("open"))},i.onmessage=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 yi(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 yi("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,XN))}},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 yi("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=$N){const o=this.ws;if(!o||o.readyState!==WebSocket.OPEN)return Promise.reject(new yi("not connected","not-sent"));const f=`web-${this.nextId++}`;return new Promise((u,p)=>{const h=a>0?setTimeout(()=>{this.pending.delete(f),p(new yi(`request timed out: ${i}`,"timeout"))},a):void 0;this.pending.set(f,{resolve:u,reject:p,timer:h});try{o.send(JSON.stringify({jsonrpc:"2.0",id:f,method:i,params:l}))}catch(m){clearTimeout(h),this.pending.delete(f),p(new yi(m instanceof Error?m.message:"send failed","not-sent"))}})}run(i){return this.request("agent/run",i,0)}listSessions(){return this.request("agent/query",{type:"sessions"})}sessionDetail(i,l=!1){return this.request("agent/query",{type:"session_detail",sessionId:i,...l?{outputRecovery:!0}:{}})}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 ZN(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}${St("/ws")}`}function PN(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 JN{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 WN({payload:t,onDecide:i,busy:l,connected:a}){const[o,f]=w.useState(""),u=t.request.toolName==="__ask_user__",{summary:p,risk:h}=xS(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:p}),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:m=>f(m.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 ib(){return wa()}const eA=()=>{},tA=async()=>{};function nA({session:t,hub:i=!1,onAuthLost:l=eA,onCheckAuth:a=tA}){const o=w.useRef(null),[f,u]=w.useState("connecting"),[p,h]=w.useState([]),m=w.useRef([]),[y,b]=w.useState(()=>HN(window.location.search)??ib()),[v,x]=w.useState(Zs()),[k,_]=w.useReducer(PN,{}),[D,R]=w.useState({}),[z,L]=w.useState(""),[G,ae]=w.useState([]),T=w.useRef(new JN),[V,$]=w.useState(0),[q,E]=w.useState(null),B=q===y,[H,Z]=w.useState(null),[ee,W]=w.useState(null),[N,X]=w.useState(""),[pe,ye]=w.useState(Date.now()),[j,O]=w.useState(0),[J,A]=w.useState(null),[le,me]=w.useState(0),te=w.useRef(0),se=w.useRef(y),we=w.useRef(null),F=w.useRef(null),Se=w.useRef(!1),Ne=w.useRef(new Map),Te=w.useRef(new Map),Ge=w.useRef(new Set),et=w.useRef(new Set),dt=w.useRef(new Set),Fe=w.useRef(!1),Ct=w.useRef(null),ht=w.useRef(null),qe=w.useCallback(ce=>{if($(Me=>Me+1),se.current!==ce)return;const ke=T.current.get(ce);L(ke.text),ae(ke.files)},[]);w.useEffect(()=>{const ce=new URL(window.location.href);ce.searchParams.set("session",y),window.history.replaceState(window.history.state,"",ce)},[y]);const pt=w.useCallback((ce,ke)=>{const Me=T.current.restore(ce.draft);qe(ce.draft.sessionId),se.current===ce.draft.sessionId&&(x(de=>({...de,run:"error",items:de.items.filter(U=>U.kind!=="user"||U.clientMessageId!==ce.clientMessageId)})),Me&&X(`${ke?`${ke} `:"消息未送达。"}内容和附件已恢复,可以重试。`))},[qe]),Ve=w.useCallback(ce=>{Fe.current&&(ce instanceof Xe&&ce.status===401?l():X(ce instanceof Error?ce.message:"操作失败,请重试。"))},[l]),tt=w.useCallback(async()=>{if(!i||!Fe.current)return;const ce=++te.current;try{const ke=await mb();Fe.current&&ce===te.current&&A(ke)}catch(ke){Fe.current&&ke instanceof Xe&&ke.status===401&&l()}},[i,l]),zt=w.useCallback(async()=>{const ce=o.current;if(ce)try{const ke=i?(await Tf()).sessions:(await ce.listSessions()).data;if(o.current===ce&&Fe.current){const Me=[...ke].sort((de,U)=>(U.lastActiveAt??U.startedAt)-(de.lastActiveAt??de.startedAt));m.current=Me,h(Me)}}catch(ke){Ve(ke)}},[Ve,i]),rt=w.useCallback(async()=>{const ce=o.current;if(ce)for(const[ke,Me]of Te.current)try{const de=await ce.sessionDetail(ke);if(!Fe.current||ce!==o.current||Te.current.get(ke)!==Me)continue;tb(de.data).chat.items.some(Ce=>Ce.kind==="user"&&Ce.clientMessageId===Me.clientMessageId)?Te.current.delete(ke):de.data.running||(Te.current.delete(ke),pt(Me))}catch(de){if(!Fe.current||ce!==o.current||Te.current.get(ke)!==Me)continue;de instanceof yi&&de.kind==="response"&&de.code===-32001&&de.message===`Session not found: ${ke}`&&(Te.current.delete(ke),pt(Me))}},[pt]),yt=w.useCallback(async ce=>{const ke=o.current;if(!ke)return;const Me={sessionId:ce,events:[],bytes:0};ht.current=Me;try{const de=await ke.sessionDetail(ce,!0);if(!Fe.current||ht.current!==Me||se.current!==ce)return;let U=Me.running??de.data.running;U?et.current.add(ce):U===!1&&et.current.delete(ce);const je=tb(de.data,Me.events);let Ce=je.chat,st=!1,ut=!1;try{const Ut=await VN(de.data,async Et=>(await ke.outputJournal(ce,Et)).data,Me.events,()=>Me.latestOutputCursor);Ut?(Ce=Ut.chat,F.current=Ut.outputCursor,st=!0):F.current=null}catch(Ut){F.current=null,ut=!(!de.data.outputJournal&&Ut instanceof yi&&Ut.kind==="response"&&Ut.code===-32602&&Ut.message==="Unknown query type: output_journal")}if(!Fe.current||ht.current!==Me||se.current!==ce)return;U=Me.running??de.data.running,Se.current=ut,ut||(we.current=je.cursor??null),W(ut?"部分运行记录无法验证,已保留当前可见内容。请修复会话记录后重试。":!st&&(je.truncated||Me.overflow)?"这次运行的实时记录较长,已恢复已保存的内容;结束后重新打开可查看完整记录。":null),U||Ge.current.has(ce)?Ce.run="running":U===!1&&(Ce.run==="running"||Ce.run==="waiting")&&(Ce.run="idle"),x(Ut=>ut?Ut:Ce)}catch(de){se.current===ce&&Ve(de)}finally{ht.current===Me&&(ht.current=null)}},[Ve]);w.useEffect(()=>{Fe.current=!0;const ce=new KN(ZN());o.current=ce;const ke=ce.onAuthLost(l),Me=ce.onStateChange(U=>{u(U),U==="open"?(Z(null),X(""),zt().then(()=>{const je=se.current;Fe.current&&o.current===ce&&(m.current.some(Ce=>Ce.sessionId===je)||et.current.has(je)||Ge.current.has(je)||Te.current.has(je))&&yt(je)}),tt(),rt()):U==="closed"&&(i&&a(),x(je=>({...je,run:"idle"})))}),de=ce.onNotification((U,je)=>{if(U==="serve/sessionsChanged"){zt(),O(Ce=>Ce+1);return}if(U==="agent/runAccepted"&&typeof je.sessionId=="string"){const Ce=Ne.current.get(je.sessionId);Ce&&(Ce.accepted=!0);return}if(U==="serve/configurationChanged"){tt(),me(Ce=>Ce+1);return}if(U==="agent/streamEvent"){const Ce=je,{sessionId:st,event:ut}=Ce,Ut=Ne.current.get(st);if(Ut&&["stream_request_start","text_delta","thinking_delta","tool_use_start"].includes(String(ut.type))&&(Ut.accepted=!0),st===se.current){if(ht.current?.sessionId===st){const Et=ht.current;typeof ut.outputCursor=="string"&&(Et.latestOutputCursor=ut.outputCursor);const Gn=new TextEncoder().encode(JSON.stringify(Ce)).length;for(Et.events.push(Ce),Et.bytes+=Gn;Et.events.length>2048||Et.bytes>8*1024*1024;){const Ht=Et.events.shift();Ht&&(Et.bytes-=new TextEncoder().encode(JSON.stringify(Ht)).length),Et.overflow=!0}}if(Se.current&&ut.type!=="session_title")return;if(typeof ut.outputCursor=="string"&&F.current){const Et=Rf(ut.outputCursor,F.current);if(Et===void 0){yt(st);return}if(Et<=0)return;F.current=ut.outputCursor}if(!zv(Ce,we.current))return;Ce.hubEpoch&&Ce.hubSequence!==void 0&&(we.current={epoch:Ce.hubEpoch,sequence:Ce.hubSequence}),x(Et=>hr(Et,ut))}ut.type==="stream_request_start"&&Z(null),ut.type==="turn_complete"&&zt();return}if(U==="serve/sessionStatus"){O(ut=>ut+1);const{sessionId:Ce,running:st}=je;if(typeof Ce!="string"||typeof st!="boolean")return;ht.current?.sessionId===Ce&&(ht.current.running=st),st?et.current.add(Ce):et.current.delete(Ce),!st&&Te.current.has(Ce)&&rt(),Ce===se.current&&x(ut=>st?{...ut,run:"running"}:ut.run==="running"||ut.run==="waiting"?{...ut,run:"idle"}:ut),zt();return}if(U==="agent/approvalRequest"||U==="agent/approvalResolved"||U==="serve/approvalSnapshot"||U==="serve/approvalLease"){_({method:U,params:je});return}if(U==="serve/workerExit"){et.current.clear();const Ce=je.clean;Z(Ce?"服务进程已退出,发送消息会自动重启":"服务进程异常退出,发送消息会自动重启"),x(st=>({...st,run:"idle"}))}});return ce.connect(),()=>{Fe.current=!1,Ct.current?.abort(),Me(),de(),ke(),ce.close(),o.current=null}},[zt,yt,tt,rt,l,a,i]);const M=Object.values(k).some(ce=>ce.lease?.holderId&&(ce.lease.expiresAt??0)>pe);w.useEffect(()=>{if(!M)return;ye(Date.now());const ce=setInterval(()=>ye(Date.now()),1e3);return()=>clearInterval(ce)},[M]);const K=async ce=>{se.current=ce,we.current=null,F.current=null,Se.current=!1,b(ce),qe(ce),x(Zs()),X(""),W(null),!(!p.some(ke=>ke.sessionId===ce)&&!et.current.has(ce)&&T.current.unsent().some(ke=>ke.sessionId===ce))&&await yt(ce)},ge=()=>{const ce=ib();se.current=ce,we.current=null,F.current=null,Se.current=!1,ht.current=null,b(ce),qe(ce),x(Zs()),X(""),W(null)},be=()=>{const ce=T.current.get(se.current),ke=ce.text.trim(),Me=o.current;if(!ke&&!ce.files.length||!Me||f!=="open"||B)return!1;const de=se.current;if(Ge.current.has(de)||et.current.has(de)||v.run==="running"||v.run==="waiting"||Object.values(k).some(Ce=>Ce.payload.sessionId===de)||Te.current.has(de))return!1;se.current=de,b(de),Ge.current.add(de);const U={clientMessageId:wa(),draft:T.current.take(de),accepted:!1};Ne.current.set(de,U);const je=U.draft.draft.files;return qe(de),X(""),x(Ce=>({...dS(Ce,ke,je.map(st=>({name:st.name,mime:st.mimeType,size:st.size})),U.clientMessageId),run:"running"})),Me.run({sessionId:de,task:ke,clientMessageId:U.clientMessageId,displayText:ke,...je.length?{uploadIds:je.map(Ce=>Ce.id)}:{}}).catch(Ce=>{Fe.current&&(Ve(Ce),Ce instanceof yi&&(Ce.kind==="transport"||Ce.kind==="timeout")?(Te.current.set(de,U),X("连接中断,重新连接后会核对这条消息是否已经送达。")):U.accepted||pt(U,Ce instanceof Error?Ce.message==="upload not found or expired"?"附件已失效,请移除后重新上传。":Ce.message:void 0),se.current===de&&x(st=>({...st,run:"error"})))}).finally(()=>{Ge.current.delete(de),Ne.current.get(de)===U&&Ne.current.delete(de),Fe.current&&se.current===de&&!et.current.has(de)&&x(Ce=>Ce.run==="running"?{...Ce,run:"idle"}:Ce)}),!0},Ee=(ce,ke,Me)=>{const de=o.current;!de||f!=="open"||dt.current.has(ce.requestId)||(dt.current.add(ce.requestId),R(U=>({...U,[ce.requestId]:!0})),X(""),de.approve({...ce,sessionId:ce.sessionId??se.current??""},ke,Me).then(()=>_({method:"agent/approvalResolved",params:{requestId:ce.requestId}})).catch(Ve).finally(()=>{dt.current.delete(ce.requestId),R(U=>{const je={...U};return delete je[ce.requestId],je})}))},Le=()=>{y&&o.current?.cancel(y).catch(Ve)},Ke=async ce=>{if(!ce?.length||Ct.current)return;const ke=new AbortController,Me=Js();Ct.current=ke,E(se.current),X("");const de=se.current;try{for(const U of Array.from(ce)){if(!Fe.current||ke.signal.aborted)break;const je=await J0(U,{signal:ke.signal,scope:Me});Fe.current&&!ke.signal.aborted&&(T.current.addFile(de,je),qe(de))}}catch(U){Ve(U)}finally{Ct.current===ke&&(Ct.current=null),Fe.current&&E(null)}},bt=Object.values(k).filter(ce=>!ce.payload.sessionId||ce.payload.sessionId===y),mt=ce=>Object.values(k).filter(ke=>ke.payload.sessionId===ce).length,lt=v.run==="running"||v.run==="waiting"||bt.length>0,Ze=w.useMemo(()=>T.current.unsent().filter(ce=>!p.some(ke=>ke.sessionId===ce.sessionId)),[V,p]),Q=J?.workspace.path??p.find(ce=>ce.sessionId===y)?.cwd??p[0]?.cwd??null,ve=Q?.split(/[\\/]/).filter(Boolean).pop()??"服务端工作区",ze=v.items.length===0&&bt.length===0,De=p.find(ce=>ce.sessionId===y),$e=ze?"新对话":De?.customTitle||v.title||De?.title||De?.preview?.trim()||Rv(v,y??"新对话");return{host:i?"hub":"legacy",workspaceApi:i,connection:f,session:t,activeId:y,chat:v,sessions:p,workspaceCwd:Q,workspaceName:ve,title:$e,workspaceKey:Q??"hub",configuration:J,configurationVersion:le,sessionsVersion:j,draft:z,files:G,uploading:B,uploadBusy:q!==null,hasUnsent:T.current.unsent().length>0,localDrafts:Ze,uncertain:Te.current.has(y),running:lt,approvals:Object.values(k).map(ce=>({id:ce.payload.requestId,sessionId:ce.payload.sessionId})),approvalCount:mt,approvalContent:bt.map(ce=>c.jsx(WN,{payload:ce.payload,onDecide:Ee,busy:!!D[ce.payload.requestId]||!!(ce.lease?.holderId&&(ce.lease.expiresAt??0)>pe),connected:f==="open"},ce.payload.requestId)),workerNote:H,replayNote:ee,error:N,clearError:()=>X(""),setDraft:ce=>{T.current.setText(se.current,ce),qe(se.current)},removeFile:ce=>{T.current.removeFile(se.current,ce),qe(se.current)},selectSession:K,newSession:ge,send:be,stop:Le,addFiles:Ke,refreshSessions:zt,refreshConfiguration:tt,onAuthLost:l}}function rb({onBackToProjects:t,projectName:i,...l}){return c.jsx(GN,{controller:nA(l),onBackToProjects:t,projectName:i})}function Dv(t){if(!t||typeof t!="object")return!1;const i=t;return ya(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 iA(t){const i=t;if(!i||i.runtime!=="docker"||typeof i.available!="boolean"||!Array.isArray(i.projects)||!i.projects.every(Dv)||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 lb(){return new URL(window.location.href).searchParams.get("project")}function ha(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 rA={stopped:"已停止",starting:"正在启动",running:"运行中",stopping:"正在停止",error:"启动失败"};function lA({children:t,onAuthLost:i}){const[l,a]=w.useState(null),[o,f]=w.useState(!1),[u,p]=w.useState(null),[h,m]=w.useState(""),[y,b]=w.useState(!0),[v,x]=w.useState(null),[k,_]=w.useState(""),[D,R]=w.useState(null),z=w.useRef(null),L=w.useRef(lb()),G=w.useRef(u),ae=w.useRef(l),T=w.useRef(0),V=w.useRef(0),$=w.useRef(null),q=w.useRef(i),E=w.useRef(!1);q.current=i,G.current=u,ae.current=l;const B=w.useCallback(N=>{if(N.status!=="running")return;const X=lb()===N.id;qs(),Us(N.id),ha(N.id,X),L.current=null,G.current=N,p(N),m("")},[]),H=w.useCallback(()=>{L.current=null,G.current=null,p(null),Us(null),qs(),ha(null)},[]),Z=w.useCallback(async N=>{if(E.current)return;const X=++V.current,pe=T.current;try{const ye=iA(await Ue("/api/v1/projects",{signal:N}));if(N?.aborted||X!==V.current||pe!==T.current)return;a(ye),ae.current=ye,b(!1),m("");const j=G.current;if(j){const J=ye.projects.find(A=>A.id===j.id);(!J||J.status!=="running"||J.generation!==j.generation)&&(H(),m("项目运行状态已经变化,请重新打开项目。未发送的内容不会带入其他项目。"));return}if(!L.current)return;const O=ye.projects.find(J=>J.id===L.current);O?O.status==="running"&&ye.available&&B(O):(L.current=null,ha(null),m("链接中的项目不存在或当前账号无权访问,请选择一个项目。"))}catch(ye){if(N?.aborted||X!==V.current||pe!==T.current)return;b(!1),ye instanceof Xe&&ye.status===404&&!ae.current?(Us(null),qs(),E.current=!0,f(!0)):ye instanceof Xe&&ye.status===401?q.current():m(ye instanceof Error?ye.message:"无法读取项目,请重试。")}},[H,B]);w.useEffect(()=>{T.current++;const N=new AbortController;Z(N.signal);const X=()=>{Z(N.signal)},pe=()=>{document.visibilityState==="visible"&&X()};return window.addEventListener("focus",X),document.addEventListener("visibilitychange",pe),()=>{T.current++,N.abort(),$.current?.abort(),window.removeEventListener("focus",X),document.removeEventListener("visibilitychange",pe),Us(null),qs()}},[Z]);const ee=l?.projects.some(N=>N.status==="starting"||N.status==="stopping");w.useEffect(()=>{if(o||!l)return;const N=new AbortController,X=setInterval(()=>{Z(N.signal)},ee?2e3:1e4);return()=>{clearInterval(X),N.abort()}},[o,!!l,ee,Z]),w.useEffect(()=>{if(!D)return;const N=document.activeElement,X=z.current;return X?.showModal?.(),()=>{X?.close?.(),N?.focus()}},[D]);const W=async(N,X)=>{if($.current||N==="create"&&!k.trim())return;const pe=new AbortController;$.current=pe,x(X?.id??"create"),m(""),V.current++;try{const ye=await Ue(N==="create"?"/api/v1/projects":`/api/v1/projects/${X.id}/${N}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N==="create"?{name:k.trim()}:{}),signal:pe.signal});if(pe.signal.aborted)return;if(!Dv(ye.project)||X&&X.id!==ye.project.id)throw new Error("服务端返回了无效的项目状态,请刷新列表。");const j=ye.project;a(O=>O&&{...O,projects:O.projects.some(J=>J.id===j.id)?O.projects.map(J=>J.id===j.id?j:J):[...O.projects,j]}),N==="create"&&_(""),N==="start"&&(L.current=j.id,ha(j.id),j.status==="running"&&B(j)),N==="stop"&&(L.current===j.id&&(L.current=null,ha(null)),R(null)),await Z(pe.signal)}catch(ye){if(pe.signal.aborted)return;ye instanceof Xe&&ye.status===401?q.current():m(ye instanceof Error?ye.message:"项目操作失败,请重试。")}finally{$.current===pe&&($.current=null),pe.signal.aborted||x(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,H)]},`${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(Pf,{}),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:()=>{Z()},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:N=>{N.preventDefault(),W("create")},children:[c.jsxs("label",{children:["新项目名称",c.jsx("input",{value:k,maxLength:80,required:!0,placeholder:"例如:个人网站",onChange:N=>_(N.target.value)})]}),c.jsx("button",{className:"library-button primary",disabled:!!v||!k.trim(),type:"submit",children:v==="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(N=>c.jsxs("article",{className:"project-card",children:[c.jsxs("div",{className:"project-card-heading",children:[c.jsx("h2",{children:N.name}),c.jsx("span",{className:`project-status ${N.status}`,children:rA[N.status]})]}),c.jsxs("p",{className:"project-date",children:["创建于 ",new Date(N.createdAt).toLocaleDateString()]}),N.error?c.jsx("p",{className:"form-error",role:"alert",children:N.error}):null,c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button primary",disabled:!!v||!l.available||N.status==="starting"||N.status==="stopping",onClick:()=>N.status==="running"?B(N):void W("start",N),children:v===N.id||N.status==="starting"||N.status==="stopping"?"正在处理…":N.status==="running"?"打开项目":"启动并打开"}),N.status==="running"?c.jsx("button",{className:"library-button",disabled:!!v,onClick:()=>R(N),children:"停止项目"}):null]})]},N.id))]})]}):null,D?c.jsxs("dialog",{className:"project-stop-confirm",ref:z,role:"alertdialog","aria-modal":"true","aria-labelledby":"project-stop-title",onCancel:N=>{N.preventDefault(),v||R(null)},children:[c.jsxs("h2",{id:"project-stop-title",children:["停止 ",D.name,"?"]}),c.jsx("p",{children:"正在运行的任务和面板进程会中断。项目文件和配置保留,可稍后重新启动。"}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button primary",disabled:!!v,onClick:()=>R(null),children:"继续运行"}),c.jsx("button",{className:"library-button",disabled:!!v,onClick:()=>{W("stop",D)},children:"确认停止"})]})]}):null]})}function aA({setupToken:t}){const[i,l]=w.useState("checking"),[a,o]=w.useState(),[f,u]=w.useState(""),[p,h]=w.useState(""),[m,y]=w.useState(""),[b,v]=w.useState(t),[x,k]=w.useState(""),[_,D]=w.useState(!1),R=w.useRef(!1),z=w.useRef(0),L=w.useRef(i);L.current=i;const G=w.useCallback($=>{R.current&&(o($?.session),l($===null?"legacy":$.initialized?$.authenticated?"authenticated":"login":"setup"),k(""),$?.initialized&&v(""))},[]),ae=w.useCallback(async()=>{const $=++z.current;try{const q=await Z0();$===z.current&&G(q)}catch(q){if(!R.current||$!==z.current||L.current==="authenticated"||L.current==="legacy")return;l("error"),k(q instanceof Error?q.message:"无法连接服务端")}},[G]);w.useEffect(()=>{R.current=!0,ae();const $=()=>{ae()},q=()=>{document.visibilityState==="visible"&&ae()};return window.addEventListener("focus",$),document.addEventListener("visibilitychange",q),()=>{R.current=!1,window.removeEventListener("focus",$),document.removeEventListener("visibilitychange",q)}},[ae]);const T=w.useCallback(()=>{z.current++,o(void 0),l("login"),h(""),k("登录已过期或此设备已被撤销,请重新登录。")},[]),V=async $=>{if($.preventDefault(),!_){z.current++,D(!0),k("");try{const q=await ub(`/api/v1/auth/${i==="setup"?"setup":"login"}`,{username:f.trim(),password:p,deviceName:m.trim()||void 0,...i==="setup"?{token:b.trim()}:{}});if(!q.authenticated)throw new Error("登录失败,请重试。");z.current++,h(""),v(""),G({initialized:!0,authenticated:!0,session:q.session})}catch(q){k(q instanceof Error?q.message:"登录失败,请重试。"),q instanceof Xe&&q.status===409&&ae()}finally{D(!1)}}};return i==="authenticated"?c.jsx(lA,{onAuthLost:T,children:($,q)=>c.jsx(rb,{session:a,hub:!0,onAuthLost:T,onCheckAuth:ae,projectName:$?.name,onBackToProjects:q})}):i==="legacy"?c.jsx(rb,{session:a,hub:!1,onAuthLost:T,onCheckAuth:ae}):c.jsx("main",{className:"auth-page",children:c.jsxs("section",{className:"auth-card",children:[c.jsx(Pf,{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:x}),c.jsx("button",{className:"send",onClick:()=>{ae()},children:"重试连接"})]}):null,i==="setup"||i==="login"?c.jsxs("form",{onSubmit:$=>{V($)},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:$=>v($.target.value)})]}):null,c.jsxs("label",{children:["用户名",c.jsx("input",{autoComplete:"username",required:!0,maxLength:64,value:f,onChange:$=>u($.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:p,onChange:$=>h($.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:m,onChange:$=>y($.target.value)})]}),x?c.jsx("p",{className:"form-error",role:"alert",children:x}):null,c.jsx("button",{className:"send",type:"submit",disabled:_,children:_?"正在连接…":i==="setup"?"创建并进入":"登录"})]}):null]})})}function sA(t="/"){"serviceWorker"in navigator&&window.isSecureContext&&navigator.serviceWorker.register(`${t}sw.js`).catch(()=>{})}const ab=u1(),oA=P0(window.location,window.history);g1.createRoot(document.getElementById("root")).render(c.jsx(w.StrictMode,{children:ab?c.jsx(c1,{callback:ab}):c.jsx(aA,{setupToken:oA})}));sA("/");