@x-otto/tui 0.0.1-alpha.6-debug → 0.0.1-alpha.8
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/README.md +60 -60
- package/dist/{Tabable-Ci-i32jC.d.ts → Tabable-CdaKqnEq.d.ts} +84 -24
- package/dist/Tabable-CdaKqnEq.d.ts.map +1 -0
- package/dist/WizardDialog-zXXC_W25.js +10 -0
- package/dist/WizardDialog-zXXC_W25.js.map +1 -0
- package/dist/compat.js +1 -1
- package/dist/{i18n-BREWHEWk.js → i18n-KiLOGLXu.js} +11 -11
- package/dist/i18n-KiLOGLXu.js.map +1 -0
- package/dist/index.d.ts +20 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +77 -77
- package/dist/index.js.map +1 -1
- package/dist/standalone.d.ts +21 -1
- package/dist/standalone.d.ts.map +1 -1
- package/dist/standalone.js +1 -1
- package/package.json +1 -1
- package/dist/Tabable-Ci-i32jC.d.ts.map +0 -1
- package/dist/WizardDialog-DTypQTfU.js +0 -12
- package/dist/WizardDialog-DTypQTfU.js.map +0 -1
- package/dist/i18n-BREWHEWk.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{n as e}from"./i18n-KiLOGLXu.js";import{createRequire as t}from"node:module";import n from"string-width";import r from"wrap-ansi";import i,{createContext as a,createElement as o,useCallback as s,useContext as c,useEffect as l,useMemo as u,useRef as d,useState as f}from"react";import{Fragment as p,jsx as m,jsxs as h}from"react/jsx-runtime";import{Box as g,Text as _,useCursor as v,useInput as y}from"ink";import{isShadowModeEnabled as b}from"@x-otto/env";var x=t(import.meta.url);const S={ink:`#0D0E11`,carbon:`#16181D`,white:`#F4F3EF`,brandNavy:`#14348C`,brandPurple:`#A28EF9`,brandInk:`#12152B`,purpleBright:`#D1BCFF`,purpleDim:`#4F3E8C`,navyBright:`#2D59C8`,navyDim:`#0F2A73`,comment:`#9498B8`},C={success:`#98C379`,error:`#E06C75`,warning:`#E5C07B`,info:`#61AFEF`,special:`#C678DD`},w={brand:S.brandPurple,brandShimmer:S.purpleBright,accent:S.brandPurple,accentDim:S.purpleDim,accentBright:S.purpleBright,text:void 0,inactive:S.comment,secondary:`#C8CBDB`,subtle:S.comment,replyPrefix:`#8F7FD6`,success:`#7EE095`,error:`#FF9592`,warning:`#FFC966`,special:`#DD78C9`,suggestion:`#6187EF`,permission:`#6187EF`,codeText:`#56B6C2`,diffAdd:`#7EE095`,diffRemove:`#FF9592`,diffAddBg:`#183820`,diffRemoveBg:`#3C181A`,panelBorder:S.comment,overlayBg:S.brandInk,tagBg:`#262A3D`,toolText:`#C8CBDB`,focusBorder:`#4D7CFF`,selection:S.brandPurple};function T(e){return e===`high`?w.error:e===`medium`?w.warning:w.success}const E=/^(zh|ja|ko)[_-]/i,D=(()=>{for(let e of[`LC_ALL`,`LC_CTYPE`,`LANG`]){let t=process.env[e];if(t&&E.test(t))return!0}return!1})(),O={countAnsiEscapeCodes:!1};D&&(O.ambiguousIsNarrow=!1);const k=(e,t)=>`[${e};${t}r`,A=()=>`\x1B[r`,j=(e,t)=>`[${t+1};${e+1}H`,M=()=>`\x1B[K`,ee=()=>`\x1B[J`,te=()=>`\x1B[0m`,N=()=>`\x1B7`,P=()=>`\x1B8`,F=/(?:https?:\/\/|www\.)\S+|\b[\w-]+(?:\.[\w-]+)+\/\S+/i,I=RegExp(`\x1B\\][^\\x07\x1B]*(?:\\x07|\x1B\\\\)|\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),ne=e=>e.replace(I,``),L=e=>n(e,O),R=e=>F.test(ne(e));function re(e,t,n=`pre`){if(n===`terminal`||t<=0)return[e];if(e===``)return[``];let i=r(e,t,{hard:!R(e),trim:!1,wordWrap:!0});return i.length===0?[``]:i.split(`
|
|
2
|
+
`)}function z(e,t,n=`pre`){let r=[];for(let i of e)r.push(...re(i,t,n));return r}function ie(e,t){let n=Math.max(1,Math.ceil(L(e)/t)),r=``;if(n>1){r+=N();for(let e=1;e<n;e++)r+=`[1B[1G${M()}`;r+=P()}return r+=M()+e+te(),r}function ae(e,t,n,r){let i=Math.max(1,t.rows-t.liveTop),a=j(0,t.liveTop)+ee()+j(0,t.liveTop);e.forEach((e,t)=>{t>0&&(a+=`\r
|
|
3
|
+
`),a+=ie(e,n)});for(let e=0;e<i;e++)a+=`\r\n${M()}`;return a+=j(r.x,r.y),a}function oe(e,t){let n=Math.max(1,t.columns),r=t.wrap??`pre`,i=t.mode??`standard`,a=t.cursor??{x:0,y:t.liveTop},o=z(e,n,r);if(o.length===0)return``;if(i===`raw`||t.liveTop<1)return ae(o,t,n,a);let s=t.liveTop,c=k(1,s)+j(0,s-1);for(let e of o)c+=`\r
|
|
4
|
+
`+ie(e,n);return c+=A()+j(a.x,a.y),c}function se(e,t,n){let r=oe(t,n);r&&e.write(r)}function ce(e=process.env){return e.ZELLIJ?`raw`:`standard`}const B={bullet:`●`,toolResult:`⎿`,thinking:`∴`,quoteBar:`▎`,userPrompt:`>`,commandPrompt:`❯`,hr:`─`,check:`✓`,cross:`✗`,checkboxOff:`☐`,checkboxOn:`☑`,todoPending:`○`,todoActive:`◐`,todoDone:`●`,breatheDim:`○`,breatheBright:`●`,ellipsis:`…`,pointer:`▶`,toggleOn:`◉`,toggleOff:`○`,warn:`⚠`,frozen:`❄`,needsInput:`◑`,statusDot:`●`,itemActive:`▸`,attention:`◆`,sparkline:`▁▂▃▄▅▆▇█`,gaugeFilled:`━`,gaugeRest:`╌`,scrollThumb:`▐`,service:`↕`,edited:`✎`,scheduled:`◷`,clipboard:`✓`,requesting:`↑`,responding:`↓`};function V(){return`${B.pointer} `}function H(){return` `.repeat(L(V()))}const U=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],le=Array.from({length:6},(e,t)=>t/5);[...le,...le.slice(1,-1).reverse()].map(e=>e<.5?B.breatheDim:B.breatheBright);const ue={borderStyle:`single`,borderTop:!0,borderBottom:!0,borderLeft:!1,borderRight:!1},W={borderStyle:`single`,borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1},de={borderStyle:`round`,borderTop:!0,borderBottom:!0,borderLeft:!0,borderRight:!0},G={none:0,tight:1,section:2,loose:4},fe={contentInset:4,borderInset:2},pe=w,me={brand:S.brandNavy,brandShimmer:S.navyBright,accent:S.brandNavy,accentDim:S.navyDim,accentBright:S.navyBright,text:void 0,inactive:`#6B7280`,secondary:`#374151`,subtle:`#6B7280`,replyPrefix:`#5B21B6`,success:`#16A34A`,error:`#DC2626`,warning:`#CA8A04`,special:`#9333EA`,suggestion:`#2563EB`,permission:`#2563EB`,codeText:`#0891B2`,diffAdd:`#16A34A`,diffRemove:`#DC2626`,diffAddBg:`#DCFCE7`,diffRemoveBg:`#FEE2E2`,panelBorder:`#D1D5DB`,overlayBg:`#F9FAFB`,tagBg:`#E5E7EB`,toolText:`#374151`,focusBorder:`#2563EB`,selection:S.brandNavy};function he(e){return e.kind===`builtin`?`builtin`:`extension:${e.extensionId}`}function ge(e){return/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)}function _e(e,t){if(e.kind===`builtin`){let e=t.id??t.localId;if(!e)throw Error(`Builtin theme preset requires id`);return e}let n=t.localId??t.id;if(!n)throw Error(`Extension theme preset requires localId`);if(!ge(n))throw Error(`Invalid extension theme preset localId: ${n}`);return`${e.extensionId}/${n}`}var ve=class{presets=new Map;presetSourceKeys=new Map;register(e,t){let n=_e(e,t),r=this.presets.get(n);if(r){let t=r.source.kind===`builtin`||e.kind===`builtin`;throw Error(t?`Cannot override builtin theme preset: ${n}`:`Duplicate theme preset id: ${n}`)}let i={...t,id:n,source:e};return this.presets.set(n,i),this.presetSourceKeys.set(n,he(e)),i}unregisterBySource(e){if(e.kind===`builtin`)return 0;let t=he(e),n=0;for(let[e,r]of[...this.presetSourceKeys])r===t&&(this.presetSourceKeys.delete(e),this.presets.delete(e)&&(n+=1));return n}get(e){return this.presets.get(e)}list(){return[...this.presets.values()]}resolve(e,t,n){let r=e===`system`?t??`dark`:e,i=n?.[r]??r,a=this.presets.get(i);if(a&&a.appearance===r)return a;let o=this.presets.get(r);if(!o)throw Error(`Missing builtin theme preset fallback for ${r}`);return o}};function ye(){let e=new ve;return e.register({kind:`builtin`},{id:`dark`,label:`Dark`,appearance:`dark`,colors:pe}),e.register({kind:`builtin`},{id:`light`,label:`Light`,appearance:`light`,colors:me}),e}let be=null;function xe(e){be=e}function Se(){return be}const Ce=a({resolvedTheme:`dark`,resolvedAppearance:`dark`,presetId:`dark`,colors:pe,setSystemTheme:()=>{},setPresetSelection:()=>{}});function we({children:e,systemTheme:t,themeRegistry:n,presetSelection:r}){let[i,a]=f(t),[o,s]=f(r);l(()=>(xe({setPresetSelection:s,setSystemTheme:a}),()=>xe(null)),[]);let c=u(()=>n??ye(),[n]).resolve(`system`,i,o),d=c.appearance,p=c.appearance,h=c.colors,g=u(()=>({resolvedTheme:d,resolvedAppearance:p,presetId:c.id,colors:h,setSystemTheme:a,setPresetSelection:s}),[d,p,c.id,h]);return m(Ce.Provider,{value:g,children:e})}function Te(){return c(Ce)}function K(){return c(Ce).colors}function Ee(e){return Buffer.isBuffer(e)?e:Buffer.from(e,`utf8`)}function De(e=process.stdin){let t=e._readableState;if(!t)return;let n=Oe(t.decoder);if(t.decoder=null,t.encoding=null,n&&n.length>0)try{e.unshift(n)}catch{}}function Oe(e){if(!e?.lastNeed||!e.lastChar||typeof e.lastTotal!=`number`)return null;let t=e.lastTotal-e.lastNeed;return t<=0?null:Buffer.from(e.lastChar.subarray(0,t))}function ke(e=200){return new Promise(t=>{if(!process.stdin.isTTY||!process.stdout.isTTY){t(void 0);return}let n=setTimeout(()=>{o(),t(void 0)},e),r=process.stdin.isRaw;process.stdin.setRawMode(!0),process.stdin.resume();let i=[],a=e=>{i.push(Ee(e));let n=Buffer.concat(i).toString().match(/\x1b\]11;rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)/);if(n){o();let e=parseInt(n[1].slice(0,2),16),r=parseInt(n[2].slice(0,2),16),i=parseInt(n[3].slice(0,2),16);t(.2126*e+.7152*r+.0722*i<128?`dark`:`light`)}},o=()=>{clearTimeout(n),process.stdin.removeListener(`data`,a),process.stdin.setRawMode(r??!1),process.stdin.pause()};process.stdin.on(`data`,a),process.stdout.write(`\x1B]11;?\x07`)})}function Ae(){return process.platform===`darwin`?`macos`:process.platform===`win32`?`windows`:`linux`}const q={enter:`↵`,up:`↑`,down:`↓`,left:`←`,right:`→`,esc:`Esc`,tab:`⇥`};function je(e,t=Ae()){let n=e.length===1?e.toUpperCase():e;return t===`macos`?`⌃+${n}`:`Ctrl+${n}`}function Me(e=Ae()){return e===`macos`?`⌘+${q.enter}`:`Ctrl+${q.enter}`}function Ne(e=Ae()){return`⇧+${q.enter}`}function Pe({header:e,children:t,footer:n,paddingY:r=G.none,maxHeight:i,borderStyle:a}){let o=K();return h(g,{...de,borderStyle:a??de.borderStyle,borderColor:o.panelBorder,backgroundColor:o.overlayBg,paddingX:G.tight,paddingY:r,marginTop:G.tight,maxHeight:i,flexDirection:`column`,children:[e,t,n&&m(g,{marginTop:G.tight,children:m(_,{dimColor:!0,children:n})})]})}function Fe({children:e,color:t}){let n=K();return m(_,{color:t??n.secondary,bold:!0,children:e})}function Ie({children:e}){return m(_,{color:K().secondary,children:e})}function Le({items:e,dim:t=!1}){return m(_,{dimColor:t||void 0,children:e.map(([e,t],n)=>h(_,{children:[n>0?` · `:``,m(Ie,{children:e}),` ${t}`]},`${e}-${n}`))})}const Re=a({focused:!1,id:``,disabled:!1,focusStyle:`pointer`});function ze(){return c(Re)}const Be=B.pointer;let Ve=0;var He=class{entries=new Map;focusMemory=new Map;register(e){this.entries.set(e.id,e)}unregister(e){this.entries.delete(e)}getTabable(e){return[...this.entries.values()].filter(t=>t.routePath===e&&t.tabIndex>=0&&!t.disabled).sort((e,t)=>e.tabIndex-t.tabIndex||e.order-t.order)}getInitialFocus(e){let t=this.focusMemory.get(e);if(t&&this.entries.has(t)&&!this.entries.get(t).disabled)return t;let n=[...this.entries.values()].filter(t=>t.routePath===e&&!t.disabled).find(e=>e.autoFocus);return n?n.id:this.getTabable(e)[0]?.id??null}next(e,t){let n=this.getTabable(t);return n.length===0?null:n[(n.findIndex(t=>t.id===e)+1)%n.length]?.id??null}prev(e,t){let n=this.getTabable(t);return n.length===0?null:n[(n.findIndex(t=>t.id===e)-1+n.length)%n.length]?.id??null}rememberFocus(e,t){this.focusMemory.set(e,t)}get(e){return this.entries.get(e)}static nextOrder(){return Ve++}};const Ue=a({routePath:`/`,currentPath:`/`,activeId:null,registry:new He,hasRouter:!1});let We=0;function Ge(e={}){let{tabIndex:t=0,disabled:n=!1,autoFocus:r=!1,onAction:i,onEscape:a,onTab:o,id:s}=e,u=d(s??`tabable-${++We}`).current,f=c(Ue),p=f.activeId===u&&!n,m=d(i);m.current=i;let h=d(a);h.current=a;let g=d(o);g.current=o;let _=d(f);return _.current=f,l(()=>{let e={id:u,tabIndex:t,disabled:n,order:He.nextOrder(),routePath:f.routePath,autoFocus:r,get onAction(){return m.current},get onEscape(){return h.current},get onTab(){return g.current}};return f.registry.register(e),()=>{let e=_.current;if(e.registry.unregister(u),e.activeId===u){let t=e.registry.getInitialFocus(e.routePath);Promise.resolve().then(()=>{let e=_.current;e.activeId===u&&e.onFocusFallback?.(t)})}}},[u,t,n,f.routePath,r]),{focused:p,id:u}}function Ke({tabIndex:e=0,disabled:t=!1,autoFocus:n=!1,onAction:r,onEscape:i,id:a,focusStyle:o=`pointer`,children:s}){let{focused:c,id:l}=Ge({tabIndex:e,disabled:t,autoFocus:n,onAction:r,onEscape:i,id:a}),d=u(()=>({focused:c,id:l,disabled:t,focusStyle:o}),[c,l,t,o]);return m(Re.Provider,{value:d,children:m(qe,{focused:c,disabled:t,style:o,children:s})})}function qe({focused:e,disabled:t,style:n,children:r}){let i=K();if(n===`none`||t)return m(p,{children:r});switch(n){case`pointer`:return h(g,{flexDirection:`row`,children:[m(_,{color:e?i.selection:i.inactive,bold:e,children:e?`${Be} `:` `}),m(g,{flexDirection:`column`,children:m(_,{color:e?i.selection:void 0,bold:e,children:r})})]});case`highlight`:return m(_,{color:e?i.selection:void 0,bold:e,children:r});case`background`:return e?h(_,{backgroundColor:`#4D7CFF`,color:`#FFFFFF`,bold:!0,children:[` `,r,` `]}):h(_,{color:i.inactive,children:[`[ `,r,` ]`]});case`border`:return m(g,{borderStyle:`single`,borderColor:e?i.selection:i.inactive,children:r});case`cursor`:return m(p,{children:r});default:return m(p,{children:r})}}var Je=class{entries=[];register(e,t,n){let r={id:e,handler:t,priority:n};return this.entries.push(r),this.entries.sort((e,t)=>t.priority-e.priority),()=>{this.entries=this.entries.filter(e=>e!==r)}}dispatch(e,t){for(let n of this.entries)if(n.handler(e,t))return!0;return!1}debug(){return this.entries.map(e=>`[${e.priority}] ${e.id}`)}};const Ye=100,Xe=50,Ze=10,Qe=a(null);function $e({children:e}){let t=i.useMemo(()=>new Je,[]);return m(Qe.Provider,{value:{focusBus:t},children:e})}function et(){let e=c(Qe);if(!e)throw Error(`useFocusBus() must be used inside <FocusBusProvider>`);return e.focusBus}function tt(){return c(Qe)?.focusBus??null}function nt(e,t,n){let r=tt(),i=d(t);i.current=t;let a=d(n??`tabable-input-${++it}`).current;y((t,n)=>{!r&&e&&i.current(t,n)},{isActive:!r&&e}),l(()=>{if(!(!r||!e))return r.register(a,(e,t)=>i.current(e,t),100)},[e,r,a])}function rt(e,t,n){let r=tt(),i=d(t);i.current=t;let a=n?.isActive??!0;y((e,t)=>{!r&&a&&i.current(e,t)},{isActive:!r&&a}),l(()=>{if(!(!r||!a))return r.register(e,(e,t)=>i.current(e,t),1e3)},[r,e,a])}let it=0;function at(e,t,n,r){let i=tt(),a=c(Ue),o=d(t);o.current=t;let s=r?.ignoreRoute||!a.hasRouter||a.routePath===a.currentPath||a.currentPath.startsWith(`${a.routePath}/`),u=(r?.isActive??!0)&&s;y((e,t)=>{!i&&u&&o.current(e,t)},{isActive:!i&&u}),l(()=>{if(!(!i||!u))return i.register(e,(e,t)=>o.current(e,t),n)},[i,e,u,n])}function J(e,t,n){at(e,t,10,n)}function ot(e,t,n){at(e,t,200,{...n,ignoreRoute:!0})}function st(e,t,n){let r=d(t);r.current=t,at(e,()=>(r.current(),!1),0,{...n,ignoreRoute:!0})}function ct(e,t,n){at(e,t,0,n)}function lt(e){let{items:t,onPick:n,direction:r=`vertical`,activeIndex:i,onActiveChange:a,escapeIndex:o,tabIndex:s=0,id:l}=e,u=t.length,d=i!==void 0,[p,m]=f(0),h=d?i:p,g=e=>{d||m(e),a?.(e)},_=c(Ue).hasRouter===!0,{focused:v}=Ge({tabIndex:s,disabled:!_||s<0,id:l,onAction:()=>{let e=t[h];return e&&!e.disabled&&n(h),!0}}),y=e=>{if(u===0)return;let n=(h+e+u)%u;for(let r=0;r<u&&t[n]?.disabled;r++)n=(n+e+u)%u;g(n)},b=(e,i)=>{let a=r===`vertical`?i.upArrow:i.leftArrow,s=r===`vertical`?i.downArrow:i.rightArrow;if(a)return y(-1),!0;if(s)return y(1),!0;if(i.return){let e=t[h];return e&&!e.disabled&&n(h),!0}if(i.escape)return o===void 0?!1:(n(o),!0);if(e>=`1`&&e<=`9`){let r=e.charCodeAt(0)-49;return r<u&&!t[r]?.disabled?(n(r),!0):!1}let c=e.toLowerCase(),l=t.findIndex(e=>e.shortcut===c&&!e.disabled);return l>=0?(n(l),!0):!1};return nt(v&&_,b),J(`roving-${l??t.map(e=>e.key).join(`-`)}`,b,{isActive:!v||!_}),{active:h,focused:v}}function ut(e,t){switch(e){case void 0:case`accent`:return t.accent;case`amber`:return t.warning;case`red`:return t.error;case`green`:return t.success;case`gray`:return t.inactive;default:return e}}function dt(e){return null}dt.displayName=`Menu.Item`;function ft(e){let t=[];return i.Children.forEach(e,e=>{i.isValidElement(e)&&e.type.displayName===`Menu.Item`&&t.push(e.props)}),t}function pt({children:e,onPick:t,activeIndex:n,onActiveChange:r,escapeIndex:i,tabIndex:a=0,id:s}){let c=K(),l=ft(e),{active:u}=lt({items:l.map((e,t)=>({key:`${t}`,shortcut:e.shortcut,disabled:e.disabled})),onPick:t,direction:`vertical`,activeIndex:n,onActiveChange:r,escapeIndex:i,tabIndex:a,id:s});return o(g,{flexDirection:`column`},...l.map((e,t)=>{let n=t===u,r=o(_,{color:e.disabled?c.inactive:n?ut(e.color,c):c.inactive,bold:n,dimColor:e.disabled},`${n?B.pointer:` `} ${t+1}. ${e.label}`);return e.detail?o(g,{key:`item-${t}`,flexDirection:`column`},r,o(g,{marginLeft:5},o(_,{color:c.inactive,dimColor:!0},e.detail))):o(g,{key:`item-${t}`,flexDirection:`column`},r)}))}pt.displayName=`Menu.Root`;const Y={Root:pt,Item:dt},mt=new Map;function ht(e){let t=e.includes(` `)?e.replace(/\t/g,` `):e;return D?n(t,{ambiguousIsNarrow:!1}):n(t)}function gt(e){if(e.length>0&&e.length<=16){let t=mt.get(e);if(t!==void 0)return t;let n=ht(e);return mt.size<4096&&mt.set(e,n),n}return ht(e)}const _t=new Intl.Segmenter(`en`,{granularity:`grapheme`}),vt=new Intl.Segmenter(`en`,{granularity:`word`}),X=/\[(?:@paste:(?:#\d+(?:\s+\+\d+\s+lines)?|image #\d+)|@(?:file|agent|skill|mcp|person|plugin|model):[^\]]+)\]/g;function yt(e){if(/^\[@paste:/.test(e))return`paste`;let t=e.match(/^\[@(file|agent|skill|mcp|person|plugin|model):/);return t?t[1]:`unknown`}function bt(e){let t=e.match(/^\[@paste:#(\d+)/);return t?Number.parseInt(t[1],10):void 0}function xt(e,t){X.lastIndex=0;let n,r=null;for(;(n=X.exec(e))!==null;)n.index+n[0].length===t&&(r={start:n.index,end:n.index+n[0].length,text:n[0]});return r}function St(e,t){X.lastIndex=0;let n;for(;(n=X.exec(e))!==null;)if(t>n.index&&t<n.index+n[0].length)return{start:n.index,end:n.index+n[0].length,text:n[0]};return null}function Ct(e,t){X.lastIndex=0;let n;for(;(n=X.exec(e))!==null;)if(n.index===t)return{start:n.index,end:n.index+n[0].length,text:n[0]};return null}function wt(e,t){let n=St(e,t);return n?n.start:t}function Tt(e){return[..._t.segment(e)]}var Z=class{text;columns;lines;_graphemes;_wordBreaks;constructor(e,t){let n=e.normalize(`NFC`);this.text=n===e?e:n,this.columns=Math.max(1,t),this.lines=this.text===``?[``]:this.text.split(`
|
|
5
|
+
`)}get graphemeList(){return this._graphemes||=Tt(this.text),this._graphemes}get wordBreaks(){if(!this._wordBreaks){let e=[0];for(let t of vt.segment(this.text))t.isWordLike&&t.index>0&&e.push(t.index);e.push(this.text.length),this._wordBreaks=e}return this._wordBreaks}get lineCount(){return this.lines.length}offsetToLineCol(e){let t=e;for(let e=0;e<this.lines.length;e++){let n=this.lines[e].length+1;if(t<n)return{line:e,col:gt(this.lines[e].slice(0,t))};t-=n}let n=this.lines.length-1;return{line:n,col:gt(this.lines[n])}}lineColToOffset(e,t){if(e>=this.lines.length)return this.text.length;let n=0;for(let t=0;t<e;t++)n+=this.lines[t].length+1;let r=this.lines[e];if(t<=0)return n;if(t>=gt(r))return n+r.length;let i=0;for(let e of Tt(r)){let r=gt(e.segment);if(i+r>t)return n+e.index;i+=r}return n+r.length}},Et=class e{measuredText;offset;selection;constructor(e,t,n=0){this.measuredText=e,this.offset=Math.max(0,Math.min(t,e.text.length)),this.selection=n}static fromText(t,n,r=0){return new e(new Z(t,n),r)}static fromCursor(t,n){return new e(n!==void 0&&n!==t.columns?new Z(t.text,n):t.measuredText,t.offset,t.selection)}get text(){return this.measuredText.text}get columns(){return this.measuredText.columns}get position(){return this.measuredText.offsetToLineCol(this.offset)}get hasSelection(){return this.selection!==0}equals(e){return this.offset===e.offset&&this.measuredText===e.measuredText}right(){if(this.offset>=this.text.length)return this;let t=St(this.text,this.offset+1);if(t&&this.offset<=t.start)return new e(this.measuredText,t.end);for(let t of this.measuredText.graphemeList)if(t.index>this.offset)return new e(this.measuredText,t.index);return new e(this.measuredText,this.text.length)}left(){if(this.offset<=0)return this;let t=St(this.text,this.offset-1);if(t)return new e(this.measuredText,t.start);let n=null;for(let e of this.measuredText.graphemeList){if(e.index>=this.offset)break;n=e}return new e(this.measuredText,n?.index??0)}up(){let t=this.position;if(t.line<=0)return this;let n=this.measuredText.lineColToOffset(t.line-1,t.col);return new e(this.measuredText,wt(this.text,n))}down(){let t=this.position;if(t.line>=this.measuredText.lineCount-1)return this;let n=this.measuredText.lineColToOffset(t.line+1,t.col);return new e(this.measuredText,wt(this.text,n))}prevWord(){for(let t=this.measuredText.wordBreaks.length-1;t>=0;t--)if(this.measuredText.wordBreaks[t]<this.offset)return new e(this.measuredText,this.measuredText.wordBreaks[t]);return new e(this.measuredText,0)}nextWord(){for(let t of this.measuredText.wordBreaks)if(t>this.offset)return new e(this.measuredText,t);return new e(this.measuredText,this.text.length)}insert(t){return t.length===0?this:new e(new Z(this.text.slice(0,this.offset)+t+this.text.slice(this.offset),this.columns),this.offset+t.length)}backspace(){if(this.offset<=0)return this;let t=St(this.text,this.offset+1);if(t&&this.offset===t.start)return new e(new Z(this.text.slice(0,t.start)+this.text.slice(t.end),this.columns),t.start);let n=xt(this.text,this.offset);if(n)return new e(new Z(this.text.slice(0,n.start)+this.text.slice(n.end),this.columns),n.start);let r=this.left();return new e(new Z(this.text.slice(0,r.offset)+this.text.slice(this.offset),this.columns),r.offset)}delete(){if(this.offset>=this.text.length)return this;let t=this.right();return new e(new Z(this.text.slice(0,this.offset)+this.text.slice(t.offset),this.columns),this.offset)}killToLineEnd(){let t=this.position,n=0;for(let e=0;e<t.line;e++)n+=this.measuredText.lines[e].length+1;let r=n+this.measuredText.lines[t.line].length,i=this.text.slice(this.offset,r);return{cursor:new e(new Z(this.text.slice(0,this.offset)+this.text.slice(r),this.columns),this.offset),killed:i}}killToLineStart(){let t=this.position,n=0;for(let e=0;e<t.line;e++)n+=this.measuredText.lines[e].length+1;if(this.offset===n&&t.line>0){let t=n-1;return{cursor:new e(new Z(this.text.slice(0,t)+this.text.slice(n),this.columns),t),killed:`
|
|
6
|
+
`}}let r=this.text.slice(n,this.offset);return{cursor:new e(new Z(this.text.slice(0,n)+this.text.slice(this.offset),this.columns),n),killed:r}}killWordBefore(){let t=xt(this.text,this.offset);if(t)return{cursor:new e(new Z(this.text.slice(0,t.start)+this.text.slice(t.end),this.columns),t.start),killed:t.text};let n=this.prevWord(),r=this.text.slice(n.offset,this.offset);return{cursor:new e(new Z(this.text.slice(0,n.offset)+this.text.slice(this.offset),this.columns),n.offset),killed:r}}modifyText(t,n=``){return new e(new Z(this.text.slice(0,this.offset)+n+this.text.slice(t),this.columns),this.offset+n.length)}deleteTokenBefore(){return this.offset<=0?null:this.backspace()}getViewportStartLine(e){let t=this.position,n=Math.floor(e/2);return Math.max(0,Math.min(t.line-n,this.measuredText.lineCount-e))}toEnd(){return new e(this.measuredText,this.text.length)}toStart(){return new e(this.measuredText,0)}toLineStart(){let t=0,n=this.position;for(let e=0;e<n.line;e++)t+=this.measuredText.lines[e].length+1;return new e(this.measuredText,t)}toLineEnd(){let t=0,n=this.position;for(let e=0;e<n.line;e++)t+=this.measuredText.lines[e].length+1;return new e(this.measuredText,t+this.measuredText.lines[n.line].length)}};function Dt(e){if(e.length===0||e.length>2)return!1;let t=e.codePointAt(0)??0;return t<32||t===127?!1:e.length===2?e.charCodeAt(0)>=55296&&e.charCodeAt(0)<=56319:!0}function Ot(e,t){let{name:n,ctrl:r,shift:i,alt:a,meta:o}=t;if(r&&n===`a`)return{cursor:e.toStart(),action:`move_to_start`};if(r&&n===`e`)return{cursor:e.toEnd(),action:`move_to_end`};if(r&&n===`b`){let t=e.left();return t.offset===e.offset?null:{cursor:t,action:`move_left`}}if(r&&n===`f`){let t=e.right();return t.offset===e.offset?null:{cursor:t,action:`move_right`}}if((a||o)&&n===`b`){let t=e.prevWord();return t.offset===e.offset?null:{cursor:t,action:`move_word_left`}}if((a||o)&&n===`f`){let t=e.nextWord();return t.offset===e.offset?null:{cursor:t,action:`move_word_right`}}if(r&&n===`h`||n===`backspace`){let t=e.backspace();return t.offset!==e.offset||t.text!==e.text?{cursor:t,action:`delete_backward`,killed:e.text.slice(t.offset,e.offset)}:null}if(r&&n===`d`){if(e.offset>=e.text.length)return null;let t=e.delete();return t.text===e.text?null:{cursor:t,action:`delete_forward`}}if(n===`delete`){let t=e.delete();return t.text===e.text?null:{cursor:t,action:`delete_forward`}}if(r&&n===`k`){let t=e.killToLineEnd();return t.killed.length>0?{cursor:t.cursor,action:`kill_to_end`,killed:t.killed}:null}if(r&&n===`u`){let t=e.killToLineStart();return t.killed.length>0?{cursor:t.cursor,action:`kill_to_start`,killed:t.killed}:null}if(r&&n===`w`){let t=e.killWordBefore();return t.killed.length>0?{cursor:t.cursor,action:`kill_word_before`,killed:t.killed}:null}return n===`return`||n===`enter`?r||o||a||i?{cursor:e,action:`submit_force`}:{cursor:e,action:`submit`}:Dt(n)?r?null:{cursor:e.insert(n),action:`insert`}:n===` `?{cursor:e.insert(` `),action:`insert`}:null}const Q={entries:[],index:-1,lastAction:`other`,lastYankOffset:0,lastYankLength:0};function kt(){return Q.entries}function At(){Q.entries=[],Q.index=-1,Q.lastAction=`other`}function jt(e,t){t&&Q.entries.length>0&&Q.lastAction===`kill`?Q.entries[0]=e+Q.entries[0]:!t&&Q.entries.length>0&&Q.lastAction===`kill`?Q.entries[0]+=e:(Q.entries.unshift(e),Q.entries.length>10&&(Q.entries.length=10)),Q.lastAction=`kill`,Q.index=-1}function Mt(){Q.lastAction=`other`,Q.index=-1}function Nt(e,t){let{name:n,ctrl:r,alt:i,meta:a,shift:o}=t;if(r&&n===`y`){if(Q.entries.length===0)return null;let t=Q.entries[0];return Q.lastAction=`yank`,Q.index=0,Q.lastYankOffset=e.offset,Q.lastYankLength=t.length,{cursor:e.insert(t),action:`insert`}}if((i||a)&&n===`y`){if(Q.lastAction!==`yank`&&Q.lastAction!==`kill`||Q.entries.length<=1)return null;Q.index=(Q.index+1)%Q.entries.length;let t=Q.entries[Q.index],n=Et.fromText(e.text,e.columns,Q.lastYankOffset).modifyText(Q.lastYankOffset+Q.lastYankLength,t);return Q.lastYankLength=t.length,Q.lastAction=`yank`,{cursor:n,action:`insert`}}if(n===`escape`){if(e.text.length===0)return null;let t=e.position,n=0;for(let r=0;r<t.line;r++)n+=e.measuredText.lines[r].length+1;let r=n+e.measuredText.lines[t.line].length,i=t.line>=e.measuredText.lineCount-1?r:r+1,a=e.text.slice(0,n)+e.text.slice(i),o=Math.min(n,a.length);return{cursor:Et.fromText(a,e.columns,o),action:`clear_text`}}if(n===`return`||n===`enter`){if(e.offset>0&&e.text[e.offset-1]===`\\`&&!o){let t=e.backspace();return Mt(),{cursor:t.insert(`
|
|
7
|
+
`),action:`insert`}}return Mt(),{cursor:e,action:i||a||r||o?`submit_force`:`submit`}}let s=Ot(e,t);return s?(s.action===`kill_to_end`&&s.killed?jt(s.killed,!1):s.action===`kill_to_start`&&s.killed||s.action===`kill_word_before`&&s.killed?jt(s.killed,!0):(s.action===`delete_backward`||s.action===`insert`)&&Mt(),s):null}function Pt(e){return e.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,``).replace(/\x1b\][^\x1b]*$/g,``).replace(/\x1b\[[0-9;]*[~a-zA-Z]/g,``).replace(/\r\n?/g,`
|
|
8
|
+
`).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,``)}function Ft(e){return e.measuredText.lineCount>10}function It(e,t){let n=e.measuredText.lineCount;if(n<=t)return null;let r=e.position,i=e.getViewportStartLine(t),a=Math.min(i+t,n);return{startLine:i,endLine:a,visibleLines:e.measuredText.lines.slice(i,a),cursorLine:r.line-i}}function Lt(e,t,n){return{x:e,y:t,lastChangeAt:n,targetX:e,targetY:t}}function Rt(e,t,n,r,i){let a=t!==e.targetX||n!==e.targetY;return i?a?r-e.lastChangeAt<150?{...e,targetX:t,targetY:n,lastChangeAt:r}:{x:t,y:n,targetX:t,targetY:n,lastChangeAt:r}:(e.x!==t||e.y!==n)&&r-e.lastChangeAt>=150?{...e,x:t,y:n}:e:!a&&e.x===t&&e.y===n?e:{x:t,y:n,targetX:t,targetY:n,lastChangeAt:r}}function zt(e){if(!e?.yogaNode)return null;let t=0,n=0,r=e;for(;r?.yogaNode;)t+=r.yogaNode.getComputedLeft(),n+=r.yogaNode.getComputedTop(),r=r.parentNode;return{x:Math.round(t),y:Math.round(n)}}function Bt(e){let t=e??void 0;for(;t;){if(!t.parentNode)return t.nodeName===`ink-root`?t:void 0;t=t.parentNode}}let Vt=0;function Ht(e){if(!e)return`NULL`;let t=[],n=e;for(let e=0;e<4&&n;e++)t.push(n.nodeName??`?`),n=n.parentNode;let r=e.childNodes?.[0]?.nodeValue;return`${t.join(`<`)}${r?`:${JSON.stringify(r.slice(0,12))}`:``}`}function Ut(e){let[t,n]=f(null),r=i.useRef(0);r.current===0&&(r.current=++Vt);let a=s(()=>{if(!e.current)return;let t=zt(e.current);n(n=>{let i=b()?void 0:process.env.OTTO_TUI_CURSOR_DEBUG;if(i)try{x(`node:fs`).appendFileSync(i,`[ORG#${r.current}] t=${Date.now()%1e5} next=${t?`${t.x},${t.y}`:`NULL`} prev=${n?`${n.x},${n.y}`:`NULL`} node=${Ht(e.current)}\n`)}catch{}return t===null||n!==null&&n.x===t.x&&n.y===t.y?n:t})},[e]);return l(a),l(()=>{let t=Bt(e.current);if(t)return t.internal_layoutListeners??=new Set,t.internal_layoutListeners.add(a),()=>{t.internal_layoutListeners?.delete(a)}}),t}let Wt=0;function Gt({active:e,containerRef:t,text:n,inline:r,deleteKeyAt:i}){let{setCursorPosition:a}=v(),o=Ut(t),s=d(0);s.current===0&&(s.current=++Wt);let c=d(null),u=d(null),p=d(n.length),m=d(0);n.length<p.current&&(m.current=Date.now()),p.current=n.length;let[,h]=f(0);if(e&&o){let e=Date.now(),t=e-i<300,l=n.length===0,d=!t&&!l&&e-m.current<300,f=Rt(c.current??Lt(r.column,r.lineOffset,e),r.column,r.lineOffset,e,d);c.current=f;let p=o.x+f.x,h=o.y+f.y,g=u.current;g!==null&&f.y>g.inlineOffset&&o.y===g.originY&&(h=g.y),u.current={y:h,originY:o.y,inlineOffset:f.y},a({x:p,y:h});let _=b()?void 0:process.env.OTTO_TUI_CURSOR_DEBUG;if(_)try{x(`node:fs`).appendFileSync(_,`[ON #${s.current}] t=${e%1e5} out=${p},${h} target=${o.x+r.column},${o.y+r.lineOffset} origin=${o.x},${o.y} inline=${r.column},${r.lineOffset} frozenInline=${f.x},${f.y} armed=${d?1:0} byDel=${t?1:0} byClr=${l?1:0} len=${n.length}\n`)}catch{}}else{c.current=null,u.current=null,a(void 0);let t=b()?void 0:process.env.OTTO_TUI_CURSOR_DEBUG;if(t)try{x(`node:fs`).appendFileSync(t,`[OFF#${s.current}] t=${Date.now()%1e5} active=${e?1:0} origin=${o?`${o.x},${o.y}`:`NULL`} len=${n.length}\n`)}catch{}}l(()=>{let e=c.current;if(!e||e.x===e.targetX&&e.y===e.targetY)return;let t=setTimeout(()=>h(e=>e+1),160);return()=>clearTimeout(t)})}const Kt=new Intl.Segmenter(`en`,{granularity:`grapheme`});function qt(e,t,n){let r=0,i=e,a=t;if(e>n){let o=Math.floor(n/2);r=Math.max(0,t-o),Math.min(e,r+n)-r<n&&(r=Math.max(0,e-n)),i=n,a=t-r}return{startLine:r,visibleRows:i,cursorLineInWindow:a}}const Jt={send:`> `,bash:`! `,bash_async:`!! `,memory:`# `,steer:`» `,dialog:``};function Yt(e,t){return e===`bash`||e===`bash_async`?t.warning:e===`memory`?t.special:e===`steer`?t.success:t.suggestion}function Xt(e,t,n){if(!e)return{lines:[``],cursorLine:0,cursorCharInLine:0};let r=[...Kt.segment(e)],i=[],a=``,o=0,s=0,c=0,l=0;for(let e=0;e<r.length;e++){let u=r[e],d=gt(u.segment);if(l===n&&(s=i.length,c=a.length),u.segment===`
|
|
9
|
+
`){i.push(a),a=``,o=0,l+=u.segment.length;continue}o+d>t&&a.length>0&&(i.push(a),a=``,o=0),a+=u.segment,o+=d,l+=u.segment.length}return n>=l&&(s=i.length,c=a.length),i.push(a),{lines:i,cursorLine:s,cursorCharInLine:c}}function Zt(e){X.lastIndex=0;let t=[],n=0,r;for(;(r=X.exec(e))!==null;){r.index>n&&t.push({chunk:e.slice(n,r.index),isChip:!1});let i=r[0],a=yt(i);t.push({chunk:i,isChip:!0,kind:a,pasteId:a===`paste`?bt(i):void 0}),n=r.index+i.length}return n<e.length&&t.push({chunk:e.slice(n),isChip:!1}),t}function Qt(e,t){switch(e){case`file`:return t.suggestion;case`agent`:return t.accent;case`skill`:case`mcp`:case`plugin`:return t.special;case`person`:return t.success;case`paste`:return t.inactive;default:return}}function $t(e,t){return e.kind===`paste`&&e.pasteId!==void 0&&(t?.has(e.pasteId)??!1)}function en(e,t){X.lastIndex=0;let n;for(;(n=X.exec(e))!==null;)if(t>n.index&&t<n.index+n[0].length){let e=yt(n[0]);return{kind:e,pasteId:e===`paste`?bt(n[0]):void 0}}}function tn(e,t){let n=Ct(e,t);if(!n)return;let r=yt(n.text);return{text:n.text,kind:r,pasteId:r===`paste`?bt(n.text):void 0}}function nn(e){return`•`.repeat(e.length)}const rn=i.memo(function({value:t,offset:n,columns:r,mode:a=`send`,placeholder:o=``,maxVisibleLines:s=10,focused:c,tabIndex:l=-1,mask:u=!1,noPrefix:d=!1,ghostSuffix:f,invalidPasteIds:p,containerRef:v,physicalCursor:y=!1,deleteKeyAt:b=0}){let x=K(),{focused:S}=Ge({tabIndex:l,disabled:l<0}),C=c??S,w=d?``:a===`dialog`&&!u?`> `:Jt[a],T=gt(w),E=w,D=Math.max(20,r-T),O=C,{lines:k,cursorLine:A,cursorCharInLine:j}=i.useMemo(()=>Xt(t,D,n),[t,D,n]),M=i.useRef(null),ee=i.useCallback(e=>{M.current=e,typeof v==`function`?v(e):v&&(v.current=e)},[v]),te=qt(k.length,A,s),N=te.startLine>0?1:0,P={column:T+gt((k[A]??``).slice(0,j)),lineOffset:N+te.cursorLineInWindow};if(Gt({active:y&&C,containerRef:M,text:t,inline:P,deleteKeyAt:b}),t.length===0&&o)return h(g,{ref:ee,flexDirection:`row`,children:[m(_,{color:C?Yt(a,x):x.inactive,children:E}),C&&m(_,{inverse:O,children:` `}),m(_,{dimColor:!0,children:o})]});let F=k.length,{startLine:I,visibleRows:ne}=qt(F,A,s),L=I+ne,R=k.slice(I,L);return h(g,{ref:ee,flexDirection:`column`,children:[I>0&&m(_,{dimColor:!0,children:` … ${I} ${e.t(`scroll.viewportLinesAbove`)}`}),R.map((e,t)=>{let n=I+t,r=n===A,i=u?nn(e):e;if(!r||!C){let r=u?[{chunk:i,isChip:!1}]:Zt(i);return h(g,{flexDirection:`row`,children:[n===0&&E?m(_,{color:C?Yt(a,x):x.inactive,children:E}):T>0&&m(_,{dimColor:!0,children:` `.repeat(T)}),r.length===0?m(_,{children:` `}):r.map((e,t)=>{let n=e.isChip&&$t(e,p);return m(_,{color:n?x.error:e.isChip?Qt(e.kind,x):void 0,strikethrough:n,children:e.chunk},t)})]},`${t}-${e.slice(0,10)}`)}let o=Math.max(0,Math.min(j,i.length)),s=!u&&o<i.length?tn(i,o):void 0;if(s){let r=i.slice(0,o),c=i.slice(o+s.text.length),l=s.kind===`paste`&&s.pasteId!==void 0&&(p?.has(s.pasteId)??!1);return h(g,{flexDirection:`row`,children:[n===0&&E?m(_,{color:C?Yt(a,x):x.inactive,children:E}):T>0&&m(_,{dimColor:!0,children:` `.repeat(T)}),Zt(r).map((e,t)=>{let n=e.isChip&&$t(e,p);return m(_,{color:n?x.error:e.isChip?Qt(e.kind,x):void 0,strikethrough:n,children:e.chunk},`b-${t}`)}),m(_,{inverse:!0,color:l?x.error:void 0,strikethrough:l,children:s.text}),Zt(c).map((e,t)=>{let n=e.isChip&&$t(e,p);return m(_,{color:n?x.error:e.isChip?Qt(e.kind,x):void 0,strikethrough:n,children:e.chunk},`a-${t}`)}),f?m(_,{dimColor:!0,children:f}):null]},`${t}-${e.slice(0,10)}`)}let c=i.slice(0,o),l=i.slice(o),d=l.length>0?[...l][0]??` `:` `,v=l.length>0?l.slice(d.length):``,y=!u&&l.length>0?en(i,o):void 0,b=y?.kind===`paste`&&y.pasteId!==void 0&&(p?.has(y.pasteId)??!1);return h(g,{flexDirection:`row`,children:[n===0&&E?m(_,{color:C?Yt(a,x):x.inactive,children:E}):T>0&&m(_,{dimColor:!0,children:` `.repeat(T)}),(u?[{chunk:c,isChip:!1}]:Zt(c)).map((e,t)=>{let n=e.isChip&&$t(e,p);return m(_,{color:n?x.error:e.isChip?Qt(e.kind,x):void 0,strikethrough:n,children:e.chunk},`b-${t}`)}),m(_,{inverse:O,color:b?x.error:y==null?void 0:Qt(y.kind,x),strikethrough:b,children:d}),(u?[{chunk:v,isChip:!1}]:Zt(v)).map((e,t)=>{let n=e.isChip&&$t(e,p);return m(_,{color:n?x.error:e.isChip?Qt(e.kind,x):void 0,strikethrough:n,children:e.chunk},`a-${t}`)}),f?m(_,{dimColor:!0,children:f}):null]},`${t}-${e.slice(0,10)}`)}),L<F&&m(_,{dimColor:!0,children:` … ${F-L} ${e.t(`scroll.viewportLinesBelow`)}`})]})}),an=[{commandId:`cycle-permission-mode`,description:`循环切换权限模式`,predicate:{shift:!0,key:`tab`},scopes:`*`},{commandId:`toggle-notifications`,description:`打开/关闭通知中心`,predicate:{ctrl:!0,input:`n`},scopes:`*`},{commandId:`toggle-edited-files`,description:`打开/关闭编辑文件面板`,predicate:{ctrl:!0,input:`v`},scopes:`*`},{commandId:`toggle-subagents`,description:`打开/关闭子代理面板`,predicate:{ctrl:!0,input:`t`},scopes:`*`},{commandId:`toggle-delegates`,description:`打开/关闭委派面板`,predicate:{ctrl:!0,input:`p`},scopes:`*`},{commandId:`toggle-draft-pane`,description:`打开/关闭草稿面板`,predicate:{ctrl:!0,input:`o`},scopes:`*`},{commandId:`toggle-queue-pane`,description:`打开/关闭队列面板`,predicate:{ctrl:!0,input:`q`},scopes:`*`},{commandId:`smart-close`,description:`智能关闭当前最上层面板`,predicate:{ctrl:!0,input:`k`},scopes:`*`},{commandId:`save-draft`,description:`保存当前输入为草稿`,predicate:{ctrl:!0,input:`s`},scopes:[`prompt`]},{commandId:`open-keybinding-panel`,description:`打开快捷键面板:浏览、搜索、重映射、重置快捷键`,predicate:{ctrl:!0,input:`/`},scopes:`*`}];function on(e){return e.ctrl===void 0&&e.shift===void 0&&e.meta===void 0&&e.input===void 0&&e.key===void 0&&e.upArrow===void 0&&e.downArrow===void 0}function sn(e,t,n){let r=n?.[e];return r===void 0?t:r}function cn(e,t,n){if(e.ctrl!==void 0&&!!n.ctrl!==e.ctrl||e.shift!==void 0&&!!n.shift!==e.shift||e.meta!==void 0&&!!n.meta!==e.meta||e.input!==void 0&&t!==e.input)return!1;if(e.key!==void 0)switch(e.key){case`tab`:if(!n.tab)return!1;break;case`escape`:if(!n.escape)return!1;break;case`return`:if(!n.return)return!1;break}return!(e.upArrow!==void 0&&n.upArrow!==e.upArrow||e.downArrow!==void 0&&n.downArrow!==e.downArrow)}function ln(e,t){return e===`*`?!0:e.includes(t)}function un(e,t,n,r,i){for(let a of e){if(!ln(a.scopes,t))continue;let e=sn(a.commandId,a.predicate,i);if(!on(e)&&cn(e,n,r))return a.commandId}}const dn=[{commandId:`list-nav-up`,description:`列表选中项上移`,predicate:{upArrow:!0},scopes:`*`},{commandId:`list-nav-up`,description:`列表选中项上移(vim k)`,predicate:{input:`k`,ctrl:!1,meta:!1},scopes:[`editedFiles`,`subagents`,`taskFocus`,`draft`,`queue`,`schedule`,`select`,`questions`]},{commandId:`list-nav-down`,description:`列表选中项下移`,predicate:{downArrow:!0},scopes:`*`},{commandId:`list-nav-down`,description:`列表选中项下移(vim j)`,predicate:{input:`j`,ctrl:!1,meta:!1},scopes:[`editedFiles`,`subagents`,`taskFocus`,`draft`,`queue`,`schedule`,`select`,`questions`]}];function fn(e,t,n,r,i){for(let a of dn){if(r!==void 0&&!pn(a.scopes,r))continue;let o=sn(a.commandId,a.predicate,i);if(!on(o)&&cn(o,t,n))return a.commandId===e}return!1}function pn(e,t){return e===`*`?!0:e.includes(t)}function mn(e,t,n,r){let i=[...an,...dn];for(let a of i){if(a.commandId===e)continue;let i=sn(a.commandId,a.predicate,r);if(!on(i)&&ln(a.scopes,n)&&hn(i,t))return{conflictsWith:a.commandId}}return null}function hn(e,t){return e.ctrl===t.ctrl&&e.shift===t.shift&&e.meta===t.meta&&e.input===t.input&&e.key===t.key&&e.upArrow===t.upArrow&&e.downArrow===t.downArrow}function gn(){let e=new Set(an.map(e=>e.commandId)),t=new Set(dn.map(e=>e.commandId));for(let n of e)if(t.has(n))throw Error(`[keybindings] duplicate commandId '${n}' found across KEY_BINDINGS and CONTROL_BINDINGS`)}gn();function _n(e,t,n){if(!t)return!1;let r=e.get(t);return r?n.tab?!!(r.onTab&&r.onTab(n.shift??!1)):n.escape?!!(r.onEscape&&r.onEscape()):n.return?!!(r.onAction&&r.onAction()):!1:!1}function vn(e,t,n,r,i){if(i.tab){let a=t;if(e.getTabable(n).length===0)return!1;if(a){let t=i.shift?e.prev(a,n):e.next(a,n);t&&r(t)}else if(!i.shift){let t=e.getInitialFocus(n);t&&r(t)}return!0}return!1}let yn=null;function bn(e){yn=e}function xn(){return yn}const Sn=a(null);function Cn(){let e=c(Sn);if(!e)throw Error(`useRouter() must be used inside <Router>`);return e}function wn(){return c(Sn)}function Tn(){let{stack:e}=Cn(),t=e[e.length-1];return t?{path:t.path,params:t.params,state:t.state}:{path:`/`,params:{},state:void 0}}function En(e){let{stack:t}=Cn();for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.path===e&&r.state!==void 0)return r.state}}function Dn(){let{stack:e}=Cn(),t=c(Ue).routePath;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.path===t)return r.state}}function On(e,t){let n=e.split(`/`),r=t.split(`/`);if(n.length!==r.length)return null;let i={};for(let e=0;e<n.length;e++){let t=n[e],a=r[e];if(t.startsWith(`:`))i[t.slice(1)]=a;else if(t!==a)return null}return i}function kn({children:e,initialPath:t=`/`}){let n=u(()=>new He,[]),[r,i]=f(()=>({entries:[{path:t,params:{}}],index:0})),[a,o]=f(null),c=d(null);c.current=a;let p=r.entries[r.index]?.path??t,h=r.entries.slice(0,r.index+1),g=d(h);g.current=h;let _=s(e=>{o(e)},[]),v=s(e=>{setTimeout(()=>{e?.lastFocusId?o(e.lastFocusId):o(n.getInitialFocus(e?.path??`/`))},0)},[n]),y=s(e=>{setTimeout(()=>{o(n.getInitialFocus(e))},0)},[n]),b=s((e,t)=>{if(typeof e==`number`){i(t=>{if(e===0||t.entries.length===0)return t;let n=t.index+e;return n<0||n>=t.entries.length?t:(v(t.entries[n]),{...t,index:n})});return}let r={path:e,params:{},state:t?.state};i(e=>{if(t?.reset)return{entries:[r],index:0};let i=c.current,a=[...e.entries];if(a.length>0&&i){let t=a[e.index];t&&(n.rememberFocus(t.path,i),a[e.index]={...t,lastFocusId:i})}if(t?.replace&&a.length>0)return a[e.index]=r,{entries:a,index:e.index};let o=[...a.slice(0,e.index+1),r];return{entries:o,index:o.length-1}}),y(e)},[y,n,v]),x=s(()=>{b(-1)},[b]),S=s(e=>{i(t=>{if(t.entries.slice(0,t.index+1).some(t=>t.path===e))return t;let r=c.current,i=[...t.entries],a=i[t.index];a&&r&&(n.rememberFocus(a.path,r),i[t.index]={...a,lastFocusId:r});let o=[...i.slice(0,t.index+1),{path:e,params:{}}];return y(e),{entries:o,index:o.length-1}})},[y,n]),C=s(e=>{i(t=>{if(t.entries.length<=1)return t;let n=-1;for(let r=t.index;r>=0;r--)if(t.entries[r].path===e){n=r;break}if(n<=0)return t;let r=[...t.entries.slice(0,n),...t.entries.slice(n+1)],i=n<=t.index?Math.max(0,t.index-1):t.index;return n===t.index&&v(r[i]),{entries:r,index:Math.min(i,r.length-1)}})},[v]),w=s(e=>{o(e)},[]),T=s((e,t)=>_n(n,c.current,t),[n]),E=s((e,t)=>vn(n,c.current,p,o,t)?!0:t.escape&&h.length>1?(x(),!0):!1,[n,p,h.length,x]),D=s((e,t)=>T(e,t)||E(e,t),[T,E]);l(()=>(bn({navigate:b,goBack:x,ensure:S,dismiss:C,get stack(){return g.current},get currentPath(){return g.current[g.current.length-1]?.path??`/`}}),()=>bn(null)),[b,x,S,C]);let O=et(),k=d(T);k.current=T;let A=d(E);A.current=E,l(()=>{let e=O.register(`router-intercept`,(e,t)=>k.current(e,t),50),t=O.register(`router-default`,(e,t)=>A.current(e,t),5);return()=>{e(),t()}},[O]),l(()=>{let e=n.getInitialFocus(p);e&&!c.current&&o(e)},[p]);let j=u(()=>({routePath:p,currentPath:p,activeId:a,registry:n,onFocusFallback:_,hasRouter:!0}),[p,a,n,_]),M=u(()=>({stack:h,currentPath:p,activeId:a,navigate:b,goBack:x,ensure:S,dismiss:C,focus:w,handleKey:D}),[h,p,a,b,x,S,C,w,D]);return m(Sn.Provider,{value:M,children:m(Ue.Provider,{value:j,children:e})})}function An(e,t){return t===e||t.startsWith(e+`/`)}function jn(e){for(let t=e.length-1;t>=0;t--){let n=e[t].path;if(!n.startsWith(`/overlay/`))return n}}function Mn({path:e,prefix:t,inStack:n,dismissibleByOverlay:r,element:i,children:a}){let{currentPath:o,stack:s,activeId:l}=Cn(),u=c(Ue),d=e=>u?h(Ue.Provider,{value:{...u,routePath:e,activeId:l},children:[i,a]}):h(p,{children:[i,a]});if(e===`*`)return d(o);if(n)return s.some(t=>t.path===e)?d(e):null;if(r){let n=jn(s);return n===void 0||(t?!An(e,n):n!==e)?null:d(e)}return t?An(e,o)?d(e):null:On(e,o)?d(e):null}function Nn({hasMore:t,count:n,indent:r=` `}){let i=K();return t?h(_,{color:i.inactive,dimColor:!0,children:[r,n===void 0?`▲ ${e.t(`common.more`)}`:e.t(`scroll.above`,{n})]}):null}function Pn({hasMore:t,count:n,indent:r=` `}){let i=K();return t?h(_,{color:i.inactive,dimColor:!0,children:[r,n===void 0?`▼ ${e.t(`common.more`)}`:e.t(`scroll.below`,{n})]}):null}function Fn(e,t){switch(e){case`primary`:return t.text;case`secondary`:return t.inactive;case`danger`:return t.error;case`success`:return t.success;case`warning`:return t.warning;case`accent`:return t.accent}}function $({children:e,type:t=`primary`,bold:n,italic:r,dim:i,wrap:a}){return m(_,{color:Fn(t,K()),bold:n,italic:r,dimColor:i,wrap:a,children:e})}function In(e){return e.leftArrow?-1:e.rightArrow?1:e.tab?e.shift?-1:1:0}function Ln(e,t,n){return n<=0?0:(e+t+n)%n}function Rn({children:e,type:t=`secondary`,leadingSpace:n=!1}){let r=K();return h(_,{children:[n?` `:``,h(_,{color:Fn(t,r),backgroundColor:r.tagBg,children:[` `,`[`,e,`]`,` `]})]})}function zn(e,t,n=0){return Math.max(3,e-t-3-2-Math.max(0,n))}function Bn(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)*.3333333333333333))}function Vn(e,t){let n=Number.isFinite(e)&&e>0?e:0;return Math.min(Bn(t),Math.max(15,n))}function Hn(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)/3))}function Un(e,t,n=0){let r=Math.min(Number.isFinite(e)&&e>0?Math.floor(e):0,5),i=Math.max(1,Bn(t)-n);return Math.min(r,i)}function Wn(e,t){let n=L(B.ellipsis);if(t<=1)return B.ellipsis;if(L(e)<=t)return e;let r=t-n,i=``;for(let t of e){let e=L(t);if(e>r)break;i+=t,r-=e}return`${i}${B.ellipsis}`}function Gn(e,t){let n=L(e);return n<=0||t<=0?``:e.repeat(Math.max(0,Math.floor(t/n)))}function Kn(e,t){let n=L(e);return n>=t?e:e+` `.repeat(t-n)}function qn(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function Jn(e){let t=Math.round(qn(e.percent)),n=Math.max(0,Math.floor(e.width));if(n===0)return{pct:t,filledCount:0,cells:[]};let r=e.segments?.filter(e=>e.width>0)??[],i=r.length>0,a,o;if(i){a=[];for(let e of r)for(let t=0;t<e.width;t++)a.push({filled:!0,segmentKey:e.key});for(o=a.length;a.length<n;)a.push({filled:!1})}else o=Math.max(0,Math.min(n,Math.round(t/100*n))),a=Array.from({length:n},(e,t)=>({filled:t<o}));if(e.markers)for(let[t,r]of Object.entries(e.markers)){if(!Number.isFinite(r))continue;let e=Math.max(0,Math.min(n-1,Math.round(r/100*n))),i=a[e];i&&(i.markerKey=t)}return{pct:t,filledCount:o,cells:a}}const Yn={ascii:{filled:`=`,empty:`.`},block:{filled:`█`,empty:`░`},dot:{filled:`▰`,empty:`▱`}};function Xn(e){return e?typeof e==`string`?Yn[e]:e:Yn.block}function Zn({label:e,indent:t=` `}){let n=K(),r=typeof e==`string`?e:String(e??``);return h(_,{color:n.inactive,bold:!0,children:[t,r.toUpperCase()]})}function Qn(e,t,n,r){let i=e.length;if(!Number.isFinite(n))return{rows:[...e],fillerCount:0,hasMoreAbove:!1,hasMoreBelow:!1,scrollTop:0};if(n<=0||i===0)return{rows:[],fillerCount:Math.max(0,n),hasMoreAbove:!1,hasMoreBelow:!1,scrollTop:0};let a=t>=0?t:0,o=r;a<o?o=a:a>=o+n&&(o=a-n+1);let s=Math.max(0,i-n);o=Math.min(Math.max(0,o),s);let c=Math.min(i,o+n),l=e.slice(o,c);return{rows:l,fillerCount:Math.max(0,n-l.length),hasMoreAbove:o>0,hasMoreBelow:c<i,scrollTop:o}}function $n(e,t=`below`){let n=[],r,i=0;return e.forEach((e,a)=>{e.group&&e.group!==r&&(i>0&&n.push({kind:`spacer`}),n.push({kind:`divider`,label:e.group}),i++),r=e.group,n.push({kind:`item`,option:e,optionIndex:a}),e.detail&&t===`below`&&n.push({kind:`detail`,option:e,optionIndex:a})}),n}function er(e,t,n,r){return Qn(e,e.findIndex(e=>e.kind===`item`&&e.optionIndex===t),n,r)}function tr(){let e=process.env.OTTO_TUI_REDUCED_MOTION;return e===`1`||e===`true`}function nr(e){return Math.max(1,Math.round(e/80))*80}const rr={now:()=>Date.now(),setTimer:(e,t)=>{let n=setTimeout(e,t);return n.unref?.(),n},clearTimer:e=>clearTimeout(e)};function ir(e={}){let t=e.clock??rr,n=e.reducedMotion??(()=>{let e=process.env.OTTO_TUI_REDUCED_MOTION;return e===`1`||e===`true`}),r=new Set,i=null,a=t.now(),o=e=>e.startedAtElapsed+(e.lastFrame+1)*e.periodMs,s=()=>{if(i!==null&&(t.clearTimer(i),i=null),r.size===0)return;let e=t.now()-a,n=1/0;for(let e of r){let t=o(e);t<n&&(n=t)}let s=Math.max(0,n-e);i=t.setTimer(c,s)},c=()=>{i=null;let e=t.now()-a;for(let t of r){let n=Math.floor((e-t.startedAtElapsed)/t.periodMs);if(n!==t.lastFrame){t.lastFrame=n;try{t.onFrame(n)}catch{}}}s()};return{subscribe(e,i){if(!Number.isFinite(e)||e<=0||n())return()=>{};let o=nr(e),c=t.now()-a,l={periodMs:o,onFrame:i,lastFrame:0,startedAtElapsed:Math.floor(c/80)*80};return r.add(l),s(),()=>{r.delete(l),s()}},minPeriodMs(){let e;for(let t of r)e=e===void 0?t.periodMs:Math.min(e,t.periodMs);return e},size:()=>r.size,dispose(){r.clear(),i!==null&&(t.clearTimer(i),i=null)}}}const ar=ir();function or(e,t){let n=d(t);n.current=t,l(()=>{if(e!=null)return ar.subscribe(e,e=>n.current(e))},[e])}function sr(e,t={}){let n=t.maxVisible??10,r=e.findIndex(e=>!e.disabled);r<0&&(r=0);let i=0;function a(){r<i?i=r:r>=i+n&&(i=r-n+1);let t=Math.max(0,e.length-n);i<0&&(i=0),i>t&&(i=t)}function o(n){if(n<0){t.onBoundary?.(`top`);return}if(n>=e.length){t.onBoundary?.(`bottom`);return}let i=n>r?1:-1,o=n;for(;o>=0&&o<e.length&&e[o]?.disabled;)o+=i;if(o<0){t.onBoundary?.(`top`);return}if(o>=e.length){t.onBoundary?.(`bottom`);return}r=o,a(),o===0&&t.onBoundary?.(`top`),o===e.length-1&&t.onBoundary?.(`bottom`)}return a(),{get selectedIndex(){return r},get scrollOffset(){return i},getVisibleOptions(){return e.slice(i,i+n)},getOptionAt(t){return e[t]},hasMoreAbove(){return i>0},hasMoreBelow(){return i+n<e.length},getSelected(){return e[r]??null},moveUp(){o(r-1)},moveDown(){o(r+1)},accept(){return e[r]??null},selectByHotkey(t){let n=e.findIndex(e=>e.hotkey===t);return n>=0&&!e[n]?.disabled?(r=n,a(),e[n]):null},selectByIndex(t){t>=0&&t<e.length&&!e[t]?.disabled&&(r=t,a())}}}function cr(e,t){return t.escape?{type:`cancel`}:t.return?{type:`accept`}:fn(`list-nav-up`,e,t)?{type:`up`}:fn(`list-nav-down`,e,t)?{type:`down`}:/^[1-9]$/.test(e)?{type:`index`,index:Number(e)-1}:null}const lr={black:0,red:.3,green:.55,yellow:.93,blue:.2,magenta:.4,cyan:.7,white:1,gray:.5,grey:.5};function ur(e){if(e.startsWith(`#`)){let t=e.slice(1),[n,r,i]=(t.length===3?[t[0]+t[0],t[1]+t[1],t[2]+t[2]]:[t.slice(0,2),t.slice(2,4),t.slice(4,6)]).map(e=>parseInt(e,16)/255);return .299*n+.587*r+.114*i}return lr[e.toLowerCase()]??.5}function dr(e){return e&&ur(e)>.55?`black`:`white`}function fr(e,t){switch(e){case`accent`:return t.selection;case`amber`:return t.warning;case`red`:return t.error;case`green`:return t.success;case`gray`:return t.panelBorder}}function pr(e,t){return fr(e,t)}function mr(e,t=w){let{label:n,variant:r=`ghost`,color:i=`accent`,focused:a=!1,disabled:o=!1}=e,s=e.brackets??r===`outline`,c=`[ ${n} ]`;if(o)return{label:c,color:t.inactive,bold:!1,dim:!0};if(r===`ghost`){let e=` ${n} `;if(a){let n=fr(i,t);return{label:s?c:e,color:dr(n),backgroundColor:n,bold:!0,dim:!1}}return{label:s?c:e,color:t.inactive,bold:!1,dim:!1}}let l=fr(i,t),u=pr(i,t);if(r===`solid`){let e=` ${n} `;return a?{label:s?c:e,color:dr(l),backgroundColor:l,bold:!0,dim:!1}:{label:s?c:e,color:s?t.inactive:u,bold:!1,dim:!1}}return a?{label:s?c:` ${n} `,color:u,bold:!0,dim:!1}:{label:s?c:` ${n} `,color:t.inactive,bold:!1,dim:!1}}function hr({label:e,variant:t=`ghost`,color:n=`accent`,focused:r,disabled:i=!1,brackets:a,tabIndex:o=-1,onAction:s}){let c=K(),{focused:l}=Ge({tabIndex:o,disabled:i||o<0,onAction:s}),u=mr({label:e,variant:t,color:n,focused:r??l,disabled:i,brackets:a},c);return m(_,{color:u.color,backgroundColor:u.backgroundColor,bold:u.bold,dimColor:u.dim||void 0,children:u.label})}function gr(e){return null}gr.displayName=`Select.Item`;function _r(e){return null}_r.displayName=`Select.Label`;function vr(e){return null}vr.displayName=`Select.Group`;function yr(){return null}yr.displayName=`Select.Separator`;function br({children:e}){return m(p,{children:e})}br.displayName=`Select.Content`;function xr(e){return null}xr.displayName=`Select.Trigger`;function Sr(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(Array.isArray(e))return e.map(Sr).join(``);if(i.isValidElement(e)){let t=e.props;return Sr(t.children)}return``}function Cr(e){let t=[],n=0;function r(e,a){i.Children.forEach(e,e=>{if(!i.isValidElement(e))return;let o=e.type;if(o.displayName===`Select.Item`){let r=e.props;n+=1,t.push({value:r.value,label:Sr(r.children),disabled:r.disabled,detail:r.detail,indent:r.indent,marker:r.marker,ordinal:n,trailingLabel:r.trailingLabel,trailingColor:r.trailingColor,labelColor:r.labelColor,group:a});return}if(o.displayName===`Select.Group`){let t=e.props,n;i.Children.forEach(t.children,e=>{i.isValidElement(e)&&e.type.displayName===`Select.Label`&&(n=Sr(e.props.children))}),r(t.children,n);return}if(o.displayName===`Select.Label`||o.displayName===`Select.Separator`||o.displayName===`Select.Trigger`)return;let s=e.props;s.children!==void 0&&r(s.children,a)})}return r(e,void 0),t}function wr({title:t,subtitle:n,headerAction:r,defaultValue:i,onValueChange:a,onCancel:o,maxVisible:s=10,footer:c,active:l=!0,onKey:v,frame:y=!0,highlightSelection:b=!0,rows:x=24,extensionHeightBudget:S=!1,detailPlacement:C=`below`,children:w}){let T=K(),E=u(()=>Cr(w),[w]),D=u(()=>C===`inline`?Math.max(0,...E.map(e=>L(e.label))):0,[C,E]),O=u(()=>C===`inline`?Math.max(0,...E.map(e=>L(e.trailingLabel??``))):0,[C,E]),k=d(null);if(!k.current){let e=i?E.findIndex(e=>e.value===i):-1;k.current=sr(E,{maxVisible:s}),e>=0&&k.current.selectByIndex(e)}let A=k.current,[j,M]=f(!1);or(2e3,e=>M(e%2==1));let[,ee]=f(0),te=()=>ee(e=>e+1),[N,P]=f(()=>!!r&&!E.some(e=>!e.disabled));J(`select-primitive`,(e,t)=>{if(v?.(e,t,A.getSelected())){te();return}if(r&&N){if(t.return){r.onPress();return}if(t.downArrow){P(!1),te();return}if(t.escape){o?.();return}return}let n=cr(e,t);if(n)switch(n.type){case`cancel`:o?.();return;case`up`:{let e=A.selectedIndex;A.moveUp(),r&&A.selectedIndex===e&&P(!0),te();return}case`down`:A.moveDown(),te();return;case`index`:{A.selectByIndex(n.index);let e=A.getSelected();e&&!e.disabled&&a?.(e.value);return}case`accept`:{let e=A.accept();e&&!e.disabled&&a?.(e.value);return}}},{isActive:l});let F=u(()=>$n(E,C),[E,C]),I=d(0),ne=y?S?Math.max(1,Math.min(F.length,Hn(x)-9)):Vn(F.length+9,x)-9:1/0,R=er(F,A.selectedIndex,ne,I.current);I.current=R.scrollTop;let re=E[A.selectedIndex]??null,z=h(p,{children:[t&&m(Fe,{children:t}),t&&m(g,{marginTop:G.tight}),n&&m($,{type:`secondary`,children:n}),r&&h(g,{flexDirection:`row`,alignSelf:`flex-start`,marginTop:n?G.tight:G.none,...de,borderColor:T.accent,paddingX:G.tight,children:[h(_,{color:T.accent,children:[r.hint,` `]}),m(hr,{variant:`ghost`,brackets:!0,color:`accent`,label:r.label,focused:N,tabIndex:-1})]})]}),ie=h(p,{children:[m(g,{height:1,children:m(Nn,{hasMore:R.hasMoreAbove})}),R.rows.map((t,n)=>{if(t.kind===`spacer`)return m(_,{children:` `},`spacer-${n}`);if(t.kind===`divider`)return m(g,{flexDirection:`column`,children:m(Zn,{label:t.label,indent:``})},`div-${n}`);let r=t.option;if(t.kind===`detail`){let e=r.indent??` `,n=r.detail??``,i=r.marker===`number`?` `.repeat(`${r.ordinal}. `.length):r.marker?` `.repeat(`${r.marker} `.length):``,a=/^● (.+?) · /u.exec(n),o=a?.[1],s=a?n.slice(a[0].length):n;return h(_,{wrap:`truncate-end`,children:[h($,{type:`secondary`,dim:!0,children:[` `,e,i]}),o?h(_,{color:T.accent,children:[j?B.breatheBright:B.breatheDim,` `,o]}):null,m($,{type:`secondary`,dim:!0,children:o?` · ${s}`:s})]},`detail-${t.optionIndex}`)}let i=r.indent??` `,a=r.marker===`number`?`${r.ordinal}. `:r.marker?`${r.marker} `:``,o=b&&r===re&&!N,s=C===`inline`&&r.detail;return h(g,{flexDirection:`row`,children:[h(_,{color:r.disabled?T.inactive:o?T.selection:r.labelColor??T.inactive,dimColor:r.disabled,bold:o&&!r.disabled,children:[o&&!r.disabled?V():H(),i,a,s?`${Kn(r.label,D)} ${Kn(r.trailingLabel??``,O)} ${r.detail}`:r.label,r.disabled?` (${e.t(`common.disabled`)})`:``]}),r.trailingLabel&&!s&&h(p,{children:[m($,{type:`secondary`,children:` `}),m(_,{color:r.trailingColor??T.inactive,dimColor:!r.trailingColor,children:r.trailingLabel})]})]},`item-${t.optionIndex}`)}),Array.from({length:R.fillerCount},(e,t)=>m(_,{children:` `},`filler-${t}`)),m(g,{height:1,children:m(Pn,{hasMore:R.hasMoreBelow})})]});return y?m(Pe,{header:z,footer:c??m(Le,{items:[[`${q.up}${q.down}`,e.t(`hint.select`)],[q.enter,e.t(`hint.confirm`)],[q.esc,e.t(`hint.cancel`)]]}),maxHeight:S&&y?Hn(x):void 0,children:ie}):h(g,{flexDirection:`column`,children:[z,ie]})}const Tr={Root:wr,Trigger:xr,Content:br,Group:vr,Label:_r,Item:gr,Separator:yr};function Er({title:t,message:n,confirmLabel:r,cancelLabel:i,confirmColor:a=`accent`,dangerous:o=!1,extraLabel:c,extraColor:l=`amber`,checkLabel:u,checked:d=!1,onConfirm:p,onCancel:v,onExtra:y,onCheckChange:b}){let x=!!c,S=x?2:1,[C,w]=f(o?S:0),[T,E]=f(d),D=Array.isArray(n)?n:[n],O=s(()=>{let e=!T;E(e),b?.(e)},[T,b]);Ge({onEscape:()=>(v(),!0)}),J(`confirm-dialog-buttons`,(e,t)=>{if(t.escape)return v(),!0;let n=In(t);return n===0?t.return?(w(e=>(e===0?p():x&&e===1?y?.():v(),e)),!0):u&&e===` `&&!t.ctrl&&!t.meta?(O(),!0):!1:(w(e=>Ln(e,n,S+1)),!0)});let k=r??e.t(`common.confirmButton`),A=i??e.t(`common.genericCancelButton`);return h(Pe,{header:m(Fe,{children:t}),footer:m(Le,{items:[[`${q.left}${q.right}`,e.t(`hint.switch`)],[q.enter,e.t(`hint.confirm`)],[q.esc,e.t(`hint.cancel`)]]}),children:[m(g,{marginTop:G.tight,flexDirection:`column`,children:D.map((e,t)=>m(_,{wrap:`truncate-end`,children:e===``?` `:e},t))}),u&&h(g,{marginTop:G.tight,children:[h($,{type:`secondary`,children:[T?B.bullet:B.todoPending,` `]}),m($,{type:`secondary`,children:u})]}),h(g,{marginTop:G.tight,flexDirection:`row`,gap:G.section,children:[m(hr,{variant:`solid`,brackets:!0,color:a,label:k,focused:C===0}),x&&m(hr,{variant:`solid`,brackets:!0,color:l,label:c,focused:C===1}),m(hr,{variant:`solid`,brackets:!0,color:`gray`,label:A,focused:C===S})]})]})}function Dr({tabIndex:e=0,autoFocus:t=!1,options:n,onSelect:r,initialIndex:i=0,maxVisible:a=8,id:o,compact:s=!1}){let c=K(),{focused:l}=Ge({tabIndex:e,autoFocus:t,id:o}),[u,d]=f(Math.min(i,n.length-1));nt(l,(e,t)=>{if(t.upArrow)return d(e=>{let t=e;for(let r=1;r<=n.length;r++){let i=(e-r+n.length)%n.length;if(!n[i]?.disabled){t=i;break}}return t}),!0;if(t.downArrow)return d(e=>{let t=e;for(let r=1;r<=n.length;r++){let i=(e+r)%n.length;if(!n[i]?.disabled){t=i;break}}return t}),!0;if(t.return){let e=n[u];return e&&!e.disabled&&r(e.value),!0}for(let t=0;t<Math.min(n.length,9);t++)if(e===String(t+1)&&n[t]&&!n[t].disabled)return r(n[t].value),!0;return!1});let p=n.length,v=p<=a?0:Math.min(Math.max(0,u-Math.floor(a/2)),p-a),y=n.slice(v,v+a);return h(g,{flexDirection:`column`,children:[v>0&&m(g,{children:h(_,{color:c.inactive,dimColor:!0,children:[` ▲ `,v]})}),y.map((e,t)=>{let n=v+t===u,r=n&&l,i=e.disabled?c.inactive:r||n?c.selection:c.inactive,a=n&&!e.disabled;return h(g,{marginBottom:s?G.none:G.tight,flexDirection:`column`,children:[h(_,{color:i,bold:a,children:[r?V():H(),e.label]}),e.detail&&m(g,{marginLeft:G.section,children:m(_,{color:c.inactive,children:e.detail})})]},e.value)}),v+a<p&&m(g,{children:h(_,{color:c.inactive,dimColor:!0,children:[` ▼ `,p-v-a]})})]})}function Or({label:e,detail:t,disabled:n,children:r}){let i=K();return h(g,{flexDirection:`column`,children:[m(_,{color:n?i.inactive:void 0,children:e}),t&&m(_,{color:i.inactive,dimColor:!0,children:t}),r]})}function kr(e,t){switch(e){case`success`:return t.success;case`warning`:return t.warning;case`error`:return t.error;case`muted`:return t.inactive;case`secondary`:return t.secondary}}function Ar(e){let t=[],n=[];for(let r of e)r.kind===`group`?(n.length>0&&t.push(n),n=[r]):n.push(r);return n.length>0&&t.push(n),t}function jr({entries:e}){let t=K();return m(g,{flexDirection:`column`,children:Ar(e).map((e,n)=>{let r=e.filter(e=>e.kind===`row`),i=Math.max(0,...r.map(e=>L(e.label)));return m(g,{flexDirection:`column`,marginTop:n>0?G.tight:G.none,children:e.map((e,n)=>{if(e.kind===`group`)return m(Zn,{label:e.title},n);if(e.kind===`blank`)return m(_,{children:` `},n);if(e.kind===`text`)return m(_,{color:e.tone?kr(e.tone,t):void 0,dimColor:e.tone===`muted`,children:e.value},n);let r=` `.repeat(Math.max(0,i-L(e.label)));return h(_,{children:[` `,m(_,{color:t.inactive,children:e.label}),r,` `,m(_,{color:e.tone?kr(e.tone,t):void 0,children:e.value})]},n)})},n)})})}function Mr(t){switch(t){case`retry`:return e.t(`retry.nowButton`);case`login`:return e.t(`model.goToLoginButton`);case`extension`:return e.t(`model.goToExtensionButton`)}}function Nr(e,t){switch(e){case`success`:return t.success;case`muted`:return t.inactive;case`warning`:return t.warning}}function Pr({title:t,lines:n,lineTones:r,onDismiss:i,action:a,dataListEntries:o}){let s=K();J(`info-dialog`,(e,t)=>t.escape?(i(),!0):t.return&&a?(i(),queueMicrotask(()=>a.run()),!0):!1);let c=a?Mr(a.kind):void 0;return h(Pe,{header:m(Fe,{children:t}),footer:m(Le,{items:a?[[q.enter,c],[q.esc,e.t(`hint.close`)]]:[[q.esc,e.t(`hint.close`)]]}),children:[m(g,{marginTop:G.tight,flexDirection:`column`,children:o?m(jr,{entries:o}):n.map((e,t)=>{let n=r?.[t];return m(_,{color:n?Nr(n,s):void 0,dimColor:n===`muted`,wrap:`truncate-end`,children:e===``?` `:e},t)})}),a&&m(g,{marginTop:G.tight,children:m(hr,{variant:`solid`,brackets:!0,color:`accent`,label:c,focused:!0})})]})}function Fr({percent:e,width:t,chars:n,color:r,segments:i,markers:a,labelPosition:o=`suffix`,labelPrefix:s=``}){let c=K(),{filled:l,empty:u}=Xn(n),d=Jn({percent:e,width:t,segments:i?.map(e=>({key:e.key,width:e.width}))}),f=new Map((i??[]).map(e=>[e.key,e.color])),p=new Map((i??[]).map(e=>[e.key,e.dimColor??!1])),g=new Map(Object.entries(a??{}).map(([e,t])=>[t.pos,{name:e,color:t.color}])),v=(e=>typeof r==`function`?r(e):typeof r==`string`?r:c.inactive)(d.pct),y=`${s}${d.pct}%`;return h(_,{children:[o===`prefix`?h(_,{color:v,bold:!0,children:[y,` `]}):null,d.cells.map((e,t)=>{let n=g.get(t),r=c.inactive;e.filled&&(r=e.segmentKey?f.get(e.segmentKey)??v:v),n&&e.filled&&(r=n.color);let i=e.filled&&e.segmentKey?p.get(e.segmentKey)??!1:!1;return m(_,{color:r,dimColor:i,children:e.filled?l:u},t)}),o===`suffix`?h(_,{children:[` `,y]}):null]})}const Ir={pending:B.todoPending,active:B.todoActive,done:B.check,error:B.cross};function Lr(e,t){let n=[];return e.forEach((e,r)=>{let i=t[r]??`pending`;i!==`pending`&&n.push({label:e,status:i})}),n}function Rr({title:t,phases:n,phaseStatuses:r,percent:a,detail:o,subProgress:s,status:c,errorMessage:u,nextStep:v,onDismiss:y}){let b=K(),x=c===`running`,S=d(null);l(()=>{if(c===`success`)return S.current=setTimeout(y,2e3),()=>{S.current&&clearTimeout(S.current)}},[c,y]);let[C,w]=f(0);return or(c===`running`?160:null,e=>{w(e%U.length)}),J(`progress-dialog`,(e,t)=>(t.return||t.escape)&&c!==`running`?(y(),!0):!1),m(Pe,{header:m(Fe,{children:t}),footer:c===`partial`||c===`error`?m(Le,{items:[[`${q.enter}/${q.esc}`,e.t(`hint.close`)]]}):void 0,children:h(g,{flexDirection:`column`,paddingX:G.tight,children:[m(g,{height:1}),x?n.map((e,t)=>{let n=r[t]??`pending`,i=n===`active`,a=n===`error`,s=n===`done`,c=b.inactive;return i?c=b.accent:a?c=b.error:s&&(c=b.success),h(g,{children:[h(_,{color:c,children:[Ir[n]??` `,` `]}),m(_,{color:i?b.accent:a?b.error:s?b.success:b.inactive,children:e}),i?h(p,{children:[h(_,{color:b.accent,children:[` `,U[C],` `]}),m($,{type:`secondary`,children:o})]}):null]},t)}):null,!x&&c!==`success`?m(g,{children:Lr(n,r).map((e,t)=>h(i.Fragment,{children:[t>0?m($,{type:`secondary`,children:` · `}):null,h(_,{color:e.status===`error`?b.error:e.status===`done`?b.success:b.accent,children:[Ir[e.status],` `]}),m($,{type:`secondary`,children:e.label})]},t))}):null,s&&c===`running`?m(g,{marginTop:G.tight,children:h(Rn,{children:[s.current,`/`,s.total]})}):null,x?m(g,{marginTop:G.tight,marginBottom:G.tight,children:m(Fr,{percent:a,width:40,chars:`ascii`,color:b.accent})}):null,x?null:h(g,{marginTop:c===`success`?G.none:G.tight,flexDirection:`column`,children:[m(g,{children:h(_,{bold:!0,color:c===`success`?b.success:c===`partial`?b.warning:b.error,children:[c===`success`?B.check:c===`partial`?B.warn:B.cross,` `,c===`success`?e.t(`install.done`):c===`partial`?e.t(`install.summaryPartial`):e.t(`install.summaryFailed`)]})}),c!==`success`&&u?m(g,{marginTop:G.tight,children:m($,{type:`secondary`,wrap:`wrap`,children:u})}):null,v?m(g,{marginTop:G.tight,children:m($,{type:`secondary`,children:v.label})}):null]})]})})}function zr(e){return e.some(e=>e.freeformInput===!0)}function Br(e){return{tab:0,cursor:0,selected:e.map(()=>[]),freeformText:``,freeformOffset:0}}function Vr(e,t,n=!1){return t.escape?{type:`cancel`}:t.tab?{type:t.shift?`tabPrev`:`tabNext`}:fn(`list-nav-up`,e,t)?{type:`cursorPrev`}:fn(`list-nav-down`,e,t)?{type:`cursorNext`}:!n&&(e===` `||t.return)?{type:`choose`}:null}function Hr(e,t,n){let r=zr(n),i=n.length+(r?1:0),a=r?n.length:-1;switch(t?.type){case`cancel`:return{state:e,done:`cancel`};case`tabPrev`:return{state:{...e,tab:(e.tab-1+i+1)%(i+1),cursor:0}};case`tabNext`:return{state:{...e,tab:(e.tab+1)%(i+1),cursor:0}};case`cursorPrev`:return e.tab===i||e.tab===a?{state:e}:{state:{...e,cursor:Math.max(0,e.cursor-1)}};case`cursorNext`:{if(e.tab===i||e.tab===a)return{state:e};let t=n[e.tab].options.length;return{state:{...e,cursor:Math.min(t-1,e.cursor+1)}}}case`choose`:{if(e.tab===i)return{state:e,done:`submit`};if(e.tab===a)return{state:{...e,tab:i}};let t=n[e.tab],r=e.selected[e.tab]??[],o=t.multiSelect?r.includes(e.cursor)?r.filter(t=>t!==e.cursor):[...r,e.cursor]:[e.cursor],s=e.selected.map((t,n)=>n===e.tab?o:t),c=t.multiSelect?e.tab:Math.min(i,e.tab+1);return{state:{...e,selected:s,tab:c,cursor:0}}}default:return{state:e}}}function Ur(e,t){let n={};return t.forEach((t,r)=>{n[t.header]=(e.selected[r]??[]).map(e=>t.options[e]?.label).filter(e=>typeof e==`string`)}),n}function Wr(e,t){return t.every((t,n)=>(e.selected[n]?.length??0)>0)}function Gr(e){return Wn(e,23)}function Kr({title:t,questions:n,onSubmit:r,onCancel:a,columns:o=60}){let s=K(),c=zr(n),l=d(null);l.current??=Br(n);let[,u]=f(0),v=c?n.length:-1,y=n.length+(c?1:0),b=e=>{let t=l.current,i=Vr(``,{tab:!0,shift:e},t.tab===v);if(!i)return!1;let{state:o,done:s}=Hr(t,i,n);return l.current=o,s===`cancel`?(a?.(),!0):s===`submit`?(r(Ur(o,n),o.freeformText||void 0),!0):(u(e=>e+1),!0)};Ge({onEscape:()=>(a?.(),!0),onTab:e=>b(e)}),J(`questions-dialog`,(e,t)=>{let i=l.current;if(i.tab===v){if(t.escape&&i.freeformText.length===0){a?.();return}if(t.tab){b(t.shift??!1);return}if(t.leftArrow){let e=Et.fromText(i.freeformText,o,i.freeformOffset).left();l.current={...i,freeformText:e.text,freeformOffset:e.offset},u(e=>e+1);return}if(t.rightArrow){let e=Et.fromText(i.freeformText,o,i.freeformOffset).right();l.current={...i,freeformText:e.text,freeformOffset:e.offset},u(e=>e+1);return}if(e.length>1&&!t.ctrl&&!t.meta&&!t.return&&!t.escape&&!t.backspace&&!t.delete&&!t.leftArrow&&!t.rightArrow){let t=Pt(e);if(t){let e=i.freeformText,n=i.freeformOffset;l.current={...i,freeformText:e.slice(0,n)+t+e.slice(n),freeformOffset:n+t.length},u(e=>e+1)}return}if(t.return){let{state:e,done:t}=Hr(i,Vr(``,{tab:!0},!0),n);if(l.current=e,t===`submit`){r(Ur(e,n),e.freeformText||void 0);return}u(e=>e+1);return}let s={name:t.escape?`escape`:t.backspace?`backspace`:t.delete?`delete`:e||`unknown`,ctrl:t.ctrl??!1,shift:!1,alt:t.meta??!1,meta:t.meta??!1},c=Nt(Et.fromText(i.freeformText,o,i.freeformOffset),s);if(!c)return;l.current={...i,freeformText:c.cursor.text,freeformOffset:c.cursor.offset},u(e=>e+1);return}let s=Vr(e,t);if(!s)return;let{state:c,done:d}=Hr(i,s,n);if(l.current=c,d===`cancel`){a?.();return}if(d===`submit`){r(Ur(c,n),c.freeformText||void 0);return}u(e=>e+1)});let x=l.current,S=x.tab===y,C=x.tab===v?m(Le,{items:[[q.enter,e.t(`freeform.advance`)],[q.esc,e.t(`hint.cancel`)]]}):m(Le,{items:[[`${q.up}${q.down}`,e.t(`hint.option`)],[q.tab,e.t(`hint.question`)],S?[q.enter,e.t(`hint.submit`)]:[`space/${q.enter}`,e.t(`hint.choose`)],[q.esc,e.t(`hint.cancel`)]]});return h(Pe,{header:t?m(Fe,{children:t}):void 0,footer:C,children:[h(g,{flexDirection:`row`,marginTop:G.tight,children:[n.map((e,t)=>{let n=(x.selected[t]?.length??0)>0,r=x.tab===t,a=r?s.selection:n?s.success:s.inactive;return h(i.Fragment,{children:[t>0&&m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:a,bold:r,children:Gr(e.header)})]},t)}),c&&h(p,{children:[m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:x.tab===v?s.selection:x.freeformText?s.success:s.inactive,bold:x.tab===v,children:e.t(`freeform.tab`)})]}),m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:S?s.selection:s.inactive,bold:S,children:e.t(`prompt.submit`)})]}),S?h(g,{flexDirection:`column`,marginTop:G.tight,children:[m(_,{color:Wr(x,n)?s.success:s.warning,children:Wr(x,n)?e.t(`questions.readyToSubmit`):e.t(`questions.someUnanswered`)}),m(g,{marginTop:G.tight,children:m(hr,{variant:`solid`,brackets:!0,color:`accent`,label:e.t(`prompt.submit`),focused:!0})})]}):x.tab===v?h(g,{flexDirection:`column`,marginTop:G.tight,children:[m(_,{color:s.secondary,children:e.t(`freeform.label`)}),m(g,{marginTop:G.tight,children:m(rn,{value:x.freeformText,offset:x.freeformOffset,columns:o,mode:`dialog`,placeholder:e.t(`freeform.placeholder`),focused:!0,physicalCursor:!0})})]}):h(g,{flexDirection:`column`,marginTop:G.tight,children:[n[x.tab].question!==t&&m(_,{color:s.text,children:n[x.tab].question}),m(g,{flexDirection:`column`,marginTop:G.tight,children:n[x.tab].options.map((e,t)=>{let n=t===x.cursor,r=(x.selected[x.tab]??[]).includes(t),i=r?B.bullet:B.todoPending;return h(g,{flexDirection:`column`,children:[h(g,{flexDirection:`row`,children:[m(_,{color:n?s.selection:s.inactive,bold:n,children:n?V():H()}),m(_,{color:n?s.selection:r?s.success:s.inactive,bold:n,children:i}),m(_,{children:` `}),m(_,{color:n?s.selection:r?s.success:s.inactive,bold:n,children:e.label})]}),e.description&&m(g,{marginLeft:G.loose,children:m($,{type:`secondary`,dim:!0,children:e.description})})]},t)})})]})]})}function qr(e,t,n,r){return h(g,{flexDirection:`row`,marginBottom:G.tight,children:[n.map((n,a)=>{let o=t.has(a),s=a===e,c=o?B.check:s?B.todoDone:B.todoPending,l=o?r.inactive:s?r.text:r.inactive;return h(i.Fragment,{children:[a>0&&m($,{type:`secondary`,children:` · `}),h(_,{color:l,bold:s,children:[c,` `,n]})]},a)}),h(g,{marginLeft:G.section,children:[m($,{type:`secondary`,children:`Step `}),m(_,{color:r.text,bold:!0,children:e+1}),h($,{type:`secondary`,children:[`/`,4]})]})]})}function Jr(){return m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,dim:!0,children:Gn(B.hr,60)})})}function Yr({request:t}){let n=K(),[r,i]=f(!1),[a,o]=f(!1),[c,u]=f(()=>Math.min(t.initialCurrent,3)),[p,v]=f(()=>new Set(t.initialCompleted)),[y,b]=f(null),[x,S]=f(null),[C,w]=f(null),[T,E]=f(null),[D,O]=f(null),[k,A]=f([]),[j,M]=f(!1),[ee,te]=f(null),N=d(null),[P,F]=f(`select`),[I,ne]=f(null),[L,R]=f(null),[re,z]=f(null),[ie,ae]=f(``),oe=d(``),[se,ce]=f(t.authProviderName??``),V=s(e=>{oe.current=e,ae(e)},[]),H=d(null),U=d(!1),le=s(()=>{U.current=!0,H.current?.cancel(),N.current&&=(clearTimeout(N.current),null),t.onDismiss()},[t]),ue=s(()=>{if(P!==`select`&&c===1){H.current?.cancel(),F(`select`),ne(null),R(null),z(null),V(``),oe.current=``,b(null);return}if(T){E(null),b(null);return}c===0?le():(v(e=>{let t=new Set(e);return t.delete(c-1),t}),u(e=>e-1),b(null),F(`select`),ne(null),R(null),z(null),V(``),w(null),A([]),M(!1),E(null),N.current&&=(clearTimeout(N.current),null))},[c,le,P,T]);l(()=>()=>{H.current?.cancel(),N.current&&clearTimeout(N.current)},[]);let W=s(()=>{v(e=>new Set([...e,c])),b(null),S(null),w(null),A([]),M(!1),E(null),F(`select`),O(null),ne(null),R(null),z(null),V(``),oe.current=``,H.current=null,c>=3?(le(),t.onComplete()):u(e=>e+1)},[c,le,t]),de=d(null),fe=s(async e=>{S(e),b(null);let n=await t.onInstallProvider(e,()=>{});U.current||(S(null),n.ok?(ce(n.providerId??e),A(n.capabilities??[]),M(n.pendingCapabilities===!0),w(e),N.current=setTimeout(()=>{N.current=null,W()},900)):(E(e),b(n.error)))},[t,W]);de.current=fe;let pe=s(()=>{let e=T;e&&(E(null),b(null),de.current?.(e))},[T]),me=s(()=>{E(null),b(null)},[]),he=d(null),ge=s(async()=>{if(t.onRefreshModelOptions)try{te(await t.onRefreshModelOptions())}catch{}},[t]),_e=s(async()=>{if(!t.onProviderOAuthStart)return;b(null),F(`oauth-wait`);let e=await t.onProviderOAuthStart(se);if(!e){F(`select`),b(`OAuth flow not available for this provider.`);return}H.current=e,ne(e.authorizationUrl),R(e.code??null),z(e.instructions??null);let n=async()=>{if(U.current)return;let t=await e.poll();if(U.current)return;let r=typeof t==`string`?t:t.status,i=typeof t==`string`?void 0:t.reason;r===`pending`?setTimeout(()=>{n().catch(()=>{})},1500):r===`done`?(await ge(),W()):i===`cancelled`?F(`select`):O(i===`network`?`network`:`rejected`)};n().catch(()=>{})},[t,W,se,ge]),ve=s(()=>{O(null),b(null),he.current?.()},[]),ye=s(()=>{O(null),t.onOpenProxySettings?.()},[t]);he.current=_e;let be=s(()=>{H.current?.openAgain?.()},[]),xe=s(()=>{H.current?.cancel(),H.current=null,ne(null),R(null),z(null),b(null),V(``),F(`key-input`)},[V]),Se=s(async()=>{if(!t.onSubmitProviderApiKey||!oe.current.trim())return;b(null),F(`logging-in`);let e=await t.onSubmitProviderApiKey(se,oe.current.trim());e.ok?(await ge(),W()):(F(`key-input`),b(e.error))},[t,W,ie,se,ge]),Ce=s(async e=>{b(null);try{await t.onSelectModel(e),W()}catch(e){b(e instanceof Error?e.message:String(e))}},[t,W]),we=s(()=>W(),[W]);J(`wizard-dialog`,(e,n)=>r?n.escape?(ue(),!0):!1:n.return?(t.onDontShowAgain(a),i(!0),!0):n.escape?(le(),!0):e===` `?(o(e=>!e),!0):!1);let Te=(()=>{if(!r)return[[q.enter,t.welcomeStartLabel],[q.esc,t.welcomeCancelLabel],[`Space`,t.welcomeDontShowAgainLabel]];let n=c===0&&!T?`exit`:`back`;switch(c){case 0:{let r=Math.min(t.providerOptions.length,9);return[[`${q.up}${q.down}`,e.t(`hint.select`)],[`1-${r}`,e.t(`hint.quick`)],[q.enter,e.t(`setup.actionInstall`)],[q.esc,n]]}case 1:return P===`key-input`?[[q.enter,`submit`],[q.esc,n]]:P===`oauth-wait`?[[q.esc,`cancel`]]:[[`1-${Math.min(t.providerAuthOptions(se).length,9)}`,e.t(`hint.quick`)],[q.enter,e.t(`setup.actionLogin`)],[q.esc,n]];case 2:{let r=Math.min((ee??t.modelOptions).length,9);return[[`${q.up}${q.down}`,e.t(`hint.select`)],[`1-${r}`,e.t(`hint.quick`)],[q.enter,e.t(`hint.confirm`)],[q.esc,n]]}case 3:return[[q.enter,e.t(`hint.confirm`)]];default:return[[q.esc,n]]}})();return m(Pe,{header:m(Fe,{children:t.title}),footer:m(Le,{items:Te}),children:r?h(g,{flexDirection:`column`,marginTop:G.tight,paddingX:G.section,children:[qr(c,p,t.stepNames,n),m(g,{marginBottom:G.tight,flexDirection:`column`,children:m(_,{bold:!0,children:t.stepSubtitles[c]})}),m(Jr,{}),y&&h(g,{marginBottom:G.tight,flexDirection:`column`,children:[h(_,{color:n.error,children:[e.t(`setup.errorTitle`),`:`]}),m(_,{color:n.error,children:y})]}),m(Xr,{step:c,request:t,installing:x,installSucceeded:C,installedCapabilities:k,installPendingCaps:j,installFailed:T,onRetryInstall:pe,onChooseAnother:me,authMode:P,setAuthMode:F,oauthUrl:I,oauthCode:L,oauthInstructions:re,apiKey:ie,apiKeyRef:oe,setApiKey:V,onInstall:fe,onOAuthStart:_e,onApiKeySubmit:Se,onOpenAgain:be,onSwitchToApiKey:xe,onRetryAuth:ve,onOpenProxySettings:ye,authFailure:D,onModel:Ce,onComplete:we,selectedProvider:se,modelOptionsOverride:ee})]}):h(g,{flexDirection:`column`,marginTop:G.tight,paddingX:G.section,children:[m(g,{marginBottom:G.tight,children:m(_,{bold:!0,children:t.welcomeTitle})}),t.welcomeGreeting&&m(g,{marginBottom:G.tight,children:m(_,{children:t.welcomeGreeting})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:t.welcomeDescription})}),m(Jr,{}),m(g,{marginBottom:G.tight,children:h(_,{color:a?n.text:n.inactive,children:[a?B.bullet:B.todoPending,` `,t.welcomeDontShowAgainLabel]})})]})})}function Xr(e){switch(e.step){case 0:return m(Qr,{request:e.request,installing:e.installing,installSucceeded:e.installSucceeded,installedCapabilities:e.installedCapabilities,installPendingCaps:e.installPendingCaps,installFailed:e.installFailed,onRetryInstall:e.onRetryInstall,onChooseAnother:e.onChooseAnother,onInstall:e.onInstall});case 1:return m($r,{request:e.request,authMode:e.authMode,setAuthMode:e.setAuthMode,oauthUrl:e.oauthUrl,oauthCode:e.oauthCode,oauthInstructions:e.oauthInstructions,apiKey:e.apiKey,apiKeyRef:e.apiKeyRef,setApiKey:e.setApiKey,onOAuthStart:e.onOAuthStart,onApiKeySubmit:e.onApiKeySubmit,onOpenAgain:e.onOpenAgain,onSwitchToApiKey:e.onSwitchToApiKey,onRetryAuth:e.onRetryAuth,onOpenProxySettings:e.onOpenProxySettings,authFailure:e.authFailure,selectedProvider:e.selectedProvider});case 2:return m(ei,{request:e.request,onModel:e.onModel,modelOptionsOverride:e.modelOptionsOverride});case 3:return m(ti,{request:e.request,onComplete:e.onComplete});default:return m(_,{children:`Unknown step`})}}function Zr(){let e=K(),t=tr(),[n,r]=f(0);return or(160,e=>r(e%U.length)),t?null:h(_,{color:e.accent,children:[` `,U[n]]})}function Qr({request:t,installing:n,installSucceeded:r,installedCapabilities:i,installPendingCaps:a,installFailed:o,onRetryInstall:s,onChooseAnother:c,onInstall:l}){let u=K(),[d,p]=f(0),v=t.providerOptions,y=n!==null;if(r){let t=v.find(e=>e.value===r)?.label??r;return h(g,{flexDirection:`column`,children:[m(g,{children:h(_,{color:u.success,bold:!0,children:[B.check,` `,e.t(`setup.installedProvider`,{provider:t})]})}),a&&m(g,{marginTop:G.tight,children:m(_,{color:u.warning,children:e.t(`setup.installPendingCapabilities`)})}),i.length>0&&h(g,{marginTop:G.tight,flexDirection:`column`,children:[m($,{type:`secondary`,children:e.t(`setup.capabilityGranted`,{caps:i.join(`, `)})}),m($,{type:`secondary`,children:e.t(`setup.capabilityRevokeHint`)})]})]})}if(o)return h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.installFailedRecovery`,{provider:o})})}),h(Y.Root,{id:`wizard-install-failed`,onPick:e=>{e===0?s():c()},children:[m(Y.Item,{label:e.t(`setup.actionRetryInstall`)}),m(Y.Item,{label:e.t(`setup.actionChooseAnotherProvider`)})]})]});if(y){let t=v.find(e=>e.value===n)?.label??n;return h(g,{children:[m(_,{color:u.text,children:e.t(`setup.installingProvider`,{provider:t})}),m(Zr,{})]})}return m(Y.Root,{id:`wizard-dialog-2`,onPick:e=>{!y&&v[e]&&l(v[e].value)},activeIndex:d,onActiveChange:p,children:v.map(e=>m(Y.Item,{label:e.label,detail:e.detail,color:u.selection},e.value))})}function $r({request:t,authMode:n,setAuthMode:r,oauthUrl:i,oauthCode:a,oauthInstructions:o,apiKey:s,apiKeyRef:c,setApiKey:l,onOAuthStart:u,onApiKeySubmit:d,onOpenAgain:v,onSwitchToApiKey:y,onRetryAuth:b,onOpenProxySettings:x,authFailure:S,selectedProvider:C}){let w=K(),[T,E]=f(0),D=n,O=t.providerAuthOptions(C);if(J(`wizard-dialog-3`,(e,n)=>{if(D===`key-input`)return n.return&&c.current.trim()?(d(),!0):n.escape?(r(`select`),!0):e&&e.length>0?(l(c.current+e),!0):((n.backspace||n.delete)&&l(c.current.slice(0,-1)),!0);if(D!==`select`)return!1;if(n.upArrow||n.downArrow)return E(e=>(e+1)%Math.max(O.length,1)),!0;if(n.return&&O[T]){let e=O[T];return e.value===`oauth`&&t.onProviderOAuthStart?u():e.value===`key`&&(l(``),r(`key-input`)),!0}let i=e?Number(e):NaN;if(Number.isInteger(i)&&i>=1&&i<=O.length){let e=O[i-1];return e.value===`oauth`&&t.onProviderOAuthStart?u():e.value===`key`&&(l(``),r(`key-input`)),!0}return!1}),S){let t=S===`network`;return h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{color:w.error,children:e.t(t?`setup.authFailedNetwork`:`setup.authFailedRejected`)})}),h(Y.Root,{id:`wizard-auth-failed`,onPick:e=>{if(t&&e===0){x();return}(t?e-1:e)===0?b():y()},children:[t?m(Y.Item,{label:e.t(`setup.actionOpenProxySettings`)}):null,m(Y.Item,{label:e.t(`setup.actionRetryAuth`)}),m(Y.Item,{label:e.t(`setup.actionUseApiKeyInstead`)})]})]})}return t.onProviderOAuthStart&&n===`oauth-wait`?h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{children:a?`Complete device authorization`:`Sign in via OAuth`})}),a?h(p,{children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`1. Open this page:`})}),i&&m(g,{marginBottom:G.tight,children:h($,{type:`secondary`,children:[` `,i]})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`2. Enter this code:`})}),m(g,{marginBottom:G.tight,children:h(_,{bold:!0,color:w.text,children:[` `,a]})}),o&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:o})})]}):h(p,{children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`Open this URL in your browser to authorize:`})}),i&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:i})})]}),m(g,{marginBottom:G.tight,children:m(_,{color:w.text,children:e.t(`setup.oauthWaiting`)})}),h(Y.Root,{id:`wizard-oauth-wait`,onPick:e=>{e===0?v():y()},children:[m(Y.Item,{label:e.t(`setup.actionOpenAgain`)}),m(Y.Item,{label:e.t(`setup.actionUseApiKeyInstead`)})]})]}):n===`key-input`?h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{children:`Paste your API key`})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`Generate a key on your provider dashboard and paste it below.`})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.apiKeyStorageNote`)})}),m(g,{marginBottom:G.tight,children:m(rn,{value:s,offset:0,columns:60,mode:`dialog`,mask:!0,placeholder:e.t(`setup.wizardApiKeyPlaceholder`),focused:!0})})]}):n===`logging-in`?m(g,{flexDirection:`column`,children:m(_,{color:w.text,children:e.t(`setup.loggingIn`)})}):h(g,{flexDirection:`column`,children:[C&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:C})}),m(g,{flexDirection:`column`,children:O.map((e,t)=>h(g,{marginBottom:G.tight,flexDirection:`column`,children:[h(_,{color:t===T?w.selection:w.inactive,bold:t===T,children:[t===T?B.pointer:` `,` `,e.label]}),e.detail&&m(g,{marginLeft:G.section,children:m($,{type:`secondary`,children:e.detail})})]},e.value))})]})}function ei({request:t,onModel:n,modelOptionsOverride:r}){let i=r??t.modelOptions,a=t=>t===`unauthenticated`?e.t(`setup.modelUnusableUnauthenticated`):t===`oauth-429-risk`?e.t(`setup.modelUnusableOauthRisk`):``;return h(g,{flexDirection:`column`,children:[i.some(e=>e.recommended)&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.modelRecommendedHint`)})}),m(Tr.Root,{maxVisible:8,frame:!1,onValueChange:e=>{n(e)},children:i.map(t=>{let n=a(t.unusableReason),r=[t.recommended?e.t(`setup.modelRecommendedTag`):``,n,t.detail??``].filter(Boolean).join(` · `);return m(Tr.Item,{value:t.value,detail:r||void 0,children:t.label},t.value)})})]})}function ti({request:t,onComplete:n}){let r=K();return J(`wizard-dialog-4`,(e,t)=>t.return?(n(),!0):!1),h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.tryAsking`)})}),m(g,{flexDirection:`column`,marginBottom:G.tight,children:t.examplePrompts.map((e,t)=>h($,{type:`secondary`,children:[` "`,e,`"`]},t))}),m(_,{color:r.text,children:e.t(`setup.pressEnterToStart`)})]})}export{sn as $,G as $t,Un as A,Ue as At,wn as B,je as Bt,Kn as C,ct as Ct,Bn as D,st as Dt,Hn as E,rt as Et,Nn as F,Le as Ft,xn as G,Ee as Gt,Tn as H,Me as Ht,Pn as I,Ie as It,mn as J,Te as Jt,_n as K,we as Kt,Mn as L,Fe as Lt,Ln as M,He as Mt,In as N,Ge as Nt,zn as O,ot as Ot,$ as P,ze as Pt,on as Q,fe as Qt,kn as R,Pe as Rt,Jn as S,Xe as St,Wn as T,et as Tt,Dn as U,ke as Ut,En as V,Ne as Vt,Cn as W,De as Wt,fn as X,ve as Xt,dn as Y,Se as Yt,un as Z,ye as Zt,$n as _,x as _n,Y as _t,Pr as a,H as an,Ot as at,Zn as b,Ze as bt,Or as c,se as cn,Pt as ct,hr as d,re as dn,Et as dt,de as en,an as et,cr as f,z as fn,Z as ft,tr as g,T as gn,gt,or as h,w as hn,bt as ht,Fr as i,U as in,kt as it,Rn as j,Ke as jt,Vn as k,nt as kt,Er as l,oe as ln,Ft as lt,ar as m,C as mn,yt as mt,Kr as n,W as nn,Gt as nt,jr as o,V as on,Nt as ot,sr as p,S as pn,Ct as pt,vn as q,K as qt,Rr as r,B as rn,It as rt,Dr as s,L as sn,At as st,Yr as t,ue as tn,rn as tt,Tr as u,ce as un,X as ut,Qn as v,Je as vt,Gn as w,J as wt,Xn as x,Ye as xt,er as y,$e as yt,On as z,q as zt};
|
|
10
|
+
//# sourceMappingURL=WizardDialog-zXXC_W25.js.map
|