larness 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/server/drizzle/0001_auth.sql +109 -109
- package/apps/server/drizzle/0002_projects.sql +12 -12
- package/apps/server/drizzle/0003_workspace.sql +80 -80
- package/apps/server/drizzle/0004_models.sql +30 -30
- package/apps/server/drizzle/0005_resources.sql +54 -54
- package/apps/server/drizzle/0006_commands.sql +23 -23
- package/apps/server/drizzle/0007_terminals.sql +41 -41
- package/apps/server/drizzle/0008_resource_actions.sql +23 -23
- package/apps/server/drizzle/0010_services.sql +31 -31
- package/apps/web/dist/assets/{FileEditor-EgU1WoyG.js → FileEditor-CxzD-z_w.js} +1 -1
- package/apps/web/dist/assets/{FileViewer-CK3jt-Kt.js → FileViewer-4LwgwN4s.js} +1 -1
- package/apps/web/dist/assets/{cssMode-C8rMoO9f.js → cssMode-BfW9rKao.js} +1 -1
- package/apps/web/dist/assets/{editor.api-oDs5eZGS.js → editor.api-D0PbFQmb.js} +1 -1
- package/apps/web/dist/assets/{freemarker2-Bpg8JM09.js → freemarker2-CUmmnP_9.js} +1 -1
- package/apps/web/dist/assets/{handlebars-17J16rlT.js → handlebars-CV0ntFU6.js} +1 -1
- package/apps/web/dist/assets/{html-DJQFF1_1.js → html-lbv15ZCZ.js} +1 -1
- package/apps/web/dist/assets/{htmlMode-H8gHwZ6x.js → htmlMode-2S1Ml4u-.js} +1 -1
- package/apps/web/dist/assets/{index-BTVfvWIs.js → index-Bu4wSG15.js} +2 -2
- package/apps/web/dist/assets/{javascript-CjeM-nVA.js → javascript-s1wW-h_2.js} +1 -1
- package/apps/web/dist/assets/{jsonMode-C6seMV0X.js → jsonMode-Di8Ytqtu.js} +1 -1
- package/apps/web/dist/assets/{liquid-B33LyktO.js → liquid-CR28rx5y.js} +1 -1
- package/apps/web/dist/assets/{lspLanguageFeatures-H7IuoVNs.js → lspLanguageFeatures-uPJRSuKu.js} +1 -1
- package/apps/web/dist/assets/{main-CQzbYrTZ.js → main-KzEpvsAJ.js} +5 -5
- package/apps/web/dist/assets/main-ptChOROf.css +1 -0
- package/apps/web/dist/assets/{mdx-CcNcLUd8.js → mdx-B_RQg_ko.js} +1 -1
- package/apps/web/dist/assets/{monaco-xD43LINc.js → monaco-BHRE2AKp.js} +3 -3
- package/apps/web/dist/assets/{python-BfhjzxvI.js → python-DxrD-zEd.js} +1 -1
- package/apps/web/dist/assets/{razor-COinq8YD.js → razor-BGSx-heg.js} +1 -1
- package/apps/web/dist/assets/{tsMode-CXpnR4mr.js → tsMode-CkPGnA4g.js} +1 -1
- package/apps/web/dist/assets/{typescript-DAgfuTsy.js → typescript-oJa8RtP0.js} +1 -1
- package/apps/web/dist/assets/{workers-DI76FldO.js → workers-BmwP04Ml.js} +1 -1
- package/apps/web/dist/assets/{xml-CSNVYs0K.js → xml-NoacuPD-.js} +1 -1
- package/apps/web/dist/assets/{yaml-Bzp-4SkQ.js → yaml-PU4CKcMI.js} +1 -1
- package/apps/web/dist/favicon.svg +4 -4
- package/apps/web/dist/index.html +1 -1
- package/package.json +9 -1
- package/apps/web/dist/assets/main-gq3n_vn8.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileViewer-
|
|
2
|
-
import{t as e}from"./index-BTVfvWIs.js";var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),c=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},u=(e,r,i)=>(i=e==null?{}:t(a(e)),l(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)),d=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ee(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ee(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),ee(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=ee(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=ee(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ee(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function te(e,t,n){if(e==null)return e;var r=[],i=0;return ee(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function P(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var F=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function ne(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,F)}catch(e){F(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function I(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else ne(I.bind(null,e))}var re={map:te,forEach:function(e,t,n){te(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return te(e,function(){t++}),t},toArray:function(e){return te(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=re,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=I,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:P}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=ne,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),f=s(((e,t)=>{t.exports=d()})),p=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),m=s(((e,t)=>{t.exports=p()})),h=u(f(),1),g=m(),_=`larness.theme`,v=(0,h.createContext)(null);function y(e,t){return e===`system`?t?`dark`:`light`:e}function b(){try{let e=localStorage.getItem(_);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`light`}function x({children:e}){let[t,n]=(0,h.useState)(b),[r,i]=(0,h.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches);(0,h.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`);i(e.matches);let t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let a=y(t,r);(0,h.useEffect)(()=>{document.documentElement.dataset.theme=a,document.documentElement.style.colorScheme=a;try{localStorage.setItem(_,t)}catch{}},[a,t]);let o=(0,h.useCallback)(e=>n(e),[]),s=(0,h.useMemo)(()=>({theme:t,resolved:a,setTheme:o}),[t,a,o]);return(0,g.jsx)(v.Provider,{value:s,children:e})}function S(){let e=(0,h.useContext)(v);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function C(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=C(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function w(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=C(e))&&(r&&(r+=` `),r+=t);return r}var T=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},E=(e,t)=>({classGroupId:e,validator:t}),D=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),O=`-`,k=[],A=`arbitrary..`,j=e=>{let t=ee(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return N(e);let n=e.split(O);return M(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?T(i,t):t:i||k}return n[e]||k}}},M=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=M(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(O):e.slice(t).join(O),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},N=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?A+r:void 0})(),ee=e=>{let{theme:t,classGroups:n}=e;return te(n,t)},te=(e,t)=>{let n=D();for(let r in e){let i=e[r];P(i,n,r,t)}return n},P=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];F(i,t,n,r)}},F=(e,t,n,r)=>{typeof e==`string`?ne(e,t,n):typeof e==`function`?I(e,t,n,r):re(e,t,n,r)},ne=(e,t,n)=>{let r=e===``?t:ie(t,e);r.classGroupId=n},I=(e,t,n,r)=>{ae(e)?P(e(r),t,n,r):(t.validators===null&&(t.validators=[]),t.validators.push(E(n,e)))},re=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];P(o,ie(t,a),n,r)}},ie=(e,t)=>{let n=e,r=t.split(O),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=D(),n.nextPart.set(t,i)),n=i}return n},ae=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,oe=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},se=`!`,ce=`:`,le=[],ue=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),de=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===ce){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(se)?(c=s.slice(0,-1),l=!0):s.startsWith(se)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return ue(t,l,c,u)};if(t){let e=t+ce,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):ue(le,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},L=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},fe=e=>({cache:oe(e.cacheSize),parseClassName:de(e),sortModifiers:L(e),postfixLookupClassGroupIds:pe(e),...j(e)}),pe=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},me=/\s+/,he=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(me),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h||(g=r(p),!g)){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+se:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},ge=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=_e(n))&&(i&&(i+=` `),i+=r);return i},_e=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=_e(e[r]))&&(n&&(n+=` `),n+=t);return n},ve=(e,...t)=>{let n,r,i,a,o=o=>(n=fe(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=he(e,n);return i(e,a),a};return a=o,(...e)=>a(ge(...e))},ye=[],be=e=>{let t=t=>t[e]||ye;return t.isThemeGetter=!0,t.themeKey=e,t},xe=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Se=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ce=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,we=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Te=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ee=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,De=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Oe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ke=e=>Ce.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),je=e=>!!e&&Number.isInteger(Number(e)),Me=e=>e.endsWith(`%`)&&Ae(e.slice(0,-1)),Ne=e=>we.test(e),Pe=()=>!0,Fe=e=>Te.test(e)&&!Ee.test(e),Ie=()=>!1,Le=e=>De.test(e),Re=e=>Oe.test(e),ze=e=>!R(e)&&!z(e),Be=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),Ve=e=>nt(e,ot,Ie),R=e=>xe.test(e),He=e=>nt(e,st,Fe),Ue=e=>nt(e,ct,Ae),We=e=>nt(e,ut,Pe),Ge=e=>nt(e,lt,Ie),Ke=e=>nt(e,it,Ie),qe=e=>nt(e,at,Re),Je=e=>nt(e,dt,Le),z=e=>Se.test(e),Ye=e=>rt(e,st),Xe=e=>rt(e,lt),Ze=e=>rt(e,it),Qe=e=>rt(e,ot),$e=e=>rt(e,at),et=e=>rt(e,dt,!0),tt=e=>rt(e,ut,!0),nt=(e,t,n)=>{let r=xe.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},rt=(e,t,n=!1)=>{let r=Se.exec(e);return r?r[1]?t(r[1]):n:!1},it=e=>e===`position`||e===`percentage`,at=e=>e===`image`||e===`url`,ot=e=>e===`length`||e===`size`||e===`bg-size`,st=e=>e===`length`,ct=e=>e===`number`,lt=e=>e===`family-name`,ut=e=>e===`number`||e===`weight`,dt=e=>e===`shadow`,ft=ve(()=>{let e=be(`color`),t=be(`font`),n=be(`text`),r=be(`font-weight`),i=be(`tracking`),a=be(`leading`),o=be(`breakpoint`),s=be(`container`),c=be(`spacing`),l=be(`radius`),u=be(`shadow`),d=be(`inset-shadow`),f=be(`text-shadow`),p=be(`drop-shadow`),m=be(`blur`),h=be(`perspective`),g=be(`aspect`),_=be(`ease`),v=be(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),z,R],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[z,R,c],T=()=>[ke,`full`,`auto`,...w()],E=()=>[je,`none`,`subgrid`,z,R],D=()=>[`auto`,{span:[`full`,je,z,R]},je,z,R],O=()=>[je,`auto`,z,R],k=()=>[`auto`,`min`,`max`,`fr`,z,R],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[ke,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ee=()=>[s,ke,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],te=()=>[ke,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,z,R],F=()=>[...b(),Ze,Ke,{position:[z,R]}],ne=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],I=()=>[`auto`,`cover`,`contain`,Qe,Ve,{size:[z,R]}],re=()=>[Me,Ye,He],ie=()=>[``,`none`,`full`,l,z,R],ae=()=>[``,Ae,Ye,He],oe=()=>[`solid`,`dashed`,`dotted`,`double`],se=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ce=()=>[Ae,Me,Ze,Ke],le=()=>[``,`none`,m,z,R],ue=()=>[`none`,Ae,z,R],de=()=>[`none`,Ae,z,R],L=()=>[Ae,z,R],fe=()=>[ke,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Ne],breakpoint:[Ne],color:[Pe],container:[Ne],"drop-shadow":[Ne],ease:[`in`,`out`,`in-out`],font:[ze],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Ne],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Ne],shadow:[Ne],spacing:[`px`,Ae],text:[Ne],"text-shadow":[Ne],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,ke,R,z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,z,R]}],"container-named":[Be],columns:[{columns:[Ae,`auto`,R,z,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[je,`auto`,z,R]}],basis:[{basis:[ke,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Ae,ke,`auto`,`initial`,`none`,R]}],grow:[{grow:[``,Ae,z,R]}],shrink:[{shrink:[``,Ae,z,R]}],order:[{order:[je,`first`,`last`,`none`,z,R]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...ee()]}],"min-inline-size":[{"min-inline":[`auto`,...ee()]}],"max-inline-size":[{"max-inline":[`none`,...ee()]}],"block-size":[{block:[`auto`,...te()]}],"min-block-size":[{"min-block":[`auto`,...te()]}],"max-block-size":[{"max-block":[`none`,...te()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...N()]}],"font-size":[{text:[`base`,n,Ye,He]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,tt,We]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,Me,R]}],"font-family":[{font:[Xe,Ge,t]}],"font-features":[{"font-features":[R]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,z,R]}],"line-clamp":[{"line-clamp":[Ae,`none`,z,Ue]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,z,R]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,z,R]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...oe(),`wavy`]}],"text-decoration-thickness":[{decoration:[Ae,`from-font`,`auto`,z,He]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[Ae,`auto`,z,R]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[je,z,R]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,z,R]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,z,R]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:I()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},je,z,R],radial:[``,z,R],conic:[``,je,z,R]},$e,qe]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:ie()}],"rounded-s":[{"rounded-s":ie()}],"rounded-e":[{"rounded-e":ie()}],"rounded-t":[{"rounded-t":ie()}],"rounded-r":[{"rounded-r":ie()}],"rounded-b":[{"rounded-b":ie()}],"rounded-l":[{"rounded-l":ie()}],"rounded-ss":[{"rounded-ss":ie()}],"rounded-se":[{"rounded-se":ie()}],"rounded-ee":[{"rounded-ee":ie()}],"rounded-es":[{"rounded-es":ie()}],"rounded-tl":[{"rounded-tl":ie()}],"rounded-tr":[{"rounded-tr":ie()}],"rounded-br":[{"rounded-br":ie()}],"rounded-bl":[{"rounded-bl":ie()}],"border-w":[{border:ae()}],"border-w-x":[{"border-x":ae()}],"border-w-y":[{"border-y":ae()}],"border-w-s":[{"border-s":ae()}],"border-w-e":[{"border-e":ae()}],"border-w-bs":[{"border-bs":ae()}],"border-w-be":[{"border-be":ae()}],"border-w-t":[{"border-t":ae()}],"border-w-r":[{"border-r":ae()}],"border-w-b":[{"border-b":ae()}],"border-w-l":[{"border-l":ae()}],"divide-x":[{"divide-x":ae()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":ae()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...oe(),`hidden`,`none`]}],"divide-style":[{divide:[...oe(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-bs":[{"border-bs":P()}],"border-color-be":[{"border-be":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...oe(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Ae,z,R]}],"outline-w":[{outline:[``,Ae,Ye,He]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`inner`,`none`,u,et,Je]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,et,Je]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:ae()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[Ae,He]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":ae()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,et,Je]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[Ae,z,R]}],"mix-blend":[{"mix-blend":[...se(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":se()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[z,R]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,z,R]}],filter:[{filter:[``,`none`,z,R]}],blur:[{blur:le()}],brightness:[{brightness:[Ae,z,R]}],contrast:[{contrast:[Ae,z,R]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,et,Je]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,Ae,z,R]}],"hue-rotate":[{"hue-rotate":[Ae,z,R]}],invert:[{invert:[``,Ae,z,R]}],saturate:[{saturate:[Ae,z,R]}],sepia:[{sepia:[``,Ae,z,R]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,z,R]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,z,R]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,z,R]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Ae,z,R]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,z,R]}],"backdrop-invert":[{"backdrop-invert":[``,Ae,z,R]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,z,R]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,z,R]}],"backdrop-sepia":[{"backdrop-sepia":[``,Ae,z,R]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,z,R]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Ae,`initial`,z,R]}],ease:[{ease:[`linear`,`initial`,_,z,R]}],delay:[{delay:[Ae,z,R]}],animate:[{animate:[`none`,v,z,R]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,z,R]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ue()}],"rotate-x":[{"rotate-x":ue()}],"rotate-y":[{"rotate-y":ue()}],"rotate-z":[{"rotate-z":ue()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":[`scale-3d`],skew:[{skew:L()}],"skew-x":[{"skew-x":L()}],"skew-y":[{"skew-y":L()}],transform:[{transform:[z,R,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:fe()}],"translate-x":[{"translate-x":fe()}],"translate-y":[{"translate-y":fe()}],"translate-z":[{"translate-z":fe()}],"translate-none":[`translate-none`],zoom:[{zoom:[je,z,R]}],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,z,R]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":P()}],"scrollbar-track-color":[{"scrollbar-track":P()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,z,R]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[Ae,Ye,He,Ue]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function B(...e){return ft(w(e))}var pt={primary:`bg-accent text-white shadow-[0_1px_2px_rgba(0,0,0,.12)] hover:brightness-110 active:brightness-95`,secondary:`border border-line bg-surface text-ink shadow-[0_1px_1px_rgba(0,0,0,.03)] hover:bg-surface-2`,ghost:`text-ink-2 hover:bg-black/[.045] hover:text-ink dark:hover:bg-white/[.06]`,soft:`bg-accent-soft text-accent hover:bg-accent/20`,danger:`bg-danger text-white shadow-[0_1px_2px_rgba(0,0,0,.12)] hover:brightness-110 active:brightness-95`},mt={sm:`h-7 gap-1.5 rounded-lg px-2.5 text-[12px]`,md:`h-8 gap-2 rounded-[9px] px-3 text-[12.5px]`};function V({variant:e=`secondary`,size:t=`md`,leading:n,className:r,children:i,type:a=`button`,...o}){return(0,g.jsxs)(`button`,{type:a,className:B(`inline-flex select-none items-center justify-center whitespace-nowrap font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 focus-visible:ring-offset-1 focus-visible:ring-offset-canvas`,`disabled:pointer-events-none disabled:opacity-45`,pt[e],mt[t],r),...o,children:[n,i]})}var ht=Object.defineProperty,gt=(e,t)=>ht(e,`name`,{value:t,configurable:!0}),_t=!!(typeof window<`u`&&window.document&&window.document.createElement);function vt(e,t,{checkForDefaultPrevented:n=!0}={}){return gt(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}gt(vt,`composeEventHandlers`);function yt(e){if(!_t)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}gt(yt,`getOwnerWindow`);function bt(e){if(!_t)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}gt(bt,`getOwnerDocument`);function xt(e,t=!1){let{activeElement:n}=bt(e);if(!n?.nodeName)return null;if(St(n)&&n.contentDocument)return xt(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=bt(n).getElementById(e);if(t)return t}}return n}gt(xt,`getActiveElement`);function St(e){return e.tagName===`IFRAME`}gt(St,`isFrame`);var Ct=Object.defineProperty,wt=(e,t)=>Ct(e,`name`,{value:t,configurable:!0});function Tt(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}wt(Tt,`setRef`);function Et(...e){return t=>{let n=!1,r=e.map(e=>{let r=Tt(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Tt(e[t],null)}}}}wt(Et,`composeRefs`);function Dt(...e){return h.useCallback(Et(...e),e)}wt(Dt,`useComposedRefs`);var Ot=Object.defineProperty,kt=(e,t)=>Ot(e,`name`,{value:t,configurable:!0});function At(e,t){let n=h.createContext(t);n.displayName=e+`Context`;let r=kt(e=>{let{children:t,...r}=e,i=h.useMemo(()=>r,Object.values(r));return(0,g.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=h.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return kt(i,`useContext`),[r,i]}kt(At,`createContext`);function jt(e,t=[]){let n=[];function r(t,r){let i=h.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=kt(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=h.useMemo(()=>o,Object.values(o));return(0,g.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=h.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return kt(s,`useContext`),[o,s]}kt(r,`createContext`);let i=kt(()=>{let t=n.map(e=>h.createContext(e));return kt(function(n){let r=n?.[e]||t;return h.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Mt(i,...t)]}kt(jt,`createContextScope`);function Mt(...e){let t=e[0];if(e.length===1)return t;let n=kt(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return kt(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}kt(Mt,`composeContextScopes`);var Nt=globalThis?.document?h.useLayoutEffect:()=>{},Pt=Object.defineProperty,Ft=(e,t)=>Pt(e,`name`,{value:t,configurable:!0}),It=h.useId||(()=>void 0),Lt=0;function Rt(e){let[t,n]=h.useState(It());return Nt(()=>{e||n(e=>e??String(Lt++))},[e]),e||(t?`radix-${t}`:``)}Ft(Rt,`useId`);var zt=Object.defineProperty,Bt=(e,t)=>zt(e,`name`,{value:t,configurable:!0}),Vt=h.useEffectEvent,Ht=h.useInsertionEffect;function Ut(e){if(typeof Vt==`function`)return Vt(e);let t=h.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof Ht==`function`?Ht(()=>{t.current=e}):Nt(()=>{t.current=e}),h.useMemo(()=>((...e)=>t.current?.(...e)),[])}Bt(Ut,`useEffectEvent`);var Wt=Object.defineProperty,Gt=(e,t)=>Wt(e,`name`,{value:t,configurable:!0}),Kt=h.useInsertionEffect||Nt;function qt({prop:e,defaultProp:t,onChange:n=Gt(()=>{},`onChange`),caller:r}){let[i,a,o]=Jt({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,h.useCallback(t=>{if(s){let n=Yt(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}Gt(qt,`useControllableState`);function Jt({defaultProp:e,onChange:t}){let[n,r]=h.useState(e),i=h.useRef(n),a=h.useRef(t);return Kt(()=>{a.current=t},[t]),h.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Gt(Jt,`useUncontrolledState`);function Yt(e){return typeof e==`function`}Gt(Yt,`isFunction`);var Xt=Symbol(`RADIX:SYNC_STATE`);function Zt(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=Ut(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=h.useReducer((t,n)=>{if(n.type===Xt)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=h.useRef(p);h.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let g=h.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return h.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Xt,state:i})},[i,d.state,c]),[g,f]}Gt(Zt,`useControllableStateReducer`);var Qt=s((e=>{var t=f();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),$t=s(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Qt()})),en=u($t(),1),tn=Object.defineProperty,nn=(e,t)=>tn(e,`name`,{value:t,configurable:!0});function rn(e){let t=h.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];r=mn(r),h.Children.forEach(r,e=>{if(un(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;for(;fn(n)&&typeof vn==`function`;)n=vn(n._payload);a=sn(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=h.cloneElement(a,void 0,s):!o&&h.Children.count(r)===1&&h.isValidElement(r)&&(a=r);let c=a?ln(a):void 0,l=Dt(n,c);if(!a){if(r||r===0)throw Error(o?_n(e):gn(e));return r}let u=cn(i,a.props??{});return a.type!==h.Fragment&&(u.ref=n?l:c),h.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}nn(rn,`createSlot`);var an=Symbol.for(`radix.slottable`);function on(e){let t=nn(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=an,t}nn(on,`createSlottable`);var sn=nn((e,t)=>`child`in e.props?h.isValidElement(t)?h.cloneElement(t,void 0,e.props.children(t.props.children)):null:h.isValidElement(t)?t:null,`getSlottableElementFromSlottable`);function cn(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`?n[r]=[i,a].filter(Boolean).join(` `):r===`aria-describedby`&&(n[r]=hn(a,i))}return{...e,...n}}nn(cn,`mergeProps`);function ln(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}nn(ln,`getElementRef`);function un(e){return h.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===an}nn(un,`isSlottable`);var dn=Symbol.for(`react.lazy`);function fn(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===dn&&`_payload`in e&&pn(e._payload)}nn(fn,`isLazyComponent`);function pn(e){return typeof e==`object`&&!!e&&`then`in e}nn(pn,`isPromiseLike`);function mn(e){let t=e;for(;fn(t)&&typeof vn==`function`;)t=vn(t._payload);return t}nn(mn,`useUnwrappedLazy`);function hn(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}nn(hn,`concatAriaDescribedby`);var gn=nn(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),_n=nn(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),vn=h.use,yn=Object.defineProperty,bn=(e,t)=>yn(e,`name`,{value:t,configurable:!0}),xn=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=rn(`Primitive.${t}`),r=h.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,g.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Sn(e,t){e&&en.flushSync(()=>e.dispatchEvent(t))}bn(Sn,`dispatchDiscreteCustomEvent`);var Cn=Object.defineProperty,wn=(e,t)=>Cn(e,`name`,{value:t,configurable:!0}),Tn=h.useInsertionEffect;function En(e){let t=h.useRef(e);return typeof Tn==`function`?Tn(()=>{t.current=e}):Nt(()=>{t.current=e}),h.useMemo(()=>((...e)=>t.current?.(...e)),[])}wn(En,`useCallbackRef`);var Dn=Object.defineProperty,On=(e,t)=>Dn(e,`name`,{value:t,configurable:!0}),kn=`dismissableLayer.update`,An=`dismissableLayer.pointerDownOutside`,jn=`dismissableLayer.focusOutside`,Mn,Nn=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Pn=h.forwardRef(On(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=h.useContext(Nn),[d,f]=h.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=h.useState({}),_=Dt(t,f),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=y?v.indexOf(y):-1,x=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,C=x>=b,w=h.useRef(!1),T=Ln(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:w,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:h.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return C&&!t},[u.branches,C])}),E=Rn(e=>{if(r&&w.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),D=d?x===v.length-1:!1,O=En(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return h.useEffect(()=>{if(D)return p.addEventListener(`keydown`,O,{capture:!0}),()=>p.removeEventListener(`keydown`,O,{capture:!0})},[p,D,O]),h.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Mn=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),zn(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Mn))}},[d,p,n,u]),h.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),zn())},[d,u]),h.useEffect(()=>{let e=On(()=>m({}),`handleUpdate`);return document.addEventListener(kn,e),()=>document.removeEventListener(kn,e)},[]),(0,g.jsx)(xn.div,{...l,ref:_,style:{pointerEvents:S?C?`auto`:`none`:void 0,...e.style},onFocusCapture:vt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:vt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:vt(e.onPointerDownCapture,T.onPointerDownCapture)})},`DismissableLayer`));function Fn(){let e=h.useContext(Nn),[t,n]=h.useState(null);return h.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}On(Fn,`useDismissableLayerSurface`);var In=On(()=>!0,`IS_TRUE`);function Ln(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=In}=t,s=En(e),c=h.useRef(!1),l=h.useRef(!1),u=h.useRef(new Map),d=h.useRef(()=>{});return h.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}On(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}On(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}On(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}On(p,`handleInteractionBubble`);let m=On(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||Bn(An,s,p,{discrete:!0})};if(On(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:On(()=>c.current=!0,`onPointerDownCapture`)}}On(Ln,`usePointerDownOutside`);function Rn(e,t=globalThis?.document){let n=En(e),r=h.useRef(!1);return h.useEffect(()=>{let e=On(e=>{e.target&&!r.current&&Bn(jn,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:On(()=>r.current=!0,`onFocusCapture`),onBlurCapture:On(()=>r.current=!1,`onBlurCapture`)}}On(Rn,`useFocusOutside`);function zn(){let e=new CustomEvent(kn);document.dispatchEvent(e)}On(zn,`dispatchUpdate`);function Bn(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Sn(i,a):i.dispatchEvent(a)}On(Bn,`handleAndDispatchCustomEvent`);var Vn=Object.defineProperty,Hn=(e,t)=>Vn(e,`name`,{value:t,configurable:!0}),Un=`focusScope.autoFocusOnMount`,Wn=`focusScope.autoFocusOnUnmount`,Gn={bubbles:!1,cancelable:!0},Kn=h.forwardRef(Hn(function(e,t){let{loop:n=!1,trapped:r=!1,branches:i,onMountAutoFocus:a,onUnmountAutoFocus:o,...s}=e,[c,l]=h.useState(null),u=En(a),d=En(o),f=h.useRef(null),p=Dt(t,l),m=h.useRef(i);h.useEffect(()=>{m.current=i});let _=h.useCallback(e=>e?c?.contains(e)?!0:!!m.current?.some(t=>t.contains(e)):!1,[c]),v=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let e=function(e){if(v.paused||!c)return;let t=e.target;_(t)?f.current=t:rr(f.current,{select:!0})},t=function(e){if(v.paused||!c)return;let t=e.relatedTarget;t!==null&&(_(t)||rr(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&rr(c)};Hn(e,`handleFocusIn`),Hn(t,`handleFocusOut`),Hn(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,v.paused,_]),h.useEffect(()=>{if(c){ir.add(v);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(Un,Gn);c.addEventListener(Un,u),c.dispatchEvent(t),t.defaultPrevented||(Zn(sr($n(c)),{select:!0}),document.activeElement===e&&rr(c))}return()=>{c.removeEventListener(Un,u);let t=c.ownerDocument,n=CustomEvent;setTimeout(()=>{let r=new n(Wn,Gn);c.addEventListener(Wn,d),c.dispatchEvent(r),r.defaultPrevented||rr(e??t.body,{select:!0}),c.removeEventListener(Wn,d),ir.remove(v)},0)}}},[c,u,d,v]);let y=h.useCallback(e=>{if(!n&&!r||v.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Qn(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&rr(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&rr(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,v.paused]);return(0,g.jsx)(xn.div,{tabIndex:-1,...s,ref:p,onKeyDown:y})},`FocusScope`)),qn=h.createContext(null);function Jn({registry:e,children:t}){return e?(0,g.jsx)(qn.Provider,{value:e,children:t}):t}Hn(Jn,`FocusScopeBranchProvider`);function Yn(){let[e,t]=h.useState([]);return{nodes:e,registry:h.useMemo(()=>({add:Hn(e=>t(t=>t.includes(e)?t:[...t,e]),`add`),remove:Hn(e=>t(t=>t.filter(t=>t!==e)),`remove`)}),[])}}Hn(Yn,`useFocusScopeBranchRegistry`);function Xn(e){let t=h.useContext(qn);h.useEffect(()=>{if(e&&t)return t.add(e),()=>t.remove(e)},[e,t])}Hn(Xn,`useFocusScopeBranch`);function Zn(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(rr(r,{select:t}),document.activeElement!==n)return}Hn(Zn,`focusFirst`);function Qn(e){let t=$n(e);return[er(t,e),er(t.reverse(),e)]}Hn(Qn,`getTabbableEdges`);function $n(e){let t=[],n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Hn(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}Hn($n,`getTabbableCandidates`);function er(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):tr(r,{upTo:t})))return r}Hn(er,`findVisible`);function tr(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}Hn(tr,`isHidden`);function nr(e){return e.tagName===`INPUT`&&typeof e.select==`function`}Hn(nr,`isSelectableInput`);function rr(e,{select:t=!1}={}){if(e&&e.focus){let n=(e.ownerDocument??document).activeElement;e.focus({preventScroll:!0}),e!==n&&nr(e)&&t&&e.select()}}Hn(rr,`focus`);var ir=ar();function ar(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=or(e,t),e.unshift(t)},remove(t){e=or(e,t),e[0]?.resume()}}}Hn(ar,`createFocusScopesStack`);function or(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Hn(or,`arrayRemove`);function sr(e){return e.filter(e=>e.tagName!==`A`)}Hn(sr,`removeLinks`);var cr=Object.defineProperty,lr=h.forwardRef(((e,t)=>cr(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=h.useState(!1);Nt(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?en.createPortal((0,g.jsx)(xn.div,{...r,ref:t}),o):null},`Portal`)),ur=Object.defineProperty,dr=(e,t)=>ur(e,`name`,{value:t,configurable:!0});function fr(e,t){return h.useReducer((e,n)=>t[e][n]??e,e)}dr(fr,`useStateMachine`);var pr=dr(e=>{let{present:t,children:n}=e,r=mr(t),i=typeof n==`function`?n({present:r.isPresent}):h.Children.only(n),a=gr(r.ref,vr(i));return typeof n==`function`||r.isPresent?h.cloneElement(i,{ref:a}):null},`Presence`);function mr(e){let[t,n]=h.useState(),r=h.useRef(null),i=h.useRef(e),a=h.useRef(`none`),o=h.useRef(void 0),[s,c]=fr(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return h.useEffect(()=>{s===`mounted`?(a.current=o.current??_r(r.current),o.current=void 0):a.current=`none`},[s]),Nt(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=_r(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),Nt(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=dr(a=>{let o=_r(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=dr(e=>{e.target===t&&(a.current=_r(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:h.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=_r(t)}else r.current=null;n(e)},[])}}dr(mr,`usePresence`);function hr(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}dr(hr,`setRef`);function gr(...e){let t=h.useRef(e);return t.current=e,h.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=hr(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():hr(n[e],null)}}},[])}dr(gr,`useStableComposedRefs`);function _r(e){return e?.animationName||`none`}dr(_r,`getAnimationName`);function vr(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}dr(vr,`getElementRef`);var yr=Object.defineProperty,br=(e,t)=>yr(e,`name`,{value:t,configurable:!0}),xr=0,Sr=null;function Cr(e){return wr(),e.children}br(Cr,`FocusGuards`);function wr(){h.useEffect(()=>{Sr||={start:Tr(),end:Tr()};let{start:e,end:t}=Sr;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),xr++,()=>{xr===1&&(Sr?.start.remove(),Sr?.end.remove(),Sr=null),xr=Math.max(0,xr-1)}},[])}br(wr,`useFocusGuards`);function Tr(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}br(Tr,`createFocusGuard`);var Er=function(){return Er=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Er.apply(this,arguments)};function Dr(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Or(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var kr=`right-scroll-bar-position`,Ar=`width-before-scroll-bar`,jr=`with-scroll-bars-hidden`,Mr=`--removed-body-scroll-bar-size`;function Nr(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Pr(e,t){var n=(0,h.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Fr=typeof window<`u`?h.useLayoutEffect:h.useEffect,Ir=new WeakMap;function Lr(e,t){var n=Pr(t||null,function(t){return e.forEach(function(e){return Nr(e,t)})});return Fr(function(){var t=Ir.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Nr(e,null)}),i.forEach(function(e){r.has(e)||Nr(e,a)})}Ir.set(n,e)},[e]),n}function Rr(e){return e}function zr(e,t){t===void 0&&(t=Rr);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Br(e){e===void 0&&(e={});var t=zr(null);return t.options=Er({async:!0,ssr:!1},e),t}var Vr=function(e){var t=e.sideCar,n=Dr(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return h.createElement(r,Er({},n))};Vr.isSideCarExport=!0;function Hr(e,t){return e.useMedium(t),Vr}var Ur=Br(),Wr=function(){},Gr=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Wr,onWheelCapture:Wr,onTouchMoveCapture:Wr}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Dr(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=Lr([n,t]),w=Er(Er({},x),i);return h.createElement(h.Fragment,null,u&&h.createElement(S,{sideCar:Ur,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?h.cloneElement(h.Children.only(s),Er(Er({},w),{ref:C})):h.createElement(y,Er({},w,{className:c,ref:C}),s))});Gr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Gr.classNames={fullWidth:Ar,zeroRight:kr};var Kr=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function qr(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Kr();return t&&e.setAttribute(`nonce`,t),e}function Jr(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yr(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Xr=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qr())&&(Jr(t,n),Yr(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Zr=function(){var e=Xr();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Qr=function(){var e=Zr();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},$r={left:0,top:0,right:0,gap:0},ei=function(e){return parseInt(e||``,10)||0},ti=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[ei(n),ei(r),ei(i)]},ni=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return $r;var t=ti(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ri=Qr(),ii=`data-scroll-locked`,ai=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileViewer-4LwgwN4s.js","assets/monaco-BHRE2AKp.js","assets/editor.api-D0PbFQmb.js","assets/index-Bu4wSG15.js","assets/editor-B8GMDV7_.css","assets/monaco-n7clI0si.css","assets/FileEditor-CxzD-z_w.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./index-Bu4wSG15.js";var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),c=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},u=(e,r,i)=>(i=e==null?{}:t(a(e)),l(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)),d=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ee(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ee(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),ee(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=ee(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=ee(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ee(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function te(e,t,n){if(e==null)return e;var r=[],i=0;return ee(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function P(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var F=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function ne(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,F)}catch(e){F(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function I(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else ne(I.bind(null,e))}var re={map:te,forEach:function(e,t,n){te(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return te(e,function(){t++}),t},toArray:function(e){return te(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=re,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=I,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:P}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=ne,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),f=s(((e,t)=>{t.exports=d()})),p=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),m=s(((e,t)=>{t.exports=p()})),h=u(f(),1),g=m(),_=`larness.theme`,v=(0,h.createContext)(null);function y(e,t){return e===`system`?t?`dark`:`light`:e}function b(){try{let e=localStorage.getItem(_);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`light`}function x({children:e}){let[t,n]=(0,h.useState)(b),[r,i]=(0,h.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches);(0,h.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`);i(e.matches);let t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let a=y(t,r);(0,h.useEffect)(()=>{document.documentElement.dataset.theme=a,document.documentElement.style.colorScheme=a;try{localStorage.setItem(_,t)}catch{}},[a,t]);let o=(0,h.useCallback)(e=>n(e),[]),s=(0,h.useMemo)(()=>({theme:t,resolved:a,setTheme:o}),[t,a,o]);return(0,g.jsx)(v.Provider,{value:s,children:e})}function S(){let e=(0,h.useContext)(v);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function C(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=C(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function w(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=C(e))&&(r&&(r+=` `),r+=t);return r}var T=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},E=(e,t)=>({classGroupId:e,validator:t}),D=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),O=`-`,k=[],A=`arbitrary..`,j=e=>{let t=ee(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return N(e);let n=e.split(O);return M(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?T(i,t):t:i||k}return n[e]||k}}},M=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=M(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(O):e.slice(t).join(O),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},N=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?A+r:void 0})(),ee=e=>{let{theme:t,classGroups:n}=e;return te(n,t)},te=(e,t)=>{let n=D();for(let r in e){let i=e[r];P(i,n,r,t)}return n},P=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];F(i,t,n,r)}},F=(e,t,n,r)=>{typeof e==`string`?ne(e,t,n):typeof e==`function`?I(e,t,n,r):re(e,t,n,r)},ne=(e,t,n)=>{let r=e===``?t:ie(t,e);r.classGroupId=n},I=(e,t,n,r)=>{ae(e)?P(e(r),t,n,r):(t.validators===null&&(t.validators=[]),t.validators.push(E(n,e)))},re=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];P(o,ie(t,a),n,r)}},ie=(e,t)=>{let n=e,r=t.split(O),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=D(),n.nextPart.set(t,i)),n=i}return n},ae=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,oe=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},se=`!`,ce=`:`,le=[],ue=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),de=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===ce){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(se)?(c=s.slice(0,-1),l=!0):s.startsWith(se)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return ue(t,l,c,u)};if(t){let e=t+ce,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):ue(le,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},L=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},fe=e=>({cache:oe(e.cacheSize),parseClassName:de(e),sortModifiers:L(e),postfixLookupClassGroupIds:pe(e),...j(e)}),pe=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},me=/\s+/,he=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(me),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h||(g=r(p),!g)){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+se:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},ge=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=_e(n))&&(i&&(i+=` `),i+=r);return i},_e=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=_e(e[r]))&&(n&&(n+=` `),n+=t);return n},ve=(e,...t)=>{let n,r,i,a,o=o=>(n=fe(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=he(e,n);return i(e,a),a};return a=o,(...e)=>a(ge(...e))},ye=[],be=e=>{let t=t=>t[e]||ye;return t.isThemeGetter=!0,t.themeKey=e,t},xe=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Se=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ce=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,we=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Te=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ee=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,De=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Oe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ke=e=>Ce.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),je=e=>!!e&&Number.isInteger(Number(e)),Me=e=>e.endsWith(`%`)&&Ae(e.slice(0,-1)),Ne=e=>we.test(e),Pe=()=>!0,Fe=e=>Te.test(e)&&!Ee.test(e),Ie=()=>!1,Le=e=>De.test(e),Re=e=>Oe.test(e),ze=e=>!R(e)&&!z(e),Be=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),Ve=e=>nt(e,ot,Ie),R=e=>xe.test(e),He=e=>nt(e,st,Fe),Ue=e=>nt(e,ct,Ae),We=e=>nt(e,ut,Pe),Ge=e=>nt(e,lt,Ie),Ke=e=>nt(e,it,Ie),qe=e=>nt(e,at,Re),Je=e=>nt(e,dt,Le),z=e=>Se.test(e),Ye=e=>rt(e,st),Xe=e=>rt(e,lt),Ze=e=>rt(e,it),Qe=e=>rt(e,ot),$e=e=>rt(e,at),et=e=>rt(e,dt,!0),tt=e=>rt(e,ut,!0),nt=(e,t,n)=>{let r=xe.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},rt=(e,t,n=!1)=>{let r=Se.exec(e);return r?r[1]?t(r[1]):n:!1},it=e=>e===`position`||e===`percentage`,at=e=>e===`image`||e===`url`,ot=e=>e===`length`||e===`size`||e===`bg-size`,st=e=>e===`length`,ct=e=>e===`number`,lt=e=>e===`family-name`,ut=e=>e===`number`||e===`weight`,dt=e=>e===`shadow`,ft=ve(()=>{let e=be(`color`),t=be(`font`),n=be(`text`),r=be(`font-weight`),i=be(`tracking`),a=be(`leading`),o=be(`breakpoint`),s=be(`container`),c=be(`spacing`),l=be(`radius`),u=be(`shadow`),d=be(`inset-shadow`),f=be(`text-shadow`),p=be(`drop-shadow`),m=be(`blur`),h=be(`perspective`),g=be(`aspect`),_=be(`ease`),v=be(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),z,R],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[z,R,c],T=()=>[ke,`full`,`auto`,...w()],E=()=>[je,`none`,`subgrid`,z,R],D=()=>[`auto`,{span:[`full`,je,z,R]},je,z,R],O=()=>[je,`auto`,z,R],k=()=>[`auto`,`min`,`max`,`fr`,z,R],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[ke,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ee=()=>[s,ke,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],te=()=>[ke,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,z,R],F=()=>[...b(),Ze,Ke,{position:[z,R]}],ne=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],I=()=>[`auto`,`cover`,`contain`,Qe,Ve,{size:[z,R]}],re=()=>[Me,Ye,He],ie=()=>[``,`none`,`full`,l,z,R],ae=()=>[``,Ae,Ye,He],oe=()=>[`solid`,`dashed`,`dotted`,`double`],se=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ce=()=>[Ae,Me,Ze,Ke],le=()=>[``,`none`,m,z,R],ue=()=>[`none`,Ae,z,R],de=()=>[`none`,Ae,z,R],L=()=>[Ae,z,R],fe=()=>[ke,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Ne],breakpoint:[Ne],color:[Pe],container:[Ne],"drop-shadow":[Ne],ease:[`in`,`out`,`in-out`],font:[ze],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Ne],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Ne],shadow:[Ne],spacing:[`px`,Ae],text:[Ne],"text-shadow":[Ne],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,ke,R,z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,z,R]}],"container-named":[Be],columns:[{columns:[Ae,`auto`,R,z,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[je,`auto`,z,R]}],basis:[{basis:[ke,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Ae,ke,`auto`,`initial`,`none`,R]}],grow:[{grow:[``,Ae,z,R]}],shrink:[{shrink:[``,Ae,z,R]}],order:[{order:[je,`first`,`last`,`none`,z,R]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...ee()]}],"min-inline-size":[{"min-inline":[`auto`,...ee()]}],"max-inline-size":[{"max-inline":[`none`,...ee()]}],"block-size":[{block:[`auto`,...te()]}],"min-block-size":[{"min-block":[`auto`,...te()]}],"max-block-size":[{"max-block":[`none`,...te()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...N()]}],"font-size":[{text:[`base`,n,Ye,He]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,tt,We]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,Me,R]}],"font-family":[{font:[Xe,Ge,t]}],"font-features":[{"font-features":[R]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,z,R]}],"line-clamp":[{"line-clamp":[Ae,`none`,z,Ue]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,z,R]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,z,R]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...oe(),`wavy`]}],"text-decoration-thickness":[{decoration:[Ae,`from-font`,`auto`,z,He]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[Ae,`auto`,z,R]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[je,z,R]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,z,R]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,z,R]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:I()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},je,z,R],radial:[``,z,R],conic:[``,je,z,R]},$e,qe]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:ie()}],"rounded-s":[{"rounded-s":ie()}],"rounded-e":[{"rounded-e":ie()}],"rounded-t":[{"rounded-t":ie()}],"rounded-r":[{"rounded-r":ie()}],"rounded-b":[{"rounded-b":ie()}],"rounded-l":[{"rounded-l":ie()}],"rounded-ss":[{"rounded-ss":ie()}],"rounded-se":[{"rounded-se":ie()}],"rounded-ee":[{"rounded-ee":ie()}],"rounded-es":[{"rounded-es":ie()}],"rounded-tl":[{"rounded-tl":ie()}],"rounded-tr":[{"rounded-tr":ie()}],"rounded-br":[{"rounded-br":ie()}],"rounded-bl":[{"rounded-bl":ie()}],"border-w":[{border:ae()}],"border-w-x":[{"border-x":ae()}],"border-w-y":[{"border-y":ae()}],"border-w-s":[{"border-s":ae()}],"border-w-e":[{"border-e":ae()}],"border-w-bs":[{"border-bs":ae()}],"border-w-be":[{"border-be":ae()}],"border-w-t":[{"border-t":ae()}],"border-w-r":[{"border-r":ae()}],"border-w-b":[{"border-b":ae()}],"border-w-l":[{"border-l":ae()}],"divide-x":[{"divide-x":ae()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":ae()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...oe(),`hidden`,`none`]}],"divide-style":[{divide:[...oe(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-bs":[{"border-bs":P()}],"border-color-be":[{"border-be":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...oe(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Ae,z,R]}],"outline-w":[{outline:[``,Ae,Ye,He]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`inner`,`none`,u,et,Je]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,et,Je]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:ae()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[Ae,He]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":ae()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,et,Je]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[Ae,z,R]}],"mix-blend":[{"mix-blend":[...se(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":se()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[z,R]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,z,R]}],filter:[{filter:[``,`none`,z,R]}],blur:[{blur:le()}],brightness:[{brightness:[Ae,z,R]}],contrast:[{contrast:[Ae,z,R]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,et,Je]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,Ae,z,R]}],"hue-rotate":[{"hue-rotate":[Ae,z,R]}],invert:[{invert:[``,Ae,z,R]}],saturate:[{saturate:[Ae,z,R]}],sepia:[{sepia:[``,Ae,z,R]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,z,R]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,z,R]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,z,R]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Ae,z,R]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,z,R]}],"backdrop-invert":[{"backdrop-invert":[``,Ae,z,R]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,z,R]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,z,R]}],"backdrop-sepia":[{"backdrop-sepia":[``,Ae,z,R]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,z,R]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Ae,`initial`,z,R]}],ease:[{ease:[`linear`,`initial`,_,z,R]}],delay:[{delay:[Ae,z,R]}],animate:[{animate:[`none`,v,z,R]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,z,R]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ue()}],"rotate-x":[{"rotate-x":ue()}],"rotate-y":[{"rotate-y":ue()}],"rotate-z":[{"rotate-z":ue()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":[`scale-3d`],skew:[{skew:L()}],"skew-x":[{"skew-x":L()}],"skew-y":[{"skew-y":L()}],transform:[{transform:[z,R,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:fe()}],"translate-x":[{"translate-x":fe()}],"translate-y":[{"translate-y":fe()}],"translate-z":[{"translate-z":fe()}],"translate-none":[`translate-none`],zoom:[{zoom:[je,z,R]}],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,z,R]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":P()}],"scrollbar-track-color":[{"scrollbar-track":P()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,z,R]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[Ae,Ye,He,Ue]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function B(...e){return ft(w(e))}var pt={primary:`bg-accent text-white shadow-[0_1px_2px_rgba(0,0,0,.12)] hover:brightness-110 active:brightness-95`,secondary:`border border-line bg-surface text-ink shadow-[0_1px_1px_rgba(0,0,0,.03)] hover:bg-surface-2`,ghost:`text-ink-2 hover:bg-black/[.045] hover:text-ink dark:hover:bg-white/[.06]`,soft:`bg-accent-soft text-accent hover:bg-accent/20`,danger:`bg-danger text-white shadow-[0_1px_2px_rgba(0,0,0,.12)] hover:brightness-110 active:brightness-95`},mt={sm:`h-7 gap-1.5 rounded-lg px-2.5 text-[12px]`,md:`h-8 gap-2 rounded-[9px] px-3 text-[12.5px]`};function V({variant:e=`secondary`,size:t=`md`,leading:n,className:r,children:i,type:a=`button`,...o}){return(0,g.jsxs)(`button`,{type:a,className:B(`inline-flex select-none items-center justify-center whitespace-nowrap font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 focus-visible:ring-offset-1 focus-visible:ring-offset-canvas`,`disabled:pointer-events-none disabled:opacity-45`,pt[e],mt[t],r),...o,children:[n,i]})}var ht=Object.defineProperty,gt=(e,t)=>ht(e,`name`,{value:t,configurable:!0}),_t=!!(typeof window<`u`&&window.document&&window.document.createElement);function vt(e,t,{checkForDefaultPrevented:n=!0}={}){return gt(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}gt(vt,`composeEventHandlers`);function yt(e){if(!_t)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}gt(yt,`getOwnerWindow`);function bt(e){if(!_t)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}gt(bt,`getOwnerDocument`);function xt(e,t=!1){let{activeElement:n}=bt(e);if(!n?.nodeName)return null;if(St(n)&&n.contentDocument)return xt(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=bt(n).getElementById(e);if(t)return t}}return n}gt(xt,`getActiveElement`);function St(e){return e.tagName===`IFRAME`}gt(St,`isFrame`);var Ct=Object.defineProperty,wt=(e,t)=>Ct(e,`name`,{value:t,configurable:!0});function Tt(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}wt(Tt,`setRef`);function Et(...e){return t=>{let n=!1,r=e.map(e=>{let r=Tt(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Tt(e[t],null)}}}}wt(Et,`composeRefs`);function Dt(...e){return h.useCallback(Et(...e),e)}wt(Dt,`useComposedRefs`);var Ot=Object.defineProperty,kt=(e,t)=>Ot(e,`name`,{value:t,configurable:!0});function At(e,t){let n=h.createContext(t);n.displayName=e+`Context`;let r=kt(e=>{let{children:t,...r}=e,i=h.useMemo(()=>r,Object.values(r));return(0,g.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=h.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return kt(i,`useContext`),[r,i]}kt(At,`createContext`);function jt(e,t=[]){let n=[];function r(t,r){let i=h.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=kt(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=h.useMemo(()=>o,Object.values(o));return(0,g.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=h.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return kt(s,`useContext`),[o,s]}kt(r,`createContext`);let i=kt(()=>{let t=n.map(e=>h.createContext(e));return kt(function(n){let r=n?.[e]||t;return h.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Mt(i,...t)]}kt(jt,`createContextScope`);function Mt(...e){let t=e[0];if(e.length===1)return t;let n=kt(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return kt(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}kt(Mt,`composeContextScopes`);var Nt=globalThis?.document?h.useLayoutEffect:()=>{},Pt=Object.defineProperty,Ft=(e,t)=>Pt(e,`name`,{value:t,configurable:!0}),It=h.useId||(()=>void 0),Lt=0;function Rt(e){let[t,n]=h.useState(It());return Nt(()=>{e||n(e=>e??String(Lt++))},[e]),e||(t?`radix-${t}`:``)}Ft(Rt,`useId`);var zt=Object.defineProperty,Bt=(e,t)=>zt(e,`name`,{value:t,configurable:!0}),Vt=h.useEffectEvent,Ht=h.useInsertionEffect;function Ut(e){if(typeof Vt==`function`)return Vt(e);let t=h.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof Ht==`function`?Ht(()=>{t.current=e}):Nt(()=>{t.current=e}),h.useMemo(()=>((...e)=>t.current?.(...e)),[])}Bt(Ut,`useEffectEvent`);var Wt=Object.defineProperty,Gt=(e,t)=>Wt(e,`name`,{value:t,configurable:!0}),Kt=h.useInsertionEffect||Nt;function qt({prop:e,defaultProp:t,onChange:n=Gt(()=>{},`onChange`),caller:r}){let[i,a,o]=Jt({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,h.useCallback(t=>{if(s){let n=Yt(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}Gt(qt,`useControllableState`);function Jt({defaultProp:e,onChange:t}){let[n,r]=h.useState(e),i=h.useRef(n),a=h.useRef(t);return Kt(()=>{a.current=t},[t]),h.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Gt(Jt,`useUncontrolledState`);function Yt(e){return typeof e==`function`}Gt(Yt,`isFunction`);var Xt=Symbol(`RADIX:SYNC_STATE`);function Zt(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=Ut(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=h.useReducer((t,n)=>{if(n.type===Xt)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=h.useRef(p);h.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let g=h.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return h.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Xt,state:i})},[i,d.state,c]),[g,f]}Gt(Zt,`useControllableStateReducer`);var Qt=s((e=>{var t=f();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),$t=s(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Qt()})),en=u($t(),1),tn=Object.defineProperty,nn=(e,t)=>tn(e,`name`,{value:t,configurable:!0});function rn(e){let t=h.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];r=mn(r),h.Children.forEach(r,e=>{if(un(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;for(;fn(n)&&typeof vn==`function`;)n=vn(n._payload);a=sn(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=h.cloneElement(a,void 0,s):!o&&h.Children.count(r)===1&&h.isValidElement(r)&&(a=r);let c=a?ln(a):void 0,l=Dt(n,c);if(!a){if(r||r===0)throw Error(o?_n(e):gn(e));return r}let u=cn(i,a.props??{});return a.type!==h.Fragment&&(u.ref=n?l:c),h.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}nn(rn,`createSlot`);var an=Symbol.for(`radix.slottable`);function on(e){let t=nn(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=an,t}nn(on,`createSlottable`);var sn=nn((e,t)=>`child`in e.props?h.isValidElement(t)?h.cloneElement(t,void 0,e.props.children(t.props.children)):null:h.isValidElement(t)?t:null,`getSlottableElementFromSlottable`);function cn(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`?n[r]=[i,a].filter(Boolean).join(` `):r===`aria-describedby`&&(n[r]=hn(a,i))}return{...e,...n}}nn(cn,`mergeProps`);function ln(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}nn(ln,`getElementRef`);function un(e){return h.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===an}nn(un,`isSlottable`);var dn=Symbol.for(`react.lazy`);function fn(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===dn&&`_payload`in e&&pn(e._payload)}nn(fn,`isLazyComponent`);function pn(e){return typeof e==`object`&&!!e&&`then`in e}nn(pn,`isPromiseLike`);function mn(e){let t=e;for(;fn(t)&&typeof vn==`function`;)t=vn(t._payload);return t}nn(mn,`useUnwrappedLazy`);function hn(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}nn(hn,`concatAriaDescribedby`);var gn=nn(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),_n=nn(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),vn=h.use,yn=Object.defineProperty,bn=(e,t)=>yn(e,`name`,{value:t,configurable:!0}),xn=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=rn(`Primitive.${t}`),r=h.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,g.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Sn(e,t){e&&en.flushSync(()=>e.dispatchEvent(t))}bn(Sn,`dispatchDiscreteCustomEvent`);var Cn=Object.defineProperty,wn=(e,t)=>Cn(e,`name`,{value:t,configurable:!0}),Tn=h.useInsertionEffect;function En(e){let t=h.useRef(e);return typeof Tn==`function`?Tn(()=>{t.current=e}):Nt(()=>{t.current=e}),h.useMemo(()=>((...e)=>t.current?.(...e)),[])}wn(En,`useCallbackRef`);var Dn=Object.defineProperty,On=(e,t)=>Dn(e,`name`,{value:t,configurable:!0}),kn=`dismissableLayer.update`,An=`dismissableLayer.pointerDownOutside`,jn=`dismissableLayer.focusOutside`,Mn,Nn=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Pn=h.forwardRef(On(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=h.useContext(Nn),[d,f]=h.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=h.useState({}),_=Dt(t,f),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=y?v.indexOf(y):-1,x=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,C=x>=b,w=h.useRef(!1),T=Ln(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:w,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:h.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return C&&!t},[u.branches,C])}),E=Rn(e=>{if(r&&w.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),D=d?x===v.length-1:!1,O=En(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return h.useEffect(()=>{if(D)return p.addEventListener(`keydown`,O,{capture:!0}),()=>p.removeEventListener(`keydown`,O,{capture:!0})},[p,D,O]),h.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Mn=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),zn(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Mn))}},[d,p,n,u]),h.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),zn())},[d,u]),h.useEffect(()=>{let e=On(()=>m({}),`handleUpdate`);return document.addEventListener(kn,e),()=>document.removeEventListener(kn,e)},[]),(0,g.jsx)(xn.div,{...l,ref:_,style:{pointerEvents:S?C?`auto`:`none`:void 0,...e.style},onFocusCapture:vt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:vt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:vt(e.onPointerDownCapture,T.onPointerDownCapture)})},`DismissableLayer`));function Fn(){let e=h.useContext(Nn),[t,n]=h.useState(null);return h.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}On(Fn,`useDismissableLayerSurface`);var In=On(()=>!0,`IS_TRUE`);function Ln(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=In}=t,s=En(e),c=h.useRef(!1),l=h.useRef(!1),u=h.useRef(new Map),d=h.useRef(()=>{});return h.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}On(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}On(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}On(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}On(p,`handleInteractionBubble`);let m=On(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||Bn(An,s,p,{discrete:!0})};if(On(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:On(()=>c.current=!0,`onPointerDownCapture`)}}On(Ln,`usePointerDownOutside`);function Rn(e,t=globalThis?.document){let n=En(e),r=h.useRef(!1);return h.useEffect(()=>{let e=On(e=>{e.target&&!r.current&&Bn(jn,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:On(()=>r.current=!0,`onFocusCapture`),onBlurCapture:On(()=>r.current=!1,`onBlurCapture`)}}On(Rn,`useFocusOutside`);function zn(){let e=new CustomEvent(kn);document.dispatchEvent(e)}On(zn,`dispatchUpdate`);function Bn(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Sn(i,a):i.dispatchEvent(a)}On(Bn,`handleAndDispatchCustomEvent`);var Vn=Object.defineProperty,Hn=(e,t)=>Vn(e,`name`,{value:t,configurable:!0}),Un=`focusScope.autoFocusOnMount`,Wn=`focusScope.autoFocusOnUnmount`,Gn={bubbles:!1,cancelable:!0},Kn=h.forwardRef(Hn(function(e,t){let{loop:n=!1,trapped:r=!1,branches:i,onMountAutoFocus:a,onUnmountAutoFocus:o,...s}=e,[c,l]=h.useState(null),u=En(a),d=En(o),f=h.useRef(null),p=Dt(t,l),m=h.useRef(i);h.useEffect(()=>{m.current=i});let _=h.useCallback(e=>e?c?.contains(e)?!0:!!m.current?.some(t=>t.contains(e)):!1,[c]),v=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let e=function(e){if(v.paused||!c)return;let t=e.target;_(t)?f.current=t:rr(f.current,{select:!0})},t=function(e){if(v.paused||!c)return;let t=e.relatedTarget;t!==null&&(_(t)||rr(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&rr(c)};Hn(e,`handleFocusIn`),Hn(t,`handleFocusOut`),Hn(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,v.paused,_]),h.useEffect(()=>{if(c){ir.add(v);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(Un,Gn);c.addEventListener(Un,u),c.dispatchEvent(t),t.defaultPrevented||(Zn(sr($n(c)),{select:!0}),document.activeElement===e&&rr(c))}return()=>{c.removeEventListener(Un,u);let t=c.ownerDocument,n=CustomEvent;setTimeout(()=>{let r=new n(Wn,Gn);c.addEventListener(Wn,d),c.dispatchEvent(r),r.defaultPrevented||rr(e??t.body,{select:!0}),c.removeEventListener(Wn,d),ir.remove(v)},0)}}},[c,u,d,v]);let y=h.useCallback(e=>{if(!n&&!r||v.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Qn(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&rr(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&rr(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,v.paused]);return(0,g.jsx)(xn.div,{tabIndex:-1,...s,ref:p,onKeyDown:y})},`FocusScope`)),qn=h.createContext(null);function Jn({registry:e,children:t}){return e?(0,g.jsx)(qn.Provider,{value:e,children:t}):t}Hn(Jn,`FocusScopeBranchProvider`);function Yn(){let[e,t]=h.useState([]);return{nodes:e,registry:h.useMemo(()=>({add:Hn(e=>t(t=>t.includes(e)?t:[...t,e]),`add`),remove:Hn(e=>t(t=>t.filter(t=>t!==e)),`remove`)}),[])}}Hn(Yn,`useFocusScopeBranchRegistry`);function Xn(e){let t=h.useContext(qn);h.useEffect(()=>{if(e&&t)return t.add(e),()=>t.remove(e)},[e,t])}Hn(Xn,`useFocusScopeBranch`);function Zn(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(rr(r,{select:t}),document.activeElement!==n)return}Hn(Zn,`focusFirst`);function Qn(e){let t=$n(e);return[er(t,e),er(t.reverse(),e)]}Hn(Qn,`getTabbableEdges`);function $n(e){let t=[],n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Hn(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}Hn($n,`getTabbableCandidates`);function er(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):tr(r,{upTo:t})))return r}Hn(er,`findVisible`);function tr(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}Hn(tr,`isHidden`);function nr(e){return e.tagName===`INPUT`&&typeof e.select==`function`}Hn(nr,`isSelectableInput`);function rr(e,{select:t=!1}={}){if(e&&e.focus){let n=(e.ownerDocument??document).activeElement;e.focus({preventScroll:!0}),e!==n&&nr(e)&&t&&e.select()}}Hn(rr,`focus`);var ir=ar();function ar(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=or(e,t),e.unshift(t)},remove(t){e=or(e,t),e[0]?.resume()}}}Hn(ar,`createFocusScopesStack`);function or(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Hn(or,`arrayRemove`);function sr(e){return e.filter(e=>e.tagName!==`A`)}Hn(sr,`removeLinks`);var cr=Object.defineProperty,lr=h.forwardRef(((e,t)=>cr(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=h.useState(!1);Nt(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?en.createPortal((0,g.jsx)(xn.div,{...r,ref:t}),o):null},`Portal`)),ur=Object.defineProperty,dr=(e,t)=>ur(e,`name`,{value:t,configurable:!0});function fr(e,t){return h.useReducer((e,n)=>t[e][n]??e,e)}dr(fr,`useStateMachine`);var pr=dr(e=>{let{present:t,children:n}=e,r=mr(t),i=typeof n==`function`?n({present:r.isPresent}):h.Children.only(n),a=gr(r.ref,vr(i));return typeof n==`function`||r.isPresent?h.cloneElement(i,{ref:a}):null},`Presence`);function mr(e){let[t,n]=h.useState(),r=h.useRef(null),i=h.useRef(e),a=h.useRef(`none`),o=h.useRef(void 0),[s,c]=fr(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return h.useEffect(()=>{s===`mounted`?(a.current=o.current??_r(r.current),o.current=void 0):a.current=`none`},[s]),Nt(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=_r(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),Nt(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=dr(a=>{let o=_r(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=dr(e=>{e.target===t&&(a.current=_r(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:h.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=_r(t)}else r.current=null;n(e)},[])}}dr(mr,`usePresence`);function hr(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}dr(hr,`setRef`);function gr(...e){let t=h.useRef(e);return t.current=e,h.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=hr(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():hr(n[e],null)}}},[])}dr(gr,`useStableComposedRefs`);function _r(e){return e?.animationName||`none`}dr(_r,`getAnimationName`);function vr(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}dr(vr,`getElementRef`);var yr=Object.defineProperty,br=(e,t)=>yr(e,`name`,{value:t,configurable:!0}),xr=0,Sr=null;function Cr(e){return wr(),e.children}br(Cr,`FocusGuards`);function wr(){h.useEffect(()=>{Sr||={start:Tr(),end:Tr()};let{start:e,end:t}=Sr;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),xr++,()=>{xr===1&&(Sr?.start.remove(),Sr?.end.remove(),Sr=null),xr=Math.max(0,xr-1)}},[])}br(wr,`useFocusGuards`);function Tr(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}br(Tr,`createFocusGuard`);var Er=function(){return Er=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Er.apply(this,arguments)};function Dr(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Or(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var kr=`right-scroll-bar-position`,Ar=`width-before-scroll-bar`,jr=`with-scroll-bars-hidden`,Mr=`--removed-body-scroll-bar-size`;function Nr(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Pr(e,t){var n=(0,h.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Fr=typeof window<`u`?h.useLayoutEffect:h.useEffect,Ir=new WeakMap;function Lr(e,t){var n=Pr(t||null,function(t){return e.forEach(function(e){return Nr(e,t)})});return Fr(function(){var t=Ir.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Nr(e,null)}),i.forEach(function(e){r.has(e)||Nr(e,a)})}Ir.set(n,e)},[e]),n}function Rr(e){return e}function zr(e,t){t===void 0&&(t=Rr);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Br(e){e===void 0&&(e={});var t=zr(null);return t.options=Er({async:!0,ssr:!1},e),t}var Vr=function(e){var t=e.sideCar,n=Dr(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return h.createElement(r,Er({},n))};Vr.isSideCarExport=!0;function Hr(e,t){return e.useMedium(t),Vr}var Ur=Br(),Wr=function(){},Gr=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Wr,onWheelCapture:Wr,onTouchMoveCapture:Wr}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Dr(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=Lr([n,t]),w=Er(Er({},x),i);return h.createElement(h.Fragment,null,u&&h.createElement(S,{sideCar:Ur,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?h.cloneElement(h.Children.only(s),Er(Er({},w),{ref:C})):h.createElement(y,Er({},w,{className:c,ref:C}),s))});Gr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Gr.classNames={fullWidth:Ar,zeroRight:kr};var Kr=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function qr(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Kr();return t&&e.setAttribute(`nonce`,t),e}function Jr(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yr(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Xr=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qr())&&(Jr(t,n),Yr(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Zr=function(){var e=Xr();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Qr=function(){var e=Zr();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},$r={left:0,top:0,right:0,gap:0},ei=function(e){return parseInt(e||``,10)||0},ti=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[ei(n),ei(r),ei(i)]},ni=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return $r;var t=ti(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ri=Qr(),ii=`data-scroll-locked`,ai=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
3
3
|
.${jr} {
|
|
4
4
|
overflow: hidden ${r};
|
|
5
5
|
padding-right: ${s}px ${r};
|
|
@@ -108,7 +108,7 @@ dist/assets/index-8f2a1c.js 412.8 kB │ gzip: 126.4 kB
|
|
|
108
108
|
➜ Local: http://localhost:5173/`}},yield{type:`plan`,item:{...n,steps:[{id:`p1`,title:`确认当前会话与项目状态`,status:`done`},{id:`p2`,title:`更新工作台并启动开发服务`,status:`done`},{id:`p3`,title:`验证预览地址与日志`,status:`running`}]}};let o=wq(Cq(`msg`),``);yield{type:`message.assistant`,item:o};for(let e of[`开发服务器已启动,端口 **5173**。`,`你可以从顶部浏览器入口打开预览,`,`或在右侧服务区查看实时日志。`])await Sq(180,t),yield{type:`message.delta`,id:o.id,text:e};yield{type:`artifact`,item:{id:Cq(`art`),kind:`artifact`,title:`本地预览已就绪`,description:`Vite 开发服务运行在 5173,可从浏览器窗口打开。`,meta:`http://localhost:5173`,href:`http://localhost:5173`,createdAt:Date.now()}},yield{type:`plan`,item:{...n,steps:[{id:`p1`,title:`确认当前会话与项目状态`,status:`done`},{id:`p2`,title:`更新工作台并启动开发服务`,status:`done`},{id:`p3`,title:`验证预览地址与日志`,status:`done`}]}},yield{type:`turn.done`}}async resolveApproval(e,t){await new Promise(e=>window.setTimeout(e,600))}async cancelTurn(e){await Promise.resolve()}};var Tq=null,Eq=null,Dq=null,Oq=null,kq=0,Aq=!1,jq=!1;function Mq(e){return{id:`error_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,kind:`error`,message:e,createdAt:Date.now()}}async function Nq(e,t,n){if(t.length===0)return;let r=await $j(e,t),i=r.find(({attachment:e})=>e.status===`failed`);if(i)throw Error(`${i.attachment.filename} 解析失败,请移除或重试。`);if(!n){for(let{attachment:t}of r)if(t.kind===`image`&&t.method===`none`)try{await Qj(e,t.id)}catch{throw Error(`${t.filename} 需要视觉模型或本地 OCR 才能发送。`)}}return r.map(({attachment:e})=>e.id)}function Pq(){Dq!==null&&(window.clearTimeout(Dq),Dq=null),Oq=null,Eq?.close(),Eq=null}function Fq(e){return e.length===0||/unauthenticated|authorization|session|revoked|expired|device/i.test(e)}function Iq(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.type===`context.compressed`)return{degraded:(typeof n.payload==`object`&&n.payload!==null?n.payload:{}).degraded===!0,createdAt:n.timestamp}}return null}function Lq(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.type!==`turn.completed`)continue;let r=typeof n.payload==`object`&&n.payload!==null?n.payload.usage:null;if(typeof r==`object`&&r){let e=r;if(typeof e.inputTokens==`number`)return e.inputTokens;if(typeof e.totalTokens==`number`)return e.totalTokens}}return 0}function Rq(e,t){return e.some(e=>vq(e)&&yq(e)===t)}function zq(e){let t=Uq.getState();e.sessionId===t.sessionId&&Uq.setState({items:fq(t.items,{messageId:e.messageId,text:e.text,createdAt:e.timestamp,turnId:e.turnId}),isStreaming:!0,activeTurnId:t.activeTurnId??e.turnId,turnStartedAt:t.turnStartedAt??e.timestamp})}function Bq(e){let t=Uq.getState();e.sessionId===t.sessionId&&Uq.setState({items:xq(t.items,{id:`reasoning_${e.turnId}`,turnId:e.turnId,text:e.text,createdAt:e.timestamp}),activeTurnId:t.activeTurnId??e.turnId,turnStartedAt:t.turnStartedAt??e.timestamp})}function Vq(e,t=!1,n=!1){let r=Uq.getState();if(e.sessionId!==void 0&&e.sessionId!==r.sessionId||e.sequence<=r.lastSeq)return;if(!n&&e.sequence!==r.lastSeq+1){r.syncEvents();return}let i=e.payload??{},a=yq(e),o=typeof i.status==`string`?i.status:null,s=e.type===`turn.created`||e.type===`turn.status`?a??r.activeTurnId:r.activeTurnId,c=vq(e)?!1:e.type===`turn.created`||o===`QUEUED`||o===`PREPARING`||o===`RUNNING`||o===`WAITING_APPROVAL`||o===`CANCELLING`||r.isStreaming,l=vq(e),u=hq(r.items,e).map(e=>l&&e.kind===`reasoning`?{...e,streaming:!1}:e),d=e.type===`turn.completed`&&typeof i.usage==`object`&&i.usage!==null?i.usage:null,f=typeof d?.inputTokens==`number`?d.inputTokens:typeof d?.totalTokens==`number`?d.totalTokens:r.contextTokens,p=e.type===`model.usage`?{...r.modelUsage,...gq([e])}:r.modelUsage;Uq.setState({items:l?u.map(e=>e.kind===`message`?{...e,streaming:!1}:e):u,lastSeq:e.sequence,activeTurnId:l?null:s,isStreaming:c,contextTokens:f,contextNotice:e.type===`context.compressed`?{degraded:i.degraded===!0,createdAt:e.timestamp}:r.contextNotice,modelUsage:p,turnStartedAt:l||c?l?null:r.turnStartedAt??e.timestamp:r.turnStartedAt}),e.type===`tool.completed`&&eq(i,aM.getQueryData([`session`])?.clientSessionId),l&&aM.invalidateQueries({queryKey:lM(e.sessionId??r.sessionId)}),t&&e.type===`tool.completed`&&typeof i.originClientSessionId==`string`&&(aM.invalidateQueries({queryKey:[`terminals`]}),ZK(i,aM.getQueryData([`session`])?.clientSessionId))}function Hq(e){if(typeof window>`u`)return;Pq(),Oq=e;let t=window.location.protocol===`https:`?`wss`:`ws`,n=new WebSocket(`${t}://${window.location.host}/ws`);Eq=n,n.addEventListener(`open`,()=>{Oq===e&&n.send(JSON.stringify({type:`subscribe`,subscriptions:[{topic:`agent`,resourceId:e}]}))}),n.addEventListener(`message`,t=>{if(Oq!==e)return;let n;try{n=JSON.parse(String(t.data))}catch{return}if(typeof n!=`object`||!n)return;let r=n;r.kind===`subscribed`?(typeof r.currentSequence==`number`?r.currentSequence:0)>Uq.getState().lastSeq&&Uq.getState().syncEvents():r.kind===`assistant.delta`&&r.topic===`agent`?zq(r):r.kind===`assistant.reasoning.delta`&&r.topic===`agent`?Bq(r):r.kind===`event`&&r.topic===`agent`&&Vq(r,!0)}),n.addEventListener(`close`,t=>{Eq===n&&Oq===e&&(Eq=null,t.code===1008&&Fq(t.reason)?window.dispatchEvent(new Event(`larness:unauthenticated`)):Dq=window.setTimeout(()=>{Oq===e&&Hq(e)},1e3))}),n.addEventListener(`error`,()=>n.close())}var Uq=hM((e,t)=>({sessionId:``,items:[],loading:!1,isStreaming:!1,activeTurnId:null,turnStartedAt:null,contextTokens:0,contextNotice:null,modelUsage:{},lastSeq:0,scrollToLatestNonce:0,load:async n=>{let r=++kq;if(Pq(),Tq?.abort(),Tq=null,e({sessionId:n,items:[],loading:!!n,isStreaming:!1,activeTurnId:null,turnStartedAt:null,contextTokens:0,contextNotice:null,modelUsage:{},lastSeq:0}),!n)e({loading:!1});else if(n.startsWith(`draft_`))e({loading:!1});else try{let[i,a]=await Promise.all([zj(n),nM(n,0)]);if(r!==kq||t().sessionId!==n)return;let o=i.activeTurn!==null&&!Rq(a,i.activeTurn.id)?i.activeTurn:null;e({items:_q(a),lastSeq:a.at(-1)?.sequence??0,loading:!1,isStreaming:o!==null,activeTurnId:o?.id??null,turnStartedAt:o?.createdAt??null,contextTokens:Lq(a),contextNotice:Iq(a),modelUsage:gq(a)});let s=aM.getQueryData([`session`]);for(let e of a)e.type===`tool.completed`&&typeof e.payload==`object`&&e.payload!==null&&eq(e.payload,s?.clientSessionId);Hq(n)}catch(t){if(r!==kq)return;e({loading:!1,items:[Mq(t instanceof Error?t.message:`加载会话失败`)]})}},disconnect:()=>{Pq()},syncEvents:async()=>{let n=t().sessionId;if(n){if(Aq)jq=!0;else{Aq=!0;try{do{jq=!1;let e=await nM(n,t().lastSeq);if(t().sessionId!==n)return;for(let t of e)Vq(t,!1,!0)}while(jq&&t().sessionId===n)}catch(r){if(t().sessionId!==n)return;let i=r instanceof Error?r.message:`事件补拉失败`;e(e=>({items:[...e.items,Mq(`事件补拉失败:${i}`)]}))}finally{Aq=!1,jq&&(jq=!1,t().syncEvents())}}}},send:async(n,r,i,a,o,s=[],c,l=!1)=>{let u=n.trim();if(!u&&s.length===0||t().isStreaming)return;let d=t().sessionId;if(!d)return;e(e=>({scrollToLatestNonce:e.scrollToLatestNonce+1}));let f=vW.getState();if(f.sessionId!==d||aM.isMutating({mutationKey:uM(d)}))return;let p=f.draftSession;if(p!==null&&p.id===d){e({isStreaming:!0,turnStartedAt:Date.now()});let n=null,f=!1;try{n=await Lj({...p.projectId===null?{}:{projectId:p.projectId},...a===void 0?{}:{agentProfile:a}}),await Bj(n.id,{...r,approvalPolicyId:i,...o===void 0?{}:{webSearchEnabled:o}});let e=await Nq(n.id,s,l);await tM(n.id,{input:u,...r,...e?{attachmentIds:e}:{}},crypto.randomUUID()),f=!0,c?.(),await aM.invalidateQueries({queryKey:[`workspace`]}),vW.getState().commitDraft(p.id,n.id,n.projectId)}catch(r){if(n!==null&&!f&&await qj(n.id).catch(()=>void 0),t().sessionId!==d)return;let i=r instanceof Error?r.message:`发送失败`;e(e=>({isStreaming:!1,turnStartedAt:null,items:[...e.items,Mq(`发送失败:${i}`)]}))}return}let m={id:`optimistic_user_${Date.now()}`,kind:`message`,role:`user`,text:u,createdAt:Date.now()};e(e=>({items:[...e.items,m],isStreaming:!0,turnStartedAt:Date.now()}));try{let n=await Nq(d,s,l),i=await tM(d,{input:u,...r,...n?{attachmentIds:n}:{}},crypto.randomUUID());if(c?.(),aM.invalidateQueries({queryKey:cM(d)}),t().sessionId!==d)return;e({activeTurnId:i.turnId}),await aM.invalidateQueries({queryKey:[`workspace`]}),t().sessionId===d&&await t().syncEvents()}catch(n){if(t().sessionId!==d)return;let r=n instanceof Error?n.message:`发送失败`;e(e=>({isStreaming:!1,turnStartedAt:null,items:[...e.items.filter(e=>e.id!==m.id),Mq(`发送失败:${r}`)]})),await t().syncEvents()}},stop:()=>{let e=t().sessionId,n=t().activeTurnId;n!==null&&Jee(n).catch(n=>{if(t().sessionId!==e)return;let r=n instanceof Error?n.message:`停止失败`;Uq.setState(e=>({items:[...e.items,Mq(`停止失败:${r}`)]}))})},resumeTurn:async n=>{let r=t().sessionId;try{let i=await Yee(n);if(t().sessionId!==r)return;e({isStreaming:!0,activeTurnId:i.turnId,turnStartedAt:Date.now()}),await t().syncEvents()}catch(e){if(t().sessionId!==r)return;let n=e instanceof Error?e.message:`无法继续该任务`;Uq.setState(e=>({items:[...e.items,Mq(`继续失败:${n}`)]}))}},resolveApproval:async(n,r)=>{let i=r===`approve`?`approved`:`rejected`,a=t=>e(e=>({items:e.items.map(e=>e.kind===`approval`&&e.id===n?{...e,status:t}:e)}));if(t().items.find(e=>e.kind===`approval`&&e.id===n)?.status!==`pending`)return;let o=t().sessionId;await Zee(n,r),t().sessionId===o&&(a(i),await t().syncEvents())}})),Wq=5;function Gq({mobile:e=!1}){let t=(0,h.useId)(),{data:n}=sM(),{projectId:r,sessionId:i,draftSession:a,sidebarWidth:o,expandedProjects:s,toggleProject:c,expandProject:l,setExpandedProjects:u,selectSession:d,startDraft:f}=vW(),p=BK(e=>e.extra),m=Uq(e=>null),_=VK(),v=ZW(),y=Eh(),b=vW(e=>e.focusComposer),[x,S]=(0,h.useState)(``),[C,w]=(0,h.useState)({}),[T,E]=(0,h.useState)(!1),[D,O]=(0,h.useState)(!1),k=HK(e=>e.webSearchOpen),A=HK(e=>e.setWebSearchOpen),[j,M]=(0,h.useState)(!1),[N,ee]=(0,h.useState)(null),[te,P]=(0,h.useState)(`global`),[F,ne]=(0,h.useState)(!1),[I,re]=(0,h.useState)(!1),[ie,ae]=(0,h.useState)(0),oe=Zg({queryKey:eG,queryFn:iG,enabled:!0,refetchInterval:15e3}),se=Math.max(0,(oe.data?.failedLast24h??0)-ie),ce=Zg({queryKey:lK(),queryFn:()=>dK(),enabled:!0,refetchInterval:3e3}),le=(0,h.useMemo)(()=>{let e=new Map;for(let t of ce.data??[])t.status===`RUNNING`&&e.set(t.projectId,(e.get(t.projectId)??0)+1);return e},[ce.data]);(0,h.useEffect)(()=>{I&&oe.data&&ae(oe.data.failedLast24h)},[I,oe.data]);let[ue,de]=(0,h.useState)(null),[L,fe]=(0,h.useState)(null),[pe,me]=(0,h.useState)(null),[he,ge]=(0,h.useState)(null),_e=(0,h.useRef)(null),ve=(0,h.useRef)(``),ye=(0,h.useRef)(!1),be=(0,h.useRef)(null);(0,h.useEffect)(()=>{if(ue===null)return;let e=()=>de(null),t=e=>{e.key===`Escape`&&de(null)};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,t),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,t),window.removeEventListener(`blur`,e)}},[ue]);let xe=(e,t,n,r)=>{e.preventDefault(),e.stopPropagation(),de(t===`project`&&n===`prj_default`?null:{kind:t,id:n,title:r,x:e.clientX,y:e.clientY})},Se=(0,h.useMemo)(()=>[...n.sessions].sort((e,t)=>t.updatedAt-e.updatedAt),[p,n.sessions]),Ce=e=>{l(e),f(e===`prj_default`?null:e),b()},we=Se.find(e=>e.id===i),Te=r===null&&(!we||we.workspaceKind==="default"),Ee=x.trim().toLowerCase(),De=e=>e.status!==`idle`||e.id===m,Oe=e=>e.id===i?2:+!!De(e),ke=n.projects.map(e=>{let t=e.name.toLowerCase().includes(Ee);return{...e,matchesName:t,sessions:Se.filter(n=>(e.kind==="default"?n.workspaceKind==="default":n.projectId===e.id)&&(t||n.title.toLowerCase().includes(Ee)))}}),Ae=ke.filter(e=>e.matchesName||e.sessions.length>0),je=Se.filter(e=>!Ee||e.title.toLowerCase().includes(Ee)||e.projectId&&n.projects.find(t=>t.id===e.projectId)?.name.toLowerCase().includes(Ee)).slice(0,6),Me=ke.filter(e=>e.kind!=="default"),Ne=Ee.length===0&&Me.length>1,Pe=new Map(Me.map((e,t)=>[e.id,t])),Fe=pe?Me.findIndex(e=>e.id===pe.id):-1,Ie=pe?.moved===!0&&pe.targetIndex!==Fe&&pe.targetIndex!==Fe+1,Le=()=>{document.body.style.userSelect=ve.current},Re=()=>{be.current===null&&(be.current=s,u(Object.fromEntries(ke.map(e=>[e.id,!1]))))},ze=()=>{let e=be.current;e!==null&&(be.current=null,u(e))},Be=async e=>{let t=y.getQueryData([`workspace`]);t&&y.setQueryData([`workspace`],{...t,projects:zK(t.projects,e)});try{await bj(e),await y.invalidateQueries({queryKey:[`workspace`]}),ge(null)}catch(e){t&&y.setQueryData([`workspace`],t),ge(pj(e,`调整项目顺序失败`)),y.invalidateQueries({queryKey:[`workspace`]})}},Ve=(e,t)=>{if(pe!==null||!Ne||t===`prj_default`||e.button!==0)return;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}ve.current=document.body.style.userSelect,document.body.style.userSelect=`none`;let n=Me.findIndex(e=>e.id===t);me({id:t,pointerId:e.pointerId,startY:e.clientY,moved:!1,targetIndex:Math.max(0,n)})},R=e=>{if(pe===null||pe.pointerId!==e.pointerId)return;!pe.moved&&Math.abs(e.clientY-pe.startY)>=4&&Re();let t=_e.current?Array.from(_e.current.querySelectorAll(`[data-project-drop-index]`)).map(e=>{let t=e.getBoundingClientRect();return{top:t.top,bottom:t.bottom}}):[];me(n=>{if(n===null||n.pointerId!==e.pointerId||!n.moved&&Math.abs(e.clientY-n.startY)<4)return n;let r=t.findIndex(t=>e.clientY<(t.top+t.bottom)/2),i=r===-1?t.length:r;return n.moved&&n.targetIndex===i?n:{...n,moved:!0,targetIndex:i}})},He=e=>{if(pe===null||pe.pointerId!==e.pointerId)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}Le(),ze();let t=pe;if(me(null),!t.moved)return;ye.current=!0,window.setTimeout(()=>{ye.current=!1},0);let n=Me.map(e=>e.id),r=RK(n,t.id,t.targetIndex);r!==n&&Be(r)},Ue=()=>{Le(),ze(),me(null)},We=(e,t)=>{if(!Ne||t===`prj_default`||e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let n=Me.map(e=>e.id),r=n.indexOf(t),i=r+(e.key===`ArrowUp`?-1:1);if(r<0||i<0||i>=n.length)return;let a=[...n];[a[r],a[i]]=[a[i],a[r]],Be(a)};return(0,h.useEffect)(()=>()=>{document.body.style.userSelect=ve.current;let e=be.current;e!==null&&(be.current=null,u(e))},[u]),(0,g.jsxs)(`aside`,{className:B(`shrink-0 flex-col bg-surface/45`,e?`flex h-full bg-surface`:`hidden md:flex`),style:{width:e?268:o},"aria-label":`项目与会话导航`,children:[(0,g.jsx)(`div`,{className:`px-2.5 pt-3`,children:(0,g.jsxs)(`button`,{type:`button`,onClick:_,className:`group flex h-8 w-full items-center gap-2 rounded-[9px] border border-line bg-surface px-2.5 text-[12px] font-medium text-ink shadow-[var(--shadow-card)] transition-colors hover:border-accent/30 hover:bg-accent-soft`,children:[(0,g.jsx)(Us,{size:14,className:`text-accent`}),(0,g.jsx)(`span`,{children:`新建会话`}),(0,g.jsx)(ym,{className:`ml-auto group-hover:border-accent/20`,children:`⌘K`})]})}),(0,g.jsx)(`div`,{className:`px-2.5 pt-2.5`,children:(0,g.jsxs)(`label`,{htmlFor:`${t}-search`,className:`flex h-7 items-center gap-1.5 rounded-lg bg-black/[.035] px-2 text-ink-3 transition-colors focus-within:bg-surface focus-within:ring-1 focus-within:ring-accent/30 dark:bg-white/[.05]`,children:[(0,g.jsx)($s,{size:12.5}),(0,g.jsx)(mm,{id:`${t}-search`,variant:`bare`,value:x,onChange:e=>S(e.target.value),placeholder:`搜索项目或会话`,className:`h-full w-full bg-transparent text-[11.5px] text-ink outline-none placeholder:text-ink-3`,"aria-label":`搜索项目或会话`})]})}),(0,g.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col overflow-y-auto px-1.5 pb-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center px-2 pb-1 text-[10px] font-semibold uppercase tracking-[.08em] text-ink-3`,children:[`项目`,(0,g.jsx)(`button`,{type:`button`,onClick:()=>E(!0),"aria-label":`添加项目`,className:`ml-auto flex h-5 w-5 items-center justify-center rounded-md text-ink-3 hover:bg-black/[.05] hover:text-ink dark:hover:bg-white/[.07]`,children:(0,g.jsx)(Vo,{size:12})})]}),(0,g.jsxs)(`div`,{ref:_e,"data-project-list":!0,children:[Ae.map(e=>{let t=s[e.id]??!0,n=e.kind==="default",r=e.runningTerminals??0,o=le.get(n?null:e.id)??0,l=n?-1:Pe.get(e.id)??-1,u=pe?.id===e.id&&pe.moved,p=n?null:e.id,m=!Ee&&a?.projectId===p,h=Wq-Number(m),_=!Ee&&e.sessions.length>h,v=C[e.id]??!1,y=e.sessions;if(_&&!v){let e=new Set([...y].sort((e,t)=>Oe(t)-Oe(e)).slice(0,h));y=y.filter(t=>e.has(t))}return(0,g.jsxs)(`div`,{"data-project-id":e.id,className:B(`relative mb-0.5`,u?`opacity-60`:null),children:[Ie&&pe&&!n&&pe.targetIndex===l?(0,g.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute -top-px left-1 right-1 z-10 h-0.5 rounded-full bg-accent`}):null,(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5`,"data-project-drop-index":n?void 0:l,children:[(0,g.jsxs)(`button`,{type:`button`,"aria-label":n?`默认工作区`:void 0,"aria-keyshortcuts":Ne&&!n?`ArrowUp ArrowDown`:void 0,"aria-pressed":n?Te:void 0,title:Ne&&!n?`拖拽调整项目顺序;聚焦后可按上下方向键`:void 0,onClick:()=>{ye.current?ye.current=!1:c(e.id)},onPointerDown:t=>Ve(t,e.id),onPointerMove:R,onPointerUp:He,onPointerCancel:Ue,onKeyDown:t=>We(t,e.id),onContextMenu:t=>xe(t,`project`,e.id,e.name),"aria-expanded":t,className:B(`flex h-[27px] min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 text-left text-[11.5px] text-ink-2 hover:bg-black/[.035] hover:text-ink dark:hover:bg-white/[.05]`,Ne&&!n?`cursor-grab`:null,pe?.id===e.id?`cursor-grabbing`:null),children:[t?(0,g.jsx)(Xa,{size:11,className:`text-ink-3`}):(0,g.jsx)(eo,{size:11,className:`text-ink-3`}),(0,g.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center rounded-[4px]`,style:{backgroundColor:`${e.accent}18`,color:e.accent},children:(0,g.jsx)(Go,{size:10})}),(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),o>0?(0,g.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5 text-accent`,title:`${o} 个运行中的后台服务`,"aria-hidden":`true`,"data-testid":`project-service-indicator`,children:[(0,g.jsx)(rc,{size:10,strokeWidth:2}),(0,g.jsx)(`span`,{className:`font-mono text-[9px]`,children:o})]}):null,r>0?(0,g.jsx)(`span`,{className:`flex shrink-0 items-center text-success`,title:`${r} 个运行中的终端`,"aria-hidden":`true`,"data-testid":`project-terminal-indicator`,children:(0,g.jsx)(dc,{size:10,strokeWidth:2})}):null,e.git?(0,g.jsx)(`span`,{className:`flex shrink-0 items-center text-ink-3`,title:e.branch?`Git · ${e.branch}`:`Git 仓库`,"aria-hidden":`true`,"data-testid":`project-git-indicator`,children:(0,g.jsx)(qo,{size:10,strokeWidth:2})}):null,n?(0,g.jsx)(`span`,{className:`text-[9px] text-ink-3`,children:`内置`}):null]}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`在 ${e.name} 中新建会话`,onClick:()=>Ce(e.id),className:`flex h-5 w-5 shrink-0 items-center justify-center rounded text-ink-3 hover:bg-black/[.06] hover:text-ink dark:hover:bg-white/[.08]`,children:(0,g.jsx)(Us,{size:11})})]}),t?(0,g.jsxs)(`div`,{className:`ml-[10px] border-l border-line/70 pl-1`,children:[m?(0,g.jsx)(Kq,{title:`新会话`,draft:!0,active:a?.id===i,running:!1,onClick:()=>f(p)}):null,y.length?y.map(e=>(0,g.jsx)(Kq,{title:e.title,active:e.id===i,running:De(e),onClick:()=>d(e.id,p),onContextMenu:t=>xe(t,`session`,e.id,e.title)},e.id)):m?null:(0,g.jsx)(`div`,{className:`px-2 py-1 text-[10.5px] text-ink-3`,children:`暂无会话`}),_?(0,g.jsx)(`button`,{type:`button`,"aria-expanded":v,onClick:()=>w(t=>({...t,[e.id]:!v})),className:`flex h-6 w-full items-center rounded-md pl-5 pr-2 text-left text-[10.5px] text-ink-3 hover:bg-black/[.035] hover:text-ink dark:hover:bg-white/[.05]`,children:v?`收起`:`展开更多`}):null]}):null]},e.id)}),Ie&&pe&&pe.targetIndex===Me.length?(0,g.jsx)(`div`,{className:`relative h-0`,"aria-hidden":`true`,children:(0,g.jsx)(`div`,{className:`absolute inset-x-1 -top-px h-0.5 rounded-full bg-accent`})}):null]}),Ae.length===0?(0,g.jsx)(`div`,{className:`mx-1 rounded-lg border border-dashed border-line px-2.5 py-3 text-[10.5px] text-ink-3`,children:Ee?`没有匹配的项目或会话`:`还没有登记项目。点击项目标题旁的 + 添加本机目录。`}):null,(0,g.jsxs)(`div`,{className:`mt-3 flex items-center px-2 pb-1 text-[10px] font-semibold uppercase tracking-[.08em] text-ink-3`,children:[`最近`,(0,g.jsx)(`span`,{className:`ml-auto font-normal normal-case tracking-normal text-ink-3/70`,children:je.length})]}),je.map(e=>{let t=n.projects.find(t=>t.id===e.projectId);return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id,e.projectId),onContextMenu:t=>xe(t,`session`,e.id,e.title),className:B(`group flex w-full flex-col gap-0.5 rounded-lg px-2 py-1.5 text-left transition-colors`,e.id===i?`bg-accent-soft/70 text-ink`:`text-ink-2 hover:bg-black/[.035] dark:hover:bg-white/[.05]`),children:[(0,g.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[De(e)?(0,g.jsx)(qq,{}):(0,g.jsx)(po,{size:11,className:`shrink-0 text-ink-3`}),(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11.5px] font-medium`,children:e.title})]}),(0,g.jsxs)(`span`,{className:`flex items-center gap-1.5 pl-[17px] text-[9.5px] text-ink-3`,children:[(0,g.jsx)(`span`,{className:`truncate`,children:t?.name??(e.workspaceKind==="default"?`默认工作区`:`独立会话`)}),(0,g.jsx)(`span`,{children:`·`}),(0,g.jsx)(`span`,{className:`shrink-0`,children:hG(e.updatedAt)})]})]},`recent_${e.id}`)})]}),(0,g.jsxs)(`div`,{className:`shrink-0 border-t border-line px-2 py-2`,children:[(0,g.jsx)(`fieldset`,{"aria-label":`服务与设置`,className:`m-0 min-w-0 border-0 p-0`,children:(0,g.jsxs)(`div`,{className:`grid grid-cols-5 gap-0.5`,children:[(0,g.jsx)(Jq,{icon:rc,title:`服务运维`,short:`服务`,onClick:()=>ne(!0)}),(0,g.jsx)(Jq,{icon:ho,title:`自动化任务`,short:`任务`,badge:se,onClick:()=>re(!0)}),(0,g.jsx)(Jq,{icon:Wa,title:`记忆与偏好`,short:`记忆`,onClick:()=>{ee(r!==null&&r!==`prj_default`?r:null),P(r!==null&&r!==`prj_default`?`project`:`global`),M(!0)}}),(0,g.jsx)(Jq,{icon:$o,title:`联网搜索`,short:`搜索`,onClick:()=>A(!0)}),(0,g.jsx)(Jq,{icon:ls,title:`模型与凭据`,short:`模型`,onClick:()=>O(!0)})]})}),(0,g.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-black/[.035] dark:hover:bg-white/[.05]`,children:[(0,g.jsxs)(`div`,{className:`relative flex h-6 w-6 items-center justify-center rounded-full bg-gradient-to-br from-[#ffd60a] to-[#ff9f0a] text-[10px] font-semibold text-[#1d1d1f]`,children:[`B`,(0,g.jsx)(`span`,{className:`absolute -bottom-0.5 -right-0.5 h-1.5 w-1.5 rounded-full bg-success ring-2 ring-surface`})]}),(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`truncate text-[11.5px] font-medium text-ink`,children:`bulv`}),(0,g.jsx)(`div`,{className:`truncate text-[9.5px] text-ink-3`,children:`本机操作者`})]}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`退出登录`,title:`退出登录`,"data-testid":`logout-button`,onClick:()=>void v(),className:`flex h-6 w-6 items-center justify-center rounded-md text-ink-3 hover:bg-black/[.06] hover:text-danger dark:hover:bg-white/[.08]`,children:(0,g.jsx)(hs,{size:13})})]})]}),ue?(0,g.jsxs)(`div`,{role:`menu`,"aria-label":`会话或项目操作`,onPointerDown:e=>e.stopPropagation(),className:`fixed z-[220] w-[184px] rounded-xl border border-line bg-surface p-1 shadow-[var(--shadow-pop)]`,style:{left:Math.min(ue.x,window.innerWidth-196),top:Math.min(ue.y,window.innerHeight-112)},children:[(0,g.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{fe({kind:ue.kind===`project`?`rename-project`:`rename-session`,id:ue.id,title:ue.title}),de(null)},className:`flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-[11.5px] text-ink-2 hover:bg-black/[.045] hover:text-ink dark:hover:bg-white/[.07]`,children:[(0,g.jsx)(Fs,{size:13,className:`text-ink-3`}),ue.kind===`project`?`重命名项目`:`重命名会话`]}),ue.kind===`project`?(0,g.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{ee(ue.id),P(`project`),M(!0),de(null)},className:`flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-[11.5px] text-ink-2 hover:bg-black/[.045] hover:text-ink dark:hover:bg-white/[.07]`,children:[(0,g.jsx)(Wa,{size:13,className:`text-ink-3`}),`项目记忆…`]}):null,(0,g.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{fe({kind:ue.kind===`project`?`remove-project`:`archive-session`,id:ue.id,title:ue.title}),de(null)},className:`flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-[11.5px] text-danger hover:bg-danger/10`,children:[ue.kind===`project`?(0,g.jsx)(xc,{size:13}):(0,g.jsx)(Aa,{size:13}),ue.kind===`project`?`移除项目`:`归档会话`]})]}):null,(0,g.jsx)(Yc,{message:he,onDismiss:()=>ge(null)}),(0,g.jsx)(QW,{session:L?.kind===`rename-session`?{id:L.id,title:L.title}:null,open:L?.kind===`rename-session`,onClose:()=>fe(null)}),(0,g.jsx)(_K,{project:L?.kind===`rename-project`?{id:L.id,name:L.title}:null,open:L?.kind===`rename-project`,onClose:()=>fe(null)}),(0,g.jsx)(Yq,{open:L?.kind===`archive-session`,title:`归档会话`,description:`“${L?.title??``}”将从列表中隐藏,工作目录与源码不会被删除。`,confirmLabel:`归档`,onCancel:()=>fe(null),onConfirm:async()=>{L?.kind===`archive-session`&&(await qj(L.id),await y.invalidateQueries({queryKey:[`workspace`]}),L.id===i&&d(``,null),fe(null))}}),(0,g.jsx)(Yq,{open:L?.kind===`remove-project`,title:`移除项目`,description:`仅移除“${L?.title??``}”的登记,不会删除本地源码;项目内会话会变成独立会话。`,confirmLabel:`移除项目`,onCancel:()=>fe(null),onConfirm:async()=>{L?.kind===`remove-project`&&(await xj(L.id),await y.invalidateQueries({queryKey:[`workspace`]}),L.id===r&&d(``,null),fe(null))}}),(0,g.jsx)(hK,{open:T,onOpenChange:E}),(0,g.jsx)(YG,{open:j,onOpenChange:M,projectId:N,initialScope:te}),(0,g.jsx)(DK,{open:F,onOpenChange:ne}),(0,g.jsx)(EG,{open:I,onOpenChange:re}),(0,g.jsx)(cK,{open:D,onOpenChange:O}),(0,g.jsx)(LK,{open:k,onOpenChange:A})]})}function Kq({title:e,active:t,running:n,draft:r=!1,onClick:i,onContextMenu:a}){return(0,g.jsxs)(`button`,{type:`button`,onClick:i,onContextMenu:a,"aria-current":t?`true`:void 0,"aria-busy":n,className:B(`flex h-[26px] w-full items-center gap-1.5 rounded-md px-2 text-left text-[11px] transition-colors`,t?`bg-accent-soft font-medium text-ink`:`text-ink-2 hover:bg-black/[.035] hover:text-ink dark:hover:bg-white/[.05]`),children:[(0,g.jsx)(`span`,{className:`flex w-3 shrink-0 items-center justify-center`,"aria-hidden":`true`,children:n?(0,g.jsx)(qq,{}):(0,g.jsx)(DW,{tone:t?`info`:`idle`})}),(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),r?(0,g.jsx)(`span`,{className:`shrink-0 rounded bg-black/[.045] px-1 py-[1px] text-[8.5px] text-ink-3 dark:bg-white/[.07]`,children:`草稿`}):null]})}function qq(){return(0,g.jsx)(ps,{size:11,className:`shrink-0 animate-spin text-accent motion-reduce:animate-none`,"aria-hidden":`true`})}function Jq({icon:e,title:t,short:n,badge:r,onClick:i}){let a=r!==void 0&&r>0?`,${r} 个失败任务`:``,o=r!==void 0&&r>0?r>99?`99+`:String(r):null;return(0,g.jsxs)(`button`,{type:`button`,onClick:i,disabled:i===void 0,"aria-label":`${t}${a}`,title:`${t}${a}`,className:`group flex h-9 min-w-0 flex-col items-center justify-center gap-0.5 rounded-lg text-ink-2 transition-colors hover:bg-black/[.035] hover:text-ink disabled:cursor-default disabled:opacity-60 dark:hover:bg-white/[.05]`,children:[(0,g.jsxs)(`span`,{className:`relative flex h-4 w-4 items-center justify-center`,children:[(0,g.jsx)(e,{size:14,strokeWidth:1.75,"aria-hidden":`true`,className:`text-ink-3 transition-colors group-hover:text-ink`}),o===null?null:(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -right-2.5 -top-1.5 min-w-[12px] rounded-full bg-danger px-0.5 text-center text-[8px] font-semibold leading-[12px] text-white`,children:o})]}),(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`w-full truncate text-center text-[9px] leading-none`,children:n})]})}function Yq({open:e,title:t,description:n,confirmLabel:r,onCancel:i,onConfirm:a}){let[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(null);(0,h.useEffect)(()=>{e&&(s(!1),l(null))},[e]);let u=async()=>{s(!0),l(null);try{await a()}catch(e){l(pj(e,`操作失败`)),s(!1)}};return(0,g.jsx)(Xc,{open:e,title:t,description:n,confirmLabel:r,danger:!0,pending:o,error:c,onDismissError:()=>l(null),onCancel:i,onConfirm:()=>void u()})}var Xq=(e,t,n)=>Math.min(n,Math.max(t,e));function Zq({side:e,label:t,value:n,min:r,max:i,defaultValue:a,onChange:o,collapsed:s=!1,className:c}){return(0,g.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":t,"aria-hidden":s||void 0,"aria-valuenow":Math.round(n),"aria-valuemin":r,"aria-valuemax":i,tabIndex:s?-1:0,onPointerDown:t=>{t.preventDefault();let a=t.clientX,s=n,c=document.body.style.cursor,l=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let u=t=>{let n=e===`left`?t.clientX-a:a-t.clientX;o(Xq(s+n,r,i))},d=()=>{document.body.style.cursor=c,document.body.style.userSelect=l,window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)},onDoubleClick:()=>o(a),onKeyDown:t=>{if(t.key!==`ArrowLeft`&&t.key!==`ArrowRight`)return;t.preventDefault();let a=t.shiftKey?64:16,s=t.key===`ArrowRight`?a:-a;o(Xq(n+(e===`left`?s:-s),r,i))},className:`relative z-30 shrink-0 cursor-col-resize bg-line transition-[width,opacity,background-color] hover:bg-accent/45 focus-visible:bg-accent/60 focus-visible:outline-none ${s?`pointer-events-none w-0 opacity-0 duration-160`:`w-px duration-200`} ${c??``}`,children:(0,g.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-y-0 -left-2 -right-2`})})}var Qq=90;function $q({icon:e,label:t,value:n,valueClass:r}){return(0,g.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(e,{size:13,strokeWidth:1.9,className:`shrink-0 text-ink-3`}),(0,g.jsx)(`span`,{className:`text-[9px] font-medium uppercase tracking-[.08em] text-ink-3`,children:t}),(0,g.jsx)(`span`,{className:`font-mono text-[10px] font-medium tabular-nums ${r}`,children:n})]})}function eJ({metrics:e}){let t=e===null?null:Math.min(100,Math.max(0,e.cpuPercent)),n=t===null?`—`:`${Math.round(t)}%`,r=t!==null&&t>Qq,i=gG(e?.memoryUsedBytes??0,e?.memoryTotalBytes??0),a=_G(e?.memoryUsedBytes??0,e?.memoryTotalBytes??0);return(0,g.jsxs)(`div`,{className:`mr-1 hidden items-center gap-3 xl:flex`,children:[(0,g.jsx)(`span`,{className:`sr-only`,children:`服务端资源占用`}),(0,g.jsx)($q,{icon:xo,label:`CPU`,value:n,valueClass:r?`text-danger`:`text-ink`}),(0,g.jsx)($q,{icon:ys,label:`RAM`,valueClass:`text-ink`,value:i===null?`—`:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:i!==null&&a>Qq?`text-danger`:void 0,children:i.used}),` / `,i.total]})})]})}async function tJ(){return Y(`/api/system/metrics`)}var nJ=4e3;function rJ(e){return Zg({queryKey:[`host-metrics`],queryFn:tJ,enabled:!0,refetchInterval:nJ,staleTime:0,retry:!1}).data??null}function iJ(e){let[t,n]=(0,h.useState)(()=>typeof window>`u`?!1:window.matchMedia(e).matches);return(0,h.useEffect)(()=>{let t=window.matchMedia(e);n(t.matches);let r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function aJ({version:e}){let{data:t}=sM(),{theme:n,resolved:r,setTheme:i}=S(),{projectId:a,sessionId:o,toggleSidebar:s,setMobileSidebar:c}=vW(),l=iJ(`(max-width: 767px)`),u=Uq(e=>e.items).filter(e=>e.kind===`approval`&&e.status===`pending`),d=Uq(e=>e.isStreaming),f=rJ(t.host),p=t.projects.find(e=>e.id===a)??null,m=n===`system`?Ts:r===`dark`?Ds:_c,h=typeof e==`string`&&e!==`0.0.0`&&/^\d+\.\d+\.\d+(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(e)?`v${e}`:`版本未知`;return(0,g.jsxs)(`header`,{className:`relative z-50 flex h-12 shrink-0 items-center gap-2 border-b border-line bg-surface/70 px-2.5 backdrop-blur-xl`,children:[(0,g.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,g.jsx)(`div`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-[7px] bg-gradient-to-br from-[#3d9bff] to-[#0066d6] text-[11px] font-bold text-white shadow-sm`,children:`L`}),(0,g.jsx)(`span`,{className:`shrink-0 text-[12.5px] font-semibold tracking-[-.01em]`,children:`Larness`}),(0,g.jsx)(`span`,{className:`shrink-0 rounded-full border border-line bg-surface-2 px-1.5 py-[1px] font-mono text-[9px] text-ink-3`,children:h})]}),(0,g.jsx)(vm,{label:l?`打开导航`:`切换侧栏`,onClick:()=>l?c(!0):s(),children:(0,g.jsx)(ks,{size:15})}),(0,g.jsx)(`span`,{className:`mx-0.5 h-3.5 w-px shrink-0 bg-line`}),(0,g.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,g.jsx)(`span`,{className:`truncate text-[12.5px] font-semibold tracking-[-.01em]`,children:p?.name??_W(o,t.sessions)}),(0,g.jsx)(`span`,{className:`text-ink-3`,children:`/`}),(0,g.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(DW,{tone:d?`running`:`idle`,pulse:d}),(0,g.jsx)(`span`,{className:`text-[11px] text-ink-2`,children:d?`Agent 运行中`:`空闲`})]}),p?.branch?(0,g.jsxs)(`span`,{className:`ml-1 hidden items-center gap-1 rounded-full border border-line bg-surface-2 px-2 py-[2px] font-mono text-[10px] text-ink-2 md:flex`,children:[(0,g.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent/70`}),p.branch]}):null]}),(0,g.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,g.jsx)(eJ,{metrics:f}),(0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsx)(vm,{label:`外观与主题`,children:(0,g.jsx)(m,{size:15})})}),(0,g.jsxs)(sm,{align:`end`,children:[(0,g.jsx)(cm,{children:`外观`}),(0,g.jsxs)(om,{value:n,onValueChange:e=>i(e),children:[(0,g.jsxs)(um,{value:`light`,children:[(0,g.jsx)(_c,{size:13}),` 浅色`]}),(0,g.jsxs)(um,{value:`dark`,children:[(0,g.jsx)(Ds,{size:13}),` 深色`]}),(0,g.jsxs)(um,{value:`system`,children:[(0,g.jsx)(Ts,{size:13}),` 跟随系统`]})]})]})]}),(0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsxs)(vm,{label:`通知`,className:`relative`,children:[(0,g.jsx)(Ha,{size:15}),u.length>0?(0,g.jsx)(`span`,{className:`absolute right-1.5 top-1.5 h-1.5 w-1.5 rounded-full bg-danger ring-2 ring-surface`}):null]})}),(0,g.jsxs)(sm,{align:`end`,className:`w-[280px]`,children:[(0,g.jsx)(cm,{children:`通知`}),u.length>0?u.map(e=>(0,g.jsxs)(lm,{className:`items-start gap-2 py-2`,children:[(0,g.jsx)(DW,{tone:`waiting`,className:`mt-1`}),(0,g.jsxs)(`span`,{children:[(0,g.jsx)(`span`,{className:`block text-[12px] font-medium text-ink`,children:e.serviceName?`${e.serviceName} 部署待批准`:e.toolName?`${e.toolName} 待批准`:`操作待批准`}),(0,g.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-ink-3`,children:e.summary??`等待你的批准。`})]})]},e.id)):(0,g.jsx)(lm,{disabled:!0,children:`暂无新通知`})]})]})]})]})}var oJ=s(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),sJ=s(((e,t)=>{var n=oJ();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),cJ=u(s(((e,t)=>{t.exports=sJ()()}))(),1);function lJ(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function uJ(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function dJ(e){return typeof e==`number`&&!isNaN(e)}function fJ(e){return parseInt(e,10)}function pJ(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}var mJ=[`Moz`,`Webkit`,`O`,`ms`];function hJ(e=`transform`){if(typeof window>`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;n<mJ.length;n++)if(gJ(e,mJ[n])in t)return mJ[n];return``}function gJ(e,t){return t?`${t}${_J(e)}`:e}function _J(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}var vJ=hJ(),yJ=``;function bJ(e,t){yJ||=lJ([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(t){return uJ(e[t])})??``;let n=e[yJ];return uJ(n)?!!n.call(e,t):!1}function xJ(e,t,n){let r=e;do{if(bJ(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function SJ(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.addEventListener?e.addEventListener(t,a,i):e.attachEvent?e.attachEvent(`on`+t,a):e[`on`+t]=a}function CJ(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.removeEventListener?e.removeEventListener(t,a,i):e.detachEvent?e.detachEvent(`on`+t,a):e[`on`+t]=null}function wJ(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=fJ(n.borderTopWidth),t+=fJ(n.borderBottomWidth),t}function TJ(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=fJ(n.borderLeftWidth),t+=fJ(n.borderRightWidth),t}function EJ(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=fJ(n.paddingTop),t-=fJ(n.paddingBottom),t}function DJ(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=fJ(n.paddingLeft),t-=fJ(n.paddingRight),t}function OJ(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function kJ(e,t){let n=jJ(e,t,`px`);return{[gJ(`transform`,vJ)]:n}}function AJ(e,t){return jJ(e,t,``)}function jJ({x:e,y:t},n,r){let i=`translate(${e}${r},${t}${r})`;return n&&(i=`translate(${`${typeof n.x==`string`?n.x:n.x+r}`}, ${`${typeof n.y==`string`?n.y:n.y+r}`})`+i),i}function MJ(e,t){return e.targetTouches&&lJ(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&lJ(e.changedTouches,e=>t===e.identifier)}function NJ(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function PJ(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function FJ(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??PJ();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
|
|
109
109
|
`,n.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
|
|
110
110
|
`,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&RJ(e.body,`react-draggable-transparent-selection`)}function IJ(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{LJ(e)}):LJ(e)}function LJ(e){if(e)try{e.body&&zJ(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function RJ(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function zJ(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function BJ(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:qJ(r);let i=JJ(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+fJ(s.paddingLeft)+fJ(o.marginLeft),top:-i.offsetTop+fJ(s.paddingTop)+fJ(o.marginTop),right:DJ(a)-TJ(i)-i.offsetLeft+fJ(s.paddingRight)-fJ(o.marginRight),bottom:EJ(a)-wJ(i)-i.offsetTop+fJ(s.paddingBottom)-fJ(o.marginBottom)}}return dJ(r.right)&&(t=Math.min(t,r.right)),dJ(r.bottom)&&(n=Math.min(n,r.bottom)),dJ(r.left)&&(t=Math.max(t,r.left)),dJ(r.top)&&(n=Math.max(n,r.top)),[t,n]}function VJ(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function HJ(e){return e.props.axis===`both`||e.props.axis===`x`}function UJ(e){return e.props.axis===`both`||e.props.axis===`y`}function WJ(e,t,n){let r=typeof t==`number`?MJ(e,t):null;if(typeof t==`number`&&!r)return null;let i=JJ(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return OJ(r||e,a,n.props.scale)}function GJ(e,t,n){let r=!dJ(e.lastX),i=JJ(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function KJ(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function qJ(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function JJ(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}var YJ=typeof process<`u`&&{}.DRAGGABLE_DEBUG?console.log.bind(console):function(){},XJ={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},ZJ=XJ.mouse,QJ=class extends h.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!xJ(e.target,this.props.handle,t)||this.props.cancel&&xJ(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=NJ(e);this.touchIdentifier=r;let i=WJ(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=GJ(this,a,o);YJ(`DraggableCore: handleDragStart: %j`,s),YJ(`calling`,this.props.onStart),this.props.onStart(e,s)!==!1&&this.mounted!==!1&&(this.props.enableUserSelectHack&&FJ(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,SJ(n,ZJ.move,this.handleDrag),SJ(n,ZJ.stop,this.handleDragStop))},this.handleDrag=e=>{let t=WJ(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=VJ(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=GJ(this,n,r);if(YJ(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1)try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}else this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=WJ(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=VJ(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=GJ(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&IJ(a.ownerDocument),YJ(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(YJ(`DraggableCore: Removing handlers`),CJ(a.ownerDocument,ZJ.move,this.handleDrag),CJ(a.ownerDocument,ZJ.stop,this.handleDragStop))},this.onMouseDown=e=>(ZJ=XJ.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(ZJ=XJ.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(ZJ=XJ.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(ZJ=XJ.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&SJ(e,XJ.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;CJ(t,XJ.mouse.move,this.handleDrag),CJ(t,XJ.touch.move,this.handleDrag),CJ(t,XJ.mouse.stop,this.handleDragStop),CJ(t,XJ.touch.stop,this.handleDragStop),CJ(e,XJ.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&IJ(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=en.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(YJ(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return h.cloneElement(h.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};QJ.displayName=`DraggableCore`,QJ.propTypes={allowAnyClick:cJ.default.bool,allowMobileScroll:cJ.default.bool,children:cJ.default.node.isRequired,disabled:cJ.default.bool,enableUserSelectHack:cJ.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:cJ.default.arrayOf(cJ.default.number),handle:cJ.default.string,cancel:cJ.default.string,nodeRef:cJ.default.object,nonce:cJ.default.string,onStart:cJ.default.func,onDrag:cJ.default.func,onStop:cJ.default.func,onMouseDown:cJ.default.func,scale:cJ.default.number,className:pJ,style:pJ,transform:pJ},QJ.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var $J=class extends h.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(YJ(`Draggable: onDragStart: %j`,t),this.props.onStart(e,KJ(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;YJ(`Draggable: onDrag: %j`,t);let n=KJ(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=BJ(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,KJ(this,t))===!1)return!1;YJ(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(YJ(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=en.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,m=s||r,g={x:HJ(this)&&p?this.state.x:m.x,y:UJ(this)&&p?this.state.y:m.y};this.state.isElementSVG?f=AJ(g,c):d=kJ(g,c);let _=h.Children.only(n),v=w(_.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return h.createElement(QJ,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},h.cloneElement(_,{className:v,style:{..._.props.style,...d},transform:f}))}};$J.displayName=`Draggable`,$J.propTypes={...QJ.propTypes,axis:cJ.default.oneOf([`both`,`x`,`y`,`none`]),bounds:cJ.default.oneOfType([cJ.default.shape({left:cJ.default.number,right:cJ.default.number,top:cJ.default.number,bottom:cJ.default.number}),cJ.default.string,cJ.default.oneOf([!1])]),defaultClassName:cJ.default.string,defaultClassNameDragging:cJ.default.string,defaultClassNameDragged:cJ.default.string,defaultPosition:cJ.default.shape({x:cJ.default.number,y:cJ.default.number}),positionOffset:cJ.default.shape({x:cJ.default.oneOfType([cJ.default.number,cJ.default.string]),y:cJ.default.oneOfType([cJ.default.number,cJ.default.string])}),position:cJ.default.shape({x:cJ.default.number,y:cJ.default.number}),className:pJ,style:pJ,transform:pJ},$J.defaultProps={...QJ.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1};var eY=$J,tY=function(){return tY=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},tY.apply(this,arguments)},nY={width:`100%`,height:`10px`,top:`0px`,left:`0px`,cursor:`row-resize`},rY={width:`10px`,height:`100%`,top:`0px`,left:`0px`,cursor:`col-resize`},iY={width:`20px`,height:`20px`,position:`absolute`,zIndex:1},aY={top:tY(tY({},nY),{top:`-5px`}),right:tY(tY({},rY),{left:void 0,right:`-5px`}),bottom:tY(tY({},nY),{top:void 0,bottom:`-5px`}),left:tY(tY({},rY),{left:`-5px`}),topRight:tY(tY({},iY),{right:`-10px`,top:`-10px`,cursor:`ne-resize`}),bottomRight:tY(tY({},iY),{right:`-10px`,bottom:`-10px`,cursor:`se-resize`}),bottomLeft:tY(tY({},iY),{left:`-10px`,bottom:`-10px`,cursor:`sw-resize`}),topLeft:tY(tY({},iY),{left:`-10px`,top:`-10px`,cursor:`nw-resize`})},oY=(0,h.memo)(function(e){var t=e.onResizeStart,n=e.direction,r=e.children,i=e.replaceStyles,a=e.className,o=(0,h.useCallback)(function(e){t(e,n)},[t,n]),s=(0,h.useCallback)(function(e){t(e,n)},[t,n]),c=(0,h.useMemo)(function(){return tY(tY({position:`absolute`,userSelect:`none`},aY[n]),i??{})},[i,n]);return(0,g.jsx)(`div`,{className:a||void 0,style:c,onMouseDown:o,onTouchStart:s,children:r})}),sY=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),cY=function(){return cY=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},cY.apply(this,arguments)},lY={width:`auto`,height:`auto`},uY=function(e,t,n){return Math.max(Math.min(e,n),t)},dY=function(e,t,n){var r=Math.round(e/t);return r*t+n*(r-1)},fY=function(e,t){return new RegExp(e,`i`).test(t)},pY=function(e){return!!(e.touches&&e.touches.length)},mY=function(e){return!(!e.clientX&&e.clientX!==0||!e.clientY&&e.clientY!==0)},hY=function(e,t,n){n===void 0&&(n=0);var r=t.reduce(function(n,r,i){return Math.abs(r-e)<Math.abs(t[n]-e)?i:n},0),i=Math.abs(t[r]-e);return n===0||i<n?t[r]:e},gY=function(e){return e=e.toString(),e===`auto`||e.endsWith(`px`)||e.endsWith(`%`)||e.endsWith(`vh`)||e.endsWith(`vw`)||e.endsWith(`vmax`)||e.endsWith(`vmin`)?e:`${e}px`},_Y=function(e,t,n,r){if(e&&typeof e==`string`){if(e.endsWith(`px`))return Number(e.replace(`px`,``));if(e.endsWith(`%`)){var i=Number(e.replace(`%`,``))/100;return t*i}if(e.endsWith(`vw`)){var i=Number(e.replace(`vw`,``))/100;return n*i}if(e.endsWith(`vh`)){var i=Number(e.replace(`vh`,``))/100;return r*i}}return e},vY=function(e,t,n,r,i,a,o){return r=_Y(r,e.width,t,n),i=_Y(i,e.height,t,n),a=_Y(a,e.width,t,n),o=_Y(o,e.height,t,n),{maxWidth:r===void 0?void 0:Number(r),maxHeight:i===void 0?void 0:Number(i),minWidth:a===void 0?void 0:Number(a),minHeight:o===void 0?void 0:Number(o)}},yY=function(e){return Array.isArray(e)?e:[e,e]},bY=`as.ref.style.className.grid.gridGap.snap.bounds.boundsByDirection.size.defaultSize.minWidth.minHeight.maxWidth.maxHeight.lockAspectRatio.lockAspectRatioExtraWidth.lockAspectRatioExtraHeight.enable.handleStyles.handleClasses.handleWrapperStyle.handleWrapperClass.children.onResizeStart.onResize.onResizeStop.handleComponent.scale.resizeRatio.snapGap`.split(`.`),xY=`__resizable_base__`,SY=function(e){sY(t,e);function t(t){var n=e.call(this,t)||this;return n.ratio=1,n.resizable=null,n.parentLeft=0,n.parentTop=0,n.resizableLeft=0,n.resizableRight=0,n.resizableTop=0,n.resizableBottom=0,n.targetLeft=0,n.targetTop=0,n.delta={width:0,height:0},n.appendBase=function(){if(!n.resizable||!n.window)return null;var e=n.parentNode;if(!e)return null;var t=n.window.document.createElement(`div`);return t.style.width=`100%`,t.style.height=`100%`,t.style.position=`absolute`,t.style.transform=`scale(0, 0)`,t.style.left=`0`,t.style.flex=`0 0 100%`,t.classList?t.classList.add(xY):t.className+=xY,e.appendChild(t),t},n.removeBase=function(e){var t=n.parentNode;t&&t.removeChild(e)},n.state={isResizing:!1,width:n.propsSize?.width??`auto`,height:n.propsSize?.height??`auto`,direction:`right`,original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:`100%`,width:`100%`,backgroundColor:`rgba(0,0,0,0)`,cursor:`auto`,opacity:0,position:`fixed`,zIndex:9999,top:`0`,left:`0`,bottom:`0`,right:`0`},flexBasis:void 0},n.onResizeStart=n.onResizeStart.bind(n),n.onMouseMove=n.onMouseMove.bind(n),n.onMouseUp=n.onMouseUp.bind(n),n}return Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return!this.resizable||!this.resizable.ownerDocument?null:this.resizable.ownerDocument.defaultView},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||lY},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var e=0,t=0;if(this.resizable&&this.window){var n=this.resizable.offsetWidth,r=this.resizable.offsetHeight,i=this.resizable.style.position;i!==`relative`&&(this.resizable.style.position=`relative`),e=this.resizable.style.width===`auto`?n:this.resizable.offsetWidth,t=this.resizable.style.height===`auto`?r:this.resizable.offsetHeight,this.resizable.style.position=i}return{width:e,height:t}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeStyle",{get:function(){var e=this,t=this.props.size,n=function(t){if(e.state[t]===void 0||e.state[t]===`auto`)return`auto`;if(e.propsSize&&e.propsSize[t]&&e.propsSize[t]?.toString().endsWith(`%`)){if(e.state[t].toString().endsWith(`%`))return e.state[t].toString();var n=e.getParentSize();return`${Number(e.state[t].toString().replace(`px`,``))/n[t]*100}%`}return gY(e.state[t])};return{width:t&&t.width!==void 0&&!this.state.isResizing?gY(t.width):n(`width`),height:t&&t.height!==void 0&&!this.state.isResizing?gY(t.height):n(`height`)}},enumerable:!1,configurable:!0}),t.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var e=this.appendBase();if(!e)return{width:0,height:0};var t=!1,n=this.parentNode.style.flexWrap;n!==`wrap`&&(t=!0,this.parentNode.style.flexWrap=`wrap`),e.style.position=`relative`,e.style.minWidth=`100%`,e.style.minHeight=`100%`;var r={width:e.offsetWidth,height:e.offsetHeight};return t&&(this.parentNode.style.flexWrap=n),this.removeBase(e),r},t.prototype.bindEvents=function(){this.window&&(this.window.addEventListener(`mouseup`,this.onMouseUp),this.window.addEventListener(`mousemove`,this.onMouseMove),this.window.addEventListener(`mouseleave`,this.onMouseUp),this.window.addEventListener(`touchmove`,this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener(`touchend`,this.onMouseUp))},t.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener(`mouseup`,this.onMouseUp),this.window.removeEventListener(`mousemove`,this.onMouseMove),this.window.removeEventListener(`mouseleave`,this.onMouseUp),this.window.removeEventListener(`touchmove`,this.onMouseMove,!0),this.window.removeEventListener(`touchend`,this.onMouseUp))},t.prototype.componentDidMount=function(){if(this.resizable&&this.window){var e=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:e.flexBasis===`auto`?void 0:e.flexBasis})}},t.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},t.prototype.createSizeForCssProperty=function(e,t){var n=this.propsSize&&this.propsSize[t];return this.state[t]===`auto`&&this.state.original[t]===e&&(n===void 0||n===`auto`)?`auto`:e},t.prototype.calculateNewMaxFromBoundary=function(e,t){var n=this.props.boundsByDirection,r=this.state.direction,i=n&&fY(`left`,r),a=n&&fY(`top`,r),o,s;if(this.props.bounds===`parent`){var c=this.parentNode;c&&(o=i?this.resizableRight-this.parentLeft:c.offsetWidth+(this.parentLeft-this.resizableLeft),s=a?this.resizableBottom-this.parentTop:c.offsetHeight+(this.parentTop-this.resizableTop))}else this.props.bounds===`window`?this.window&&(o=i?this.resizableRight:this.window.innerWidth-this.resizableLeft,s=a?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(o=i?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),s=a?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return o&&Number.isFinite(o)&&(e=e&&e<o?e:o),s&&Number.isFinite(s)&&(t=t&&t<s?t:s),{maxWidth:e,maxHeight:t}},t.prototype.calculateNewSizeFromDirection=function(e,t){var n=this.props.scale||1,r=yY(this.props.resizeRatio||1),i=r[0],a=r[1],o=this.state,s=o.direction,c=o.original,l=this.props,u=l.lockAspectRatio,d=l.lockAspectRatioExtraHeight,f=l.lockAspectRatioExtraWidth,p=c.width,m=c.height,h=d||0,g=f||0;return fY(`right`,s)&&(p=c.width+(e-c.x)*i/n,u&&(m=(p-g)/this.ratio+h)),fY(`left`,s)&&(p=c.width-(e-c.x)*i/n,u&&(m=(p-g)/this.ratio+h)),fY(`bottom`,s)&&(m=c.height+(t-c.y)*a/n,u&&(p=(m-h)*this.ratio+g)),fY(`top`,s)&&(m=c.height-(t-c.y)*a/n,u&&(p=(m-h)*this.ratio+g)),{newWidth:p,newHeight:m}},t.prototype.calculateNewSizeFromAspectRatio=function(e,t,n,r){var i=this.props,a=i.lockAspectRatio,o=i.lockAspectRatioExtraHeight,s=i.lockAspectRatioExtraWidth,c=r.width===void 0?10:r.width,l=n.width===void 0||n.width<0?e:n.width,u=r.height===void 0?10:r.height,d=n.height===void 0||n.height<0?t:n.height,f=o||0,p=s||0;if(a){var m=(u-f)*this.ratio+p,h=(d-f)*this.ratio+p,g=(c-p)/this.ratio+f,_=(l-p)/this.ratio+f,v=Math.max(c,m),y=Math.min(l,h),b=Math.max(u,g),x=Math.min(d,_);e=uY(e,v,y),t=uY(t,b,x)}else e=uY(e,c,l),t=uY(t,u,d);return{newWidth:e,newHeight:t}},t.prototype.setBoundingClientRect=function(){var e=1/(this.props.scale||1);if(this.props.bounds===`parent`){var t=this.parentNode;if(t){var n=t.getBoundingClientRect();this.parentLeft=n.left*e,this.parentTop=n.top*e}}if(this.props.bounds&&typeof this.props.bounds!=`string`){var r=this.props.bounds.getBoundingClientRect();this.targetLeft=r.left*e,this.targetTop=r.top*e}if(this.resizable){var i=this.resizable.getBoundingClientRect(),a=i.left,o=i.top,s=i.right,c=i.bottom;this.resizableLeft=a*e,this.resizableRight=s*e,this.resizableTop=o*e,this.resizableBottom=c*e}},t.prototype.onResizeStart=function(e,t){if(this.resizable&&this.window){var n=0,r=0;if(e.nativeEvent&&mY(e.nativeEvent)?(n=e.nativeEvent.clientX,r=e.nativeEvent.clientY):e.nativeEvent&&pY(e.nativeEvent)&&(n=e.nativeEvent.touches[0].clientX,r=e.nativeEvent.touches[0].clientY),!(this.props.onResizeStart&&this.resizable&&this.props.onResizeStart(e,t,this.resizable)===!1)){this.props.size&&(this.props.size.height!==void 0&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),this.props.size.width!==void 0&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio=typeof this.props.lockAspectRatio==`number`?this.props.lockAspectRatio:this.size.width/this.size.height;var i,a=this.window.getComputedStyle(this.resizable);if(a.flexBasis!==`auto`){var o=this.parentNode;if(o){var s=this.window.getComputedStyle(o).flexDirection;this.flexDir=s.startsWith(`row`)?`row`:`column`,i=a.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var c={original:{x:n,y:r,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:cY(cY({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(e.target).cursor||`auto`}),direction:t,flexBasis:i};this.setState(c)}}},t.prototype.onMouseMove=function(e){var t=this;if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&pY(e))try{e.preventDefault(),e.stopPropagation()}catch{}var n=this.props,r=n.maxWidth,i=n.maxHeight,a=n.minWidth,o=n.minHeight,s=pY(e)?e.touches[0].clientX:e.clientX,c=pY(e)?e.touches[0].clientY:e.clientY,l=this.state,u=l.direction,d=l.original,f=l.width,p=l.height,m=this.getParentSize(),h=vY(m,this.window.innerWidth,this.window.innerHeight,r,i,a,o);r=h.maxWidth,i=h.maxHeight,a=h.minWidth,o=h.minHeight;var g=this.calculateNewSizeFromDirection(s,c),_=g.newHeight,v=g.newWidth,y=this.calculateNewMaxFromBoundary(r,i);this.props.snap&&this.props.snap.x&&(v=hY(v,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(_=hY(_,this.props.snap.y,this.props.snapGap));var b=this.calculateNewSizeFromAspectRatio(v,_,{width:y.maxWidth,height:y.maxHeight},{width:a,height:o});if(v=b.newWidth,_=b.newHeight,this.props.grid){var x=dY(v,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),S=dY(_,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),C=this.props.snapGap||0,w=C===0||Math.abs(x-v)<=C?x:v,T=C===0||Math.abs(S-_)<=C?S:_;v=w,_=T}var E={width:v-d.width,height:_-d.height};if(this.delta=E,f&&typeof f==`string`){if(f.endsWith(`%`)){var D=v/m.width*100;v=`${D}%`}else if(f.endsWith(`vw`)){var O=v/this.window.innerWidth*100;v=`${O}vw`}else if(f.endsWith(`vh`)){var k=v/this.window.innerHeight*100;v=`${k}vh`}}if(p&&typeof p==`string`){if(p.endsWith(`%`)){var D=_/m.height*100;_=`${D}%`}else if(p.endsWith(`vw`)){var O=_/this.window.innerWidth*100;_=`${O}vw`}else if(p.endsWith(`vh`)){var k=_/this.window.innerHeight*100;_=`${k}vh`}}var A={width:this.createSizeForCssProperty(v,`width`),height:this.createSizeForCssProperty(_,`height`)};this.flexDir===`row`?A.flexBasis=A.width:this.flexDir===`column`&&(A.flexBasis=A.height);var j=this.state.width!==A.width,M=this.state.height!==A.height,N=this.state.flexBasis!==A.flexBasis,ee=j||M||N;ee&&(0,en.flushSync)(function(){t.setState(A)}),this.props.onResize&&ee&&this.props.onResize(e,u,this.resizable,E)}},t.prototype.onMouseUp=function(e){var t=this.state,n=t.isResizing,r=t.direction;t.original,n&&this.resizable&&(this.props.onResizeStop&&this.props.onResizeStop(e,r,this.resizable,this.delta),this.props.size&&this.setState({width:this.props.size.width??`auto`,height:this.props.size.height??`auto`}),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:cY(cY({},this.state.backgroundStyle),{cursor:`auto`})}))},t.prototype.updateSize=function(e){this.setState({width:e.width??`auto`,height:e.height??`auto`})},t.prototype.renderResizer=function(){var e=this,t=this.props,n=t.enable,r=t.handleStyles,i=t.handleClasses,a=t.handleWrapperStyle,o=t.handleWrapperClass,s=t.handleComponent;if(!n)return null;var c=Object.keys(n).map(function(t){return n[t]===!1?null:(0,g.jsx)(oY,{direction:t,onResizeStart:e.onResizeStart,replaceStyles:r&&r[t],className:i&&i[t],children:s&&s[t]?s[t]:null},t)});return(0,g.jsx)(`div`,{className:o,style:a,children:c})},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce(function(t,n){return bY.indexOf(n)===-1&&(t[n]=e.props[n]),t},{}),n=cY(cY(cY({position:`relative`,userSelect:this.state.isResizing?`none`:`auto`},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:`border-box`,flexShrink:0});this.state.flexBasis&&(n.flexBasis=this.state.flexBasis);var r=this.props.as||`div`;return(0,g.jsxs)(r,cY({style:n,className:this.props.className},t,{ref:function(t){t&&(e.resizable=t)},children:[this.state.isResizing&&(0,g.jsx)(`div`,{style:this.state.backgroundStyle}),this.props.children,this.renderResizer()]}))},t.defaultProps={as:`div`,onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],gridGap:[0,0],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},t}(h.PureComponent),CY=function(e,t){return CY=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},CY(e,t)};function wY(e,t){CY(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var TY=function(){return TY=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},TY.apply(this,arguments)};function EY(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}var DY={width:`auto`,height:`auto`,display:`inline-block`,position:`absolute`,top:0,left:0},OY=function(e){return{bottom:e,bottomLeft:e,bottomRight:e,left:e,right:e,top:e,topLeft:e,topRight:e}},kY=function(e){wY(t,e);function t(t){var n=e.call(this,t)||this;return n.resizingPosition={x:0,y:0},n.offsetFromParent={left:0,top:0},n.resizableElement={current:null},n.originalPosition={x:0,y:0},n.state={resizing:!1,bounds:{top:0,right:0,bottom:0,left:0},maxWidth:t.maxWidth,maxHeight:t.maxHeight},n.onResizeStart=n.onResizeStart.bind(n),n.onResize=n.onResize.bind(n),n.onResizeStop=n.onResizeStop.bind(n),n.onDragStart=n.onDragStart.bind(n),n.onDrag=n.onDrag.bind(n),n.onDragStop=n.onDragStop.bind(n),n.getMaxSizesFromProps=n.getMaxSizesFromProps.bind(n),n}return t.prototype.componentDidMount=function(){this.updateOffsetFromParent();var e=this.offsetFromParent,t=e.left,n=e.top,r=this.getDraggablePosition(),i=r.x,a=r.y;this.draggable.setState({x:i-t,y:a-n}),this.forceUpdate()},t.prototype.getDraggablePosition=function(){var e=this.draggable.state;return{x:e.x,y:e.y}},t.prototype.getParent=function(){return this.resizable&&this.resizable.parentNode},t.prototype.getParentSize=function(){return this.resizable.getParentSize()},t.prototype.getMaxSizesFromProps=function(){return{maxWidth:this.props.maxWidth===void 0?2**53-1:this.props.maxWidth,maxHeight:this.props.maxHeight===void 0?2**53-1:this.props.maxHeight}},t.prototype.getSelfElement=function(){return this.resizable&&this.resizable.resizable},t.prototype.getOffsetHeight=function(e){var t=this.props.scale;switch(this.props.bounds){case`window`:return window.innerHeight/t;case`body`:return document.body.offsetHeight/t;default:return e.offsetHeight}},t.prototype.getOffsetWidth=function(e){var t=this.props.scale;switch(this.props.bounds){case`window`:return window.innerWidth/t;case`body`:return document.body.offsetWidth/t;default:return e.offsetWidth}},t.prototype.onDragStart=function(e,t){if(this.props.onDragStart&&this.props.onDragStart(e,t)===!1)return!1;var n=this.getDraggablePosition();if(this.originalPosition=n,this.props.bounds){var r=this.getParent(),i=this.props.scale,a;if(this.props.bounds===`parent`)a=r;else if(this.props.bounds===`body`){var o=r.getBoundingClientRect(),s=o.left,c=o.top,l=document.body.getBoundingClientRect(),u=-(s-r.offsetLeft*i-l.left)/i,d=-(c-r.offsetTop*i-l.top)/i,f=(document.body.offsetWidth-this.resizable.size.width*i)/i+u,p=(document.body.offsetHeight-this.resizable.size.height*i)/i+d;return this.setState({bounds:{top:d,right:f,bottom:p,left:u}})}else if(this.props.bounds===`window`){if(!this.resizable)return;var m=r.getBoundingClientRect(),h=m.left,g=m.top,_=-(h-r.offsetLeft*i)/i,v=-(g-r.offsetTop*i)/i,f=(window.innerWidth-this.resizable.size.width*i)/i+_,p=(window.innerHeight-this.resizable.size.height*i)/i+v;return this.setState({bounds:{top:v,right:f,bottom:p,left:_}})}else typeof this.props.bounds==`string`?a=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(a=this.props.bounds);if(a instanceof HTMLElement&&r instanceof HTMLElement){var y=a.getBoundingClientRect(),b=y.left,x=y.top,S=r.getBoundingClientRect(),C=S.left,w=S.top,T=(b-C)/i,E=x-w;if(this.resizable){this.updateOffsetFromParent();var D=this.offsetFromParent;this.setState({bounds:{top:E-D.top,right:T+(a.offsetWidth-this.resizable.size.width)-D.left/i,bottom:E+(a.offsetHeight-this.resizable.size.height)-D.top,left:T-D.left/i}})}}}},t.prototype.onDrag=function(e,t){if(this.props.onDrag){var n=this.offsetFromParent,r=n.left,i=n.top;if(!this.props.dragAxis||this.props.dragAxis===`both`)return this.props.onDrag(e,TY(TY({},t),{x:t.x+r,y:t.y+i}));if(this.props.dragAxis===`x`)return this.props.onDrag(e,TY(TY({},t),{x:t.x+r,y:this.originalPosition.y+i,deltaY:0}));if(this.props.dragAxis===`y`)return this.props.onDrag(e,TY(TY({},t),{x:this.originalPosition.x+r,y:t.y+i,deltaX:0}))}},t.prototype.onDragStop=function(e,t){if(this.props.onDragStop){var n=this.offsetFromParent,r=n.left,i=n.top;if(!this.props.dragAxis||this.props.dragAxis===`both`)return this.props.onDragStop(e,TY(TY({},t),{x:t.x+r,y:t.y+i}));if(this.props.dragAxis===`x`)return this.props.onDragStop(e,TY(TY({},t),{x:t.x+r,y:this.originalPosition.y+i,deltaY:0}));if(this.props.dragAxis===`y`)return this.props.onDragStop(e,TY(TY({},t),{x:this.originalPosition.x+r,y:t.y+i,deltaX:0}))}},t.prototype.onResizeStart=function(e,t,n){if(this.props.onResizeStart&&this.props.onResizeStart(e,t,n)===!1)return!1;e.stopPropagation(),this.setState({resizing:!0});var r=this.props.scale,i=this.offsetFromParent,a=this.getDraggablePosition();if(this.resizingPosition={x:a.x+i.left,y:a.y+i.top},this.originalPosition=a,this.props.bounds){var o=this.getParent(),s=void 0;this.props.bounds===`parent`?s=o:this.props.bounds===`body`?s=document.body:this.props.bounds===`window`?s=window:typeof this.props.bounds==`string`?s=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(s=this.props.bounds);var c=this.getSelfElement();if(c instanceof Element&&(s instanceof HTMLElement||s===window)&&o instanceof HTMLElement){var l=this.getMaxSizesFromProps(),u=l.maxWidth,d=l.maxHeight,f=this.getParentSize();if(u&&typeof u==`string`){if(u.endsWith(`%`)){var p=Number(u.replace(`%`,``))/100;u=f.width*p}else u.endsWith(`px`)&&(u=Number(u.replace(`px`,``)))}if(d&&typeof d==`string`){if(d.endsWith(`%`)){var p=Number(d.replace(`%`,``))/100;d=f.height*p}else d.endsWith(`px`)&&(d=Number(d.replace(`px`,``)))}var m=c.getBoundingClientRect(),h=m.left,g=m.top,_=this.props.bounds===`window`?{left:0,top:0}:s.getBoundingClientRect(),v=_.left,y=_.top,b=this.getOffsetWidth(s),x=this.getOffsetHeight(s),S=t.toLowerCase().endsWith(`left`),C=t.toLowerCase().endsWith(`right`),w=t.startsWith(`top`),T=t.startsWith(`bottom`);if((S||w)&&this.resizable){var E=(h-v)/r+this.resizable.size.width;this.setState({maxWidth:E>Number(u)?u:E})}if(C||this.props.lockAspectRatio&&!S&&!w){var E=b+(v-h)/r;this.setState({maxWidth:E>Number(u)?u:E})}if((w||S)&&this.resizable){var E=(g-y)/r+this.resizable.size.height;this.setState({maxHeight:E>Number(d)?d:E})}if(T||this.props.lockAspectRatio&&!w&&!S){var E=x+(y-g)/r;this.setState({maxHeight:E>Number(d)?d:E})}}}else this.setState({maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight})},t.prototype.onResize=function(e,t,n,r){var i=this,a={x:this.originalPosition.x,y:this.originalPosition.y},o=-r.width,s=-r.height;[`top`,`left`,`topLeft`,`bottomLeft`,`topRight`].includes(t)&&(t===`bottomLeft`?a.x+=o:(t===`topRight`||(a.x+=o),a.y+=s));var c=this.draggable.state;(a.x!==c.x||a.y!==c.y)&&(0,en.flushSync)(function(){i.draggable.setState(a)}),this.updateOffsetFromParent();var l=this.offsetFromParent,u=this.getDraggablePosition().x+l.left,d=this.getDraggablePosition().y+l.top;this.resizingPosition={x:u,y:d},this.props.onResize&&this.props.onResize(e,t,n,r,{x:u,y:d})},t.prototype.onResizeStop=function(e,t,n,r){this.setState({resizing:!1});var i=this.getMaxSizesFromProps(),a=i.maxWidth,o=i.maxHeight;this.setState({maxWidth:a,maxHeight:o}),this.props.onResizeStop&&this.props.onResizeStop(e,t,n,r,this.resizingPosition)},t.prototype.updateSize=function(e){this.resizable&&this.resizable.updateSize({width:e.width,height:e.height})},t.prototype.updatePosition=function(e){this.draggable.setState(e)},t.prototype.updateOffsetFromParent=function(){var e=this.props.scale,t=this.getParent(),n=this.getSelfElement();if(!t||n===null)return{top:0,left:0};var r=t.getBoundingClientRect(),i=r.left,a=r.top,o=n.getBoundingClientRect(),s=this.getDraggablePosition(),c=t.scrollLeft,l=t.scrollTop;this.offsetFromParent={left:o.left-i+c-s.x*e,top:o.top-a+l-s.y*e}},t.prototype.render=function(){var e=this,t=this.props,n=t.disableDragging,r=t.style,i=t.dragHandleClassName,a=t.position,o=t.onMouseDown,s=t.onMouseUp,c=t.dragAxis,l=t.dragGrid,u=t.bounds,d=t.enableUserSelectHack,f=t.cancel,p=t.children;t.onResizeStart,t.onResize,t.onResizeStop,t.onDragStart,t.onDrag,t.onDragStop;var m=t.resizeHandleStyles,g=t.resizeHandleClasses,_=t.resizeHandleComponent,v=t.enableResizing,y=t.resizeGrid,b=t.resizeHandleWrapperClass,x=t.resizeHandleWrapperStyle,S=t.scale,C=t.allowAnyClick,w=t.dragPositionOffset,T=EY(t,`disableDragging.style.dragHandleClassName.position.onMouseDown.onMouseUp.dragAxis.dragGrid.bounds.enableUserSelectHack.cancel.children.onResizeStart.onResize.onResizeStop.onDragStart.onDrag.onDragStop.resizeHandleStyles.resizeHandleClasses.resizeHandleComponent.enableResizing.resizeGrid.resizeHandleWrapperClass.resizeHandleWrapperStyle.scale.allowAnyClick.dragPositionOffset`.split(`.`)),E=this.props.default?TY({},this.props.default):void 0;delete T.default;var D=n||i?{cursor:`auto`}:{cursor:`move`},O=TY(TY(TY({},DY),D),r),k=this.offsetFromParent,A=k.left,j=k.top,M;a&&(M={x:a.x-A,y:a.y-j});var N=this.state.resizing?void 0:M,ee=this.state.resizing?`both`:c;return(0,h.createElement)(eY,{ref:function(t){t&&(e.draggable=t)},handle:i?`.${i}`:void 0,defaultPosition:E,onMouseDown:o,onMouseUp:s,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,axis:ee,disabled:n,grid:l,bounds:u?this.state.bounds:void 0,position:N,enableUserSelectHack:d,cancel:f,scale:S,allowAnyClick:C,nodeRef:this.resizableElement,positionOffset:w},(0,h.createElement)(SY,TY({},T,{ref:function(t){t&&(e.resizable=t,e.resizableElement.current=t.resizable)},defaultSize:E,size:this.props.size,enable:typeof v==`boolean`?OY(v):v,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,style:O,minWidth:this.props.minWidth,minHeight:this.props.minHeight,maxWidth:this.state.resizing?this.state.maxWidth:this.props.maxWidth,maxHeight:this.state.resizing?this.state.maxHeight:this.props.maxHeight,grid:y,handleWrapperClass:b,handleWrapperStyle:x,lockAspectRatio:this.props.lockAspectRatio,lockAspectRatioExtraWidth:this.props.lockAspectRatioExtraWidth,lockAspectRatioExtraHeight:this.props.lockAspectRatioExtraHeight,handleStyles:m,handleClasses:g,handleComponent:_,scale:this.props.scale}),p))},t.defaultProps={maxWidth:2**53-1,maxHeight:2**53-1,scale:1,onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},onDragStart:function(){},onDrag:function(){},onDragStop:function(){}},t}(h.PureComponent);function AY(e,t){return e?e.kind===`services`?t.services.find(t=>t.id===e.resourceId)?.name??e.title:e.kind===`terminal`?t.terminals.find(t=>t.id===e.resourceId)?.title??e.title:e.title:`窗口`}async function jY(e,t=`/`,n=`embedded`,r=`service`,i){return Y(`/api/previews/resolve`,{method:`POST`,csrf:!0,body:r===`process`?{processId:e,projectId:i,path:t,mode:n}:{serviceId:e,path:t,mode:n}})}function MY({tab:e}){return e.browser?(0,g.jsx)(PY,{tab:e}):(0,g.jsx)(FY,{tab:e})}function NY(e){return e instanceof fj||e instanceof Error?e.message:`预览不可用`}function PY({tab:e}){let t=e.browser,[n,r]=(0,h.useState)(null),[i,a]=(0,h.useState)(``),[o,s]=(0,h.useState)(!0),[c,l]=(0,h.useState)(0),[u,d]=(0,h.useState)(!1),f=(0,h.useRef)(null),p=`preview-${e.id.replace(/[^a-zA-Z0-9_-]/g,`-`)}`;(0,h.useEffect)(()=>{if(!t)return;let n=!1,i=c;return s(!0),a(``),r(null),jY(t.serviceId,t.path,`embedded`,t.targetKind,e.projectId??void 0).then(e=>{n||i!==c||(r(e),s(!1))}).catch(e=>{n||i!==c||(a(NY(e)),s(!1))}),()=>{n=!0}},[t,c,e.projectId]),(0,h.useEffect)(()=>{n&&f.current?.submit()},[n]);let m=async()=>{if(!t||u)return;d(!0),a(``);let n=window.open(`about:blank`,`_blank`);try{if(!n)throw Error(`浏览器阻止了新窗口`);n.opener=null;let r=await jY(t.serviceId,t.path,`external`,t.targetKind,e.projectId??void 0),i=document.createElement(`form`);i.method=`POST`,i.action=r.bootstrapUrl,i.target=`preview-external-${Date.now()}`,n.name=i.target,i.style.display=`none`;for(let[e,n]of[[`ticket`,r.ticket],[`path`,t.path]]){let t=document.createElement(`input`);t.type=`hidden`,t.name=e,t.value=n,i.append(t)}document.body.append(i),i.submit(),i.remove()}catch(e){n?.close(),a(NY(e))}finally{d(!1)}};return(0,g.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,g.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-1 border-b border-line bg-surface-2/45 px-2`,children:[(0,g.jsx)(vm,{label:`后退`,disabled:!0,className:`h-6 w-6`,children:(0,g.jsx)(Pa,{size:13})}),(0,g.jsx)(vm,{label:`前进`,disabled:!0,className:`h-6 w-6`,children:(0,g.jsx)(Ia,{size:13})}),(0,g.jsx)(vm,{label:`刷新预览`,onClick:()=>l(e=>e+1),className:`h-6 w-6`,children:(0,g.jsx)(Gs,{size:12,className:o?`animate-spin`:void 0})}),(0,g.jsxs)(`div`,{className:`mx-1 flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-lg border border-line bg-surface px-2`,children:[(0,g.jsx)(ac,{size:11,className:`shrink-0 text-success`}),(0,g.jsx)(`span`,{title:`预览地址`,className:`h-full min-w-0 flex-1 truncate font-mono text-[10.5px] leading-7 text-ink-2`,children:n?`${n.origin}${t?.path??`/`}`:`解析预览来源…`}),o?(0,g.jsx)(ps,{size:11,className:`animate-spin text-ink-3`}):null]}),(0,g.jsx)(vm,{label:`在独立来源打开`,onClick:()=>void m(),disabled:u,className:`h-6 w-6`,children:(0,g.jsx)(Do,{size:12})})]}),(0,g.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-white`,children:[i?(0,g.jsxs)(`div`,{className:`absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-surface text-center`,children:[(0,g.jsx)(`p`,{role:`alert`,title:i,className:`max-w-[360px] px-4 text-[12px] text-ink-2`,children:`无法访问`}),(0,g.jsx)(`button`,{type:`button`,className:`text-[11px] text-accent underline`,onClick:()=>l(e=>e+1),children:`刷新`})]}):null,(0,g.jsx)(`form`,{ref:f,method:`POST`,action:n?.bootstrapUrl??``,target:p,hidden:!0,children:(0,g.jsx)(`input`,{type:`hidden`,name:`ticket`,value:n?.ticket??``,readOnly:!0})}),(0,g.jsx)(`iframe`,{name:p,title:`项目预览`,"data-testid":`preview-frame`,src:`about:blank`,sandbox:`allow-scripts allow-forms allow-same-origin`,referrerPolicy:`no-referrer`,className:`h-full w-full border-0 bg-white`}),o?(0,g.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-surface/60 text-[11px] text-ink-3`,children:`正在建立隔离预览…`}):null]}),(0,g.jsxs)(`div`,{className:`flex h-6 shrink-0 items-center gap-1.5 border-t border-line bg-surface-2/50 px-2 font-mono text-[9px] text-ink-3`,children:[(0,g.jsx)(Co,{size:10,className:`shrink-0`}),(0,g.jsx)(`span`,{className:`whitespace-nowrap`,children:`独立来源`})]})]})}function FY({tab:e}){let[t,n]=(0,h.useState)(e.resourceId.startsWith(`http`)?e.resourceId:`http://localhost:5173/dashboard`),[r,i]=(0,h.useState)(!1),a=()=>{i(!0),window.setTimeout(()=>i(!1),650)};return(0,g.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,g.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-1 border-b border-line bg-surface-2/45 px-2`,children:[(0,g.jsx)(vm,{label:`后退`,disabled:!0,className:`h-6 w-6`,children:(0,g.jsx)(Pa,{size:13})}),(0,g.jsx)(vm,{label:`前进`,disabled:!0,className:`h-6 w-6`,children:(0,g.jsx)(Ia,{size:13})}),(0,g.jsx)(vm,{label:`刷新`,onClick:a,className:`h-6 w-6`,children:(0,g.jsx)(Gs,{size:12,className:r?`animate-spin`:void 0})}),(0,g.jsxs)(`form`,{className:`mx-1 flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-lg border border-line bg-surface px-2`,onSubmit:e=>{e.preventDefault(),a()},children:[(0,g.jsx)(ac,{size:11,className:`shrink-0 text-success`}),(0,g.jsx)(mm,{variant:`bare`,value:t,onChange:e=>n(e.target.value),"aria-label":`预览地址`,className:`h-full min-w-0 flex-1 bg-transparent font-mono text-[10.5px] text-ink-2 outline-none`}),r?(0,g.jsx)(ps,{size:11,className:`animate-spin text-ink-3`}):null]})]}),(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-[#f7f8fa]`,children:(0,g.jsx)(IY,{address:t})}),(0,g.jsxs)(`div`,{className:`flex h-6 shrink-0 items-center gap-1.5 border-t border-line bg-surface-2/50 px-2 font-mono text-[9px] text-ink-3`,children:[(0,g.jsx)(Co,{size:10,className:`shrink-0`}),(0,g.jsx)(`span`,{className:`whitespace-nowrap`,children:`演示预览`})]})]})}function IY({address:e}){return(0,g.jsxs)(`div`,{className:`min-h-full bg-[#f7f8fa] text-[#1d1d1f]`,children:[(0,g.jsx)(`div`,{className:`border-b border-black/[.06] bg-white/80 px-6 py-3 backdrop-blur`,children:(0,g.jsxs)(`div`,{className:`mx-auto flex max-w-[900px] items-center gap-3`,children:[(0,g.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-lg bg-[#0a84ff] text-[10px] font-bold text-white`,children:`L`}),(0,g.jsx)(`span`,{className:`text-[12px] font-semibold`,children:`Larness`}),(0,g.jsxs)(`nav`,{className:`ml-4 flex items-center gap-4 text-[10.5px] text-[#6e6e73]`,children:[(0,g.jsx)(`span`,{className:`text-[#1d1d1f]`,children:`概览`}),(0,g.jsx)(`span`,{children:`项目`}),(0,g.jsx)(`span`,{children:`运行记录`})]}),(0,g.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`rounded-full bg-[#30d158]/10 px-2 py-[2px] text-[9px] font-medium text-[#1f9d48]`,children:`dev · healthy`}),(0,g.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-[#ffd60a]`})]})]})}),(0,g.jsxs)(`div`,{className:`mx-auto max-w-[900px] px-6 py-8`,children:[(0,g.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-[.12em] text-[#86868b]`,children:`Workspace overview`}),(0,g.jsx)(`h2`,{className:`mt-2 text-[28px] font-semibold tracking-[-.03em]`,children:`你的工作空间,已就绪。`}),(0,g.jsx)(`p`,{className:`mt-1.5 max-w-[520px] text-[12px] leading-5 text-[#6e6e73]`,children:`这是 Vite 开发服务的本地预览占位页面。真实项目会在独立来源中加载,不共享管理站的 Cookie。`})]}),(0,g.jsxs)(`div`,{className:`hidden rounded-xl border border-black/[.06] bg-white px-3 py-2 text-right shadow-sm sm:block`,children:[(0,g.jsx)(`div`,{className:`font-mono text-[9px] text-[#86868b]`,children:e}),(0,g.jsx)(`div`,{className:`mt-1 text-[10px] text-[#1f9d48]`,children:`HTTP 200 · 42ms`})]})]}),(0,g.jsx)(`div`,{className:`mt-6 grid grid-cols-3 gap-3`,children:[{label:`运行中的服务`,value:`3`,detail:`+1 今日`,tint:`#0a84ff`},{label:`本周部署`,value:`12`,detail:`全部健康`,tint:`#30d158`},{label:`终端会话`,value:`2`,detail:`1 个空闲`,tint:`#ff9f0a`}].map(e=>(0,g.jsxs)(`div`,{className:`rounded-2xl border border-black/[.06] bg-white p-4 shadow-[0_1px_2px_rgba(0,0,0,.03)]`,children:[(0,g.jsx)(`div`,{className:`text-[10px] text-[#86868b]`,children:e.label}),(0,g.jsxs)(`div`,{className:`mt-2 flex items-end gap-2`,children:[(0,g.jsx)(`span`,{className:`text-[26px] font-semibold leading-none tracking-[-.04em]`,children:e.value}),(0,g.jsx)(`span`,{className:`pb-0.5 text-[9.5px] text-[#6e6e73]`,children:e.detail})]}),(0,g.jsx)(`div`,{className:`mt-3 h-1 rounded-full bg-black/[.05]`,children:(0,g.jsx)(`div`,{className:`h-full rounded-full`,style:{width:e.label===`运行中的服务`?`62%`:`78%`,background:e.tint}})})]},e.label))}),(0,g.jsxs)(`div`,{className:`mt-3 grid grid-cols-[1.4fr_1fr] gap-3`,children:[(0,g.jsxs)(`div`,{className:`rounded-2xl border border-black/[.06] bg-white p-4`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-[11px] font-semibold`,children:`最近活动`}),(0,g.jsx)(`span`,{className:`text-[9.5px] text-[#86868b]`,children:`过去 24 小时`})]}),(0,g.jsx)(`div`,{className:`mt-3 flex h-[92px] items-end gap-1.5`,children:[38,52,44,66,58,74,62,80,68,86,72,92].map((e,t)=>(0,g.jsx)(`div`,{className:B(`flex-1 rounded-t-[3px]`,t===11?`bg-[#0a84ff]`:`bg-[#0a84ff]/20`),style:{height:`${e}%`}},t))})]}),(0,g.jsxs)(`div`,{className:`rounded-2xl border border-black/[.06] bg-white p-4`,children:[(0,g.jsx)(`div`,{className:`text-[11px] font-semibold`,children:`当前会话`}),(0,g.jsx)(`div`,{className:`mt-3 space-y-2`,children:[[`feat/agent-runtime`,`feat/agent-runtime`,`运行中`],[`web-prod`,`PM2 · 8080`,`待部署`],[`preview`,`localhost:5173`,`已连接`]].map(([e,t,n])=>(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[#0a84ff]`}),(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`truncate text-[10.5px] font-medium`,children:e}),(0,g.jsx)(`div`,{className:`truncate font-mono text-[9px] text-[#86868b]`,children:t})]}),(0,g.jsx)(`span`,{className:`text-[9px] text-[#6e6e73]`,children:n})]},e))})]})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center justify-center gap-2 border-t border-black/[.05] py-4 text-[9px] text-[#86868b]`,children:[(0,g.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[#30d158]`}),`这是 S0 视觉 Demo 的静态预览,不加载真实项目页面`]})]})}function LY({tab:e}){return(0,g.jsx)(RY,{tab:e})}function RY({tab:e}){let[t,n]=(0,h.useState)(null),r=e.projectId,i=e.git,a=Zg({queryKey:[`git`,`diff`,r,i?.path,i?.staged],queryFn:()=>kW(r??``,i?.path??``,i?.staged===!0),enabled:r!==null&&i!==void 0,retry:!1});if(r===null||i===void 0)return(0,g.jsx)(`p`,{className:`p-4 text-xs text-ink-3`,children:`Diff 目标缺少项目或路径,请重新打开。`});if(a.isPending)return(0,g.jsxs)(`p`,{className:`flex items-center gap-2 p-4 text-xs text-ink-3`,children:[(0,g.jsx)(ps,{size:12,className:`animate-spin`}),` 读取 Diff…`]});if(a.isError)return(0,g.jsx)(Yc,{message:`差异读取失败,请重新打开或重试。`,retry:{label:`重新读取`,run:()=>void a.refetch()}});let o=a.data;return(0,g.jsxs)(zY,{data:o,children:[(0,g.jsx)(Yc,{message:t,onDismiss:()=>n(null)}),(0,g.jsx)(`button`,{type:`button`,className:`shrink-0 rounded px-1 py-0.5 text-ink-2 hover:bg-surface-2`,onClick:()=>{n(null),HM({projectId:r},i.path,`project`).catch(e=>n(VM(e)))},children:`打开工作区文件`})]})}function zY({data:e,children:t}){let n=e.binary?[]:e.diff.split(`
|
|
111
|
-
`);return(0,g.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-line px-3 py-2`,children:[(0,g.jsx)(Xo,{size:14,className:`text-ink-3`}),(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink-2`,children:e.path}),(0,g.jsx)(`span`,{className:`rounded-full border border-line bg-surface-2 px-1.5 py-[1px] text-[9px] text-ink-3`,children:e.staged?`已暂存`:`工作区`}),t]}),e.binary?(0,g.jsx)(`p`,{className:`p-4 text-xs text-ink-3`,children:`二进制文件不显示文本 Diff;仍可按显式路径暂存 / 提交。`}):e.truncated?(0,g.jsx)(`p`,{className:`p-4 text-xs text-warning`,children:`Diff 超过 1 MiB,已截断;不自动写入或覆盖文件。`}):e.diff.trim()===``?(0,g.jsxs)(`div`,{className:`space-y-1 p-4 text-xs text-ink-3`,children:[(0,g.jsx)(`p`,{children:e.staged?`暂存区与 HEAD 没有文本差异。`:`工作区没有未暂存的文本差异。`}),(0,g.jsx)(`p`,{children:`未跟踪文件、仅权限或行尾变化、以及只存在于另一侧的改动不会显示在这里;可切换“已暂存 / 工作区”,或直接打开工作区文件。`})]}):(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto font-mono text-[10.5px] leading-[19px]`,children:n.map((e,t)=>(0,g.jsxs)(`div`,{className:B(`flex min-w-max whitespace-pre`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-success/[.08]`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-danger/[.07]`),children:[(0,g.jsx)(`span`,{className:`w-5 shrink-0 select-none text-center text-ink-3/70`,children:e.startsWith(`+`)&&!e.startsWith(`+++`)?`+`:e.startsWith(`-`)&&!e.startsWith(`---`)?`-`:` `}),(0,g.jsx)(`span`,{className:`whitespace-pre pr-6 text-ink-2`,children:e||` `})]},`${t}_${e.slice(0,16)}`))}),(0,g.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-3 border-t border-line bg-surface-2/40 px-3 text-[10px] text-ink-3`,children:[(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(Ja,{size:11,className:`text-success`}),`只读 Diff`]}),(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(Us,{size:11,className:`text-success`}),`新增`]}),(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(xc,{size:11,className:`text-danger`}),`删除`]})]})]})}(0,h.lazy)(()=>e(()=>import(`./FileViewer-CK3jt-Kt.js`),__vite__mapDeps([0,1,2,3,4,5])));var BY=(0,h.lazy)(()=>e(()=>import(`./FileEditor-EgU1WoyG.js`),__vite__mapDeps([6,1,2,3,4,5])));function VY({tab:e}){return e.file?(0,g.jsx)(HY,{tab:e,target:e.file},e.id):(0,g.jsx)(`div`,{className:`p-5 text-sm text-ink-3`,children:`从右侧文件树打开文件。旧的预览 Tab 请关闭后重新打开。`})}function HY({tab:e,target:t}){let n=Zg({queryKey:LM(t.scope,t.path),queryFn:()=>RM(t.scope,t.path),staleTime:0}),r=yM(e=>e.monitoring[IM(t.scope)]),i=yM(t=>t.drafts[e.resourceId]),a=yM(t=>t.saving[e.resourceId]??!1),[o,s]=(0,h.useState)(null),[c,l]=(0,h.useState)(!1),u=n.data,d=!!i&&!!u&&i.baseVersion!==u.version,f=i?.text??u?.content;return(0,h.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`s`&&(t.preventDefault(),a||n.isError||d||(s(null),WM(e).catch(e=>s(VM(e)))))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[a,n.isError,d,e]),(0,g.jsxs)(`div`,{className:`flex h-full flex-col text-[11px] text-ink-2`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-line p-2`,children:[(0,g.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,title:t.path,children:[t.path,i?` ●`:``]}),(0,g.jsx)(`button`,{type:`button`,title:`在文件树中定位`,className:`hidden xl:inline`,onClick:()=>vW.getState().revealFile(IM(t.scope),t.path),children:`在文件树中定位`}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`刷新文件`,disabled:a,onClick:()=>{s(null),n.refetch()},children:`刷新`}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`保存文件`,disabled:!i||a||d||n.isError,onClick:()=>{s(null),WM(e).catch(e=>s(VM(e)))},children:a?`保存中…`:`保存`})]}),(0,g.jsx)(Yc,{message:n.isError?VM(n.error):d?null:o,onDismiss:n.isError?void 0:()=>s(null)}),d?(0,g.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-line bg-warning/10 p-2`,children:[(0,g.jsx)(`p`,{role:`status`,children:`磁盘文件已变化,草稿已保留。`}),(0,g.jsxs)(`div`,{className:`flex gap-4`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:()=>l(!c),children:c?`返回编辑`:`查看差异`}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>{yM.getState().discard(e.resourceId),l(!1),s(null)},children:`重新加载磁盘`}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>{u&&i&&yM.getState().edit(e.resourceId,i.text,u.version),l(!1),s(null)},children:`手工合并`})]}),(0,g.jsx)(`p`,{className:`text-ink-3`,children:c?`磁盘版本 → 本地草稿`:`重载将放弃草稿;手工合并保留草稿,编辑后按当前磁盘版本保存。`})]}):null,(0,g.jsx)(`div`,{className:`min-h-0 flex-1`,children:f===void 0?(0,g.jsx)(`p`,{className:`p-4`,children:n.isPending?`正在读取完整文件…`:`文件不可用`}):(0,g.jsx)(h.Suspense,{fallback:(0,g.jsx)(`p`,{className:`p-4`,children:`正在加载编辑器…`}),children:(0,g.jsx)(BY,{identity:e.resourceId,path:t.path,text:f,original:c&&d?u?.content:void 0,readOnly:a||n.isError,onChange:t=>{u&&(t===u.content&&(!i||i.baseVersion===u.version)?yM.getState().discard(e.resourceId):(FM.getState().keepFileTab(e.id),yM.getState().edit(e.resourceId,t,i?.baseVersion??u.version)))}},`${e.resourceId}:${c}`)})}),(0,g.jsxs)(`div`,{className:`shrink-0 border-t border-line px-3 py-1 text-ink-3`,children:[`UTF-8 · `,i?`未保存`:`已同步`,n.isFetching?` · 正在刷新`:``,` · `,r??`正在连接文件监听…`]})]})}function UY(e){switch(e){case`RUNNING`:return`运行中`;case`STARTING`:return`启动中`;case`STOPPING`:return`停止中`;case`STOPPED`:return`已停止`;case`FAILED`:return`失败`;default:return`已退出`}}function WY(e){return e===`RUNNING`?`border-success/20 bg-success/10 text-success`:e===`FAILED`?`border-danger/20 bg-danger/10 text-danger`:`border-line bg-surface-2 text-ink-3`}function GY({tab:e}){let t=e.projectId;return t?(0,g.jsx)(KY,{projectId:t,initialId:e.resourceId.startsWith(`prc_`)?e.resourceId:null}):(0,g.jsx)(`div`,{className:`flex h-full items-center justify-center text-xs text-ink-3`,children:`选择一个项目后查看服务`})}function KY({projectId:e,initialId:t}){let[n,r]=(0,h.useState)(t),i=Eh(),a=Zg({queryKey:lK(e),queryFn:()=>dK(e),refetchInterval:2e3});if(n)return(0,g.jsx)(qY,{id:n,projectId:e,onBack:()=>r(null),onStopped:()=>{i.invalidateQueries({queryKey:lK(e)}),i.invalidateQueries({queryKey:uK(n)})}});let o=a.data??[],s=o.filter(e=>e.status===`RUNNING`).length;return(0,g.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-line px-3 py-2`,children:[(0,g.jsx)(rc,{size:14,className:`text-ink-3`}),(0,g.jsx)(`span`,{className:`text-[12px] font-semibold text-ink`,children:`服务`}),(0,g.jsxs)(`span`,{className:`rounded-full bg-surface-2 px-1.5 text-[10px] text-ink-3`,children:[s,`/`,o.length]}),(0,g.jsx)(vm,{className:`ml-auto h-6 w-6`,label:`刷新服务`,onClick:()=>void a.refetch(),disabled:a.isFetching,children:(0,g.jsx)(Gs,{size:12,className:a.isFetching?`animate-spin`:void 0})})]}),(0,g.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,g.jsx)(Yc,{message:a.isError?`服务读取失败,请刷新重试。`:null}),o.length===0&&!a.isError?(0,g.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center`,children:[(0,g.jsx)(rc,{size:22,className:`text-ink-3`}),(0,g.jsx)(`p`,{className:`text-[12px] font-medium text-ink`,children:`当前项目暂无后台服务`}),(0,g.jsx)(`p`,{className:`max-w-[340px] text-[11px] text-ink-3`,children:`在项目会话中让 Agent 启动开发服务器或常驻任务,启动后即可在这里查看和预览。`})]}):(0,g.jsx)(`div`,{className:`grid grid-cols-1 gap-2 md:grid-cols-2`,children:o.map(e=>(0,g.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`rounded-lg border border-line bg-surface p-2.5 text-left transition-colors hover:bg-surface-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`truncate text-[12px] font-medium text-ink`,children:e.name??e.executable}),(0,g.jsx)(`span`,{className:B(`rounded-full border px-1.5 py-[1px] text-[9px]`,WY(e.status)),children:UY(e.status)}),e.previewEligible?(0,g.jsx)(`span`,{className:`ml-auto rounded bg-accent-soft px-1 text-[9px] text-accent`,children:`可预览`}):null]}),(0,g.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-ink-3`,children:e.port?`127.0.0.1:${e.port}`:e.executable}),(0,g.jsxs)(`div`,{className:`mt-0.5 truncate text-[9.5px] text-ink-3`,children:[e.pid?`PID ${e.pid} · `:``,e.cwd]})]},e.id))})]})]})}function qY({id:e,projectId:t,onBack:n,onStopped:r}){let i=Eh(),a=FM(e=>e.open),[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(null),[u,d]=(0,h.useState)(0),[f,p]=(0,h.useState)([]),m=(0,h.useRef)(0),_=Zg({queryKey:uK(e),queryFn:()=>fK(e),refetchInterval:2e3}),v=Zg({queryKey:[`processes`,`output`,e,u],queryFn:()=>pK(e,u,200),refetchInterval:1500});(0,h.useEffect)(()=>{let e=v.data;if(!e)return;let t=e.chunks.filter(e=>e.cursor>m.current);t.length>0&&(m.current=t[t.length-1]?.cursor??m.current,p(e=>[...e,...t.map(e=>e.data)].slice(-600))),e.nextCursor>u&&d(e.nextCursor)},[v.data,u]);let y=_.data,b=async()=>{try{await mK(e),s(!1),l(null),await i.invalidateQueries({queryKey:uK(e)}),await i.invalidateQueries({queryKey:[`processes`]}),r()}catch(e){l(pj(e,`停止服务失败,请重试。`)),s(!1)}};return(0,g.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-line px-3 py-2`,children:[(0,g.jsx)(vm,{className:`h-6 w-6`,label:`返回服务列表`,onClick:n,children:(0,g.jsx)(Pa,{size:13})}),(0,g.jsx)(`span`,{className:`truncate text-[12px] font-semibold text-ink`,children:y?.name??`服务详情`}),y?(0,g.jsx)(`span`,{className:B(`rounded-full border px-1.5 py-[1px] text-[9px]`,WY(y.status)),children:UY(y.status)}):null,y?.previewEligible?(0,g.jsx)(V,{className:`ml-auto`,size:`sm`,variant:`secondary`,leading:(0,g.jsx)(Do,{size:11}),onClick:()=>a({kind:`browser`,resourceId:`browser:${y.id}:/`,browser:{serviceId:y.id,path:`/`,targetKind:`process`},title:`预览 ${y.name??y.executable}`,projectId:t,source:`project`}),children:`预览`}):null,y?.status===`RUNNING`||y?.status===`STARTING`?(0,g.jsx)(V,{className:y.previewEligible?``:`ml-auto`,size:`sm`,variant:`secondary`,leading:(0,g.jsx)(pc,{size:11}),onClick:()=>s(!0),children:`停止`}):null]}),(0,g.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,g.jsx)(Yc,{message:c??(_.isError?`服务读取失败`:null)}),y?(0,g.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[11px]`,children:[(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`命令`}),(0,g.jsx)(`dd`,{className:`truncate font-mono text-ink-2`,children:y.executable}),(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`目录`}),(0,g.jsx)(`dd`,{className:`truncate font-mono text-ink-2`,children:y.cwd}),(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`端口`}),(0,g.jsx)(`dd`,{className:`font-mono text-ink-2`,children:y.port?`127.0.0.1:${y.port}`:`未声明`}),(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`PID`}),(0,g.jsx)(`dd`,{className:`font-mono text-ink-2`,children:y.pid??`—`}),(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`开始`}),(0,g.jsx)(`dd`,{className:`text-ink-2`,children:y.startedAt?new Date(y.startedAt).toLocaleString(`zh-CN`):`—`})]}):null,(0,g.jsx)(`pre`,{role:`log`,"aria-label":`服务输出`,className:`mt-3 max-h-[calc(100dvh-16rem)] min-h-32 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-2 p-2 font-mono text-[10.5px] text-ink-2`,children:f.length>0?f.join(``):`等待服务输出…`})]}),(0,g.jsx)(Xc,{open:o,title:`停止服务?`,description:`将停止该任务及其进程组;未保存的临时状态会丢失。`,confirmLabel:`确认停止`,danger:!0,onCancel:()=>s(!1),onConfirm:()=>void b()})]})}var JY=2,YY=1,XY=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(JY,Math.floor(u/e.css.cell.width)),rows:Math.max(YY,Math.floor(l/e.css.cell.height))}}},ZY=Object.defineProperty,QY=Object.getOwnPropertyDescriptor,$Y=(e,t)=>{for(var n in t)ZY(e,n,{get:t[n],enumerable:!0})},eX=(e,t,n,r)=>{for(var i=r>1?void 0:r?QY(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ZY(t,n,i),i},X=(e,t)=>(n,r)=>t(n,r,e),tX=`Terminal input`,nX={get:()=>tX,set:e=>tX=e},rX=`Too much output to announce, navigate to rows manually to read`,iX={get:()=>rX,set:e=>rX=e};function aX(e){return e.replace(/\r?\n/g,`\r`)}function oX(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function sX(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function cX(e,t,n,r){e.stopPropagation(),e.clipboardData&&lX(e.clipboardData.getData(`text/plain`),t,n,r)}function lX(e,t,n,r){e=aX(e),e=oX(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function uX(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function dX(e,t,n,r,i){uX(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function fX(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function pX(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var mX=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},hX=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},gX=``,_X=` `,vX=class e{constructor(){this.fg=0,this.bg=0,this.extended=new yX}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},yX=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},bX=class e extends vX{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new yX,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?fX(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},xX=`di$target`,SX=`di$dependencies`,CX=new Map;function wX(e){return e[SX]||[]}function TX(e){if(CX.has(e))return CX.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);EX(t,e,r)};return t._id=e,CX.set(e,t),t}function EX(e,t,n){t[xX]===t?t[SX].push({id:e,index:n}):(t[SX]=[{id:e,index:n}],t[xX]=t)}var DX=TX(`BufferService`),OX=TX(`CoreMouseService`),kX=TX(`CoreService`),AX=TX(`CharsetService`),jX=TX(`InstantiationService`),MX=TX(`LogService`),NX=TX(`OptionsService`),PX=TX(`OscLinkService`),FX=TX(`UnicodeService`),IX=TX(`DecorationService`),LX=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new bX,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):RX(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};LX=eX([X(0,DX),X(1,NX),X(2,PX)],LX);function RX(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
111
|
+
`);return(0,g.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-line px-3 py-2`,children:[(0,g.jsx)(Xo,{size:14,className:`text-ink-3`}),(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink-2`,children:e.path}),(0,g.jsx)(`span`,{className:`rounded-full border border-line bg-surface-2 px-1.5 py-[1px] text-[9px] text-ink-3`,children:e.staged?`已暂存`:`工作区`}),t]}),e.binary?(0,g.jsx)(`p`,{className:`p-4 text-xs text-ink-3`,children:`二进制文件不显示文本 Diff;仍可按显式路径暂存 / 提交。`}):e.truncated?(0,g.jsx)(`p`,{className:`p-4 text-xs text-warning`,children:`Diff 超过 1 MiB,已截断;不自动写入或覆盖文件。`}):e.diff.trim()===``?(0,g.jsxs)(`div`,{className:`space-y-1 p-4 text-xs text-ink-3`,children:[(0,g.jsx)(`p`,{children:e.staged?`暂存区与 HEAD 没有文本差异。`:`工作区没有未暂存的文本差异。`}),(0,g.jsx)(`p`,{children:`未跟踪文件、仅权限或行尾变化、以及只存在于另一侧的改动不会显示在这里;可切换“已暂存 / 工作区”,或直接打开工作区文件。`})]}):(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto font-mono text-[10.5px] leading-[19px]`,children:n.map((e,t)=>(0,g.jsxs)(`div`,{className:B(`flex min-w-max whitespace-pre`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-success/[.08]`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-danger/[.07]`),children:[(0,g.jsx)(`span`,{className:`w-5 shrink-0 select-none text-center text-ink-3/70`,children:e.startsWith(`+`)&&!e.startsWith(`+++`)?`+`:e.startsWith(`-`)&&!e.startsWith(`---`)?`-`:` `}),(0,g.jsx)(`span`,{className:`whitespace-pre pr-6 text-ink-2`,children:e||` `})]},`${t}_${e.slice(0,16)}`))}),(0,g.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-3 border-t border-line bg-surface-2/40 px-3 text-[10px] text-ink-3`,children:[(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(Ja,{size:11,className:`text-success`}),`只读 Diff`]}),(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(Us,{size:11,className:`text-success`}),`新增`]}),(0,g.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(xc,{size:11,className:`text-danger`}),`删除`]})]})]})}(0,h.lazy)(()=>e(()=>import(`./FileViewer-4LwgwN4s.js`),__vite__mapDeps([0,1,2,3,4,5])));var BY=(0,h.lazy)(()=>e(()=>import(`./FileEditor-CxzD-z_w.js`),__vite__mapDeps([6,1,2,3,4,5])));function VY({tab:e}){return e.file?(0,g.jsx)(HY,{tab:e,target:e.file},e.id):(0,g.jsx)(`div`,{className:`p-5 text-sm text-ink-3`,children:`从右侧文件树打开文件。旧的预览 Tab 请关闭后重新打开。`})}function HY({tab:e,target:t}){let n=Zg({queryKey:LM(t.scope,t.path),queryFn:()=>RM(t.scope,t.path),staleTime:0}),r=yM(e=>e.monitoring[IM(t.scope)]),i=yM(t=>t.drafts[e.resourceId]),a=yM(t=>t.saving[e.resourceId]??!1),[o,s]=(0,h.useState)(null),[c,l]=(0,h.useState)(!1),u=n.data,d=!!i&&!!u&&i.baseVersion!==u.version,f=i?.text??u?.content;return(0,h.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`s`&&(t.preventDefault(),a||n.isError||d||(s(null),WM(e).catch(e=>s(VM(e)))))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[a,n.isError,d,e]),(0,g.jsxs)(`div`,{className:`flex h-full flex-col text-[11px] text-ink-2`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-line p-2`,children:[(0,g.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,title:t.path,children:[t.path,i?` ●`:``]}),(0,g.jsx)(`button`,{type:`button`,title:`在文件树中定位`,className:`hidden xl:inline`,onClick:()=>vW.getState().revealFile(IM(t.scope),t.path),children:`在文件树中定位`}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`刷新文件`,disabled:a,onClick:()=>{s(null),n.refetch()},children:`刷新`}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`保存文件`,disabled:!i||a||d||n.isError,onClick:()=>{s(null),WM(e).catch(e=>s(VM(e)))},children:a?`保存中…`:`保存`})]}),(0,g.jsx)(Yc,{message:n.isError?VM(n.error):d?null:o,onDismiss:n.isError?void 0:()=>s(null)}),d?(0,g.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-line bg-warning/10 p-2`,children:[(0,g.jsx)(`p`,{role:`status`,children:`磁盘文件已变化,草稿已保留。`}),(0,g.jsxs)(`div`,{className:`flex gap-4`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:()=>l(!c),children:c?`返回编辑`:`查看差异`}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>{yM.getState().discard(e.resourceId),l(!1),s(null)},children:`重新加载磁盘`}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>{u&&i&&yM.getState().edit(e.resourceId,i.text,u.version),l(!1),s(null)},children:`手工合并`})]}),(0,g.jsx)(`p`,{className:`text-ink-3`,children:c?`磁盘版本 → 本地草稿`:`重载将放弃草稿;手工合并保留草稿,编辑后按当前磁盘版本保存。`})]}):null,(0,g.jsx)(`div`,{className:`min-h-0 flex-1`,children:f===void 0?(0,g.jsx)(`p`,{className:`p-4`,children:n.isPending?`正在读取完整文件…`:`文件不可用`}):(0,g.jsx)(h.Suspense,{fallback:(0,g.jsx)(`p`,{className:`p-4`,children:`正在加载编辑器…`}),children:(0,g.jsx)(BY,{identity:e.resourceId,path:t.path,text:f,original:c&&d?u?.content:void 0,readOnly:a||n.isError,onChange:t=>{u&&(t===u.content&&(!i||i.baseVersion===u.version)?yM.getState().discard(e.resourceId):(FM.getState().keepFileTab(e.id),yM.getState().edit(e.resourceId,t,i?.baseVersion??u.version)))}},`${e.resourceId}:${c}`)})}),(0,g.jsxs)(`div`,{className:`shrink-0 border-t border-line px-3 py-1 text-ink-3`,children:[`UTF-8 · `,i?`未保存`:`已同步`,n.isFetching?` · 正在刷新`:``,` · `,r??`正在连接文件监听…`]})]})}function UY(e){switch(e){case`RUNNING`:return`运行中`;case`STARTING`:return`启动中`;case`STOPPING`:return`停止中`;case`STOPPED`:return`已停止`;case`FAILED`:return`失败`;default:return`已退出`}}function WY(e){return e===`RUNNING`?`border-success/20 bg-success/10 text-success`:e===`FAILED`?`border-danger/20 bg-danger/10 text-danger`:`border-line bg-surface-2 text-ink-3`}function GY({tab:e}){let t=e.projectId;return t?(0,g.jsx)(KY,{projectId:t,initialId:e.resourceId.startsWith(`prc_`)?e.resourceId:null}):(0,g.jsx)(`div`,{className:`flex h-full items-center justify-center text-xs text-ink-3`,children:`选择一个项目后查看服务`})}function KY({projectId:e,initialId:t}){let[n,r]=(0,h.useState)(t),i=Eh(),a=Zg({queryKey:lK(e),queryFn:()=>dK(e),refetchInterval:2e3});if(n)return(0,g.jsx)(qY,{id:n,projectId:e,onBack:()=>r(null),onStopped:()=>{i.invalidateQueries({queryKey:lK(e)}),i.invalidateQueries({queryKey:uK(n)})}});let o=a.data??[],s=o.filter(e=>e.status===`RUNNING`).length;return(0,g.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-line px-3 py-2`,children:[(0,g.jsx)(rc,{size:14,className:`text-ink-3`}),(0,g.jsx)(`span`,{className:`text-[12px] font-semibold text-ink`,children:`服务`}),(0,g.jsxs)(`span`,{className:`rounded-full bg-surface-2 px-1.5 text-[10px] text-ink-3`,children:[s,`/`,o.length]}),(0,g.jsx)(vm,{className:`ml-auto h-6 w-6`,label:`刷新服务`,onClick:()=>void a.refetch(),disabled:a.isFetching,children:(0,g.jsx)(Gs,{size:12,className:a.isFetching?`animate-spin`:void 0})})]}),(0,g.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,g.jsx)(Yc,{message:a.isError?`服务读取失败,请刷新重试。`:null}),o.length===0&&!a.isError?(0,g.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center`,children:[(0,g.jsx)(rc,{size:22,className:`text-ink-3`}),(0,g.jsx)(`p`,{className:`text-[12px] font-medium text-ink`,children:`当前项目暂无后台服务`}),(0,g.jsx)(`p`,{className:`max-w-[340px] text-[11px] text-ink-3`,children:`在项目会话中让 Agent 启动开发服务器或常驻任务,启动后即可在这里查看和预览。`})]}):(0,g.jsx)(`div`,{className:`grid grid-cols-1 gap-2 md:grid-cols-2`,children:o.map(e=>(0,g.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`rounded-lg border border-line bg-surface p-2.5 text-left transition-colors hover:bg-surface-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`truncate text-[12px] font-medium text-ink`,children:e.name??e.executable}),(0,g.jsx)(`span`,{className:B(`rounded-full border px-1.5 py-[1px] text-[9px]`,WY(e.status)),children:UY(e.status)}),e.previewEligible?(0,g.jsx)(`span`,{className:`ml-auto rounded bg-accent-soft px-1 text-[9px] text-accent`,children:`可预览`}):null]}),(0,g.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-ink-3`,children:e.port?`127.0.0.1:${e.port}`:e.executable}),(0,g.jsxs)(`div`,{className:`mt-0.5 truncate text-[9.5px] text-ink-3`,children:[e.pid?`PID ${e.pid} · `:``,e.cwd]})]},e.id))})]})]})}function qY({id:e,projectId:t,onBack:n,onStopped:r}){let i=Eh(),a=FM(e=>e.open),[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(null),[u,d]=(0,h.useState)(0),[f,p]=(0,h.useState)([]),m=(0,h.useRef)(0),_=Zg({queryKey:uK(e),queryFn:()=>fK(e),refetchInterval:2e3}),v=Zg({queryKey:[`processes`,`output`,e,u],queryFn:()=>pK(e,u,200),refetchInterval:1500});(0,h.useEffect)(()=>{let e=v.data;if(!e)return;let t=e.chunks.filter(e=>e.cursor>m.current);t.length>0&&(m.current=t[t.length-1]?.cursor??m.current,p(e=>[...e,...t.map(e=>e.data)].slice(-600))),e.nextCursor>u&&d(e.nextCursor)},[v.data,u]);let y=_.data,b=async()=>{try{await mK(e),s(!1),l(null),await i.invalidateQueries({queryKey:uK(e)}),await i.invalidateQueries({queryKey:[`processes`]}),r()}catch(e){l(pj(e,`停止服务失败,请重试。`)),s(!1)}};return(0,g.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-line px-3 py-2`,children:[(0,g.jsx)(vm,{className:`h-6 w-6`,label:`返回服务列表`,onClick:n,children:(0,g.jsx)(Pa,{size:13})}),(0,g.jsx)(`span`,{className:`truncate text-[12px] font-semibold text-ink`,children:y?.name??`服务详情`}),y?(0,g.jsx)(`span`,{className:B(`rounded-full border px-1.5 py-[1px] text-[9px]`,WY(y.status)),children:UY(y.status)}):null,y?.previewEligible?(0,g.jsx)(V,{className:`ml-auto`,size:`sm`,variant:`secondary`,leading:(0,g.jsx)(Do,{size:11}),onClick:()=>a({kind:`browser`,resourceId:`browser:${y.id}:/`,browser:{serviceId:y.id,path:`/`,targetKind:`process`},title:`预览 ${y.name??y.executable}`,projectId:t,source:`project`}),children:`预览`}):null,y?.status===`RUNNING`||y?.status===`STARTING`?(0,g.jsx)(V,{className:y.previewEligible?``:`ml-auto`,size:`sm`,variant:`secondary`,leading:(0,g.jsx)(pc,{size:11}),onClick:()=>s(!0),children:`停止`}):null]}),(0,g.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,g.jsx)(Yc,{message:c??(_.isError?`服务读取失败`:null)}),y?(0,g.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[11px]`,children:[(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`命令`}),(0,g.jsx)(`dd`,{className:`truncate font-mono text-ink-2`,children:y.executable}),(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`目录`}),(0,g.jsx)(`dd`,{className:`truncate font-mono text-ink-2`,children:y.cwd}),(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`端口`}),(0,g.jsx)(`dd`,{className:`font-mono text-ink-2`,children:y.port?`127.0.0.1:${y.port}`:`未声明`}),(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`PID`}),(0,g.jsx)(`dd`,{className:`font-mono text-ink-2`,children:y.pid??`—`}),(0,g.jsx)(`dt`,{className:`text-ink-3`,children:`开始`}),(0,g.jsx)(`dd`,{className:`text-ink-2`,children:y.startedAt?new Date(y.startedAt).toLocaleString(`zh-CN`):`—`})]}):null,(0,g.jsx)(`pre`,{role:`log`,"aria-label":`服务输出`,className:`mt-3 max-h-[calc(100dvh-16rem)] min-h-32 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-2 p-2 font-mono text-[10.5px] text-ink-2`,children:f.length>0?f.join(``):`等待服务输出…`})]}),(0,g.jsx)(Xc,{open:o,title:`停止服务?`,description:`将停止该任务及其进程组;未保存的临时状态会丢失。`,confirmLabel:`确认停止`,danger:!0,onCancel:()=>s(!1),onConfirm:()=>void b()})]})}var JY=2,YY=1,XY=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(JY,Math.floor(u/e.css.cell.width)),rows:Math.max(YY,Math.floor(l/e.css.cell.height))}}},ZY=Object.defineProperty,QY=Object.getOwnPropertyDescriptor,$Y=(e,t)=>{for(var n in t)ZY(e,n,{get:t[n],enumerable:!0})},eX=(e,t,n,r)=>{for(var i=r>1?void 0:r?QY(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ZY(t,n,i),i},X=(e,t)=>(n,r)=>t(n,r,e),tX=`Terminal input`,nX={get:()=>tX,set:e=>tX=e},rX=`Too much output to announce, navigate to rows manually to read`,iX={get:()=>rX,set:e=>rX=e};function aX(e){return e.replace(/\r?\n/g,`\r`)}function oX(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function sX(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function cX(e,t,n,r){e.stopPropagation(),e.clipboardData&&lX(e.clipboardData.getData(`text/plain`),t,n,r)}function lX(e,t,n,r){e=aX(e),e=oX(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function uX(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function dX(e,t,n,r,i){uX(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function fX(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function pX(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var mX=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},hX=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},gX=``,_X=` `,vX=class e{constructor(){this.fg=0,this.bg=0,this.extended=new yX}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},yX=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},bX=class e extends vX{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new yX,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?fX(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},xX=`di$target`,SX=`di$dependencies`,CX=new Map;function wX(e){return e[SX]||[]}function TX(e){if(CX.has(e))return CX.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);EX(t,e,r)};return t._id=e,CX.set(e,t),t}function EX(e,t,n){t[xX]===t?t[SX].push({id:e,index:n}):(t[SX]=[{id:e,index:n}],t[xX]=t)}var DX=TX(`BufferService`),OX=TX(`CoreMouseService`),kX=TX(`CoreService`),AX=TX(`CharsetService`),jX=TX(`InstantiationService`),MX=TX(`LogService`),NX=TX(`OptionsService`),PX=TX(`OscLinkService`),FX=TX(`UnicodeService`),IX=TX(`DecorationService`),LX=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new bX,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):RX(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};LX=eX([X(0,DX),X(1,NX),X(2,PX)],LX);function RX(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
112
112
|
|
|
113
113
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var zX=TX(`CharSizeService`),BX=TX(`CoreBrowserService`),VX=TX(`MouseService`),HX=TX(`RenderService`),UX=TX(`SelectionService`),WX=TX(`CharacterJoinerService`),GX=TX(`ThemeService`),KX=TX(`LinkProviderService`),qX=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?$X.isErrorNoTelemetry(e)?new $X(e.message+`
|
|
114
114
|
|
|
@@ -123,7 +123,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
123
123
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),$1&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=S0(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=L1(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-C0),C0),t/=C0,t/Math.abs(t)+Math.round(t*(w0-1)))}shouldForceSelection(e){return Y1?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),T0)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Y1&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<E0&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=c0(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);n?!e||!t||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&t[0]===this._oldSelectionEnd[0]&&t[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,t,n):this._oldHasSelection&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=S0(n,this._bufferService.cols)}};O0=eX([X(3,DX),X(4,kX),X(5,VX),X(6,NX),X(7,HX),X(8,BX)],O0);var k0=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},A0=class{constructor(){this._color=new k0,this._css=new k0}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},j0=Object.freeze((()=>{let e=[a1.toColor(`#2e3436`),a1.toColor(`#cc0000`),a1.toColor(`#4e9a06`),a1.toColor(`#c4a000`),a1.toColor(`#3465a4`),a1.toColor(`#75507b`),a1.toColor(`#06989a`),a1.toColor(`#d3d7cf`),a1.toColor(`#555753`),a1.toColor(`#ef2929`),a1.toColor(`#8ae234`),a1.toColor(`#fce94f`),a1.toColor(`#729fcf`),a1.toColor(`#ad7fa8`),a1.toColor(`#34e2e2`),a1.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:r1.toCss(r,i,a),rgba:r1.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:r1.toCss(n,n,n),rgba:r1.toRgba(n,n,n)})}return e})()),M0=a1.toColor(`#ffffff`),N0=a1.toColor(`#000000`),P0=a1.toColor(`#ffffff`),F0=N0,I0={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},L0=M0,R0=class extends gZ{constructor(e){super(),this._optionsService=e,this._contrastCache=new A0,this._halfContrastCache=new A0,this._onChangeColors=this._register(new Z),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:M0,background:N0,cursor:P0,cursorAccent:F0,selectionForeground:void 0,selectionBackgroundTransparent:I0,selectionBackgroundOpaque:i1.blend(N0,I0),selectionInactiveBackgroundTransparent:I0,selectionInactiveBackgroundOpaque:i1.blend(N0,I0),scrollbarSliderBackground:i1.opacity(M0,.2),scrollbarSliderHoverBackground:i1.opacity(M0,.4),scrollbarSliderActiveBackground:i1.opacity(M0,.5),overviewRulerBorder:M0,ansi:j0.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=z0(e.foreground,M0),t.background=z0(e.background,N0),t.cursor=i1.blend(t.background,z0(e.cursor,P0)),t.cursorAccent=i1.blend(t.background,z0(e.cursorAccent,F0)),t.selectionBackgroundTransparent=z0(e.selectionBackground,I0),t.selectionBackgroundOpaque=i1.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=z0(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=i1.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?z0(e.selectionForeground,n1):void 0,t.selectionForeground===n1&&(t.selectionForeground=void 0),i1.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=i1.opacity(t.selectionBackgroundTransparent,.3)),i1.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=i1.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=z0(e.scrollbarSliderBackground,i1.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=z0(e.scrollbarSliderHoverBackground,i1.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=z0(e.scrollbarSliderActiveBackground,i1.opacity(t.foreground,.5)),t.overviewRulerBorder=z0(e.overviewRulerBorder,L0),t.ansi=j0.slice(),t.ansi[0]=z0(e.black,j0[0]),t.ansi[1]=z0(e.red,j0[1]),t.ansi[2]=z0(e.green,j0[2]),t.ansi[3]=z0(e.yellow,j0[3]),t.ansi[4]=z0(e.blue,j0[4]),t.ansi[5]=z0(e.magenta,j0[5]),t.ansi[6]=z0(e.cyan,j0[6]),t.ansi[7]=z0(e.white,j0[7]),t.ansi[8]=z0(e.brightBlack,j0[8]),t.ansi[9]=z0(e.brightRed,j0[9]),t.ansi[10]=z0(e.brightGreen,j0[10]),t.ansi[11]=z0(e.brightYellow,j0[11]),t.ansi[12]=z0(e.brightBlue,j0[12]),t.ansi[13]=z0(e.brightMagenta,j0[13]),t.ansi[14]=z0(e.brightCyan,j0[14]),t.ansi[15]=z0(e.brightWhite,j0[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=z0(e.extendedAnsi[r],j0[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0)for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];else switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};R0=eX([X(0,NX)],R0);function z0(e,t){if(e!==void 0)try{return a1.toColor(e)}catch{}return t}var B0=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},V0=class{constructor(){this._services=new B0,this._services.set(jX,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=wX(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},H0={trace:0,debug:1,info:2,warn:3,error:4,off:5},U0=`xterm.js: `,W0=class extends gZ{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),G0=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=H0[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:U0)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};W0=eX([X(0,NX)],W0);var G0,K0=class extends gZ{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Z),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Z),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Z),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},q0=3,J0=Object.freeze(new vX),Y0=0,X0=2,Z0=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*q0);let r=t||bX.fromCharData([0,gX,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*q0+0],n=t&2097151;return[this._data[e*q0+1],t&2097152?this._combined[e]:n?fX(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*q0+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*q0+0]=e|2097152|t[2]<<22):this._data[e*q0+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*q0+0]>>22}hasWidth(e){return this._data[e*q0+0]&12582912}getFg(e){return this._data[e*q0+1]}getBg(e){return this._data[e*q0+2]}hasContent(e){return this._data[e*q0+0]&4194303}getCodePoint(e){let t=this._data[e*q0+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*q0+0]&2097152}getString(e){let t=this._data[e*q0+0];return t&2097152?this._combined[e]:t&2097151?fX(t&2097151):``}isProtected(e){return this._data[e*q0+2]&536870912}loadCell(e,t){return Y0=e*q0,t.content=this._data[Y0+0],t.fg=this._data[Y0+1],t.bg=this._data[Y0+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*q0+0]=t.content,this._data[e*q0+1]=t.fg,this._data[e*q0+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*q0+0]=t|n<<22,this._data[e*q0+1]=r.fg,this._data[e*q0+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*q0+0];r&2097152?this._combined[e]+=fX(t):r&2097151?(this._combined[e]=fX(r&2097151)+fX(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*q0+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new bX;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new bX;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r)for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;else for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*X0<this._data.buffer.byteLength;let n=e*q0;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*X0<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*X0<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*q0+0]&4194303)return e+(this._data[e*q0+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*q0+0]&4194303||this._data[e*q0+2]&50331648)return e+(this._data[e*q0+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<q0;e++)this._data[(n+i)*q0+e]=a[(t+i)*q0+e];a[(t+i)*q0+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<q0;e++)this._data[(n+i)*q0+e]=a[(t+i)*q0+e];a[(t+i)*q0+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*q0+0],n=e&2097151,a=e&2097152?this._combined[t]:n?fX(n):_X;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function Q0(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=n2(u,d,t),p=1,m=0;for(;p<u.length;){let e=n2(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function $0(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function e2(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function t2(e,t,n){let r=[],i=e.map((n,r)=>n2(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=n2(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function n2(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var r2=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Z),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),dZ(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};r2._nextId=1;var i2=r2,a2={},o2=a2.B;a2[0]={"`":`◆`,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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},a2.A={"#":`£`},a2.B=void 0,a2[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},a2.C=a2[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},a2.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},a2.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},a2.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},a2.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},a2.E=a2[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},a2.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},a2.H=a2[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},a2[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var s2=4294967295,c2=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=J0.clone(),this.savedCharset=o2,this.markers=[],this._nullCell=bX.fromCharData([0,gX,1,0]),this._whitespaceCell=bX.fromCharData([0,_X,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new i0,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new K0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new yX),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new yX),this._whitespaceCell}getBlankLine(e,t){return new Z0(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>s2?s2:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=J0);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new K0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(J0),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Z0(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new Z0(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=Q0(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(J0),n);if(r.length>0){let n=$0(this.lines,r);e2(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(J0),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Z0(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(J0),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=t2(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(J0,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=n2(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new i2(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},l2=class extends gZ{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Z),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new c2(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c2(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},u2=2,d2=1,f2=class extends gZ{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,u2),this.rows=Math.max(e.rawOptions.rows||0,d2),this.buffers=this._register(new l2(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,r&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};f2=eX([X(0,NX)],f2);var p2={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Y1,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},m2=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],h2=class extends gZ{constructor(e){super(),this._onOptionChange=this._register(new Z),this.onOptionChange=this._onOptionChange.event;let t={...p2};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(pZ(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in p2))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in p2))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=p2[e],!g2(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=p2[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=m2.includes(t)?t:p2[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function g2(e){return e===`block`||e===`underline`||e===`bar`}function _2(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&_2(e[r],t-1);return n}var v2=Object.freeze({insertMode:!1}),y2=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),b2=class extends gZ{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Z),this.onData=this._onData.event,this._onUserInput=this._register(new Z),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Z),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=_2(v2),this.decPrivateModes=_2(y2)}reset(){this.modes=_2(v2),this.decPrivateModes=_2(y2)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};b2=eX([X(0,DX),X(1,MX),X(2,NX)],b2);var x2={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function S2(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var C2=String.fromCharCode,w2={DEFAULT:e=>{let t=[S2(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${C2(t[0])}${C2(t[1])}${C2(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${S2(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${S2(e,!0)};${e.x};${e.y}${t}`}},T2=class extends gZ{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Z),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(x2))this.addProtocol(e,x2[e]);for(let e of Object.keys(w2))this.addEncoding(e,w2[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};T2=eX([X(0,DX),X(1,kX),X(2,NX)],T2);var E2=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],D2=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],O2;function k2(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var A2=class{constructor(){if(this.version=`6`,!O2){O2=new Uint8Array(65536),O2.fill(1),O2[0]=0,O2.fill(0,1,32),O2.fill(0,127,160),O2.fill(2,4352,4448),O2[9001]=2,O2[9002]=2,O2.fill(2,11904,42192),O2[12351]=1,O2.fill(2,44032,55204),O2.fill(2,63744,64256),O2.fill(2,65040,65050),O2.fill(2,65072,65136),O2.fill(2,65280,65377),O2.fill(2,65504,65511);for(let e=0;e<E2.length;++e)O2.fill(0,E2[e][0],E2[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?O2[e]:k2(e,D2)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=j2.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return j2.createPropertyValue(0,n,r)}},j2=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Z,this.onChange=this._onChange.event;let e=new A2;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},M2=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function N2(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var P2=2147483647,F2=256,I2=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>F2)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>P2?P2:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>P2?P2:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,P2):e}},L2=[],R2=class{constructor(){this._state=0,this._active=L2,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=L2}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=L2,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||L2,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,pX(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=L2,this._id=-1,this._state=0}}},z2=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=pX(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},B2=[],V2=class{constructor(){this._handlers=Object.create(null),this._active=B2,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=B2}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=B2,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||B2,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,pX(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=B2,this._ident=0}},H2=new I2;H2.addParam(0);var U2=class{constructor(e){this._handler=e,this._data=``,this._params=H2,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():H2,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=pX(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=H2,this._data=``,this._hitLimit=!1,e));return this._params=H2,this._data=``,this._hitLimit=!1,t}},W2=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},G2=160,K2=function(){let e=new W2(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(G2,0,2,0),e.add(G2,8,5,8),e.add(G2,6,0,6),e.add(G2,11,0,11),e.add(G2,13,13,13),e}(),q2=class extends gZ{constructor(e=K2){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new I2,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(pZ(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new R2),this._dcsParser=this._register(new V2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:G2)],i>>4){case 2:for(let i=n+1;;++i)if(i>=t||(r=e[i])<32||r>126&&r<G2||++i>=t||(r=e[i])<32||r>126&&r<G2||++i>=t||(r=e[i])<32||r>126&&r<G2||++i>=t||(r=e[i])<32||r>126&&r<G2){this._printHandler(e,n,i),n=i-1;break}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<G2){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<G2){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},J2=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,Y2=/^[\da-f]+$/;function X2(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=J2.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),Y2.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function Z2(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function Q2(e,t=16){let[n,r,i]=e;return`rgb:${Z2(n,t)}/${Z2(r,t)}/${Z2(i,t)}`}var $2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},e4=131072,t4=10;function n4(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var r4=5e3,i4=0,a4=class extends gZ{constructor(e,t,n,r,i,a,o,s,c=new q2){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new mX,this._utf8Decoder=new hX,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=J0.clone(),this._eraseAttrDataInternal=J0.clone(),this._onRequestBell=this._register(new Z),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Z),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Z),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Z),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Z),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Z),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Z),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Z),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Z),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new o4(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(Q.BEL,()=>this.bell()),this._parser.setExecuteHandler(Q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Q.BS,()=>this.backspace()),this._parser.setExecuteHandler(Q.HT,()=>this.tab()),this._parser.setExecuteHandler(Q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Y$.IND,()=>this.index()),this._parser.setExecuteHandler(Y$.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Y$.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new z2(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new z2(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new z2(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new z2(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new z2(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new z2(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new z2(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new z2(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new z2(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new z2(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new z2(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new z2(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in a2)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new U2((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),r4))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${r4} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>e4&&(a=this._parseStack.position+e4)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<e4&&(this._parseBuffer=new Uint32Array(Math.min(e.length,e4))),o||this._dirtyRowTracker.clearRange(),e.length>e4)for(let t=a;t<e.length;t+=e4){let a=t+e4<e.length?t+e4:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=j2.extractWidth(t);let n=j2.extractShouldJoin(t),m=n?j2.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(fX(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof Z0&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}else if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!n4(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new U2(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new z2(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(J0));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=j2.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(Q.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(Q.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(Q.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(Q.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(Q.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,o2),this._charsetService.setgCharset(1,o2),this._charsetService.setgCharset(2,o2),this._charsetService.setgCharset(3,o2);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${Q.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=vX.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=J0.fg,e.bg=J0.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=J0.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=J0.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=J0.fg&16777215,r.bg&=-67108864,r.bg|=J0.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Q.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=J0.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!n4(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>t4&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>t4&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(s4(n)){if(r===`?`)t.push({type:0,index:n});else{let e=X2(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=X2(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);s4(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,o2),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset($2[e[0]],a2[e[1]]||o2),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=J0.clone(),this._eraseAttrDataInternal=J0.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new bX;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${Q.ESC}${e}${Q.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},o4=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(i4=e,e=t,t=i4),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};o4=eX([X(0,DX)],o4);function s4(e){return 0<=e&&e<256}var c4=5e7,l4=12,u4=50,d4=class extends gZ{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>c4)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=l4?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=l4)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>u4&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},f4=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};f4=eX([X(0,DX)],f4);var p4=!1,m4=class extends gZ{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new _Z),this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onData=this._register(new Z),this.onData=this._onData.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Z),this._instantiationService=new V0,this.optionsService=this._register(new h2(e)),this._instantiationService.setService(NX,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(f2)),this._instantiationService.setService(DX,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(W0)),this._instantiationService.setService(MX,this._logService),this.coreService=this._register(this._instantiationService.createInstance(b2)),this._instantiationService.setService(kX,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(T2)),this._instantiationService.setService(OX,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(j2)),this._instantiationService.setService(FX,this.unicodeService),this._charsetService=this._instantiationService.createInstance(M2),this._instantiationService.setService(AX,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(f4),this._instantiationService.setService(PX,this._oscLinkService),this._inputHandler=this._register(new a4(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(wZ.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(wZ.forward(this._bufferService.onResize,this._onResize)),this._register(wZ.forward(this.coreService.onData,this._onData)),this._register(wZ.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new d4((e,t)=>this._inputHandler.parse(e,t))),this._register(wZ.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Z),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!p4&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),p4=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,u2),t=Math.max(t,d2),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(N2.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(N2(this._bufferService),!1))),this._windowsWrappingHeuristics.value=pZ(()=>{for(let t of e)t.dispose()})}}},h4={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function g4(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?Q.ESC+`OA`:Q.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?Q.ESC+`OD`:Q.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?Q.ESC+`OC`:Q.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?Q.ESC+`OB`:Q.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:Q.DEL,e.altKey&&(i.key=Q.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Q.ESC+`[Z`;break}i.key=Q.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Q.ESC+Q.CR:Q.CR,i.cancel=!0;break;case 27:i.key=Q.ESC,e.altKey&&(i.key=Q.ESC+Q.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`D`:t?Q.ESC+`OD`:Q.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`C`:t?Q.ESC+`OC`:Q.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`A`:t?Q.ESC+`OA`:Q.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`B`:t?Q.ESC+`OB`:Q.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Q.ESC+`[2~`);break;case 46:i.key=a?Q.ESC+`[3;`+(a+1)+`~`:Q.ESC+`[3~`;break;case 36:i.key=a?Q.ESC+`[1;`+(a+1)+`H`:t?Q.ESC+`OH`:Q.ESC+`[H`;break;case 35:i.key=a?Q.ESC+`[1;`+(a+1)+`F`:t?Q.ESC+`OF`:Q.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?Q.ESC+`[5;`+(a+1)+`~`:Q.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?Q.ESC+`[6;`+(a+1)+`~`:Q.ESC+`[6~`;break;case 112:i.key=a?Q.ESC+`[1;`+(a+1)+`P`:Q.ESC+`OP`;break;case 113:i.key=a?Q.ESC+`[1;`+(a+1)+`Q`:Q.ESC+`OQ`;break;case 114:i.key=a?Q.ESC+`[1;`+(a+1)+`R`:Q.ESC+`OR`;break;case 115:i.key=a?Q.ESC+`[1;`+(a+1)+`S`:Q.ESC+`OS`;break;case 116:i.key=a?Q.ESC+`[15;`+(a+1)+`~`:Q.ESC+`[15~`;break;case 117:i.key=a?Q.ESC+`[17;`+(a+1)+`~`:Q.ESC+`[17~`;break;case 118:i.key=a?Q.ESC+`[18;`+(a+1)+`~`:Q.ESC+`[18~`;break;case 119:i.key=a?Q.ESC+`[19;`+(a+1)+`~`:Q.ESC+`[19~`;break;case 120:i.key=a?Q.ESC+`[20;`+(a+1)+`~`:Q.ESC+`[20~`;break;case 121:i.key=a?Q.ESC+`[21;`+(a+1)+`~`:Q.ESC+`[21~`;break;case 122:i.key=a?Q.ESC+`[23;`+(a+1)+`~`:Q.ESC+`[23~`;break;case 123:i.key=a?Q.ESC+`[24;`+(a+1)+`~`:Q.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=Q.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Q.DEL:e.keyCode===219?i.key=Q.ESC:e.keyCode===220?i.key=Q.FS:e.keyCode===221&&(i.key=Q.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=h4[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=Q.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=Q.ESC+n}else if(e.keyCode===32)i.key=Q.ESC+(e.ctrlKey?Q.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=Q.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=Q.US),e.key===`@`&&(i.key=Q.NUL))}return i}var _4=0,v4=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new i0,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new i0,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(_4=this._search(t),_4===-1)||this._getKey(this._array[_4])!==t)return!1;do if(this._array[_4]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(_4),!0;while(++_4<this._array.length&&this._getKey(this._array[_4])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(_4=this._search(e),!(_4<0||_4>=this._array.length)&&this._getKey(this._array[_4])===e))do yield this._array[_4];while(++_4<this._array.length&&this._getKey(this._array[_4])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(_4=this._search(e),!(_4<0||_4>=this._array.length)&&this._getKey(this._array[_4])===e))do t(this._array[_4]);while(++_4<this._array.length&&this._getKey(this._array[_4])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},y4=0,b4=0,x4=class extends gZ{constructor(){super(),this._decorations=new v4(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Z),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Z),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(pZ(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new S4(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{y4=t.options.x??0,b4=y4+(t.options.width??1),e>=y4&&e<b4&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},S4=class extends hZ{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Z),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Z),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?a1.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?a1.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},C4=1e3,w4=class{constructor(e,t=C4){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},T4=20,E4=class extends gZ{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new w4(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
124
124
|
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(QQ(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(pZ(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<T4+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
125
125
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===T4+1&&(this._liveRegion.textContent+=iX.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};E4=eX([X(1,jX),X(2,BX),X(3,HX)],E4);var D4=class extends gZ{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Z),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Z),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(pZ(()=>{dZ(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(QQ(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(QQ(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(QQ(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(QQ(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){this._activeLine!==e.y||this._wasResized?(this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1):this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){this._activeProviderReplies&&t||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&O4(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,dZ(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};D4=eX([X(1,VX),X(2,HX),X(3,DX),X(4,KX)],D4);function O4(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var k4=class extends m4{constructor(e={}){super(e),this._linkifier=this._register(new _Z),this.browser=V1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new _Z),this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Z),this.onKey=this._onKey.event,this._onRender=this._register(new Z),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Z),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Z),this.onBell=this._onBell.event,this._onFocus=this._register(new Z),this._onBlur=this._register(new Z),this._onA11yCharEmitter=this._register(new Z),this._onA11yTabEmitter=this._register(new Z),this._onWillOpen=this._register(new Z),this._setup(),this._decorationService=this._instantiationService.createInstance(x4),this._instantiationService.setService(IX,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(I1),this._instantiationService.setService(KX,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(LX)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(wZ.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(wZ.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(wZ.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(wZ.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(pZ(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=i1.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${Q.ESC}]${n};${Q2(r)}${X$.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=r1.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=r1.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(E4,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(QQ(this.element,`copy`,e=>{this.hasSelection()&&sX(e,this._selectionService)}));let e=e=>cX(e,this.textarea,this.coreService,this.optionsService);this._register(QQ(this.textarea,`paste`,e)),this._register(QQ(this.element,`paste`,e)),G1?this._register(QQ(this.element,`mousedown`,e=>{e.button===2&&dX(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(QQ(this.element,`contextmenu`,e=>{dX(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),$1&&this._register(QQ(this.element,`auxclick`,e=>{e.button===1&&uX(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(QQ(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(QQ(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(QQ(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(QQ(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(QQ(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(QQ(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(QQ(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(QQ(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,nX.get()),e0||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(P1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(BX,this._coreBrowserService),this._register(QQ(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(QQ(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(A1,this._document,this._helperContainer),this._instantiationService.setService(zX,this._charSizeService),this._themeService=this._instantiationService.createInstance(R0),this._instantiationService.setService(GX,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(d1),this._instantiationService.setService(WX,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(o0,this.rows,this.screenElement)),this._instantiationService.setService(HX,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Z$,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(z1),this._instantiationService.setService(VX,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(D4,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(H$,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(O0,this.element,this.screenElement,r)),this._instantiationService.setService(UX,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(wZ.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(U$,this.screenElement)),this._register(QQ(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(E4,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(J$,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(J$,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(k1,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(QQ(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(QQ(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=Q.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){lX(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=g4(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Q.ETX||n.key===Q.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(A4(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(J0));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(Q.ESC+`[I`):this.coreService.triggerDataEvent(Q.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function A4(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var j4=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},M4=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new bX)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},N4=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new M4(t)}getNullCell(){return new bX}},P4=class extends gZ{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Z),this.onBufferChange=this._onBufferChange.event,this._normal=new N4(this._core.buffers.normal,`normal`),this._alternate=new N4(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},F4=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},I4=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},L4=[`cols`,`rows`],R4=0,z4=class extends gZ{constructor(e){super(),this._core=this._register(new k4(e)),this._addonManager=this._register(new j4),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(L4.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new F4(this._core),this._parser}get unicode(){return this._checkProposedApi(),new I4(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new P4(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
126
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return nX.get()},set promptLabel(e){nX.set(e)},get tooMuchOutput(){return iX.get()},set tooMuchOutput(e){iX.set(e)}}}_verifyIntegers(...e){for(R4 of e)if(R4===1/0||isNaN(R4)||R4%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(R4 of e)if(R4&&(R4===1/0||isNaN(R4)||R4%1!=0||R4<0))throw Error(`This API only accepts positive integers`)}},B4=(0,h.createContext)(null);function V4({children:e,windows:t}){let[n]=(0,h.useState)(()=>new Map);return(0,h.useEffect)(()=>{if(!n.size)return;let e=new Set(t.flatMap(e=>e.tabs.map(e=>e.id)));for(let[t,r]of n)e.has(t)||(r.terminal.dispose(),n.delete(t))},[n,t]),(0,h.useEffect)(()=>()=>{for(let e of n.values())e.terminal.dispose();n.clear()},[n]),(0,g.jsx)(B4.Provider,{value:n,children:e})}function H4(){let e=(0,h.useContext)(B4);if(!e)throw Error(`Terminal screen provider is missing`);return e}function U4(){let e=new z4({fontSize:12,fontFamily:`ui-monospace, Menlo, monospace`,cursorBlink:!0,scrollback:2e3,disableStdin:!0,theme:{background:`#0f1115`,foreground:`#d7dae0`}}),t=new XY;return e.loadAddon(t),{terminal:e,fit:t,cursor:0,log:``,gap:!1,ready:!1,pendingWrite:Promise.resolve()}}var W4={CREATED:`正在创建`,RUNNING:`运行中`,STOPPING:`正在终止`,EXITED:`已退出`,TERMINATED:`已终止`,INTERRUPTED:`已中断`};function G4({id:e,tabId:t,visible:n}){let r=H4(),i=Zg({queryKey:UK(e),queryFn:()=>KK(e),enabled:n,staleTime:0,refetchOnMount:`always`,refetchInterval:2e3}),a=i.data?WK(i.data.status):!1,o=i.isFetchedAfterMount&&i.isSuccess,[s,c]=(0,h.useState)(!1);(0,h.useEffect)(()=>{o&&c(!0)},[o]);let l=(o||s)&&!!i.data&&!a,u=i.data?GK(i.data):null;(0,h.useEffect)(()=>{if(u===null)return;let t=FM.getState();t.windows.some(t=>t.tabs.some(t=>t.resourceId===e&&t.title!==u))&&FM.setState({windows:t.windows.map(t=>({...t,tabs:t.tabs.map(t=>t.resourceId===e&&t.title!==u?{...t,title:u}:t)}))})},[e,u]);let d=(0,h.useRef)(i.data);d.current=i.data;let f=(0,h.useRef)(null),p=(0,h.useRef)(null),m=(0,h.useRef)(null),_=(0,h.useRef)(!1),[v,y]=(0,h.useState)(null);(0,h.useEffect)(()=>{y(document.getElementById(`terminal-controls-${t}`))},[t]);let[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(null),[w,T]=(0,h.useState)(``),[E,D]=(0,h.useState)(``),[O,k]=(0,h.useState)(!1),[A,j]=(0,h.useState)(``),[M,N]=(0,h.useState)(!0),[ee,te]=(0,h.useState)(!1),[P,F]=(0,h.useState)(Date.now()),ne=i.data?.lease,I=n&&!!S&&ne?.ownerConnectionId===S&&ne.expiresAt>P&&i.data?.status===`RUNNING`&&!i.isError,re=I&&b,ie=ne?.ownerType===`agent`&&ne.expiresAt>P&&i.data?.status===`RUNNING`&&!i.isError;(0,h.useLayoutEffect)(()=>{if(a){r.get(t)?.terminal.dispose(),r.delete(t),j(``);return}let e=f.current;if(!l||!e)return;let n=r.get(t)??U4();r.set(t,n),p.current=n;let i=n.terminal;return i.element?e.appendChild(i.element):i.open(e),k(n.gap),j(n.ready?n.log:``),N(!n.ready),()=>{p.current=null,i.element?.remove()}},[r,l,t,a]),(0,h.useLayoutEffect)(()=>{C(null),x(!1);let t=f.current,r=p.current;if(!n||!l||!t||!r)return;let{terminal:i,fit:a}=r;i.options.cursorBlink=!0,_.current=!1;let o=!1,s=!1,c=500,u,h,g=null,v=null,y=0,b=null,S=null,w=[],E=0;T(``);let D=()=>o?Promise.resolve():aM.invalidateQueries({queryKey:UK(e)}),O=()=>{let e=d.current;return!!g&&!!v&&e?.status===`RUNNING`&&e.lease?.ownerConnectionId===g&&e.lease.generation===v&&e.lease.expiresAt>Date.now()&&u?.readyState===WebSocket.OPEN},A=()=>{v=null,x(!1),S=null,w=[],E=0,i.options.disableStdin=!0},M=()=>{if(!O()||S!==null||!w.length)return;let t=w.shift();t!==void 0&&(E-=new TextEncoder().encode(t).length,S=++y,u?.send(JSON.stringify({type:`terminal.input`,terminalId:e,leaseGeneration:v,inputSequence:S,data:t})))},ee=i.onData(e=>{if(!O())return;let t=new TextEncoder().encode(e).length;t>8192||E+t>32768?T(`输入过大,请分段粘贴(单次最多 8 KiB)。`):(w.push(e),E+=t,M())}),te=()=>{r.ready||(r.ready=!0,j(r.log),N(!1))},P=async()=>{if(!(s||o)){s=!0;try{await r.pendingWrite;for(let t=0;t<8&&!o;t++){let t=KA.parse(await Y(`/api/terminals/${encodeURIComponent(e)}/output?after=${r.cursor}&limit=100`));if(o)return;r.gap||=t.resyncRequired||t.truncated;let n=r.cursor,a=[];for(let e of t.chunks)e.cursor<=n||(e.cursor!==n+1&&(r.gap=!0),a.push(e.data),n=e.cursor);r.gap&&k(!0);let s=Math.max(n,t.nextCursor);if(!a.length){r.cursor=s,te();break}let c=a.join(``);r.pendingWrite=new Promise(e=>{i.write(c,()=>{r.cursor=s,r.log=(r.log+c).slice(-16384),e()})}),await r.pendingWrite,!o&&r.ready&&j(r.log)}}catch{o||(T(`输出读取失败,正在重试;历史可能不完整。`),te())}finally{s=!1}}},ne,I=()=>{clearTimeout(ne),ne=setTimeout(()=>{!o&&t.clientWidth&&t.clientHeight&&(a.fit(),O()&&YK(e,`resize`,{connectionId:g,leaseGeneration:v,cols:Math.max(2,Math.min(500,i.cols)),rows:Math.max(1,Math.min(300,i.rows))}).catch(()=>{o||(A(),D(),T(`尺寸同步失败,请重新获取输入权。`))}))},100)},re=new ResizeObserver(I);re.observe(t),I();let ie=()=>{if(o)return;let t=new URL(`/ws`,location.href);t.protocol=t.protocol===`https:`?`wss:`:`ws:`;let n=new WebSocket(t);u=n,n.onopen=()=>n.send(JSON.stringify({type:`subscribe`,subscriptions:[{topic:`terminal`,resourceId:e,after:0}]})),n.onmessage=t=>{if(o||u!==n)return;let r;try{r=JSON.parse(String(t.data))}catch{A(),T(`终端响应无效,请刷新。`);return}let i=qA.safeParse(r);if(i.success&&i.data.subscription.resourceId===e){g=i.data.connectionId,c=500,D().then(()=>{!o&&u===n&&n.readyState===WebSocket.OPEN&&C(g)}),P();return}let a=JA.safeParse(r);if(a.success&&S===a.data.inputSequence){S=null,M();return}let s=WA.safeParse(r);if(s.success&&s.data.resourceId===e){(s.data.payload.lease?.generation!==v||s.data.payload.lease?.ownerConnectionId!==g||s.data.payload.status!==`RUNNING`)&&A(),D(),P();return}if(VA.safeParse(r).success){P();return}let l=YA.safeParse(r);l.success&&(A(),D(),T(`终端操作被拒绝(${l.data.code}),请重新获取输入权。`))},n.onclose=()=>{o||(g=null,C(null),A(),D(),T(`连接已断开,正在重连;不会重放输入。`),h=setTimeout(ie,c),c=Math.min(c*2,1e4))}},ae=t=>{t.lease&&(d.current=t,aM.setQueryData(UK(e),t),v=t.lease.generation,b!==v&&(y=0),b=v,x(!0),S=null,i.options.disableStdin=!1,i.focus(),I(),T(``))};m.current={acquire:async()=>{if(!g)throw Error(`Disconnected`);let t=g,n=await YK(e,`lease`,{action:`acquire`,connectionId:t});o||g!==t||n.lease?.ownerConnectionId!==t||ae(n)},takeover:async()=>{if(!g)throw Error(`Disconnected`);let t=g,n=await YK(e,`takeover`,{connectionId:t});o||g!==t||n.lease?.ownerConnectionId!==t||ae(n)},release:async()=>{let t=d.current?.lease,n=t?.ownerConnectionId===g?t?.generation:v;A(),g&&n&&await YK(e,`lease`,{action:`release`,connectionId:g,leaseGeneration:n})}};let oe=setInterval(()=>{if(!O())return;let t=g,n=v;YK(e,`lease`,{action:`renew`,connectionId:g,leaseGeneration:v}).then(r=>{!o&&t===g&&n===v&&(d.current=r,aM.setQueryData(UK(e),r))}).catch(()=>{o||(A(),D(),T(`输入租约续期失败,请重新获取输入权。`))})},1e4),se=setInterval(()=>{F(Date.now()),i.options.disableStdin=!O(),O()||x(!1),P()},1e3);return ie(),()=>{o=!0,m.current=null,clearTimeout(h),clearTimeout(ne),clearInterval(oe),clearInterval(se),re.disconnect(),ee.dispose(),u?.close(),i.options.disableStdin=!0,i.options.cursorBlink=!1,i.blur()}},[e,l,n]),(0,h.useEffect)(()=>{if(!n||M||!S||!i.data||i.data.status!==`RUNNING`||i.isError||_.current||(_.current=!0,i.data.mode!==`shell`||i.data.lease&&i.data.lease.expiresAt>Date.now()))return;let t=!1;return te(!0),m.current?.acquire().catch(()=>{t||aM.invalidateQueries({queryKey:UK(e)})}).finally(()=>{t||te(!1)}),()=>{t=!0,te(!1)}},[S,e,i.data,i.isError,M,n]);let ae=async e=>{te(!0),T(``),D(``);try{await e()}catch{D(`终端操作失败,请刷新状态后重试。`)}finally{te(!1)}};return(0,g.jsxs)(`div`,{"data-testid":`live-terminal`,"data-terminal-id":e,"data-input-state":re?`active`:ie?`agent`:`inactive`,className:`flex h-full min-h-0 flex-col bg-[#0f1115] text-white/80`,children:[v?(0,en.createPortal)((0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsx)(`button`,{type:`button`,"aria-label":`终端操作`,title:`终端操作`,className:`flex w-7 items-center justify-center text-ink-3 hover:bg-surface-2 hover:text-ink`,children:(0,g.jsx)(To,{size:14})})}),(0,g.jsx)(sm,{onCloseAutoFocus:e=>{e.preventDefault(),re&&f.current?.querySelector(`.xterm-helper-textarea`)?.focus()},children:(0,g.jsx)(lm,{"aria-label":I?`释放输入权`:ie?`接管控制`:`获取输入权`,disabled:ee||M||!S||!i.data||i.isError||i.data.status!==`RUNNING`||!I&&!ie&&!!ne&&ne.expiresAt>P,onSelect:()=>void ae(async()=>{I?await m.current?.release():ie?await m.current?.takeover():await m.current?.acquire()}),children:I?`交给 AI`:ie?`接管控制`:`输入终端`})})]}),v):null,i.data&&i.data.status!==`RUNNING`?(0,g.jsx)(`p`,{role:`status`,className:`px-2 text-xs`,children:W4[i.data.status]}):null,i.data?.reasonCode?(0,g.jsxs)(`p`,{className:`px-2 text-xs`,children:[`状态原因:`,i.data.reasonCode]}):null,i.data?.exitCode!==null&&i.data?.exitCode!==void 0?(0,g.jsxs)(`p`,{className:`px-2 text-xs`,children:[`退出码 `,i.data.exitCode]}):null,!a&&O?(0,g.jsx)(`p`,{role:`status`,className:`px-2 text-xs text-amber-300`,children:`部分历史输出已过期或缺失,当前回放不完整。`}):null,i.isError||!a&&w?(0,g.jsx)(`p`,{role:`alert`,className:`px-2 text-xs text-red-300`,children:!a&&w||`终端不可用,请刷新核对;不会自动重建。`}):null,(0,g.jsx)(Yc,{message:!a&&n?E:null,onDismiss:()=>D(``)}),l?(0,g.jsxs)(g.Fragment,{children:[M?(0,g.jsx)(`p`,{role:`status`,className:`px-2 pt-2 text-xs text-white/60`,children:`正在恢复终端输出…`}):null,(0,g.jsx)(`div`,{ref:f,role:`application`,"aria-label":`交互终端`,className:B(`min-h-0 flex-1 p-2`,M&&`invisible`),onPointerDown:()=>{!I&&!ie&&S&&!ee&&(!ne||ne.expiresAt<=Date.now())&&i.data?.status===`RUNNING`&&ae(async()=>{await m.current?.acquire()})}}),(0,g.jsx)(`pre`,{role:`log`,"aria-label":`终端输出`,"aria-live":`off`,className:`sr-only`,children:A})]}):null]})}function K4({scope:e,label:t=`新建终端`,children:n,className:r}){let[i,a]=(0,h.useState)(null),[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(``);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":t,title:`新建终端`,className:r,onClick:()=>{l(``),a({key:crypto.randomUUID(),scope:e})},children:n??`新建终端`}),(0,g.jsx)(Xc,{open:i!==null,title:`创建终端确认`,description:`终端以本机账户权限运行,可访问项目外文件。`,confirmLabel:`确认创建`,pendingLabel:`正在创建…`,pending:o,error:c,onDismissError:()=>l(``),onCancel:()=>a(null),onConfirm:async()=>{if(i&&!o){s(!0),l(``);try{XK(await JK(i.scope,i.key)),a(null),aM.invalidateQueries({queryKey:[`terminals`]}),aM.invalidateQueries({queryKey:[`workspace`]})}catch{l(`创建结果未确认,请重试核对;重试不会重复创建。`)}finally{s(!1)}}}})]})}function q4(e,t){return`projectId`in t&&t.projectId!==`prj_default`?e.projectId===t.projectId:`sessionId`in t?e.workspaceSessionId===t.sessionId:!e.projectId&&!e.workspaceSessionId}async function J4(e,t){let n=[],r=new Set,i;do{t.throwIfAborted();let a=await qK(i,e);if(n.push(...a.items.filter(t=>t.status===`RUNNING`&&q4(t,e))),i=a.nextCursor??void 0,i){if(r.has(i))throw Error(`Repeated terminal cursor`);r.add(i)}}while(i);for(let r of n.reverse()){t.throwIfAborted();let n=await KK(r.id).catch(e=>{if(e instanceof fj&&e.status===404)return null;throw e});if(n){if(n.id!==r.id||!q4(n,e))throw Error(`Terminal scope changed`);if(n.status===`RUNNING`)return n}}return null}function Y4({projectId:e,sessionId:t,visible:n=!0}){let r=e?{projectId:e}:t?{sessionId:t}:{workspace:`default`},{data:i,isFetchedAfterMount:a,isError:o,isFetching:s,refetch:c}=Zg({queryKey:[`terminals`,`restore`,e,t],queryFn:({signal:e})=>J4(r,e),enabled:n,staleTime:0,refetchOnMount:`always`,refetchOnWindowFocus:!1});return(0,h.useEffect)(()=>{n&&i&&a&&!o&&!s&&XK(i)},[i,a,o,s,n]),(0,g.jsx)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-3 text-[12px] text-ink`,children:o&&!s?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{role:`alert`,className:`text-ink-3`,children:`无法恢复终端,请重试。`}),(0,g.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>void c(),children:`重试`}),(0,g.jsx)(K4,{scope:r,className:`text-accent`})]}):!a||s||i?(0,g.jsx)(`p`,{role:`status`,className:`text-ink-3`,children:`正在读取终端…`}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dc,{size:24,"aria-hidden":`true`,className:`text-ink-3/50`}),(0,g.jsx)(`p`,{className:`text-ink-3`,children:`暂无运行中的终端`}),(0,g.jsx)(K4,{scope:r,className:`rounded-lg bg-accent px-3 py-1.5 text-white`})]})})}function X4({tab:e,visible:t}){return e.resourceId===`terminal:empty`?(0,g.jsx)(Y4,{projectId:e.projectId,sessionId:e.sourceSessionId??void 0,visible:t}):(0,g.jsx)(G4,{id:e.resourceId,tabId:e.id,visible:t},e.id)}function Z4({tab:e,visible:t}){if(!e)return null;switch(e.kind){case`files`:return(0,g.jsx)(VY,{tab:e});case`terminal`:return(0,g.jsx)(X4,{tab:e,visible:t});case`services`:return(0,g.jsx)(GY,{tab:e});case`browser`:return(0,g.jsx)(MY,{tab:e});case`git-diff`:return(0,g.jsx)(LY,{tab:e});default:return null}}function Q4({kind:e,path:t}){return e===`files`?(0,g.jsx)(pW,{path:t,size:14}):(0,g.jsx)(e===`terminal`?dc:e===`services`?rc:e===`browser`?Co:Xo,{size:11.5,className:`shrink-0 text-ink-3`})}function $4(e,t,n){return e?n??e:t===`session`?`独立会话`:`默认工作区`}function e3({window:e}){let[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(``),a=yM(e=>e.saving),o=yM(e=>e.drafts),s=FM(e=>e.setActiveTab),c=FM(e=>e.closeTab),{data:l}=sM(),u=CM(e.tabs,e.filter),d=wM(u,e.activeTabId)?.id,f=u.filter(e=>e.kind!==`terminal`||e.resourceId!==`terminal:empty`),p=e.tabs[0]?.kind,m=(0,h.useRef)(null),[_,v]=(0,h.useState)(!1),[y,b]=(0,h.useState)(null);return(0,h.useEffect)(()=>{let t=m.current;if(!t||!e.tabs.length)return;let n=()=>v(t.scrollWidth>t.clientWidth+1),r=new ResizeObserver(n);return r.observe(t),n(),t.querySelector(`[data-tab-id="${d}"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`}),()=>r.disconnect()},[e.tabs,d]),(0,g.jsxs)(`div`,{className:`relative flex h-8 shrink-0 items-stretch border-b border-line bg-surface-2/35`,children:[(0,g.jsx)(Yc,{message:r,onDismiss:()=>i(``)}),_?(0,g.jsx)(`button`,{type:`button`,"aria-label":`向左滚动 Tab`,className:`shrink-0 px-1 text-ink-3 hover:text-ink`,onClick:()=>m.current?.scrollBy({left:-180,behavior:`smooth`}),children:(0,g.jsx)(Qa,{size:13})}):null,(0,g.jsx)(`div`,{ref:m,role:`tablist`,"aria-label":`窗口 Tab`,onKeyDown:t=>{if(!(t.target instanceof HTMLElement)||t.target.getAttribute(`role`)!==`tab`)return;let n=f.findIndex(e=>e.id===d),r=t.key===`ArrowRight`?(n+1)%f.length:t.key===`ArrowLeft`?(n-1+f.length)%f.length:t.key===`Home`?0:t.key===`End`?f.length-1:-1,i=f[r];i&&(t.preventDefault(),s(e.id,i.id),m.current?.querySelector(`[data-tab-id="${i.id}"]`)?.focus())},className:`window-tabs-scroll flex h-8 min-w-0 flex-1 items-end gap-0.5 overflow-x-auto overflow-y-hidden px-2`,onWheel:e=>{m.current&&Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(m.current.scrollLeft+=e.deltaY)},children:f.map(r=>{let u=r.id===d,f=l.projects.find(e=>e.id===r.projectId)??null,p=$4(r.projectId,r.originType,f?.name);return(0,g.jsx)(`div`,{className:`flex shrink-0 items-end`,children:(0,g.jsxs)(`div`,{className:B(`group flex h-7 max-w-[220px] shrink-0 items-center gap-1.5 rounded-t-[8px] border border-b-0 px-2.5 text-[10.5px] transition-colors`,u?`border-line bg-surface text-ink`:`border-transparent text-ink-3 hover:bg-black/[.03] hover:text-ink-2 dark:hover:bg-white/[.04]`),children:[y?.id===r.id?(0,g.jsx)(`form`,{onSubmit:async e=>{e.preventDefault();try{await YK(r.resourceId,`rename`,{title:y.title}),b(null)}catch{i(`改名失败,请重试。`)}},children:(0,g.jsx)(mm,{ref:e=>e?.focus(),"aria-label":`终端名称`,maxLength:80,value:y.title,onChange:e=>b({...y,title:e.target.value}),onKeyDown:e=>{e.key===`Escape`&&b(null)},className:`h-5 w-32 border-accent/40 px-1 text-[11px]`})}):(0,g.jsxs)(`button`,{type:`button`,"data-tab-id":r.id,role:`tab`,"aria-selected":u,onDoubleClick:()=>{r.preview&&FM.getState().keepFileTab(r.id),r.kind===`terminal`&&r.resourceId.startsWith(`term_`)&&b({id:r.id,title:r.title})},onKeyDown:e=>{e.key===`F2`&&r.kind===`terminal`&&r.resourceId.startsWith(`term_`)&&(e.preventDefault(),b({id:r.id,title:r.title}))},onClick:()=>s(e.id,r.id),title:`${p} · ${r.title}${r.kind===`terminal`?` · 双击或 F2 改名`:r.preview?` · 预览,双击保留`:``}`,className:`flex min-w-0 flex-1 items-center gap-1.5 focus-visible:outline-none`,children:[(0,g.jsx)(Q4,{kind:r.kind,path:r.file?.path??r.title}),(0,g.jsxs)(`span`,{className:B(`truncate`,r.preview&&`italic`),children:[r.title,o[r.resourceId]?` ●`:``]})]}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭 ${r.title}`,disabled:!!t||(a[r.resourceId]??!1),onClick:async t=>{if(t.stopPropagation(),r.kind===`terminal`&&r.resourceId!==`terminal:empty`){n(r.id),i(``);try{let t=await KK(r.resourceId);if(!$K(WK(t.status)?t:await YK(r.resourceId,`terminate`,{confirmed:!0})))throw Error(`Termination unconfirmed`);c(e.id,r.id)}catch{i(`终止未确认,已保留 Tab;请核对状态后重试。`)}finally{n(null)}}else r.file&&o[r.resourceId]?yM.setState({closeRequest:{windowId:e.id,tabId:r.id}}):c(e.id,r.id)},className:`window-no-drag rounded p-0.5 text-ink-3 opacity-70 transition-opacity hover:bg-black/[.06] hover:text-ink group-hover:opacity-100 dark:hover:bg-white/[.08]`,children:(0,g.jsx)(Ac,{size:10})})]})},r.id)})}),_?(0,g.jsx)(`button`,{type:`button`,"aria-label":`向右滚动 Tab`,className:`shrink-0 px-1 text-ink-3 hover:text-ink`,onClick:()=>m.current?.scrollBy({left:180,behavior:`smooth`}),children:(0,g.jsx)(eo,{size:13})}):null,p===`terminal`?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{id:`terminal-controls-${d}`,className:`flex shrink-0`}),(0,g.jsx)(K4,{label:`新建终端 Tab`,className:`flex w-8 shrink-0 items-center justify-center text-ink-3 hover:bg-surface-2 hover:text-ink`,scope:e.tabs[0]?.projectId?{projectId:e.tabs[0].projectId}:e.tabs[0]?.originType===`session`&&e.tabs[0].sourceSessionId?{sessionId:e.tabs[0].sourceSessionId}:{workspace:`default`},children:(0,g.jsx)(Us,{size:14})})]}):null]})}function t3({window:e}){let t=FM(e=>e.focus),n=FM(e=>e.close),r=FM(e=>e.hide),i=FM(e=>e.toggleMaximize),a=FM(e=>e.togglePin),o=FM(e=>e.setBounds),{data:s}=sM(),c=wM(CM(e.tabs,e.filter),e.activeTabId),l=AY(c,s);return(0,g.jsxs)(kY,{bounds:`parent`,dragHandleClassName:`window-drag-handle`,cancel:`.window-no-drag`,disableDragging:e.maximized,enableResizing:!e.maximized,minWidth:420,minHeight:280,size:e.maximized?{width:`100%`,height:`100%`}:{width:e.width,height:e.height},position:e.maximized?{x:0,y:0}:{x:e.x,y:e.y},onMouseDown:()=>t(e.id),onDragStop:(t,n)=>o(e.id,{x:n.x,y:n.y,width:e.width,height:e.height}),onResizeStop:(t,n,r,i,a)=>o(e.id,{x:a.x,y:a.y,width:r.offsetWidth,height:r.offsetHeight}),style:{zIndex:e.z,display:e.minimized?`none`:`flex`,flexDirection:`column`},inert:e.minimized,"data-window-frame":e.id,role:`dialog`,"aria-label":l,className:B(`pointer-events-auto flex flex-col overflow-hidden border border-line bg-surface window-shadow`,e.maximized?`rounded-none`:`rounded-xl`),children:[(0,g.jsxs)(`div`,{className:`window-drag-handle flex h-10 shrink-0 items-center gap-2 border-b border-line bg-surface-2/55 px-3`,children:[(0,g.jsxs)(`div`,{className:`window-no-drag group/traffic flex items-center gap-1.5`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭窗口`,title:`关闭窗口`,onClick:()=>n(e.id),className:`flex h-3 w-3 items-center justify-center rounded-full bg-[#ff5f57] text-[8px] text-[#6b0d08] opacity-95 transition-opacity hover:brightness-95`,children:(0,g.jsx)(Ac,{size:7,strokeWidth:2.8,className:`opacity-0 group-hover/traffic:opacity-100`})}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`隐藏窗口`,title:`隐藏窗口`,onClick:()=>r(e.id),className:`flex h-3 w-3 items-center justify-center rounded-full bg-[#febc2e] text-[8px] text-[#6b4b00] opacity-95 transition-opacity hover:brightness-95`,children:(0,g.jsx)(Cs,{size:7,strokeWidth:3,className:`opacity-0 group-hover/traffic:opacity-100`})}),(0,g.jsx)(`button`,{type:`button`,"aria-label":e.maximized?`还原窗口`:`最大化窗口`,title:e.maximized?`还原窗口`:`最大化窗口`,onClick:()=>i(e.id),className:`flex h-3 w-3 items-center justify-center rounded-full bg-[#28c840] text-[8px] text-[#0b4d12] opacity-95 transition-opacity hover:brightness-95`,children:e.maximized?(0,g.jsx)(xs,{size:7,strokeWidth:2.8,className:`opacity-0 group-hover/traffic:opacity-100`}):(0,g.jsx)(_s,{size:7,strokeWidth:2.8,className:`opacity-0 group-hover/traffic:opacity-100`})})]}),(0,g.jsxs)(`div`,{className:`pointer-events-none absolute left-1/2 -translate-x-1/2 text-center`,children:[(0,g.jsx)(`div`,{className:`max-w-[260px] truncate text-[11.5px] font-medium text-ink`,children:l}),(0,g.jsx)(`div`,{className:`text-[9px] text-ink-3`,children:n3(c?.kind)})]}),(0,g.jsx)(`div`,{className:`window-no-drag ml-auto flex items-center`,children:(0,g.jsx)(vm,{label:e.pinned?`取消置顶`:`置顶窗口`,active:e.pinned,className:`h-6 w-6`,onClick:()=>a(e.id),children:e.pinned?(0,g.jsx)(Ls,{size:12}):(0,g.jsx)(zs,{size:12})})})]}),c?.kind===`services`?null:(0,g.jsx)(e3,{window:e}),(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:c?(0,g.jsx)(Z4,{tab:c,visible:!e.minimized}):(0,g.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] text-ink-3`,children:`暂无打开的 Tab`})})]})}function n3(e){switch(e){case`files`:return`文件`;case`terminal`:return`终端`;case`services`:return`服务`;case`browser`:return`预览`;case`git-diff`:return`Diff`;default:return``}}function r3({scope:e,paths:t}){let n=mW(e,t),r=IM(e);return(0,h.useEffect)(()=>{yM.setState(e=>({monitoring:{...e.monitoring,[r]:n}}))},[r,n]),(0,g.jsx)(`span`,{className:`sr-only`,role:`status`,children:n})}function i3(){let t=(0,h.useRef)([]),n=FM(e=>e.windows),r=yM(e=>e.drafts),i=yM(e=>e.closeRequest),[a,o]=(0,h.useState)(null),[s,c]=(0,h.useState)(!1),l=new Map;for(let e of n)for(let t of e.tabs){if(!t.file)continue;let e=IM(t.file.scope),n=l.get(e)??{scope:t.file.scope,paths:[]};n.paths.push(t.file.path),l.set(e,n)}(0,h.useEffect)(()=>{let r=n.flatMap(e=>e.tabs.filter(e=>e.file).map(e=>e.resourceId)),i=t.current.filter(e=>!r.includes(e));i.length&&e(async()=>{let{disposeFileModel:e}=await import(`./FileEditor-EgU1WoyG.js`);return{disposeFileModel:e}},__vite__mapDeps([6,1,2,3,4,5])).then(({disposeFileModel:e})=>{for(let t of i)FM.getState().windows.some(e=>e.tabs.some(e=>e.file&&e.resourceId===t))||e(t)}),t.current=r},[n]),(0,h.useEffect)(()=>{let e=e=>{Object.keys(yM.getState().drafts).length&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[]);let u=i?n.find(e=>e.id===i.windowId)?.tabs.find(e=>e.id===i.tabId):void 0,d=()=>{yM.setState({closeRequest:null}),o(null)},f=()=>{i&&u&&(yM.getState().discard(u.resourceId),FM.getState().closeTab(i.windowId,i.tabId),d())};return(0,g.jsxs)(g.Fragment,{children:[[...l].map(([e,t])=>(0,g.jsx)(r3,{...t},e)),i&&u&&r[u.resourceId]?(0,g.jsx)(Wc,{open:!0,onOpenChange:e=>{!e&&!s&&d()},children:(0,g.jsxs)(Kc,{className:`pointer-events-auto space-y-4 text-sm`,children:[(0,g.jsx)(qc,{children:`未保存的文件`}),(0,g.jsxs)(Jc,{children:[u.title,` 有未保存的改动。`]}),(0,g.jsx)(Yc,{message:a,onDismiss:()=>o(null)}),(0,g.jsxs)(`div`,{className:`flex gap-3`,children:[(0,g.jsx)(V,{type:`button`,disabled:s,onClick:()=>{c(!0),WM(u).then(f).catch(e=>o(VM(e))).finally(()=>c(!1))},children:`保存并关闭`}),(0,g.jsx)(V,{type:`button`,variant:`secondary`,disabled:s,onClick:f,children:`放弃改动`}),(0,g.jsx)(V,{type:`button`,variant:`secondary`,disabled:s,onClick:d,children:`取消`})]})]})}):null]})}function a3(){let e=FM(e=>e.closeRequest);return e?(0,g.jsx)(o3,{request:e},JSON.stringify(e)):null}function o3({request:e}){let t=FM(e=>e.windows),n=yM(e=>e.drafts),r=yM(e=>e.saving),[i,a]=(0,h.useState)(e.tabIds.length<=1),[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(``),u=t.find(t=>t.id===e.windowId)?.tabs.filter(t=>e.tabIds.includes(t.id))??[],d=u.find(e=>e.file&&n[e.resourceId]),f=o||u.some(e=>r[e.resourceId]),p=()=>FM.setState({closeRequest:null});return(0,h.useEffect)(()=>{if(!(!i||d||f)){for(let t of u)FM.getState().closeTab(e.windowId,t.id);FM.setState({closeRequest:null})}},[i,d,f,u,e.windowId]),i&&!d?null:(0,g.jsx)(Wc,{open:!0,onOpenChange:e=>{!e&&!f&&p()},children:(0,g.jsxs)(Kc,{className:`pointer-events-auto space-y-4 text-sm`,onEscapeKeyDown:e=>{f&&e.preventDefault()},onPointerDownOutside:e=>{f&&e.preventDefault()},children:[(0,g.jsx)(qc,{children:i?`未保存的文件`:`关闭 ${u.length} 个 Tab?`}),(0,g.jsx)(Jc,{children:i?`${d?.title??`文件`} 有未保存的改动。`:`最小化可以保留这些 Tab,关闭后需要重新打开。`}),(0,g.jsx)(Yc,{message:c,onDismiss:()=>l(``)}),(0,g.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,g.jsx)(V,{variant:`secondary`,disabled:f,onClick:p,children:`取消`}),i?d?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(V,{variant:`secondary`,disabled:f,onClick:()=>{yM.getState().discard(d.resourceId),l(``)},children:`放弃改动并继续`}),(0,g.jsx)(V,{disabled:f,onClick:()=>{s(!0),l(``),WM(d).then(()=>{yM.getState().drafts[d.resourceId]&&l(`文件在保存期间有新改动,请再次保存。`)}).catch(()=>l(`保存失败,已保留文件和草稿,请核对后重试。`)).finally(()=>s(!1))},children:`保存并继续`})]}):null:(0,g.jsx)(V,{onClick:()=>a(!0),children:`关闭全部 Tab`})]})]})})}function s3({window:e}){let[t,n]=(0,h.useState)(!e.minimized);if(!t){if(e.minimized)return null;n(!0)}return(0,g.jsx)(t3,{window:e})}function c3(){let{projectId:e,sessionId:t}=vW(),{data:n}=sM(),r=gW(e,t,n.sessions),i=FM(e=>e.windows),a=FM(e=>e.setBounds);return(0,h.useEffect)(()=>{let e=()=>{for(let e of FM.getState().windows)e.maximized||a(e.id,{x:e.x,y:e.y,width:e.width,height:e.height})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[a]),(0,h.useEffect)(()=>{let e=window.setTimeout(()=>{for(let e of FM.getState().windows)e.maximized||a(e.id,{x:e.x,y:e.y,width:e.width,height:e.height})},50);return()=>window.clearTimeout(e)},[a]),(0,h.useEffect)(()=>{let e=e=>{e.button===0&&e.target instanceof Element&&(document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)||e.target.closest(`[data-window-frame], [data-window-dock], [data-project-resources], [role="dialog"], [role="alertdialog"], [role="menu"]`)||FM.getState().hideScope(r))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[r]),(0,g.jsx)(V4,{windows:i,children:(0,g.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-40 overflow-hidden`,children:[(0,g.jsx)(a3,{}),(0,g.jsx)(i3,{}),i.filter(e=>kM(e)===r).map(e=>(0,g.jsx)(s3,{window:e},e.id))]})})}var l3={files:No,terminal:dc,services:rc,browser:Co,"git-diff":Xo};function u3(){let{data:e}=sM(),{projectId:t,sessionId:n}=vW(),{windows:r,focusedId:i,open:a,restore:o}=FM(),s=(Zg({queryKey:lK(),queryFn:()=>dK(),enabled:!0,refetchInterval:3e3}).data??[]).filter(e=>e.status===`RUNNING`&&e.projectId===t).length,c=gW(t,n,e.sessions),l=hW(t,n,e.sessions),u=r.filter(e=>kM(e)===c),d=n=>{let r=u.find(e=>e.tabs[0]?.kind===n);r?o(r.id):(e.terminals.find(e=>e.projectId===t),e.services.find(e=>e.projectId===t),a({kind:n,resourceId:`${n}:empty`,title:n===`terminal`?`终端`:`服务`,projectId:t,sessionId:`sessionId`in l?l.sessionId:null,source:t?`project`:`session`}))};return(0,g.jsx)(`div`,{className:`pointer-events-none relative z-10 mb-1.5 flex justify-center px-1`,children:(0,g.jsxs)(`nav`,{"aria-label":`项目窗口`,"data-window-dock":!0,className:`window-tabs-scroll pointer-events-auto flex max-w-full items-center gap-0.5 overflow-x-auto rounded-[10px] border border-line bg-surface/90 p-0.5 shadow-[var(--shadow-card)] backdrop-blur-xl`,children:[[`terminal`,`services`].map(e=>{let t=l3[e],n=u.find(t=>t.tabs[0]?.kind===e),r=n&&!n.minimized&&n.id===i;return(0,g.jsxs)(`button`,{type:`button`,"aria-label":e===`terminal`?`打开终端窗口`:`打开服务窗口`,"aria-pressed":!!r,onClick:()=>d(e),className:B(`flex h-6 shrink-0 items-center gap-1 rounded-md px-1.5 [@media(pointer:coarse)]:h-11 text-[11px] font-medium transition-colors`,r?`bg-accent-soft text-accent`:`text-ink-2 hover:bg-surface-2 hover:text-ink`),children:[(0,g.jsx)(t,{size:12,strokeWidth:1.7,className:e===`terminal`?`text-accent`:`text-success`}),e===`terminal`?`终端`:`服务`,e===`services`&&s>0?(0,g.jsx)(`span`,{className:`rounded bg-black/[.045] px-1 font-mono text-[9px] dark:bg-white/[.08]`,children:s}):null,e===`terminal`&&n&&n.tabs.filter(e=>!e.resourceId.endsWith(`:empty`)).length>0?(0,g.jsx)(`span`,{className:`rounded bg-black/[.045] px-1 font-mono text-[9px] dark:bg-white/[.08]`,children:n.tabs.filter(e=>!e.resourceId.endsWith(`:empty`)).length}):null]},e)}),u.filter(e=>e.minimized&&![`terminal`,`services`].includes(e.tabs[0]?.kind??``)).map(e=>{let t=e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0];if(!t)return null;let n=l3[t.kind];return(0,g.jsxs)(`button`,{type:`button`,"aria-label":`恢复 ${t.title}`,onClick:()=>o(e.id),title:t.title,className:`flex h-6 max-w-32 shrink-0 items-center gap-1 rounded-md px-1.5 [@media(pointer:coarse)]:h-11 text-[11px] text-ink-2 transition-colors hover:bg-surface-2 hover:text-ink`,children:[(0,g.jsx)(n,{size:12,className:`shrink-0 text-accent`}),(0,g.jsx)(`span`,{className:`truncate`,children:t.title}),e.tabs.length>1?(0,g.jsx)(`span`,{className:`text-[9px] text-ink-3`,children:e.tabs.length}):null]},e.id)})]})})}function d3(e){let t=new Set(e.filter(e=>e.kind===`message`&&e.role===`user`&&e.turnOutcome!==void 0).map(e=>e.turnId));return e.filter(e=>e.kind===`approval`&&e.status===`pending`&&(e.turnId===void 0||!t.has(e.turnId)))}function f3(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var p3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,m3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,h3={};function g3(e,t){return((t||h3).jsx?m3:p3).test(e)}var _3=/[ \t\n\f\r]/g;function v3(e){return typeof e==`object`?e.type===`text`&&y3(e.value):y3(e)}function y3(e){return e.replace(_3,``)===``}var b3=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};b3.prototype.normal={},b3.prototype.property={},b3.prototype.space=void 0;function x3(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new b3(n,r,t)}function S3(e){return e.toLowerCase()}var C3=class{constructor(e,t){this.attribute=t,this.property=e}};C3.prototype.attribute=``,C3.prototype.booleanish=!1,C3.prototype.boolean=!1,C3.prototype.commaOrSpaceSeparated=!1,C3.prototype.commaSeparated=!1,C3.prototype.defined=!1,C3.prototype.mustUseProperty=!1,C3.prototype.number=!1,C3.prototype.overloadedBoolean=!1,C3.prototype.property=``,C3.prototype.spaceSeparated=!1,C3.prototype.space=void 0;var w3=c({boolean:()=>E3,booleanish:()=>D3,commaOrSpaceSeparated:()=>j3,commaSeparated:()=>A3,number:()=>$,overloadedBoolean:()=>O3,spaceSeparated:()=>k3}),T3=0,E3=M3(),D3=M3(),O3=M3(),$=M3(),k3=M3(),A3=M3(),j3=M3();function M3(){return 2**++T3}var N3=Object.keys(w3),P3=class extends C3{constructor(e,t,n,r){let i=-1;if(super(e,t),F3(this,`space`,r),typeof n==`number`)for(;++i<N3.length;){let e=N3[i];F3(this,N3[i],(n&w3[e])===w3[e])}}};P3.prototype.defined=!0;function F3(e,t,n){n&&(e[t]=n)}function I3(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new P3(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[S3(r)]=r,n[S3(a.attribute)]=r}return new b3(t,n,e.space)}var L3=I3({properties:{ariaActiveDescendant:null,ariaAtomic:D3,ariaAutoComplete:null,ariaBusy:D3,ariaChecked:D3,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:k3,ariaCurrent:null,ariaDescribedBy:k3,ariaDetails:null,ariaDisabled:D3,ariaDropEffect:k3,ariaErrorMessage:null,ariaExpanded:D3,ariaFlowTo:k3,ariaGrabbed:D3,ariaHasPopup:null,ariaHidden:D3,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:k3,ariaLevel:$,ariaLive:null,ariaModal:D3,ariaMultiLine:D3,ariaMultiSelectable:D3,ariaOrientation:null,ariaOwns:k3,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:D3,ariaReadOnly:D3,ariaRelevant:null,ariaRequired:D3,ariaRoleDescription:k3,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:D3,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function R3(e,t){return t in e?e[t]:t}function z3(e,t){return R3(e,t.toLowerCase())}var B3=I3({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:A3,acceptCharset:k3,accessKey:k3,action:null,allow:null,allowFullScreen:E3,allowPaymentRequest:E3,allowUserMedia:E3,alpha:E3,alt:null,as:null,async:E3,autoCapitalize:null,autoComplete:k3,autoFocus:E3,autoPlay:E3,blocking:k3,capture:null,charSet:null,checked:E3,cite:null,className:k3,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:D3,controls:E3,controlsList:k3,coords:$|A3,crossOrigin:null,data:null,dateTime:null,decoding:null,default:E3,defer:E3,dir:null,dirName:null,disabled:E3,download:O3,draggable:D3,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:E3,formTarget:null,headers:k3,height:$,hidden:O3,high:$,href:null,hrefLang:null,htmlFor:k3,httpEquiv:k3,id:null,imageSizes:null,imageSrcSet:null,inert:E3,inputMode:null,integrity:null,is:null,isMap:E3,itemId:null,itemProp:k3,itemRef:k3,itemScope:E3,itemType:k3,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:E3,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:E3,muted:E3,name:null,nonce:null,noModule:E3,noValidate:E3,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:E3,optimum:$,pattern:null,ping:k3,placeholder:null,playsInline:E3,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:E3,referrerPolicy:null,rel:k3,required:E3,reversed:E3,rows:$,rowSpan:$,sandbox:k3,scope:null,scoped:E3,seamless:E3,selected:E3,shadowRootClonable:E3,shadowRootCustomElementRegistry:E3,shadowRootDelegatesFocus:E3,shadowRootMode:null,shadowRootSerializable:E3,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:D3,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:E3,useMap:null,value:D3,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:k3,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:E3,declare:E3,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:E3,noHref:E3,noShade:E3,noWrap:E3,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:D3,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:E3,disablePictureInPicture:E3,disableRemotePlayback:E3,exportParts:A3,part:k3,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:z3}),V3=I3({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:j3,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:k3,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:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:E3,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,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:A3,g2:A3,glyphName:A3,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:j3,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,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:$,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:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:k3,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:j3,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:j3,rev:j3,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:j3,requiredFeatures:j3,requiredFonts:j3,requiredFormats:j3,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:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:j3,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:j3,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:j3,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:R3}),H3=I3({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),U3=I3({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:z3}),W3=I3({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),G3={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`},K3=/[A-Z]/g,q3=/-[a-z]/g,J3=/^data[-\w.:]+$/i;function Y3(e,t){let n=S3(t),r=t,i=C3;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&J3.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(q3,Z3);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!q3.test(e)){let n=e.replace(K3,X3);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=P3}return new i(r,t)}function X3(e){return`-`+e.toLowerCase()}function Z3(e){return e.charAt(1).toUpperCase()}var Q3=x3([L3,B3,H3,U3,W3],`html`),$3=x3([L3,V3,H3,U3,W3],`svg`);function e6(e){return e.join(` `).trim()}var t6=/\/\*(?:[^*]|\*(?!\/))*\*\//g,n6=/\n/g,r6=/^\s*/,i6=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a6=/^:\s*/,o6=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,s6=/^[;\s]*/,c6=`
|
|
126
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return nX.get()},set promptLabel(e){nX.set(e)},get tooMuchOutput(){return iX.get()},set tooMuchOutput(e){iX.set(e)}}}_verifyIntegers(...e){for(R4 of e)if(R4===1/0||isNaN(R4)||R4%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(R4 of e)if(R4&&(R4===1/0||isNaN(R4)||R4%1!=0||R4<0))throw Error(`This API only accepts positive integers`)}},B4=(0,h.createContext)(null);function V4({children:e,windows:t}){let[n]=(0,h.useState)(()=>new Map);return(0,h.useEffect)(()=>{if(!n.size)return;let e=new Set(t.flatMap(e=>e.tabs.map(e=>e.id)));for(let[t,r]of n)e.has(t)||(r.terminal.dispose(),n.delete(t))},[n,t]),(0,h.useEffect)(()=>()=>{for(let e of n.values())e.terminal.dispose();n.clear()},[n]),(0,g.jsx)(B4.Provider,{value:n,children:e})}function H4(){let e=(0,h.useContext)(B4);if(!e)throw Error(`Terminal screen provider is missing`);return e}function U4(){let e=new z4({fontSize:12,fontFamily:`ui-monospace, Menlo, monospace`,cursorBlink:!0,scrollback:2e3,disableStdin:!0,theme:{background:`#0f1115`,foreground:`#d7dae0`}}),t=new XY;return e.loadAddon(t),{terminal:e,fit:t,cursor:0,log:``,gap:!1,ready:!1,pendingWrite:Promise.resolve()}}var W4={CREATED:`正在创建`,RUNNING:`运行中`,STOPPING:`正在终止`,EXITED:`已退出`,TERMINATED:`已终止`,INTERRUPTED:`已中断`};function G4({id:e,tabId:t,visible:n}){let r=H4(),i=Zg({queryKey:UK(e),queryFn:()=>KK(e),enabled:n,staleTime:0,refetchOnMount:`always`,refetchInterval:2e3}),a=i.data?WK(i.data.status):!1,o=i.isFetchedAfterMount&&i.isSuccess,[s,c]=(0,h.useState)(!1);(0,h.useEffect)(()=>{o&&c(!0)},[o]);let l=(o||s)&&!!i.data&&!a,u=i.data?GK(i.data):null;(0,h.useEffect)(()=>{if(u===null)return;let t=FM.getState();t.windows.some(t=>t.tabs.some(t=>t.resourceId===e&&t.title!==u))&&FM.setState({windows:t.windows.map(t=>({...t,tabs:t.tabs.map(t=>t.resourceId===e&&t.title!==u?{...t,title:u}:t)}))})},[e,u]);let d=(0,h.useRef)(i.data);d.current=i.data;let f=(0,h.useRef)(null),p=(0,h.useRef)(null),m=(0,h.useRef)(null),_=(0,h.useRef)(!1),[v,y]=(0,h.useState)(null);(0,h.useEffect)(()=>{y(document.getElementById(`terminal-controls-${t}`))},[t]);let[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(null),[w,T]=(0,h.useState)(``),[E,D]=(0,h.useState)(``),[O,k]=(0,h.useState)(!1),[A,j]=(0,h.useState)(``),[M,N]=(0,h.useState)(!0),[ee,te]=(0,h.useState)(!1),[P,F]=(0,h.useState)(Date.now()),ne=i.data?.lease,I=n&&!!S&&ne?.ownerConnectionId===S&&ne.expiresAt>P&&i.data?.status===`RUNNING`&&!i.isError,re=I&&b,ie=ne?.ownerType===`agent`&&ne.expiresAt>P&&i.data?.status===`RUNNING`&&!i.isError;(0,h.useLayoutEffect)(()=>{if(a){r.get(t)?.terminal.dispose(),r.delete(t),j(``);return}let e=f.current;if(!l||!e)return;let n=r.get(t)??U4();r.set(t,n),p.current=n;let i=n.terminal;return i.element?e.appendChild(i.element):i.open(e),k(n.gap),j(n.ready?n.log:``),N(!n.ready),()=>{p.current=null,i.element?.remove()}},[r,l,t,a]),(0,h.useLayoutEffect)(()=>{C(null),x(!1);let t=f.current,r=p.current;if(!n||!l||!t||!r)return;let{terminal:i,fit:a}=r;i.options.cursorBlink=!0,_.current=!1;let o=!1,s=!1,c=500,u,h,g=null,v=null,y=0,b=null,S=null,w=[],E=0;T(``);let D=()=>o?Promise.resolve():aM.invalidateQueries({queryKey:UK(e)}),O=()=>{let e=d.current;return!!g&&!!v&&e?.status===`RUNNING`&&e.lease?.ownerConnectionId===g&&e.lease.generation===v&&e.lease.expiresAt>Date.now()&&u?.readyState===WebSocket.OPEN},A=()=>{v=null,x(!1),S=null,w=[],E=0,i.options.disableStdin=!0},M=()=>{if(!O()||S!==null||!w.length)return;let t=w.shift();t!==void 0&&(E-=new TextEncoder().encode(t).length,S=++y,u?.send(JSON.stringify({type:`terminal.input`,terminalId:e,leaseGeneration:v,inputSequence:S,data:t})))},ee=i.onData(e=>{if(!O())return;let t=new TextEncoder().encode(e).length;t>8192||E+t>32768?T(`输入过大,请分段粘贴(单次最多 8 KiB)。`):(w.push(e),E+=t,M())}),te=()=>{r.ready||(r.ready=!0,j(r.log),N(!1))},P=async()=>{if(!(s||o)){s=!0;try{await r.pendingWrite;for(let t=0;t<8&&!o;t++){let t=KA.parse(await Y(`/api/terminals/${encodeURIComponent(e)}/output?after=${r.cursor}&limit=100`));if(o)return;r.gap||=t.resyncRequired||t.truncated;let n=r.cursor,a=[];for(let e of t.chunks)e.cursor<=n||(e.cursor!==n+1&&(r.gap=!0),a.push(e.data),n=e.cursor);r.gap&&k(!0);let s=Math.max(n,t.nextCursor);if(!a.length){r.cursor=s,te();break}let c=a.join(``);r.pendingWrite=new Promise(e=>{i.write(c,()=>{r.cursor=s,r.log=(r.log+c).slice(-16384),e()})}),await r.pendingWrite,!o&&r.ready&&j(r.log)}}catch{o||(T(`输出读取失败,正在重试;历史可能不完整。`),te())}finally{s=!1}}},ne,I=()=>{clearTimeout(ne),ne=setTimeout(()=>{!o&&t.clientWidth&&t.clientHeight&&(a.fit(),O()&&YK(e,`resize`,{connectionId:g,leaseGeneration:v,cols:Math.max(2,Math.min(500,i.cols)),rows:Math.max(1,Math.min(300,i.rows))}).catch(()=>{o||(A(),D(),T(`尺寸同步失败,请重新获取输入权。`))}))},100)},re=new ResizeObserver(I);re.observe(t),I();let ie=()=>{if(o)return;let t=new URL(`/ws`,location.href);t.protocol=t.protocol===`https:`?`wss:`:`ws:`;let n=new WebSocket(t);u=n,n.onopen=()=>n.send(JSON.stringify({type:`subscribe`,subscriptions:[{topic:`terminal`,resourceId:e,after:0}]})),n.onmessage=t=>{if(o||u!==n)return;let r;try{r=JSON.parse(String(t.data))}catch{A(),T(`终端响应无效,请刷新。`);return}let i=qA.safeParse(r);if(i.success&&i.data.subscription.resourceId===e){g=i.data.connectionId,c=500,D().then(()=>{!o&&u===n&&n.readyState===WebSocket.OPEN&&C(g)}),P();return}let a=JA.safeParse(r);if(a.success&&S===a.data.inputSequence){S=null,M();return}let s=WA.safeParse(r);if(s.success&&s.data.resourceId===e){(s.data.payload.lease?.generation!==v||s.data.payload.lease?.ownerConnectionId!==g||s.data.payload.status!==`RUNNING`)&&A(),D(),P();return}if(VA.safeParse(r).success){P();return}let l=YA.safeParse(r);l.success&&(A(),D(),T(`终端操作被拒绝(${l.data.code}),请重新获取输入权。`))},n.onclose=()=>{o||(g=null,C(null),A(),D(),T(`连接已断开,正在重连;不会重放输入。`),h=setTimeout(ie,c),c=Math.min(c*2,1e4))}},ae=t=>{t.lease&&(d.current=t,aM.setQueryData(UK(e),t),v=t.lease.generation,b!==v&&(y=0),b=v,x(!0),S=null,i.options.disableStdin=!1,i.focus(),I(),T(``))};m.current={acquire:async()=>{if(!g)throw Error(`Disconnected`);let t=g,n=await YK(e,`lease`,{action:`acquire`,connectionId:t});o||g!==t||n.lease?.ownerConnectionId!==t||ae(n)},takeover:async()=>{if(!g)throw Error(`Disconnected`);let t=g,n=await YK(e,`takeover`,{connectionId:t});o||g!==t||n.lease?.ownerConnectionId!==t||ae(n)},release:async()=>{let t=d.current?.lease,n=t?.ownerConnectionId===g?t?.generation:v;A(),g&&n&&await YK(e,`lease`,{action:`release`,connectionId:g,leaseGeneration:n})}};let oe=setInterval(()=>{if(!O())return;let t=g,n=v;YK(e,`lease`,{action:`renew`,connectionId:g,leaseGeneration:v}).then(r=>{!o&&t===g&&n===v&&(d.current=r,aM.setQueryData(UK(e),r))}).catch(()=>{o||(A(),D(),T(`输入租约续期失败,请重新获取输入权。`))})},1e4),se=setInterval(()=>{F(Date.now()),i.options.disableStdin=!O(),O()||x(!1),P()},1e3);return ie(),()=>{o=!0,m.current=null,clearTimeout(h),clearTimeout(ne),clearInterval(oe),clearInterval(se),re.disconnect(),ee.dispose(),u?.close(),i.options.disableStdin=!0,i.options.cursorBlink=!1,i.blur()}},[e,l,n]),(0,h.useEffect)(()=>{if(!n||M||!S||!i.data||i.data.status!==`RUNNING`||i.isError||_.current||(_.current=!0,i.data.mode!==`shell`||i.data.lease&&i.data.lease.expiresAt>Date.now()))return;let t=!1;return te(!0),m.current?.acquire().catch(()=>{t||aM.invalidateQueries({queryKey:UK(e)})}).finally(()=>{t||te(!1)}),()=>{t=!0,te(!1)}},[S,e,i.data,i.isError,M,n]);let ae=async e=>{te(!0),T(``),D(``);try{await e()}catch{D(`终端操作失败,请刷新状态后重试。`)}finally{te(!1)}};return(0,g.jsxs)(`div`,{"data-testid":`live-terminal`,"data-terminal-id":e,"data-input-state":re?`active`:ie?`agent`:`inactive`,className:`flex h-full min-h-0 flex-col bg-[#0f1115] text-white/80`,children:[v?(0,en.createPortal)((0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsx)(`button`,{type:`button`,"aria-label":`终端操作`,title:`终端操作`,className:`flex w-7 items-center justify-center text-ink-3 hover:bg-surface-2 hover:text-ink`,children:(0,g.jsx)(To,{size:14})})}),(0,g.jsx)(sm,{onCloseAutoFocus:e=>{e.preventDefault(),re&&f.current?.querySelector(`.xterm-helper-textarea`)?.focus()},children:(0,g.jsx)(lm,{"aria-label":I?`释放输入权`:ie?`接管控制`:`获取输入权`,disabled:ee||M||!S||!i.data||i.isError||i.data.status!==`RUNNING`||!I&&!ie&&!!ne&&ne.expiresAt>P,onSelect:()=>void ae(async()=>{I?await m.current?.release():ie?await m.current?.takeover():await m.current?.acquire()}),children:I?`交给 AI`:ie?`接管控制`:`输入终端`})})]}),v):null,i.data&&i.data.status!==`RUNNING`?(0,g.jsx)(`p`,{role:`status`,className:`px-2 text-xs`,children:W4[i.data.status]}):null,i.data?.reasonCode?(0,g.jsxs)(`p`,{className:`px-2 text-xs`,children:[`状态原因:`,i.data.reasonCode]}):null,i.data?.exitCode!==null&&i.data?.exitCode!==void 0?(0,g.jsxs)(`p`,{className:`px-2 text-xs`,children:[`退出码 `,i.data.exitCode]}):null,!a&&O?(0,g.jsx)(`p`,{role:`status`,className:`px-2 text-xs text-amber-300`,children:`部分历史输出已过期或缺失,当前回放不完整。`}):null,i.isError||!a&&w?(0,g.jsx)(`p`,{role:`alert`,className:`px-2 text-xs text-red-300`,children:!a&&w||`终端不可用,请刷新核对;不会自动重建。`}):null,(0,g.jsx)(Yc,{message:!a&&n?E:null,onDismiss:()=>D(``)}),l?(0,g.jsxs)(g.Fragment,{children:[M?(0,g.jsx)(`p`,{role:`status`,className:`px-2 pt-2 text-xs text-white/60`,children:`正在恢复终端输出…`}):null,(0,g.jsx)(`div`,{ref:f,role:`application`,"aria-label":`交互终端`,className:B(`min-h-0 flex-1 p-2`,M&&`invisible`),onPointerDown:()=>{!I&&!ie&&S&&!ee&&(!ne||ne.expiresAt<=Date.now())&&i.data?.status===`RUNNING`&&ae(async()=>{await m.current?.acquire()})}}),(0,g.jsx)(`pre`,{role:`log`,"aria-label":`终端输出`,"aria-live":`off`,className:`sr-only`,children:A})]}):null]})}function K4({scope:e,label:t=`新建终端`,children:n,className:r}){let[i,a]=(0,h.useState)(null),[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(``);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":t,title:`新建终端`,className:r,onClick:()=>{l(``),a({key:crypto.randomUUID(),scope:e})},children:n??`新建终端`}),(0,g.jsx)(Xc,{open:i!==null,title:`创建终端确认`,description:`终端以本机账户权限运行,可访问项目外文件。`,confirmLabel:`确认创建`,pendingLabel:`正在创建…`,pending:o,error:c,onDismissError:()=>l(``),onCancel:()=>a(null),onConfirm:async()=>{if(i&&!o){s(!0),l(``);try{XK(await JK(i.scope,i.key)),a(null),aM.invalidateQueries({queryKey:[`terminals`]}),aM.invalidateQueries({queryKey:[`workspace`]})}catch{l(`创建结果未确认,请重试核对;重试不会重复创建。`)}finally{s(!1)}}}})]})}function q4(e,t){return`projectId`in t&&t.projectId!==`prj_default`?e.projectId===t.projectId:`sessionId`in t?e.workspaceSessionId===t.sessionId:!e.projectId&&!e.workspaceSessionId}async function J4(e,t){let n=[],r=new Set,i;do{t.throwIfAborted();let a=await qK(i,e);if(n.push(...a.items.filter(t=>t.status===`RUNNING`&&q4(t,e))),i=a.nextCursor??void 0,i){if(r.has(i))throw Error(`Repeated terminal cursor`);r.add(i)}}while(i);for(let r of n.reverse()){t.throwIfAborted();let n=await KK(r.id).catch(e=>{if(e instanceof fj&&e.status===404)return null;throw e});if(n){if(n.id!==r.id||!q4(n,e))throw Error(`Terminal scope changed`);if(n.status===`RUNNING`)return n}}return null}function Y4({projectId:e,sessionId:t,visible:n=!0}){let r=e?{projectId:e}:t?{sessionId:t}:{workspace:`default`},{data:i,isFetchedAfterMount:a,isError:o,isFetching:s,refetch:c}=Zg({queryKey:[`terminals`,`restore`,e,t],queryFn:({signal:e})=>J4(r,e),enabled:n,staleTime:0,refetchOnMount:`always`,refetchOnWindowFocus:!1});return(0,h.useEffect)(()=>{n&&i&&a&&!o&&!s&&XK(i)},[i,a,o,s,n]),(0,g.jsx)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-3 text-[12px] text-ink`,children:o&&!s?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{role:`alert`,className:`text-ink-3`,children:`无法恢复终端,请重试。`}),(0,g.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>void c(),children:`重试`}),(0,g.jsx)(K4,{scope:r,className:`text-accent`})]}):!a||s||i?(0,g.jsx)(`p`,{role:`status`,className:`text-ink-3`,children:`正在读取终端…`}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dc,{size:24,"aria-hidden":`true`,className:`text-ink-3/50`}),(0,g.jsx)(`p`,{className:`text-ink-3`,children:`暂无运行中的终端`}),(0,g.jsx)(K4,{scope:r,className:`rounded-lg bg-accent px-3 py-1.5 text-white`})]})})}function X4({tab:e,visible:t}){return e.resourceId===`terminal:empty`?(0,g.jsx)(Y4,{projectId:e.projectId,sessionId:e.sourceSessionId??void 0,visible:t}):(0,g.jsx)(G4,{id:e.resourceId,tabId:e.id,visible:t},e.id)}function Z4({tab:e,visible:t}){if(!e)return null;switch(e.kind){case`files`:return(0,g.jsx)(VY,{tab:e});case`terminal`:return(0,g.jsx)(X4,{tab:e,visible:t});case`services`:return(0,g.jsx)(GY,{tab:e});case`browser`:return(0,g.jsx)(MY,{tab:e});case`git-diff`:return(0,g.jsx)(LY,{tab:e});default:return null}}function Q4({kind:e,path:t}){return e===`files`?(0,g.jsx)(pW,{path:t,size:14}):(0,g.jsx)(e===`terminal`?dc:e===`services`?rc:e===`browser`?Co:Xo,{size:11.5,className:`shrink-0 text-ink-3`})}function $4(e,t,n){return e?n??e:t===`session`?`独立会话`:`默认工作区`}function e3({window:e}){let[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(``),a=yM(e=>e.saving),o=yM(e=>e.drafts),s=FM(e=>e.setActiveTab),c=FM(e=>e.closeTab),{data:l}=sM(),u=CM(e.tabs,e.filter),d=wM(u,e.activeTabId)?.id,f=u.filter(e=>e.kind!==`terminal`||e.resourceId!==`terminal:empty`),p=e.tabs[0]?.kind,m=(0,h.useRef)(null),[_,v]=(0,h.useState)(!1),[y,b]=(0,h.useState)(null);return(0,h.useEffect)(()=>{let t=m.current;if(!t||!e.tabs.length)return;let n=()=>v(t.scrollWidth>t.clientWidth+1),r=new ResizeObserver(n);return r.observe(t),n(),t.querySelector(`[data-tab-id="${d}"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`}),()=>r.disconnect()},[e.tabs,d]),(0,g.jsxs)(`div`,{className:`relative flex h-8 shrink-0 items-stretch border-b border-line bg-surface-2/35`,children:[(0,g.jsx)(Yc,{message:r,onDismiss:()=>i(``)}),_?(0,g.jsx)(`button`,{type:`button`,"aria-label":`向左滚动 Tab`,className:`shrink-0 px-1 text-ink-3 hover:text-ink`,onClick:()=>m.current?.scrollBy({left:-180,behavior:`smooth`}),children:(0,g.jsx)(Qa,{size:13})}):null,(0,g.jsx)(`div`,{ref:m,role:`tablist`,"aria-label":`窗口 Tab`,onKeyDown:t=>{if(!(t.target instanceof HTMLElement)||t.target.getAttribute(`role`)!==`tab`)return;let n=f.findIndex(e=>e.id===d),r=t.key===`ArrowRight`?(n+1)%f.length:t.key===`ArrowLeft`?(n-1+f.length)%f.length:t.key===`Home`?0:t.key===`End`?f.length-1:-1,i=f[r];i&&(t.preventDefault(),s(e.id,i.id),m.current?.querySelector(`[data-tab-id="${i.id}"]`)?.focus())},className:`window-tabs-scroll flex h-8 min-w-0 flex-1 items-end gap-0.5 overflow-x-auto overflow-y-hidden px-2`,onWheel:e=>{m.current&&Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(m.current.scrollLeft+=e.deltaY)},children:f.map(r=>{let u=r.id===d,f=l.projects.find(e=>e.id===r.projectId)??null,p=$4(r.projectId,r.originType,f?.name);return(0,g.jsx)(`div`,{className:`flex shrink-0 items-end`,children:(0,g.jsxs)(`div`,{className:B(`group flex h-7 max-w-[220px] shrink-0 items-center gap-1.5 rounded-t-[8px] border border-b-0 px-2.5 text-[10.5px] transition-colors`,u?`border-line bg-surface text-ink`:`border-transparent text-ink-3 hover:bg-black/[.03] hover:text-ink-2 dark:hover:bg-white/[.04]`),children:[y?.id===r.id?(0,g.jsx)(`form`,{onSubmit:async e=>{e.preventDefault();try{await YK(r.resourceId,`rename`,{title:y.title}),b(null)}catch{i(`改名失败,请重试。`)}},children:(0,g.jsx)(mm,{ref:e=>e?.focus(),"aria-label":`终端名称`,maxLength:80,value:y.title,onChange:e=>b({...y,title:e.target.value}),onKeyDown:e=>{e.key===`Escape`&&b(null)},className:`h-5 w-32 border-accent/40 px-1 text-[11px]`})}):(0,g.jsxs)(`button`,{type:`button`,"data-tab-id":r.id,role:`tab`,"aria-selected":u,onDoubleClick:()=>{r.preview&&FM.getState().keepFileTab(r.id),r.kind===`terminal`&&r.resourceId.startsWith(`term_`)&&b({id:r.id,title:r.title})},onKeyDown:e=>{e.key===`F2`&&r.kind===`terminal`&&r.resourceId.startsWith(`term_`)&&(e.preventDefault(),b({id:r.id,title:r.title}))},onClick:()=>s(e.id,r.id),title:`${p} · ${r.title}${r.kind===`terminal`?` · 双击或 F2 改名`:r.preview?` · 预览,双击保留`:``}`,className:`flex min-w-0 flex-1 items-center gap-1.5 focus-visible:outline-none`,children:[(0,g.jsx)(Q4,{kind:r.kind,path:r.file?.path??r.title}),(0,g.jsxs)(`span`,{className:B(`truncate`,r.preview&&`italic`),children:[r.title,o[r.resourceId]?` ●`:``]})]}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭 ${r.title}`,disabled:!!t||(a[r.resourceId]??!1),onClick:async t=>{if(t.stopPropagation(),r.kind===`terminal`&&r.resourceId!==`terminal:empty`){n(r.id),i(``);try{let t=await KK(r.resourceId);if(!$K(WK(t.status)?t:await YK(r.resourceId,`terminate`,{confirmed:!0})))throw Error(`Termination unconfirmed`);c(e.id,r.id)}catch{i(`终止未确认,已保留 Tab;请核对状态后重试。`)}finally{n(null)}}else r.file&&o[r.resourceId]?yM.setState({closeRequest:{windowId:e.id,tabId:r.id}}):c(e.id,r.id)},className:`window-no-drag rounded p-0.5 text-ink-3 opacity-70 transition-opacity hover:bg-black/[.06] hover:text-ink group-hover:opacity-100 dark:hover:bg-white/[.08]`,children:(0,g.jsx)(Ac,{size:10})})]})},r.id)})}),_?(0,g.jsx)(`button`,{type:`button`,"aria-label":`向右滚动 Tab`,className:`shrink-0 px-1 text-ink-3 hover:text-ink`,onClick:()=>m.current?.scrollBy({left:180,behavior:`smooth`}),children:(0,g.jsx)(eo,{size:13})}):null,p===`terminal`?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{id:`terminal-controls-${d}`,className:`flex shrink-0`}),(0,g.jsx)(K4,{label:`新建终端 Tab`,className:`flex w-8 shrink-0 items-center justify-center text-ink-3 hover:bg-surface-2 hover:text-ink`,scope:e.tabs[0]?.projectId?{projectId:e.tabs[0].projectId}:e.tabs[0]?.originType===`session`&&e.tabs[0].sourceSessionId?{sessionId:e.tabs[0].sourceSessionId}:{workspace:`default`},children:(0,g.jsx)(Us,{size:14})})]}):null]})}function t3({window:e}){let t=FM(e=>e.focus),n=FM(e=>e.close),r=FM(e=>e.hide),i=FM(e=>e.toggleMaximize),a=FM(e=>e.togglePin),o=FM(e=>e.setBounds),{data:s}=sM(),c=wM(CM(e.tabs,e.filter),e.activeTabId),l=AY(c,s);return(0,g.jsxs)(kY,{bounds:`parent`,dragHandleClassName:`window-drag-handle`,cancel:`.window-no-drag`,disableDragging:e.maximized,enableResizing:!e.maximized,minWidth:420,minHeight:280,size:e.maximized?{width:`100%`,height:`100%`}:{width:e.width,height:e.height},position:e.maximized?{x:0,y:0}:{x:e.x,y:e.y},onMouseDown:()=>t(e.id),onDragStop:(t,n)=>o(e.id,{x:n.x,y:n.y,width:e.width,height:e.height}),onResizeStop:(t,n,r,i,a)=>o(e.id,{x:a.x,y:a.y,width:r.offsetWidth,height:r.offsetHeight}),style:{zIndex:e.z,display:e.minimized?`none`:`flex`,flexDirection:`column`},inert:e.minimized,"data-window-frame":e.id,role:`dialog`,"aria-label":l,className:B(`pointer-events-auto flex flex-col overflow-hidden border border-line bg-surface window-shadow`,e.maximized?`rounded-none`:`rounded-xl`),children:[(0,g.jsxs)(`div`,{className:`window-drag-handle flex h-10 shrink-0 items-center gap-2 border-b border-line bg-surface-2/55 px-3`,children:[(0,g.jsxs)(`div`,{className:`window-no-drag group/traffic flex items-center gap-1.5`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭窗口`,title:`关闭窗口`,onClick:()=>n(e.id),className:`flex h-3 w-3 items-center justify-center rounded-full bg-[#ff5f57] text-[8px] text-[#6b0d08] opacity-95 transition-opacity hover:brightness-95`,children:(0,g.jsx)(Ac,{size:7,strokeWidth:2.8,className:`opacity-0 group-hover/traffic:opacity-100`})}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`隐藏窗口`,title:`隐藏窗口`,onClick:()=>r(e.id),className:`flex h-3 w-3 items-center justify-center rounded-full bg-[#febc2e] text-[8px] text-[#6b4b00] opacity-95 transition-opacity hover:brightness-95`,children:(0,g.jsx)(Cs,{size:7,strokeWidth:3,className:`opacity-0 group-hover/traffic:opacity-100`})}),(0,g.jsx)(`button`,{type:`button`,"aria-label":e.maximized?`还原窗口`:`最大化窗口`,title:e.maximized?`还原窗口`:`最大化窗口`,onClick:()=>i(e.id),className:`flex h-3 w-3 items-center justify-center rounded-full bg-[#28c840] text-[8px] text-[#0b4d12] opacity-95 transition-opacity hover:brightness-95`,children:e.maximized?(0,g.jsx)(xs,{size:7,strokeWidth:2.8,className:`opacity-0 group-hover/traffic:opacity-100`}):(0,g.jsx)(_s,{size:7,strokeWidth:2.8,className:`opacity-0 group-hover/traffic:opacity-100`})})]}),(0,g.jsxs)(`div`,{className:`pointer-events-none absolute left-1/2 -translate-x-1/2 text-center`,children:[(0,g.jsx)(`div`,{className:`max-w-[260px] truncate text-[11.5px] font-medium text-ink`,children:l}),(0,g.jsx)(`div`,{className:`text-[9px] text-ink-3`,children:n3(c?.kind)})]}),(0,g.jsx)(`div`,{className:`window-no-drag ml-auto flex items-center`,children:(0,g.jsx)(vm,{label:e.pinned?`取消置顶`:`置顶窗口`,active:e.pinned,className:`h-6 w-6`,onClick:()=>a(e.id),children:e.pinned?(0,g.jsx)(Ls,{size:12}):(0,g.jsx)(zs,{size:12})})})]}),c?.kind===`services`?null:(0,g.jsx)(e3,{window:e}),(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:c?(0,g.jsx)(Z4,{tab:c,visible:!e.minimized}):(0,g.jsx)(`div`,{className:`flex h-full items-center justify-center text-[11px] text-ink-3`,children:`暂无打开的 Tab`})})]})}function n3(e){switch(e){case`files`:return`文件`;case`terminal`:return`终端`;case`services`:return`服务`;case`browser`:return`预览`;case`git-diff`:return`Diff`;default:return``}}function r3({scope:e,paths:t}){let n=mW(e,t),r=IM(e);return(0,h.useEffect)(()=>{yM.setState(e=>({monitoring:{...e.monitoring,[r]:n}}))},[r,n]),(0,g.jsx)(`span`,{className:`sr-only`,role:`status`,children:n})}function i3(){let t=(0,h.useRef)([]),n=FM(e=>e.windows),r=yM(e=>e.drafts),i=yM(e=>e.closeRequest),[a,o]=(0,h.useState)(null),[s,c]=(0,h.useState)(!1),l=new Map;for(let e of n)for(let t of e.tabs){if(!t.file)continue;let e=IM(t.file.scope),n=l.get(e)??{scope:t.file.scope,paths:[]};n.paths.push(t.file.path),l.set(e,n)}(0,h.useEffect)(()=>{let r=n.flatMap(e=>e.tabs.filter(e=>e.file).map(e=>e.resourceId)),i=t.current.filter(e=>!r.includes(e));i.length&&e(async()=>{let{disposeFileModel:e}=await import(`./FileEditor-CxzD-z_w.js`);return{disposeFileModel:e}},__vite__mapDeps([6,1,2,3,4,5])).then(({disposeFileModel:e})=>{for(let t of i)FM.getState().windows.some(e=>e.tabs.some(e=>e.file&&e.resourceId===t))||e(t)}),t.current=r},[n]),(0,h.useEffect)(()=>{let e=e=>{Object.keys(yM.getState().drafts).length&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[]);let u=i?n.find(e=>e.id===i.windowId)?.tabs.find(e=>e.id===i.tabId):void 0,d=()=>{yM.setState({closeRequest:null}),o(null)},f=()=>{i&&u&&(yM.getState().discard(u.resourceId),FM.getState().closeTab(i.windowId,i.tabId),d())};return(0,g.jsxs)(g.Fragment,{children:[[...l].map(([e,t])=>(0,g.jsx)(r3,{...t},e)),i&&u&&r[u.resourceId]?(0,g.jsx)(Wc,{open:!0,onOpenChange:e=>{!e&&!s&&d()},children:(0,g.jsxs)(Kc,{className:`pointer-events-auto space-y-4 text-sm`,children:[(0,g.jsx)(qc,{children:`未保存的文件`}),(0,g.jsxs)(Jc,{children:[u.title,` 有未保存的改动。`]}),(0,g.jsx)(Yc,{message:a,onDismiss:()=>o(null)}),(0,g.jsxs)(`div`,{className:`flex gap-3`,children:[(0,g.jsx)(V,{type:`button`,disabled:s,onClick:()=>{c(!0),WM(u).then(f).catch(e=>o(VM(e))).finally(()=>c(!1))},children:`保存并关闭`}),(0,g.jsx)(V,{type:`button`,variant:`secondary`,disabled:s,onClick:f,children:`放弃改动`}),(0,g.jsx)(V,{type:`button`,variant:`secondary`,disabled:s,onClick:d,children:`取消`})]})]})}):null]})}function a3(){let e=FM(e=>e.closeRequest);return e?(0,g.jsx)(o3,{request:e},JSON.stringify(e)):null}function o3({request:e}){let t=FM(e=>e.windows),n=yM(e=>e.drafts),r=yM(e=>e.saving),[i,a]=(0,h.useState)(e.tabIds.length<=1),[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(``),u=t.find(t=>t.id===e.windowId)?.tabs.filter(t=>e.tabIds.includes(t.id))??[],d=u.find(e=>e.file&&n[e.resourceId]),f=o||u.some(e=>r[e.resourceId]),p=()=>FM.setState({closeRequest:null});return(0,h.useEffect)(()=>{if(!(!i||d||f)){for(let t of u)FM.getState().closeTab(e.windowId,t.id);FM.setState({closeRequest:null})}},[i,d,f,u,e.windowId]),i&&!d?null:(0,g.jsx)(Wc,{open:!0,onOpenChange:e=>{!e&&!f&&p()},children:(0,g.jsxs)(Kc,{className:`pointer-events-auto space-y-4 text-sm`,onEscapeKeyDown:e=>{f&&e.preventDefault()},onPointerDownOutside:e=>{f&&e.preventDefault()},children:[(0,g.jsx)(qc,{children:i?`未保存的文件`:`关闭 ${u.length} 个 Tab?`}),(0,g.jsx)(Jc,{children:i?`${d?.title??`文件`} 有未保存的改动。`:`最小化可以保留这些 Tab,关闭后需要重新打开。`}),(0,g.jsx)(Yc,{message:c,onDismiss:()=>l(``)}),(0,g.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,g.jsx)(V,{variant:`secondary`,disabled:f,onClick:p,children:`取消`}),i?d?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(V,{variant:`secondary`,disabled:f,onClick:()=>{yM.getState().discard(d.resourceId),l(``)},children:`放弃改动并继续`}),(0,g.jsx)(V,{disabled:f,onClick:()=>{s(!0),l(``),WM(d).then(()=>{yM.getState().drafts[d.resourceId]&&l(`文件在保存期间有新改动,请再次保存。`)}).catch(()=>l(`保存失败,已保留文件和草稿,请核对后重试。`)).finally(()=>s(!1))},children:`保存并继续`})]}):null:(0,g.jsx)(V,{onClick:()=>a(!0),children:`关闭全部 Tab`})]})]})})}function s3({window:e}){let[t,n]=(0,h.useState)(!e.minimized);if(!t){if(e.minimized)return null;n(!0)}return(0,g.jsx)(t3,{window:e})}function c3(){let{projectId:e,sessionId:t}=vW(),{data:n}=sM(),r=gW(e,t,n.sessions),i=FM(e=>e.windows),a=FM(e=>e.setBounds);return(0,h.useEffect)(()=>{let e=()=>{for(let e of FM.getState().windows)e.maximized||a(e.id,{x:e.x,y:e.y,width:e.width,height:e.height})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[a]),(0,h.useEffect)(()=>{let e=window.setTimeout(()=>{for(let e of FM.getState().windows)e.maximized||a(e.id,{x:e.x,y:e.y,width:e.width,height:e.height})},50);return()=>window.clearTimeout(e)},[a]),(0,h.useEffect)(()=>{let e=e=>{e.button===0&&e.target instanceof Element&&(document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)||e.target.closest(`[data-window-frame], [data-window-dock], [data-project-resources], [role="dialog"], [role="alertdialog"], [role="menu"]`)||FM.getState().hideScope(r))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[r]),(0,g.jsx)(V4,{windows:i,children:(0,g.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-40 overflow-hidden`,children:[(0,g.jsx)(a3,{}),(0,g.jsx)(i3,{}),i.filter(e=>kM(e)===r).map(e=>(0,g.jsx)(s3,{window:e},e.id))]})})}var l3={files:No,terminal:dc,services:rc,browser:Co,"git-diff":Xo};function u3(){let{data:e}=sM(),{projectId:t,sessionId:n}=vW(),{windows:r,focusedId:i,open:a,restore:o}=FM(),s=(Zg({queryKey:lK(),queryFn:()=>dK(),enabled:!0,refetchInterval:3e3}).data??[]).filter(e=>e.status===`RUNNING`&&e.projectId===t).length,c=gW(t,n,e.sessions),l=hW(t,n,e.sessions),u=r.filter(e=>kM(e)===c),d=n=>{let r=u.find(e=>e.tabs[0]?.kind===n);r?o(r.id):(e.terminals.find(e=>e.projectId===t),e.services.find(e=>e.projectId===t),a({kind:n,resourceId:`${n}:empty`,title:n===`terminal`?`终端`:`服务`,projectId:t,sessionId:`sessionId`in l?l.sessionId:null,source:t?`project`:`session`}))};return(0,g.jsx)(`div`,{className:`pointer-events-none relative z-10 mb-1.5 flex justify-center px-1`,children:(0,g.jsxs)(`nav`,{"aria-label":`项目窗口`,"data-window-dock":!0,className:`window-tabs-scroll pointer-events-auto flex max-w-full items-center gap-0.5 overflow-x-auto rounded-[10px] border border-line bg-surface/90 p-0.5 shadow-[var(--shadow-card)] backdrop-blur-xl`,children:[[`terminal`,`services`].map(e=>{let t=l3[e],n=u.find(t=>t.tabs[0]?.kind===e),r=n&&!n.minimized&&n.id===i;return(0,g.jsxs)(`button`,{type:`button`,"aria-label":e===`terminal`?`打开终端窗口`:`打开服务窗口`,"aria-pressed":!!r,onClick:()=>d(e),className:B(`flex h-6 shrink-0 items-center gap-1 rounded-md px-1.5 [@media(pointer:coarse)]:h-11 text-[11px] font-medium transition-colors`,r?`bg-accent-soft text-accent`:`text-ink-2 hover:bg-surface-2 hover:text-ink`),children:[(0,g.jsx)(t,{size:12,strokeWidth:1.7,className:e===`terminal`?`text-accent`:`text-success`}),e===`terminal`?`终端`:`服务`,e===`services`&&s>0?(0,g.jsx)(`span`,{className:`rounded bg-black/[.045] px-1 font-mono text-[9px] dark:bg-white/[.08]`,children:s}):null,e===`terminal`&&n&&n.tabs.filter(e=>!e.resourceId.endsWith(`:empty`)).length>0?(0,g.jsx)(`span`,{className:`rounded bg-black/[.045] px-1 font-mono text-[9px] dark:bg-white/[.08]`,children:n.tabs.filter(e=>!e.resourceId.endsWith(`:empty`)).length}):null]},e)}),u.filter(e=>e.minimized&&![`terminal`,`services`].includes(e.tabs[0]?.kind??``)).map(e=>{let t=e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0];if(!t)return null;let n=l3[t.kind];return(0,g.jsxs)(`button`,{type:`button`,"aria-label":`恢复 ${t.title}`,onClick:()=>o(e.id),title:t.title,className:`flex h-6 max-w-32 shrink-0 items-center gap-1 rounded-md px-1.5 [@media(pointer:coarse)]:h-11 text-[11px] text-ink-2 transition-colors hover:bg-surface-2 hover:text-ink`,children:[(0,g.jsx)(n,{size:12,className:`shrink-0 text-accent`}),(0,g.jsx)(`span`,{className:`truncate`,children:t.title}),e.tabs.length>1?(0,g.jsx)(`span`,{className:`text-[9px] text-ink-3`,children:e.tabs.length}):null]},e.id)})]})})}function d3(e){let t=new Set(e.filter(e=>e.kind===`message`&&e.role===`user`&&e.turnOutcome!==void 0).map(e=>e.turnId));return e.filter(e=>e.kind===`approval`&&e.status===`pending`&&(e.turnId===void 0||!t.has(e.turnId)))}function f3(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var p3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,m3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,h3={};function g3(e,t){return((t||h3).jsx?m3:p3).test(e)}var _3=/[ \t\n\f\r]/g;function v3(e){return typeof e==`object`?e.type===`text`&&y3(e.value):y3(e)}function y3(e){return e.replace(_3,``)===``}var b3=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};b3.prototype.normal={},b3.prototype.property={},b3.prototype.space=void 0;function x3(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new b3(n,r,t)}function S3(e){return e.toLowerCase()}var C3=class{constructor(e,t){this.attribute=t,this.property=e}};C3.prototype.attribute=``,C3.prototype.booleanish=!1,C3.prototype.boolean=!1,C3.prototype.commaOrSpaceSeparated=!1,C3.prototype.commaSeparated=!1,C3.prototype.defined=!1,C3.prototype.mustUseProperty=!1,C3.prototype.number=!1,C3.prototype.overloadedBoolean=!1,C3.prototype.property=``,C3.prototype.spaceSeparated=!1,C3.prototype.space=void 0;var w3=c({boolean:()=>E3,booleanish:()=>D3,commaOrSpaceSeparated:()=>j3,commaSeparated:()=>A3,number:()=>$,overloadedBoolean:()=>O3,spaceSeparated:()=>k3}),T3=0,E3=M3(),D3=M3(),O3=M3(),$=M3(),k3=M3(),A3=M3(),j3=M3();function M3(){return 2**++T3}var N3=Object.keys(w3),P3=class extends C3{constructor(e,t,n,r){let i=-1;if(super(e,t),F3(this,`space`,r),typeof n==`number`)for(;++i<N3.length;){let e=N3[i];F3(this,N3[i],(n&w3[e])===w3[e])}}};P3.prototype.defined=!0;function F3(e,t,n){n&&(e[t]=n)}function I3(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new P3(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[S3(r)]=r,n[S3(a.attribute)]=r}return new b3(t,n,e.space)}var L3=I3({properties:{ariaActiveDescendant:null,ariaAtomic:D3,ariaAutoComplete:null,ariaBusy:D3,ariaChecked:D3,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:k3,ariaCurrent:null,ariaDescribedBy:k3,ariaDetails:null,ariaDisabled:D3,ariaDropEffect:k3,ariaErrorMessage:null,ariaExpanded:D3,ariaFlowTo:k3,ariaGrabbed:D3,ariaHasPopup:null,ariaHidden:D3,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:k3,ariaLevel:$,ariaLive:null,ariaModal:D3,ariaMultiLine:D3,ariaMultiSelectable:D3,ariaOrientation:null,ariaOwns:k3,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:D3,ariaReadOnly:D3,ariaRelevant:null,ariaRequired:D3,ariaRoleDescription:k3,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:D3,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function R3(e,t){return t in e?e[t]:t}function z3(e,t){return R3(e,t.toLowerCase())}var B3=I3({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:A3,acceptCharset:k3,accessKey:k3,action:null,allow:null,allowFullScreen:E3,allowPaymentRequest:E3,allowUserMedia:E3,alpha:E3,alt:null,as:null,async:E3,autoCapitalize:null,autoComplete:k3,autoFocus:E3,autoPlay:E3,blocking:k3,capture:null,charSet:null,checked:E3,cite:null,className:k3,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:D3,controls:E3,controlsList:k3,coords:$|A3,crossOrigin:null,data:null,dateTime:null,decoding:null,default:E3,defer:E3,dir:null,dirName:null,disabled:E3,download:O3,draggable:D3,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:E3,formTarget:null,headers:k3,height:$,hidden:O3,high:$,href:null,hrefLang:null,htmlFor:k3,httpEquiv:k3,id:null,imageSizes:null,imageSrcSet:null,inert:E3,inputMode:null,integrity:null,is:null,isMap:E3,itemId:null,itemProp:k3,itemRef:k3,itemScope:E3,itemType:k3,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:E3,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:E3,muted:E3,name:null,nonce:null,noModule:E3,noValidate:E3,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:E3,optimum:$,pattern:null,ping:k3,placeholder:null,playsInline:E3,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:E3,referrerPolicy:null,rel:k3,required:E3,reversed:E3,rows:$,rowSpan:$,sandbox:k3,scope:null,scoped:E3,seamless:E3,selected:E3,shadowRootClonable:E3,shadowRootCustomElementRegistry:E3,shadowRootDelegatesFocus:E3,shadowRootMode:null,shadowRootSerializable:E3,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:D3,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:E3,useMap:null,value:D3,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:k3,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:E3,declare:E3,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:E3,noHref:E3,noShade:E3,noWrap:E3,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:D3,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:E3,disablePictureInPicture:E3,disableRemotePlayback:E3,exportParts:A3,part:k3,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:z3}),V3=I3({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:j3,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:k3,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:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:E3,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,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:A3,g2:A3,glyphName:A3,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:j3,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,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:$,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:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:k3,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:j3,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:j3,rev:j3,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:j3,requiredFeatures:j3,requiredFonts:j3,requiredFormats:j3,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:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:j3,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:j3,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:j3,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:R3}),H3=I3({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),U3=I3({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:z3}),W3=I3({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),G3={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`},K3=/[A-Z]/g,q3=/-[a-z]/g,J3=/^data[-\w.:]+$/i;function Y3(e,t){let n=S3(t),r=t,i=C3;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&J3.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(q3,Z3);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!q3.test(e)){let n=e.replace(K3,X3);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=P3}return new i(r,t)}function X3(e){return`-`+e.toLowerCase()}function Z3(e){return e.charAt(1).toUpperCase()}var Q3=x3([L3,B3,H3,U3,W3],`html`),$3=x3([L3,V3,H3,U3,W3],`svg`);function e6(e){return e.join(` `).trim()}var t6=/\/\*(?:[^*]|\*(?!\/))*\*\//g,n6=/\n/g,r6=/^\s*/,i6=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a6=/^:\s*/,o6=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,s6=/^[;\s]*/,c6=`
|
|
127
127
|
`,l6=`/`,u6=`*`,d6=``,f6=`comment`,p6=`declaration`;function m6(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var n=1,r=1;function i(e){var t=e.match(n6);t&&(n+=t.length);var i=e.lastIndexOf(c6);r=~i?e.length-i:r+e.length}function a(){var e={line:n,column:r};return function(t){return t.position=new o(e),l(),t}}function o(e){this.start=e,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(i){var a=Error(t.source+`:`+n+`:`+r+`: `+i);if(a.reason=i,a.filename=t.source,a.line=n,a.column=r,a.source=e,!t.silent)throw a}function c(t){var n=t.exec(e);if(n){var r=n[0];return i(r),e=e.slice(r.length),n}}function l(){c(r6)}function u(e){for(var t;t=d();)e.push(t);return e}function d(){var t=a();if(l6==e.charAt(0)&&u6==e.charAt(1)){for(var n=2;d6!=e.charAt(n)&&(u6!=e.charAt(n)||l6!=e.charAt(n+1));)++n;if(n+=2,d6===e.charAt(n-1))return s(`End of comment missing`);var o=e.slice(2,n-2);return r+=2,i(o),e=e.slice(n),r+=2,t({type:f6,comment:o})}}function f(){var e=a(),t=c(i6);if(t){if(d(),!c(a6))return s(`property missing ':'`);var n=c(o6),r=e({type:p6,property:t[0].replace(t6,d6).trim(),value:n?n[0].replace(t6,d6).trim():d6});return c(s6),r}}function p(){var e=[];u(e);for(var t;t=f();)e.push(t),u(e);return e}return l(),p()}function h6(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=m6(e),i=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:a}=e;i?t(r,a,e):a&&(n??={},n[r]=a)}),n}var g6=v6(`end`),_6=v6(`start`);function v6(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function y6(e){let t=_6(e),n=g6(e);if(t&&n)return{start:t,end:n}}function b6(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?S6(e.position):`start`in e||`end`in e?S6(e):`line`in e||`column`in e?x6(e):``}function x6(e){return C6(e&&e.line)+`:`+C6(e&&e.column)}function S6(e){return x6(e&&e.start)+`-`+x6(e&&e.end)}function C6(e){return e&&typeof e==`number`?e:1}var w6=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=b6(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};w6.prototype.file=``,w6.prototype.name=``,w6.prototype.reason=``,w6.prototype.message=``,w6.prototype.stack=``,w6.prototype.column=void 0,w6.prototype.line=void 0,w6.prototype.ancestors=void 0,w6.prototype.cause=void 0,w6.prototype.fatal=void 0,w6.prototype.place=void 0,w6.prototype.ruleId=void 0,w6.prototype.source=void 0;var T6={}.hasOwnProperty,E6=new Map,D6=/[A-Z]/g,O6=/-([a-z])/g,k6=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),A6=new Set([`td`,`th`]),j6=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function M6(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=U6(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=H6(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?$3:Q3,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=N6(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function N6(e,t,n){if(t.type===`element`)return P6(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return F6(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return L6(e,t,n);if(t.type===`mdxjsEsm`)return I6(e,t);if(t.type===`root`)return R6(e,t,n);if(t.type===`text`)return z6(e,t)}function P6(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=$3,e.schema=i),e.ancestors.push(t);let a=Y6(e,t.tagName,!1),o=W6(e,t),s=K6(e,t);return k6.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!v3(e)})),B6(e,o,a,t),V6(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function F6(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}X6(e,t.position)}function I6(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);X6(e,t.position)}function L6(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=$3,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Y6(e,t.name,!0),o=G6(e,t),s=K6(e,t);return B6(e,o,a,t),V6(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function R6(e,t,n){let r={};return V6(r,K6(e,t)),e.create(t,e.Fragment,r,n)}function z6(e,t){return t.value}function B6(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function V6(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function H6(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function U6(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=_6(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function W6(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&T6.call(t.properties,i)){let a=q6(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&A6.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function G6(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else X6(e,t.position)}else{let{name:i}=r,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else X6(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function K6(e,t){let n=[],r=-1,i=e.passKeys?new Map:E6;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=N6(e,a,o);s!==void 0&&n.push(s)}return n}function q6(e,t,n){if(n==null||typeof n==`number`&&Number.isNaN(n))return;let r=Y3(e.schema,t);return Array.isArray(n)&&(n=r.commaSeparated?f3(n):e6(n)),r.property===`style`?[`style`,typeof n==`object`?e.stylePropertyNameCase===`dom`?n:Z6(n):J6(e,String(n))]:[e.elementAttributeNameCase===`react`&&r.space?G3[r.property]||r.property:r.attribute,n]}function J6(e,t){let n={};try{h6(t,function(t,r){if(t&&r){let i=t;i.slice(0,2)!==`--`&&(i=i.toLowerCase(),e.stylePropertyNameCase===`dom`&&(i.slice(0,4)===`-ms-`&&(i=i.slice(1)),i=i.replace(O6,e8))),n[i]=r}})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new w6("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=j6+`#cannot-parse-style-attribute`,r}return n}function Y6(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=g3(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=g3(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return T6.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);X6(e)}function X6(e,t){let n=new w6("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=j6+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Z6(e){let t={},n;for(n in e)T6.call(e,n)&&(t[Q6(n)]=e[n]);return t}function Q6(e){if(e.slice(0,2)===`--`)return e;let t=e.replace(D6,$6);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function $6(e){return`-`+e.toLowerCase()}function e8(e,t){return t.toUpperCase()}var t8={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`]},n8={};function r8(e,t){let n=t||n8;return i8(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function i8(e,t,n){if(o8(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return a8(e.children,t,n)}return Array.isArray(e)?a8(e,t,n):``}function a8(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=i8(e[i],t,n);return r.join(``)}function o8(e){return!!(e&&typeof e==`object`)}var s8=document.createElement(`i`);function c8(e){let t=`&`+e+`;`;s8.innerHTML=t;let n=s8.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function l8(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function u8(e,t){return e.length>0?(l8(e,e.length,0,t),e):t}var d8={}.hasOwnProperty;function f8(e){let t={},n=-1;for(;++n<e.length;)p8(t,e[n]);return t}function p8(e,t){let n;for(n in t){let r=(d8.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){d8.call(r,a)||(r[a]=[]);let e=i[a];m8(r[a],Array.isArray(e)?e:e?[e]:[])}}}function m8(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);l8(e,0,0,r)}function h8(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function g8(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var _8=k8(/[A-Za-z]/),v8=k8(/[\dA-Za-z]/),y8=k8(/[#-'*+\--9=?A-Z^-~]/);function b8(e){return e!==null&&(e<32||e===127)}var x8=k8(/\d/),S8=k8(/[\dA-Fa-f]/),C8=k8(/[!-/:-@[-`{-~]/);function w8(e){return e!==null&&e<-2}function T8(e){return e!==null&&(e<0||e===32)}function E8(e){return e===-2||e===-1||e===32}var D8=k8(/\p{P}|\p{S}/u),O8=k8(/\s/);function k8(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function A8(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&v8(e.charCodeAt(n+1))&&v8(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function j8(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return E8(r)?(e.enter(n),s(r)):t(r)}function s(r){return E8(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function M8(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&E8(t)?(e.enter(r),c(t)):l(t)}function c(t){return E8(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var N8={tokenize:P8};function P8(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),j8(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return w8(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var F8=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){I8(this,e,t,n,!1)}addBefore(e,t,n){I8(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function I8(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var L8={tokenize:z8},R8={tokenize:B8};function z8(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new F8;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(R8,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(R8,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return w8(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new F8;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function B8(e,t,n){return j8(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function V8(e){if(e===null||T8(e)||O8(e))return 1;if(D8(e))return 2}function H8(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var U8={name:`attention`,resolveAll:W8,tokenize:G8};function W8(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};K8(o,-a),K8(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=u8(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=u8(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=u8(r,H8(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=u8(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=u8(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),l8(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function G8(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=V8(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=V8(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function K8(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var q8={name:`autolink`,tokenize:J8};function J8(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return _8(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||v8(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||v8(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||b8(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):y8(t)?(e.consume(t),l):n(t)}function u(e){return v8(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||v8(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Y8={partial:!0,tokenize:X8};function X8(e,t,n){return r;function r(t){return E8(t)?j8(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||w8(e)?t(e):n(e)}}var Z8={continuation:{tokenize:$8},exit:e5,name:`blockQuote`,tokenize:Q8};function Q8(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return E8(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function $8(e,t,n){let r=this;return i;function i(t){return E8(t)?j8(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Z8,t,n)(r)}}function e5(e){e.exit(`blockQuote`)}var t5={name:`characterEscape`,tokenize:n5};function n5(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return C8(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var r5={name:`characterReference`,tokenize:i5};function i5(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=v8,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=S8,u):(e.enter(`characterReferenceValue`),a=7,o=x8,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===v8&&!c8(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var a5={partial:!0,tokenize:ire};function ire(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var o5={concrete:!0,name:`codeFenced`,tokenize:are};function are(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),E8(t)?j8(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||w8(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(a5,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||w8(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):E8(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),j8(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||w8(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||w8(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&E8(t)?j8(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||w8(t)?e.check(a5,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||w8(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),E8(t)?j8(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),E8(t)?j8(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||w8(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var s5={name:`codeIndented`,tokenize:sre},ore={partial:!0,tokenize:cre};function sre(e,t,n){return r;function r(t){return e.enter(`codeIndented`),M8(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):w8(t)?e.attempt(ore,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||w8(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function cre(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):w8(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):M8(e,t,a,`linePrefix`,4,4)(o)}function a(e){return w8(e)?i(e):n(e)}}var lre={name:`codeText`,previous:dre,resolve:ure,tokenize:fre};function ure(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function dre(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function fre(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):w8(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||w8(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var pre=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&c5(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),c5(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),c5(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);c5(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);c5(this.left,t.reverse())}}}};function c5(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function l5(e){let t={},n=-1,r,i,a,o,s,c,l,u=new pre(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,mre(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return l8(e,0,1/0,u.slice(0)),!l}function mre(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var hre={resolve:_re,tokenize:vre},gre={partial:!0,tokenize:yre};function _re(e){return l5(e),e}function vre(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):w8(t)?e.check(gre,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function yre(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j8(e,a,`linePrefix`)}function a(i){if(i===null||w8(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function u5(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||b8(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||w8(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||T8(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||b8(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function d5(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):w8(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||w8(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!E8(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function f5(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):w8(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j8(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||w8(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function p5(e,t){let n;return r;function r(i){return w8(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):E8(i)?j8(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var bre={name:`definition`,tokenize:Sre},xre={partial:!0,tokenize:Cre};function Sre(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return d5.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=g8(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return T8(t)?p5(e,l)(t):l(t)}function l(t){return u5(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(xre,d,d)(t)}function d(t){return E8(t)?j8(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||w8(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Cre(e,t,n){return r;function r(t){return T8(t)?p5(e,i)(t):n(t)}function i(t){return f5(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return E8(t)?j8(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||w8(e)?t(e):n(e)}}var wre={name:`hardBreakEscape`,tokenize:Tre};function Tre(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return w8(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Ere={name:`headingAtx`,resolve:Dre,tokenize:Ore};function Dre(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};l8(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function Ore(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||T8(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||w8(n)?(e.exit(`atxHeading`),t(n)):E8(n)?j8(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||T8(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var m5=`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`.split(`.`),h5=[`pre`,`script`,`style`,`textarea`],kre={concrete:!0,name:`htmlFlow`,resolveTo:jre,tokenize:Mre},Are={partial:!0,tokenize:Nre};function jre(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Mre(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:P):_8(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):_8(a)?(e.consume(a),i=4,r.interrupt?t:P):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:P):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return _8(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||T8(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&h5.includes(l)?(i=1,r.interrupt?t(s):O(s)):m5.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||v8(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return E8(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||_8(t)?(e.consume(t),b):E8(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||v8(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):E8(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):E8(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||w8(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||T8(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||E8(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||w8(t)?O(t):E8(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),F):t===63&&i===3?(e.consume(t),P):t===93&&i===5?(e.consume(t),te):w8(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Are,ne,k)(t)):t===null||w8(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(a5,A,ne)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||w8(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),P):O(t)}function N(t){return t===47?(e.consume(t),o=``,ee):O(t)}function ee(t){if(t===62){let n=o.toLowerCase();return h5.includes(n)?(e.consume(t),F):O(t)}return _8(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ee):O(t)}function te(t){return t===93?(e.consume(t),P):O(t)}function P(t){return t===62?(e.consume(t),F):t===45&&i===2?(e.consume(t),P):O(t)}function F(t){return t===null||w8(t)?(e.exit(`htmlFlowData`),ne(t)):(e.consume(t),F)}function ne(n){return e.exit(`htmlFlow`),t(n)}}function Nre(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Y8,t,n)}}var Pre={name:`htmlText`,tokenize:Fre};function Fre(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):_8(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):_8(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):w8(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):w8(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):w8(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):w8(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return _8(t)?(e.consume(t),S):n(t)}function S(t){return t===45||v8(t)?(e.consume(t),S):C(t)}function C(t){return w8(t)?(o=C,N(t)):E8(t)?(e.consume(t),C):M(t)}function w(t){return t===45||v8(t)?(e.consume(t),w):t===47||t===62||T8(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||_8(t)?(e.consume(t),E):w8(t)?(o=T,N(t)):E8(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||v8(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):w8(t)?(o=D,N(t)):E8(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):w8(t)?(o=O,N(t)):E8(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):w8(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||T8(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||T8(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ee}function ee(t){return E8(t)?j8(e,te,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):te(t)}function te(t){return e.enter(`htmlTextData`),o(t)}}var g5={name:`labelEnd`,resolveAll:zre,resolveTo:Bre,tokenize:Vre},Ire={tokenize:Hre},Lre={tokenize:Ure},Rre={tokenize:Wre};function zre(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&l8(e,0,e.length,n),e}function Bre(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=u8(o,e.slice(i+1,i+r+3)),o=u8(o,[[`enter`,l,t]]),o=u8(o,H8(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=u8(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=u8(o,e.slice(a+1)),o=u8(o,[[`exit`,s,t]]),l8(e,i,e.length,o),e}function Vre(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(g8(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Ire,u,o?u:d)(t):t===91?e.attempt(Lre,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Rre,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function Hre(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return T8(t)?p5(e,a)(t):a(t)}function a(t){return t===41?u(t):u5(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return T8(t)?p5(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?f5(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return T8(t)?p5(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Ure(e,t,n){let r=this;return i;function i(t){return d5.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(g8(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Wre(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Gre={name:`labelStartImage`,resolveAll:g5.resolveAll,tokenize:Kre};function Kre(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var qre={name:`labelStartLink`,resolveAll:g5.resolveAll,tokenize:Jre};function Jre(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var _5={name:`lineEnding`,tokenize:Yre};function Yre(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),j8(e,t,`linePrefix`)}}var v5={name:`thematicBreak`,tokenize:Xre};function Xre(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||w8(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),E8(t)?j8(e,s,`whitespace`)(t):s(t))}}var y5={continuation:{tokenize:eie},exit:nie,name:`list`,tokenize:$re},Zre={partial:!0,tokenize:rie},Qre={partial:!0,tokenize:tie};function $re(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:x8(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(v5,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return x8(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Y8,r.interrupt?n:u,e.attempt(Zre,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return E8(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function eie(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Y8,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,j8(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!E8(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Qre,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,j8(e,e.attempt(y5,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function tie(e,t,n){let r=this;return j8(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function nie(e){e.exit(this.containerState.type)}function rie(e,t,n){let r=this;return j8(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!E8(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var b5={name:`setextUnderline`,resolveTo:iie,tokenize:aie};function iie(e,t){let n=new F8,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function aie(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),E8(t)?j8(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||w8(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var oie={tokenize:sie};function sie(e){let t=this,n=e.attempt(Y8,r,e.attempt(this.parser.constructs.flowInitial,i,j8(e,e.attempt(this.parser.constructs.flow,i,e.attempt(hre,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var cie={resolveAll:S5()},lie=x5(`string`),uie=x5(`text`);function x5(e){return{resolveAll:S5(e===`text`?die:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function S5(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):t[r]&&t[r][1].type===`data`||(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function die(e,t){let n=new F8,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var fie=c({attentionMarkers:()=>bie,contentInitial:()=>mie,disable:()=>xie,document:()=>pie,flow:()=>gie,flowInitial:()=>hie,insideSpan:()=>yie,string:()=>_ie,text:()=>vie}),pie={42:y5,43:y5,45:y5,48:y5,49:y5,50:y5,51:y5,52:y5,53:y5,54:y5,55:y5,56:y5,57:y5,62:Z8},mie={91:bre},hie={[-2]:s5,[-1]:s5,32:s5},gie={35:Ere,42:v5,45:[b5,v5],60:kre,61:b5,95:v5,96:o5,126:o5},_ie={38:r5,92:t5},vie={[-5]:_5,[-4]:_5,[-3]:_5,33:Gre,38:r5,42:U8,60:[q8,Pre],91:qre,92:[wre,t5],93:g5,95:U8,96:lre},yie={null:[U8,cie]},bie={null:[42,95]},xie={null:[]};function Sie(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=u8(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=H8(a,l.events,l),l.events):[]}function f(e,t){return wie(p(e),t)}function p(e){return Cie(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){w8(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&l8(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Cie(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function wie(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
128
128
|
`;break;case-3:o=`\r
|
|
129
129
|
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Tie(e){let t={constructs:f8([fie,...(e||{}).extensions||[]]),content:n(N8),defined:[],document:n(L8),flow:n(oie),lazy:{},string:n(lie),text:n(uie)};return t;function n(e){return n;function n(n){return Sie(t,e,n)}}}function Eie(e){for(;!l5(e););return e}var C5=/[\0\t\n\r]/g;function Die(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){C5.lastIndex=c;let n=C5.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Oie=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function kie(e){return e.replace(Oie,Aie)}function Aie(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return h8(n.slice(t?2:1),t?16:10)}return c8(n)||e}var w5={}.hasOwnProperty;function jie(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Mie(n)(Eie(Tie(n).document().write(Die()(e,t,!0))))}function Mie(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(ve),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(me),blockQuote:o(ue),characterEscape:E,characterReference:E,codeFenced:o(de),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(de,s),codeText:o(L,s),codeTextData:E,data:E,codeFlowValue:E,definition:o(fe),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(pe),hardBreakEscape:o(he),hardBreakTrailing:o(he),htmlFlow:o(ge,s),htmlFlowData:E,htmlText:o(ge,s),htmlTextData:E,image:o(_e),label:s,link:o(ve),listItem:o(be),listItemValue:p,listOrdered:o(ye,f),listUnordered:o(ye),paragraph:o(xe),reference:re,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(me),strong:o(Se),thematicBreak:o(we)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:le,autolinkProtocol:ce,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:oe,characterReference:se,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:D,codeIndented:l(v),codeText:l(M),codeTextData:D,data:D,definition:l(),definitionDestinationString:x,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(k),hardBreakTrailing:l(k),htmlFlow:l(A),htmlFlowData:D,htmlText:l(j),htmlTextData:D,image:l(ee),label:P,labelText:te,lineEnding:O,link:l(N),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ie,resourceDestinationString:F,resourceTitleString:ne,resource:I,setextHeading:l(T),setextHeadingLineSequence:w,setextHeadingText:C,strong:l(),thematicBreak:l()}};E5(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[],position:void 0},o={stack:[r],tokenStack:[],config:t,enter:c,exit:u,buffer:s,resume:d,data:n},l=[],f=[],p=-1;for(;++p<e.length;)f.push(e[p]),(e[p][1].type===`listOrdered`||e[p][1].type===`listUnordered`)&&(e[p][0]===`enter`?l.push(f.length-1):a(f,l.pop()));for(e=f,p=-1;++p<e.length;){let n=t[e[p][0]];e[p][0]===`enter`&&t.beforeEnter.length>0&&i(t.beforeEnter,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),w5.call(n,e[p][1].type)&&n[e[p][1].type].call({...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),e[p][0]===`exit`&&t.afterExit.length>0&&i(t.afterExit,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||D5).call(o,void 0,e[0])}for(r.position={start:T5(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:T5(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},p=-1;++p<t.transforms.length;)r=t.transforms[p](r)||r;return r}function i(e,t,n){let r=-1;for(;++r<e.length;)e[r].call(t,n)}function a(e,t){let n=e.length-1,r=t-1,i=-1,a=!1,o,s,c,l,u=[];for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let n=r;for(s=void 0;n--;){let t=e[n];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=n}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),u.push({at:s||r,event:[`exit`,o,t[2]]})}if(t[1].type===`listItemPrefix`){let e={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=e,u.push({at:r,event:[`enter`,e,t[2]]}),c=void 0,l=!0}}}let d=e.splice(t),f=0;for(r=-1;++r<d.length;){for(;f<u.length&&u[f].at===t+r;)e.push(u[f++].event);e.push(d[r])}e[t][1]._spread=a}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:T5(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw Error("Cannot close `"+e.type+"` ("+b6({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||D5).call(this,e,r[0])),n.position.end=T5(e.end)}function d(){return r8(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function h(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function v(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function y(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=g8(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function x(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function S(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function C(){this.data.setextHeadingSlurpLineEnding=!0}function w(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&n.type===`text`||(n=Ce(),n.position={start:T5(e.start),end:void 0},t.push(n)),this.stack.push(n)}function D(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=T5(e.end)}function O(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=T5(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(E.call(this,e),D.call(this,e))}function k(){this.data.atHardBreak=!0}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ee(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function te(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=kie(t),n.identifier=g8(t).toLowerCase()}function P(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function F(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ne(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function I(){this.data.inReference=void 0}function re(){this.data.referenceType=`collapsed`}function ie(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=g8(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ae(e){this.data.characterReferenceType=e.type}function oe(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=h8(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=c8(t);let i=this.stack[this.stack.length-1];i.value+=r}function se(e){let t=this.stack.pop();t.position.end=T5(e.end)}function ce(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function le(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ue(){return{type:`blockquote`,children:[],position:void 0}}function de(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function L(){return{type:`inlineCode`,value:``,position:void 0}}function fe(){return{type:`definition`,identifier:``,label:null,title:null,url:``,position:void 0}}function pe(){return{type:`emphasis`,children:[],position:void 0}}function me(){return{type:`heading`,depth:0,children:[],position:void 0}}function he(){return{type:`break`,position:void 0}}function ge(){return{type:`html`,value:``,position:void 0}}function _e(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function ve(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function ye(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function be(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function xe(){return{type:`paragraph`,children:[],position:void 0}}function Se(){return{type:`strong`,children:[],position:void 0}}function Ce(){return{type:`text`,value:``,position:void 0}}function we(){return{type:`thematicBreak`,position:void 0}}}function T5(e){return{line:e.line,column:e.column,offset:e.offset}}function E5(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?E5(e,r):Nie(e,r)}}function Nie(e,t){let n;for(n in t)if(w5.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`afterExit`:case`beforeEnter`:{let r=t[n];r&&e[n].push(r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function D5(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+b6({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+b6({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+b6({start:t.start,end:t.end})+`) is still open`)}function Pie(e){let t=this;t.parser=n;function n(n){return jie(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function Fie(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Iie(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
@@ -154,4 +154,4 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
154
154
|
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=j7(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}V7.peek=lse;function V7(e){return e.value||``}function lse(){return`<`}H7.peek=use;function H7(e,t,n,r){let i=O7(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function use(){return`!`}U7.peek=dse;function U7(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function dse(){return`!`}W7.peek=fse;function W7(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function fse(){return"`"}function G7(e,t){let n=r8(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}K7.peek=pse;function K7(e,t,n,r){let i=O7(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(G7(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`),u=n.containerPhrasing(e,{before:l,after:`](`,...o.current()});l+=o.move(u),c(),l+=o.move(`](`);let d=/[\0- \u007F]/.test(e.url),f=r.before.charAt(r.before.length-1),p=e.title||void 0;if(!p&&!d&&(f===`
|
|
155
155
|
`||f===`\r`)){let e=0;for(;e<u.length&&u.charCodeAt(e)!==93;)e+=u.charCodeAt(e)===92?2:1;u.charCodeAt(e+1)===58&&(p=``)}return!e.url&&typeof p==`string`||d?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:typeof p==`string`?` `:`)`,...o.current()}))),c(),typeof p==`string`&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(p,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function pse(e,t,n){return G7(e,n)?`<`:`[`}q7.peek=mse;function q7(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function mse(){return`[`}function J7(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function hse(e){let t=J7(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function gse(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Y7(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function _se(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?gse(n):J7(n),s=e.ordered?o===`.`?`)`:`.`:hse(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if(o!==`*`&&o!==`-`||!t||t.children&&t.children[0]||n.stack[n.stack.length-1]!==`list`||n.stack[n.stack.length-2]!==`listItem`||n.stack[n.stack.length-3]!==`list`||n.stack[n.stack.length-4]!==`listItem`||n.indexStack[n.indexStack.length-1]!==0||n.indexStack[n.indexStack.length-2]!==0||n.indexStack[n.indexStack.length-3]!==0||(c=!0),Y7(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function vse(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function yse(e,t,n,r){let i=vse(n),a=n.bulletCurrent||J7(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function bse(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function xse(e,t,n,r){if(!e.children.some(function(e){return Uoe(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function Sse(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}X7.attention=Z7,X7.peek=Cse;function X7(e,t,n,r){let i=n.enter(`phrasing`),a=R7([I7(e,Z7,n,n.createTracker(r))],r.before,r.after);return i(),a}function Z7(e,t){return{construct:`strong`,markers:Sse(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function Cse(e,t,n){return n.options.strong||`*`}function wse(e,t,n,r){let i=t?t.children:[],a=n.indexStack[n.indexStack.length-1];return n.safe(e.value,{...r,afterNode:i[a+1],beforeNode:i[a-1]})}function Tse(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Ese(e,t,n){let r=(Y7(n)+(n.options.ruleSpaces?` `:``)).repeat(Tse(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Q7={blockquote:Woe,break:D7,code:Xoe,definition:Qoe,emphasis:z7,hardBreak:D7,heading:cse,html:V7,image:H7,imageReference:U7,inlineCode:W7,link:K7,linkReference:q7,list:_se,listItem:yse,paragraph:bse,root:xse,strong:X7,text:wse,thematicBreak:Ese};function Dse(){return{enter:{table:Ose,tableData:e9,tableHeader:e9,tableRow:Ase},exit:{codeText:jse,table:kse,tableData:$7,tableHeader:$7,tableRow:$7}}}function Ose(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function kse(e){this.exit(e),this.data.inTable=void 0}function Ase(e){this.enter({type:`tableRow`,children:[]},e)}function $7(e){this.exit(e)}function e9(e){this.enter({type:`tableCell`,children:[]},e)}function jse(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Mse));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Mse(e,t){return t===`|`?t:e}function Nse(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
156
156
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
157
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Voe(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Q7.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Pse(){return{exit:{taskListCheckValueChecked:t9,taskListCheckValueUnchecked:t9,paragraph:Ise}}}function Fse(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Lse}}}function t9(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Ise(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Lse(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Q7.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Rse(){return[loe(),Aoe(),Poe(),Dse(),Pse()]}function zse(e){return{extensions:[uoe(),joe(e),Foe(),Nse(e),Fse()]}}var Bse={tokenize:Kse,partial:!0},n9={tokenize:qse,partial:!0},r9={tokenize:Jse,partial:!0},i9={tokenize:Yse,partial:!0},Vse={tokenize:Xse,partial:!0},a9={name:`wwwAutolink`,tokenize:Wse,previous:u9},o9={name:`protocolAutolink`,tokenize:Gse,previous:d9},s9={name:`emailAutolink`,tokenize:Use,previous:f9},c9={};function Hse(){return{text:c9}}for(var l9=48;l9<123;)c9[l9]=s9,l9++,l9===58?l9=65:l9===91&&(l9=97);c9[43]=s9,c9[45]=s9,c9[46]=s9,c9[95]=s9,c9[72]=[s9,o9],c9[104]=[s9,o9],c9[87]=[s9,a9],c9[119]=[s9,a9];function Use(e,t,n){let r=this,i,a;return o;function o(t){return!p9(t)||!f9.call(r,r.previous)||m9(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return p9(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Vse,u,l)(t):t===45||t===95||v8(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&_8(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Wse(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!u9.call(r,r.previous)||m9(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Bse,e.attempt(n9,e.attempt(r9,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Gse(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&d9.call(r,r.previous)&&!m9(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(_8(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||b8(t)||T8(t)||O8(t)||D8(t)?n(t):e.attempt(n9,e.attempt(r9,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Kse(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function qse(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(i9,c,s)(t):t===null||T8(t)||O8(t)||t!==45&&D8(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Jse(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(i9,t,a)(o):o===null||T8(o)||O8(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Yse(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||T8(o)||O8(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||T8(e)||O8(e)?t(e):r(e)}function a(e){return _8(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):_8(t)?(e.consume(t),o):n(t)}}function Xse(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return v8(e)?n(e):t(e)}}function u9(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||T8(e)}function d9(e){return!_8(e)}function f9(e){return!(e===47||p9(e))}function p9(e){return e===43||e===45||e===46||e===95||v8(e)}function m9(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Zse={tokenize:ace,partial:!0};function Qse(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:nce,continuation:{tokenize:rce},exit:ice}},text:{91:{name:`gfmFootnoteCall`,tokenize:tce},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:$se,resolveTo:ece}}}}function $se(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=g8(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function ece(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function tce(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||T8(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(g8(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return T8(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function nce(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||T8(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=g8(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return T8(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),j8(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function rce(e,t,n){return e.check(Y8,t,e.attempt(Zse,t,n))}function ice(e){e.exit(`gfmFootnoteDefinition`)}function ace(e,t,n){let r=this;return j8(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function oce(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&l8(o,o.length,0,H8(s,e.slice(r+1,n),t)),l8(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),l8(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=V8(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=V8(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var sce=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){cce(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function cce(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function lce(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function uce(){return{flow:{null:{name:`table`,tokenize:dce,resolveAll:fce}}}}function dce(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):w8(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):E8(t)?j8(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||T8(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,E8(t)?j8(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return E8(t)?j8(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||w8(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return E8(t)?j8(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||w8(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||w8(n)?(e.exit(`tableRow`),t(n)):E8(n)?j8(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||T8(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function fce(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new sce;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(g9(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=h9(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=h9(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=h9(f,t,o,i,n,d)):(o[0]=o[1],d=h9(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&g9(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=lce(t.events,n))}return e}function h9(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},_9(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=_9(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=_9(t.events,n[2]),a=_9(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},_9(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function g9(e,t,n,r,i){let a=[],o=_9(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function _9(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var pce={name:`tasklistCheck`,tokenize:hce};function mce(){return{text:{91:pce}}}function hce(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return T8(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return w8(r)?t(r):E8(r)?e.check({tokenize:gce},t,n)(r):n(r)}}function gce(e,t,n){return j8(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function _ce(e){return f8([Hse(),Qse(),oce(e),uce(),mce()])}var vce={};function yce(e){let t=this,n=e||vce,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(_ce(n)),a.push(Rse()),o.push(zse(n))}var bce={h1:({children:e})=>(0,g.jsx)(`h1`,{className:`mb-2 mt-1 text-[15px] font-medium leading-6 text-ink`,children:e}),h2:({children:e})=>(0,g.jsx)(`h2`,{className:`mb-1.5 mt-3 text-[14px] font-medium leading-5 text-ink`,children:e}),h3:({children:e})=>(0,g.jsx)(`h3`,{className:`mb-1 mt-2.5 text-[13px] font-medium leading-5 text-ink`,children:e}),p:({children:e})=>(0,g.jsx)(`p`,{className:`my-1.5 leading-[1.65] first:mt-0 last:mb-0`,children:e}),strong:({children:e})=>(0,g.jsx)(`strong`,{className:`font-medium text-ink`,children:e}),em:({children:e})=>(0,g.jsx)(`em`,{className:`italic`,children:e}),a:({children:e,href:t})=>(0,g.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent`,children:e}),ul:({children:e})=>(0,g.jsx)(`ul`,{className:`my-1.5 list-disc space-y-0.5 pl-5 marker:text-ink-3`,children:e}),ol:({children:e})=>(0,g.jsx)(`ol`,{className:`my-1.5 list-decimal space-y-0.5 pl-5 marker:text-ink-3`,children:e}),li:({children:e})=>(0,g.jsx)(`li`,{className:`leading-[1.65]`,children:e}),blockquote:({children:e})=>(0,g.jsx)(`blockquote`,{className:`my-2 border-l-2 border-accent/30 pl-3 text-ink-2`,children:e}),hr:()=>(0,g.jsx)(`hr`,{className:`my-3 border-line`}),pre:({children:e})=>(0,g.jsx)(`pre`,{className:`my-2 overflow-x-auto rounded-lg bg-surface-2 px-3 py-2.5 font-mono text-[12px] leading-5 text-ink`,children:e}),code:({children:e,className:t})=>(0,g.jsx)(`code`,{className:t?`font-mono ${t}`:`rounded bg-black/[.06] px-1 py-[1px] font-mono text-[.92em] text-ink dark:bg-white/[.1]`,children:e}),table:({children:e})=>(0,g.jsx)(`div`,{className:`my-2 overscroll-x-contain overflow-x-auto rounded-lg border border-line`,children:(0,g.jsx)(`table`,{className:`w-full min-w-max border-collapse text-left text-[11.5px] [overflow-wrap:anywhere]`,children:e})}),thead:({children:e})=>(0,g.jsx)(`thead`,{className:`bg-surface-2 text-ink-2`,children:e}),th:({children:e,style:t})=>(0,g.jsx)(`th`,{style:t,className:`whitespace-nowrap border-b border-line-strong px-3 py-1.5 font-medium`,children:e}),td:({children:e,style:t})=>(0,g.jsx)(`td`,{style:t,className:`max-w-[320px] border-b border-line/70 px-3 py-1.5 align-middle`,children:e}),tr:({children:e})=>(0,g.jsx)(`tr`,{className:`even:bg-ink/[.04] last:[&>td]:border-b-0`,children:e})};function v9({text:e}){return(0,g.jsx)(`div`,{className:`markdown-body [&_pre_code]:bg-transparent [&_pre_code]:p-0`,children:(0,g.jsx)($ae,{remarkPlugins:[yce],components:bce,children:e})})}var xce=(0,h.lazy)(()=>e(()=>import(`./FileEditor-EgU1WoyG.js`),__vite__mapDeps([6,1,2,3,4,5]))),Sce=6e4;function y9({sessionId:e,target:t,onClose:n}){let[r,i]=(0,h.useState)(null),[a,o]=(0,h.useState)(null),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),d=l===t.id,f=t.kind===`document`&&cb(t.mime),[p,m]=(0,h.useState)({id:t.id,view:`text`}),_=p.id===t.id?p.view:`text`,v=e=>m({id:t.id,view:e}),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(null);return(0,h.useEffect)(()=>{if(t.kind!==`document`||_!==`text`)return;let n=!0;return i(null),o(null),eM(e,t.id).then(e=>{n&&(i(e.markdown),c(e.truncated))}).catch(()=>{n&&o(`无法读取解析结果。`)}),()=>{n=!1}},[e,t.id,t.kind,_]),(0,h.useEffect)(()=>{if(!f||_!==`source`)return;let n=!0;return b(null),S(null),qee(e,t.id,{maxChars:Sce}).then(e=>{n&&b({content:e.content,lineStart:e.lineStart,lineEnd:e.lineEnd,totalLines:e.totalLines,truncated:e.truncated})}).catch(()=>{n&&S(`无法读取原始文件。`)}),()=>{n=!1}},[e,t.id,f,_]),(0,h.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,g.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`附件预览:${t.filename}`,className:`fixed inset-0 z-[340] flex items-center justify-center bg-black/45 p-4`,children:(0,g.jsxs)(`div`,{className:`flex max-h-[86vh] w-full max-w-4xl flex-col overflow-hidden rounded-xl border border-line bg-surface shadow-[var(--shadow-card)]`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2`,children:[(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px] text-ink`,children:t.filename}),f?(0,g.jsx)(`div`,{role:`tablist`,"aria-label":`预览视图`,className:`flex items-center gap-0.5 rounded-full bg-surface-2/60 p-0.5`,children:[[`text`,`解析视图`],[`source`,`原文`]].map(([e,t])=>(0,g.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":_===e,onClick:()=>v(e),className:`rounded-full px-2 py-0.5 text-[11px] ${_===e?`bg-surface text-ink shadow-[var(--shadow-card)]`:`text-ink-3 hover:text-ink`}`,children:t},e))}):null,t.kind===`document`?(0,g.jsx)(`a`,{href:Yj(e,t.id),download:t.filename,className:`text-[11px] text-accent hover:underline`,children:`下载`}):null,(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:n,className:`rounded p-1 text-ink-3 hover:bg-surface-2`,children:(0,g.jsx)(Ac,{size:14})})]}),(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:t.kind===`image`?d?(0,g.jsx)(`p`,{role:`status`,className:`text-[12px] text-danger`,children:`无法加载原图,文件可能已被删除。`}):(0,g.jsx)(`img`,{src:Yj(e,t.id),alt:t.filename,className:`mx-auto max-h-[70vh] max-w-full object-contain`,onError:()=>u(t.id)}):_===`source`?(0,g.jsx)(Cce,{identity:t.id,filename:t.filename,source:y,error:x}):a===null?r===null?(0,g.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-[12px] text-ink-3`,children:[(0,g.jsx)(ps,{size:13,className:`animate-spin motion-reduce:animate-none`}),` `,`读取解析结果…`]}):r.length===0?(0,g.jsx)(`p`,{role:`status`,className:`text-[12px] text-ink-3`,children:`该附件没有可预览的文本。`}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(v9,{text:r}),s?(0,g.jsx)(`p`,{className:`mt-3 text-[11px] text-ink-3`,children:`预览已截断,完整内容可由 Agent 分页读取。`}):null]}):(0,g.jsx)(`p`,{role:`status`,className:`text-[12px] text-danger`,children:a})})]})})}function Cce({identity:e,filename:t,source:n,error:r}){return r===null?n===null?(0,g.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-[12px] text-ink-3`,children:[(0,g.jsx)(ps,{size:13,className:`animate-spin motion-reduce:animate-none`}),` 读取原始文件…`]}):(0,g.jsxs)(`div`,{className:`flex h-[68vh] flex-col gap-2`,children:[(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-md border border-line`,children:(0,g.jsx)(h.Suspense,{fallback:(0,g.jsx)(`p`,{className:`p-3 text-[12px] text-ink-3`,children:`加载编辑器…`}),children:(0,g.jsx)(xce,{identity:`attachment:${e}`,path:t,text:n.content,readOnly:!0,onChange:()=>void 0})})}),(0,g.jsxs)(`p`,{className:`text-[11px] text-ink-3`,children:[`第 `,n.lineStart,`–`,n.lineEnd,` 行 · 共 `,n.totalLines,` 行`,n.truncated?` · 预览已截断,完整内容可由 Agent 分页读取`:``]})]}):(0,g.jsx)(`p`,{role:`status`,className:`text-[12px] text-danger`,children:r})}var b9=`inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border border-line/80 bg-surface-2/55 px-2 text-[11px] text-ink-2`,wce=`transition-colors hover:border-accent/35 hover:bg-accent-soft/30 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:pointer-events-none disabled:opacity-55`,Tce={none:`原图`,native:`文本`,"text-layer":`文本层`,ocr:`OCR`,vision:`视觉转写`},Ece={ATTACHMENT_TOO_LARGE:`文件过大`,ATTACHMENT_UNSUPPORTED:`格式不支持`,ATTACHMENT_LIMIT:`附件已满`,ATTACHMENT_PARSE_FAILED:`无法解析`,ATTACHMENT_PARSE_TIMEOUT:`解析超时`,ATTACHMENT_ENCRYPTED:`文件已加密`,ATTACHMENT_PDF_NO_TEXT:`PDF 无可提取文本`,ATTACHMENT_VISION_UNAVAILABLE:`当前模型不支持图片`,ATTACHMENT_NOT_READY:`仍在解析`,ATTACHMENT_STORAGE_FAILED:`存储不可用`};function Dce(e){return[e.status===`uploading`||e.status===`pending`?`解析中`:null,e.status===`failed`?e.errorCode?Ece[e.errorCode]??`解析失败`:`解析失败`:null,e.pageCount?`${e.pageCount} 页`:null,e.method&&e.method!==`none`?Tce[e.method]:null,e.warningCount?`${e.warningCount} 条警告`:null].filter(Boolean).join(` · `)}function x9({item:e,disabled:t=!1,onRemove:n,onOpen:r}){let i=e.status===`uploading`||e.status===`pending`,a=e.status===`failed`,o=Dce(e);return(0,g.jsxs)(`div`,{className:B(b9,`shrink-0 gap-1 pr-1.5 pl-2 text-left`,a?`border-danger/35 bg-danger/5`:e.status===`ready`&&r?`hover:border-accent/35 hover:bg-accent-soft/30`:null),title:o.length>0?`${e.filename} · ${o}`:e.filename,"data-testid":`attachment-chip`,children:[i?(0,g.jsx)(ps,{size:11,"aria-hidden":`true`,className:`shrink-0 animate-spin text-ink-3 motion-reduce:animate-none`}):(0,g.jsx)(pW,{path:e.filename,size:13}),(0,g.jsx)(`button`,{type:`button`,onClick:r,disabled:e.status!==`ready`||r===void 0,className:`min-w-0 max-w-[180px] truncate text-left text-[11px] text-ink-2 enabled:hover:text-ink disabled:cursor-default`,children:e.filename}),a?(0,g.jsx)(Cc,{size:10,"aria-hidden":`true`,className:B(`shrink-0 text-danger`,n?null:`mr-0.5`)}):null,o.length>0?(0,g.jsx)(`span`,{className:`sr-only`,children:o}):null,n?(0,g.jsx)(`button`,{type:`button`,onClick:n,disabled:t,"aria-label":`移除 ${e.filename}`,className:`shrink-0 rounded-full p-0.5 text-ink-3 hover:bg-surface-3 hover:text-ink disabled:opacity-40`,children:(0,g.jsx)(Ac,{size:10})}):null]})}function Oce({items:e,disabled:t=!1,onRemove:n,onRetry:r,onPreview:i}){return e.length===0?null:(0,g.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pt-3`,"data-testid":`attachment-tray`,children:e.map(e=>(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(x9,{item:{id:e.attachment?.id,filename:e.file.name,kind:e.attachment?.kind??(e.file.type.startsWith(`image/`)?`image`:`document`),status:e.status,method:e.attachment?.method,pageCount:e.attachment?.pageCount,warningCount:e.attachment?.warnings.length,errorCode:e.errorCode??e.attachment?.errorCode},disabled:t,onRemove:()=>n(e.key),onOpen:()=>i?.(e)}),e.status===`failed`&&r?(0,g.jsx)(`button`,{type:`button`,onClick:()=>r(e.key),className:`text-[11px] text-accent hover:underline`,children:`重试`}):null]},e.key))})}var S9=`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-[11.5px] text-ink-2 outline-none hover:bg-surface-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/40 disabled:opacity-50`;function kce({groups:e,model:t,credentialProfileId:n,thinking:r,catalogError:i,disabled:a,onSelectModel:o,onSelectThinking:s}){let c=(0,h.useId)(),l=(0,h.useRef)(null),u=(0,h.useRef)(null),d=(0,h.useRef)(null),[f,p]=(0,h.useState)(!1),[m,_]=(0,h.useState)(`root`),v=t?.thinking.mode,y=t?.thinking.supported?v===`toggle`?[{id:`off`,label:`关闭`},{id:`on`,label:`开启`}]:[...v===`mandatory-levels`||v===`variants`?[]:[{id:`off`,label:`关闭`}],...t.thinking.levels]:[],b=y.find(e=>e.id===r)?.label;(0,h.useEffect)(()=>{if(!f)return;d.current?.focus();let e=e=>{e.target instanceof Node&&!l.current?.contains(e.target)&&p(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[f]);let x=()=>{p(!1),u.current?.focus()},S=e=>{d.current?.focus(),_(e)};return(0,g.jsxs)(`div`,{ref:l,className:`relative min-w-0`,children:[(0,g.jsxs)(`button`,{ref:u,type:`button`,"aria-label":`模型与思考:${t?.label??`选择模型`}${b?` · ${b}`:``}`,"aria-haspopup":`dialog`,"aria-expanded":f&&!a,"aria-controls":f&&!a?c:void 0,disabled:a,onClick:()=>{_(`root`),p(!f)},className:`flex h-7 min-w-0 items-center gap-1.5 rounded-lg px-1.5 text-[11px] font-medium text-ink-2 transition-colors hover:bg-surface-2 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[(0,g.jsx)(`span`,{className:`max-w-[96px] truncate sm:max-w-[144px]`,children:t?.label??`选择模型`}),b?(0,g.jsxs)(`span`,{className:B(`shrink-0 text-[10px] font-semibold`,r===`off`||r===`effort:none`?`text-ink-3`:`text-accent`),children:[(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1 text-ink-3`,children:`·`}),b]}):null,(0,g.jsx)(Xa,{size:11,"aria-hidden":`true`,className:`shrink-0 text-ink-3`})]}),f&&!a?(0,g.jsx)(`div`,{ref:d,id:c,role:`dialog`,"aria-label":`模型与思考`,tabIndex:-1,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),x())},className:`absolute bottom-[calc(100%+8px)] left-0 z-40 flex max-h-[min(360px,55dvh)] w-[min(240px,calc(100vw-68px))] flex-col overflow-hidden rounded-xl border border-line bg-surface/95 p-1.5 text-ink shadow-[var(--shadow-pop)] outline-none backdrop-blur-xl`,children:m===`root`?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`button`,{type:`button`,"aria-label":`模型:${t?.label??`选择模型`}`,onClick:()=>S(`models`),className:S9,children:[(0,g.jsx)(`span`,{className:`w-14 shrink-0 text-[10px] text-ink-3`,children:`模型`}),(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-ink`,children:t?.label??`选择模型`}),(0,g.jsx)(eo,{size:11,"aria-hidden":`true`,className:`text-ink-3`})]}),(0,g.jsxs)(`button`,{type:`button`,"aria-label":`思考强度:${b??`不支持`}`,disabled:y.length===0,onClick:()=>S(`thinking`),className:S9,children:[(0,g.jsx)(`span`,{className:`w-14 shrink-0 text-[10px] text-ink-3`,children:`思考强度`}),(0,g.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate`,b&&r!==`off`&&r!==`effort:none`&&`text-accent`),children:b??`不支持`}),y.length>0?(0,g.jsx)(eo,{size:11,"aria-hidden":`true`,className:`text-ink-3`}):null]})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-1 pb-1 pt-0.5`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":`返回`,onClick:()=>S(`root`),className:`grid size-5 place-items-center rounded-md text-ink-3 outline-none hover:bg-surface-2 focus-visible:ring-2 focus-visible:ring-accent/40`,children:(0,g.jsx)(Qa,{size:12,"aria-hidden":`true`})}),(0,g.jsx)(`span`,{className:`text-[10.5px] font-semibold text-ink-3`,children:m===`models`?`模型`:`思考强度`})]}),(0,g.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain`,children:m===`models`?(0,g.jsxs)(g.Fragment,{children:[e.length===0?(0,g.jsx)(`p`,{className:`px-2 py-2 text-[11px] text-ink-3`,children:i?`目录不可用,请在模型设置中刷新。`:`请先在模型设置中添加 Key。`}):null,e.map(e=>{let r=`${c}-${e.credentialProfileId}`;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{id:r,className:`truncate px-2.5 pb-0.5 pt-1.5 text-[10px] text-ink-3`,children:e.credentialLabel}),(0,g.jsxs)(`ul`,{"aria-labelledby":r,children:[e.models.length===0?(0,g.jsx)(`li`,{className:`px-2.5 py-1.5 text-[10.5px] text-ink-3`,children:e.lastRefreshError?`目录读取失败,请在设置中刷新。`:`此 Key 暂无可选模型`}):null,e.models.map(r=>{let i=r.id===t?.id&&e.credentialProfileId===n;return(0,g.jsx)(`li`,{children:(0,g.jsxs)(`button`,{type:`button`,"aria-label":r.label,"aria-pressed":i,onClick:()=>{x(),o(r.id,e.credentialProfileId)},className:B(S9,i&&`bg-surface-2 text-ink`),children:[(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label}),(0,g.jsx)(`span`,{className:`text-[9.5px] text-ink-3`,children:tK(r)}),i?(0,g.jsx)(Ja,{size:13,"aria-hidden":`true`,className:`shrink-0 text-accent`}):null]})},r.id)})]})]},e.credentialProfileId)})]}):y.map(e=>(0,g.jsxs)(`button`,{type:`button`,"aria-pressed":e.id===r,onClick:()=>{x(),e.id!==r&&s(e.id)},className:B(S9,e.id===r&&`bg-surface-2 text-ink`),children:[(0,g.jsx)(`span`,{className:`flex-1`,children:e.label}),e.id===r?(0,g.jsx)(Ja,{size:13,"aria-hidden":`true`,className:`shrink-0 text-accent`}):null]},e.id))})]})}):null]})}function C9(e){if(e<1e3)return String(e);if(e<1e5){let t=(e/1e3).toFixed(1);return`${t.endsWith(`.0`)?t.slice(0,-2):t}k`}if(e<1e6)return`${Math.round(e/1e3)}k`;let t=(e/1e6).toFixed(2);return`${t.endsWith(`.00`)?t.slice(0,-3):t.endsWith(`0`)?t.slice(0,-1):t}M`}function Ace(e,t){return e===void 0||t===void 0||e<=0||t<=0?null:Math.round(e/(t/1e3))}function jce(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}function Mce(e,t){if(e!==null&&t!==null&&Number.isFinite(e)&&e>=0&&Number.isFinite(t)&&t>0){let n=Math.min(100,Math.max(0,Math.round(e/t*100)));return{known:!0,percent:n,text:`本轮 ${C9(e)} / ${C9(t)} · ${n}%`,detail:`本轮请求输入:${e.toLocaleString()} / ${t.toLocaleString()} tokens(${n}%)`}}return{known:!1,percent:0,text:`暂无统计`,detail:t!==null&&Number.isFinite(t)&&t>0?`暂无统计 · 模型窗口 ${t.toLocaleString()} tokens`:`暂无统计 · 模型窗口未知`}}function w9({used:e,limit:t}){let n=Mce(e,t);return(0,g.jsx)(wh,{label:n.detail,side:`top`,children:(0,g.jsxs)(`div`,{role:`progressbar`,"aria-label":`上下文用量`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n.known?n.percent:void 0,"aria-valuetext":n.detail,className:`flex shrink-0 items-center gap-1`,children:[(0,g.jsxs)(`svg`,{"aria-hidden":`true`,width:`14`,height:`14`,viewBox:`0 0 20 20`,className:`-rotate-90`,fill:`none`,children:[(0,g.jsx)(`circle`,{cx:`10`,cy:`10`,r:`7`,stroke:`currentColor`,strokeWidth:`2`,className:`text-line-strong`}),n.known?(0,g.jsx)(`circle`,{cx:`10`,cy:`10`,r:`7`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`100`,strokeDashoffset:100-n.percent,className:B(`transition-[stroke-dashoffset] duration-150 motion-reduce:transition-none`,n.percent>=90?`text-danger`:n.percent>=75?`text-warning`:`text-accent`)}):null]}),(0,g.jsx)(`span`,{className:`tabular-nums`,children:n.text})]})})}function T9({children:e}){return(0,g.jsx)(`div`,{role:`status`,"aria-label":`会话用量`,className:`mt-1 flex min-h-[16px] flex-wrap items-center gap-1 px-1 text-[10.5px] text-ink-3`,children:e})}function Nce({usage:e,streaming:t,lastStep:n,contextUsage:r}){if(e===null)return(0,g.jsxs)(T9,{children:[(0,g.jsx)(`span`,{children:`Token 统计加载中…`}),(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsx)(w9,{...r})]});if(e===void 0)return(0,g.jsxs)(T9,{children:[(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsx)(w9,{...r})]});let i=e.partial,a=`${i?`≥ `:``}${C9(e.totalTokens)} tokens`,o=e.cache.hitRate===null?null:Math.round(e.cache.hitRate*100),s=e.cache.knownRequests>0?[`缓存命中 ${C9(e.cache.readTokens)} tokens`,`未命中 ${C9(e.cache.missTokens)} tokens`,...e.cache.unknownRequests>0?[`未知 ${e.cache.unknownRequests} 次请求`]:[]].join(` · `):e.cache.unknownRequests>0?`缓存未知 · ${e.cache.unknownRequests} 次请求未回报缓存字段`:null,c=[`输入 ${C9(e.inputTokens)}`,`输出 ${C9(e.outputTokens)}`,...s===null?[]:[s],...i?[`缺失 ${e.missingTurns} 轮`]:[]].join(` · `),l=n===null?null:Ace(n.outputTokens,n.durationMs);return(0,g.jsxs)(T9,{children:[(0,g.jsx)(wh,{label:c,side:`top`,children:(0,g.jsx)(`span`,{className:`tabular-nums`,children:a})}),o===null?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,g.jsx)(wh,{label:s??`缓存命中率`,side:`top`,children:(0,g.jsxs)(`span`,{className:`tabular-nums`,children:[`缓存命中 `,o,`%`]})})]}),t&&l!==null&&n!==null?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,g.jsx)(wh,{label:`最后一步输出 ${C9(n.outputTokens)} tokens · ${jce(n.durationMs)}`,side:`top`,children:(0,g.jsxs)(`span`,{className:`tabular-nums`,children:[l,` tok/s`]})})]}):null,(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsx)(w9,{...r})]})}var E9={id:`standard`,label:`标准审批`,detail:`L0/L1 自动,L2 询问`,icon:ac,tone:`text-accent`},D9=[{id:`readonly`,label:`只读`,detail:`禁止修改与执行`,icon:lc,tone:`text-success`},{id:`strict`,label:`严格审批`,detail:`所有写入都询问`,icon:sc,tone:`text-warning`},E9,{id:`autonomous`,label:`完全自主`,detail:`所有工具免人工审批`,icon:sc,tone:`text-danger`}],O9=[{id:`coding`,label:`Coding`,detail:`快速完成编程任务`,icon:_o},{id:`plan`,label:`Plan`,detail:`按需创建任务计划完成`,icon:ds}];function k9(e){if(!e.thinking.supported)return`off`;if(e.thinking.mode===`toggle`)return`on`;if(e.thinking.defaultLevel)return e.thinking.defaultLevel;let t=e.thinking.mode===`mandatory-levels`?`high`:`medium`;return e.thinking.levels.find(e=>e.id===t)?.id??e.thinking.levels[0]?.id??`off`}function A9(e,t){if(!e.thinking.supported)return t===`off`;let n=e.thinking.mode??`levels`;return n===`toggle`?t===`off`||t===`on`:n===`variants`?e.thinking.levels.some(e=>e.id===t):n!==`mandatory-levels`&&t===`off`||e.thinking.levels.some(e=>e.id===t)}function Pce({centered:e=!1,onSubmit:t}){let[n,r]=(0,h.useState)(),[i,a]=(0,h.useState)(``),[o,s]=(0,h.useState)(null),[c,l]=(0,h.useState)(null),u=(0,h.useRef)(null),d=(0,h.useRef)(new Set),[f,p]=(0,h.useState)(null),[m,_]=(0,h.useState)(),[v,y]=(0,h.useState)(),[b,x]=(0,h.useState)(null),[S,C]=(0,h.useState)(null),[w,T]=(0,h.useState)(),{catalog:E,error:D}=dte(),O=yW(e=>e.draft),k=yW(e=>e.setDraft),A=Uq(e=>e.isStreaming),j=Uq(e=>e.activeTurnId),M=Uq(e=>e.send),N=Uq(e=>e.stop),ee=vW(e=>e.focusComposerNonce),te=(0,h.useRef)(null),P=vW(e=>e.sessionId),F=!!P,ne=vW(e=>e.draftSession),I=ne?.id===P,re=mte(F&&!I?P:null),ie=I||re?.id===P,ae=re?.approvalPolicyId??(m?.sessionId===P?m.value:E9.id),oe=re?.agentProfile??(v?.sessionId===P?v.value:`coding`),se=Qg({mutationKey:uM(P)},aM)>0,ce=!F||!ie||se||A&&!j,le=f!==null&&f===P,ue=t_({mutationKey:uM(P),mutationFn:async({id:e,patch:t})=>{let n=cM(e);await aM.cancelQueries({queryKey:n});let r=await Bj(e,t);await aM.cancelQueries({queryKey:n}),aM.setQueryData(n,e=>e?{...e,...r}:{...r,activeTurn:null})}},aM),de=E?.groups??(E?[E]:[]),L=de.map(e=>({...e,models:e.models.filter(e=>e.visible!==!1&&(e.agentSelectable??e.contextWindow!==null))})),fe=de.flatMap(e=>e.models.map(t=>({group:e,model:t}))),pe=fe.filter(({model:e})=>e.visible!==!1&&(e.agentSelectable??e.contextWindow!==null)),me=I?ne.selection:re,he=e=>fe.find(({group:t,model:n})=>n.id===e.model&&(e.credentialProfileId==null||e.credentialProfileId===t.credentialProfileId)),ge=me?he(me):void 0,_e=E?.defaultSelection?he(E.defaultSelection):void 0,ve=_e?.model.visible===!1?void 0:_e,ye=!!(me?.model&&me?.credentialProfileId&&!ge),be=ge??(ye?void 0:ve??pe[0]),xe=ie?be?.model:void 0,Se=be?.group.credentialProfileId??null,Ce=ge?me?.thinking:ve?E?.defaultSelection?.thinking:null,we=Ce==="default"?`medium`:Ce,Te=xe&&we&&A9(xe,we)?we:xe?k9(xe):`off`,Ee=fM(),De=Ee.data.activeConnectionId!==null&&Ee.data.connections.some(e=>e.id===Ee.data.activeConnectionId),Oe=I?ne?.webSearchEnabled??!1:re?.webSearchEnabled??!1,ke=Oe&&De,Ae=F&&xe!==void 0&&(xe.agentSelectable??xe.contextWindow!==null)&&!se&&!A,je=n?.sessionId===P?n.items:[],Me=je.map(e=>e.file),Ne=xe?.capabilities?.inputModalities?.includes(`image`)===!0,Pe=!I&&!Ne&&je.some(e=>e.file.type.startsWith(`image/`)&&e.status===`ready`&&e.attachment?.method!==`ocr`&&e.attachment?.method!==`vision`),Fe=je.some(e=>e.status===`uploading`||e.status===`pending`),Ie=je.some(e=>e.status===`failed`),Le=(0,h.useCallback)(async(e,t)=>{if(P&&!d.current.has(e)){d.current.add(e);try{let n=await Qj(P,t);r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:n.status,attachment:n,errorCode:n.errorCode}:t)}:t)}catch(t){let n=t instanceof fj?t.code:`ATTACHMENT_VISION_UNAVAILABLE`;r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:`failed`,errorCode:n}:t)}:t),s({message:`图片需要视觉模型或本地 OCR 才能发送。`,tone:`error`})}finally{d.current.delete(e)}}},[P]),Re=async(e,t)=>{if(P&&!I)try{let n=await Zj(P,t);r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:n.attachment.status,attachment:n.attachment,errorCode:n.attachment.errorCode}:t)}:t),n.attachment.status===`failed`&&s({message:`附件解析失败,可重试或移除。`,tone:`error`}),n.attachment.kind===`image`&&n.attachment.status===`ready`&&n.attachment.method===`none`&&!Ne&&Le(e,n.attachment.id)}catch(t){r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:`failed`}:t)}:t),s({message:t instanceof Error?t.message:`附件上传失败`,tone:`error`})}},ze=e=>{if(!F||!P||A||e.length===0)return;let t=n?.sessionId===P?n.items:[],i=8-t.length;if(i<=0){s({message:`每轮最多添加 8 个附件。`,tone:`error`});return}let o=e.slice(0,i),c=o.map(e=>({file:e,reason:_b(e.name,e.size)})).find(e=>e.reason!==null);if(c!==void 0&&c.reason!==null){s({message:c.reason===`secret`?`${c.file.name} 可能是凭据文件,附件不接收密钥或证书。`:c.reason===`size`?`${c.file.name} 超过 ${gb/1024/1024} MiB 上限。`:`不支持 ${c.file.name}(代码/配置/文档/图片,最大 20 MiB)。`,tone:`error`});return}let l=o.map(e=>({key:`${e.name}:${e.lastModified}:${Math.random().toString(36).slice(2,7)}`,file:e,status:I?`ready`:`uploading`}));if(r({sessionId:P,items:[...t,...l]}),a(``),!I)for(let e of l)Re(e.key,e.file)},Be=e=>{r(t=>t?.sessionId===P?{...t,items:t.items.filter(t=>t.key!==e)}:t)},Ve=e=>{let t=je.find(t=>t.key===e);t&&(r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:`uploading`}:t)}:t),Re(e,t.file))},R=D9.find(e=>e.id===ae)??E9,He=R.icon,Ue=O9.find(e=>e.id===oe)??O9[0],We=Ue.icon,Ge=Uq(e=>e.modelUsage),Ke=xe?Ge[xe.id]:void 0,qe=fte(F&&!I?P:null),Je=F&&!I&&(Ke!==void 0||(qe?.turns??0)>0),z=Ke?.contextWindow??xe?.contextWindow??null,Ye=Ke?.outputTokens!==void 0&&Ke.durationMs!==void 0?{outputTokens:Ke.outputTokens,durationMs:Ke.durationMs}:null,Xe=Uq(e=>d3(e.items).length>0);(0,h.useEffect)(()=>vW.subscribe((e,t)=>{e.sessionId!==t.sessionId&&p(null)}),[]),(0,h.useEffect)(()=>{ee>0&&te.current?.focus()},[ee]),(0,h.useEffect)(()=>{if(!(I||Ne||!P))for(let e of je)e.file.type.startsWith(`image/`)&&e.status===`ready`&&e.attachment?.method===`none`&&Le(e.key,e.attachment.id)},[Ne,I,P,je,Le]),(0,h.useEffect)(()=>{if(b===null)return;let e=setTimeout(()=>x(null),4e3);return()=>clearTimeout(e)},[b]),(0,h.useEffect)(()=>{let e=te.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(180,Math.max(48,e.scrollHeight))}px`)},[O]);let Ze=async(e,t)=>{if(!ce){C(null),x(null);try{I?vW.getState().setDraftModel(P,e):await ue.mutateAsync({id:P,patch:e}),t&&vW.getState().sessionId===P&&x({sessionId:P,message:`已切换到 ${t}`})}catch(e){C({sessionId:P,message:pj(e,`模型选择保存失败,请重试。`)})}}},Qe=(e,t)=>{let n=pe.find(({group:n,model:r})=>r.id===e&&n.credentialProfileId===t);n&&Ze({model:e,credentialProfileId:t,thinking:A9(n.model,Te)?Te:k9(n.model)},n.model.label)},$e=async e=>{if(!(ce||e===oe)){if(C(null),I)y({sessionId:P,value:e});else try{await ue.mutateAsync({id:P,patch:{agentProfile:e}})}catch(e){C({sessionId:P,message:pj(e,`Agent Profile 保存失败,请重试。`)})}}},et=async e=>{if(!(ce||e===ae)){if(C(null),I)_({sessionId:P,value:e});else try{await ue.mutateAsync({id:P,patch:{approvalPolicyId:e}})}catch(e){C({sessionId:P,message:pj(e,`审批策略保存失败,请重试。`)})}}},tt=async()=>{if(F&&!ce&&De){if(C(null),x(null),I){let e=!Oe;vW.getState().setDraftWebSearch(P,e),x({sessionId:P,message:e?`已开启联网搜索`:`已关闭联网搜索`})}else try{await ue.mutateAsync({id:P,patch:{webSearchEnabled:!Oe}}),x({sessionId:P,message:Oe?`已关闭联网搜索`:`已开启联网搜索,下一轮生效`})}catch(e){C({sessionId:P,message:pj(e,`联网搜索开关保存失败,请重试。`)})}}},nt=()=>{if(!Ae||!xe||!Se||Xe||Pe||Fe||Ie)return;let e=O.trim();if(!e&&Me.length===0)return;t?.();let n={model:xe.id,credentialProfileId:Se,thinking:Te},i=I?ae:void 0,a=I?oe:void 0,o=I&&Oe&&De?!0:void 0;Me.length===0?M(e,n,i,a,o):M(e,n,i,a,o,Me,()=>{r(e=>e?.sessionId===P?void 0:e),vW.getState().sessionId===P&&yW.getState().draft===O&&k(``)},Ne),Me.length===0&&k(``),requestAnimationFrame(()=>te.current?.focus())};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{"data-testid":`composer-surface`,className:B(`relative rounded-[18px] border border-line shadow-[var(--shadow-card)] transition-[border-color,box-shadow] focus-within:border-accent/35 focus-within:ring-2 focus-within:ring-accent/10`,e?`bg-surface/40 backdrop-blur-sm`:`bg-surface`),children:[b?.sessionId===P?(0,g.jsx)(`p`,{role:`status`,className:`pointer-events-none absolute bottom-full left-2 mb-1 w-fit max-w-[calc(100%-1rem)] truncate rounded-md bg-surface/90 px-2 py-0.5 text-[10.5px] text-ink-3`,children:b.message}):null,(0,g.jsx)(Yc,{message:S?.sessionId===P?S.message:null,onDismiss:()=>C(null)}),je.length>0?(0,g.jsx)(Oce,{items:je,disabled:A,onRemove:Be,onRetry:Ve,onPreview:e=>e.attachment?l({id:e.attachment.id,filename:e.attachment.filename,kind:e.attachment.kind,mime:e.attachment.mime}):void 0}):null,i||Pe?(0,g.jsx)(`p`,{role:`status`,className:`px-3 pt-2 text-xs text-warning`,children:i||`当前模型连接未声明图片输入。请切换模型、启用 OCR 或移除图片。`}):null,(0,g.jsx)(`input`,{ref:u,type:`file`,accept:hb,multiple:!0,className:`hidden`,onChange:e=>{ze([...e.target.files??[]]),e.target.value=``}}),(0,g.jsx)(Hc,{message:o?.message??null,tone:o?.tone,onDismiss:()=>s(null)}),c?(0,g.jsx)(y9,{sessionId:P,target:c,onClose:()=>l(null)}):null,(0,g.jsx)(hm,{variant:`bare`,ref:te,value:O,rows:1,placeholder:F?e?`提问、描述要做的改动…`:`继续对话,或提出新的任务…`:`新建或选择一个会话…`,onPaste:e=>{let t=[...e.clipboardData.files];t.length>0&&(e.preventDefault(),ze(t))},onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.files.length&&(e.preventDefault(),ze([...e.dataTransfer.files]))},"aria-label":`对话输入`,onChange:e=>k(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey){if(e.nativeEvent.isComposing)return;e.preventDefault(),A||nt()}},className:`block max-h-[180px] min-h-[48px] w-full resize-none bg-transparent px-3.5 pt-3 text-[13px] leading-[1.65] text-ink outline-none placeholder:text-ink-3 focus:outline-none focus-visible:outline-none`}),(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 pb-2 pt-1`,children:[(0,g.jsx)(vm,{label:De?ke?`联网搜索:已开启`:`联网搜索:已关闭`:`联网搜索:未配置`,active:ke,"aria-pressed":ke,title:De?Oe?`关闭联网搜索`:`开启联网搜索`:`请先在左侧「联网搜索」添加搜索 Key`,disabled:!F||ce||!De,onClick:()=>void tt(),className:`h-7 w-7`,children:(0,g.jsx)($o,{size:15,"aria-hidden":`true`})}),(0,g.jsx)(kce,{groups:L,model:xe,credentialProfileId:Se,thinking:Te,catalogError:D,disabled:ce,onSelectModel:Qe,onSelectThinking:e=>{xe&&Se&&Ze({model:xe.id,credentialProfileId:Se,thinking:e})}},P),(0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsx)(vm,{disabled:ce,label:`Agent Profile:${Ue.label}`,title:`${Ue.label} · ${Ue.detail}`,className:`h-7 w-7`,children:(0,g.jsx)(We,{size:15,className:`text-accent`,"aria-hidden":`true`})})}),(0,g.jsxs)(sm,{align:`start`,className:`w-[230px]`,children:[(0,g.jsx)(cm,{children:`Agent Profile`}),(0,g.jsx)(om,{value:oe,onValueChange:e=>void $e(e),children:O9.map(e=>(0,g.jsx)(um,{value:e.id,className:`items-start py-2`,children:(0,g.jsxs)(`span`,{className:`flex flex-col`,children:[(0,g.jsx)(`span`,{className:`text-[11.5px] font-medium text-ink`,children:e.label}),(0,g.jsx)(`span`,{className:`text-[10px] text-ink-3`,children:e.detail})]})},e.id))})]})]},`profile-${P}`),(0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsx)(vm,{disabled:ce,label:`审批策略:${R.label}`,title:`${R.label} · ${R.detail}`,className:`h-7 w-7`,children:(0,g.jsx)(He,{size:15,className:R.tone,"aria-hidden":`true`})})}),(0,g.jsxs)(sm,{align:`start`,className:`w-[230px]`,children:[(0,g.jsx)(cm,{children:`审批策略`}),(0,g.jsx)(om,{value:ae,onValueChange:e=>{let t=D9.find(t=>t.id===e);t&&t.id!==ae&&(t.id===`autonomous`?p(P):et(t.id))},children:D9.map(e=>(0,g.jsx)(um,{value:e.id,className:`items-start py-2`,children:(0,g.jsxs)(`span`,{className:`flex flex-col`,children:[(0,g.jsx)(`span`,{className:`text-[11.5px] font-medium text-ink`,children:e.label}),(0,g.jsx)(`span`,{className:`text-[10px] text-ink-3`,children:e.detail})]})},e.id))})]})]},`policy-${P}`),(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsx)(vm,{label:`添加附件`,title:`添加 PDF、Office、文本或图片(最大 20 MiB)`,disabled:!F||A,onClick:()=>u.current?.click(),className:`h-7 w-7`,children:(0,g.jsx)(Ns,{size:15,"aria-hidden":`true`})}),A?(0,g.jsx)(`button`,{type:`button`,onClick:N,"aria-label":`停止执行`,className:`ml-1 flex h-7 w-7 items-center justify-center rounded-full bg-danger/10 text-danger transition-colors hover:bg-danger/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-danger/40`,children:(0,g.jsx)(pc,{size:11,fill:`currentColor`})}):(0,g.jsx)(`button`,{type:`button`,onClick:nt,disabled:!O.trim()&&Me.length===0||!Ae||Xe||Pe||Fe||Ie,"aria-label":`发送消息`,className:B(`ml-1 flex h-7 w-7 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,(O.trim()||Me.length>0)&&Ae&&!Xe&&!Pe&&!Fe&&!Ie?`bg-accent text-white shadow-[var(--shadow-card)] hover:brightness-110 active:brightness-95`:`bg-black/[.06] text-ink-3 dark:bg-white/[.08]`),children:(0,g.jsx)(Ba,{size:15,strokeWidth:2.2})})]}),(0,g.jsx)(Xc,{open:le,title:`启用完全自主?`,description:`Agent 将不再逐次请求工具审批,可自行修改或删除文件、执行命令、进行 Git 推送等操作。程序以本机账户权限运行,可访问项目外文件和网络。请仅在信任当前任务时启用。此设置从下一轮起在当前会话持续生效,随时可以切回标准审批。`,confirmLabel:`确认启用`,danger:!0,onCancel:()=>p(null),onConfirm:()=>{le&&et(`autonomous`),p(null)}})]}),Je?(0,g.jsx)(Nce,{usage:I?void 0:qe,streaming:A,lastStep:Ye,contextUsage:{used:Ke?.inputTokens??null,limit:z}}):null]})}function Fce(){let e=Uq(e=>e.items),t=Uq(e=>e.sessionId),n=d3(e),[r,i]=(0,h.useState)(null),a=Math.max(0,n.findIndex(e=>e.id===r)),o=n[a];return o?(0,g.jsx)(Ice,{item:o,index:a,total:n.length,navigate:e=>i(n[a+e]?.id??o.id)},`${t}:${o.id}`):null}function Ice({item:e,index:t,total:n,navigate:r}){let i=Uq(e=>e.resolveApproval),{data:a}=sM(),o=vW(e=>e.projectId),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),[d,f]=(0,h.useState)(Date.now);(0,h.useEffect)(()=>{let e=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let p=e.expiresAt!==void 0&&d>=e.expiresAt,m=async t=>{if(!(s||p)){c(!0),u(null);try{await i(e.id,t)}catch(e){u(pj(e,`审批提交失败,请重试`))}finally{c(!1)}}};return(0,g.jsxs)(`section`,{"aria-label":`待处理审批`,className:`mb-2 max-h-[min(42dvh,360px)] overflow-y-auto rounded-xl border border-warning/25 bg-surface p-2.5 shadow-[var(--shadow-card)] text-[12px]`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-ink`,children:[(0,g.jsx)(ac,{size:14,className:`text-warning`}),(0,g.jsx)(`span`,{children:`需要批准`}),n>1?(0,g.jsxs)(`div`,{className:`ml-auto flex items-center gap-1 text-ink-3`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":`上一项审批`,disabled:s||t===0,onClick:()=>r(-1),className:`rounded p-1 disabled:opacity-30`,children:(0,g.jsx)(Qa,{size:14})}),(0,g.jsxs)(`span`,{children:[t+1,`/`,n]}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`下一项审批`,disabled:s||t===n-1,onClick:()=>r(1),className:`rounded p-1 disabled:opacity-30`,children:(0,g.jsx)(eo,{size:14})})]}):null]}),(0,g.jsx)(`pre`,{className:`mt-1.5 max-h-16 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 px-2 py-1.5 font-mono text-[12px] text-ink`,children:e.summary??e.impact??`请求执行操作`}),p?(0,g.jsx)(`p`,{role:`status`,className:`mt-1.5 text-ink-3`,children:`审批已过期,等待任务更新。`}):null,(0,g.jsx)(Yc,{message:l,onDismiss:()=>u(null)}),(0,g.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,g.jsxs)(`details`,{className:`min-w-0 flex-1 pt-1 text-[11px] text-ink-3`,children:[(0,g.jsx)(`summary`,{className:`cursor-pointer`,children:`查看操作详情`}),(0,g.jsxs)(`div`,{className:`mt-1.5 space-y-1 whitespace-pre-wrap break-words`,children:[(0,g.jsxs)(`div`,{children:[a.projects.find(e=>e.id===o)?.name??`默认工作区`,` ·`,` `,e.toolName??e.serviceName??`操作`]}),(0,g.jsxs)(`div`,{children:[`授权范围:仅本次操作 · 风险 `,e.risk??`—`]}),e.expiresAt===void 0?null:(0,g.jsxs)(`div`,{children:[`有效至 `,new Date(e.expiresAt).toLocaleTimeString()]}),(0,g.jsx)(`pre`,{className:`max-h-28 overflow-auto whitespace-pre-wrap`,children:JSON.stringify(e.scope??{},null,2)})]})]}),(0,g.jsxs)(`div`,{className:`flex shrink-0 gap-1.5`,children:[(0,g.jsx)(V,{variant:`primary`,size:`sm`,"aria-label":e.toolName?`批准执行`:`批准部署`,disabled:s||p,onClick:()=>void m(`approve`),children:s?`提交中…`:`批准本次`}),(0,g.jsx)(V,{variant:`secondary`,size:`sm`,disabled:s||p,onClick:()=>void m(`reject`),children:`拒绝`})]})]})]})}function j9({icon:e,label:t,ariaLabel:n,onClick:r,disabled:i,titleAttr:a}){return(0,g.jsxs)(`button`,{type:`button`,"aria-label":n,title:a??n,disabled:i,onClick:r,className:B(`group`,b9,wce),children:[(0,g.jsx)(e,{size:11,className:`shrink-0 text-accent`}),(0,g.jsx)(`span`,{className:`truncate`,children:t}),(0,g.jsx)(Ra,{size:10,className:`shrink-0 text-ink-3 group-hover:text-accent`})]})}function Lce(e){return e.split(`/`).pop()??e}function M9({target:e}){let[t,n]=(0,h.useState)(!1),[r,i]=(0,h.useState)(null),[a,o]=(0,h.useState)(!1);return(0,g.jsxs)(`div`,{className:`min-w-0`,children:[(0,g.jsx)(j9,{icon:Lo,label:`文件 · ${Lce(e.path)}`,ariaLabel:`查看文件 · ${e.path}`,disabled:a,onClick:()=>{o(!0),i(null),HM(e.scope,e.path,`agent`).then(t=>n(e.version!==void 0&&e.version!==t.version)).catch(e=>i(VM(e))).finally(()=>o(!1))}}),(0,g.jsx)(Hc,{message:r??(t?`文件已变化,已打开当前版本。`:null),tone:r?`error`:`success`,onDismiss:()=>r?i(null):n(!1)})]})}function N9({target:e}){let t=FM(e=>e.open),n=e.name??e.path;return(0,g.jsx)(j9,{icon:Co,label:`预览 · ${n}`,ariaLabel:`打开预览 · ${n}`,onClick:()=>t({kind:`browser`,resourceId:`browser:${e.serviceId}:${e.path}`,browser:{serviceId:e.serviceId,path:e.path},title:`预览服务`,projectId:e.projectId,source:`agent`})})}function Rce(e){return(0,g.jsx)(zce,{...e},JSON.stringify([e.projectId,e.terminalId]))}function zce({terminalId:e,projectId:t,label:n,ariaLabel:r,className:i,variant:a=`link`}){let[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(null),u=(0,h.useRef)(0),d=(0,h.useRef)(!1);(0,h.useEffect)(()=>()=>{u.current+=1,d.current=!1},[]);let f=async()=>{if(d.current)return;d.current=!0;let n=++u.current;s(!0),l(null);try{let r=await KK(e);if(n!==u.current)return;r.id!==e||r.projectId!==t?l({text:`终端归属已变化,无法打开。`,error:!0}):$K(r)?l({text:`终端已关闭`}):r.status===`RUNNING`?XK(r):l({text:r.status===`STOPPING`?`终端正在关闭,请稍后重试。`:r.status===`CREATED`?`终端正在创建,请稍后重试。`:`终端状态异常,请核对状态后重试。`})}catch(e){if(n!==u.current)return;l(e instanceof fj&&e.status===404?{text:`终端已关闭或已被清理`}:{text:`无法读取终端状态,请重试。`,error:!0})}finally{n===u.current&&(d.current=!1,s(!1))}};return(0,g.jsxs)(`div`,{className:`min-w-0`,children:[a===`card`?(0,g.jsx)(j9,{icon:dc,label:`终端 · ${n.replace(/^打开终端 · /,``)}`,ariaLabel:r??n,disabled:o,onClick:()=>void f()}):(0,g.jsxs)(`button`,{type:`button`,disabled:o,"aria-label":r,"aria-busy":o,onClick:()=>void f(),className:B(`flex max-w-full items-center gap-2 py-1 text-left text-[12px] text-ink-2 hover:text-ink disabled:opacity-50`,i),children:[(0,g.jsx)(dc,{size:13,className:`shrink-0 text-accent`}),(0,g.jsx)(`span`,{className:`break-all`,children:n})]}),(0,g.jsx)(Hc,{message:c?.text??null,tone:c?.error?`error`:`info`,onDismiss:()=>l(null)})]})}function P9({target:e}){return(0,g.jsx)(Rce,{terminalId:e.terminalId,projectId:e.projectId,label:`打开终端 · ${e.role??e.terminalId}`,variant:`card`})}function Bce({sessionId:e,attachments:t}){let[n,r]=(0,h.useState)(null);return t.length===0?null:(0,g.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,"data-testid":`attachment-strip`,children:[t.map(e=>(0,g.jsx)(x9,{item:{id:e.id,filename:e.filename,kind:e.kind,status:e.status,method:e.method,pageCount:e.pageCount,errorCode:e.errorCode},onOpen:()=>r({id:e.id,filename:e.filename,kind:e.kind,mime:e.mime})},e.id)),n?(0,g.jsx)(y9,{sessionId:e,target:n,onClose:()=>r(null)}):null]})}function Vce(e,t){let n=Eh(),[r,i]=(0,h.useState)(`正在连接输出…`);return(0,h.useEffect)(()=>{if(!t)return;let r=!1,a,o,s,c=1e3,l=!1,u=(t=!1)=>{l||=!t,r||s||(s=setTimeout(()=>{s=void 0,r||(n.invalidateQueries({queryKey:[`command`,e,`output`]}),l&&n.invalidateQueries({queryKey:[`command`,e,`state`]})),l=!1},250))},d=()=>{if(r)return;let t=new URL(`/ws`,window.location.href);t.protocol=t.protocol===`https:`?`wss:`:`ws:`,a=new WebSocket(t),a.onopen=()=>{a?.send(JSON.stringify({type:`subscribe`,subscriptions:[{topic:`command`,resourceId:e,after:0}]})),c=1e3,i(`实时输出已连接`),u()},a.onmessage=t=>{let n;try{n=JSON.parse(String(t.data))}catch{return}let r=VO.safeParse(n),i=RO.safeParse(n);r.success&&r.data.resourceId===e&&u(!0),i.success&&i.data.resourceId===e&&u()},a.onerror=()=>i(`输出连接中断,正在刷新状态…`),a.onclose=()=>{r||(i(`输出连接中断,正在重连…`),u(),o=setTimeout(d,c),c=Math.min(c*2,1e4))}};return d(),()=>{r=!0,clearTimeout(o),clearTimeout(s),a?.close()}},[t,n,e]),r}var Hce={CREATED:`准备执行`,RUNNING:`执行中`,CANCELLING:`正在停止`,COMPLETED:`已完成`,FAILED:`执行失败`,CANCELLED:`已取消`,TIMED_OUT:`执行超时`,INTERRUPTED:`执行中断`},F9=e=>!e||[`CREATED`,`RUNNING`,`CANCELLING`].includes(e);async function Uce(e,t){let n=t?.cursor??0,r=t?.text??``,i=t?.truncated??!1,a=t?.gap??!1;for(let t=0;t<64;t++){let t=BO.parse(await Y(`/api/commands/${e}/output?after=${n}&limit=500`));if(t.resyncRequired&&!t.chunks.length&&(r=``),r+=t.chunks.filter(e=>e.cursor>n).map(e=>e.data).join(``),i||=t.truncated,a||=t.resyncRequired,t.nextCursor<=n||t.chunks.length<500)return{text:r,truncated:i,gap:a,cursor:t.nextCursor};n=t.nextCursor}return{text:r,truncated:!0,gap:a,cursor:n}}function Wce({commandId:e}){let t=Eh(),n=Zg({queryKey:[`command`,e,`state`],queryFn:async()=>zO.parse(await Y(`/api/commands/${e}`)),staleTime:0,refetchInterval:e=>F9(e.state.data?.status)&&!e.state.error?2e3:!1}),r=F9(n.data?.status);Vce(e,r&&!n.error);let i=Zg({queryKey:[`command`,e,`output`],queryFn:()=>Uce(e,t.getQueryData([`command`,e,`output`])),staleTime:0,refetchInterval:r&&!n.error?2e3:!1}),a=n.data?.status;(0,h.useEffect)(()=>{a&&!F9(a)&&t.invalidateQueries({queryKey:[`command`,e,`output`]})},[t,e,a]);let o=()=>t.invalidateQueries({queryKey:[`command`,e]}),s=t_({mutationFn:async()=>zO.parse(await Y(`/api/commands/${e}/cancel`,{method:`POST`,body:{},csrf:!0})),onSuccess:n=>{t.setQueryData([`command`,e,`state`],n),o()},onError:()=>{o()}});return(0,g.jsxs)(`section`,{"aria-label":`命令执行`,className:`mt-2 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-2 text-[11px]`,children:[(0,g.jsx)(`span`,{className:`font-semibold text-ink`,children:`命令执行`}),(0,g.jsx)(`span`,{role:`status`,className:`text-ink-2`,children:n.data?Hce[n.data.status]:n.error?`命令不可用`:`正在读取状态…`}),n.data?.exitCode!==null&&n.data?.exitCode!==void 0?(0,g.jsxs)(`span`,{className:`font-mono text-ink-3`,children:[`退出码 `,n.data.exitCode]}):null,(0,g.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-1`,children:[(0,g.jsx)(V,{size:`sm`,variant:`secondary`,onClick:()=>void o(),children:`刷新输出`}),n.data&&r?(0,g.jsx)(V,{size:`sm`,variant:`secondary`,disabled:s.isPending||n.data.status===`CANCELLING`,onClick:()=>s.mutate(),children:`取消命令`}):null]})]}),n.data?.reasonCode?(0,g.jsxs)(`p`,{className:`px-3 text-[11px] text-ink-2`,children:[`原因:`,n.data.reasonCode]}):null,n.data?.status===`INTERRUPTED`?(0,g.jsx)(`p`,{className:`px-3 text-[11px] text-warning`,children:`执行已中断;停止情况以状态原因为准,不能确认时项目保持受阻。`}):null,(0,g.jsx)(Yc,{message:s.error?`取消命令失败,请刷新确认。`:n.error||i.error?`命令状态或输出读取失败。`:null,onDismiss:s.error?()=>s.reset():void 0}),i.data?.gap?(0,g.jsx)(`p`,{className:`px-3 text-[11px] text-warning`,children:`输出有缺口,以下仅为当前可用记录。`}):null,i.data?.truncated||n.data?.truncated?(0,g.jsx)(`p`,{className:`px-3 text-[11px] text-warning`,children:`输出已截断。`}):null,(0,g.jsx)(`pre`,{role:`log`,"aria-label":`命令输出`,className:`max-h-[200px] overflow-auto whitespace-pre-wrap break-words border-t border-line bg-surface-2 px-3 py-2 font-mono text-[11px] text-ink-2`,children:i.data?.text||(r?`等待命令输出…`:`无可用输出`)})]})}function I9({item:e,turnActive:t=!1,turnOutcome:n,commentary:r=!1,onRetry:i}){switch(e.kind){case`message`:return(0,g.jsx)(L9,{item:e,commentary:r});case`plan`:return(0,g.jsx)(Yce,{item:e,turnActive:t,turnOutcome:n});case`tool`:return(0,g.jsx)(Xce,{item:e});case`reasoning`:return null;case`approval`:return null;case`artifact`:return(0,g.jsx)(Zce,{item:e});case`error`:return(0,g.jsxs)(`div`,{role:`status`,className:B(`border-l-2 pl-3 text-[12px] leading-5`,/已停止/.test(e.message)?`border-line text-ink-3`:`border-danger/50 text-ink-2`),children:[e.message,i?(0,g.jsx)(`button`,{type:`button`,onClick:i,className:`ml-2 text-[11px] text-accent hover:underline`,children:`重试`}):null]})}}function L9({item:e,children:t,commentary:n=!1,finalAnswer:r=!1}){let[i,a]=(0,h.useState)(!1),[o,s]=(0,h.useState)(!1),c=vW(e=>e.sessionId);if(e.role===`user`&&e.text.startsWith(`Work state checkpoint`))return(0,g.jsx)(`div`,{className:`mb-5 flex justify-end`,children:(0,g.jsxs)(`div`,{className:`max-w-[91%] rounded-[18px] bg-surface-2 px-3.5 py-2.5 text-[12px] leading-[1.65] text-ink-2 sm:max-w-[82%]`,children:[(0,g.jsx)(`div`,{className:`text-ink`,children:`自动继续上一轮的未完成工作`}),(0,g.jsx)(`div`,{className:`mt-0.5`,children:`已带上已完成文件、命令与失败诊断的核对事实。`}),(0,g.jsx)(`button`,{type:`button`,className:`mt-1 text-[11px] text-ink-3 transition-colors hover:text-accent`,onClick:()=>a(e=>!e),children:i?`收起核对事实`:`查看核对事实`}),i?(0,g.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] text-ink-3`,children:e.text}):null]})});let l=e.attachments&&e.attachments.length>0?void 0:e.screenshots;return e.role===`user`?(0,g.jsxs)(`div`,{className:`mb-5 flex flex-col items-end gap-1.5`,children:[e.text?(0,g.jsxs)(`div`,{className:`max-w-[91%] rounded-[18px] bg-accent-soft px-3.5 py-2.5 text-[13px] leading-[1.65] text-ink sm:max-w-[82%]`,children:[(0,g.jsx)(`div`,{className:B(`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,!i&&e.text.length>1200&&`line-clamp-8`),children:e.text}),e.text.length>1200?(0,g.jsx)(`button`,{type:`button`,className:`mt-1 text-[11px] text-ink-3`,onClick:()=>a(e=>!e),children:i?`收起`:`展开消息`}):null]}):null,e.attachments&&e.attachments.length>0&&c?(0,g.jsx)(Bce,{sessionId:c,attachments:e.attachments}):null,l?(0,g.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:l.ids.map(e=>(0,g.jsx)(Gce,{src:Jj(l.sessionId,e)},e))}):null]}):(0,g.jsxs)(`article`,{className:B(`min-w-0 break-words leading-[1.65] [overflow-wrap:anywhere]`,n?`text-[12px] text-ink-2`:`text-[13px] text-ink`),children:[e.text?(0,g.jsx)(`div`,{"data-testid":r?`final-answer-bubble`:`message-bubble`,className:B(`w-fit min-w-0 max-w-full rounded-2xl rounded-tl-md border border-line bg-surface`,n?`px-3 py-2`:`px-3.5 py-2.5`),children:(0,g.jsx)(v9,{text:e.text})}):null,t,!e.streaming&&e.text?(0,g.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 px-0.5`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":o?`已复制答复`:`复制答复`,className:`rounded p-1 text-ink-3 hover:bg-surface-2`,onClick:()=>{navigator.clipboard.writeText(e.text).then(()=>s(!0)).catch(()=>s(!1))},children:o?(0,g.jsx)(Ja,{size:13}):(0,g.jsx)(yo,{size:13})}),(0,g.jsx)(`time`,{dateTime:new Date(e.createdAt).toISOString(),title:new Date(e.createdAt).toLocaleString(),className:`font-mono text-[11px] text-ink-3`,children:new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})})]}):null]})}function Gce({src:e}){let[t,n]=(0,h.useState)(!1);return t?(0,g.jsx)(`span`,{className:`rounded-md border border-line bg-surface-2 px-2 py-1 text-[11px] text-ink-3`,children:`截图不可用`}):(0,g.jsx)(`img`,{src:e,alt:`用户截图`,className:`max-h-48 max-w-full rounded-lg object-contain`,loading:`lazy`,onError:()=>n(!0)})}function Kce(e,t,n){if(e!==`running`||t)return e;switch(n){case`cancelled`:return`stopped`;case`failed`:case`interrupted`:return`interrupted`;default:return`unmarked`}}var qce={done:`已完成:`,running:`进行中:`,failed:`失败:`,pending:`待做:`,stopped:`已停止`,interrupted:`已中断`,unmarked:`未标记完成`},Jce=new Set([`stopped`,`interrupted`,`unmarked`]);function Yce({item:e,turnActive:t,turnOutcome:n}){let r=e.steps.length,i=e.steps.filter(e=>e.status===`done`).length,a=e.steps.filter(e=>e.status===`failed`).length,o=t?0:e.steps.filter(e=>e.status===`running`||e.status===`pending`).length,s=`计划 · ${i}/${r} · ${e.title}${o>0?` · 另有 ${o} 步未完成`:``}`;return(0,g.jsxs)(`div`,{className:`mb-2 min-w-0 rounded-lg bg-surface-3 px-2.5 py-2 text-[12px] text-ink-2 sm:max-w-[28rem]`,children:[(0,g.jsxs)(`div`,{"aria-hidden":`true`,className:`mb-1.5 flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`shrink-0 font-medium`,children:`计划`}),(0,g.jsxs)(`span`,{className:`shrink-0 text-[11px] tabular-nums`,children:[i,`/`,r]}),(0,g.jsx)(`span`,{className:`flex-1`}),a>0?(0,g.jsxs)(`span`,{className:`shrink-0 text-[10.5px] text-danger`,children:[a,` 步失败`]}):o>0?(0,g.jsxs)(`span`,{className:`shrink-0 text-[10.5px]`,children:[o,` 步未完成`]}):null]}),(0,g.jsx)(`ol`,{"aria-label":s,className:`space-y-[3px]`,children:e.steps.map(e=>{let r=Kce(e.status,t,n);return(0,g.jsxs)(`li`,{"aria-current":r===`running`?`step`:void 0,className:`flex items-start gap-1.5`,children:[r===`done`?(0,g.jsx)(Ja,{size:13,className:`mt-[2px] shrink-0 text-success`}):r===`running`?(0,g.jsx)(ps,{size:13,className:`mt-[2px] shrink-0 animate-spin text-accent motion-reduce:animate-none`}):r===`failed`?(0,g.jsx)(Ac,{size:13,className:`mt-[2px] shrink-0 text-danger`}):(0,g.jsx)(uo,{size:13,className:`mt-[2px] shrink-0 text-ink-3`}),(0,g.jsxs)(`span`,{className:B(`min-w-0 flex-1 break-words`,r===`running`&&`text-ink`),children:[e.title,(0,g.jsx)(`span`,{className:B(Jce.has(r)?`ml-2`:`sr-only`,`text-[11px]`),children:qce[r]})]})]},e.id)})})]})}function Xce({item:e}){let[t,n]=(0,h.useState)(!1);return(0,g.jsxs)(`div`,{className:`min-w-0 text-[12px] text-ink-3`,children:[(0,g.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(e=>!e),className:`flex w-full items-start gap-1.5 rounded-md py-1 text-left transition-colors hover:text-accent`,children:[(0,g.jsx)(eo,{size:13,className:B(`mt-0.5 shrink-0`,t&&`rotate-90`)}),(0,g.jsx)(`span`,{className:B(`min-w-0 [overflow-wrap:anywhere]`,e.commandLabel&&`line-clamp-2 font-mono`),children:e.commandLabel||e.summary||e.name}),e.status===`error`?(0,g.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-0.5 text-danger`,children:[(0,g.jsx)(Ac,{size:13}),` 失败`,e.retried===!0?(0,g.jsx)(`span`,{className:`text-ink-3`,children:`· 已重试`}):null]}):null]}),t?(0,g.jsxs)(`div`,{className:`ml-5 space-y-2`,children:[(0,g.jsxs)(`div`,{className:`text-[11px]`,children:[e.name,e.durationMs===void 0?``:` · ${Math.round(e.durationMs/1e3)}秒`]}),e.args?(0,g.jsx)(`pre`,{className:`max-h-[200px] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-2.5 font-mono text-[12px] text-ink-2`,children:e.args}):null,e.output?(0,g.jsx)(`pre`,{className:`max-h-[200px] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-2.5 font-mono text-[12px] text-ink-2`,children:e.output}):null,e.commandId?(0,g.jsx)(Wce,{commandId:e.commandId}):null]}):null]})}function Zce({item:e}){let t=FM(e=>e.open),{projectId:n,sessionId:r}=vW();return e.resourceTarget?.kind===`file`?(0,g.jsx)(M9,{target:e.resourceTarget}):e.resourceTarget?.kind===`preview`?(0,g.jsx)(N9,{target:e.resourceTarget}):e.resourceTarget?.kind===`terminal`?(0,g.jsx)(P9,{target:e.resourceTarget}):(0,g.jsxs)(`div`,{className:`break-words text-[12px] text-ink-2`,children:[(0,g.jsx)(`span`,{children:e.title}),(0,g.jsx)(`p`,{className:`mt-1 text-ink-3`,children:e.description}),e.href?(0,g.jsxs)(`button`,{type:`button`,className:`mt-1 text-accent underline decoration-accent/30 underline-offset-4 hover:decoration-accent`,onClick:()=>t({kind:`browser`,resourceId:e.href??e.id,title:e.title,projectId:n,sessionId:r,source:`artifact`}),children:[`打开 `,e.title]}):null]})}var R9=3;function Qce(e){return e.kind===`message`&&e.role===`user`}function $ce(e){return e.kind===`message`&&e.role===`user`&&e.text.startsWith(`Work state checkpoint`)}function ele(e){let t=[],n=new Map,r;for(let i of e){let e=i.kind===`message`&&i.role===`user`;if($ce(i)&&i.turnId!==void 0&&r!==void 0){n.set(i.turnId,r),r.turnIds.push(i.turnId),r.users.push(i);continue}let a=i.turnId??(e?i.id:r?.id??i.id),o=n.get(a);if(o)o.items.push(i),i.turnId!==void 0&&!o.turnIds.includes(i.turnId)&&o.turnIds.push(i.turnId),e&&(r=o,o.users.push(i));else{let o={id:a,items:[i],turnIds:i.turnId===void 0?[]:[i.turnId],users:e?[i]:[]};t.push(o),n.set(a,o),r=o}}return t}function tle(e,t){return t===null?e.at(-1):e.find(e=>e.turnIds.includes(t))}function nle(e){switch(e){case`tokens`:return`已达花费上限`;case`context`:return`上下文已满`;case`duration`:return`执行超时中止`;case`steps`:return`步数已达上限`;case`tool_calls`:return`工具调用已达上限`;default:return`预算停止`}}function rle(e){let t=Uq(e=>e.turnStartedAt),[n,r]=(0,h.useState)(()=>Date.now());return(0,h.useEffect)(()=>{if(!e)return;r(Date.now());let t=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),!e||t===null?null:Math.max(0,Math.floor((n-t)/1e3))}function ile(){return(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`process-sparkle`,"data-active":`true`,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 20 20`,fill:`none`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{className:`process-sparkle-main`,d:`M7.6 2.2c.5 4.2 1.9 5.6 6.1 6.1-4.2.5-5.6 1.9-6.1 6.1-.5-4.2-1.9-5.6-6.1-6.1 4.2-.5 5.6-1.9 6.1-6.1Z`,fill:`currentColor`}),(0,g.jsx)(`path`,{className:`process-sparkle-small`,d:`M15.4 11.2c.3 2.3 1 3 3.3 3.3-2.3.3-3 1-3.3 3.3-.3-2.3-1-3-3.3-3.3 2.3-.3 3-1 3.3-3.3Z`,fill:`currentColor`})]})})}function ale(e){switch(e.name){case`run_command`:case`run_shell`:return`命令`;case`read_file`:case`list_files`:case`search_code`:return`读取`;case`write_file`:case`apply_patch`:return`修改文件`;case`start_process`:case`list_processes`:case`read_process_output`:case`stop_process`:return`后台进程`;case`list_service_ops`:case`read_service_ops_logs`:case`control_service_ops`:return`服务运维`;default:return``}}function ole({group:e,active:t}){let n=Uq(e=>e.send),r=Uq(e=>e.resumeTurn),i=e.items,a=i.find(Qce),o=e.users.at(-1)??a,s=t&&o?.turnOutcome===void 0,[c,l]=(0,h.useState)(!1),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(!1),m=i.filter(e=>e.kind===`tool`&&e.name!==`update_plan`),_=-1,v=-1;i.forEach((e,t)=>{e.kind===`tool`&&(_=t),e.kind===`message`&&e.role===`assistant`&&(v=t)});let y=v>=0&&!s&&o?.terminalReason!==`continued`&&(v>_||o?.turnOutcome===`completed`)?i[v]:void 0,b=t&&!y?[...i].reverse().find(e=>e.kind===`message`&&e.role===`assistant`):void 0,x=i.filter(e=>e.kind===`plan`).at(-1),S=i.filter(e=>e!==a&&e!==y&&e!==b&&(e.kind===`message`&&e.role===`assistant`||e.kind===`tool`&&e.name!==`update_plan`)),C=o?.turnOutcome===`interrupted`,w=o?.turnOutcome===`failed`,T=o?.turnOutcome===`cancelled`,E=o?.terminalReason===`continued`,D=C&&o.turnId!==void 0?`interrupted_${o.turnId}`:void 0,O=o?.terminalReason===`budget`,k=o?.terminalReason===`output_truncated`,A=e.users.reduce((e,t)=>t.durationMs===void 0?e:(e??0)+t.durationMs,void 0),j=rle(s),M=s&&d3(i).length>0,N=[...i].reverse().find(e=>e.kind===`tool`&&e.name!==`update_plan`&&e.status===`running`),ee=s&&i.some(e=>e.kind===`message`&&e.role===`assistant`&&e.streaming),te=s&&i.some(e=>e.kind===`reasoning`&&e.streaming),P;P=s?M?`Waiting for approval...`:N?`Running...`:ee?`Generating...`:te?`Thinking...`:`Starting...`:E?`Continuing...`:T?`Stopped`:C?`Interrupted`:w?`Failed`:`Completed`;let F=Math.max(0,e.users.length-1),ne=s&&j!==null?`${j}s`:!s&&A!==void 0?`${Math.round(A/1e3)}s`:``,I=m.length,re=I>0?`${I} 步`:``,ie=[ne,N?ale(N):``,F>0?`已自动继续 ${F} 次`:``,!s&&O?nle(o?.budgetCause):``,!s&&k?`输出被截断`:``].filter(Boolean).join(` · `),ae=[`执行过程`,P,ie,re].filter(Boolean).join(` · `),oe=c?S:!s&&y===void 0?S.filter(e=>e.kind===`tool`&&e.status===`error`):[],se=new Map;for(let e of m){let t=e.resourceTarget;t&&se.set(t.kind===`file`?JSON.stringify([t.scope,t.path]):t.kind===`preview`?`preview:${t.serviceId}:${t.path}`:t.terminalId,t)}let ce=new Set([...se.values()].filter(e=>e.kind===`file`).map(e=>e.path)),le=new Map,ue=0;for(let t of e.users){ue+=t.fileResultsOmitted??0;for(let e of t.fileResults??[])le.set(e.path,e)}let de=le.size===0?void 0:[...le.values()],L=new Set((de??[]).filter(e=>e.category===`deliverable`).map(e=>e.path)),fe=de===void 0?[...se.entries()]:[...se.entries()].filter(([,e])=>e.kind!==`file`||L.has(e.path)),pe=fe.filter(([,e])=>e.kind===`file`),me=f?pe:pe.slice(0,R9),he=new Set(me.map(([e])=>e)),ge=fe.filter(([e,t])=>t.kind!==`file`||he.has(e)),_e=i.filter(e=>{if(e.kind!==`artifact`)return!1;let t=e.title.replace(/^已(?:修改|创建) /,``);return de===void 0?!ce.has(t):t===e.title}),ve=ge.length>0||_e.length>0||ue>0,ye=!s&&ve?(0,g.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[ge.length>0?(0,g.jsxs)(`section`,{"aria-label":`本次成果`,className:`flex flex-wrap gap-1.5`,children:[ge.map(([e,t])=>t.kind===`file`?(0,g.jsx)(M9,{target:t},e):t.kind===`preview`?(0,g.jsx)(N9,{target:t},e):(0,g.jsx)(P9,{target:t},e)),pe.length>R9?(0,g.jsx)(`button`,{type:`button`,"aria-label":f?`收起文件`:`展开全部文件`,"aria-expanded":f,onClick:()=>p(e=>!e),className:`px-1 py-1 text-[11px] text-ink-3 transition-colors hover:text-accent`,children:f?`收起`:`展开全部`}):null]}):null,_e.map(e=>(0,g.jsx)(I9,{item:e},e.id)),ue>0?(0,g.jsx)(`p`,{className:`text-[11px] text-ink-3`,children:`另有 ${ue} 个文件未列出`}):null]}):null;return(0,g.jsxs)(`section`,{"aria-label":`对话轮次`,className:`min-w-0`,children:[a?(0,g.jsx)(I9,{item:a}):null,x?(0,g.jsx)(I9,{item:x,turnActive:s,turnOutcome:o?.turnOutcome},x.id):null,(0,g.jsxs)(`div`,{className:`space-y-2`,children:[S.length>0||m.length>0||te||M||s&&!y?(0,g.jsxs)(`div`,{className:`text-[12px] text-ink-3`,children:[(0,g.jsxs)(`button`,{type:`button`,"aria-label":ae,"aria-expanded":c,onClick:()=>l(e=>!e),className:`process-status-row flex w-full items-center gap-2 rounded-md px-1 py-1 text-left transition-colors hover:text-accent`,children:[s?(0,g.jsx)(ile,{}):null,(0,g.jsx)(`span`,{className:B(`shrink-0 font-medium text-ink-2`,s&&`process-status-shimmer`),children:P}),ie===``?null:(0,g.jsx)(`span`,{className:`relative top-[0.5px] min-w-0 truncate text-[11px] text-ink-3`,children:ie}),(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[re===``?null:(0,g.jsx)(`span`,{"data-testid":`process-metrics`,className:`text-[11px] text-ink-3 tabular-nums`,children:re}),re===``?null:(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px bg-line`}),(0,g.jsx)(eo,{size:13,className:B(`shrink-0 transition-transform`,c&&`rotate-90`)})]})]}),oe.length>0?(0,g.jsx)(`div`,{className:`ml-1.5 mt-1 space-y-1 border-l border-line pl-3`,children:oe.map(e=>(0,g.jsx)(I9,{item:e,turnActive:s,commentary:!0},e.id))}):null]}):null,o?.turnOutcome===`interrupted`&&o.turnId!==void 0?(0,g.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-line bg-surface-2 px-2.5 py-1.5 text-[12px] text-ink-2`,children:u?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:`继续会新建一轮,并带上已完成文件、命令与失败诊断的核对事实;原轮次保持原样。`}),(0,g.jsx)(`button`,{type:`button`,className:`rounded border border-line px-2 py-0.5 text-ink transition-colors hover:text-accent`,onClick:()=>{d(!1),r(o.turnId??``)},children:`确认继续`}),(0,g.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-ink-3 transition-colors hover:text-ink`,onClick:()=>d(!1),children:`取消`})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:`上次执行被中断(服务重启或退出)。`}),(0,g.jsx)(`button`,{type:`button`,className:`rounded border border-line px-2 py-0.5 text-ink transition-colors hover:text-accent`,onClick:()=>d(!0),children:`继续这个任务`})]})}):null,b?(0,g.jsx)(I9,{item:b,commentary:!0}):null,y?.kind===`message`?(0,g.jsx)(L9,{item:y,finalAnswer:!0,children:ye}):ye,i.filter(e=>e.kind===`error`&&e.id!==D).map(e=>(0,g.jsx)(I9,{item:e,onRetry:a?()=>void n(a.text):void 0},e.id))]})]})}function sle(){let e=Uq(e=>e.items),t=Uq(e=>e.loading),n=Uq(e=>e.isStreaming),r=Uq(e=>e.contextNotice),i=Uq(e=>e.activeTurnId),a=Uq(e=>e.scrollToLatestNonce),o=vW(e=>e.sessionId),s=(0,h.useRef)(null),c=(0,h.useRef)(null),l=(0,h.useRef)(!0),[u,d]=(0,h.useState)(!1),f=(0,h.useCallback)(()=>{let e=s.current;e&&(l.current?e.scrollTop=e.scrollHeight:d(e.scrollHeight-e.scrollTop-e.clientHeight>140))},[]);(0,h.useLayoutEffect)(()=>{l.current=!0,d(!1)},[o]);let p=e.map(e=>e.kind===`reasoning`?``:JSON.stringify(e)).join(`|`);(0,h.useLayoutEffect)(f,[p,t]),(0,h.useLayoutEffect)(()=>{if(a===0)return;l.current=!0,d(!1);let e=s.current;e&&(e.scrollTop=e.scrollHeight)},[a]),(0,h.useEffect)(()=>{let e=s.current,t=c.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(f);return n.observe(e),n.observe(t),()=>n.disconnect()},[f]);let m=ele(e),_=n?tle(m,i):void 0;return(0,g.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,g.jsx)(`div`,{ref:s,role:`log`,"aria-label":`会话时间线`,onClickCapture:e=>{e.target instanceof Element&&e.target.closest(`button[aria-expanded]`)&&(l.current=!1)},onScroll:e=>{let t=e.currentTarget,n=t.scrollHeight-t.scrollTop-t.clientHeight;l.current=n<70,d(n>140)},className:`min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-7 [scrollbar-gutter:stable]`,children:(0,g.jsxs)(`div`,{ref:c,className:`mx-auto w-full max-w-[760px] space-y-8 pb-5`,children:[r?(0,g.jsxs)(`p`,{role:`status`,className:`text-[11px] text-ink-3`,children:[`上下文已压缩`,r.degraded?`(降级:超出部分已截断)`:``]}):null,t?(0,g.jsx)(`div`,{role:`status`,className:`py-8 text-[12px] text-ink-3`,children:`正在加载对话…`}):m.map(e=>(0,g.jsx)(ole,{group:e,active:_===e},`${o}:${e.id}`))]})}),(0,g.jsx)(`div`,{"aria-hidden":`true`,className:`conversation-scroll-edge conversation-scroll-edge-top`}),(0,g.jsx)(`div`,{"aria-hidden":`true`,className:`conversation-scroll-edge conversation-scroll-edge-bottom`}),u?(0,g.jsx)(`button`,{type:`button`,"aria-label":`回到最新消息`,onClick:()=>{l.current=!0,f(),d(!1)},className:`absolute bottom-3 left-1/2 z-10 flex h-8 w-8 -translate-x-1/2 items-center justify-center rounded-full border border-line bg-surface text-accent shadow-[var(--shadow-card)] transition-colors hover:bg-accent-soft`,children:(0,g.jsx)(Ma,{size:14})}):null]})}var cle=[{label:`了解项目`,text:`先帮我了解项目结构、主要功能和启动方式。`,icon:Uo,color:`text-accent`},{label:`排查问题`,text:`帮我排查一个问题:`,icon:Ka,color:`text-warning`},{label:`实现功能`,text:`我想在这个项目中实现一个功能:`,icon:_o,color:`text-success`}];function lle(){return(0,g.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 grid place-items-center overflow-clip [container-type:size]`,children:(0,g.jsx)(`div`,{"data-testid":`welcome-backdrop`,className:`welcome-backdrop relative aspect-square w-[min(100cqw,100cqh,700px)]`})})}function ule({workspaceLabel:e}){return(0,g.jsxs)(`h2`,{className:`mb-6 text-balance text-center text-[20px] font-semibold tracking-tight text-ink [overflow-wrap:anywhere] sm:text-[27px]`,children:[`想在 `,e,` 中做些什么?`]})}function dle(){return(0,g.jsx)(`section`,{"aria-label":`建议任务`,className:`mt-3 flex flex-wrap justify-center gap-2`,children:cle.map(({label:e,text:t,icon:n,color:r})=>(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{yW.getState().setDraft(t),vW.getState().focusComposer()},className:`inline-flex min-h-8 items-center gap-1.5 rounded-lg border border-line bg-surface/70 px-2.5 text-[12px] text-ink-2 transition-colors hover:border-accent/30 hover:bg-accent-soft hover:text-ink focus-visible:outline-2 focus-visible:outline-accent`,children:[(0,g.jsx)(n,{size:14,className:r,"aria-hidden":`true`}),e]},e))})}function fle(){let{data:e}=sM(),{projectId:t,sessionId:n,resourceCollapsed:r,toggleResource:i}=vW();BK(e=>e.extra);let a=Eh(),[o,s]=(0,h.useState)(!1),c=Uq(e=>e.sessionId===n&&!e.loading&&!e.isStreaming&&!e.items.length),l=(0,h.useRef)(null),u=(0,h.useRef)(null),d=(0,h.useRef)(null),f=()=>{c&&l.current&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches&&(u.current={sessionId:n,top:l.current.getBoundingClientRect().top})};(0,h.useLayoutEffect)(()=>{if(c){d.current?.cancel();return}let e=u.current;u.current=null;let t=l.current;if(e?.sessionId!==n||!t||typeof t.animate!=`function`)return;let r=e.top-t.getBoundingClientRect().top;r&&(d.current=t.animate([{transform:`translateY(${r}px)`},{transform:`translateY(0)`}],{duration:290,easing:`cubic-bezier(.22,.75,.25,1)`}))},[c,n]);let p=[...e.sessions].find(e=>e.id===n),m=e.projects.find(e=>e.id===t)?.name??_W(n,e.sessions),_=async()=>{if(p)try{await qj(p.id),await a.invalidateQueries({queryKey:[`workspace`]})}catch(e){window.dispatchEvent(new CustomEvent(`larness:workspace-error`,{detail:pj(e,`归档会话失败`)}))}};return(0,g.jsxs)(`main`,{className:`conversation-surface flex min-h-0 min-w-0 flex-1 flex-col bg-canvas/55`,children:[(0,g.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 px-4 sm:px-7`,children:[(0,g.jsx)(`h1`,{className:`min-w-0 truncate text-[12px] font-medium`,children:p?.title??`新会话`}),(0,g.jsx)(`span`,{className:`ml-auto hidden max-w-[40%] truncate text-[11px] text-ink-3 md:block`,children:m}),(0,g.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 md:ml-0`,children:[(0,g.jsx)(vm,{label:r?`展开项目资源`:`折叠项目资源`,className:`hidden xl:inline-flex`,onClick:i,children:(0,g.jsx)(js,{size:14})}),(0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsx)(vm,{label:`会话操作`,children:(0,g.jsx)(To,{size:15})})}),(0,g.jsxs)(sm,{align:`end`,className:`w-[190px]`,children:[(0,g.jsx)(lm,{disabled:!p,onSelect:()=>s(!0),children:`重命名会话`}),(0,g.jsx)(dm,{}),(0,g.jsx)(lm,{disabled:!p||!1,onSelect:()=>void _(),className:`text-danger focus:text-danger`,children:`归档会话`})]})]})]})]}),c?null:(0,g.jsx)(sle,{}),(0,g.jsx)(QW,{session:p?{id:p.id,title:p.title}:null,onClose:()=>s(!1),open:o}),(0,g.jsxs)(`div`,{"data-testid":`composer-dock`,"data-placement":c?`center`:`bottom`,className:B(`relative px-4 sm:px-7`,c?`flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto py-5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`:`shrink-0 pb-3 pt-1`),children:[c?(0,g.jsx)(lle,{}):null,(0,g.jsxs)(`div`,{className:B(`relative mx-auto flex w-full max-w-[760px] flex-col`,c&&`my-auto shrink-0`),children:[c?(0,g.jsx)(ule,{workspaceLabel:m}):null,c?null:(0,g.jsx)(u3,{}),(0,g.jsx)(Fce,{}),(0,g.jsx)(`div`,{ref:l,"data-composer-motion":!0,className:`relative z-10 min-w-0`,children:(0,g.jsx)(Pce,{centered:c,onSubmit:f})}),c?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dle,{}),(0,g.jsx)(`div`,{className:`mt-5`,children:(0,g.jsx)(u3,{})})]}):null]})]})]})}function ple(e){let t=Uq(e=>e.load),n=Uq(e=>e.disconnect);(0,h.useEffect)(()=>(t(e),()=>n()),[n,t,e])}function mle({scope:e,treeWidth:t,open:n,close:r,restoreFocus:i}){return(0,g.jsx)(Wc,{open:n,onOpenChange:e=>{e||r()},children:n?(0,g.jsx)(hle,{scope:e,treeWidth:t,close:r,restoreFocus:i}):null})}function hle({scope:e,treeWidth:t,close:n,restoreFocus:r}){let[i,a]=(0,h.useState)(``),[o,s]=(0,h.useState)(``),[c,l]=(0,h.useState)(0),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(``),m=(0,h.useRef)(null),_=(0,h.useId)(),v=i.trim();(0,h.useLayoutEffect)(()=>()=>m.current?.abort(),[]),(0,h.useEffect)(()=>{let e=window.setTimeout(()=>s(v),160);return()=>window.clearTimeout(e)},[v]);let y=Zg({queryKey:[`file-search`,IM(e),o],queryFn:({signal:t})=>Ote(e,o,t),enabled:v!==``&&v===o,retry:!1,gcTime:3e4}),b=v===o?y.data?.items??[]:[],x=Math.min(c,b.length-1),S=b[x],C=S?`${_}-${x}`:void 0;(0,h.useEffect)(()=>{C&&document.getElementById(C)?.scrollIntoView?.({block:`nearest`})},[C]);let w=r=>{if(m.current)return;m.current=new AbortController;let{signal:i}=m.current;p(``),d(!0),HM(e,r,`projectId`in e?`project`:`sessionId`in e?`session`:`global`,{signal:i,treeWidth:t}).then(n).catch(e=>{i.aborted||p(VM(e))}).finally(()=>{i.aborted||(m.current=null,d(!1))})};return(0,g.jsxs)(Kc,{overlayClassName:`bg-black/10 backdrop-blur-[3px] dark:bg-black/30`,className:`top-[min(15dvh,140px)] bottom-auto mx-auto max-h-[76dvh] w-[min(640px,calc(100vw-28px))] overflow-hidden rounded-[22px] border-white/60 bg-surface/90 p-0 shadow-[0_24px_80px_-16px_rgb(0_0_0/0.38)] backdrop-blur-2xl dark:border-white/12`,onCloseAutoFocus:e=>{e.preventDefault(),r()},children:[(0,g.jsx)(qc,{className:`sr-only`,children:`快速打开文件`}),(0,g.jsx)(Jc,{className:`sr-only`,children:`搜索当前工作区。使用方向键选择,Enter 打开。`}),(0,g.jsxs)(`div`,{className:`flex h-16 items-center gap-3 px-4 sm:h-[72px] sm:px-5`,children:[(0,g.jsx)($s,{size:24,"aria-hidden":`true`,className:`shrink-0 text-ink-3`}),(0,g.jsx)(mm,{variant:`bare`,className:`h-full min-w-0 flex-1 bg-transparent text-base text-ink outline-none sm:text-xl`,role:`combobox`,"aria-label":`文件名或相对路径`,"aria-autocomplete":`list`,"aria-controls":_,"aria-expanded":b.length>0,"aria-activedescendant":C,placeholder:`输入文件名或相对路径`,maxLength:128,readOnly:u,value:i,onChange:e=>{a(e.target.value),l(0),p(``)},onKeyDown:e=>{if(S&&!e.nativeEvent.isComposing){switch(e.key){case`ArrowDown`:l((x+1)%b.length);break;case`ArrowUp`:l((x+b.length-1)%b.length);break;case`Enter`:w(S.path);break;default:return}e.preventDefault()}}}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭快速打开`,title:`关闭快速打开`,onClick:n,className:`shrink-0 rounded-md border border-line bg-surface-2/70 px-1.5 py-0.5 font-mono text-[10px] text-ink-3 hover:text-ink`,children:`Esc`})]}),(0,g.jsx)(Yc,{message:f||(v===o&&y.isError?`搜索文件失败,请修改关键词或重试。`:null),onDismiss:f?()=>p(``):void 0,retry:!f&&v===o&&y.isError?{label:`重试`,run:()=>void y.refetch()}:void 0}),(0,g.jsx)(`div`,{id:_,role:`listbox`,"aria-label":`匹配的文件`,className:B(`max-h-[min(55dvh,420px)] overflow-y-auto`,b.length>0&&`my-2 border-t border-line px-2 pt-2`),children:b.map((e,t)=>(0,g.jsxs)(`button`,{type:`button`,role:`option`,tabIndex:-1,id:`${_}-${t}`,"aria-selected":t===x,"aria-disabled":u,title:e.path,className:B(`flex w-full min-w-0 items-center gap-3 rounded-xl px-3 py-2 text-left`,t===x?`bg-accent-soft text-accent`:`hover:bg-surface-2`),onPointerMove:()=>l(t),onMouseDown:e=>e.preventDefault(),onClick:()=>w(e.path),children:[(0,g.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-[9px] bg-surface-2 text-ink-3`,children:(0,g.jsx)(pW,{path:e.path,size:18})}),(0,g.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,g.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,g.jsx)(`span`,{className:`truncate text-[11px] text-ink-3`,children:e.path.split(`/`).slice(0,-1).join(`/`)||`.`})]}),t===x?(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-ink-3`,children:`↵`}):null]},e.path))}),v&&!f&&(u||v!==o||y.isFetching||y.data?.partial||y.isSuccess&&!b.length)?(0,g.jsx)(`p`,{role:`status`,className:`border-t border-line px-5 py-2.5 text-[11px] text-ink-3`,children:u?`正在打开文件…`:v!==o||y.isFetching?`正在搜索…`:y.data?.partial?`结果受限,请缩小关键词。`:`没有匹配的文件。`}):null]})}var gle=(e,t=220)=>{let[n,r]=(0,h.useState)(e),[i,a]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{if(e){r(!0);let e=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(e)}a(!1);let n=window.setTimeout(()=>r(!1),t);return()=>window.clearTimeout(n)},[e,t]),{mounted:n,visible:i}};function _le({version:e}){let{data:t,isPending:n,isError:r}=sM(),i=vW(e=>e.projectId),a=vW(e=>e.sessionId),o=vW(e=>e.reconcileWorkspace),s=vW(e=>e.sidebarCollapsed),c=vW(e=>e.sidebarWidth),l=vW(e=>e.resourceWidth),u=vW(e=>e.resourceCollapsed),d=vW(e=>e.setSidebarWidth),f=vW(e=>e.setResourceWidth),p=vW(e=>e.mobileSidebarOpen),m=vW(e=>e.toggleSidebar),_=vW(e=>e.setMobileSidebar),v=VK(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(null),C=(0,h.useRef)(null),w=hW(i,a,t.sessions),T=IM(w),E=x===T;x!==null&&!E&&S(null);let D=(0,h.useCallback)(()=>{C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,S(T)},[T]),O=gle(p);return ple(a),(0,h.useEffect)(()=>{let e=e=>{let t=e.detail;b(typeof t==`string`?t:`操作失败`)};return window.addEventListener(`larness:workspace-error`,e),()=>window.removeEventListener(`larness:workspace-error`,e)},[]),(0,h.useEffect)(()=>{n||r||o(t.projects.map(e=>e.id),t.sessions)},[t.projects,t.sessions,n,r,o]),(0,h.useEffect)(()=>{let e=e=>{if(e.defaultPrevented)return;let t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase();if(t&&n===`p`&&!e.shiftKey&&!e.altKey){if(!E&&document.querySelector(`[aria-modal="true"], [role="dialog"][data-state="open"]`))return;e.preventDefault(),!E&&!e.repeat&&D()}else if(!E){if(t&&n===`k`)e.preventDefault(),v();else if(t&&n===`b`)e.preventDefault(),m();else if(e.key===`Escape`&&!t){let t=FM.getState(),n=vW.getState(),r=aM.getQueryData([`workspace`])?.sessions??[],i=gW(n.projectId,n.sessionId,r),a=t.windows.filter(e=>!e.minimized&&kM(e)===i).sort((e,t)=>t.z-e.z)[0];a&&(e.preventDefault(),t.hide(a.id))}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v,D,E,m]),(0,g.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-canvas text-ink`,"data-testid":`workspace-home`,children:[(0,g.jsx)(aJ,{version:e}),(0,g.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,g.jsx)($y,{collapsed:s,width:c,className:`hidden md:flex`,children:(0,g.jsx)(Gq,{})}),(0,g.jsx)(Zq,{side:`left`,label:`调整项目侧栏宽度`,value:c,min:220,max:360,defaultValue:268,onChange:d,collapsed:s,className:`hidden md:block`}),(0,g.jsx)(fle,{}),(0,g.jsx)(Zq,{side:`right`,label:`调整资源侧栏宽度`,value:l,min:280,max:460,defaultValue:340,onChange:f,collapsed:u,className:`hidden xl:block`}),(0,g.jsx)($y,{collapsed:u,width:l,side:`right`,className:`hidden xl:flex`,children:(0,g.jsx)(qW,{onQuickOpen:D})}),(0,g.jsx)(c3,{})]}),(0,g.jsx)(mle,{scope:w,treeWidth:u||window.innerWidth<1280?void 0:l,open:E,close:()=>S(null),restoreFocus:()=>{C.current?.focus({preventScroll:!0}),C.current=null}}),(0,g.jsx)(Yc,{message:y,onDismiss:()=>b(null)}),O.mounted?(0,g.jsxs)(`div`,{className:`fixed inset-0 z-[150] md:hidden`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭导航`,onClick:()=>_(!1),className:B(`absolute inset-0 bg-black/30 backdrop-blur-[2px] transition-opacity duration-200`,O.visible?`opacity-100`:`pointer-events-none opacity-0`)}),(0,g.jsx)(`div`,{className:B(`absolute inset-y-0 left-0 w-[280px] shadow-[var(--shadow-window)] transition-transform duration-200 ease-out`,O.visible?`translate-x-0`:`pointer-events-none -translate-x-full`),children:(0,g.jsx)(Gq,{mobile:!0})})]}):null]})}function vle(){let e=Eh();(0,h.useEffect)(()=>{let t=!1,n,r,i=window.location.protocol===`https:`?`wss`:`ws`,a={queryKey:[`workspace`],exact:!0},o=async()=>{e.getQueryData(a.queryKey)===void 0&&await e.cancelQueries(a),t||await e.invalidateQueries(a)},s=()=>{let a=new WebSocket(`${i}://${window.location.host}/ws`);n=a;let c=!1;a.addEventListener(`open`,()=>{c=!0,a.send(JSON.stringify({type:`subscribe`,subscriptions:[{topic:`system`,resourceId:`system`}]}))}),a.addEventListener(`message`,n=>{if(!(t||typeof n.data!=`string`))try{let t=JSON.parse(n.data);eA.safeParse(t).success&&o(),tA.safeParse(t).success&&e.invalidateQueries({queryKey:[`jobs`]}),nA.safeParse(t).success&&e.invalidateQueries({queryKey:[`memory`]})}catch{}}),a.addEventListener(`close`,()=>{t||(c&&(e.invalidateQueries({queryKey:[`session`]}),e.invalidateQueries({queryKey:[`bootstrap`]})),r=window.setTimeout(s,1e3))}),a.addEventListener(`error`,()=>a.close())};return s(),()=>{t=!0,window.clearTimeout(r),n?.close()}},[e])}function yle({version:e}){return vle(),(0,g.jsx)(_le,{version:e})}function ble({message:e,onRetry:t}){return(0,g.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-canvas px-6 text-ink`,children:(0,g.jsxs)(`section`,{className:`w-full max-w-[420px] rounded-[18px] border border-line bg-surface p-7 shadow-card`,children:[(0,g.jsx)(`h1`,{className:`text-lg font-semibold`,children:`无法连接本机服务`}),(0,g.jsx)(`p`,{className:`mt-2 text-sm text-ink-2`,children:e}),t?(0,g.jsx)(`button`,{type:`button`,className:`mt-5 h-10 rounded-md bg-accent px-4 text-sm font-medium text-accent-ink`,onClick:t,children:`重试`}):null]})})}function xle({children:e,redirectTo:t=`/login`}){let n=YW(),r=Pv();if(n.isPending)return null;if(!n.data){let e=t===`/login`?`/login?returnTo=${encodeURIComponent(r.pathname+r.search)}`:t;return(0,g.jsx)(gy,{to:e,replace:!0})}return(0,g.jsx)(g.Fragment,{children:e})}function Sle(){let e=JW();if(e.isPending)return null;if(e.isError||!e.data)return(0,g.jsx)(ble,{message:e.error instanceof Error?e.error.message:`本机服务未启动`,onRetry:()=>void e.refetch()});let t=e.data.auth,n=window.location.origin===t.passkeyOrigin,r=t.passkeyEnabled&&n&&t.passkeyRegistered?`/login`:`/pair`;return(0,g.jsx)(xle,{redirectTo:r,children:(0,g.jsx)(yle,{version:e.data.app?.version})})}function z9(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function B9(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function V9(){return Cle.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var Cle={stubThis:e=>e};function H9(e){let{id:t}=e;return{...e,id:B9(t),transports:e.transports,type:e.type}}function U9(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var W9=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function wle({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new W9({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new W9({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new W9({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new W9({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new W9({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new W9({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new W9({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new W9({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!U9(t))return new W9({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new W9({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new W9({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new W9({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var G9=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},Tle=[`cross-platform`,`platform`];function K9(e){if(e&&!(Tle.indexOf(e)<0))return e}async function Ele(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!V9())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:B9(t.challenge),user:{...t.user,id:B9(t.user.id)},excludeCredentials:t.excludeCredentials?.map(H9)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=G9.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw wle({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){q9(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=z9(e))}catch(e){q9(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=z9(c.getAuthenticatorData())}catch(e){q9(`getAuthenticatorData()`,e)}return{id:o,rawId:z9(s),response:{attestationObject:z9(c.attestationObject),clientDataJSON:z9(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:K9(a.authenticatorAttachment)}}function q9(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function Dle(){if(!V9())return J9.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?J9.stubThis(new Promise(e=>e(!1))):J9.stubThis(e.isConditionalMediationAvailable())}var J9={stubThis:e=>e};function Ole({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new W9({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new W9({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!U9(t))return new W9({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new W9({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new W9({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function kle(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!V9())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(H9));let a={...t,challenge:B9(t.challenge),allowCredentials:i},o={};if(n){if(!await Dle())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=G9.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Ole({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=z9(u.userHandle)),{id:c,rawId:z9(l),response:{authenticatorData:z9(u.authenticatorData),clientDataJSON:z9(u.clientDataJSON),signature:z9(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:K9(s.authenticatorAttachment)}}function Ale(e){return e===null||!e.startsWith(`/`)||e.startsWith(`//`)||e===`/login`?`/`:e}function Y9(e){if(e instanceof fj){if(e.code===`CHALLENGE_EXPIRED`)return`登录挑战已过期,请重试`;if(e.code===`PASSKEY_AUTH_FAILED`)return`Passkey 登录失败;如果设备已被撤销,请重新配对`;if(e.code===`WEBAUTHN_NOT_CONFIGURED`||e.code===`ORIGIN_INVALID`)return`当前来源不能使用 Passkey,请改用 localhost / HTTPS 或使用配对码`}return e instanceof DOMException&&e.name===`NotAllowedError`?`已取消 Passkey 登录`:pj(e,`登录失败,请重试。`)}function jle(){let[e]=Vy(),t=Ale(e.get(`returnTo`)),n=JW(),r=YW(),i=Eh(),[a,o]=(0,h.useState)(null),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),d=V9(),f=n.data!==void 0&&window.location.origin===n.data.auth.passkeyOrigin,p=n.data?.initialized===!0&&n.data.auth.passkeyEnabled&&f&&d,m=(0,h.useCallback)(async()=>{try{let e=await Y(`/api/webauthn/authentication/options`,{method:`POST`});return o(e),e}catch(e){return u(Y9(e)),null}},[]);if((0,h.useEffect)(()=>{p&&m()},[p,m]),r.data)return(0,g.jsx)(gy,{to:t,replace:!0});let _=async()=>{c(!0),u(null);try{let e=a??await m();if(e===null)return;let t=await kle({optionsJSON:e.options});await Y(`/api/webauthn/authentication/verify`,{method:`POST`,body:{challengeId:e.challengeId,response:t}}),await i.invalidateQueries({queryKey:[`session`]}),await i.invalidateQueries({queryKey:[`bootstrap`]})}catch(e){u(Y9(e)),e instanceof fj&&e.code===`CHALLENGE_EXPIRED`&&(o(null),await m())}finally{c(!1)}};return(0,g.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-canvas px-6 py-10 text-ink`,children:(0,g.jsxs)(`section`,{className:`w-full max-w-[420px] rounded-[18px] border border-line bg-surface p-7 shadow-card`,children:[(0,g.jsxs)(`div`,{className:`mb-6 flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`inline-flex size-7 items-center justify-center rounded-md bg-accent text-[13px] font-semibold text-accent-ink`,children:`L`}),(0,g.jsx)(`span`,{className:`text-[15px] font-semibold tracking-tight`,children:`Larness`}),(0,g.jsx)(`span`,{className:`ml-auto text-xs text-ink-3`,children:n.data?.app.version})]}),(0,g.jsx)(`h1`,{className:`text-lg font-semibold`,children:`使用 Passkey 登录`}),(0,g.jsx)(`p`,{className:`mt-1 text-sm text-ink-2`,children:`使用 Face ID、指纹或系统 PIN 解锁当前工作空间。`}),n.data?null:(0,g.jsx)(`p`,{className:`mt-6 text-sm text-ink-2`,children:n.isError?`无法连接本机服务`:`正在读取工作空间状态…`}),n.data&&!n.data.initialized?(0,g.jsxs)(`p`,{className:`mt-6 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:[`工作空间尚未初始化。请先在本机运行 `,(0,g.jsx)(`code`,{children:`pnpm run tui`}),` 完成初始化。`]}):null,n.data?.initialized===!0&&!f?(0,g.jsxs)(`p`,{className:`mt-6 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:[`当前来源 `,(0,g.jsx)(`code`,{children:window.location.origin}),` 不是 canonical origin`,` `,(0,g.jsx)(`code`,{children:n.data.auth.passkeyOrigin}),`。请改用 localhost 或 HTTPS 域名,或使用下方的“使用配对码”入口。`]}):null,n.data?.initialized===!0&&f&&!d?(0,g.jsx)(`p`,{className:`mt-6 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:`当前浏览器不支持 WebAuthn / Passkey,请使用配对码入口。`}):null,n.data?.initialized===!0&&!n.data.auth.passkeyEnabled?(0,g.jsx)(`p`,{className:`mt-6 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:`WebAuthn 配置无效(RP ID / Origin),Passkey 不可用;请使用配对码入口。`}):null,p?(0,g.jsx)(`button`,{type:`button`,className:`mt-6 flex h-10 w-full items-center justify-center rounded-md bg-accent px-4 text-sm font-medium text-accent-ink transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,disabled:s||a===null,onClick:()=>void _(),children:s?`正在验证…`:a===null?`正在准备…`:`使用 Passkey 登录`}):null,(0,g.jsx)(Yc,{message:l,onDismiss:()=>u(null)}),(0,g.jsxs)(`div`,{className:`mt-5 flex items-center justify-between text-sm`,children:[(0,g.jsx)(Ly,{className:`text-accent hover:underline`,to:`/pair`,children:`使用配对码`}),p&&a===null?(0,g.jsx)(`button`,{type:`button`,className:`text-ink-2 hover:text-ink`,onClick:()=>void m(),children:`重试准备`}):null]})]})})}var X9=`larness.pairing.request`;function Z9(){try{window.sessionStorage.removeItem(X9)}catch{}}function Mle(){try{let e=window.sessionStorage.getItem(X9);if(e===null)return null;let t=JSON.parse(e);return typeof t.requestId==`string`&&typeof t.shortCode==`string`&&typeof t.pollToken==`string`&&typeof t.expiresAt==`number`&&t.expiresAt>Date.now()+1e3?t:(Z9(),null)}catch{return Z9(),null}}function Nle(e){try{window.sessionStorage.setItem(X9,JSON.stringify(e))}catch{}}function Q9(e){if(e instanceof fj){if(e.code===`NOT_INITIALIZED`)return`工作空间尚未初始化。请先在本机运行 pnpm run tui。`;if(e.code===`CODE_INVALID`){let t=e.details?.attemptsLeft;return t===void 0?`配对码不正确`:`配对码不正确,剩余 ${t} 次尝试`}return e.code===`PAIRING_DENIED`?`本机已拒绝本次配对申请`:e.code===`PAIRING_EXPIRED`?`配对申请或配对码已过期,请重新申请`:e.code===`RATE_LIMITED`?`尝试过于频繁,请稍后再试`:e.code===`ENROLLMENT_EXPIRED`?`Passkey 注册窗口已过期,请重新配对`:e.code===`ORIGIN_INVALID`||e.code===`WEBAUTHN_NOT_CONFIGURED`?`当前来源不能注册 Passkey,请改用 localhost / HTTPS,或在 TUI 中选择“允许本次”`:e.code===`PASSKEY_REGISTRATION_FAILED`?`Passkey 注册失败,请重试或重新配对`:e.message}return e instanceof DOMException&&e.name===`NotAllowedError`?`已取消 Passkey 注册`:e instanceof Error?e.message:`操作失败`}function Ple(){let e=YW(),t=Eh(),n=(0,h.useRef)(!1),[r,i]=(0,h.useState)(`creating`),[a,o]=(0,h.useState)(null),[s,c]=(0,h.useState)(null),[l,u]=(0,h.useState)(``),[d,f]=(0,h.useState)(null),[p,m]=(0,h.useState)(null),[_,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(!1),x=V9();(0,h.useEffect)(()=>{e.data&&Z9()},[e.data]);let S=(0,h.useCallback)(async()=>{Z9(),i(`creating`),v(null),o(null),f(null),m(null),c(null),u(``);try{let e=await Y(`/api/pairing/requests`,{method:`POST`,body:{clientLabel:navigator.userAgent.slice(0,100)}});Nle(e),o(e),i(`waiting`)}catch(e){v(Q9(e)),i(`error`)}},[]);(0,h.useEffect)(()=>{if(n.current)return;n.current=!0;let e=Mle();e===null?S():(o(e),i(`waiting`))},[S]),(0,h.useEffect)(()=>{if(r!==`waiting`||a===null)return;let e=!1,n=setInterval(()=>{(async()=>{try{let n=await Y(`/api/pairing/requests/${a.requestId}`,{headers:{"x-pairing-token":a.pollToken}});if(e)return;n.status===`approved`?(c(n.decision),i(`code`)):n.status===`enrollment_pending`?(c(`trust`),i(`enrollment`)):n.status===`denied`?(Z9(),v(`本机已拒绝本次配对申请`),i(`error`)):n.status===`expired`?(Z9(),v(`配对申请已过期,请重新申请`),i(`error`)):n.status===`redeemed`&&(Z9(),await t.invalidateQueries({queryKey:[`session`]}),i(`error`),v(`该申请已完成配对,请返回工作台`))}catch(t){e||(t instanceof fj&&t.code===`NOT_FOUND`&&Z9(),v(Q9(t)),i(`error`))}})()},2e3);return()=>{e=!0,clearInterval(n)}},[r,a,t]);let C=(0,h.useCallback)(async()=>{try{let e=await Y(`/api/webauthn/registration/options`,{method:`POST`});return m(e),e}catch(e){return v(Q9(e)),null}},[]);if((0,h.useEffect)(()=>{r===`enrollment`&&x&&C()},[r,x,C]),e.data)return(0,g.jsx)(gy,{to:`/`,replace:!0});let w=async e=>{if(e.preventDefault(),a!==null){b(!0),v(null);try{let e=await Y(`/api/pairing/redeem`,{method:`POST`,body:{requestId:a.requestId,code:l.trim()}});if(e.status===`session`){Z9(),await t.invalidateQueries({queryKey:[`session`]}),await t.invalidateQueries({queryKey:[`bootstrap`]}),i(`error`),v(`配对成功,正在进入工作台…`),await t.refetchQueries({queryKey:[`session`]});return}f(e),i(`enrollment`)}catch(e){v(Q9(e))}finally{b(!1)}}},T=async()=>{if(p!==null){b(!0),v(null);try{let e=await Ele({optionsJSON:p.options});await Y(`/api/webauthn/registration/verify`,{method:`POST`,body:{challengeId:p.challengeId,response:e}}),Z9(),await t.invalidateQueries({queryKey:[`session`]}),await t.invalidateQueries({queryKey:[`bootstrap`]}),v(`Passkey 已创建,正在进入工作台…`),await t.refetchQueries({queryKey:[`session`]})}catch(e){v(Q9(e)),e instanceof fj&&(e.code===`CHALLENGE_EXPIRED`||e.code===`PASSKEY_REGISTRATION_FAILED`||e.code===`ENROLLMENT_EXPIRED`)&&(m(null),await C())}finally{b(!1)}}};return(0,g.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-canvas px-6 py-10 text-ink`,children:(0,g.jsxs)(`section`,{className:`w-full max-w-[460px] rounded-[18px] border border-line bg-surface p-7 shadow-card`,"data-request-id":a?.requestId??``,"data-stage":r,children:[(0,g.jsxs)(`div`,{className:`mb-6 flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`inline-flex size-7 items-center justify-center rounded-md bg-accent text-[13px] font-semibold text-accent-ink`,children:`L`}),(0,g.jsx)(`span`,{className:`text-[15px] font-semibold tracking-tight`,children:`Larness`})]}),(0,g.jsx)(`h1`,{className:`text-lg font-semibold`,children:`配对这台浏览器`}),(0,g.jsx)(`p`,{className:`mt-1 text-sm text-ink-2`,children:`申请需要在本机 TUI 中批准;配对码只显示一次。`}),r===`creating`?(0,g.jsx)(`p`,{className:`mt-6 text-sm text-ink-2`,children:`正在创建配对申请…`}):null,r===`waiting`&&a?(0,g.jsxs)(`div`,{className:`mt-6`,children:[(0,g.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-ink-3`,children:`短编号`}),(0,g.jsx)(`p`,{className:`mt-1 font-mono text-3xl font-semibold tracking-[0.18em] text-ink`,children:a.shortCode}),(0,g.jsx)(`p`,{className:`mt-3 text-sm text-ink-2`,children:`等待本机 TUI 批准。批准后在此输入一次性配对码。`}),(0,g.jsx)(`button`,{type:`button`,className:`mt-4 text-sm text-accent hover:underline`,onClick:()=>void S(),children:`重新申请`})]}):null,r===`code`&&a?(0,g.jsxs)(`form`,{className:`mt-6`,onSubmit:e=>void w(e),children:[(0,g.jsxs)(`p`,{className:`text-sm text-ink-2`,children:[`已获批准(`,s===`trust`?`始终允许,需要创建 Passkey`:`允许本次`,`)。 请输入 TUI 显示的配对码。`]}),(0,g.jsx)(`label`,{className:`mt-4 block text-xs font-medium text-ink-2`,htmlFor:`pair-code`,children:`配对码`}),(0,g.jsx)(mm,{id:`pair-code`,className:`mt-1 h-11 px-3 font-mono text-lg tracking-[0.14em]`,value:l,onChange:e=>u(e.target.value.toUpperCase()),placeholder:`XXXXX-XXXXX`,autoComplete:`one-time-code`}),(0,g.jsx)(`button`,{type:`submit`,className:`mt-4 flex h-10 w-full items-center justify-center rounded-md bg-accent px-4 text-sm font-medium text-accent-ink transition hover:opacity-90 disabled:opacity-50`,disabled:y||l.trim().length===0,children:y?`正在兑换…`:`兑换配对码`}),(0,g.jsx)(`button`,{type:`button`,className:`mt-3 text-sm text-ink-2 hover:text-ink`,onClick:()=>void S(),children:`重新申请`})]}):null,r===`enrollment`?(0,g.jsxs)(`div`,{className:`mt-6`,children:[(0,g.jsx)(`p`,{className:`text-sm text-ink-2`,children:`配对码已兑换。必须在窗口过期前创建 Passkey,之后才能进入工作台。`}),d===null?(0,g.jsx)(`p`,{className:`mt-2 text-xs text-ink-3`,children:`已恢复同一配对申请的注册窗口。`}):null,x?null:(0,g.jsx)(`p`,{className:`mt-3 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:`当前浏览器不支持 WebAuthn。请重新配对,并在 TUI 中选择“允许本次”。`}),x?(0,g.jsx)(`button`,{type:`button`,className:`mt-4 flex h-10 w-full items-center justify-center rounded-md bg-accent px-4 text-sm font-medium text-accent-ink transition hover:opacity-90 disabled:opacity-50`,disabled:y||p===null,onClick:()=>void T(),children:y?`正在创建…`:p===null?`正在准备…`:`创建 Passkey`}):null,(0,g.jsx)(`button`,{type:`button`,className:`mt-3 text-sm text-ink-2 hover:text-ink`,onClick:()=>void S(),children:`重新配对`})]}):null,r===`error`?(0,g.jsxs)(`div`,{className:`mt-6`,children:[(0,g.jsx)(`button`,{type:`button`,className:`mt-2 flex h-10 w-full items-center justify-center rounded-md bg-accent px-4 text-sm font-medium text-accent-ink transition hover:opacity-90`,onClick:()=>void S(),children:`重新申请`}),(0,g.jsx)(Ly,{className:`mt-3 inline-block text-sm text-ink-2 hover:text-ink`,to:`/login`,children:`返回登录`})]}):null,(0,g.jsx)(Yc,{message:_,onDismiss:()=>v(null)}),a?(0,g.jsxs)(`p`,{className:`mt-5 text-xs text-ink-3`,children:[`申请有效期至 `,new Date(a.expiresAt).toLocaleTimeString(),`;配对码在其他设备上不显示。`]}):null]})})}function Fle(){return XW(),(0,g.jsxs)(yy,{children:[(0,g.jsx)(_y,{path:`/`,element:(0,g.jsx)(Sle,{})}),(0,g.jsx)(_y,{path:`/login`,element:(0,g.jsx)(jle,{})}),(0,g.jsx)(_y,{path:`/pair`,element:(0,g.jsx)(Ple,{})}),(0,g.jsx)(_y,{path:`*`,element:(0,g.jsx)(gy,{to:`/`,replace:!0})})]})}function Ile(){return(0,g.jsx)(Fle,{})}var Lle=c({}),$9=document.getElementById(`root`);if(!$9)throw Error(`Root element not found`);(0,qy.createRoot)($9).render((0,g.jsx)(h.StrictMode,{children:(0,g.jsx)(x,{children:(0,g.jsx)(Dh,{client:aM,children:(0,g.jsx)(Ch,{delayDuration:250,children:(0,g.jsx)(Iy,{children:(0,g.jsx)(Ile,{})})})})})}));export{c as a,f as i,S as n,u as o,m as r,Lle as t};
|
|
157
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Voe(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Q7.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Pse(){return{exit:{taskListCheckValueChecked:t9,taskListCheckValueUnchecked:t9,paragraph:Ise}}}function Fse(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Lse}}}function t9(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Ise(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Lse(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Q7.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Rse(){return[loe(),Aoe(),Poe(),Dse(),Pse()]}function zse(e){return{extensions:[uoe(),joe(e),Foe(),Nse(e),Fse()]}}var Bse={tokenize:Kse,partial:!0},n9={tokenize:qse,partial:!0},r9={tokenize:Jse,partial:!0},i9={tokenize:Yse,partial:!0},Vse={tokenize:Xse,partial:!0},a9={name:`wwwAutolink`,tokenize:Wse,previous:u9},o9={name:`protocolAutolink`,tokenize:Gse,previous:d9},s9={name:`emailAutolink`,tokenize:Use,previous:f9},c9={};function Hse(){return{text:c9}}for(var l9=48;l9<123;)c9[l9]=s9,l9++,l9===58?l9=65:l9===91&&(l9=97);c9[43]=s9,c9[45]=s9,c9[46]=s9,c9[95]=s9,c9[72]=[s9,o9],c9[104]=[s9,o9],c9[87]=[s9,a9],c9[119]=[s9,a9];function Use(e,t,n){let r=this,i,a;return o;function o(t){return!p9(t)||!f9.call(r,r.previous)||m9(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return p9(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Vse,u,l)(t):t===45||t===95||v8(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&_8(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Wse(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!u9.call(r,r.previous)||m9(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Bse,e.attempt(n9,e.attempt(r9,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Gse(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&d9.call(r,r.previous)&&!m9(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(_8(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||b8(t)||T8(t)||O8(t)||D8(t)?n(t):e.attempt(n9,e.attempt(r9,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Kse(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function qse(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(i9,c,s)(t):t===null||T8(t)||O8(t)||t!==45&&D8(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Jse(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(i9,t,a)(o):o===null||T8(o)||O8(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Yse(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||T8(o)||O8(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||T8(e)||O8(e)?t(e):r(e)}function a(e){return _8(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):_8(t)?(e.consume(t),o):n(t)}}function Xse(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return v8(e)?n(e):t(e)}}function u9(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||T8(e)}function d9(e){return!_8(e)}function f9(e){return!(e===47||p9(e))}function p9(e){return e===43||e===45||e===46||e===95||v8(e)}function m9(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Zse={tokenize:ace,partial:!0};function Qse(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:nce,continuation:{tokenize:rce},exit:ice}},text:{91:{name:`gfmFootnoteCall`,tokenize:tce},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:$se,resolveTo:ece}}}}function $se(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=g8(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function ece(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function tce(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||T8(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(g8(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return T8(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function nce(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||T8(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=g8(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return T8(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),j8(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function rce(e,t,n){return e.check(Y8,t,e.attempt(Zse,t,n))}function ice(e){e.exit(`gfmFootnoteDefinition`)}function ace(e,t,n){let r=this;return j8(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function oce(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&l8(o,o.length,0,H8(s,e.slice(r+1,n),t)),l8(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),l8(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=V8(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=V8(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var sce=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){cce(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function cce(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function lce(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function uce(){return{flow:{null:{name:`table`,tokenize:dce,resolveAll:fce}}}}function dce(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):w8(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):E8(t)?j8(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||T8(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,E8(t)?j8(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return E8(t)?j8(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||w8(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return E8(t)?j8(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||w8(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||w8(n)?(e.exit(`tableRow`),t(n)):E8(n)?j8(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||T8(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function fce(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new sce;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(g9(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=h9(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=h9(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=h9(f,t,o,i,n,d)):(o[0]=o[1],d=h9(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&g9(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=lce(t.events,n))}return e}function h9(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},_9(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=_9(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=_9(t.events,n[2]),a=_9(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},_9(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function g9(e,t,n,r,i){let a=[],o=_9(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function _9(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var pce={name:`tasklistCheck`,tokenize:hce};function mce(){return{text:{91:pce}}}function hce(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return T8(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return w8(r)?t(r):E8(r)?e.check({tokenize:gce},t,n)(r):n(r)}}function gce(e,t,n){return j8(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function _ce(e){return f8([Hse(),Qse(),oce(e),uce(),mce()])}var vce={};function yce(e){let t=this,n=e||vce,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(_ce(n)),a.push(Rse()),o.push(zse(n))}var bce={h1:({children:e})=>(0,g.jsx)(`h1`,{className:`mb-2 mt-1 text-[15px] font-medium leading-6 text-ink`,children:e}),h2:({children:e})=>(0,g.jsx)(`h2`,{className:`mb-1.5 mt-3 text-[14px] font-medium leading-5 text-ink`,children:e}),h3:({children:e})=>(0,g.jsx)(`h3`,{className:`mb-1 mt-2.5 text-[13px] font-medium leading-5 text-ink`,children:e}),p:({children:e})=>(0,g.jsx)(`p`,{className:`my-1.5 leading-[1.65] first:mt-0 last:mb-0`,children:e}),strong:({children:e})=>(0,g.jsx)(`strong`,{className:`font-medium text-ink`,children:e}),em:({children:e})=>(0,g.jsx)(`em`,{className:`italic`,children:e}),a:({children:e,href:t})=>(0,g.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent`,children:e}),ul:({children:e})=>(0,g.jsx)(`ul`,{className:`my-1.5 list-disc space-y-0.5 pl-5 marker:text-ink-3`,children:e}),ol:({children:e})=>(0,g.jsx)(`ol`,{className:`my-1.5 list-decimal space-y-0.5 pl-5 marker:text-ink-3`,children:e}),li:({children:e})=>(0,g.jsx)(`li`,{className:`leading-[1.65]`,children:e}),blockquote:({children:e})=>(0,g.jsx)(`blockquote`,{className:`my-2 border-l-2 border-accent/30 pl-3 text-ink-2`,children:e}),hr:()=>(0,g.jsx)(`hr`,{className:`my-3 border-line`}),pre:({children:e})=>(0,g.jsx)(`pre`,{className:`my-2 overflow-x-auto rounded-lg bg-surface-2 px-3 py-2.5 font-mono text-[12px] leading-5 text-ink`,children:e}),code:({children:e,className:t})=>(0,g.jsx)(`code`,{className:t?`font-mono ${t}`:`rounded bg-black/[.06] px-1 py-[1px] font-mono text-[.92em] text-ink dark:bg-white/[.1]`,children:e}),table:({children:e})=>(0,g.jsx)(`div`,{className:`my-2 overscroll-x-contain overflow-x-auto rounded-lg border border-line`,children:(0,g.jsx)(`table`,{className:`w-full min-w-max border-collapse text-left text-[11.5px] [overflow-wrap:anywhere]`,children:e})}),thead:({children:e})=>(0,g.jsx)(`thead`,{className:`bg-surface-2 text-ink-2`,children:e}),th:({children:e,style:t})=>(0,g.jsx)(`th`,{style:t,className:`whitespace-nowrap border-b border-line-strong px-3 py-1.5 font-medium`,children:e}),td:({children:e,style:t})=>(0,g.jsx)(`td`,{style:t,className:`max-w-[320px] border-b border-line/70 px-3 py-1.5 align-middle`,children:e}),tr:({children:e})=>(0,g.jsx)(`tr`,{className:`even:bg-ink/[.04] last:[&>td]:border-b-0`,children:e})};function v9({text:e}){return(0,g.jsx)(`div`,{className:`markdown-body [&_pre_code]:bg-transparent [&_pre_code]:p-0`,children:(0,g.jsx)($ae,{remarkPlugins:[yce],components:bce,children:e})})}var xce=(0,h.lazy)(()=>e(()=>import(`./FileEditor-CxzD-z_w.js`),__vite__mapDeps([6,1,2,3,4,5]))),Sce=6e4;function y9({sessionId:e,target:t,onClose:n}){let[r,i]=(0,h.useState)(null),[a,o]=(0,h.useState)(null),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),d=l===t.id,f=t.kind===`document`&&cb(t.mime),[p,m]=(0,h.useState)({id:t.id,view:`text`}),_=p.id===t.id?p.view:`text`,v=e=>m({id:t.id,view:e}),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(null);return(0,h.useEffect)(()=>{if(t.kind!==`document`||_!==`text`)return;let n=!0;return i(null),o(null),eM(e,t.id).then(e=>{n&&(i(e.markdown),c(e.truncated))}).catch(()=>{n&&o(`无法读取解析结果。`)}),()=>{n=!1}},[e,t.id,t.kind,_]),(0,h.useEffect)(()=>{if(!f||_!==`source`)return;let n=!0;return b(null),S(null),qee(e,t.id,{maxChars:Sce}).then(e=>{n&&b({content:e.content,lineStart:e.lineStart,lineEnd:e.lineEnd,totalLines:e.totalLines,truncated:e.truncated})}).catch(()=>{n&&S(`无法读取原始文件。`)}),()=>{n=!1}},[e,t.id,f,_]),(0,h.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,g.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`附件预览:${t.filename}`,className:`fixed inset-0 z-[340] flex items-center justify-center bg-black/45 p-4`,children:(0,g.jsxs)(`div`,{className:`flex max-h-[86vh] w-full max-w-4xl flex-col overflow-hidden rounded-xl border border-line bg-surface shadow-[var(--shadow-card)]`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2`,children:[(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px] text-ink`,children:t.filename}),f?(0,g.jsx)(`div`,{role:`tablist`,"aria-label":`预览视图`,className:`flex items-center gap-0.5 rounded-full bg-surface-2/60 p-0.5`,children:[[`text`,`解析视图`],[`source`,`原文`]].map(([e,t])=>(0,g.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":_===e,onClick:()=>v(e),className:`rounded-full px-2 py-0.5 text-[11px] ${_===e?`bg-surface text-ink shadow-[var(--shadow-card)]`:`text-ink-3 hover:text-ink`}`,children:t},e))}):null,t.kind===`document`?(0,g.jsx)(`a`,{href:Yj(e,t.id),download:t.filename,className:`text-[11px] text-accent hover:underline`,children:`下载`}):null,(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:n,className:`rounded p-1 text-ink-3 hover:bg-surface-2`,children:(0,g.jsx)(Ac,{size:14})})]}),(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:t.kind===`image`?d?(0,g.jsx)(`p`,{role:`status`,className:`text-[12px] text-danger`,children:`无法加载原图,文件可能已被删除。`}):(0,g.jsx)(`img`,{src:Yj(e,t.id),alt:t.filename,className:`mx-auto max-h-[70vh] max-w-full object-contain`,onError:()=>u(t.id)}):_===`source`?(0,g.jsx)(Cce,{identity:t.id,filename:t.filename,source:y,error:x}):a===null?r===null?(0,g.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-[12px] text-ink-3`,children:[(0,g.jsx)(ps,{size:13,className:`animate-spin motion-reduce:animate-none`}),` `,`读取解析结果…`]}):r.length===0?(0,g.jsx)(`p`,{role:`status`,className:`text-[12px] text-ink-3`,children:`该附件没有可预览的文本。`}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(v9,{text:r}),s?(0,g.jsx)(`p`,{className:`mt-3 text-[11px] text-ink-3`,children:`预览已截断,完整内容可由 Agent 分页读取。`}):null]}):(0,g.jsx)(`p`,{role:`status`,className:`text-[12px] text-danger`,children:a})})]})})}function Cce({identity:e,filename:t,source:n,error:r}){return r===null?n===null?(0,g.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-[12px] text-ink-3`,children:[(0,g.jsx)(ps,{size:13,className:`animate-spin motion-reduce:animate-none`}),` 读取原始文件…`]}):(0,g.jsxs)(`div`,{className:`flex h-[68vh] flex-col gap-2`,children:[(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-md border border-line`,children:(0,g.jsx)(h.Suspense,{fallback:(0,g.jsx)(`p`,{className:`p-3 text-[12px] text-ink-3`,children:`加载编辑器…`}),children:(0,g.jsx)(xce,{identity:`attachment:${e}`,path:t,text:n.content,readOnly:!0,onChange:()=>void 0})})}),(0,g.jsxs)(`p`,{className:`text-[11px] text-ink-3`,children:[`第 `,n.lineStart,`–`,n.lineEnd,` 行 · 共 `,n.totalLines,` 行`,n.truncated?` · 预览已截断,完整内容可由 Agent 分页读取`:``]})]}):(0,g.jsx)(`p`,{role:`status`,className:`text-[12px] text-danger`,children:r})}var b9=`inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border border-line/80 bg-surface-2/55 px-2 text-[11px] text-ink-2`,wce=`transition-colors hover:border-accent/35 hover:bg-accent-soft/30 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:pointer-events-none disabled:opacity-55`,Tce={none:`原图`,native:`文本`,"text-layer":`文本层`,ocr:`OCR`,vision:`视觉转写`},Ece={ATTACHMENT_TOO_LARGE:`文件过大`,ATTACHMENT_UNSUPPORTED:`格式不支持`,ATTACHMENT_LIMIT:`附件已满`,ATTACHMENT_PARSE_FAILED:`无法解析`,ATTACHMENT_PARSE_TIMEOUT:`解析超时`,ATTACHMENT_ENCRYPTED:`文件已加密`,ATTACHMENT_PDF_NO_TEXT:`PDF 无可提取文本`,ATTACHMENT_VISION_UNAVAILABLE:`当前模型不支持图片`,ATTACHMENT_NOT_READY:`仍在解析`,ATTACHMENT_STORAGE_FAILED:`存储不可用`};function Dce(e){return[e.status===`uploading`||e.status===`pending`?`解析中`:null,e.status===`failed`?e.errorCode?Ece[e.errorCode]??`解析失败`:`解析失败`:null,e.pageCount?`${e.pageCount} 页`:null,e.method&&e.method!==`none`?Tce[e.method]:null,e.warningCount?`${e.warningCount} 条警告`:null].filter(Boolean).join(` · `)}function x9({item:e,disabled:t=!1,onRemove:n,onOpen:r}){let i=e.status===`uploading`||e.status===`pending`,a=e.status===`failed`,o=Dce(e);return(0,g.jsxs)(`div`,{className:B(b9,`shrink-0 gap-1 pr-1.5 pl-2 text-left`,a?`border-danger/35 bg-danger/5`:e.status===`ready`&&r?`hover:border-accent/35 hover:bg-accent-soft/30`:null),title:o.length>0?`${e.filename} · ${o}`:e.filename,"data-testid":`attachment-chip`,children:[i?(0,g.jsx)(ps,{size:11,"aria-hidden":`true`,className:`shrink-0 animate-spin text-ink-3 motion-reduce:animate-none`}):(0,g.jsx)(pW,{path:e.filename,size:13}),(0,g.jsx)(`button`,{type:`button`,onClick:r,disabled:e.status!==`ready`||r===void 0,className:`min-w-0 max-w-[180px] truncate text-left text-[11px] text-ink-2 enabled:hover:text-ink disabled:cursor-default`,children:e.filename}),a?(0,g.jsx)(Cc,{size:10,"aria-hidden":`true`,className:B(`shrink-0 text-danger`,n?null:`mr-0.5`)}):null,o.length>0?(0,g.jsx)(`span`,{className:`sr-only`,children:o}):null,n?(0,g.jsx)(`button`,{type:`button`,onClick:n,disabled:t,"aria-label":`移除 ${e.filename}`,className:`shrink-0 rounded-full p-0.5 text-ink-3 hover:bg-surface-3 hover:text-ink disabled:opacity-40`,children:(0,g.jsx)(Ac,{size:10})}):null]})}function Oce({items:e,disabled:t=!1,onRemove:n,onRetry:r,onPreview:i}){return e.length===0?null:(0,g.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pt-3`,"data-testid":`attachment-tray`,children:e.map(e=>(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(x9,{item:{id:e.attachment?.id,filename:e.file.name,kind:e.attachment?.kind??(e.file.type.startsWith(`image/`)?`image`:`document`),status:e.status,method:e.attachment?.method,pageCount:e.attachment?.pageCount,warningCount:e.attachment?.warnings.length,errorCode:e.errorCode??e.attachment?.errorCode},disabled:t,onRemove:()=>n(e.key),onOpen:()=>i?.(e)}),e.status===`failed`&&r?(0,g.jsx)(`button`,{type:`button`,onClick:()=>r(e.key),className:`text-[11px] text-accent hover:underline`,children:`重试`}):null]},e.key))})}var S9=`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-[11.5px] text-ink-2 outline-none hover:bg-surface-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/40 disabled:opacity-50`;function kce({groups:e,model:t,credentialProfileId:n,thinking:r,catalogError:i,disabled:a,onSelectModel:o,onSelectThinking:s}){let c=(0,h.useId)(),l=(0,h.useRef)(null),u=(0,h.useRef)(null),d=(0,h.useRef)(null),[f,p]=(0,h.useState)(!1),[m,_]=(0,h.useState)(`root`),v=t?.thinking.mode,y=t?.thinking.supported?v===`toggle`?[{id:`off`,label:`关闭`},{id:`on`,label:`开启`}]:[...v===`mandatory-levels`||v===`variants`?[]:[{id:`off`,label:`关闭`}],...t.thinking.levels]:[],b=y.find(e=>e.id===r)?.label;(0,h.useEffect)(()=>{if(!f)return;d.current?.focus();let e=e=>{e.target instanceof Node&&!l.current?.contains(e.target)&&p(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[f]);let x=()=>{p(!1),u.current?.focus()},S=e=>{d.current?.focus(),_(e)};return(0,g.jsxs)(`div`,{ref:l,className:`relative min-w-0`,children:[(0,g.jsxs)(`button`,{ref:u,type:`button`,"aria-label":`模型与思考:${t?.label??`选择模型`}${b?` · ${b}`:``}`,"aria-haspopup":`dialog`,"aria-expanded":f&&!a,"aria-controls":f&&!a?c:void 0,disabled:a,onClick:()=>{_(`root`),p(!f)},className:`flex h-7 min-w-0 items-center gap-1.5 rounded-lg px-1.5 text-[11px] font-medium text-ink-2 transition-colors hover:bg-surface-2 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[(0,g.jsx)(`span`,{className:`max-w-[96px] truncate sm:max-w-[144px]`,children:t?.label??`选择模型`}),b?(0,g.jsxs)(`span`,{className:B(`shrink-0 text-[10px] font-semibold`,r===`off`||r===`effort:none`?`text-ink-3`:`text-accent`),children:[(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1 text-ink-3`,children:`·`}),b]}):null,(0,g.jsx)(Xa,{size:11,"aria-hidden":`true`,className:`shrink-0 text-ink-3`})]}),f&&!a?(0,g.jsx)(`div`,{ref:d,id:c,role:`dialog`,"aria-label":`模型与思考`,tabIndex:-1,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),x())},className:`absolute bottom-[calc(100%+8px)] left-0 z-40 flex max-h-[min(360px,55dvh)] w-[min(240px,calc(100vw-68px))] flex-col overflow-hidden rounded-xl border border-line bg-surface/95 p-1.5 text-ink shadow-[var(--shadow-pop)] outline-none backdrop-blur-xl`,children:m===`root`?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`button`,{type:`button`,"aria-label":`模型:${t?.label??`选择模型`}`,onClick:()=>S(`models`),className:S9,children:[(0,g.jsx)(`span`,{className:`w-14 shrink-0 text-[10px] text-ink-3`,children:`模型`}),(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-ink`,children:t?.label??`选择模型`}),(0,g.jsx)(eo,{size:11,"aria-hidden":`true`,className:`text-ink-3`})]}),(0,g.jsxs)(`button`,{type:`button`,"aria-label":`思考强度:${b??`不支持`}`,disabled:y.length===0,onClick:()=>S(`thinking`),className:S9,children:[(0,g.jsx)(`span`,{className:`w-14 shrink-0 text-[10px] text-ink-3`,children:`思考强度`}),(0,g.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate`,b&&r!==`off`&&r!==`effort:none`&&`text-accent`),children:b??`不支持`}),y.length>0?(0,g.jsx)(eo,{size:11,"aria-hidden":`true`,className:`text-ink-3`}):null]})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-1 pb-1 pt-0.5`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":`返回`,onClick:()=>S(`root`),className:`grid size-5 place-items-center rounded-md text-ink-3 outline-none hover:bg-surface-2 focus-visible:ring-2 focus-visible:ring-accent/40`,children:(0,g.jsx)(Qa,{size:12,"aria-hidden":`true`})}),(0,g.jsx)(`span`,{className:`text-[10.5px] font-semibold text-ink-3`,children:m===`models`?`模型`:`思考强度`})]}),(0,g.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain`,children:m===`models`?(0,g.jsxs)(g.Fragment,{children:[e.length===0?(0,g.jsx)(`p`,{className:`px-2 py-2 text-[11px] text-ink-3`,children:i?`目录不可用,请在模型设置中刷新。`:`请先在模型设置中添加 Key。`}):null,e.map(e=>{let r=`${c}-${e.credentialProfileId}`;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{id:r,className:`truncate px-2.5 pb-0.5 pt-1.5 text-[10px] text-ink-3`,children:e.credentialLabel}),(0,g.jsxs)(`ul`,{"aria-labelledby":r,children:[e.models.length===0?(0,g.jsx)(`li`,{className:`px-2.5 py-1.5 text-[10.5px] text-ink-3`,children:e.lastRefreshError?`目录读取失败,请在设置中刷新。`:`此 Key 暂无可选模型`}):null,e.models.map(r=>{let i=r.id===t?.id&&e.credentialProfileId===n;return(0,g.jsx)(`li`,{children:(0,g.jsxs)(`button`,{type:`button`,"aria-label":r.label,"aria-pressed":i,onClick:()=>{x(),o(r.id,e.credentialProfileId)},className:B(S9,i&&`bg-surface-2 text-ink`),children:[(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label}),(0,g.jsx)(`span`,{className:`text-[9.5px] text-ink-3`,children:tK(r)}),i?(0,g.jsx)(Ja,{size:13,"aria-hidden":`true`,className:`shrink-0 text-accent`}):null]})},r.id)})]})]},e.credentialProfileId)})]}):y.map(e=>(0,g.jsxs)(`button`,{type:`button`,"aria-pressed":e.id===r,onClick:()=>{x(),e.id!==r&&s(e.id)},className:B(S9,e.id===r&&`bg-surface-2 text-ink`),children:[(0,g.jsx)(`span`,{className:`flex-1`,children:e.label}),e.id===r?(0,g.jsx)(Ja,{size:13,"aria-hidden":`true`,className:`shrink-0 text-accent`}):null]},e.id))})]})}):null]})}function C9(e){if(e<1e3)return String(e);if(e<1e5){let t=(e/1e3).toFixed(1);return`${t.endsWith(`.0`)?t.slice(0,-2):t}k`}if(e<1e6)return`${Math.round(e/1e3)}k`;let t=(e/1e6).toFixed(2);return`${t.endsWith(`.00`)?t.slice(0,-3):t.endsWith(`0`)?t.slice(0,-1):t}M`}function Ace(e,t){return e===void 0||t===void 0||e<=0||t<=0?null:Math.round(e/(t/1e3))}function jce(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}function Mce(e,t){if(e!==null&&t!==null&&Number.isFinite(e)&&e>=0&&Number.isFinite(t)&&t>0){let n=Math.min(100,Math.max(0,Math.round(e/t*100)));return{known:!0,percent:n,text:`本轮 ${C9(e)} / ${C9(t)} · ${n}%`,detail:`本轮请求输入:${e.toLocaleString()} / ${t.toLocaleString()} tokens(${n}%)`}}return{known:!1,percent:0,text:`暂无统计`,detail:t!==null&&Number.isFinite(t)&&t>0?`暂无统计 · 模型窗口 ${t.toLocaleString()} tokens`:`暂无统计 · 模型窗口未知`}}function w9({used:e,limit:t}){let n=Mce(e,t);return(0,g.jsx)(wh,{label:n.detail,side:`top`,children:(0,g.jsxs)(`div`,{role:`progressbar`,"aria-label":`上下文用量`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n.known?n.percent:void 0,"aria-valuetext":n.detail,className:`flex shrink-0 items-center gap-1`,children:[(0,g.jsxs)(`svg`,{"aria-hidden":`true`,width:`14`,height:`14`,viewBox:`0 0 20 20`,className:`-rotate-90`,fill:`none`,children:[(0,g.jsx)(`circle`,{cx:`10`,cy:`10`,r:`7`,stroke:`currentColor`,strokeWidth:`2`,className:`text-line-strong`}),n.known?(0,g.jsx)(`circle`,{cx:`10`,cy:`10`,r:`7`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`100`,strokeDashoffset:100-n.percent,className:B(`transition-[stroke-dashoffset] duration-150 motion-reduce:transition-none`,n.percent>=90?`text-danger`:n.percent>=75?`text-warning`:`text-accent`)}):null]}),(0,g.jsx)(`span`,{className:`tabular-nums`,children:n.text})]})})}function T9({children:e}){return(0,g.jsx)(`div`,{role:`status`,"aria-label":`会话用量`,className:`mt-1 flex min-h-[16px] flex-wrap items-center gap-1 px-1 text-[10.5px] text-ink-3`,children:e})}function Nce({usage:e,streaming:t,lastStep:n,contextUsage:r}){if(e===null)return(0,g.jsxs)(T9,{children:[(0,g.jsx)(`span`,{children:`Token 统计加载中…`}),(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsx)(w9,{...r})]});if(e===void 0)return(0,g.jsxs)(T9,{children:[(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsx)(w9,{...r})]});let i=e.partial,a=`${i?`≥ `:``}${C9(e.totalTokens)} tokens`,o=e.cache.hitRate===null?null:Math.round(e.cache.hitRate*100),s=e.cache.knownRequests>0?[`缓存命中 ${C9(e.cache.readTokens)} tokens`,`未命中 ${C9(e.cache.missTokens)} tokens`,...e.cache.unknownRequests>0?[`未知 ${e.cache.unknownRequests} 次请求`]:[]].join(` · `):e.cache.unknownRequests>0?`缓存未知 · ${e.cache.unknownRequests} 次请求未回报缓存字段`:null,c=[`输入 ${C9(e.inputTokens)}`,`输出 ${C9(e.outputTokens)}`,...s===null?[]:[s],...i?[`缺失 ${e.missingTurns} 轮`]:[]].join(` · `),l=n===null?null:Ace(n.outputTokens,n.durationMs);return(0,g.jsxs)(T9,{children:[(0,g.jsx)(wh,{label:c,side:`top`,children:(0,g.jsx)(`span`,{className:`tabular-nums`,children:a})}),o===null?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,g.jsx)(wh,{label:s??`缓存命中率`,side:`top`,children:(0,g.jsxs)(`span`,{className:`tabular-nums`,children:[`缓存命中 `,o,`%`]})})]}),t&&l!==null&&n!==null?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,g.jsx)(wh,{label:`最后一步输出 ${C9(n.outputTokens)} tokens · ${jce(n.durationMs)}`,side:`top`,children:(0,g.jsxs)(`span`,{className:`tabular-nums`,children:[l,` tok/s`]})})]}):null,(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsx)(w9,{...r})]})}var E9={id:`standard`,label:`标准审批`,detail:`L0/L1 自动,L2 询问`,icon:ac,tone:`text-accent`},D9=[{id:`readonly`,label:`只读`,detail:`禁止修改与执行`,icon:lc,tone:`text-success`},{id:`strict`,label:`严格审批`,detail:`所有写入都询问`,icon:sc,tone:`text-warning`},E9,{id:`autonomous`,label:`完全自主`,detail:`所有工具免人工审批`,icon:sc,tone:`text-danger`}],O9=[{id:`coding`,label:`Coding`,detail:`快速完成编程任务`,icon:_o},{id:`plan`,label:`Plan`,detail:`按需创建任务计划完成`,icon:ds}];function k9(e){if(!e.thinking.supported)return`off`;if(e.thinking.mode===`toggle`)return`on`;if(e.thinking.defaultLevel)return e.thinking.defaultLevel;let t=e.thinking.mode===`mandatory-levels`?`high`:`medium`;return e.thinking.levels.find(e=>e.id===t)?.id??e.thinking.levels[0]?.id??`off`}function A9(e,t){if(!e.thinking.supported)return t===`off`;let n=e.thinking.mode??`levels`;return n===`toggle`?t===`off`||t===`on`:n===`variants`?e.thinking.levels.some(e=>e.id===t):n!==`mandatory-levels`&&t===`off`||e.thinking.levels.some(e=>e.id===t)}function Pce({centered:e=!1,onSubmit:t}){let[n,r]=(0,h.useState)(),[i,a]=(0,h.useState)(``),[o,s]=(0,h.useState)(null),[c,l]=(0,h.useState)(null),u=(0,h.useRef)(null),d=(0,h.useRef)(new Set),[f,p]=(0,h.useState)(null),[m,_]=(0,h.useState)(),[v,y]=(0,h.useState)(),[b,x]=(0,h.useState)(null),[S,C]=(0,h.useState)(null),[w,T]=(0,h.useState)(),{catalog:E,error:D}=dte(),O=yW(e=>e.draft),k=yW(e=>e.setDraft),A=Uq(e=>e.isStreaming),j=Uq(e=>e.activeTurnId),M=Uq(e=>e.send),N=Uq(e=>e.stop),ee=vW(e=>e.focusComposerNonce),te=(0,h.useRef)(null),P=vW(e=>e.sessionId),F=!!P,ne=vW(e=>e.draftSession),I=ne?.id===P,re=mte(F&&!I?P:null),ie=I||re?.id===P,ae=re?.approvalPolicyId??(m?.sessionId===P?m.value:E9.id),oe=re?.agentProfile??(v?.sessionId===P?v.value:`coding`),se=Qg({mutationKey:uM(P)},aM)>0,ce=!F||!ie||se||A&&!j,le=f!==null&&f===P,ue=t_({mutationKey:uM(P),mutationFn:async({id:e,patch:t})=>{let n=cM(e);await aM.cancelQueries({queryKey:n});let r=await Bj(e,t);await aM.cancelQueries({queryKey:n}),aM.setQueryData(n,e=>e?{...e,...r}:{...r,activeTurn:null})}},aM),de=E?.groups??(E?[E]:[]),L=de.map(e=>({...e,models:e.models.filter(e=>e.visible!==!1&&(e.agentSelectable??e.contextWindow!==null))})),fe=de.flatMap(e=>e.models.map(t=>({group:e,model:t}))),pe=fe.filter(({model:e})=>e.visible!==!1&&(e.agentSelectable??e.contextWindow!==null)),me=I?ne.selection:re,he=e=>fe.find(({group:t,model:n})=>n.id===e.model&&(e.credentialProfileId==null||e.credentialProfileId===t.credentialProfileId)),ge=me?he(me):void 0,_e=E?.defaultSelection?he(E.defaultSelection):void 0,ve=_e?.model.visible===!1?void 0:_e,ye=!!(me?.model&&me?.credentialProfileId&&!ge),be=ge??(ye?void 0:ve??pe[0]),xe=ie?be?.model:void 0,Se=be?.group.credentialProfileId??null,Ce=ge?me?.thinking:ve?E?.defaultSelection?.thinking:null,we=Ce==="default"?`medium`:Ce,Te=xe&&we&&A9(xe,we)?we:xe?k9(xe):`off`,Ee=fM(),De=Ee.data.activeConnectionId!==null&&Ee.data.connections.some(e=>e.id===Ee.data.activeConnectionId),Oe=I?ne?.webSearchEnabled??!1:re?.webSearchEnabled??!1,ke=Oe&&De,Ae=F&&xe!==void 0&&(xe.agentSelectable??xe.contextWindow!==null)&&!se&&!A,je=n?.sessionId===P?n.items:[],Me=je.map(e=>e.file),Ne=xe?.capabilities?.inputModalities?.includes(`image`)===!0,Pe=!I&&!Ne&&je.some(e=>e.file.type.startsWith(`image/`)&&e.status===`ready`&&e.attachment?.method!==`ocr`&&e.attachment?.method!==`vision`),Fe=je.some(e=>e.status===`uploading`||e.status===`pending`),Ie=je.some(e=>e.status===`failed`),Le=(0,h.useCallback)(async(e,t)=>{if(P&&!d.current.has(e)){d.current.add(e);try{let n=await Qj(P,t);r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:n.status,attachment:n,errorCode:n.errorCode}:t)}:t)}catch(t){let n=t instanceof fj?t.code:`ATTACHMENT_VISION_UNAVAILABLE`;r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:`failed`,errorCode:n}:t)}:t),s({message:`图片需要视觉模型或本地 OCR 才能发送。`,tone:`error`})}finally{d.current.delete(e)}}},[P]),Re=async(e,t)=>{if(P&&!I)try{let n=await Zj(P,t);r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:n.attachment.status,attachment:n.attachment,errorCode:n.attachment.errorCode}:t)}:t),n.attachment.status===`failed`&&s({message:`附件解析失败,可重试或移除。`,tone:`error`}),n.attachment.kind===`image`&&n.attachment.status===`ready`&&n.attachment.method===`none`&&!Ne&&Le(e,n.attachment.id)}catch(t){r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:`failed`}:t)}:t),s({message:t instanceof Error?t.message:`附件上传失败`,tone:`error`})}},ze=e=>{if(!F||!P||A||e.length===0)return;let t=n?.sessionId===P?n.items:[],i=8-t.length;if(i<=0){s({message:`每轮最多添加 8 个附件。`,tone:`error`});return}let o=e.slice(0,i),c=o.map(e=>({file:e,reason:_b(e.name,e.size)})).find(e=>e.reason!==null);if(c!==void 0&&c.reason!==null){s({message:c.reason===`secret`?`${c.file.name} 可能是凭据文件,附件不接收密钥或证书。`:c.reason===`size`?`${c.file.name} 超过 ${gb/1024/1024} MiB 上限。`:`不支持 ${c.file.name}(代码/配置/文档/图片,最大 20 MiB)。`,tone:`error`});return}let l=o.map(e=>({key:`${e.name}:${e.lastModified}:${Math.random().toString(36).slice(2,7)}`,file:e,status:I?`ready`:`uploading`}));if(r({sessionId:P,items:[...t,...l]}),a(``),!I)for(let e of l)Re(e.key,e.file)},Be=e=>{r(t=>t?.sessionId===P?{...t,items:t.items.filter(t=>t.key!==e)}:t)},Ve=e=>{let t=je.find(t=>t.key===e);t&&(r(t=>t?.sessionId===P?{...t,items:t.items.map(t=>t.key===e?{...t,status:`uploading`}:t)}:t),Re(e,t.file))},R=D9.find(e=>e.id===ae)??E9,He=R.icon,Ue=O9.find(e=>e.id===oe)??O9[0],We=Ue.icon,Ge=Uq(e=>e.modelUsage),Ke=xe?Ge[xe.id]:void 0,qe=fte(F&&!I?P:null),Je=F&&!I&&(Ke!==void 0||(qe?.turns??0)>0),z=Ke?.contextWindow??xe?.contextWindow??null,Ye=Ke?.outputTokens!==void 0&&Ke.durationMs!==void 0?{outputTokens:Ke.outputTokens,durationMs:Ke.durationMs}:null,Xe=Uq(e=>d3(e.items).length>0);(0,h.useEffect)(()=>vW.subscribe((e,t)=>{e.sessionId!==t.sessionId&&p(null)}),[]),(0,h.useEffect)(()=>{ee>0&&te.current?.focus()},[ee]),(0,h.useEffect)(()=>{if(!(I||Ne||!P))for(let e of je)e.file.type.startsWith(`image/`)&&e.status===`ready`&&e.attachment?.method===`none`&&Le(e.key,e.attachment.id)},[Ne,I,P,je,Le]),(0,h.useEffect)(()=>{if(b===null)return;let e=setTimeout(()=>x(null),4e3);return()=>clearTimeout(e)},[b]),(0,h.useEffect)(()=>{let e=te.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(180,Math.max(48,e.scrollHeight))}px`)},[O]);let Ze=async(e,t)=>{if(!ce){C(null),x(null);try{I?vW.getState().setDraftModel(P,e):await ue.mutateAsync({id:P,patch:e}),t&&vW.getState().sessionId===P&&x({sessionId:P,message:`已切换到 ${t}`})}catch(e){C({sessionId:P,message:pj(e,`模型选择保存失败,请重试。`)})}}},Qe=(e,t)=>{let n=pe.find(({group:n,model:r})=>r.id===e&&n.credentialProfileId===t);n&&Ze({model:e,credentialProfileId:t,thinking:A9(n.model,Te)?Te:k9(n.model)},n.model.label)},$e=async e=>{if(!(ce||e===oe)){if(C(null),I)y({sessionId:P,value:e});else try{await ue.mutateAsync({id:P,patch:{agentProfile:e}})}catch(e){C({sessionId:P,message:pj(e,`Agent Profile 保存失败,请重试。`)})}}},et=async e=>{if(!(ce||e===ae)){if(C(null),I)_({sessionId:P,value:e});else try{await ue.mutateAsync({id:P,patch:{approvalPolicyId:e}})}catch(e){C({sessionId:P,message:pj(e,`审批策略保存失败,请重试。`)})}}},tt=async()=>{if(F&&!ce&&De){if(C(null),x(null),I){let e=!Oe;vW.getState().setDraftWebSearch(P,e),x({sessionId:P,message:e?`已开启联网搜索`:`已关闭联网搜索`})}else try{await ue.mutateAsync({id:P,patch:{webSearchEnabled:!Oe}}),x({sessionId:P,message:Oe?`已关闭联网搜索`:`已开启联网搜索,下一轮生效`})}catch(e){C({sessionId:P,message:pj(e,`联网搜索开关保存失败,请重试。`)})}}},nt=()=>{if(!Ae||!xe||!Se||Xe||Pe||Fe||Ie)return;let e=O.trim();if(!e&&Me.length===0)return;t?.();let n={model:xe.id,credentialProfileId:Se,thinking:Te},i=I?ae:void 0,a=I?oe:void 0,o=I&&Oe&&De?!0:void 0;Me.length===0?M(e,n,i,a,o):M(e,n,i,a,o,Me,()=>{r(e=>e?.sessionId===P?void 0:e),vW.getState().sessionId===P&&yW.getState().draft===O&&k(``)},Ne),Me.length===0&&k(``),requestAnimationFrame(()=>te.current?.focus())};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{"data-testid":`composer-surface`,className:B(`relative rounded-[18px] border border-line shadow-[var(--shadow-card)] transition-[border-color,box-shadow] focus-within:border-accent/35 focus-within:ring-2 focus-within:ring-accent/10`,e?`bg-surface/40 backdrop-blur-sm`:`bg-surface`),children:[b?.sessionId===P?(0,g.jsx)(`p`,{role:`status`,className:`pointer-events-none absolute bottom-full left-2 mb-1 w-fit max-w-[calc(100%-1rem)] truncate rounded-md bg-surface/90 px-2 py-0.5 text-[10.5px] text-ink-3`,children:b.message}):null,(0,g.jsx)(Yc,{message:S?.sessionId===P?S.message:null,onDismiss:()=>C(null)}),je.length>0?(0,g.jsx)(Oce,{items:je,disabled:A,onRemove:Be,onRetry:Ve,onPreview:e=>e.attachment?l({id:e.attachment.id,filename:e.attachment.filename,kind:e.attachment.kind,mime:e.attachment.mime}):void 0}):null,i||Pe?(0,g.jsx)(`p`,{role:`status`,className:`px-3 pt-2 text-xs text-warning`,children:i||`当前模型连接未声明图片输入。请切换模型、启用 OCR 或移除图片。`}):null,(0,g.jsx)(`input`,{ref:u,type:`file`,accept:hb,multiple:!0,className:`hidden`,onChange:e=>{ze([...e.target.files??[]]),e.target.value=``}}),(0,g.jsx)(Hc,{message:o?.message??null,tone:o?.tone,onDismiss:()=>s(null)}),c?(0,g.jsx)(y9,{sessionId:P,target:c,onClose:()=>l(null)}):null,(0,g.jsx)(hm,{variant:`bare`,ref:te,value:O,rows:1,placeholder:F?e?`提问、描述要做的改动…`:`继续对话,或提出新的任务…`:`新建或选择一个会话…`,onPaste:e=>{let t=[...e.clipboardData.files];t.length>0&&(e.preventDefault(),ze(t))},onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.files.length&&(e.preventDefault(),ze([...e.dataTransfer.files]))},"aria-label":`对话输入`,onChange:e=>k(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey){if(e.nativeEvent.isComposing)return;e.preventDefault(),A||nt()}},className:`block max-h-[180px] min-h-[48px] w-full resize-none bg-transparent px-3.5 pt-3 text-[13px] leading-[1.65] text-ink outline-none placeholder:text-ink-3 focus:outline-none focus-visible:outline-none`}),(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 pb-2 pt-1`,children:[(0,g.jsx)(vm,{label:De?ke?`联网搜索:已开启`:`联网搜索:已关闭`:`联网搜索:未配置`,active:ke,"aria-pressed":ke,title:De?Oe?`关闭联网搜索`:`开启联网搜索`:`请先在左侧「联网搜索」添加搜索 Key`,disabled:!F||ce||!De,onClick:()=>void tt(),className:`h-7 w-7`,children:(0,g.jsx)($o,{size:15,"aria-hidden":`true`})}),(0,g.jsx)(kce,{groups:L,model:xe,credentialProfileId:Se,thinking:Te,catalogError:D,disabled:ce,onSelectModel:Qe,onSelectThinking:e=>{xe&&Se&&Ze({model:xe.id,credentialProfileId:Se,thinking:e})}},P),(0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsx)(vm,{disabled:ce,label:`Agent Profile:${Ue.label}`,title:`${Ue.label} · ${Ue.detail}`,className:`h-7 w-7`,children:(0,g.jsx)(We,{size:15,className:`text-accent`,"aria-hidden":`true`})})}),(0,g.jsxs)(sm,{align:`start`,className:`w-[230px]`,children:[(0,g.jsx)(cm,{children:`Agent Profile`}),(0,g.jsx)(om,{value:oe,onValueChange:e=>void $e(e),children:O9.map(e=>(0,g.jsx)(um,{value:e.id,className:`items-start py-2`,children:(0,g.jsxs)(`span`,{className:`flex flex-col`,children:[(0,g.jsx)(`span`,{className:`text-[11.5px] font-medium text-ink`,children:e.label}),(0,g.jsx)(`span`,{className:`text-[10px] text-ink-3`,children:e.detail})]})},e.id))})]})]},`profile-${P}`),(0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsx)(vm,{disabled:ce,label:`审批策略:${R.label}`,title:`${R.label} · ${R.detail}`,className:`h-7 w-7`,children:(0,g.jsx)(He,{size:15,className:R.tone,"aria-hidden":`true`})})}),(0,g.jsxs)(sm,{align:`start`,className:`w-[230px]`,children:[(0,g.jsx)(cm,{children:`审批策略`}),(0,g.jsx)(om,{value:ae,onValueChange:e=>{let t=D9.find(t=>t.id===e);t&&t.id!==ae&&(t.id===`autonomous`?p(P):et(t.id))},children:D9.map(e=>(0,g.jsx)(um,{value:e.id,className:`items-start py-2`,children:(0,g.jsxs)(`span`,{className:`flex flex-col`,children:[(0,g.jsx)(`span`,{className:`text-[11.5px] font-medium text-ink`,children:e.label}),(0,g.jsx)(`span`,{className:`text-[10px] text-ink-3`,children:e.detail})]})},e.id))})]})]},`policy-${P}`),(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsx)(vm,{label:`添加附件`,title:`添加 PDF、Office、文本或图片(最大 20 MiB)`,disabled:!F||A,onClick:()=>u.current?.click(),className:`h-7 w-7`,children:(0,g.jsx)(Ns,{size:15,"aria-hidden":`true`})}),A?(0,g.jsx)(`button`,{type:`button`,onClick:N,"aria-label":`停止执行`,className:`ml-1 flex h-7 w-7 items-center justify-center rounded-full bg-danger/10 text-danger transition-colors hover:bg-danger/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-danger/40`,children:(0,g.jsx)(pc,{size:11,fill:`currentColor`})}):(0,g.jsx)(`button`,{type:`button`,onClick:nt,disabled:!O.trim()&&Me.length===0||!Ae||Xe||Pe||Fe||Ie,"aria-label":`发送消息`,className:B(`ml-1 flex h-7 w-7 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,(O.trim()||Me.length>0)&&Ae&&!Xe&&!Pe&&!Fe&&!Ie?`bg-accent text-white shadow-[var(--shadow-card)] hover:brightness-110 active:brightness-95`:`bg-black/[.06] text-ink-3 dark:bg-white/[.08]`),children:(0,g.jsx)(Ba,{size:15,strokeWidth:2.2})})]}),(0,g.jsx)(Xc,{open:le,title:`启用完全自主?`,description:`Agent 将不再逐次请求工具审批,可自行修改或删除文件、执行命令、进行 Git 推送等操作。程序以本机账户权限运行,可访问项目外文件和网络。请仅在信任当前任务时启用。此设置从下一轮起在当前会话持续生效,随时可以切回标准审批。`,confirmLabel:`确认启用`,danger:!0,onCancel:()=>p(null),onConfirm:()=>{le&&et(`autonomous`),p(null)}})]}),Je?(0,g.jsx)(Nce,{usage:I?void 0:qe,streaming:A,lastStep:Ye,contextUsage:{used:Ke?.inputTokens??null,limit:z}}):null]})}function Fce(){let e=Uq(e=>e.items),t=Uq(e=>e.sessionId),n=d3(e),[r,i]=(0,h.useState)(null),a=Math.max(0,n.findIndex(e=>e.id===r)),o=n[a];return o?(0,g.jsx)(Ice,{item:o,index:a,total:n.length,navigate:e=>i(n[a+e]?.id??o.id)},`${t}:${o.id}`):null}function Ice({item:e,index:t,total:n,navigate:r}){let i=Uq(e=>e.resolveApproval),{data:a}=sM(),o=vW(e=>e.projectId),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),[d,f]=(0,h.useState)(Date.now);(0,h.useEffect)(()=>{let e=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let p=e.expiresAt!==void 0&&d>=e.expiresAt,m=async t=>{if(!(s||p)){c(!0),u(null);try{await i(e.id,t)}catch(e){u(pj(e,`审批提交失败,请重试`))}finally{c(!1)}}};return(0,g.jsxs)(`section`,{"aria-label":`待处理审批`,className:`mb-2 max-h-[min(42dvh,360px)] overflow-y-auto rounded-xl border border-warning/25 bg-surface p-2.5 shadow-[var(--shadow-card)] text-[12px]`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-ink`,children:[(0,g.jsx)(ac,{size:14,className:`text-warning`}),(0,g.jsx)(`span`,{children:`需要批准`}),n>1?(0,g.jsxs)(`div`,{className:`ml-auto flex items-center gap-1 text-ink-3`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":`上一项审批`,disabled:s||t===0,onClick:()=>r(-1),className:`rounded p-1 disabled:opacity-30`,children:(0,g.jsx)(Qa,{size:14})}),(0,g.jsxs)(`span`,{children:[t+1,`/`,n]}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`下一项审批`,disabled:s||t===n-1,onClick:()=>r(1),className:`rounded p-1 disabled:opacity-30`,children:(0,g.jsx)(eo,{size:14})})]}):null]}),(0,g.jsx)(`pre`,{className:`mt-1.5 max-h-16 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 px-2 py-1.5 font-mono text-[12px] text-ink`,children:e.summary??e.impact??`请求执行操作`}),p?(0,g.jsx)(`p`,{role:`status`,className:`mt-1.5 text-ink-3`,children:`审批已过期,等待任务更新。`}):null,(0,g.jsx)(Yc,{message:l,onDismiss:()=>u(null)}),(0,g.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,g.jsxs)(`details`,{className:`min-w-0 flex-1 pt-1 text-[11px] text-ink-3`,children:[(0,g.jsx)(`summary`,{className:`cursor-pointer`,children:`查看操作详情`}),(0,g.jsxs)(`div`,{className:`mt-1.5 space-y-1 whitespace-pre-wrap break-words`,children:[(0,g.jsxs)(`div`,{children:[a.projects.find(e=>e.id===o)?.name??`默认工作区`,` ·`,` `,e.toolName??e.serviceName??`操作`]}),(0,g.jsxs)(`div`,{children:[`授权范围:仅本次操作 · 风险 `,e.risk??`—`]}),e.expiresAt===void 0?null:(0,g.jsxs)(`div`,{children:[`有效至 `,new Date(e.expiresAt).toLocaleTimeString()]}),(0,g.jsx)(`pre`,{className:`max-h-28 overflow-auto whitespace-pre-wrap`,children:JSON.stringify(e.scope??{},null,2)})]})]}),(0,g.jsxs)(`div`,{className:`flex shrink-0 gap-1.5`,children:[(0,g.jsx)(V,{variant:`primary`,size:`sm`,"aria-label":e.toolName?`批准执行`:`批准部署`,disabled:s||p,onClick:()=>void m(`approve`),children:s?`提交中…`:`批准本次`}),(0,g.jsx)(V,{variant:`secondary`,size:`sm`,disabled:s||p,onClick:()=>void m(`reject`),children:`拒绝`})]})]})]})}function j9({icon:e,label:t,ariaLabel:n,onClick:r,disabled:i,titleAttr:a}){return(0,g.jsxs)(`button`,{type:`button`,"aria-label":n,title:a??n,disabled:i,onClick:r,className:B(`group`,b9,wce),children:[(0,g.jsx)(e,{size:11,className:`shrink-0 text-accent`}),(0,g.jsx)(`span`,{className:`truncate`,children:t}),(0,g.jsx)(Ra,{size:10,className:`shrink-0 text-ink-3 group-hover:text-accent`})]})}function Lce(e){return e.split(`/`).pop()??e}function M9({target:e}){let[t,n]=(0,h.useState)(!1),[r,i]=(0,h.useState)(null),[a,o]=(0,h.useState)(!1);return(0,g.jsxs)(`div`,{className:`min-w-0`,children:[(0,g.jsx)(j9,{icon:Lo,label:`文件 · ${Lce(e.path)}`,ariaLabel:`查看文件 · ${e.path}`,disabled:a,onClick:()=>{o(!0),i(null),HM(e.scope,e.path,`agent`).then(t=>n(e.version!==void 0&&e.version!==t.version)).catch(e=>i(VM(e))).finally(()=>o(!1))}}),(0,g.jsx)(Hc,{message:r??(t?`文件已变化,已打开当前版本。`:null),tone:r?`error`:`success`,onDismiss:()=>r?i(null):n(!1)})]})}function N9({target:e}){let t=FM(e=>e.open),n=e.name??e.path;return(0,g.jsx)(j9,{icon:Co,label:`预览 · ${n}`,ariaLabel:`打开预览 · ${n}`,onClick:()=>t({kind:`browser`,resourceId:`browser:${e.serviceId}:${e.path}`,browser:{serviceId:e.serviceId,path:e.path},title:`预览服务`,projectId:e.projectId,source:`agent`})})}function Rce(e){return(0,g.jsx)(zce,{...e},JSON.stringify([e.projectId,e.terminalId]))}function zce({terminalId:e,projectId:t,label:n,ariaLabel:r,className:i,variant:a=`link`}){let[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(null),u=(0,h.useRef)(0),d=(0,h.useRef)(!1);(0,h.useEffect)(()=>()=>{u.current+=1,d.current=!1},[]);let f=async()=>{if(d.current)return;d.current=!0;let n=++u.current;s(!0),l(null);try{let r=await KK(e);if(n!==u.current)return;r.id!==e||r.projectId!==t?l({text:`终端归属已变化,无法打开。`,error:!0}):$K(r)?l({text:`终端已关闭`}):r.status===`RUNNING`?XK(r):l({text:r.status===`STOPPING`?`终端正在关闭,请稍后重试。`:r.status===`CREATED`?`终端正在创建,请稍后重试。`:`终端状态异常,请核对状态后重试。`})}catch(e){if(n!==u.current)return;l(e instanceof fj&&e.status===404?{text:`终端已关闭或已被清理`}:{text:`无法读取终端状态,请重试。`,error:!0})}finally{n===u.current&&(d.current=!1,s(!1))}};return(0,g.jsxs)(`div`,{className:`min-w-0`,children:[a===`card`?(0,g.jsx)(j9,{icon:dc,label:`终端 · ${n.replace(/^打开终端 · /,``)}`,ariaLabel:r??n,disabled:o,onClick:()=>void f()}):(0,g.jsxs)(`button`,{type:`button`,disabled:o,"aria-label":r,"aria-busy":o,onClick:()=>void f(),className:B(`flex max-w-full items-center gap-2 py-1 text-left text-[12px] text-ink-2 hover:text-ink disabled:opacity-50`,i),children:[(0,g.jsx)(dc,{size:13,className:`shrink-0 text-accent`}),(0,g.jsx)(`span`,{className:`break-all`,children:n})]}),(0,g.jsx)(Hc,{message:c?.text??null,tone:c?.error?`error`:`info`,onDismiss:()=>l(null)})]})}function P9({target:e}){return(0,g.jsx)(Rce,{terminalId:e.terminalId,projectId:e.projectId,label:`打开终端 · ${e.role??e.terminalId}`,variant:`card`})}function Bce({sessionId:e,attachments:t}){let[n,r]=(0,h.useState)(null);return t.length===0?null:(0,g.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,"data-testid":`attachment-strip`,children:[t.map(e=>(0,g.jsx)(x9,{item:{id:e.id,filename:e.filename,kind:e.kind,status:e.status,method:e.method,pageCount:e.pageCount,errorCode:e.errorCode},onOpen:()=>r({id:e.id,filename:e.filename,kind:e.kind,mime:e.mime})},e.id)),n?(0,g.jsx)(y9,{sessionId:e,target:n,onClose:()=>r(null)}):null]})}function Vce(e,t){let n=Eh(),[r,i]=(0,h.useState)(`正在连接输出…`);return(0,h.useEffect)(()=>{if(!t)return;let r=!1,a,o,s,c=1e3,l=!1,u=(t=!1)=>{l||=!t,r||s||(s=setTimeout(()=>{s=void 0,r||(n.invalidateQueries({queryKey:[`command`,e,`output`]}),l&&n.invalidateQueries({queryKey:[`command`,e,`state`]})),l=!1},250))},d=()=>{if(r)return;let t=new URL(`/ws`,window.location.href);t.protocol=t.protocol===`https:`?`wss:`:`ws:`,a=new WebSocket(t),a.onopen=()=>{a?.send(JSON.stringify({type:`subscribe`,subscriptions:[{topic:`command`,resourceId:e,after:0}]})),c=1e3,i(`实时输出已连接`),u()},a.onmessage=t=>{let n;try{n=JSON.parse(String(t.data))}catch{return}let r=VO.safeParse(n),i=RO.safeParse(n);r.success&&r.data.resourceId===e&&u(!0),i.success&&i.data.resourceId===e&&u()},a.onerror=()=>i(`输出连接中断,正在刷新状态…`),a.onclose=()=>{r||(i(`输出连接中断,正在重连…`),u(),o=setTimeout(d,c),c=Math.min(c*2,1e4))}};return d(),()=>{r=!0,clearTimeout(o),clearTimeout(s),a?.close()}},[t,n,e]),r}var Hce={CREATED:`准备执行`,RUNNING:`执行中`,CANCELLING:`正在停止`,COMPLETED:`已完成`,FAILED:`执行失败`,CANCELLED:`已取消`,TIMED_OUT:`执行超时`,INTERRUPTED:`执行中断`},F9=e=>!e||[`CREATED`,`RUNNING`,`CANCELLING`].includes(e);async function Uce(e,t){let n=t?.cursor??0,r=t?.text??``,i=t?.truncated??!1,a=t?.gap??!1;for(let t=0;t<64;t++){let t=BO.parse(await Y(`/api/commands/${e}/output?after=${n}&limit=500`));if(t.resyncRequired&&!t.chunks.length&&(r=``),r+=t.chunks.filter(e=>e.cursor>n).map(e=>e.data).join(``),i||=t.truncated,a||=t.resyncRequired,t.nextCursor<=n||t.chunks.length<500)return{text:r,truncated:i,gap:a,cursor:t.nextCursor};n=t.nextCursor}return{text:r,truncated:!0,gap:a,cursor:n}}function Wce({commandId:e}){let t=Eh(),n=Zg({queryKey:[`command`,e,`state`],queryFn:async()=>zO.parse(await Y(`/api/commands/${e}`)),staleTime:0,refetchInterval:e=>F9(e.state.data?.status)&&!e.state.error?2e3:!1}),r=F9(n.data?.status);Vce(e,r&&!n.error);let i=Zg({queryKey:[`command`,e,`output`],queryFn:()=>Uce(e,t.getQueryData([`command`,e,`output`])),staleTime:0,refetchInterval:r&&!n.error?2e3:!1}),a=n.data?.status;(0,h.useEffect)(()=>{a&&!F9(a)&&t.invalidateQueries({queryKey:[`command`,e,`output`]})},[t,e,a]);let o=()=>t.invalidateQueries({queryKey:[`command`,e]}),s=t_({mutationFn:async()=>zO.parse(await Y(`/api/commands/${e}/cancel`,{method:`POST`,body:{},csrf:!0})),onSuccess:n=>{t.setQueryData([`command`,e,`state`],n),o()},onError:()=>{o()}});return(0,g.jsxs)(`section`,{"aria-label":`命令执行`,className:`mt-2 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-2 text-[11px]`,children:[(0,g.jsx)(`span`,{className:`font-semibold text-ink`,children:`命令执行`}),(0,g.jsx)(`span`,{role:`status`,className:`text-ink-2`,children:n.data?Hce[n.data.status]:n.error?`命令不可用`:`正在读取状态…`}),n.data?.exitCode!==null&&n.data?.exitCode!==void 0?(0,g.jsxs)(`span`,{className:`font-mono text-ink-3`,children:[`退出码 `,n.data.exitCode]}):null,(0,g.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-1`,children:[(0,g.jsx)(V,{size:`sm`,variant:`secondary`,onClick:()=>void o(),children:`刷新输出`}),n.data&&r?(0,g.jsx)(V,{size:`sm`,variant:`secondary`,disabled:s.isPending||n.data.status===`CANCELLING`,onClick:()=>s.mutate(),children:`取消命令`}):null]})]}),n.data?.reasonCode?(0,g.jsxs)(`p`,{className:`px-3 text-[11px] text-ink-2`,children:[`原因:`,n.data.reasonCode]}):null,n.data?.status===`INTERRUPTED`?(0,g.jsx)(`p`,{className:`px-3 text-[11px] text-warning`,children:`执行已中断;停止情况以状态原因为准,不能确认时项目保持受阻。`}):null,(0,g.jsx)(Yc,{message:s.error?`取消命令失败,请刷新确认。`:n.error||i.error?`命令状态或输出读取失败。`:null,onDismiss:s.error?()=>s.reset():void 0}),i.data?.gap?(0,g.jsx)(`p`,{className:`px-3 text-[11px] text-warning`,children:`输出有缺口,以下仅为当前可用记录。`}):null,i.data?.truncated||n.data?.truncated?(0,g.jsx)(`p`,{className:`px-3 text-[11px] text-warning`,children:`输出已截断。`}):null,(0,g.jsx)(`pre`,{role:`log`,"aria-label":`命令输出`,className:`max-h-[200px] overflow-auto whitespace-pre-wrap break-words border-t border-line bg-surface-2 px-3 py-2 font-mono text-[11px] text-ink-2`,children:i.data?.text||(r?`等待命令输出…`:`无可用输出`)})]})}function I9({item:e,turnActive:t=!1,turnOutcome:n,commentary:r=!1,onRetry:i}){switch(e.kind){case`message`:return(0,g.jsx)(L9,{item:e,commentary:r});case`plan`:return(0,g.jsx)(Yce,{item:e,turnActive:t,turnOutcome:n});case`tool`:return(0,g.jsx)(Xce,{item:e});case`reasoning`:return null;case`approval`:return null;case`artifact`:return(0,g.jsx)(Zce,{item:e});case`error`:return(0,g.jsxs)(`div`,{role:`status`,className:B(`border-l-2 pl-3 text-[12px] leading-5`,/已停止/.test(e.message)?`border-line text-ink-3`:`border-danger/50 text-ink-2`),children:[e.message,i?(0,g.jsx)(`button`,{type:`button`,onClick:i,className:`ml-2 text-[11px] text-accent hover:underline`,children:`重试`}):null]})}}function L9({item:e,children:t,commentary:n=!1,finalAnswer:r=!1}){let[i,a]=(0,h.useState)(!1),[o,s]=(0,h.useState)(!1),c=vW(e=>e.sessionId);if(e.role===`user`&&e.text.startsWith(`Work state checkpoint`))return(0,g.jsx)(`div`,{className:`mb-5 flex justify-end`,children:(0,g.jsxs)(`div`,{className:`max-w-[91%] rounded-[18px] bg-surface-2 px-3.5 py-2.5 text-[12px] leading-[1.65] text-ink-2 sm:max-w-[82%]`,children:[(0,g.jsx)(`div`,{className:`text-ink`,children:`自动继续上一轮的未完成工作`}),(0,g.jsx)(`div`,{className:`mt-0.5`,children:`已带上已完成文件、命令与失败诊断的核对事实。`}),(0,g.jsx)(`button`,{type:`button`,className:`mt-1 text-[11px] text-ink-3 transition-colors hover:text-accent`,onClick:()=>a(e=>!e),children:i?`收起核对事实`:`查看核对事实`}),i?(0,g.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] text-ink-3`,children:e.text}):null]})});let l=e.attachments&&e.attachments.length>0?void 0:e.screenshots;return e.role===`user`?(0,g.jsxs)(`div`,{className:`mb-5 flex flex-col items-end gap-1.5`,children:[e.text?(0,g.jsxs)(`div`,{className:`max-w-[91%] rounded-[18px] bg-accent-soft px-3.5 py-2.5 text-[13px] leading-[1.65] text-ink sm:max-w-[82%]`,children:[(0,g.jsx)(`div`,{className:B(`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,!i&&e.text.length>1200&&`line-clamp-8`),children:e.text}),e.text.length>1200?(0,g.jsx)(`button`,{type:`button`,className:`mt-1 text-[11px] text-ink-3`,onClick:()=>a(e=>!e),children:i?`收起`:`展开消息`}):null]}):null,e.attachments&&e.attachments.length>0&&c?(0,g.jsx)(Bce,{sessionId:c,attachments:e.attachments}):null,l?(0,g.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:l.ids.map(e=>(0,g.jsx)(Gce,{src:Jj(l.sessionId,e)},e))}):null]}):(0,g.jsxs)(`article`,{className:B(`min-w-0 break-words leading-[1.65] [overflow-wrap:anywhere]`,n?`text-[12px] text-ink-2`:`text-[13px] text-ink`),children:[e.text?(0,g.jsx)(`div`,{"data-testid":r?`final-answer-bubble`:`message-bubble`,className:B(`w-fit min-w-0 max-w-full rounded-2xl rounded-tl-md border border-line bg-surface`,n?`px-3 py-2`:`px-3.5 py-2.5`),children:(0,g.jsx)(v9,{text:e.text})}):null,t,!e.streaming&&e.text?(0,g.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 px-0.5`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":o?`已复制答复`:`复制答复`,className:`rounded p-1 text-ink-3 hover:bg-surface-2`,onClick:()=>{navigator.clipboard.writeText(e.text).then(()=>s(!0)).catch(()=>s(!1))},children:o?(0,g.jsx)(Ja,{size:13}):(0,g.jsx)(yo,{size:13})}),(0,g.jsx)(`time`,{dateTime:new Date(e.createdAt).toISOString(),title:new Date(e.createdAt).toLocaleString(),className:`font-mono text-[11px] text-ink-3`,children:new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})})]}):null]})}function Gce({src:e}){let[t,n]=(0,h.useState)(!1);return t?(0,g.jsx)(`span`,{className:`rounded-md border border-line bg-surface-2 px-2 py-1 text-[11px] text-ink-3`,children:`截图不可用`}):(0,g.jsx)(`img`,{src:e,alt:`用户截图`,className:`max-h-48 max-w-full rounded-lg object-contain`,loading:`lazy`,onError:()=>n(!0)})}function Kce(e,t,n){if(e!==`running`||t)return e;switch(n){case`cancelled`:return`stopped`;case`failed`:case`interrupted`:return`interrupted`;default:return`unmarked`}}var qce={done:`已完成:`,running:`进行中:`,failed:`失败:`,pending:`待做:`,stopped:`已停止`,interrupted:`已中断`,unmarked:`未标记完成`},Jce=new Set([`stopped`,`interrupted`,`unmarked`]);function Yce({item:e,turnActive:t,turnOutcome:n}){let r=e.steps.length,i=e.steps.filter(e=>e.status===`done`).length,a=e.steps.filter(e=>e.status===`failed`).length,o=t?0:e.steps.filter(e=>e.status===`running`||e.status===`pending`).length,s=`计划 · ${i}/${r} · ${e.title}${o>0?` · 另有 ${o} 步未完成`:``}`;return(0,g.jsxs)(`div`,{className:`mb-2 min-w-0 rounded-lg bg-surface-3 px-2.5 py-2 text-[12px] text-ink-2 sm:max-w-[28rem]`,children:[(0,g.jsxs)(`div`,{"aria-hidden":`true`,className:`mb-1.5 flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`shrink-0 font-medium`,children:`计划`}),(0,g.jsxs)(`span`,{className:`shrink-0 text-[11px] tabular-nums`,children:[i,`/`,r]}),(0,g.jsx)(`span`,{className:`flex-1`}),a>0?(0,g.jsxs)(`span`,{className:`shrink-0 text-[10.5px] text-danger`,children:[a,` 步失败`]}):o>0?(0,g.jsxs)(`span`,{className:`shrink-0 text-[10.5px]`,children:[o,` 步未完成`]}):null]}),(0,g.jsx)(`ol`,{"aria-label":s,className:`space-y-[3px]`,children:e.steps.map(e=>{let r=Kce(e.status,t,n);return(0,g.jsxs)(`li`,{"aria-current":r===`running`?`step`:void 0,className:`flex items-start gap-1.5`,children:[r===`done`?(0,g.jsx)(Ja,{size:13,className:`mt-[2px] shrink-0 text-success`}):r===`running`?(0,g.jsx)(ps,{size:13,className:`mt-[2px] shrink-0 animate-spin text-accent motion-reduce:animate-none`}):r===`failed`?(0,g.jsx)(Ac,{size:13,className:`mt-[2px] shrink-0 text-danger`}):(0,g.jsx)(uo,{size:13,className:`mt-[2px] shrink-0 text-ink-3`}),(0,g.jsxs)(`span`,{className:B(`min-w-0 flex-1 break-words`,r===`running`&&`text-ink`),children:[e.title,(0,g.jsx)(`span`,{className:B(Jce.has(r)?`ml-2`:`sr-only`,`text-[11px]`),children:qce[r]})]})]},e.id)})})]})}function Xce({item:e}){let[t,n]=(0,h.useState)(!1);return(0,g.jsxs)(`div`,{className:`min-w-0 text-[12px] text-ink-3`,children:[(0,g.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(e=>!e),className:`flex w-full items-start gap-1.5 rounded-md py-1 text-left transition-colors hover:text-accent`,children:[(0,g.jsx)(eo,{size:13,className:B(`mt-0.5 shrink-0`,t&&`rotate-90`)}),(0,g.jsx)(`span`,{className:B(`min-w-0 [overflow-wrap:anywhere]`,e.commandLabel&&`line-clamp-2 font-mono`),children:e.commandLabel||e.summary||e.name}),e.status===`error`?(0,g.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-0.5 text-danger`,children:[(0,g.jsx)(Ac,{size:13}),` 失败`,e.retried===!0?(0,g.jsx)(`span`,{className:`text-ink-3`,children:`· 已重试`}):null]}):null]}),t?(0,g.jsxs)(`div`,{className:`ml-5 space-y-2`,children:[(0,g.jsxs)(`div`,{className:`text-[11px]`,children:[e.name,e.durationMs===void 0?``:` · ${Math.round(e.durationMs/1e3)}秒`]}),e.args?(0,g.jsx)(`pre`,{className:`max-h-[200px] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-2.5 font-mono text-[12px] text-ink-2`,children:e.args}):null,e.output?(0,g.jsx)(`pre`,{className:`max-h-[200px] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-2.5 font-mono text-[12px] text-ink-2`,children:e.output}):null,e.commandId?(0,g.jsx)(Wce,{commandId:e.commandId}):null]}):null]})}function Zce({item:e}){let t=FM(e=>e.open),{projectId:n,sessionId:r}=vW();return e.resourceTarget?.kind===`file`?(0,g.jsx)(M9,{target:e.resourceTarget}):e.resourceTarget?.kind===`preview`?(0,g.jsx)(N9,{target:e.resourceTarget}):e.resourceTarget?.kind===`terminal`?(0,g.jsx)(P9,{target:e.resourceTarget}):(0,g.jsxs)(`div`,{className:`break-words text-[12px] text-ink-2`,children:[(0,g.jsx)(`span`,{children:e.title}),(0,g.jsx)(`p`,{className:`mt-1 text-ink-3`,children:e.description}),e.href?(0,g.jsxs)(`button`,{type:`button`,className:`mt-1 text-accent underline decoration-accent/30 underline-offset-4 hover:decoration-accent`,onClick:()=>t({kind:`browser`,resourceId:e.href??e.id,title:e.title,projectId:n,sessionId:r,source:`artifact`}),children:[`打开 `,e.title]}):null]})}var R9=3;function Qce(e){return e.kind===`message`&&e.role===`user`}function $ce(e){return e.kind===`message`&&e.role===`user`&&e.text.startsWith(`Work state checkpoint`)}function ele(e){let t=[],n=new Map,r;for(let i of e){let e=i.kind===`message`&&i.role===`user`;if($ce(i)&&i.turnId!==void 0&&r!==void 0){n.set(i.turnId,r),r.turnIds.push(i.turnId),r.users.push(i);continue}let a=i.turnId??(e?i.id:r?.id??i.id),o=n.get(a);if(o)o.items.push(i),i.turnId!==void 0&&!o.turnIds.includes(i.turnId)&&o.turnIds.push(i.turnId),e&&(r=o,o.users.push(i));else{let o={id:a,items:[i],turnIds:i.turnId===void 0?[]:[i.turnId],users:e?[i]:[]};t.push(o),n.set(a,o),r=o}}return t}function tle(e,t){return t===null?e.at(-1):e.find(e=>e.turnIds.includes(t))}function nle(e){switch(e){case`tokens`:return`已达花费上限`;case`context`:return`上下文已满`;case`duration`:return`执行超时中止`;case`steps`:return`步数已达上限`;case`tool_calls`:return`工具调用已达上限`;default:return`预算停止`}}function rle(e){let t=Uq(e=>e.turnStartedAt),[n,r]=(0,h.useState)(()=>Date.now());return(0,h.useEffect)(()=>{if(!e)return;r(Date.now());let t=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),!e||t===null?null:Math.max(0,Math.floor((n-t)/1e3))}function ile(){return(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`process-sparkle`,"data-active":`true`,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 20 20`,fill:`none`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{className:`process-sparkle-main`,d:`M7.6 2.2c.5 4.2 1.9 5.6 6.1 6.1-4.2.5-5.6 1.9-6.1 6.1-.5-4.2-1.9-5.6-6.1-6.1 4.2-.5 5.6-1.9 6.1-6.1Z`,fill:`currentColor`}),(0,g.jsx)(`path`,{className:`process-sparkle-small`,d:`M15.4 11.2c.3 2.3 1 3 3.3 3.3-2.3.3-3 1-3.3 3.3-.3-2.3-1-3-3.3-3.3 2.3-.3 3-1 3.3-3.3Z`,fill:`currentColor`})]})})}function ale(e){switch(e.name){case`run_command`:case`run_shell`:return`命令`;case`read_file`:case`list_files`:case`search_code`:return`读取`;case`write_file`:case`apply_patch`:return`修改文件`;case`start_process`:case`list_processes`:case`read_process_output`:case`stop_process`:return`后台进程`;case`list_service_ops`:case`read_service_ops_logs`:case`control_service_ops`:return`服务运维`;default:return``}}function ole({group:e,active:t}){let n=Uq(e=>e.send),r=Uq(e=>e.resumeTurn),i=e.items,a=i.find(Qce),o=e.users.at(-1)??a,s=t&&o?.turnOutcome===void 0,[c,l]=(0,h.useState)(!1),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(!1),m=i.filter(e=>e.kind===`tool`&&e.name!==`update_plan`),_=-1,v=-1;i.forEach((e,t)=>{e.kind===`tool`&&(_=t),e.kind===`message`&&e.role===`assistant`&&(v=t)});let y=v>=0&&!s&&o?.terminalReason!==`continued`&&(v>_||o?.turnOutcome===`completed`)?i[v]:void 0,b=t&&!y?[...i].reverse().find(e=>e.kind===`message`&&e.role===`assistant`):void 0,x=i.filter(e=>e.kind===`plan`).at(-1),S=i.filter(e=>e!==a&&e!==y&&e!==b&&(e.kind===`message`&&e.role===`assistant`||e.kind===`tool`&&e.name!==`update_plan`)),C=o?.turnOutcome===`interrupted`,w=o?.turnOutcome===`failed`,T=o?.turnOutcome===`cancelled`,E=o?.terminalReason===`continued`,D=C&&o.turnId!==void 0?`interrupted_${o.turnId}`:void 0,O=o?.terminalReason===`budget`,k=o?.terminalReason===`output_truncated`,A=e.users.reduce((e,t)=>t.durationMs===void 0?e:(e??0)+t.durationMs,void 0),j=rle(s),M=s&&d3(i).length>0,N=[...i].reverse().find(e=>e.kind===`tool`&&e.name!==`update_plan`&&e.status===`running`),ee=s&&i.some(e=>e.kind===`message`&&e.role===`assistant`&&e.streaming),te=s&&i.some(e=>e.kind===`reasoning`&&e.streaming),P;P=s?M?`Waiting for approval...`:N?`Running...`:ee?`Generating...`:te?`Thinking...`:`Starting...`:E?`Continuing...`:T?`Stopped`:C?`Interrupted`:w?`Failed`:`Completed`;let F=Math.max(0,e.users.length-1),ne=s&&j!==null?`${j}s`:!s&&A!==void 0?`${Math.round(A/1e3)}s`:``,I=m.length,re=I>0?`${I} 步`:``,ie=[ne,N?ale(N):``,F>0?`已自动继续 ${F} 次`:``,!s&&O?nle(o?.budgetCause):``,!s&&k?`输出被截断`:``].filter(Boolean).join(` · `),ae=[`执行过程`,P,ie,re].filter(Boolean).join(` · `),oe=c?S:!s&&y===void 0?S.filter(e=>e.kind===`tool`&&e.status===`error`):[],se=new Map;for(let e of m){let t=e.resourceTarget;t&&se.set(t.kind===`file`?JSON.stringify([t.scope,t.path]):t.kind===`preview`?`preview:${t.serviceId}:${t.path}`:t.terminalId,t)}let ce=new Set([...se.values()].filter(e=>e.kind===`file`).map(e=>e.path)),le=new Map,ue=0;for(let t of e.users){ue+=t.fileResultsOmitted??0;for(let e of t.fileResults??[])le.set(e.path,e)}let de=le.size===0?void 0:[...le.values()],L=new Set((de??[]).filter(e=>e.category===`deliverable`).map(e=>e.path)),fe=de===void 0?[...se.entries()]:[...se.entries()].filter(([,e])=>e.kind!==`file`||L.has(e.path)),pe=fe.filter(([,e])=>e.kind===`file`),me=f?pe:pe.slice(0,R9),he=new Set(me.map(([e])=>e)),ge=fe.filter(([e,t])=>t.kind!==`file`||he.has(e)),_e=i.filter(e=>{if(e.kind!==`artifact`)return!1;let t=e.title.replace(/^已(?:修改|创建) /,``);return de===void 0?!ce.has(t):t===e.title}),ve=ge.length>0||_e.length>0||ue>0,ye=!s&&ve?(0,g.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[ge.length>0?(0,g.jsxs)(`section`,{"aria-label":`本次成果`,className:`flex flex-wrap gap-1.5`,children:[ge.map(([e,t])=>t.kind===`file`?(0,g.jsx)(M9,{target:t},e):t.kind===`preview`?(0,g.jsx)(N9,{target:t},e):(0,g.jsx)(P9,{target:t},e)),pe.length>R9?(0,g.jsx)(`button`,{type:`button`,"aria-label":f?`收起文件`:`展开全部文件`,"aria-expanded":f,onClick:()=>p(e=>!e),className:`px-1 py-1 text-[11px] text-ink-3 transition-colors hover:text-accent`,children:f?`收起`:`展开全部`}):null]}):null,_e.map(e=>(0,g.jsx)(I9,{item:e},e.id)),ue>0?(0,g.jsx)(`p`,{className:`text-[11px] text-ink-3`,children:`另有 ${ue} 个文件未列出`}):null]}):null;return(0,g.jsxs)(`section`,{"aria-label":`对话轮次`,className:`min-w-0`,children:[a?(0,g.jsx)(I9,{item:a}):null,x?(0,g.jsx)(I9,{item:x,turnActive:s,turnOutcome:o?.turnOutcome},x.id):null,(0,g.jsxs)(`div`,{className:`space-y-2`,children:[S.length>0||m.length>0||te||M||s&&!y?(0,g.jsxs)(`div`,{className:`text-[12px] text-ink-3`,children:[(0,g.jsxs)(`button`,{type:`button`,"aria-label":ae,"aria-expanded":c,onClick:()=>l(e=>!e),className:`process-status-row flex w-full items-center gap-2 rounded-md px-1 py-1 text-left transition-colors hover:text-accent`,children:[s?(0,g.jsx)(ile,{}):null,(0,g.jsx)(`span`,{className:B(`shrink-0 font-medium text-ink-2`,s&&`process-status-shimmer`),children:P}),ie===``?null:(0,g.jsx)(`span`,{className:`relative top-[0.5px] min-w-0 truncate text-[11px] text-ink-3`,children:ie}),(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[re===``?null:(0,g.jsx)(`span`,{"data-testid":`process-metrics`,className:`text-[11px] text-ink-3 tabular-nums`,children:re}),re===``?null:(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px bg-line`}),(0,g.jsx)(eo,{size:13,className:B(`shrink-0 transition-transform`,c&&`rotate-90`)})]})]}),oe.length>0?(0,g.jsx)(`div`,{className:`ml-1.5 mt-1 space-y-1 border-l border-line pl-3`,children:oe.map(e=>(0,g.jsx)(I9,{item:e,turnActive:s,commentary:!0},e.id))}):null]}):null,o?.turnOutcome===`interrupted`&&o.turnId!==void 0?(0,g.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-line bg-surface-2 px-2.5 py-1.5 text-[12px] text-ink-2`,children:u?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:`继续会新建一轮,并带上已完成文件、命令与失败诊断的核对事实;原轮次保持原样。`}),(0,g.jsx)(`button`,{type:`button`,className:`rounded border border-line px-2 py-0.5 text-ink transition-colors hover:text-accent`,onClick:()=>{d(!1),r(o.turnId??``)},children:`确认继续`}),(0,g.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-ink-3 transition-colors hover:text-ink`,onClick:()=>d(!1),children:`取消`})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:`上次执行被中断(服务重启或退出)。`}),(0,g.jsx)(`button`,{type:`button`,className:`rounded border border-line px-2 py-0.5 text-ink transition-colors hover:text-accent`,onClick:()=>d(!0),children:`继续这个任务`})]})}):null,b?(0,g.jsx)(I9,{item:b,commentary:!0}):null,y?.kind===`message`?(0,g.jsx)(L9,{item:y,finalAnswer:!0,children:ye}):ye,i.filter(e=>e.kind===`error`&&e.id!==D).map(e=>(0,g.jsx)(I9,{item:e,onRetry:a?()=>void n(a.text):void 0},e.id))]})]})}function sle(){let e=Uq(e=>e.items),t=Uq(e=>e.loading),n=Uq(e=>e.isStreaming),r=Uq(e=>e.contextNotice),i=Uq(e=>e.activeTurnId),a=Uq(e=>e.scrollToLatestNonce),o=vW(e=>e.sessionId),s=(0,h.useRef)(null),c=(0,h.useRef)(null),l=(0,h.useRef)(!0),[u,d]=(0,h.useState)(!1),f=(0,h.useCallback)(()=>{let e=s.current;e&&(l.current?e.scrollTop=e.scrollHeight:d(e.scrollHeight-e.scrollTop-e.clientHeight>140))},[]);(0,h.useLayoutEffect)(()=>{l.current=!0,d(!1)},[o]);let p=e.map(e=>e.kind===`reasoning`?``:JSON.stringify(e)).join(`|`);(0,h.useLayoutEffect)(f,[p,t]),(0,h.useLayoutEffect)(()=>{if(a===0)return;l.current=!0,d(!1);let e=s.current;e&&(e.scrollTop=e.scrollHeight)},[a]),(0,h.useEffect)(()=>{let e=s.current,t=c.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(f);return n.observe(e),n.observe(t),()=>n.disconnect()},[f]);let m=ele(e),_=n?tle(m,i):void 0;return(0,g.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,g.jsx)(`div`,{ref:s,role:`log`,"aria-label":`会话时间线`,onClickCapture:e=>{e.target instanceof Element&&e.target.closest(`button[aria-expanded]`)&&(l.current=!1)},onScroll:e=>{let t=e.currentTarget,n=t.scrollHeight-t.scrollTop-t.clientHeight;l.current=n<70,d(n>140)},className:`min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-7 [scrollbar-gutter:stable]`,children:(0,g.jsxs)(`div`,{ref:c,className:`mx-auto w-full max-w-[760px] space-y-8 pb-5`,children:[r?(0,g.jsxs)(`p`,{role:`status`,className:`text-[11px] text-ink-3`,children:[`上下文已压缩`,r.degraded?`(降级:超出部分已截断)`:``]}):null,t?(0,g.jsx)(`div`,{role:`status`,className:`py-8 text-[12px] text-ink-3`,children:`正在加载对话…`}):m.map(e=>(0,g.jsx)(ole,{group:e,active:_===e},`${o}:${e.id}`))]})}),(0,g.jsx)(`div`,{"aria-hidden":`true`,className:`conversation-scroll-edge conversation-scroll-edge-top`}),(0,g.jsx)(`div`,{"aria-hidden":`true`,className:`conversation-scroll-edge conversation-scroll-edge-bottom`}),u?(0,g.jsx)(`button`,{type:`button`,"aria-label":`回到最新消息`,onClick:()=>{l.current=!0,f(),d(!1)},className:`absolute bottom-3 left-1/2 z-10 flex h-8 w-8 -translate-x-1/2 items-center justify-center rounded-full border border-line bg-surface text-accent shadow-[var(--shadow-card)] transition-colors hover:bg-accent-soft`,children:(0,g.jsx)(Ma,{size:14})}):null]})}var cle=[{label:`了解项目`,text:`先帮我了解项目结构、主要功能和启动方式。`,icon:Uo,color:`text-accent`},{label:`排查问题`,text:`帮我排查一个问题:`,icon:Ka,color:`text-warning`},{label:`实现功能`,text:`我想在这个项目中实现一个功能:`,icon:_o,color:`text-success`}];function lle(){return(0,g.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 grid place-items-center overflow-clip [container-type:size]`,children:(0,g.jsx)(`div`,{"data-testid":`welcome-backdrop`,className:`welcome-backdrop relative aspect-square w-[min(100cqw,100cqh,700px)]`})})}function ule({workspaceLabel:e}){return(0,g.jsxs)(`h2`,{className:`mb-6 text-balance text-center text-[20px] font-semibold tracking-tight text-ink [overflow-wrap:anywhere] sm:text-[27px]`,children:[`想在 `,e,` 中做些什么?`]})}function dle(){return(0,g.jsx)(`section`,{"aria-label":`建议任务`,className:`mt-3 flex flex-wrap justify-center gap-2`,children:cle.map(({label:e,text:t,icon:n,color:r})=>(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{yW.getState().setDraft(t),vW.getState().focusComposer()},className:`inline-flex min-h-8 items-center gap-1.5 rounded-lg border border-line bg-surface/70 px-2.5 text-[12px] text-ink-2 transition-colors hover:border-accent/30 hover:bg-accent-soft hover:text-ink focus-visible:outline-2 focus-visible:outline-accent`,children:[(0,g.jsx)(n,{size:14,className:r,"aria-hidden":`true`}),e]},e))})}function fle(){let{data:e}=sM(),{projectId:t,sessionId:n,resourceCollapsed:r,toggleResource:i}=vW();BK(e=>e.extra);let a=Eh(),[o,s]=(0,h.useState)(!1),c=Uq(e=>e.sessionId===n&&!e.loading&&!e.isStreaming&&!e.items.length),l=(0,h.useRef)(null),u=(0,h.useRef)(null),d=(0,h.useRef)(null),f=()=>{c&&l.current&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches&&(u.current={sessionId:n,top:l.current.getBoundingClientRect().top})};(0,h.useLayoutEffect)(()=>{if(c){d.current?.cancel();return}let e=u.current;u.current=null;let t=l.current;if(e?.sessionId!==n||!t||typeof t.animate!=`function`)return;let r=e.top-t.getBoundingClientRect().top;r&&(d.current=t.animate([{transform:`translateY(${r}px)`},{transform:`translateY(0)`}],{duration:290,easing:`cubic-bezier(.22,.75,.25,1)`}))},[c,n]);let p=[...e.sessions].find(e=>e.id===n),m=e.projects.find(e=>e.id===t)?.name??_W(n,e.sessions),_=async()=>{if(p)try{await qj(p.id),await a.invalidateQueries({queryKey:[`workspace`]})}catch(e){window.dispatchEvent(new CustomEvent(`larness:workspace-error`,{detail:pj(e,`归档会话失败`)}))}};return(0,g.jsxs)(`main`,{className:`conversation-surface flex min-h-0 min-w-0 flex-1 flex-col bg-canvas/55`,children:[(0,g.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 px-4 sm:px-7`,children:[(0,g.jsx)(`h1`,{className:`min-w-0 truncate text-[12px] font-medium`,children:p?.title??`新会话`}),(0,g.jsx)(`span`,{className:`ml-auto hidden max-w-[40%] truncate text-[11px] text-ink-3 md:block`,children:m}),(0,g.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 md:ml-0`,children:[(0,g.jsx)(vm,{label:r?`展开项目资源`:`折叠项目资源`,className:`hidden xl:inline-flex`,onClick:i,children:(0,g.jsx)(js,{size:14})}),(0,g.jsxs)(im,{children:[(0,g.jsx)(am,{asChild:!0,children:(0,g.jsx)(vm,{label:`会话操作`,children:(0,g.jsx)(To,{size:15})})}),(0,g.jsxs)(sm,{align:`end`,className:`w-[190px]`,children:[(0,g.jsx)(lm,{disabled:!p,onSelect:()=>s(!0),children:`重命名会话`}),(0,g.jsx)(dm,{}),(0,g.jsx)(lm,{disabled:!p||!1,onSelect:()=>void _(),className:`text-danger focus:text-danger`,children:`归档会话`})]})]})]})]}),c?null:(0,g.jsx)(sle,{}),(0,g.jsx)(QW,{session:p?{id:p.id,title:p.title}:null,onClose:()=>s(!1),open:o}),(0,g.jsxs)(`div`,{"data-testid":`composer-dock`,"data-placement":c?`center`:`bottom`,className:B(`relative px-4 sm:px-7`,c?`flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto py-5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`:`shrink-0 pb-3 pt-1`),children:[c?(0,g.jsx)(lle,{}):null,(0,g.jsxs)(`div`,{className:B(`relative mx-auto flex w-full max-w-[760px] flex-col`,c&&`my-auto shrink-0`),children:[c?(0,g.jsx)(ule,{workspaceLabel:m}):null,c?null:(0,g.jsx)(u3,{}),(0,g.jsx)(Fce,{}),(0,g.jsx)(`div`,{ref:l,"data-composer-motion":!0,className:`relative z-10 min-w-0`,children:(0,g.jsx)(Pce,{centered:c,onSubmit:f})}),c?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dle,{}),(0,g.jsx)(`div`,{className:`mt-5`,children:(0,g.jsx)(u3,{})})]}):null]})]})]})}function ple(e){let t=Uq(e=>e.load),n=Uq(e=>e.disconnect);(0,h.useEffect)(()=>(t(e),()=>n()),[n,t,e])}function mle({scope:e,treeWidth:t,open:n,close:r,restoreFocus:i}){return(0,g.jsx)(Wc,{open:n,onOpenChange:e=>{e||r()},children:n?(0,g.jsx)(hle,{scope:e,treeWidth:t,close:r,restoreFocus:i}):null})}function hle({scope:e,treeWidth:t,close:n,restoreFocus:r}){let[i,a]=(0,h.useState)(``),[o,s]=(0,h.useState)(``),[c,l]=(0,h.useState)(0),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(``),m=(0,h.useRef)(null),_=(0,h.useId)(),v=i.trim();(0,h.useLayoutEffect)(()=>()=>m.current?.abort(),[]),(0,h.useEffect)(()=>{let e=window.setTimeout(()=>s(v),160);return()=>window.clearTimeout(e)},[v]);let y=Zg({queryKey:[`file-search`,IM(e),o],queryFn:({signal:t})=>Ote(e,o,t),enabled:v!==``&&v===o,retry:!1,gcTime:3e4}),b=v===o?y.data?.items??[]:[],x=Math.min(c,b.length-1),S=b[x],C=S?`${_}-${x}`:void 0;(0,h.useEffect)(()=>{C&&document.getElementById(C)?.scrollIntoView?.({block:`nearest`})},[C]);let w=r=>{if(m.current)return;m.current=new AbortController;let{signal:i}=m.current;p(``),d(!0),HM(e,r,`projectId`in e?`project`:`sessionId`in e?`session`:`global`,{signal:i,treeWidth:t}).then(n).catch(e=>{i.aborted||p(VM(e))}).finally(()=>{i.aborted||(m.current=null,d(!1))})};return(0,g.jsxs)(Kc,{overlayClassName:`bg-black/10 backdrop-blur-[3px] dark:bg-black/30`,className:`top-[min(15dvh,140px)] bottom-auto mx-auto max-h-[76dvh] w-[min(640px,calc(100vw-28px))] overflow-hidden rounded-[22px] border-white/60 bg-surface/90 p-0 shadow-[0_24px_80px_-16px_rgb(0_0_0/0.38)] backdrop-blur-2xl dark:border-white/12`,onCloseAutoFocus:e=>{e.preventDefault(),r()},children:[(0,g.jsx)(qc,{className:`sr-only`,children:`快速打开文件`}),(0,g.jsx)(Jc,{className:`sr-only`,children:`搜索当前工作区。使用方向键选择,Enter 打开。`}),(0,g.jsxs)(`div`,{className:`flex h-16 items-center gap-3 px-4 sm:h-[72px] sm:px-5`,children:[(0,g.jsx)($s,{size:24,"aria-hidden":`true`,className:`shrink-0 text-ink-3`}),(0,g.jsx)(mm,{variant:`bare`,className:`h-full min-w-0 flex-1 bg-transparent text-base text-ink outline-none sm:text-xl`,role:`combobox`,"aria-label":`文件名或相对路径`,"aria-autocomplete":`list`,"aria-controls":_,"aria-expanded":b.length>0,"aria-activedescendant":C,placeholder:`输入文件名或相对路径`,maxLength:128,readOnly:u,value:i,onChange:e=>{a(e.target.value),l(0),p(``)},onKeyDown:e=>{if(S&&!e.nativeEvent.isComposing){switch(e.key){case`ArrowDown`:l((x+1)%b.length);break;case`ArrowUp`:l((x+b.length-1)%b.length);break;case`Enter`:w(S.path);break;default:return}e.preventDefault()}}}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭快速打开`,title:`关闭快速打开`,onClick:n,className:`shrink-0 rounded-md border border-line bg-surface-2/70 px-1.5 py-0.5 font-mono text-[10px] text-ink-3 hover:text-ink`,children:`Esc`})]}),(0,g.jsx)(Yc,{message:f||(v===o&&y.isError?`搜索文件失败,请修改关键词或重试。`:null),onDismiss:f?()=>p(``):void 0,retry:!f&&v===o&&y.isError?{label:`重试`,run:()=>void y.refetch()}:void 0}),(0,g.jsx)(`div`,{id:_,role:`listbox`,"aria-label":`匹配的文件`,className:B(`max-h-[min(55dvh,420px)] overflow-y-auto`,b.length>0&&`my-2 border-t border-line px-2 pt-2`),children:b.map((e,t)=>(0,g.jsxs)(`button`,{type:`button`,role:`option`,tabIndex:-1,id:`${_}-${t}`,"aria-selected":t===x,"aria-disabled":u,title:e.path,className:B(`flex w-full min-w-0 items-center gap-3 rounded-xl px-3 py-2 text-left`,t===x?`bg-accent-soft text-accent`:`hover:bg-surface-2`),onPointerMove:()=>l(t),onMouseDown:e=>e.preventDefault(),onClick:()=>w(e.path),children:[(0,g.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-[9px] bg-surface-2 text-ink-3`,children:(0,g.jsx)(pW,{path:e.path,size:18})}),(0,g.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,g.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,g.jsx)(`span`,{className:`truncate text-[11px] text-ink-3`,children:e.path.split(`/`).slice(0,-1).join(`/`)||`.`})]}),t===x?(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-ink-3`,children:`↵`}):null]},e.path))}),v&&!f&&(u||v!==o||y.isFetching||y.data?.partial||y.isSuccess&&!b.length)?(0,g.jsx)(`p`,{role:`status`,className:`border-t border-line px-5 py-2.5 text-[11px] text-ink-3`,children:u?`正在打开文件…`:v!==o||y.isFetching?`正在搜索…`:y.data?.partial?`结果受限,请缩小关键词。`:`没有匹配的文件。`}):null]})}var gle=(e,t=220)=>{let[n,r]=(0,h.useState)(e),[i,a]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{if(e){r(!0);let e=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(e)}a(!1);let n=window.setTimeout(()=>r(!1),t);return()=>window.clearTimeout(n)},[e,t]),{mounted:n,visible:i}};function _le({version:e}){let{data:t,isPending:n,isError:r}=sM(),i=vW(e=>e.projectId),a=vW(e=>e.sessionId),o=vW(e=>e.reconcileWorkspace),s=vW(e=>e.sidebarCollapsed),c=vW(e=>e.sidebarWidth),l=vW(e=>e.resourceWidth),u=vW(e=>e.resourceCollapsed),d=vW(e=>e.setSidebarWidth),f=vW(e=>e.setResourceWidth),p=vW(e=>e.mobileSidebarOpen),m=vW(e=>e.toggleSidebar),_=vW(e=>e.setMobileSidebar),v=VK(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(null),C=(0,h.useRef)(null),w=hW(i,a,t.sessions),T=IM(w),E=x===T;x!==null&&!E&&S(null);let D=(0,h.useCallback)(()=>{C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,S(T)},[T]),O=gle(p);return ple(a),(0,h.useEffect)(()=>{let e=e=>{let t=e.detail;b(typeof t==`string`?t:`操作失败`)};return window.addEventListener(`larness:workspace-error`,e),()=>window.removeEventListener(`larness:workspace-error`,e)},[]),(0,h.useEffect)(()=>{n||r||o(t.projects.map(e=>e.id),t.sessions)},[t.projects,t.sessions,n,r,o]),(0,h.useEffect)(()=>{let e=e=>{if(e.defaultPrevented)return;let t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase();if(t&&n===`p`&&!e.shiftKey&&!e.altKey){if(!E&&document.querySelector(`[aria-modal="true"], [role="dialog"][data-state="open"]`))return;e.preventDefault(),!E&&!e.repeat&&D()}else if(!E){if(t&&n===`k`)e.preventDefault(),v();else if(t&&n===`b`)e.preventDefault(),m();else if(e.key===`Escape`&&!t){let t=FM.getState(),n=vW.getState(),r=aM.getQueryData([`workspace`])?.sessions??[],i=gW(n.projectId,n.sessionId,r),a=t.windows.filter(e=>!e.minimized&&kM(e)===i).sort((e,t)=>t.z-e.z)[0];a&&(e.preventDefault(),t.hide(a.id))}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v,D,E,m]),(0,g.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-canvas text-ink`,"data-testid":`workspace-home`,children:[(0,g.jsx)(aJ,{version:e}),(0,g.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,g.jsx)($y,{collapsed:s,width:c,className:`hidden md:flex`,children:(0,g.jsx)(Gq,{})}),(0,g.jsx)(Zq,{side:`left`,label:`调整项目侧栏宽度`,value:c,min:220,max:360,defaultValue:268,onChange:d,collapsed:s,className:`hidden md:block`}),(0,g.jsx)(fle,{}),(0,g.jsx)(Zq,{side:`right`,label:`调整资源侧栏宽度`,value:l,min:280,max:460,defaultValue:340,onChange:f,collapsed:u,className:`hidden xl:block`}),(0,g.jsx)($y,{collapsed:u,width:l,side:`right`,className:`hidden xl:flex`,children:(0,g.jsx)(qW,{onQuickOpen:D})}),(0,g.jsx)(c3,{})]}),(0,g.jsx)(mle,{scope:w,treeWidth:u||window.innerWidth<1280?void 0:l,open:E,close:()=>S(null),restoreFocus:()=>{C.current?.focus({preventScroll:!0}),C.current=null}}),(0,g.jsx)(Yc,{message:y,onDismiss:()=>b(null)}),O.mounted?(0,g.jsxs)(`div`,{className:`fixed inset-0 z-[150] md:hidden`,children:[(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭导航`,onClick:()=>_(!1),className:B(`absolute inset-0 bg-black/30 backdrop-blur-[2px] transition-opacity duration-200`,O.visible?`opacity-100`:`pointer-events-none opacity-0`)}),(0,g.jsx)(`div`,{className:B(`absolute inset-y-0 left-0 w-[280px] shadow-[var(--shadow-window)] transition-transform duration-200 ease-out`,O.visible?`translate-x-0`:`pointer-events-none -translate-x-full`),children:(0,g.jsx)(Gq,{mobile:!0})})]}):null]})}function vle(){let e=Eh();(0,h.useEffect)(()=>{let t=!1,n,r,i=window.location.protocol===`https:`?`wss`:`ws`,a={queryKey:[`workspace`],exact:!0},o=async()=>{e.getQueryData(a.queryKey)===void 0&&await e.cancelQueries(a),t||await e.invalidateQueries(a)},s=()=>{let a=new WebSocket(`${i}://${window.location.host}/ws`);n=a;let c=!1;a.addEventListener(`open`,()=>{c=!0,a.send(JSON.stringify({type:`subscribe`,subscriptions:[{topic:`system`,resourceId:`system`}]}))}),a.addEventListener(`message`,n=>{if(!(t||typeof n.data!=`string`))try{let t=JSON.parse(n.data);eA.safeParse(t).success&&o(),tA.safeParse(t).success&&e.invalidateQueries({queryKey:[`jobs`]}),nA.safeParse(t).success&&e.invalidateQueries({queryKey:[`memory`]})}catch{}}),a.addEventListener(`close`,()=>{t||(c&&(e.invalidateQueries({queryKey:[`session`]}),e.invalidateQueries({queryKey:[`bootstrap`]})),r=window.setTimeout(s,1e3))}),a.addEventListener(`error`,()=>a.close())};return s(),()=>{t=!0,window.clearTimeout(r),n?.close()}},[e])}function yle({version:e}){return vle(),(0,g.jsx)(_le,{version:e})}function ble({message:e,onRetry:t}){return(0,g.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-canvas px-6 text-ink`,children:(0,g.jsxs)(`section`,{className:`w-full max-w-[420px] rounded-[18px] border border-line bg-surface p-7 shadow-card`,children:[(0,g.jsx)(`h1`,{className:`text-lg font-semibold`,children:`无法连接本机服务`}),(0,g.jsx)(`p`,{className:`mt-2 text-sm text-ink-2`,children:e}),t?(0,g.jsx)(`button`,{type:`button`,className:`mt-5 h-10 rounded-md bg-accent px-4 text-sm font-medium text-accent-ink`,onClick:t,children:`重试`}):null]})})}function xle({children:e,redirectTo:t=`/login`}){let n=YW(),r=Pv();if(n.isPending)return null;if(!n.data){let e=t===`/login`?`/login?returnTo=${encodeURIComponent(r.pathname+r.search)}`:t;return(0,g.jsx)(gy,{to:e,replace:!0})}return(0,g.jsx)(g.Fragment,{children:e})}function Sle(){let e=JW();if(e.isPending)return null;if(e.isError||!e.data)return(0,g.jsx)(ble,{message:e.error instanceof Error?e.error.message:`本机服务未启动`,onRetry:()=>void e.refetch()});let t=e.data.auth,n=window.location.origin===t.passkeyOrigin,r=t.passkeyEnabled&&n&&t.passkeyRegistered?`/login`:`/pair`;return(0,g.jsx)(xle,{redirectTo:r,children:(0,g.jsx)(yle,{version:e.data.app?.version})})}function z9(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function B9(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function V9(){return Cle.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var Cle={stubThis:e=>e};function H9(e){let{id:t}=e;return{...e,id:B9(t),transports:e.transports,type:e.type}}function U9(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var W9=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function wle({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new W9({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new W9({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new W9({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new W9({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new W9({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new W9({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new W9({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new W9({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!U9(t))return new W9({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new W9({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new W9({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new W9({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var G9=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},Tle=[`cross-platform`,`platform`];function K9(e){if(e&&!(Tle.indexOf(e)<0))return e}async function Ele(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!V9())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:B9(t.challenge),user:{...t.user,id:B9(t.user.id)},excludeCredentials:t.excludeCredentials?.map(H9)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=G9.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw wle({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){q9(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=z9(e))}catch(e){q9(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=z9(c.getAuthenticatorData())}catch(e){q9(`getAuthenticatorData()`,e)}return{id:o,rawId:z9(s),response:{attestationObject:z9(c.attestationObject),clientDataJSON:z9(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:K9(a.authenticatorAttachment)}}function q9(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function Dle(){if(!V9())return J9.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?J9.stubThis(new Promise(e=>e(!1))):J9.stubThis(e.isConditionalMediationAvailable())}var J9={stubThis:e=>e};function Ole({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new W9({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new W9({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!U9(t))return new W9({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new W9({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new W9({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function kle(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!V9())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(H9));let a={...t,challenge:B9(t.challenge),allowCredentials:i},o={};if(n){if(!await Dle())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=G9.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Ole({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=z9(u.userHandle)),{id:c,rawId:z9(l),response:{authenticatorData:z9(u.authenticatorData),clientDataJSON:z9(u.clientDataJSON),signature:z9(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:K9(s.authenticatorAttachment)}}function Ale(e){return e===null||!e.startsWith(`/`)||e.startsWith(`//`)||e===`/login`?`/`:e}function Y9(e){if(e instanceof fj){if(e.code===`CHALLENGE_EXPIRED`)return`登录挑战已过期,请重试`;if(e.code===`PASSKEY_AUTH_FAILED`)return`Passkey 登录失败;如果设备已被撤销,请重新配对`;if(e.code===`WEBAUTHN_NOT_CONFIGURED`||e.code===`ORIGIN_INVALID`)return`当前来源不能使用 Passkey,请改用 localhost / HTTPS 或使用配对码`}return e instanceof DOMException&&e.name===`NotAllowedError`?`已取消 Passkey 登录`:pj(e,`登录失败,请重试。`)}function jle(){let[e]=Vy(),t=Ale(e.get(`returnTo`)),n=JW(),r=YW(),i=Eh(),[a,o]=(0,h.useState)(null),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),d=V9(),f=n.data!==void 0&&window.location.origin===n.data.auth.passkeyOrigin,p=n.data?.initialized===!0&&n.data.auth.passkeyEnabled&&f&&d,m=(0,h.useCallback)(async()=>{try{let e=await Y(`/api/webauthn/authentication/options`,{method:`POST`});return o(e),e}catch(e){return u(Y9(e)),null}},[]);if((0,h.useEffect)(()=>{p&&m()},[p,m]),r.data)return(0,g.jsx)(gy,{to:t,replace:!0});let _=async()=>{c(!0),u(null);try{let e=a??await m();if(e===null)return;let t=await kle({optionsJSON:e.options});await Y(`/api/webauthn/authentication/verify`,{method:`POST`,body:{challengeId:e.challengeId,response:t}}),await i.invalidateQueries({queryKey:[`session`]}),await i.invalidateQueries({queryKey:[`bootstrap`]})}catch(e){u(Y9(e)),e instanceof fj&&e.code===`CHALLENGE_EXPIRED`&&(o(null),await m())}finally{c(!1)}};return(0,g.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-canvas px-6 py-10 text-ink`,children:(0,g.jsxs)(`section`,{className:`w-full max-w-[420px] rounded-[18px] border border-line bg-surface p-7 shadow-card`,children:[(0,g.jsxs)(`div`,{className:`mb-6 flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`inline-flex size-7 items-center justify-center rounded-md bg-accent text-[13px] font-semibold text-accent-ink`,children:`L`}),(0,g.jsx)(`span`,{className:`text-[15px] font-semibold tracking-tight`,children:`Larness`}),(0,g.jsx)(`span`,{className:`ml-auto text-xs text-ink-3`,children:n.data?.app.version})]}),(0,g.jsx)(`h1`,{className:`text-lg font-semibold`,children:`使用 Passkey 登录`}),(0,g.jsx)(`p`,{className:`mt-1 text-sm text-ink-2`,children:`使用 Face ID、指纹或系统 PIN 解锁当前工作空间。`}),n.data?null:(0,g.jsx)(`p`,{className:`mt-6 text-sm text-ink-2`,children:n.isError?`无法连接本机服务`:`正在读取工作空间状态…`}),n.data&&!n.data.initialized?(0,g.jsxs)(`p`,{className:`mt-6 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:[`工作空间尚未初始化。请先在本机运行 `,(0,g.jsx)(`code`,{children:`pnpm run tui`}),` 完成初始化。`]}):null,n.data?.initialized===!0&&!f?(0,g.jsxs)(`p`,{className:`mt-6 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:[`当前来源 `,(0,g.jsx)(`code`,{children:window.location.origin}),` 不是 canonical origin`,` `,(0,g.jsx)(`code`,{children:n.data.auth.passkeyOrigin}),`。请改用 localhost 或 HTTPS 域名,或使用下方的“使用配对码”入口。`]}):null,n.data?.initialized===!0&&f&&!d?(0,g.jsx)(`p`,{className:`mt-6 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:`当前浏览器不支持 WebAuthn / Passkey,请使用配对码入口。`}):null,n.data?.initialized===!0&&!n.data.auth.passkeyEnabled?(0,g.jsx)(`p`,{className:`mt-6 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:`WebAuthn 配置无效(RP ID / Origin),Passkey 不可用;请使用配对码入口。`}):null,p?(0,g.jsx)(`button`,{type:`button`,className:`mt-6 flex h-10 w-full items-center justify-center rounded-md bg-accent px-4 text-sm font-medium text-accent-ink transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,disabled:s||a===null,onClick:()=>void _(),children:s?`正在验证…`:a===null?`正在准备…`:`使用 Passkey 登录`}):null,(0,g.jsx)(Yc,{message:l,onDismiss:()=>u(null)}),(0,g.jsxs)(`div`,{className:`mt-5 flex items-center justify-between text-sm`,children:[(0,g.jsx)(Ly,{className:`text-accent hover:underline`,to:`/pair`,children:`使用配对码`}),p&&a===null?(0,g.jsx)(`button`,{type:`button`,className:`text-ink-2 hover:text-ink`,onClick:()=>void m(),children:`重试准备`}):null]})]})})}var X9=`larness.pairing.request`;function Z9(){try{window.sessionStorage.removeItem(X9)}catch{}}function Mle(){try{let e=window.sessionStorage.getItem(X9);if(e===null)return null;let t=JSON.parse(e);return typeof t.requestId==`string`&&typeof t.shortCode==`string`&&typeof t.pollToken==`string`&&typeof t.expiresAt==`number`&&t.expiresAt>Date.now()+1e3?t:(Z9(),null)}catch{return Z9(),null}}function Nle(e){try{window.sessionStorage.setItem(X9,JSON.stringify(e))}catch{}}function Q9(e){if(e instanceof fj){if(e.code===`NOT_INITIALIZED`)return`工作空间尚未初始化。请先在本机运行 pnpm run tui。`;if(e.code===`CODE_INVALID`){let t=e.details?.attemptsLeft;return t===void 0?`配对码不正确`:`配对码不正确,剩余 ${t} 次尝试`}return e.code===`PAIRING_DENIED`?`本机已拒绝本次配对申请`:e.code===`PAIRING_EXPIRED`?`配对申请或配对码已过期,请重新申请`:e.code===`RATE_LIMITED`?`尝试过于频繁,请稍后再试`:e.code===`ENROLLMENT_EXPIRED`?`Passkey 注册窗口已过期,请重新配对`:e.code===`ORIGIN_INVALID`||e.code===`WEBAUTHN_NOT_CONFIGURED`?`当前来源不能注册 Passkey,请改用 localhost / HTTPS,或在 TUI 中选择“允许本次”`:e.code===`PASSKEY_REGISTRATION_FAILED`?`Passkey 注册失败,请重试或重新配对`:e.message}return e instanceof DOMException&&e.name===`NotAllowedError`?`已取消 Passkey 注册`:e instanceof Error?e.message:`操作失败`}function Ple(){let e=YW(),t=Eh(),n=(0,h.useRef)(!1),[r,i]=(0,h.useState)(`creating`),[a,o]=(0,h.useState)(null),[s,c]=(0,h.useState)(null),[l,u]=(0,h.useState)(``),[d,f]=(0,h.useState)(null),[p,m]=(0,h.useState)(null),[_,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(!1),x=V9();(0,h.useEffect)(()=>{e.data&&Z9()},[e.data]);let S=(0,h.useCallback)(async()=>{Z9(),i(`creating`),v(null),o(null),f(null),m(null),c(null),u(``);try{let e=await Y(`/api/pairing/requests`,{method:`POST`,body:{clientLabel:navigator.userAgent.slice(0,100)}});Nle(e),o(e),i(`waiting`)}catch(e){v(Q9(e)),i(`error`)}},[]);(0,h.useEffect)(()=>{if(n.current)return;n.current=!0;let e=Mle();e===null?S():(o(e),i(`waiting`))},[S]),(0,h.useEffect)(()=>{if(r!==`waiting`||a===null)return;let e=!1,n=setInterval(()=>{(async()=>{try{let n=await Y(`/api/pairing/requests/${a.requestId}`,{headers:{"x-pairing-token":a.pollToken}});if(e)return;n.status===`approved`?(c(n.decision),i(`code`)):n.status===`enrollment_pending`?(c(`trust`),i(`enrollment`)):n.status===`denied`?(Z9(),v(`本机已拒绝本次配对申请`),i(`error`)):n.status===`expired`?(Z9(),v(`配对申请已过期,请重新申请`),i(`error`)):n.status===`redeemed`&&(Z9(),await t.invalidateQueries({queryKey:[`session`]}),i(`error`),v(`该申请已完成配对,请返回工作台`))}catch(t){e||(t instanceof fj&&t.code===`NOT_FOUND`&&Z9(),v(Q9(t)),i(`error`))}})()},2e3);return()=>{e=!0,clearInterval(n)}},[r,a,t]);let C=(0,h.useCallback)(async()=>{try{let e=await Y(`/api/webauthn/registration/options`,{method:`POST`});return m(e),e}catch(e){return v(Q9(e)),null}},[]);if((0,h.useEffect)(()=>{r===`enrollment`&&x&&C()},[r,x,C]),e.data)return(0,g.jsx)(gy,{to:`/`,replace:!0});let w=async e=>{if(e.preventDefault(),a!==null){b(!0),v(null);try{let e=await Y(`/api/pairing/redeem`,{method:`POST`,body:{requestId:a.requestId,code:l.trim()}});if(e.status===`session`){Z9(),await t.invalidateQueries({queryKey:[`session`]}),await t.invalidateQueries({queryKey:[`bootstrap`]}),i(`error`),v(`配对成功,正在进入工作台…`),await t.refetchQueries({queryKey:[`session`]});return}f(e),i(`enrollment`)}catch(e){v(Q9(e))}finally{b(!1)}}},T=async()=>{if(p!==null){b(!0),v(null);try{let e=await Ele({optionsJSON:p.options});await Y(`/api/webauthn/registration/verify`,{method:`POST`,body:{challengeId:p.challengeId,response:e}}),Z9(),await t.invalidateQueries({queryKey:[`session`]}),await t.invalidateQueries({queryKey:[`bootstrap`]}),v(`Passkey 已创建,正在进入工作台…`),await t.refetchQueries({queryKey:[`session`]})}catch(e){v(Q9(e)),e instanceof fj&&(e.code===`CHALLENGE_EXPIRED`||e.code===`PASSKEY_REGISTRATION_FAILED`||e.code===`ENROLLMENT_EXPIRED`)&&(m(null),await C())}finally{b(!1)}}};return(0,g.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-canvas px-6 py-10 text-ink`,children:(0,g.jsxs)(`section`,{className:`w-full max-w-[460px] rounded-[18px] border border-line bg-surface p-7 shadow-card`,"data-request-id":a?.requestId??``,"data-stage":r,children:[(0,g.jsxs)(`div`,{className:`mb-6 flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`inline-flex size-7 items-center justify-center rounded-md bg-accent text-[13px] font-semibold text-accent-ink`,children:`L`}),(0,g.jsx)(`span`,{className:`text-[15px] font-semibold tracking-tight`,children:`Larness`})]}),(0,g.jsx)(`h1`,{className:`text-lg font-semibold`,children:`配对这台浏览器`}),(0,g.jsx)(`p`,{className:`mt-1 text-sm text-ink-2`,children:`申请需要在本机 TUI 中批准;配对码只显示一次。`}),r===`creating`?(0,g.jsx)(`p`,{className:`mt-6 text-sm text-ink-2`,children:`正在创建配对申请…`}):null,r===`waiting`&&a?(0,g.jsxs)(`div`,{className:`mt-6`,children:[(0,g.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-ink-3`,children:`短编号`}),(0,g.jsx)(`p`,{className:`mt-1 font-mono text-3xl font-semibold tracking-[0.18em] text-ink`,children:a.shortCode}),(0,g.jsx)(`p`,{className:`mt-3 text-sm text-ink-2`,children:`等待本机 TUI 批准。批准后在此输入一次性配对码。`}),(0,g.jsx)(`button`,{type:`button`,className:`mt-4 text-sm text-accent hover:underline`,onClick:()=>void S(),children:`重新申请`})]}):null,r===`code`&&a?(0,g.jsxs)(`form`,{className:`mt-6`,onSubmit:e=>void w(e),children:[(0,g.jsxs)(`p`,{className:`text-sm text-ink-2`,children:[`已获批准(`,s===`trust`?`始终允许,需要创建 Passkey`:`允许本次`,`)。 请输入 TUI 显示的配对码。`]}),(0,g.jsx)(`label`,{className:`mt-4 block text-xs font-medium text-ink-2`,htmlFor:`pair-code`,children:`配对码`}),(0,g.jsx)(mm,{id:`pair-code`,className:`mt-1 h-11 px-3 font-mono text-lg tracking-[0.14em]`,value:l,onChange:e=>u(e.target.value.toUpperCase()),placeholder:`XXXXX-XXXXX`,autoComplete:`one-time-code`}),(0,g.jsx)(`button`,{type:`submit`,className:`mt-4 flex h-10 w-full items-center justify-center rounded-md bg-accent px-4 text-sm font-medium text-accent-ink transition hover:opacity-90 disabled:opacity-50`,disabled:y||l.trim().length===0,children:y?`正在兑换…`:`兑换配对码`}),(0,g.jsx)(`button`,{type:`button`,className:`mt-3 text-sm text-ink-2 hover:text-ink`,onClick:()=>void S(),children:`重新申请`})]}):null,r===`enrollment`?(0,g.jsxs)(`div`,{className:`mt-6`,children:[(0,g.jsx)(`p`,{className:`text-sm text-ink-2`,children:`配对码已兑换。必须在窗口过期前创建 Passkey,之后才能进入工作台。`}),d===null?(0,g.jsx)(`p`,{className:`mt-2 text-xs text-ink-3`,children:`已恢复同一配对申请的注册窗口。`}):null,x?null:(0,g.jsx)(`p`,{className:`mt-3 rounded-md bg-surface-2 p-3 text-sm text-ink-2`,children:`当前浏览器不支持 WebAuthn。请重新配对,并在 TUI 中选择“允许本次”。`}),x?(0,g.jsx)(`button`,{type:`button`,className:`mt-4 flex h-10 w-full items-center justify-center rounded-md bg-accent px-4 text-sm font-medium text-accent-ink transition hover:opacity-90 disabled:opacity-50`,disabled:y||p===null,onClick:()=>void T(),children:y?`正在创建…`:p===null?`正在准备…`:`创建 Passkey`}):null,(0,g.jsx)(`button`,{type:`button`,className:`mt-3 text-sm text-ink-2 hover:text-ink`,onClick:()=>void S(),children:`重新配对`})]}):null,r===`error`?(0,g.jsxs)(`div`,{className:`mt-6`,children:[(0,g.jsx)(`button`,{type:`button`,className:`mt-2 flex h-10 w-full items-center justify-center rounded-md bg-accent px-4 text-sm font-medium text-accent-ink transition hover:opacity-90`,onClick:()=>void S(),children:`重新申请`}),(0,g.jsx)(Ly,{className:`mt-3 inline-block text-sm text-ink-2 hover:text-ink`,to:`/login`,children:`返回登录`})]}):null,(0,g.jsx)(Yc,{message:_,onDismiss:()=>v(null)}),a?(0,g.jsxs)(`p`,{className:`mt-5 text-xs text-ink-3`,children:[`申请有效期至 `,new Date(a.expiresAt).toLocaleTimeString(),`;配对码在其他设备上不显示。`]}):null]})})}function Fle(){return XW(),(0,g.jsxs)(yy,{children:[(0,g.jsx)(_y,{path:`/`,element:(0,g.jsx)(Sle,{})}),(0,g.jsx)(_y,{path:`/login`,element:(0,g.jsx)(jle,{})}),(0,g.jsx)(_y,{path:`/pair`,element:(0,g.jsx)(Ple,{})}),(0,g.jsx)(_y,{path:`*`,element:(0,g.jsx)(gy,{to:`/`,replace:!0})})]})}function Ile(){return(0,g.jsx)(Fle,{})}var Lle=c({}),$9=document.getElementById(`root`);if(!$9)throw Error(`Root element not found`);(0,qy.createRoot)($9).render((0,g.jsx)(h.StrictMode,{children:(0,g.jsx)(x,{children:(0,g.jsx)(Dh,{client:aM,children:(0,g.jsx)(Ch,{delayDuration:250,children:(0,g.jsx)(Iy,{children:(0,g.jsx)(Ile,{})})})})})}));export{c as a,f as i,S as n,u as o,m as r,Lle as t};
|