@yuriai/web 0.2.24 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-pXIw9gfD.js → AgentAvatar--wjVXk3I.js} +1 -1
- package/dist/assets/{AssistantView-C-w3bUrv.js → AssistantView-CSpW-4g6.js} +3 -3
- package/dist/assets/{DiagramView-DG3ivTxa.js → DiagramView-DN_rHdr9.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DAByozhu.js → FadeInOnReveal-555z1y1N.js} +1 -1
- package/dist/assets/{GuiPluginSurface-BVnl7lAb.js → GuiPluginSurface-BPMATuPa.js} +1 -1
- package/dist/assets/{GuiPluginWindow-Ccm-tyo2.js → GuiPluginWindow-CAmfr79x.js} +1 -1
- package/dist/assets/{Icon-_iMMNG9-.js → Icon-Bn4Eec3Y.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BPEqdGkV.js → ImageLoadingPlaceholder-BMsQLN_b.js} +1 -1
- package/dist/assets/{LoadingImage-COJSLMyx.js → LoadingImage-DI7sb_H_.js} +1 -1
- package/dist/assets/{MarkdownRenderer-BvAzySCw.js → MarkdownRenderer-DP2a0lfG.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BNKrdLn6.js → MarkdownRendererImpl-B9K5q0Lc.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-D4UBaz2A.js → MarkstreamRendererImpl-9gUEVQck.js} +1 -1
- package/dist/assets/MobileDetailNavigation-C9NHt08G.js +1 -0
- package/dist/assets/{MobileResizableSheet-Cp3AyvCP.js → MobileResizableSheet-_6OvPSMI.js} +1 -1
- package/dist/assets/{MobileShareBridge-BAGwzKL9.js → MobileShareBridge-BrdOiu_r.js} +2 -2
- package/dist/assets/{MobileTabPageHeader-B8XecBxj.js → MobileTabPageHeader-qe23xT2-.js} +1 -1
- package/dist/assets/{MultiRunWindow-wzhT2t36.js → MultiRunWindow-CvHADKf9.js} +1 -1
- package/dist/assets/{OnboardingScreen-BwQKn_88.js → OnboardingScreen-g8PDztN3.js} +1 -1
- package/dist/assets/{OverlayScrollbar-U7GvtZ-e.js → OverlayScrollbar-COv8rH_z.js} +1 -1
- package/dist/assets/{SettingsView-CUJaYbvx.js → SettingsView-DK8Jkkhd.js} +1 -1
- package/dist/assets/{SettingsWindow-Bj0swB6o.js → SettingsWindow-EP8KZok8.js} +1 -1
- package/dist/assets/{TerminalView-DxdoY20L.js → TerminalView-BLer-ZhM.js} +1 -1
- package/dist/assets/ToolOutputDialog-DI-s2TBb.js +10 -0
- package/dist/assets/{YuriLogo-BFsNnpdF.js → YuriLogo-BP4j1iqV.js} +1 -1
- package/dist/assets/{appThemeRegistry-B8xSNJj3.js → appThemeRegistry-BnQF2GlY.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-C2SmtQG7.js → assistant-attachment-cache-Cis9yYGt.js} +1 -1
- package/dist/assets/{button-K_jXf_uP.js → button-Be1cqulG.js} +1 -1
- package/dist/assets/{capgoAdapter-EJ9NoUtY.js → capgoAdapter-B31jIkD8.js} +1 -1
- package/dist/assets/{collapsible-DqW91GHI.js → collapsible-DqfguRMp.js} +1 -1
- package/dist/assets/{desktop-5DP3-Bao.js → desktop-JwYqThiw.js} +1 -1
- package/dist/assets/{desktopHosts-CrVcscUO.js → desktopHosts-CB0CTcMg.js} +1 -1
- package/dist/assets/{desktopRelayRestore-DJFLfsuw.js → desktopRelayRestore-CoLLVJw8.js} +1 -1
- package/dist/assets/{device-BKQ_0FdZ.js → device-hj359GjJ.js} +1 -1
- package/dist/assets/{diagram-Pn5Vu970.js → diagram-hEIRiKol.js} +1 -1
- package/dist/assets/{dialog-DivrqsAq.js → dialog-BS-KgM5J.js} +1 -1
- package/dist/assets/{dropdown-menu.styles-zVps2mhA.js → dropdown-menu.styles-xxM2ofOp.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-BHQaa6JY.js → fileMentionTouchSelection-CTh0Mc2g.js} +1 -1
- package/dist/assets/{fileQueries-Bd-OEFmO.js → fileQueries-COS23nLq.js} +1 -1
- package/dist/assets/{fileReferenceActions-DkLLKj6A.js → fileReferenceActions-Cus9oSW7.js} +1 -1
- package/dist/assets/{gitApi-CxEKzsxG.js → gitApi-deADOzlN.js} +1 -1
- package/dist/assets/{gitApiHttp-Bnr4_wxy.js → gitApiHttp-BBRKl9WX.js} +1 -1
- package/dist/assets/{gui-D3wrcUs6.js → gui-BHEKelUx.js} +1 -1
- package/dist/assets/{host-DgJqhX6n.js → host-DrqLUbqt.js} +1 -1
- package/dist/assets/{image-loading-DVZlFuU5.js → image-loading-DJZLvhMd.js} +1 -1
- package/dist/assets/{input-BcXfvvm_.js → input-DTdHYZ6r.js} +1 -1
- package/dist/assets/{insertionBoundaries-BRe1eEJ8.js → insertionBoundaries-h2be7xbf.js} +1 -1
- package/dist/assets/{main-DrTZmnej.js → main-BpBrYqtJ.js} +4 -4
- package/dist/assets/main-C2QklNP4.js +2 -0
- package/dist/assets/{markdownHeightCache-BaLmCxOF.js → markdownHeightCache-DnR01ECa.js} +1 -1
- package/dist/assets/{mcpQueries-CZhOdHBy.js → mcpQueries-Cpb22_60.js} +1 -1
- package/dist/assets/miniChat-C-9deNrt.js +2 -0
- package/dist/assets/mobile-DW7tEL-k.js +2 -0
- package/dist/assets/{mobileBackNavigation-YpHutGKo.js → mobileBackNavigation-BibkyIeB.js} +1 -1
- package/dist/assets/{multirun-CMHEBqrK.js → multirun-CPvUnP91.js} +1 -1
- package/dist/assets/{native-config-BB2iYljF.js → native-config-DA8S8EqV.js} +1 -1
- package/dist/assets/{persistence-BPb2hZ3c.js → persistence-CBL0OOdj.js} +1 -1
- package/dist/assets/{platform-wGCQUVxr.js → platform-DFJEtBlo.js} +1 -1
- package/dist/assets/{projectMeta-Dg9OJmrW.js → projectMeta-BwAS96mf.js} +1 -1
- package/dist/assets/{queryRuntime-DWgXfxGx.js → queryRuntime-Dkpnq3Z1.js} +1 -1
- package/dist/assets/{readiness-jjsKReaO.js → readiness-RiznV1AX.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DZwB5g10.js → renderElectronMiniChatApp-DdGqTh4X.js} +2 -2
- package/dist/assets/renderMobileApp-Bipi0hKv.js +28 -0
- package/dist/assets/runtime-auth-DBn9yahL.js +1 -0
- package/dist/assets/{runtime-fetch-DfALP7-b.js → runtime-fetch-D4ja813o.js} +1 -1
- package/dist/assets/{runtime-file-download-xvItwYMc.js → runtime-file-download-B_c7JBoS.js} +1 -1
- package/dist/assets/runtime-file-resource-DpTxBCsp.js +2 -0
- package/dist/assets/{runtime-switch-DhMY9eiB.js → runtime-switch-DEZ1K7qW.js} +1 -1
- package/dist/assets/{runtimeConfig-Dltne9D7.js → runtimeConfig-Dx7Y6Yvp.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-Cg5UpXxg.js → runtimeEndpointReset-0buInzjw.js} +3 -3
- package/dist/assets/{scheduledTaskNavigation-Bk2y-IY1.js → scheduledTaskNavigation-CYozx15H.js} +1 -1
- package/dist/assets/{sessionChangeSummary-DEHSsyvw.js → sessionChangeSummary-BGisROOB.js} +1 -1
- package/dist/assets/{sessionLookup-2R9LMoF8.js → sessionLookup-B7kUOIpO.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DR_NRIKS.js → sortable-tabs-strip-CQZ16rbO.js} +1 -1
- package/dist/assets/{speechSettingsQueries-ozQ8Mhi0.js → speechSettingsQueries-CWXTghOr.js} +2 -2
- package/dist/assets/src-BFsc_2gs.css +2 -0
- package/dist/assets/tap-LkQum5bB.js +1 -0
- package/dist/assets/{terminalApi-Cjd7Jry6.js → terminalApi-C0_GUlPR.js} +1 -1
- package/dist/assets/{textarea-BnV-WjE-.js → textarea-BU8JtaSQ.js} +1 -1
- package/dist/assets/{tooltip-8gf-KZqb.js → tooltip-C8DhNU1d.js} +1 -1
- package/dist/assets/touch-gestures-zegXCZEP.js +1 -0
- package/dist/assets/{types-DP6as8RK.js → types-C9aO7yfx.js} +1 -1
- package/dist/assets/{useAppFontEffects-cZSrS9NV.js → useAppFontEffects-Bs6kVjrE.js} +39 -39
- package/dist/assets/{useAssistantUIStore-BZt-lLlW.js → useAssistantUIStore-NlYBroMc.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-BSdFqddg.js → useDesktopWindowControlsLayout-COBTly74.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-e-F-XtxW.js → useEffectiveDirectory-Bg0LmEqP.js} +1 -1
- package/dist/assets/{useFontPreferences-CGThMzt0.js → useFontPreferences-DQAS94Z4.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BIYkf6Km.js → useMobileNavigationStore-hhiMBg5n.js} +4 -4
- package/dist/assets/{useUIStore-CEingF2z.js → useUIStore-96W41KFb.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-B3gQr9bJ.js → useWorkerHighlightedLines-BZUO0Si5.js} +1 -1
- package/dist/index.html +21 -21
- package/dist/mini-chat.html +21 -21
- package/dist/mobile.html +21 -21
- package/package.json +1 -1
- package/server/lib/relay/DOCUMENTATION.md +27 -0
- package/server/lib/relay/cross-compat.test.js +42 -1
- package/server/lib/relay/e2ee.js +2 -2
- package/server/lib/relay/host-client.js +5 -3
- package/server/lib/relay/relay-server.e2e.test.ts +52 -1
- package/server/lib/relay/tunnel-codec.js +6 -5
- package/server/lib/relay/tunnel-host.js +4 -4
- package/server/lib/relay/tunnel-host.test.js +21 -0
- package/server/lib/remote-desktop/DOCUMENTATION.md +8 -0
- package/dist/assets/MobileDetailNavigation-C2dQ4cxR.js +0 -1
- package/dist/assets/ToolOutputDialog-T7WEKBA_.js +0 -10
- package/dist/assets/main-Bx5Hr212.js +0 -2
- package/dist/assets/miniChat-B9OCzzmD.js +0 -2
- package/dist/assets/mobile-CWceFL9L.js +0 -2
- package/dist/assets/renderMobileApp-BR5Ewan-.js +0 -28
- package/dist/assets/runtime-auth-BaBM02zI.js +0 -1
- package/dist/assets/runtime-file-resource-DtsKbFf3.js +0 -2
- package/dist/assets/src-BxW5eh2m.css +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,v as n,x as r}from"./desktop-5DP3-Bao.js";import{it as i,rt as a}from"./vendor-base-ui-CdzJ6My_.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{a as s,i as c,o as l,t as u}from"./store-7wItZZ7_.js";import{n as d,t as f}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as p}from"./vendor-tailwind-merge-BicNWLTg.js";var m=e(i(),1),h=o(),g=async(e,r)=>{if(!t())throw Error(`Desktop runtime is not available`);return n(e,r)},_=async()=>{if(r())try{await g(`desktop_start_window_drag`)}catch{}},v=async e=>{if(r())try{await g(`desktop_set_window_title`,{title:e})}catch{}},y=async(e,t)=>{if(r())try{await g(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},ee=async e=>{if(r())try{await g(`desktop_set_menu_locale`,{locale:e})}catch{}},b=async()=>{if(!r())return null;try{let e=await g(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},x=m.createContext(null),S=a(),C=e=>{let t=(0,h.c)(19),{children:n}=e,r=c(w),i=c(te),a=c(T),o=c(ne),d,f;t[0]===r?(d=t[1],f=t[2]):(d=()=>{typeof document>`u`||(document.documentElement.lang=r)},f=[r],t[0]=r,t[1]=d,t[2]=f),m.useEffect(d,f);let p,g;t[3]!==a||t[4]!==r?(p=()=>{a===null&&ee(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=p,t[6]=g):(p=t[5],g=t[6]),m.useEffect(p,g);let _;t[7]===i?_=t[8]:(_=(e,t)=>u(i,e,t),t[7]=i,t[8]=_);let v=_,y;t[9]===v?y=t[10]:(y=e=>v(l[e]),t[9]=v,t[10]=y);let b;t[11]!==r||t[12]!==o||t[13]!==v||t[14]!==y?(b={locale:r,locales:s,setLocale:o,label:y,t:v},t[11]=r,t[12]=o,t[13]=v,t[14]=y,t[15]=b):b=t[15];let C=b,E;return t[16]!==n||t[17]!==C?(E=(0,S.jsx)(x.Provider,{value:C,children:n}),t[16]=n,t[17]=C,t[18]=E):E=t[18],E};function w(e){return e.locale}function te(e){return e.dictionary}function T(e){return e.loadingLocale}function ne(e){return e.setLocale}var E={startingApi:`Starting OpenCode API…`,initializing:`Initializing…`,connecting:`Connecting…`,connected:`Connected!`,connectionError:`Connection error`,disconnected:`Disconnected`,reconnecting:`Reconnecting…`,initialDataLoadFailed:`OpenCode connected, but initial data load failed.`,cliNotFound:`OpenCode CLI not found. Please install it first.`,providersReady:`✓ Providers`,providersLoading:`… Providers`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Starting webview dev server (${e})...`,waitingDevServer:(e,t)=>`Waiting for webview dev server (${e})... attempt ${t}`,loadingData:(e,t)=>`Loading data (${e}, ${t})…`},re={startingApi:`Démarrage de l’API OpenCode…`,initializing:`Initialisation…`,connecting:`Connexion…`,connected:`Connecté !`,connectionError:`Erreur de connexion`,disconnected:`Déconnecté`,reconnecting:`Reconnexion…`,initialDataLoadFailed:`OpenCode est connecté, mais le chargement initial des données a échoué.`,cliNotFound:`L’interface en ligne de commande OpenCode est introuvable. Veuillez l’installer d’abord.`,providersReady:`✓ Fournisseurs`,providersLoading:`… Fournisseurs`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Démarrage du serveur de développement de la webview (${e})...`,waitingDevServer:(e,t)=>`En attente du serveur de développement de la webview (${e})... tentative ${t}`,loadingData:(e,t)=>`Chargement des données (${e}, ${t})…`},D={startingApi:`正在启动 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在连接…`,connected:`已连接!`,connectionError:`连接错误`,disconnected:`已断开连接`,reconnecting:`正在重新连接…`,initialDataLoadFailed:`OpenCode 已连接,但初始数据加载失败。`,cliNotFound:`未找到 OpenCode CLI。请先安装它。`,providersReady:`✓ 提供商`,providersLoading:`… 提供商`,agentsReady:`✓ Agent`,agentsLoading:`… Agent`,startingDevServer:e=>`正在启动 webview 开发服务器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 开发服务器 (${e})... 第 ${t} 次尝试`,loadingData:(e,t)=>`正在加载数据 (${e}, ${t})…`},O={startingApi:`正在啟動 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在連線…`,connected:`已連線!`,connectionError:`連線錯誤`,disconnected:`已中斷連線`,reconnecting:`正在重新連線…`,initialDataLoadFailed:`OpenCode 已連線,但初始資料載入失敗。`,cliNotFound:`找不到 OpenCode CLI。請先安裝。`,providersReady:`✓ 提供者`,providersLoading:`… 提供者`,agentsReady:`✓ 代理`,agentsLoading:`… 代理`,startingDevServer:e=>`正在啟動 webview 開發伺服器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 開發伺服器 (${e})... 第 ${t} 次嘗試`,loadingData:(e,t)=>`正在載入資料 (${e}, ${t})…`},k={startingApi:`Запуск OpenCode API…`,initializing:`Ініціалізація…`,connecting:`Підключення…`,connected:`Підключено!`,connectionError:`Помилка підключення`,disconnected:`Відключено`,reconnecting:`Повторне підключення…`,initialDataLoadFailed:`OpenCode підключено, але початкове завантаження даних не вдалося.`,cliNotFound:`OpenCode CLI не знайдено. Спершу встановіть його.`,providersReady:`✓ Провайдери`,providersLoading:`… Провайдери`,agentsReady:`✓ Агенти`,agentsLoading:`… Агенти`,startingDevServer:e=>`Запуск dev-сервера webview (${e})...`,waitingDevServer:(e,t)=>`Очікування dev-сервера webview (${e})... спроба ${t}`,loadingData:(e,t)=>`Завантаження даних (${e}, ${t})…`},A={startingApi:`Iniciando la API de OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connected:`¡Conectado!`,connectionError:`Error de conexión`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode se conectó, pero falló la carga inicial de datos.`,cliNotFound:`No se encontró OpenCode CLI. Instálalo primero.`,providersReady:`✓ Proveedores`,providersLoading:`… Proveedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando el servidor de desarrollo de webview (${e})...`,waitingDevServer:(e,t)=>`Esperando el servidor de desarrollo de webview (${e})... intento ${t}`,loadingData:(e,t)=>`Cargando datos (${e}, ${t})…`},j={startingApi:`Iniciando a API do OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connected:`Conectado!`,connectionError:`Erro de conexão`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode conectado, mas o carregamento inicial dos dados falhou.`,cliNotFound:`OpenCode CLI não encontrado. Instale-o primeiro.`,providersReady:`✓ Provedores`,providersLoading:`… Provedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando o servidor de desenvolvimento da webview (${e})...`,waitingDevServer:(e,t)=>`Aguardando o servidor de desenvolvimento da webview (${e})... tentativa ${t}`,loadingData:(e,t)=>`Carregando dados (${e}, ${t})…`},M={startingApi:`OpenCode API 시작 중…`,initializing:`초기화 중…`,connecting:`연결 중…`,connected:`연결됨!`,connectionError:`연결 오류`,disconnected:`연결 끊김`,reconnecting:`다시 연결 중…`,initialDataLoadFailed:`OpenCode에 연결되었지만 초기 데이터 로드에 실패했습니다.`,cliNotFound:`OpenCode CLI를 찾을 수 없습니다. 먼저 설치하세요.`,providersReady:`✓ 공급자`,providersLoading:`… 공급자`,agentsReady:`✓ 에이전트`,agentsLoading:`… 에이전트`,startingDevServer:e=>`webview 개발 서버 시작 중 (${e})...`,waitingDevServer:(e,t)=>`webview 개발 서버 대기 중 (${e})... ${t}번째 시도`,loadingData:(e,t)=>`데이터 로드 중 (${e}, ${t})…`},N={startingApi:`Uruchamianie API OpenCode…`,initializing:`Inicjalizacja…`,connecting:`Łączenie…`,connected:`Połączono!`,connectionError:`Błąd połączenia`,disconnected:`Rozłączono`,reconnecting:`Ponowne łączenie…`,initialDataLoadFailed:`OpenCode połączony, ale początkowe ładowanie danych nie powiodło się.`,cliNotFound:`Nie znaleziono OpenCode CLI. Najpierw go zainstaluj.`,providersReady:`✓ Dostawcy`,providersLoading:`… Dostawcy`,agentsReady:`✓ Agenci`,agentsLoading:`… Agenci`,startingDevServer:e=>`Uruchamianie serwera deweloperskiego webview (${e})...`,waitingDevServer:(e,t)=>`Oczekiwanie na serwer deweloperski webview (${e})... próba ${t}`,loadingData:(e,t)=>`Ładowanie danych (${e}, ${t})…`},P={startingApi:`OpenCode API を起動中…`,initializing:`初期化中…`,connecting:`接続中…`,connected:`接続完了!`,connectionError:`接続エラー`,disconnected:`切断されました`,reconnecting:`再接続中…`,initialDataLoadFailed:`OpenCode に接続しましたが、初期データの読み込みに失敗しました。`,cliNotFound:`OpenCode CLI が見つかりません。先にインストールしてください。`,providersReady:`✓ プロバイダ`,providersLoading:`… プロバイダ`,agentsReady:`✓ エージェント`,agentsLoading:`… エージェント`,startingDevServer:e=>`Webview 開発サーバーを起動中 (${e})...`,waitingDevServer:(e,t)=>`Webview 開発サーバーを待機中 (${e})... 試行 ${t}`,loadingData:(e,t)=>`データを読み込み中 (${e}, ${t})…`},F=e=>I[e],I={en:E,fr:re,"zh-CN":D,"zh-TW":O,uk:k,es:A,"pt-BR":j,ko:M,pl:N,ja:P},L={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},R=e=>L[e]??`en-US`,z=()=>R(c.getState().locale);function B(){let e=m.useContext(x);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}async function V(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}function H(...e){return p(d(e))}var U=()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),W=()=>typeof navigator>`u`?!1:/Windows/.test(navigator.userAgent||``),G=()=>U()?`common.revealPath.finder`:W()?`common.revealPath.fileExplorer`:`common.revealPath.fileManager`,K=e=>U()&&r()?e.metaKey:e.ctrlKey,q=()=>U()&&r()?`⌘`:`Ctrl`,J=(e,t)=>{let n=e??``,r=Math.max(16,t?.maxLength??45);if(n.length<=r)return n;let i=n.split(`/`);if(i.length<=1)return n;let a=i.pop()??``;if(!a)return n;let o=Math.max(0,r-(a.length+2));if(o<=0)return`…/${a}`;let s=``;for(let e of i){if(!e)continue;let t=s?`${s}/${e}`:e;if(t.length>o)break;s=t}if(!s){let e=i[0]??``;s=e?e.slice(0,o):``}return s?`${s}…/${a}`:`…/${a}`},Y=e=>e?e===`/`?`/`:e.replace(/\/+$/,``):``;function X(e,t){if(!e)return``;let n=Y(e);if(n===`/`)return`/`;let r=t?Y(t):void 0;if(r&&r!==`/`){if(n===r)return`~`;if(n.startsWith(`${r}/`)){let e=n.slice(r.length+1);return e?`~/${e}`:`~`}}return n}function ie(e,t){if(!e)return`/`;let n=Y(e);if(!n||n===`/`)return`/`;let r=t?Y(t):void 0;return r&&r!==`/`&&n===r?`~`:n.split(`/`).pop()||n||`/`}function ae(e,t){let n=(0,h.c)(3),r;return n[0]!==e||n[1]!==t?(r=n=>{for(let r of[e,t])r&&(typeof r==`function`?r(n):r.current=n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],r}function oe(e,t){let n={...t};for(let r in e){let i=t[r],a=e[r];n[r]=/^on[A-Z]/.test(r)&&typeof i==`function`&&typeof a==`function`?(...e)=>{a(...e),i(...e)}:r===`className`&&typeof i==`string`&&typeof a==`string`?`${a} ${i}`:r===`style`&&typeof i==`object`&&typeof a==`object`?{...a,...i}:a}return n}var Z=m.forwardRef(function(e,t){let n=(0,h.c)(3),{children:r,...i}=e,a=m.isValidElement(r)?r:null,o=ae(t,a?a.ref:void 0);if(!a)return null;let s=oe(a.props,i),c;return n[0]!==o||n[1]!==s?(c={...s,ref:o},n[0]=o,n[1]=s,n[2]=c):c=n[2],m.cloneElement(a,c)}),Q=[`bg-[var(--surface-muted)] text-foreground border-0 shadow-none`,`hover:bg-[color-mix(in_srgb,var(--foreground)_6%,var(--surface-muted))]`,`active:bg-[color-mix(in_srgb,var(--foreground)_12%,var(--surface-muted))]`,`focus-visible:border-transparent focus-visible:ring-foreground/20`].join(` `),$=[`bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]`,`text-[var(--status-error)]`,`border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]`].join(` `),se=f([`group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium tracking-[0.01em] shrink-0 select-none`,`transition-[background-color,border-color,color,opacity,filter,transform] duration-150 ease-out outline-none`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`],{variants:{variant:{default:Q,destructive:H($,`focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`),neutral:Q,outline:Q,mobileGlass:`yuri-mobile-floating-action text-foreground hover:brightness-105 active:bg-interactive-active focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,chip:H(Q,`aria-pressed:bg-[color-mix(in_srgb,var(--foreground)_6%,var(--surface-muted))]`,`aria-pressed:hover:bg-[color-mix(in_srgb,var(--foreground)_8%,var(--surface-muted))]`,`aria-pressed:active:bg-[color-mix(in_srgb,var(--foreground)_10%,var(--surface-muted))]`),secondary:`bg-interactive-hover text-foreground hover:bg-interactive-active`,ghost:`text-foreground hover:bg-interactive-hover hover:text-foreground active:bg-interactive-active`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-3.5 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]`,xs:`h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]`,lg:`h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]`,icon:`size-9`,mobileIcon:`size-10 min-h-10 min-w-10 rounded-full`}},defaultVariants:{variant:`default`,size:`default`}}),ce=new Set([`icon`,`mobileIcon`,`xs`]);function le(e){let t=(0,h.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,variant:s,size:i,asChild:a,type:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a!==void 0&&a,l=c?Z:`button`,u;t[7]!==c||t[8]!==o?(u=c?o===void 0?{}:{type:o}:{type:o??`button`},t[7]=c,t[8]=o,t[9]=u):u=t[9];let d=u,f=i!=null&&ce.has(i)?`compact`:void 0,p;t[10]!==n||t[11]!==i||t[12]!==s?(p=H(se({variant:s,size:i,className:n})),t[10]=n,t[11]=i,t[12]=s,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==f||t[16]!==r||t[17]!==p||t[18]!==d?(m=(0,S.jsx)(l,{"data-slot":`button`,"data-mobile-press-feedback":f,className:p,...d,...r}),t[14]=l,t[15]=f,t[16]=r,t[17]=p,t[18]=d,t[19]=m):m=t[19],m}export{g as _,X as a,_ as b,K as c,V as d,B as f,b as g,C as h,ie as i,U as l,F as m,Z as n,q as o,z as p,H as r,G as s,le as t,J as u,y as v,v as y};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,v as n,x as r}from"./desktop-JwYqThiw.js";import{it as i,rt as a}from"./vendor-base-ui-CdzJ6My_.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{a as s,i as c,o as l,t as u}from"./store-7wItZZ7_.js";import{n as d,t as f}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as p}from"./vendor-tailwind-merge-BicNWLTg.js";var m=e(i(),1),h=o(),g=async(e,r)=>{if(!t())throw Error(`Desktop runtime is not available`);return n(e,r)},_=async()=>{if(r())try{await g(`desktop_start_window_drag`)}catch{}},v=async e=>{if(r())try{await g(`desktop_set_window_title`,{title:e})}catch{}},y=async(e,t)=>{if(r())try{await g(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},ee=async e=>{if(r())try{await g(`desktop_set_menu_locale`,{locale:e})}catch{}},b=async()=>{if(!r())return null;try{let e=await g(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},x=m.createContext(null),S=a(),C=e=>{let t=(0,h.c)(19),{children:n}=e,r=c(w),i=c(te),a=c(T),o=c(ne),d,f;t[0]===r?(d=t[1],f=t[2]):(d=()=>{typeof document>`u`||(document.documentElement.lang=r)},f=[r],t[0]=r,t[1]=d,t[2]=f),m.useEffect(d,f);let p,g;t[3]!==a||t[4]!==r?(p=()=>{a===null&&ee(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=p,t[6]=g):(p=t[5],g=t[6]),m.useEffect(p,g);let _;t[7]===i?_=t[8]:(_=(e,t)=>u(i,e,t),t[7]=i,t[8]=_);let v=_,y;t[9]===v?y=t[10]:(y=e=>v(l[e]),t[9]=v,t[10]=y);let b;t[11]!==r||t[12]!==o||t[13]!==v||t[14]!==y?(b={locale:r,locales:s,setLocale:o,label:y,t:v},t[11]=r,t[12]=o,t[13]=v,t[14]=y,t[15]=b):b=t[15];let C=b,E;return t[16]!==n||t[17]!==C?(E=(0,S.jsx)(x.Provider,{value:C,children:n}),t[16]=n,t[17]=C,t[18]=E):E=t[18],E};function w(e){return e.locale}function te(e){return e.dictionary}function T(e){return e.loadingLocale}function ne(e){return e.setLocale}var E={startingApi:`Starting OpenCode API…`,initializing:`Initializing…`,connecting:`Connecting…`,connected:`Connected!`,connectionError:`Connection error`,disconnected:`Disconnected`,reconnecting:`Reconnecting…`,initialDataLoadFailed:`OpenCode connected, but initial data load failed.`,cliNotFound:`OpenCode CLI not found. Please install it first.`,providersReady:`✓ Providers`,providersLoading:`… Providers`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Starting webview dev server (${e})...`,waitingDevServer:(e,t)=>`Waiting for webview dev server (${e})... attempt ${t}`,loadingData:(e,t)=>`Loading data (${e}, ${t})…`},re={startingApi:`Démarrage de l’API OpenCode…`,initializing:`Initialisation…`,connecting:`Connexion…`,connected:`Connecté !`,connectionError:`Erreur de connexion`,disconnected:`Déconnecté`,reconnecting:`Reconnexion…`,initialDataLoadFailed:`OpenCode est connecté, mais le chargement initial des données a échoué.`,cliNotFound:`L’interface en ligne de commande OpenCode est introuvable. Veuillez l’installer d’abord.`,providersReady:`✓ Fournisseurs`,providersLoading:`… Fournisseurs`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Démarrage du serveur de développement de la webview (${e})...`,waitingDevServer:(e,t)=>`En attente du serveur de développement de la webview (${e})... tentative ${t}`,loadingData:(e,t)=>`Chargement des données (${e}, ${t})…`},D={startingApi:`正在启动 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在连接…`,connected:`已连接!`,connectionError:`连接错误`,disconnected:`已断开连接`,reconnecting:`正在重新连接…`,initialDataLoadFailed:`OpenCode 已连接,但初始数据加载失败。`,cliNotFound:`未找到 OpenCode CLI。请先安装它。`,providersReady:`✓ 提供商`,providersLoading:`… 提供商`,agentsReady:`✓ Agent`,agentsLoading:`… Agent`,startingDevServer:e=>`正在启动 webview 开发服务器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 开发服务器 (${e})... 第 ${t} 次尝试`,loadingData:(e,t)=>`正在加载数据 (${e}, ${t})…`},O={startingApi:`正在啟動 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在連線…`,connected:`已連線!`,connectionError:`連線錯誤`,disconnected:`已中斷連線`,reconnecting:`正在重新連線…`,initialDataLoadFailed:`OpenCode 已連線,但初始資料載入失敗。`,cliNotFound:`找不到 OpenCode CLI。請先安裝。`,providersReady:`✓ 提供者`,providersLoading:`… 提供者`,agentsReady:`✓ 代理`,agentsLoading:`… 代理`,startingDevServer:e=>`正在啟動 webview 開發伺服器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 開發伺服器 (${e})... 第 ${t} 次嘗試`,loadingData:(e,t)=>`正在載入資料 (${e}, ${t})…`},k={startingApi:`Запуск OpenCode API…`,initializing:`Ініціалізація…`,connecting:`Підключення…`,connected:`Підключено!`,connectionError:`Помилка підключення`,disconnected:`Відключено`,reconnecting:`Повторне підключення…`,initialDataLoadFailed:`OpenCode підключено, але початкове завантаження даних не вдалося.`,cliNotFound:`OpenCode CLI не знайдено. Спершу встановіть його.`,providersReady:`✓ Провайдери`,providersLoading:`… Провайдери`,agentsReady:`✓ Агенти`,agentsLoading:`… Агенти`,startingDevServer:e=>`Запуск dev-сервера webview (${e})...`,waitingDevServer:(e,t)=>`Очікування dev-сервера webview (${e})... спроба ${t}`,loadingData:(e,t)=>`Завантаження даних (${e}, ${t})…`},A={startingApi:`Iniciando la API de OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connected:`¡Conectado!`,connectionError:`Error de conexión`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode se conectó, pero falló la carga inicial de datos.`,cliNotFound:`No se encontró OpenCode CLI. Instálalo primero.`,providersReady:`✓ Proveedores`,providersLoading:`… Proveedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando el servidor de desarrollo de webview (${e})...`,waitingDevServer:(e,t)=>`Esperando el servidor de desarrollo de webview (${e})... intento ${t}`,loadingData:(e,t)=>`Cargando datos (${e}, ${t})…`},j={startingApi:`Iniciando a API do OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connected:`Conectado!`,connectionError:`Erro de conexão`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode conectado, mas o carregamento inicial dos dados falhou.`,cliNotFound:`OpenCode CLI não encontrado. Instale-o primeiro.`,providersReady:`✓ Provedores`,providersLoading:`… Provedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando o servidor de desenvolvimento da webview (${e})...`,waitingDevServer:(e,t)=>`Aguardando o servidor de desenvolvimento da webview (${e})... tentativa ${t}`,loadingData:(e,t)=>`Carregando dados (${e}, ${t})…`},M={startingApi:`OpenCode API 시작 중…`,initializing:`초기화 중…`,connecting:`연결 중…`,connected:`연결됨!`,connectionError:`연결 오류`,disconnected:`연결 끊김`,reconnecting:`다시 연결 중…`,initialDataLoadFailed:`OpenCode에 연결되었지만 초기 데이터 로드에 실패했습니다.`,cliNotFound:`OpenCode CLI를 찾을 수 없습니다. 먼저 설치하세요.`,providersReady:`✓ 공급자`,providersLoading:`… 공급자`,agentsReady:`✓ 에이전트`,agentsLoading:`… 에이전트`,startingDevServer:e=>`webview 개발 서버 시작 중 (${e})...`,waitingDevServer:(e,t)=>`webview 개발 서버 대기 중 (${e})... ${t}번째 시도`,loadingData:(e,t)=>`데이터 로드 중 (${e}, ${t})…`},N={startingApi:`Uruchamianie API OpenCode…`,initializing:`Inicjalizacja…`,connecting:`Łączenie…`,connected:`Połączono!`,connectionError:`Błąd połączenia`,disconnected:`Rozłączono`,reconnecting:`Ponowne łączenie…`,initialDataLoadFailed:`OpenCode połączony, ale początkowe ładowanie danych nie powiodło się.`,cliNotFound:`Nie znaleziono OpenCode CLI. Najpierw go zainstaluj.`,providersReady:`✓ Dostawcy`,providersLoading:`… Dostawcy`,agentsReady:`✓ Agenci`,agentsLoading:`… Agenci`,startingDevServer:e=>`Uruchamianie serwera deweloperskiego webview (${e})...`,waitingDevServer:(e,t)=>`Oczekiwanie na serwer deweloperski webview (${e})... próba ${t}`,loadingData:(e,t)=>`Ładowanie danych (${e}, ${t})…`},P={startingApi:`OpenCode API を起動中…`,initializing:`初期化中…`,connecting:`接続中…`,connected:`接続完了!`,connectionError:`接続エラー`,disconnected:`切断されました`,reconnecting:`再接続中…`,initialDataLoadFailed:`OpenCode に接続しましたが、初期データの読み込みに失敗しました。`,cliNotFound:`OpenCode CLI が見つかりません。先にインストールしてください。`,providersReady:`✓ プロバイダ`,providersLoading:`… プロバイダ`,agentsReady:`✓ エージェント`,agentsLoading:`… エージェント`,startingDevServer:e=>`Webview 開発サーバーを起動中 (${e})...`,waitingDevServer:(e,t)=>`Webview 開発サーバーを待機中 (${e})... 試行 ${t}`,loadingData:(e,t)=>`データを読み込み中 (${e}, ${t})…`},F=e=>I[e],I={en:E,fr:re,"zh-CN":D,"zh-TW":O,uk:k,es:A,"pt-BR":j,ko:M,pl:N,ja:P},L={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},R=e=>L[e]??`en-US`,z=()=>R(c.getState().locale);function B(){let e=m.useContext(x);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}async function V(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}function H(...e){return p(d(e))}var U=()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),W=()=>typeof navigator>`u`?!1:/Windows/.test(navigator.userAgent||``),G=()=>U()?`common.revealPath.finder`:W()?`common.revealPath.fileExplorer`:`common.revealPath.fileManager`,K=e=>U()&&r()?e.metaKey:e.ctrlKey,q=()=>U()&&r()?`⌘`:`Ctrl`,J=(e,t)=>{let n=e??``,r=Math.max(16,t?.maxLength??45);if(n.length<=r)return n;let i=n.split(`/`);if(i.length<=1)return n;let a=i.pop()??``;if(!a)return n;let o=Math.max(0,r-(a.length+2));if(o<=0)return`…/${a}`;let s=``;for(let e of i){if(!e)continue;let t=s?`${s}/${e}`:e;if(t.length>o)break;s=t}if(!s){let e=i[0]??``;s=e?e.slice(0,o):``}return s?`${s}…/${a}`:`…/${a}`},Y=e=>e?e===`/`?`/`:e.replace(/\/+$/,``):``;function X(e,t){if(!e)return``;let n=Y(e);if(n===`/`)return`/`;let r=t?Y(t):void 0;if(r&&r!==`/`){if(n===r)return`~`;if(n.startsWith(`${r}/`)){let e=n.slice(r.length+1);return e?`~/${e}`:`~`}}return n}function ie(e,t){if(!e)return`/`;let n=Y(e);if(!n||n===`/`)return`/`;let r=t?Y(t):void 0;return r&&r!==`/`&&n===r?`~`:n.split(`/`).pop()||n||`/`}function ae(e,t){let n=(0,h.c)(3),r;return n[0]!==e||n[1]!==t?(r=n=>{for(let r of[e,t])r&&(typeof r==`function`?r(n):r.current=n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],r}function oe(e,t){let n={...t};for(let r in e){let i=t[r],a=e[r];n[r]=/^on[A-Z]/.test(r)&&typeof i==`function`&&typeof a==`function`?(...e)=>{a(...e),i(...e)}:r===`className`&&typeof i==`string`&&typeof a==`string`?`${a} ${i}`:r===`style`&&typeof i==`object`&&typeof a==`object`?{...a,...i}:a}return n}var Z=m.forwardRef(function(e,t){let n=(0,h.c)(3),{children:r,...i}=e,a=m.isValidElement(r)?r:null,o=ae(t,a?a.ref:void 0);if(!a)return null;let s=oe(a.props,i),c;return n[0]!==o||n[1]!==s?(c={...s,ref:o},n[0]=o,n[1]=s,n[2]=c):c=n[2],m.cloneElement(a,c)}),Q=[`bg-[var(--surface-muted)] text-foreground border-0 shadow-none`,`hover:bg-[color-mix(in_srgb,var(--foreground)_6%,var(--surface-muted))]`,`active:bg-[color-mix(in_srgb,var(--foreground)_12%,var(--surface-muted))]`,`focus-visible:border-transparent focus-visible:ring-foreground/20`].join(` `),$=[`bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]`,`text-[var(--status-error)]`,`border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]`].join(` `),se=f([`group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium tracking-[0.01em] shrink-0 select-none`,`transition-[background-color,border-color,color,opacity,filter,transform] duration-150 ease-out outline-none`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`],{variants:{variant:{default:Q,destructive:H($,`focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`),neutral:Q,outline:Q,mobileGlass:`yuri-mobile-floating-action text-foreground hover:brightness-105 active:bg-interactive-active focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,chip:H(Q,`aria-pressed:bg-[color-mix(in_srgb,var(--foreground)_6%,var(--surface-muted))]`,`aria-pressed:hover:bg-[color-mix(in_srgb,var(--foreground)_8%,var(--surface-muted))]`,`aria-pressed:active:bg-[color-mix(in_srgb,var(--foreground)_10%,var(--surface-muted))]`),secondary:`bg-interactive-hover text-foreground hover:bg-interactive-active`,ghost:`text-foreground hover:bg-interactive-hover hover:text-foreground active:bg-interactive-active`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-3.5 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]`,xs:`h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]`,lg:`h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]`,icon:`size-9`,mobileIcon:`size-10 min-h-10 min-w-10 rounded-full`}},defaultVariants:{variant:`default`,size:`default`}}),ce=new Set([`icon`,`mobileIcon`,`xs`]);function le(e){let t=(0,h.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,variant:s,size:i,asChild:a,type:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a!==void 0&&a,l=c?Z:`button`,u;t[7]!==c||t[8]!==o?(u=c?o===void 0?{}:{type:o}:{type:o??`button`},t[7]=c,t[8]=o,t[9]=u):u=t[9];let d=u,f=i!=null&&ce.has(i)?`compact`:void 0,p;t[10]!==n||t[11]!==i||t[12]!==s?(p=H(se({variant:s,size:i,className:n})),t[10]=n,t[11]=i,t[12]=s,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==f||t[16]!==r||t[17]!==p||t[18]!==d?(m=(0,S.jsx)(l,{"data-slot":`button`,"data-mobile-press-feedback":f,className:p,...d,...r}),t[14]=l,t[15]=f,t[16]=r,t[17]=p,t[18]=d,t[19]=m):m=t[19],m}export{g as _,X as a,_ as b,K as c,V as d,B as f,b as g,C as h,ie as i,U as l,F as m,Z as n,q as o,z as p,H as r,G as s,le as t,J as u,y as v,v as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as n}from"./types-
|
|
1
|
+
import{a as e,n as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as n}from"./types-C9aO7yfx.js";var r=e(`CapacitorUpdater`),i=()=>{if(typeof window>`u`)return!1;try{return t.isNativePlatform()&&t.isPluginAvailable(`CapacitorUpdater`)}catch{return!1}},a=()=>{throw new n},o=()=>({async notifyAppReady(){return i()||a(),r.notifyAppReady()},async download(e){return i()||a(),r.download(e)},async next(e){return i()||a(),r.next(e)},async reload(){return i()||a(),r.reload()},async current(){return i()||a(),r.current()},async getDeviceId(){return i()||a(),r.getDeviceId()},async list(){return i()||a(),r.list()},addListener:(async(e,t)=>(i()||a(),r.addListener(e,t)))}),s,c=async()=>s===void 0?i()?(s=o(),s):(s=null,null):s,l=()=>i();export{l as n,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,n,r,rt as i,t as a}from"./vendor-base-ui-CdzJ6My_.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{r as s}from"./button-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,n,r,rt as i,t as a}from"./vendor-base-ui-CdzJ6My_.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{r as s}from"./button-Be1cqulG.js";var c=o(),l=e(t(),1),u=i(),d=r,f=e=>{let t=(0,c.c)(14),r,i,a,o;t[0]===e?(r=t[1],i=t[2],a=t[3],o=t[4]):({className:a,asChild:r,children:i,...o}=e,t[0]=e,t[1]=r,t[2]=i,t[3]=a,t[4]=o);let d;t[5]!==r||t[6]!==i?(d=r&&l.isValidElement(i)?{render:i}:{children:i},t[5]=r,t[6]=i,t[7]=d):d=t[7];let f=d,p;t[8]===a?p=t[9]:(p=s(`flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,a),t[8]=a,t[9]=p);let m;return t[10]!==o||t[11]!==f||t[12]!==p?(m=(0,u.jsx)(n,{className:p,...o,...f}),t[10]=o,t[11]=f,t[12]=p,t[13]=m):m=t[13],m},p=e=>{let t=(0,c.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=s(`overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,u.jsx)(a,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};export{p as n,f as r,d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{w as e}from"./runtime-auth-BaBM02zI.js";import{r as t,t as n}from"./runtime-switch-DhMY9eiB.js";import{t as r}from"./runtimeAPIRegistry-C2VogTny.js";var i=[`local`,`remote`,null],a=[`ok`,`not-configured`,`unreachable`,`incompatible`,`wrong-service`,`missing`];function o(e){if(!e||typeof e!=`object`)return{valid:!1};let t=e,n=t.target,r=t.status;if(n!==null&&(typeof n!=`string`||!i.includes(n))||typeof r!=`string`||!a.includes(r))return{valid:!1};if(n===`remote`||n===`local`){if(r===`ok`&&n===`local`)return{valid:!0,outcome:{target:`local`,status:`ok`}};if(r===`ok`&&n===`remote`)return typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`ok`,hostId:t.hostId,url:t.url}};if(r===`unreachable`)return n===`local`?{valid:!0,outcome:{target:`local`,status:`unreachable`}}:typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`unreachable`,hostId:t.hostId,url:t.url}};if(r===`incompatible`||r===`wrong-service`)return n!==`remote`||typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:r,hostId:t.hostId,url:t.url}};if(r===`missing`)return n!==`remote`||typeof t.hostId!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`missing`,hostId:t.hostId}}}if(n===null){if(r===`not-configured`)return{valid:!0,outcome:{target:null,status:`not-configured`}};if(r===`missing`)return{valid:!1}}return{valid:!1}}function s(e){if(!e.isDesktopShell)return null;let t=e.bootOutcome;if(!t)return null;if(t.status===`ok`){if(t.target===`local`)return{screen:`main`};if(t.target===`remote`)return{screen:`main`,hostId:t.hostId,url:t.url}}if(t.target===null&&t.status===`not-configured`)return{screen:`chooser`};if(t.target===`local`&&t.status===`unreachable`)return{screen:`recovery`,variant:`local-unavailable`};if(t.target===`remote`){if(t.status===`unreachable`)return{screen:`recovery`,variant:`remote-unreachable`,hostId:t.hostId,url:t.url};if(t.status===`incompatible`)return{screen:`recovery`,variant:`remote-incompatible`,hostId:t.hostId,url:t.url};if(t.status===`wrong-service`)return{screen:`recovery`,variant:`remote-wrong-service`,hostId:t.hostId,url:t.url};if(t.status===`missing`)return{screen:`recovery`,variant:`remote-missing`,hostId:t.hostId}}return null}function c(e){return e.isDesktopShell?e.bootOutcomeKnown?e.bootViewIsMain===!1||e.isInitialized:!1:e.isInitialized}function l(e){return e.isDesktopShell&&!e.isDesktopLocalOriginActive}function u(){if(f()!==`valid`)return null;let e=o(d());return e.valid?e.outcome:null}var d=()=>{if(typeof window>`u`)return;let e=window.__YURI_DESKTOP_BOOT_OUTCOME__;if(e!=null)return e;let t=window.__YURI_DESKTOP_BOOT__;if(t&&typeof t.getOutcome==`function`)try{return t.getOutcome()}catch{return}return e};function f(){if(typeof window>`u`)return`not-injected`;let e=d();return e==null?`not-injected`:o(e).valid?`valid`:`malformed`}var p=()=>typeof window>`u`?null:window.__YURI_ELECTRON__??null,m=()=>typeof window>`u`?null:window.__YURI_DESKTOP__??null,h=()=>p()?.runtime===`electron`,g=()=>h()&&p()?.packaged===!0,_=e=>{if(!h())return null;let t=m()?.getPathForFile?.(e);return typeof t==`string`&&t.trim()?t:null},v=()=>{if(typeof window>`u`)return null;let e=window.__YURI_PLATFORM__;return typeof e==`string`?e:null},y=()=>{if(!h())return!1;let e=v();return e===`win32`||e===`linux`},b=(e=v())=>e===`linux`?`left`:`right`,ee=(e,t=v())=>e===`left`||e===`right`?e:b(t),x=()=>typeof m()?.invoke==`function`,S=()=>h()&&x(),C=()=>h()&&I()?m()?.guiPlugins:void 0,w=()=>h()?m()?.guiPlugins:void 0,T=()=>h()?m()?.viewExport:void 0,E=async(e,t)=>{let n=m();return typeof n?.invoke==`function`?n.invoke(e,t??{}):null},te=async e=>{if(!S()||!I())throw Error(`unsupported`);let t=await E(e.type===`status`?`desktop_remote_desktop_status`:e.type===`enabled`?`desktop_remote_desktop_enable`:`desktop_remote_desktop_permission`,{...e});if(!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`||typeof t.screenRecording!=`string`||typeof t.accessibility!=`boolean`||typeof t.helperAvailable!=`boolean`||typeof t.ready!=`boolean`)throw Error(`invalid_desktop_status`);return t},ne=async()=>{if(!S()||!I())return null;try{let e=await E(`desktop_get_launch_at_login`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get launch at login status`,e),null}},D=async e=>{if(!S()||!I())return null;try{let t=await E(`desktop_set_launch_at_login`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set launch at login status`,e),null}},O=async()=>{if(!S()||!I())return null;try{let e=await E(`desktop_get_minimize_to_tray`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get minimize to tray status`,e),null}},k=async e=>{if(!S()||!I())return null;try{let t=await E(`desktop_set_minimize_to_tray`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set minimize to tray status`,e),null}},A=async()=>{if(!S()||!I())return null;try{let e=await E(`desktop_get_keep_awake`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`||typeof e.active!=`boolean`?null:e}catch(e){return console.warn(`Failed to get keep awake status`,e),null}},j=async e=>{if(!S()||!I())return null;try{let t=await E(`desktop_set_keep_awake`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`||typeof t.active!=`boolean`?null:t}catch(e){return console.warn(`Failed to set keep awake status`,e),null}},M=e=>{let t=e.trim();if(!t)return null;try{return new URL(t).origin}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`).origin}catch{return null}}},N=e=>{let t=e.trim();if(!t)return null;try{return new URL(t)}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`)}catch{return null}}},P=e=>e.replace(/^\[|\]$/g,``).toLowerCase(),F=e=>{let t=P(e);return t===`localhost`||t===`127.0.0.1`||t===`::1`},I=()=>{if(typeof window>`u`||!L()||e())return!1;let r=t();if(r.startsWith(`host:`))return!1;if(r===`local`)return!0;let i=typeof window.__YURI_LOCAL_ORIGIN__==`string`?window.__YURI_LOCAL_ORIGIN__:``,a=N(i),o=N(n());if(!o&&a&&u()?.target===`local`)return!0;if(a&&o){if(a.origin===o.origin)return!0;let e=a.port||(a.protocol===`https:`?`443`:`80`),t=o.port||(o.protocol===`https:`?`443`:`80`);return a.protocol===o.protocol&&e===t&&F(a.hostname)&&F(o.hostname)}let s=N(window.location.origin);if(a&&s){if(a.origin===s.origin)return!0;let e=a.port||(a.protocol===`https:`?`443`:`80`),t=s.port||(s.protocol===`https:`?`443`:`80`);return a.protocol===s.protocol&&e===t&&F(a.hostname)&&F(s.hostname)}let c=M(i),l=M(window.location.origin)||window.location.origin;return c&&l&&c===l?!0:!!(s&&F(s.hostname))},L=()=>typeof window>`u`?!1:h(),R=async()=>{if(!L())return!1;try{return await E(`desktop_start_window_drag`),!0}catch{return!1}},z=()=>r()?.runtime?.isVSCode===!0,B=()=>{let e=r()?.runtime?.platform;return e===`web`?!0:e===`desktop`||e===`vscode`?!1:!z()},V=async()=>{if(typeof window<`u`){let e=window.__YURI_HOME__;if(e&&e.length>0)return e}return null},H=async e=>{if(x()&&I())try{let e=await m()?.openDialog?.({directory:!0,multiple:!1,title:`Select Working Directory`});return!e||typeof e!=`string`?{success:!1,error:`Directory selection cancelled`}:{success:!0,path:e}}catch(e){return console.warn(`Failed to request directory access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!0,path:e}},U=e=>typeof e==`object`&&!!e&&!Array.isArray(e),W=async e=>{if(x()&&I())try{let t=await m()?.openDialog?.({directory:!1,multiple:!1,title:`Select File`,returnGrant:!0,...e?.filters?{filters:e.filters}:{},...e?.defaultPath?{defaultPath:e.defaultPath}:{}});if(!t)return{success:!1,error:`File selection cancelled`};if(typeof t==`string`)return{success:!0,path:t};if(!U(t))return{success:!1,error:`File selection cancelled`};let n=typeof t.path==`string`?t.path:``;return n?{success:!0,path:n,outsideFileGrant:typeof t.outsideFileGrant==`string`?t.outsideFileGrant:void 0}:{success:!1,error:`File selection cancelled`}}catch(e){return console.warn(`Failed to request file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!1,error:`Native file picker not available`}},G=async e=>{let t=typeof e==`string`?e.trim():``;if(!t)return{success:!1,error:`Path is required`};if(!x()||!I())return{success:!1,error:`Native file access not available`};try{let e=await m()?.grantFileAccess?.(t);if(!U(e))return{success:!1,error:`File access was not granted`};let n=typeof e.path==`string`?e.path:``,r=typeof e.outsideFileGrant==`string`?e.outsideFileGrant:``;return!n||!r?{success:!1,error:`File access was not granted`}:{success:!0,path:n,outsideFileGrant:r}}catch(e){return console.warn(`Failed to request existing file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}},K=async e=>({success:!0}),q=async e=>({success:!0}),J=async e=>{if(!x())throw Error(`Desktop update checker is unavailable`);let t=await E(`desktop_check_for_updates`,{channelOverride:e});if(!t)throw Error(`Desktop update checker returned no result`);return t},Y=async e=>{x()&&await E(`desktop_ota_ready`,{version:e})},X=()=>E(`desktop_get_app_version`),Z=async e=>{let t=m();return typeof t?.listen==`function`?t.listen(`yuri:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({event:typeof r.event==`string`?r.event:void 0,data:r.data&&typeof r.data==`object`?r.data:void 0})}):null},re=async e=>{let t=m();return typeof t?.listen==`function`?t.listen(`yuri:update-ready`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({version:typeof r.version==`string`?r.version:null,downloaded:r.downloaded===!0})}):null},ie=async e=>{if(!x())return!1;let t=m(),n=null,r=0,i;try{return typeof e==`function`&&t?.listen&&(n=await t.listen(`yuri:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let a=n,o=typeof a.event==`string`?a.event:null,s=a.data&&typeof a.data==`object`?a.data:null;if(o===`Started`){r=0,i=typeof s?.contentLength==`number`?s.contentLength:void 0,e({downloaded:r,total:i});return}if(o===`Progress`){let t=s?.downloaded,n=s?.total;typeof t==`number`&&(r=t),typeof n==`number`&&(i=n),e({downloaded:r,total:i});return}o===`Finished`&&e({downloaded:r,total:i})})),await E(`desktop_download_and_install_update`),!0}catch(e){throw e instanceof Error?e:Error(String(e))}finally{if(n)try{let e=n();e instanceof Promise&&await e}catch{}}},ae=async()=>x()?Q({applyUpdate:!0}):!1,Q=async({applyUpdate:e=!1}={})=>{if(!x())return!1;try{return await E(`desktop_restart`,e?{applyUpdate:!0}:void 0),!0}catch(e){return console.warn(`Failed to restart desktop app`,e),!1}},oe=async()=>{if(!x()||!I())return null;try{let e=await E(`desktop_get_lan_address`);return typeof e==`string`&&e.trim().length>0?e.trim():null}catch(e){return console.warn(`Failed to get desktop LAN address`,e),null}},$=async(e,t)=>{if(!x()||!I())return!1;let n=e?.trim();if(!n)return!1;try{return await E(`desktop_open_path`,{path:n,app:typeof t==`string`&&t.trim().length>0?t.trim():void 0}),!0}catch(e){return console.warn(`Failed to open path`,e),!1}},se=async e=>{if(!x()||!I())return null;let t=e?.trim();if(!t)return null;try{let e=await E(`desktop_is_binary_path`,{path:t});return typeof e==`boolean`?e:null}catch{return null}},ce=async e=>{if(!x()||!I())return!1;let t=e?.trim();if(!t)return!1;try{return await E(`desktop_reveal_path`,{path:t}),!0}catch{return $(t)}},le=async(e,t)=>{if(!x()||!I())return null;let n=e?.trim();if(!n)return null;try{let e=await E(`desktop_save_markdown_file`,{defaultFileName:n,content:t});return typeof e==`string`&&e.trim().length>0?e:null}catch(e){return console.warn(`Failed to save markdown file`,e),null}},ue=async(e,n,r,i)=>{if(!x()||!i&&!I())return!1;if(i)return t()===`host:${i}`&&(await E(`desktop_open_ssh_in_app`,{projectPath:e,appId:n,hostId:i}),!0);let a=e?.trim(),o=n?.trim(),s=r?.trim();if(!a||!o||!s)return!1;try{return await E(`desktop_open_in_app`,{projectPath:a,appId:o,appName:s}),!0}catch(e){return console.warn(`Failed to open project in app`,e),!1}},de=async(e,t,n)=>{if(!x()||!I())return!1;let r=e?.trim(),i=t?.trim(),a=n?.trim();if(!r||!i||!a)return!1;try{return await E(`desktop_open_file_in_app`,{filePath:r,appId:i,appName:a}),!0}catch(e){return console.warn(`Failed to open file in app`,e),!1}},fe=async(e,t)=>{if(!x())return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};if(v()===`linux`)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};let n=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];if(n.length===0)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};try{let e=await E(`desktop_get_installed_apps`,{apps:n,force:t===!0||void 0});if(!e||typeof e!=`object`)return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};let r=e;return r.supported===!1?{apps:[],success:!0,hasCache:!1,isCacheStale:!1}:Array.isArray(r.apps)?{apps:r.apps.filter(e=>e&&typeof e==`object`).map(e=>{let t=e;return{name:typeof t.name==`string`?t.name:``,iconDataUrl:typeof t.iconDataUrl==`string`?t.iconDataUrl:null}}).filter(e=>e.name.length>0),success:!0,hasCache:r.hasCache===!0,isCacheStale:r.isCacheStale===!0}:{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}catch(e){return console.warn(`Failed to fetch installed apps`,e),{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}};export{$ as A,j as B,g as C,re as D,Z as E,ee as F,q as G,k as H,Q as I,f as J,y as K,ae as L,H as M,G as N,Y as O,W as P,ce as R,h as S,B as T,K as U,D as V,R as W,s as X,u as Y,l as Z,x as _,fe as a,I as b,w as c,oe as d,ne as f,v as g,_ as h,ie as i,ue as j,de as k,V as l,T as m,J as n,X as o,O as p,c as q,te as r,C as s,S as t,A as u,E as v,z as w,L as x,se as y,le as z};
|
|
1
|
+
import{w as e}from"./runtime-auth-DBn9yahL.js";import{r as t,t as n}from"./runtime-switch-DEZ1K7qW.js";import{t as r}from"./runtimeAPIRegistry-C2VogTny.js";var i=[`local`,`remote`,null],a=[`ok`,`not-configured`,`unreachable`,`incompatible`,`wrong-service`,`missing`];function o(e){if(!e||typeof e!=`object`)return{valid:!1};let t=e,n=t.target,r=t.status;if(n!==null&&(typeof n!=`string`||!i.includes(n))||typeof r!=`string`||!a.includes(r))return{valid:!1};if(n===`remote`||n===`local`){if(r===`ok`&&n===`local`)return{valid:!0,outcome:{target:`local`,status:`ok`}};if(r===`ok`&&n===`remote`)return typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`ok`,hostId:t.hostId,url:t.url}};if(r===`unreachable`)return n===`local`?{valid:!0,outcome:{target:`local`,status:`unreachable`}}:typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`unreachable`,hostId:t.hostId,url:t.url}};if(r===`incompatible`||r===`wrong-service`)return n!==`remote`||typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:r,hostId:t.hostId,url:t.url}};if(r===`missing`)return n!==`remote`||typeof t.hostId!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`missing`,hostId:t.hostId}}}if(n===null){if(r===`not-configured`)return{valid:!0,outcome:{target:null,status:`not-configured`}};if(r===`missing`)return{valid:!1}}return{valid:!1}}function s(e){if(!e.isDesktopShell)return null;let t=e.bootOutcome;if(!t)return null;if(t.status===`ok`){if(t.target===`local`)return{screen:`main`};if(t.target===`remote`)return{screen:`main`,hostId:t.hostId,url:t.url}}if(t.target===null&&t.status===`not-configured`)return{screen:`chooser`};if(t.target===`local`&&t.status===`unreachable`)return{screen:`recovery`,variant:`local-unavailable`};if(t.target===`remote`){if(t.status===`unreachable`)return{screen:`recovery`,variant:`remote-unreachable`,hostId:t.hostId,url:t.url};if(t.status===`incompatible`)return{screen:`recovery`,variant:`remote-incompatible`,hostId:t.hostId,url:t.url};if(t.status===`wrong-service`)return{screen:`recovery`,variant:`remote-wrong-service`,hostId:t.hostId,url:t.url};if(t.status===`missing`)return{screen:`recovery`,variant:`remote-missing`,hostId:t.hostId}}return null}function c(e){return e.isDesktopShell?e.bootOutcomeKnown?e.bootViewIsMain===!1||e.isInitialized:!1:e.isInitialized}function l(e){return e.isDesktopShell&&!e.isDesktopLocalOriginActive}function u(){if(f()!==`valid`)return null;let e=o(d());return e.valid?e.outcome:null}var d=()=>{if(typeof window>`u`)return;let e=window.__YURI_DESKTOP_BOOT_OUTCOME__;if(e!=null)return e;let t=window.__YURI_DESKTOP_BOOT__;if(t&&typeof t.getOutcome==`function`)try{return t.getOutcome()}catch{return}return e};function f(){if(typeof window>`u`)return`not-injected`;let e=d();return e==null?`not-injected`:o(e).valid?`valid`:`malformed`}var p=()=>typeof window>`u`?null:window.__YURI_ELECTRON__??null,m=()=>typeof window>`u`?null:window.__YURI_DESKTOP__??null,h=()=>p()?.runtime===`electron`,g=()=>h()&&p()?.packaged===!0,_=e=>{if(!h())return null;let t=m()?.getPathForFile?.(e);return typeof t==`string`&&t.trim()?t:null},v=()=>{if(typeof window>`u`)return null;let e=window.__YURI_PLATFORM__;return typeof e==`string`?e:null},y=()=>{if(!h())return!1;let e=v();return e===`win32`||e===`linux`},b=(e=v())=>e===`linux`?`left`:`right`,ee=(e,t=v())=>e===`left`||e===`right`?e:b(t),x=()=>typeof m()?.invoke==`function`,S=()=>h()&&x(),C=()=>h()&&I()?m()?.guiPlugins:void 0,w=()=>h()?m()?.guiPlugins:void 0,T=()=>h()?m()?.viewExport:void 0,E=async(e,t)=>{let n=m();return typeof n?.invoke==`function`?n.invoke(e,t??{}):null},te=async e=>{if(!S()||!I())throw Error(`unsupported`);let t=await E(e.type===`status`?`desktop_remote_desktop_status`:e.type===`enabled`?`desktop_remote_desktop_enable`:`desktop_remote_desktop_permission`,{...e});if(!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`||typeof t.screenRecording!=`string`||typeof t.accessibility!=`boolean`||typeof t.helperAvailable!=`boolean`||typeof t.ready!=`boolean`)throw Error(`invalid_desktop_status`);return t},ne=async()=>{if(!S()||!I())return null;try{let e=await E(`desktop_get_launch_at_login`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get launch at login status`,e),null}},D=async e=>{if(!S()||!I())return null;try{let t=await E(`desktop_set_launch_at_login`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set launch at login status`,e),null}},O=async()=>{if(!S()||!I())return null;try{let e=await E(`desktop_get_minimize_to_tray`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get minimize to tray status`,e),null}},k=async e=>{if(!S()||!I())return null;try{let t=await E(`desktop_set_minimize_to_tray`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set minimize to tray status`,e),null}},A=async()=>{if(!S()||!I())return null;try{let e=await E(`desktop_get_keep_awake`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`||typeof e.active!=`boolean`?null:e}catch(e){return console.warn(`Failed to get keep awake status`,e),null}},j=async e=>{if(!S()||!I())return null;try{let t=await E(`desktop_set_keep_awake`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`||typeof t.active!=`boolean`?null:t}catch(e){return console.warn(`Failed to set keep awake status`,e),null}},M=e=>{let t=e.trim();if(!t)return null;try{return new URL(t).origin}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`).origin}catch{return null}}},N=e=>{let t=e.trim();if(!t)return null;try{return new URL(t)}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`)}catch{return null}}},P=e=>e.replace(/^\[|\]$/g,``).toLowerCase(),F=e=>{let t=P(e);return t===`localhost`||t===`127.0.0.1`||t===`::1`},I=()=>{if(typeof window>`u`||!L()||e())return!1;let r=t();if(r.startsWith(`host:`))return!1;if(r===`local`)return!0;let i=typeof window.__YURI_LOCAL_ORIGIN__==`string`?window.__YURI_LOCAL_ORIGIN__:``,a=N(i),o=N(n());if(!o&&a&&u()?.target===`local`)return!0;if(a&&o){if(a.origin===o.origin)return!0;let e=a.port||(a.protocol===`https:`?`443`:`80`),t=o.port||(o.protocol===`https:`?`443`:`80`);return a.protocol===o.protocol&&e===t&&F(a.hostname)&&F(o.hostname)}let s=N(window.location.origin);if(a&&s){if(a.origin===s.origin)return!0;let e=a.port||(a.protocol===`https:`?`443`:`80`),t=s.port||(s.protocol===`https:`?`443`:`80`);return a.protocol===s.protocol&&e===t&&F(a.hostname)&&F(s.hostname)}let c=M(i),l=M(window.location.origin)||window.location.origin;return c&&l&&c===l?!0:!!(s&&F(s.hostname))},L=()=>typeof window>`u`?!1:h(),R=async()=>{if(!L())return!1;try{return await E(`desktop_start_window_drag`),!0}catch{return!1}},z=()=>r()?.runtime?.isVSCode===!0,B=()=>{let e=r()?.runtime?.platform;return e===`web`?!0:e===`desktop`||e===`vscode`?!1:!z()},V=async()=>{if(typeof window<`u`){let e=window.__YURI_HOME__;if(e&&e.length>0)return e}return null},H=async e=>{if(x()&&I())try{let e=await m()?.openDialog?.({directory:!0,multiple:!1,title:`Select Working Directory`});return!e||typeof e!=`string`?{success:!1,error:`Directory selection cancelled`}:{success:!0,path:e}}catch(e){return console.warn(`Failed to request directory access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!0,path:e}},U=e=>typeof e==`object`&&!!e&&!Array.isArray(e),W=async e=>{if(x()&&I())try{let t=await m()?.openDialog?.({directory:!1,multiple:!1,title:`Select File`,returnGrant:!0,...e?.filters?{filters:e.filters}:{},...e?.defaultPath?{defaultPath:e.defaultPath}:{}});if(!t)return{success:!1,error:`File selection cancelled`};if(typeof t==`string`)return{success:!0,path:t};if(!U(t))return{success:!1,error:`File selection cancelled`};let n=typeof t.path==`string`?t.path:``;return n?{success:!0,path:n,outsideFileGrant:typeof t.outsideFileGrant==`string`?t.outsideFileGrant:void 0}:{success:!1,error:`File selection cancelled`}}catch(e){return console.warn(`Failed to request file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!1,error:`Native file picker not available`}},G=async e=>{let t=typeof e==`string`?e.trim():``;if(!t)return{success:!1,error:`Path is required`};if(!x()||!I())return{success:!1,error:`Native file access not available`};try{let e=await m()?.grantFileAccess?.(t);if(!U(e))return{success:!1,error:`File access was not granted`};let n=typeof e.path==`string`?e.path:``,r=typeof e.outsideFileGrant==`string`?e.outsideFileGrant:``;return!n||!r?{success:!1,error:`File access was not granted`}:{success:!0,path:n,outsideFileGrant:r}}catch(e){return console.warn(`Failed to request existing file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}},K=async e=>({success:!0}),q=async e=>({success:!0}),J=async e=>{if(!x())throw Error(`Desktop update checker is unavailable`);let t=await E(`desktop_check_for_updates`,{channelOverride:e});if(!t)throw Error(`Desktop update checker returned no result`);return t},Y=async e=>{x()&&await E(`desktop_ota_ready`,{version:e})},X=()=>E(`desktop_get_app_version`),Z=async e=>{let t=m();return typeof t?.listen==`function`?t.listen(`yuri:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({event:typeof r.event==`string`?r.event:void 0,data:r.data&&typeof r.data==`object`?r.data:void 0})}):null},re=async e=>{let t=m();return typeof t?.listen==`function`?t.listen(`yuri:update-ready`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({version:typeof r.version==`string`?r.version:null,downloaded:r.downloaded===!0})}):null},ie=async e=>{if(!x())return!1;let t=m(),n=null,r=0,i;try{return typeof e==`function`&&t?.listen&&(n=await t.listen(`yuri:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let a=n,o=typeof a.event==`string`?a.event:null,s=a.data&&typeof a.data==`object`?a.data:null;if(o===`Started`){r=0,i=typeof s?.contentLength==`number`?s.contentLength:void 0,e({downloaded:r,total:i});return}if(o===`Progress`){let t=s?.downloaded,n=s?.total;typeof t==`number`&&(r=t),typeof n==`number`&&(i=n),e({downloaded:r,total:i});return}o===`Finished`&&e({downloaded:r,total:i})})),await E(`desktop_download_and_install_update`),!0}catch(e){throw e instanceof Error?e:Error(String(e))}finally{if(n)try{let e=n();e instanceof Promise&&await e}catch{}}},ae=async()=>x()?Q({applyUpdate:!0}):!1,Q=async({applyUpdate:e=!1}={})=>{if(!x())return!1;try{return await E(`desktop_restart`,e?{applyUpdate:!0}:void 0),!0}catch(e){return console.warn(`Failed to restart desktop app`,e),!1}},oe=async()=>{if(!x()||!I())return null;try{let e=await E(`desktop_get_lan_address`);return typeof e==`string`&&e.trim().length>0?e.trim():null}catch(e){return console.warn(`Failed to get desktop LAN address`,e),null}},$=async(e,t)=>{if(!x()||!I())return!1;let n=e?.trim();if(!n)return!1;try{return await E(`desktop_open_path`,{path:n,app:typeof t==`string`&&t.trim().length>0?t.trim():void 0}),!0}catch(e){return console.warn(`Failed to open path`,e),!1}},se=async e=>{if(!x()||!I())return null;let t=e?.trim();if(!t)return null;try{let e=await E(`desktop_is_binary_path`,{path:t});return typeof e==`boolean`?e:null}catch{return null}},ce=async e=>{if(!x()||!I())return!1;let t=e?.trim();if(!t)return!1;try{return await E(`desktop_reveal_path`,{path:t}),!0}catch{return $(t)}},le=async(e,t)=>{if(!x()||!I())return null;let n=e?.trim();if(!n)return null;try{let e=await E(`desktop_save_markdown_file`,{defaultFileName:n,content:t});return typeof e==`string`&&e.trim().length>0?e:null}catch(e){return console.warn(`Failed to save markdown file`,e),null}},ue=async(e,n,r,i)=>{if(!x()||!i&&!I())return!1;if(i)return t()===`host:${i}`&&(await E(`desktop_open_ssh_in_app`,{projectPath:e,appId:n,hostId:i}),!0);let a=e?.trim(),o=n?.trim(),s=r?.trim();if(!a||!o||!s)return!1;try{return await E(`desktop_open_in_app`,{projectPath:a,appId:o,appName:s}),!0}catch(e){return console.warn(`Failed to open project in app`,e),!1}},de=async(e,t,n)=>{if(!x()||!I())return!1;let r=e?.trim(),i=t?.trim(),a=n?.trim();if(!r||!i||!a)return!1;try{return await E(`desktop_open_file_in_app`,{filePath:r,appId:i,appName:a}),!0}catch(e){return console.warn(`Failed to open file in app`,e),!1}},fe=async(e,t)=>{if(!x())return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};if(v()===`linux`)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};let n=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];if(n.length===0)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};try{let e=await E(`desktop_get_installed_apps`,{apps:n,force:t===!0||void 0});if(!e||typeof e!=`object`)return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};let r=e;return r.supported===!1?{apps:[],success:!0,hasCache:!1,isCacheStale:!1}:Array.isArray(r.apps)?{apps:r.apps.filter(e=>e&&typeof e==`object`).map(e=>{let t=e;return{name:typeof t.name==`string`?t.name:``,iconDataUrl:typeof t.iconDataUrl==`string`?t.iconDataUrl:null}}).filter(e=>e.name.length>0),success:!0,hasCache:r.hasCache===!0,isCacheStale:r.isCacheStale===!0}:{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}catch(e){return console.warn(`Failed to fetch installed apps`,e),{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}};export{$ as A,j as B,g as C,re as D,Z as E,ee as F,q as G,k as H,Q as I,f as J,y as K,ae as L,H as M,G as N,Y as O,W as P,ce as R,h as S,B as T,K as U,D as V,R as W,s as X,u as Y,l as Z,x as _,fe as a,I as b,w as c,oe as d,ne as f,v as g,_ as h,ie as i,ue as j,de as k,V as l,T as m,J as n,X as o,O as p,c as q,te as r,C as s,S as t,A as u,E as v,z as w,L as x,se as y,le as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e}from"./runtime-auth-
|
|
1
|
+
import{E as e}from"./runtime-auth-DBn9yahL.js";import{_ as t,v as n}from"./desktop-JwYqThiw.js";var r=e=>typeof e==`object`&&!!e,i=e=>e.trim().toLowerCase()===`authorization`,a=e=>{if(!r(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=n.trim(),a=typeof r==`string`?r.trim():``;!e||!a||/[\r\n:]/.test(e)||/[\r\n]/.test(a)||i(e)||(t[e]=a)}return Object.keys(t).length>0?t:void 0},o=`connect-link`,s=(e,t)=>e.source===`connect-link`||e.relay?!0:t.has(e.id),c=(e,t)=>!t.has(e.id)&&s(e,t),l=e=>`relay://${e}`,u=e=>{if(!r(e))return null;let t=g(e,`relayUrl`)||g(e,`relay_url`),n=g(e,`serverId`)||g(e,`server_id`),i=e.hostEncPubJwk??e.host_enc_pub_jwk;return!t||!n||!r(i)?null:{relayUrl:t,serverId:n,hostEncPubJwk:i}},d=/^(t|.*(?:token|auth|secret|api).*)$/i,f=e=>{let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:t.split(`#`)[0]||null}catch{return null}},p=e=>{let t=f(e);if(!t)return null;try{let e=new URL(t);if((e.pathname.replace(/\/+$/,``)||`/`)===`/connect`&&e.searchParams.has(`t`))return{persistedUrl:e.origin,redeemUrl:e.toString(),kind:`tunnel-connect-link`}}catch{return null}return{persistedUrl:t,redeemUrl:null,kind:`normal-host`}},m=e=>{let t=f(e);if(!t)return e;try{let e=new URL(t);(e.username||e.password)&&(e.username=``,e.password=``);let n=Array.from(new Set(Array.from(e.searchParams.keys())));for(let t of n)d.test(t)&&e.searchParams.set(t,`[REDACTED]`);return e.toString()}catch{return t}},h=(e,t)=>{let n=f(e),r=f(t);if(!n||!r)return!1;try{let e=new URL(n),t=new URL(r);if(e.origin!==t.origin||t.search&&e.search!==t.search)return!1;let i=t.pathname.length>1?t.pathname.replace(/\/+$/,``):t.pathname,a=e.pathname.length>1?e.pathname.replace(/\/+$/,``):e.pathname;return i===`/`||a===i||a.startsWith(`${i}/`)}catch{return!1}},g=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},_=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},v=e=>{if(!r(e))return null;let t=g(e,`id`),n=g(e,`label`),i=g(e,`url`),s=g(e,`apiUrl`)||g(e,`api_url`),c=g(e,`clientToken`)||g(e,`client_token`),l=a(e.requestHeaders),d=u(e.relay),f=g(e,`source`)===`connect-link`?o:void 0;return!t||!n||!i&&!d?null:{id:t,label:n,url:i||``,...s?{apiUrl:s}:{},...c?{clientToken:c}:{},...l?{requestHeaders:l}:{},...d?{relay:d}:{},...f?{source:f}:{}}},y=e=>f(e.apiUrl||e.url)||e.apiUrl||e.url,b=()=>t()?(e,t)=>n(e,t):null,x=async()=>{let e=b();if(!e)return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let t=await e(`desktop_hosts_get`);if(!r(t))return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let n=t.hosts;return{hosts:Array.isArray(n)?n.map(v).filter(e=>!!e):[],defaultHostId:g(t,`defaultHostId`)||g(t,`default_host_id`)||g(t,`defaultHostID`),initialHostChoiceCompleted:t.initialHostChoiceCompleted===!0||t.initial_host_choice_completed===!0,localOrigin:g(t,`localOrigin`)||g(t,`local_origin`)}},S=async e=>{let t=b();if(!t)return;let n={hosts:e.hosts,defaultHostId:e.defaultHostId,initialHostChoiceCompleted:e.initialHostChoiceCompleted};e.localClientToken!==void 0&&(n.localClientToken=e.localClientToken),await t(`desktop_hosts_set`,{input:n})},C=async e=>{let t=b();if(!t)throw Error(`Desktop host preparation is unavailable`);let n=v(await t(`desktop_host_prepare`,{hostId:e.id}));if(!n||n.id!==e.id)throw Error(`Invalid prepared desktop host`);return n},w=async()=>{let e=b();if(!e)return``;let t=await e(`desktop_local_client_token_get`).catch(()=>null);return typeof t==`string`?t.trim():``},T=async()=>{let e=b();if(!e)return``;let t=await e(`desktop_install_id_get`).catch(()=>null);return typeof t==`string`?t.trim():``},E=8e3,D=async(t,n)=>{let r=e({relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:t.hostEncPubJwk}),i=Date.now(),a=!1,o;try{let e=await Promise.race([(async()=>{let e=await r.fetch(`/auth/session`,{headers:n?.clientToken?{Authorization:`Bearer ${n.clientToken}`}:{}});return{response:e,payload:e.ok?await e.json().catch(()=>null):null}})(),new Promise(e=>{o=setTimeout(()=>e(null),E)})]),t=e?.response;return t?.status===401||t?.status===403?{status:`auth`,latencyMs:Math.max(0,Date.now()-i)}:t?.ok?e?.payload?.authenticated===!0?(a=n?.keepTunnel===!0,{status:`ok`,latencyMs:Math.max(0,Date.now()-i),...a?{tunnel:r}:{}}):{status:`auth`,latencyMs:Math.max(0,Date.now()-i)}:{status:`unreachable`,latencyMs:0}}catch{return{status:`unreachable`,latencyMs:0}}finally{o!==void 0&&clearTimeout(o),a||r.close()}},O=async(e,t)=>{let n=b();if(!n)return{status:`unreachable`,latencyMs:0};let i=await n(`desktop_host_probe`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0,expectedServerId:t?.expectedServerId||void 0});if(!r(i))return{status:`unreachable`,latencyMs:0};let a=i.status;return{status:a===`ok`||a===`auth`||a===`update-recommended`||a===`incompatible`||a===`wrong-service`||a===`unreachable`?a:`unreachable`,latencyMs:_(i,`latencyMs`)??_(i,`latency_ms`)??0}},k=async(e,t)=>{let n=b();n&&await n(`desktop_new_window_at_url`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0})},A=async e=>{let t=b();t&&await t(`desktop_new_window_for_host`,{hostId:e})};export{l as _,T as a,A as c,c as d,s as f,m as g,D as h,S as i,C as l,f as m,O as n,w as o,h as p,x as r,k as s,o as t,y as u,p as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e}from"./runtime-auth-
|
|
1
|
+
import{b as e}from"./runtime-auth-DBn9yahL.js";import{l as t,n,r}from"./runtime-switch-DEZ1K7qW.js";import{n as i}from"./runtime-fetch-D4ja813o.js";import{S as a}from"./desktop-JwYqThiw.js";import{h as o,i as s,l as c,m as l,n as u,r as d,u as f}from"./desktopHosts-CB0CTcMg.js";var p=e=>e!==`ok`&&e!==`update-recommended`,m=e=>e.id===`local`?`local`:`host:${e.id}`,h=e=>r()===m(e),g=async(n,r)=>{if(!a())return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};n=await c(n);let i=l(f(n))||``;if(!i&&!n.relay)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`};let s=(r,i)=>{i&&e({relayUrl:r.relayUrl,serverId:r.serverId,hostEncPubJwk:r.hostEncPubJwk},i),t({apiBaseUrl:C(),clientToken:n.clientToken||null,runtimeKey:m(n),relay:r}),T(n.id)},d=e=>{t({apiBaseUrl:e,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:m(n)})},h={status:`unreachable`,latencyMs:0},g=null,_;if(i){let e=await u(i,{clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,expectedServerId:n.relay?.serverId||null}).catch(()=>({status:`unreachable`,latencyMs:0}));h={status:e.status,latencyMs:e.latencyMs},p(e.status)||(g=`direct`)}if(!g&&n.relay){let e=await o(n.relay,{keepTunnel:!0,clientToken:n.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));e.status===`ok`?(h={status:e.status,latencyMs:e.latencyMs,via:`relay`},g=`relay`,_=`tunnel`in e?e.tunnel:void 0):(!i||e.status===`auth`)&&(h={status:e.status,latencyMs:e.latencyMs})}return g?g===`relay`&&n.relay?(s(n.relay,_),{ok:!0,via:`relay`,status:h}):(d(i),{ok:!0,via:`direct`,status:h}):{ok:!1,status:h,reason:`unreachable`}},_=5e3,v=1500,y=e=>e===`ok`||e===`update-recommended`,b=!1,x=()=>{if(typeof window>`u`)return``;let e=window.__YURI_LOCAL_ORIGIN__;return typeof e==`string`?e.trim():``},S=e=>{if(!e||e===`null`)return!1;try{let t=new URL(e);return(t.protocol===`http:`||t.protocol===`https:`)&&t.origin!==`null`}catch{return!1}},C=()=>{if(typeof window>`u`)return``;let e=window.location.origin;if(S(e))return e;let t=x();return S(t)?t:``},w=async e=>{if(!a()||b)return;let o=`host:${e}`;if(r()!==o)return;let c=n(),f=()=>r()===o&&n()===c;b=!0;try{let n=await d().catch(()=>null);if(!f())return;let r=n?.hosts.find(t=>t.id===e);if(!n||!r?.relay)return;let a=r.apiUrl?l(r.apiUrl):null;if(a&&a.startsWith(`https://`))return;let c=await i(`/api/client-auth/connection/candidates`).catch(()=>null);if(!c?.ok)return;let p=await c.json().catch(()=>null);if(!f()||!p||p.serverId!==r.relay.serverId)return;let m=Array.isArray(p.candidates)?p.candidates:[],h=[];for(let e of m){if(!e||typeof e!=`object`)continue;let t=e;if(t.type!==`lan`||typeof t.url!=`string`)continue;let n=l(t.url);n&&!h.includes(n)&&h.push(n)}if(h.length===0)return;let g=a&&h.includes(a)?a:h[0];if(g!==a&&await s({hosts:n.hosts.map(t=>t.id===e?{...t,apiUrl:g}:t),defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted}).catch(()=>void 0),!f()||!y((await u(g,{clientToken:r.clientToken||null,requestHeaders:r.requestHeaders||null,expectedServerId:r.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0}))).status)||!f())return;t({apiBaseUrl:g,clientToken:r.clientToken||null,requestHeaders:r.requestHeaders||null,runtimeKey:o})}finally{b=!1}},T=e=>{typeof window>`u`||window.setTimeout(()=>{w(e).catch(()=>void 0)},_)},E=async e=>{if(!a())return;let i=r(),o=n(),s=()=>r()===i&&n()===o,c=await d().catch(()=>null);if(!c||!s())return;let p=e||(c.defaultHostId===`local`?null:c.defaultHostId);if(!p)return;let h=c.hosts.find(e=>e.id===p);if(!h?.relay)return;let g=m(h);if(r()===g)return;let _=e=>{t({apiBaseUrl:e,clientToken:h.clientToken||null,requestHeaders:h.requestHeaders||null,runtimeKey:g})},b=()=>{t({apiBaseUrl:C(),clientToken:h.clientToken||null,runtimeKey:g,relay:h.relay??void 0}),T(h.id)},x=h.apiUrl?l(f(h)):null;if(!x){b();return}let S=e=>y(e.status),w=u(x,{clientToken:h.clientToken||null,requestHeaders:h.requestHeaders||null,expectedServerId:h.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0})),E=await Promise.race([w,new Promise(e=>setTimeout(()=>e(null),v))]);if(s()){if(E){if(S(E)){_(x);return}b();return}b()}};export{g as i,h as n,m as r,E as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/rolldown-runtime-hePW80VL.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{w as t,x as n}from"./desktop-
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{w as t,x as n}from"./desktop-JwYqThiw.js";import{it as r}from"./vendor-base-ui-CdzJ6My_.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as o}from"./platform-DFJEtBlo.js";var s=e(r(),1),c=i(),l=.85,u=1.2,d=10/9,f=.9,p=.98,m=p/f,h=`yuri.designPtScale.v8`;function g(e){return!Number.isFinite(e)||e<=0?1:Math.min(u,Math.max(l,e))}function _(e){if(!e)return p;let t=e.density,n=(e.xdpi+e.ydpi)/2;if(!(t>0)||!(n>=50)||n>800)return p;let r=g(n/t/163);return Math.min(p,r*m)}function v(){if(typeof window>`u`)return 1;try{let e=Number.parseFloat(window.localStorage.getItem(`yuri.designPtScale.v8`)??``),t=window.Capacitor?.getPlatform?.();return t===`android`?Math.min(p,g(e)):t===`ios`?d:g(e)}catch{return 1}}function y(e){if(!(typeof window>`u`))try{window.localStorage.setItem(h,String(e))}catch{}}function b(e,t=document.documentElement){let n=g(e);t.style.setProperty(`--dpt`,`${n}px`),t.style.setProperty(`--dpt-n`,String(n))}async function x(){if(typeof document>`u`)return 1;b(v());let{Capacitor:e,registerPlugin:t}=await a(async()=>{let{Capacitor:e,registerPlugin:t}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{Capacitor:e,registerPlugin:t}},__vite__mapDeps([0,1]));if(!e.isNativePlatform())return b(1),1;if(e.getPlatform()===`ios`)return b(d),y(d),d;if(e.getPlatform()!==`android`)return b(1),1;if(!e.isPluginAvailable(`YuriPhysicalScale`))return b(p),y(p),p;try{let e=_(await t(`YuriPhysicalScale`).getMetrics());return y(e),b(e),e}catch{return b(p),y(p),p}}var S={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},C={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:`desktop`,screenWidth:1024,breakpoint:`lg`,hasTouchInput:!1,hasTouchOnlyPointer:!1},w=()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`surface`)===`desktop`,T=e=>{if(typeof navigator>`u`)return{isExplicitTablet:!1};let t=navigator.userAgent||``,n=navigator.platform||``,r=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,i=/Android/i.test(t)&&!/Mobile/i.test(t),a=/Tablet/i.test(t);return{isExplicitTablet:r||i||a}},E=(e,t,n)=>{if(typeof window>`u`)return;let r=document.documentElement,i=t===`mobile`,a=t===`tablet`;r.classList.remove(`device-mobile`,`device-tablet`,`device-desktop`),r.classList.add(t===`mobile`?`device-mobile`:t===`tablet`?`device-tablet`:`device-desktop`),e?(r.classList.add(`desktop-runtime`),r.style.setProperty(`--is-mobile`,`0`),r.style.setProperty(`--device-type`,`desktop`),r.style.setProperty(`--font-scale`,`1`),r.style.setProperty(`--has-coarse-pointer`,`0`),r.style.setProperty(`--has-touch-input`,`0`),r.classList.remove(`mobile-pointer`)):(r.classList.remove(`desktop-runtime`),r.style.setProperty(`--is-mobile`,i?`1`:`0`),r.style.setProperty(`--device-type`,t),r.style.setProperty(`--font-scale`,i?`0.9`:a?`0.95`:`1`),r.style.setProperty(`--has-coarse-pointer`,n?`1`:`0`),r.style.setProperty(`--has-touch-input`,n?`1`:`0`),n?r.classList.add(`mobile-pointer`):r.classList.remove(`mobile-pointer`)),b(e?1:v(),r)};function D(){let e=window.innerWidth,r=typeof window.matchMedia==`function`,i=r?window.matchMedia(`(pointer: coarse)`):null,a=r?window.matchMedia(`(hover: none)`):null,s=i?.matches??!1,c=a?.matches??!1,l=typeof navigator<`u`?navigator.maxTouchPoints??0:0,u=n()||t()||w(),{isExplicitTablet:d}=T(l),f=s||c||l>0,p=s||c,m=e>S.md&&e<=S.lg,h=e<=S.md,g=f&&h,_=f&&!g&&(m||d),v=!f||!_&&e>S.lg,y=`desktop`;u?(g=!1,_=!1,v=!0,y=`desktop`):o()?(g=!0,_=!1,v=!1,y=`mobile`):g?y=`mobile`:_?y=`tablet`:(v=!0,y=`desktop`),E(u,y,f);let b=`xs`;for(let[t,n]of Object.entries(S))e>=n&&(b=t);return{isMobile:g,isTablet:_,isDesktop:v,deviceType:y,screenWidth:e,breakpoint:b,hasTouchInput:f,hasTouchOnlyPointer:p}}var O=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,k=new Set,A=null,j,M=null,N=()=>typeof window>`u`?C:(A||=D(),A),P=()=>{for(let e of k)e()},F=()=>{j=void 0;let e=D();A&&O(A,e)||(A=e,P())},I=()=>{typeof window>`u`||j!==void 0||(j=window.requestAnimationFrame(F))},L=(e,t)=>e?typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},R=()=>{if(typeof window>`u`)return()=>{};A=D(),window.addEventListener(`resize`,I);let e=typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null,t=typeof window.matchMedia==`function`?window.matchMedia(`(hover: none)`):null,n=L(e,I),r=L(t,I);return()=>{window.removeEventListener(`resize`,I),n(),r(),j!==void 0&&(window.cancelAnimationFrame(j),j=void 0)}},z=e=>typeof window>`u`?()=>{}:(k.add(e),M||=R(),()=>{k.delete(e),k.size===0&&M&&(M(),M=null,A=null)});function B(){if(typeof window>`u`||typeof window<`u`&&n())return!1;let e=document.documentElement,t=e.style.getPropertyValue(`--is-mobile`)||getComputedStyle(e).getPropertyValue(`--is-mobile`);return t===`1`||t===`true`}var V=()=>typeof window>`u`?!1:!!(navigator.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`)?.matches||window.matchMedia?.(`(display-mode: fullscreen)`)?.matches),H=()=>{if(typeof window>`u`||n())return!1;let e=typeof navigator<`u`?navigator.maxTouchPoints??0:0;return V()&&e>0&&window.innerWidth>S.md};function U(){let e=(0,c.c)(2),[t,n]=s.useState(W),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>n(H()),t=window.matchMedia?.(`(display-mode: standalone)`),r=window.matchMedia?.(`(display-mode: fullscreen)`);e(),window.addEventListener(`resize`,e),window.addEventListener(`focus`,e);let i=t=>{t&&(typeof t.addEventListener==`function`?t.addEventListener(`change`,e):typeof t.addListener==`function`&&t.addListener(e))},a=t=>{t&&(typeof t.removeEventListener==`function`?t.removeEventListener(`change`,e):typeof t.removeListener==`function`&&t.removeListener(e))};return i(t),i(r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`focus`,e),a(t),a(r)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),s.useEffect(r,i),t}function W(){return H()}var G=()=>typeof window>`u`?`portrait`:window.matchMedia?.(`(orientation: landscape)`)?.matches?`landscape`:`portrait`;function K(){let e=(0,c.c)(2),[t,n]=s.useState(G),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(orientation: landscape)`),t=()=>n(e.matches?`landscape`:`portrait`);return t(),L(e,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),s.useEffect(r,i),t}function q(){return s.useSyncExternalStore(z,N,J)}function J(){return C}export{U as a,K as i,B as n,x as o,q as r,D as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{r}from"./button-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{r}from"./button-Be1cqulG.js";import{t as i}from"./vendor-react-drawio-Ck9ZKdNN.js";var a=e(t(),1),o=n(),s=`<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>`;function c(){if(typeof document>`u`)return!1;let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||!e&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}var l=a.forwardRef(function({xml:e,readOnly:t,className:n,onChange:l},u){let d=a.useRef(e),f=a.useRef(null),p=a.useRef(!1),[m,h]=a.useState(c),g=a.useRef(e),_=a.useRef(e);_.current!==e&&(_.current=e,g.current=e,d.current=e);let v=a.useRef(m);v.current!==m&&(v.current=m,g.current=d.current);let y=a.useRef(null);a.useEffect(()=>{let e=()=>h(c());e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()},[]),a.useEffect(()=>{let e=setTimeout(()=>{y.current?.querySelector(`.diagrams-iframe`)?.focus()},600);return()=>clearTimeout(e)},[]),a.useImperativeHandle(u,()=>({getXml:()=>d.current}));let b=a.useCallback(()=>{!e&&!p.current&&(p.current=!0,setTimeout(()=>{f.current?.template({})},500))},[e]),x=a.useCallback(e=>{d.current=e.xml,l?.(e.xml)},[l]);return(0,o.jsx)(`div`,{ref:y,className:r(`h-full w-full`,n),children:(0,o.jsx)(i,{ref:f,xml:g.current||s,autosave:!0,urlParameters:{ui:t?`simple`:m?`dark`:`kennedy`,spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:x},m?`dark`:`light`)})});export{l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,J as n,Q as r,X as i,Y as a,Z as o,et as s,it as c,q as l,rt as u}from"./vendor-base-ui-CdzJ6My_.js";import{n as d}from"./vendor-react-BP2cRVqX.js";import{f,r as p}from"./button-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,J as n,Q as r,X as i,Y as a,Z as o,et as s,it as c,q as l,rt as u}from"./vendor-base-ui-CdzJ6My_.js";import{n as d}from"./vendor-react-BP2cRVqX.js";import{f,r as p}from"./button-Be1cqulG.js";import{n as m}from"./Icon-Bn4Eec3Y.js";var h=d(),g=e(c(),1),_=u(),v=0;function y(e,t){return e&&g.isValidElement(t)?{render:t}:{children:t}}function b(e){let t=(0,h.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,_.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function x(e){let t=(0,h.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({asChild:n,children:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==r?(a=y(n,r),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o=a,s;return t[7]!==i||t[8]!==o?(s=(0,_.jsx)(l,{"data-slot":`dialog-trigger`,...i,...o}),t[7]=i,t[8]=o,t[9]=s):s=t[9],s}function S(e){let t=(0,h.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,_.jsx)(i,{...n}),t[2]=n,t[3]=r),r}var C=g.forwardRef((e,t)=>{let n=(0,h.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],n[3]=a):a=n[3],g.useEffect(A,a);let o=t,c;n[4]===r?c=n[5]:(c=p(`app-region-no-drag fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,r),n[4]=r,n[5]=c);let l;return n[6]!==i||n[7]!==o||n[8]!==c?(l=(0,_.jsx)(s,{ref:o,"data-slot":`dialog-overlay`,className:c,...i}),n[6]=i,n[7]=o,n[8]=c,n[9]=l):l=n[9],l});C.displayName=`DialogOverlay`;function w(e){let n=(0,h.c)(29),r,i,a,s,c,l;n[0]===e?(r=n[1],i=n[2],a=n[3],s=n[4],c=n[5],l=n[6]):({className:i,overlayClassName:s,containerClassName:a,children:r,showCloseButton:l,...c}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=s,n[5]=c,n[6]=l);let u=l===void 0||l,{t:d}=f(),g;n[7]===s?g=n[8]:(g=p(`rounded-none`,s),n[7]=s,n[8]=g);let v;n[9]===g?v=n[10]:(v=(0,_.jsx)(C,{className:g}),n[9]=g,n[10]=v);let y=a??`items-center p-4`,b;n[11]===y?b=n[12]:(b=p(`fixed inset-0 z-50 flex justify-center pointer-events-none`,y),n[11]=y,n[12]=b);let x;n[13]===i?x=n[14]:(x=p(`app-region-no-drag relative pointer-events-auto bg-background text-foreground flex flex-col w-full max-w-lg max-h-full gap-4 rounded-xl border p-6 shadow-none overflow-y-auto pwa-dialog-content origin-center`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`,i),n[13]=i,n[14]=x);let w;n[15]!==u||n[16]!==d?(w=u&&(0,_.jsxs)(t,{"data-slot":`dialog-close`,className:`ring-offset-background focus:ring-ring data-[open]:bg-interactive-active data-[open]:text-foreground absolute top-2 right-2 rounded-lg opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none text-muted-foreground hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,_.jsx)(m,{name:`close`}),(0,_.jsx)(`span`,{className:`sr-only`,children:d(`dialog.common.actions.close`)})]}),n[15]=u,n[16]=d,n[17]=w):w=n[17];let T;n[18]!==r||n[19]!==c||n[20]!==x||n[21]!==w?(T=(0,_.jsxs)(o,{"data-slot":`dialog-content`,"data-state-slot":`dialog`,className:x,...c,children:[r,w]}),n[18]=r,n[19]=c,n[20]=x,n[21]=w,n[22]=T):T=n[22];let E;n[23]!==b||n[24]!==T?(E=(0,_.jsx)(`div`,{className:b,children:T}),n[23]=b,n[24]=T,n[25]=E):E=n[25];let D;return n[26]!==v||n[27]!==E?(D=(0,_.jsxs)(S,{children:[v,E]}),n[26]=v,n[27]=E,n[28]=D):D=n[28],D}function T(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col gap-2 text-center sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(`div`,{"data-slot":`dialog-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function E(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col-reverse gap-2 bottom-safe-area sm:flex-row sm:justify-end`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(`div`,{"data-slot":`dialog-footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function D(e){let t=(0,h.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=p(`typography-markdown leading-none font-semibold text-foreground`,r),t[3]=r,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,_.jsx)(n,{"data-slot":`dialog-title`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function O(e){let t=(0,h.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=p(`text-muted-foreground typography-ui-label`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,_.jsx)(r,{"data-slot":`dialog-description`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function k(){v=Math.max(0,v-1),v===0&&document.documentElement.classList.remove(`yuri-dialog-open`)}function A(){return v+=1,document.documentElement.classList.add(`yuri-dialog-open`),k}export{T as a,E as i,w as n,D as o,O as r,x as s,b as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t}from"./runtime-auth-BaBM02zI.js";import{c as n,f as r,i}from"./runtime-switch-DhMY9eiB.js";import{n as a}from"./runtime-fetch-DfALP7-b.js";import{it as o}from"./vendor-base-ui-CdzJ6My_.js";import{yt as s}from"./gitApiHttp-Bnr4_wxy.js";import{n as c}from"./vendor-react-BP2cRVqX.js";import{r as l}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{f as u}from"./button-K_jXf_uP.js";var d=`yuri:close-embedded-session-chat`,f=`yuri:embedded-visibility`,p=`yuri:embedded-visibility-request`,m=e=>new URLSearchParams(e).get(`yuriPanel`)===`session-chat`,h=(e,t,n)=>JSON.stringify({sessionID:e,directory:t||``,readOnly:n===!0}),g=(e,t,n,r)=>{if(typeof window>`u`)return``;let i=new URL(window.location.pathname,window.location.origin);return i.searchParams.set(`yuriPanel`,`session-chat`),i.searchParams.set(`surface`,`desktop`),i.searchParams.set(`sessionId`,e),n?i.searchParams.set(`readOnly`,`1`):i.searchParams.delete(`readOnly`),t&&t.trim().length>0?i.searchParams.set(`directory`,t):i.searchParams.delete(`directory`),i.searchParams.set(`themeMode`,r.mode),i.searchParams.set(`lightThemeId`,r.lightThemeId),i.searchParams.set(`darkThemeId`,r.darkThemeId),i.searchParams.set(`themeVariant`,r.currentTheme.metadata.variant===`dark`?`dark`:`light`),i.searchParams.set(`currentTheme`,JSON.stringify(r.currentTheme)),i.hash=``,i.toString()},_=(e,t,n,r,i,a)=>{let o=h(n,r,i),s=e.get(t);if(s?.signature===o)return s.src;let c=g(n,r,i,a);return e.set(t,{signature:o,src:c}),c},v=null,y=()=>{if(v!==null)return v;if(typeof window>`u`)return v=!1,!1;try{return v=new URLSearchParams(window.location.search).get(`yuriPanel`)===`session-chat`,v}catch{return v=!1,!1}},b=()=>{if(!y())return null;try{let e=new URLSearchParams(window.location.search).get(`sessionId`);return e&&e.trim().length>0?e.trim():null}catch{return null}},x=e(o(),1);async function S(e,t){let n=i(),r=await a(`/api/voice/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e}),signal:AbortSignal.any([t,AbortSignal.timeout(2e4)])});if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`))return await r.body?.cancel(),null;if(!r.ok)throw await r.body?.cancel(),Error(`Unable to create speech session`);let o=await r.json();if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(o?.transport===`host`)return null;if(o?.transport!==`volcengine-direct`||typeof o.token!=`string`||o.token.length>16384||!/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(o.token)||typeof o.appId!=`string`||!/^[A-Za-z0-9_-]{1,128}$/.test(o.appId)||typeof o.resourceId!=`string`||!/^[A-Za-z0-9._-]{1,128}$/.test(o.resourceId)||!Number.isFinite(o.expiresAt)||o.expiresAt<=Date.now()+5e3||o.expiresAt>Date.now()+36e4||e===`tts`&&(typeof o.voice!=`string`||!/^[A-Za-z0-9_-]{1,200}$/.test(o.voice)||!Number.isFinite(o.speed)||o.speed<.5||o.speed>2||!Number.isFinite(o.pitch)||o.pitch<.5||o.pitch>2||!Number.isFinite(o.volume)||o.volume<0||o.volume>1)||e===`asr`&&o.asrContext!==void 0&&(typeof o.asrContext!=`string`||o.asrContext.length>2e3||/\0/.test(o.asrContext)))throw Error(`Invalid speech session`);return o}function C(e,t){let n=new URL(t===`asr`?`wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async`:`wss://openspeech.bytedance.com/api/v3/tts/bidirection`);return n.search=new URLSearchParams({api_app_key:e.appId,api_access_key:`Jwt; ${e.token}`,api_resource_id:e.resourceId}).toString(),n.toString()}var w=new TextEncoder,T=new TextDecoder,E=1048576;function D(e,t=!1,n=!1){let r=new Uint8Array(8+e.length);return r.set([17,(t?2:1)<<4|(n?2:0),t?0:16,0]),new DataView(r.buffer).setUint32(4,e.length),r.set(e,8),r}function O(e,t=``,n={}){let r=w.encode(t),i=w.encode(JSON.stringify(n)),a=new Uint8Array(12+i.length+(t?4+r.length:0));a.set([17,20,16,0]);let o=new DataView(a.buffer);o.setInt32(4,e);let s=8;return t&&(o.setUint32(s,r.length),a.set(r,s+4),s+=4+r.length),o.setUint32(s,i.length),a.set(i,s+4),a}async function k(e,t){if(e.byteLength<8||e.byteLength>E)throw Error(`Invalid speech frame size`);let n=new Uint8Array(e),r=new DataView(e),i=n[1]>>4,a=n[1]&15,o=n[2]&15,s=(n[0]&15)*4;if(n[0]>>4!=1||s<4||s>n.length-4)throw Error(`Invalid speech frame`);let c=()=>{if(s+4>n.length)throw Error(`Truncated speech frame`);let e=r.getUint32(s);return s+=4,e};if(i===15)throw Error(`Speech provider failed (code ${c()})`);if(i!==9&&(t!==`tts`||i!==11))throw Error(`Unexpected speech frame`);a&1&&c();let l=0,u=``;if(a&4&&(l=c(),t===`tts`)){let e=c();if(e>256||s+e>n.length)throw Error(`Invalid speech session ID`);u=T.decode(n.subarray(s,s+e)),s+=e}let d=c();if(s+d!==n.length)throw Error(`Truncated speech payload`);let f=n.slice(s);if(o===1){let e=new Blob([f]).stream().pipeThrough(new DecompressionStream(`gzip`)).getReader(),t=[],n=0;try{for(;;){let r=await e.read();if(r.done)break;if(n+=r.value.length,n>E)throw Error(`Speech payload exceeds size limit`);t.push(r.value)}}finally{await e.cancel().catch(()=>void 0),e.releaseLock()}f=new Uint8Array(n);let r=0;for(let e of t)f.set(e,r),r+=e.length}else if(o!==0)throw Error(`Unsupported speech compression`);return{type:i,event:l,sessionId:u,final:!!(a&2),payload:f}}function A(e){let t=JSON.parse(T.decode(e));if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid speech response`);return t}async function j(e,t){t.throwIfAborted();let n=new WebSocket(e);n.binaryType=`arraybuffer`;let r=[],i=0,a=null,o=null,s=null,c=(e=!0)=>{t.removeEventListener(`abort`,u),n.onmessage=null,n.onclose=null,n.onerror=null,n.onopen=null,e&&(r.length=0,i=0),n.close(),o?.()},l=(e,t=!0)=>{a??=e,s?.(a),c(t)},u=()=>l(new DOMException(`Speech cancelled`,`AbortError`));t.addEventListener(`abort`,u,{once:!0}),n.onmessage=e=>{if(!(e.data instanceof ArrayBuffer)||e.data.byteLength>E){l(Error(`Invalid speech message`));return}if(i+=e.data.byteLength,i>33554432||r.length>=4096){l(Error(`Speech receive buffer exceeded`));return}r.push(e.data),o?.()},n.onerror=()=>l(Error(`Speech connection failed`)),n.onclose=()=>l(Error(`Speech connection ended before completion`),!1);let d=setTimeout(()=>l(Error(`Speech connection timed out`)),1e4);try{await new Promise((e,t)=>{s=t,n.onopen=()=>e()})}finally{clearTimeout(d),s=null}return{send(e){if(t.throwIfAborted(),a)throw a;if(n.readyState!==WebSocket.OPEN||n.bufferedAmount+e.length>E)throw Error(`Speech send buffer exceeded`);n.send(e)},async read(){let e=setTimeout(()=>l(Error(`Speech response timed out`)),6e4);try{for(;!r.length&&!a;)await new Promise(e=>{o=e});if(t.throwIfAborted(),!r.length&&a)throw a;let e=r.shift();return i-=e.byteLength,e}finally{clearTimeout(e),o=null}},close(){a??=new DOMException(`Speech closed`,`AbortError`),c()}}}var M=class{abort;partial;disconnected;socket=null;failure=null;completion=null;text=``;final=!1;finishing=!1;sequence=0;constructor(e,t,n){this.abort=e,this.partial=t,this.disconnected=n}get connected(){return this.socket!==null&&!this.failure&&!this.abort.signal.aborted}async start(e,t){if(t!==`audio/pcm;rate=16000;bits=16`)throw Error(`Direct speech requires 16 kHz PCM16 audio`);let n=await j(C(e,`asr`),this.abort.signal);this.socket=n;try{n.send(D(new TextEncoder().encode(JSON.stringify({user:{uid:`yuri`},audio:{format:`pcm`,codec:`raw`,rate:16e3,bits:16,channel:1},request:{model_name:`bigmodel`,result_type:`full`,enable_itn:!0,enable_punc:!0,enable_nonstream:!0,show_utterances:!0,...e.asrContext?.trim()?{corpus:{context:JSON.stringify({context_type:`dialog_ctx`,context_data:[{text:e.asrContext.trim()}]})}}:{}}}))))}catch(e){throw n.close(),e}this.completion=this.receive().catch(e=>{this.failure=e instanceof Error?e:Error(`Speech recognition failed`),n.close(),!this.abort.signal.aborted&&!this.finishing&&this.disconnected()})}send(e,t){if(!this.connected||this.finishing||this.final||e!==this.sequence)return!1;try{if(t.length>128e3)throw Error(`Speech audio chunk exceeds size limit`);let e=atob(t);if(e.length%2)throw Error(`Invalid PCM audio`);let n=Uint8Array.from(e,e=>e.charCodeAt(0));return this.socket.send(D(n,!0)),this.sequence++,!0}catch{return this.failure=Error(`Unable to send speech audio`),this.socket?.close(),!1}}async finish(e){if(this.failure)throw this.failure;if(!this.socket||e!==this.sequence-1)throw Error(`Incomplete speech audio`);this.finishing=!0,this.socket.send(D(new Uint8Array,!0,!0));let t=setTimeout(()=>{this.failure=Error(`Speech finalization timed out`),this.socket?.close()},3e4);try{if(await this.completion,this.abort.signal.throwIfAborted(),this.failure)throw this.failure;if(!this.final)throw Error(`Incomplete speech recognition`);return{text:this.text}}finally{clearTimeout(t),this.socket.close()}}cancel(){this.abort.abort(),this.socket?.close()}async receive(){for(;;){let e=await k(await this.socket.read(),`asr`);this.abort.signal.throwIfAborted();let t=A(e.payload);if(t.code!==void 0&&![0,1e3,2e7].includes(Number(t.code)))throw Error(`Speech recognition failed`);let n=t.result;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Invalid speech transcript`);if(n&&typeof n==`object`&&`text`in n){if(typeof n.text!=`string`)throw Error(`Invalid speech transcript`);this.text=n.text,e.final||this.partial(this.text)}if(e.final){if(!this.finishing)throw Error(`Speech recognition ended unexpectedly`);this.final=!0;return}}}},N=(e,t,n)=>{let r=Error(e);return r.name=`DictationStreamError`,r.retryable=t,n&&(r.reasonCode=n),r},P=1e4,F=15e3,I=3e4,L=3e4,R=new class{socket=null;connectPromise=null;idleCloseTimer=null;pendingStarts=new Map;pendingFinishes=new Map;connectionListeners=new Set;partialListeners=new Set;activeDictations=0;directStarts=new Map;directSessions=new Map;get isConnected(){if(this.socket?.readyState===WebSocket.OPEN)return!0;for(let e of this.directSessions.values())if(e.connected)return!0;return!1}subscribeConnectionStatus(e){return this.connectionListeners.add(e),()=>{this.connectionListeners.delete(e)}}onPartial(e){return this.partialListeners.add(e),()=>{this.partialListeners.delete(e)}}async ensureConnected(){if(this.socket?.readyState!==WebSocket.OPEN){if(this.connectPromise){await this.connectPromise;return}try{await t()}catch{}this.connectPromise=new Promise((e,t)=>{let n=!1,i;try{let e=r().websocket(`/api/dictation/ws`);i=s(e)}catch(e){this.connectPromise=null,t(e instanceof Error?e:Error(String(e)));return}let a=setTimeout(()=>{if(!n){n=!0,this.connectPromise=null;try{i.close()}catch{}t(Error(`Dictation connection timed out`))}},P);i.onopen=()=>{},i.onmessage=t=>{let r;try{r=JSON.parse(String(t.data))}catch{return}if(!n&&r.type===`ready`){n=!0,clearTimeout(a),this.socket=i,this.connectPromise=null,this.notifyConnection(!0),e();return}this.handleMessage(r)},i.onerror=()=>{window.setTimeout(()=>{n||(n=!0,clearTimeout(a),this.connectPromise=null,t(Error(`Dictation connection failed`)))},250)},i.onclose=e=>{if(!n){n=!0,clearTimeout(a),this.connectPromise=null;let r=e?.reason?`: ${e.reason}`:``;t(Error(`Dictation connection failed${r}`));return}this.socket===i&&(this.socket=null,this.rejectAllPending(Error(`Dictation connection lost`)),this.notifyConnection(!1))}}),await this.connectPromise}}async startDictationStream(e,t){let n=new AbortController;this.directStarts.set(e,n);try{let r=await S(`asr`,n.signal);if(n.signal.throwIfAborted(),r){let i=new M(n,t=>{for(let n of this.partialListeners)n(e,t)},()=>{this.directSessions.delete(e),i.cancel(),this.notifyConnection(!1)});this.directSessions.set(e,i),await i.start(r,t),n.signal.throwIfAborted(),this.notifyConnection(!0);return}await this.ensureConnected(),n.signal.throwIfAborted()}catch(t){throw this.directSessions.get(e)?.cancel(),this.directSessions.delete(e),t}finally{this.directStarts.delete(e)}return this.activeDictations+=1,this.clearIdleCloseTimer(),new Promise((n,r)=>{let i=setTimeout(()=>{this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation start timed out`))},F);this.pendingStarts.set(e,{resolve:()=>{clearTimeout(i),n()},reject:e=>{clearTimeout(i),this.releaseDictation(),r(e)},timeout:i}),this.send({type:`start`,dictationId:e,format:t})||(clearTimeout(i),this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation connection lost`)))})}sendDictationStreamChunk(e,t,n){let r=this.directSessions.get(e);return r?r.send(t,n):this.send({type:`chunk`,dictationId:e,seq:t,audio:n})}finishDictationStream(e,t){let n=this.directSessions.get(e);return n?n.finish(t).finally(()=>{n.cancel(),this.directSessions.delete(e)}):new Promise((n,r)=>{let i={resolve:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),n(e)},reject:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),r(e)},timeout:null};i.timeout=setTimeout(()=>{this.pendingFinishes.delete(e),this.releaseDictation(),r(Error(`Timed out waiting for transcription`))},L),this.pendingFinishes.set(e,i),this.send({type:`finish`,dictationId:e,finalSeq:t})||(this.pendingFinishes.delete(e),i.reject(Error(`Dictation connection lost`)))})}cancelDictationStream(e){this.directStarts.get(e)?.abort(),this.directStarts.delete(e);let t=this.directSessions.get(e);if(t){t.cancel(),this.directSessions.delete(e);return}this.send({type:`cancel`,dictationId:e});let n=this.pendingStarts.get(e);n&&(this.pendingStarts.delete(e),n.reject(Error(`Dictation cancelled`)));let r=this.pendingFinishes.get(e);r&&(this.pendingFinishes.delete(e),r.reject(Error(`Dictation cancelled`))),this.releaseDictation(),this.scheduleIdleCloseIfReady()}handleMessage(e){let t=e.dictationId;if(t)switch(e.type){case`ack`:{let e=this.pendingStarts.get(t);e&&(this.pendingStarts.delete(t),e.resolve());return}case`partial`:for(let n of this.partialListeners)n(t,e.text??``);return;case`finish_accepted`:{let n=this.pendingFinishes.get(t);n&&typeof e.timeoutMs==`number`&&(n.timeout&&clearTimeout(n.timeout),n.timeout=setTimeout(()=>{this.pendingFinishes.delete(t),n.reject(Error(`Timed out waiting for transcription`))},e.timeoutMs+5e3));return}case`final`:{let n=this.pendingFinishes.get(t);n&&(this.pendingFinishes.delete(t),n.resolve({text:e.text??``})),this.scheduleIdleCloseIfReady();return}case`error`:{let n=N(e.error||`Dictation failed`,e.retryable!==!1,e.reasonCode),r=this.pendingStarts.get(t);r&&(this.pendingStarts.delete(t),r.reject(n));let i=this.pendingFinishes.get(t);i&&(this.pendingFinishes.delete(t),i.reject(n)),this.scheduleIdleCloseIfReady();return}}}send(e){if(!this.isConnected||!this.socket)return!1;try{return this.socket.send(JSON.stringify(e)),!0}catch{return!1}}notifyConnection(e){for(let t of this.connectionListeners)t(e)}rejectAllPending(e){for(let[t,n]of this.pendingStarts)this.pendingStarts.delete(t),n.reject(e);for(let[t,n]of this.pendingFinishes)this.pendingFinishes.delete(t),n.reject(e);this.activeDictations=0}releaseDictation(){this.activeDictations=Math.max(0,this.activeDictations-1),this.scheduleIdleCloseIfReady()}scheduleIdleCloseIfReady(){this.activeDictations>0||this.pendingFinishes.size>0||this.pendingStarts.size>0||(this.clearIdleCloseTimer(),this.idleCloseTimer=setTimeout(()=>{if(this.activeDictations===0&&this.pendingFinishes.size===0&&this.pendingStarts.size===0){let e=this.socket;if(this.socket=null,e){try{e.close(1e3,`idle`)}catch{}this.notifyConnection(!1)}}},I))}cancelAllForRuntimeSwitch(){for(let e of this.directStarts.values())e.abort();this.directStarts.clear();for(let e of this.directSessions.values())e.cancel();this.directSessions.clear(),this.clearIdleCloseTimer();let e=this.socket;if(this.socket=null,this.connectPromise=null,this.rejectAllPending(Error(`Runtime changed`)),e){try{e.close(1e3,`runtime switch`)}catch{}this.notifyConnection(!1)}}clearIdleCloseTimer(){this.idleCloseTimer&&=(clearTimeout(this.idleCloseTimer),null)}};typeof window<`u`&&window.addEventListener(`yuri:runtime-endpoint-changed`,()=>{R.cancelAllForRuntimeSwitch()});var z=128,B=`audio/pcm;rate=16000;bits=16`,V=()=>new Promise(e=>setTimeout(e,0)),H=()=>{let e=Math.random().toString(36).slice(2,10);return`dic_${Date.now().toString(16)}${e}`},ee=class{client;format;createDictationId;dictationId=null;sendSeq=0;segments=[];streamReady=!1;flushTimer=null;drainWaiters=[];startGeneration=0;startPromise=null;constructor(e){this.client=e.client,this.format=e.format??B,this.createDictationId=e.createDictationId??H}getDictationId(){return this.dictationId}getFinalSeq(){return this.segments.length-1}hasSegments(){return this.segments.length>0}clearAll(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.segments=[],this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}resetStreamForReplay(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}enqueueSegment(e){if(this.segments.push(e),this.client.isConnected){if(!this.dictationId){this.startPromise||this.restartStream().catch(()=>{});return}this.flush()}}flush(){let e=this.dictationId;if(!this.client.isConnected||!e||!this.streamReady)return 0;let t=0;for(;this.sendSeq<this.segments.length&&t<z;){let n=this.sendSeq,r=this.segments[n];if(!this.client.sendDictationStreamChunk(e,n,r))break;this.sendSeq=n+1,t+=1}return this.hasPendingSegments()?this.scheduleFlush():this.resolveDrainWaiters(),t}async restartStream(){this.startGeneration+=1;let e=this.startGeneration,t=this.createDictationId();this.dictationId=t,this.sendSeq=0,this.streamReady=!1;let n=(async()=>{await this.client.startDictationStream(t,this.format),this.startGeneration===e&&this.dictationId===t&&(this.streamReady=!0,this.flush())})().catch(n=>{throw this.startGeneration===e&&this.dictationId===t&&(this.dictationId=null,this.streamReady=!1),n}).finally(()=>{this.startPromise===n&&(this.startPromise=null)});this.startPromise=n,await n}async finish(e){this.dictationId||await this.restartStream(),this.startPromise&&await this.startPromise;let t=this.dictationId;if(!t||!this.streamReady)throw Error(`Failed to start dictation stream`);return this.flush(),await this.waitForFlushDrain(),{dictationId:t,text:(await this.client.finishDictationStream(t,e)).text}}cancel(){this.resetStreamForReplay()}hasPendingSegments(){return this.sendSeq<this.segments.length}scheduleFlush(){this.flushTimer||=setTimeout(()=>{this.flushTimer=null,this.flush()},0)}clearScheduledFlush(){this.resolveDrainWaiters(),this.flushTimer&&=(clearTimeout(this.flushTimer),null)}async waitForFlushDrain(){for(;this.hasPendingSegments();){if(!this.client.isConnected||!this.dictationId||!this.streamReady)throw Error(`Failed to flush dictation stream`);await new Promise(e=>{this.drainWaiters.push(e)}),await V()}}resolveDrainWaiters(){let e=this.drainWaiters;this.drainWaiters=[];for(let t of e)t()}},U=c(),W=new Set;function G(e){return W.add(e),()=>{W.delete(e)}}function K(){for(let e of W)e();if(typeof window<`u`&&window.speechSynthesis?.cancel(),typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type=`play-and-record`}catch{}}function te(){if(typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type!==`playback`&&(e.type=`playback`)}catch{}}var q=16e3,J=q/5,Y=()=>{if(typeof window>`u`)return null;let e=window;return e.AudioContext||e.webkitAudioContext||null},X=e=>{let t=Math.max(-1,Math.min(1,e));return Math.round(t<0?t*32768:t*32767)},ne=(e,t,n)=>{if(e.length===0)return new Int16Array;if(t===n){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++)t[n]=X(e[n]);return t}let r=t/n,i=Math.max(1,Math.round(e.length/r)),a=new Int16Array(i);for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=X(e[i]*(1-s)+e[o]*s)}return a},re=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Int16Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},Z=e=>{let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)},Q=()=>({stream:null,context:null,source:null,processor:null,gain:null,pending:new Int16Array,started:!1}),$=e=>{if(e)try{e.disconnect()}catch{}},ie=()=>typeof navigator>`u`||typeof window>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`?!1:Y()!==null;function ae(e){let t=(0,U.c)(16),[n,r]=(0,x.useState)(0),i=(0,x.useRef)(e.onPcmSegment),a=(0,x.useRef)(e.onError),o,s;t[0]!==e.onError||t[1]!==e.onPcmSegment?(o=()=>{i.current=e.onPcmSegment,a.current=e.onError},s=[e.onPcmSegment,e.onError],t[0]=e.onError,t[1]=e.onPcmSegment,t[2]=o,t[3]=s):(o=t[2],s=t[3]),(0,x.useEffect)(o,s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=Q(),t[4]=c):c=t[4];let u=(0,x.useRef)(c),d=(0,x.useRef)(0),f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=async()=>{if(u.current.started)return;if(typeof navigator>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`)throw Error(`Microphone capture is not supported in this environment`);let e=Y();if(!e)throw Error(`AudioContext unavailable`);let t=d.current+=1;K();let n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}});if(t!==d.current){n.getTracks().forEach(ue);return}let a=new e;try{if(a.state===`suspended`&&await a.resume().catch(le),t!==d.current){n.getTracks().forEach(ce),await a.close();return}let e=a.createMediaStreamSource(n),o=a.createScriptProcessor(4096,1,1),s=a.createGain();s.gain.value=0,u.current={stream:n,context:a,source:e,processor:o,gain:s,pending:new Int16Array,started:!0},o.onaudioprocess=e=>{let t=u.current;if(!t.started)return;let n=e.inputBuffer.getChannelData(0),o=0;for(let e=0;e<n.length;e++)o+=n[e]*n[e];let s=Math.sqrt(o/Math.max(1,n.length));r(Math.min(1,Math.max(0,s*2)));let c=ne(n,a.sampleRate,q);for(t.pending=re(t.pending,c);t.pending.length>=J;){let e=t.pending.slice(0,J);t.pending=t.pending.slice(J),i.current(Z(e))}},e.connect(o),o.connect(s),s.connect(a.destination)}catch(e){let t=e;n.getTracks().forEach(se);try{await a.close()}catch{}throw u.current=Q(),t instanceof Error?t:Error(String(t))}},t[5]=f):f=t[5];let p=l(f),m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=async()=>{d.current+=1;let e=u.current;if(e.started=!1,r(0),e.processor)try{e.processor.onaudioprocess=null}catch{}$(e.processor),$(e.source),$(e.gain),e.stream&&e.stream.getTracks().forEach(oe);let t=e.pending;if(e.pending=new Int16Array,t.length>0&&i.current(Z(t)),e.context)try{await e.context.close()}catch{}u.current===e&&(u.current=Q())},t[6]=m):m=t[6];let h=l(m),g,_;t[7]===h?(g=t[8],_=t[9]):(g=()=>()=>{h().catch(e=>{a.current?.(e instanceof Error?e:Error(String(e)))})},_=[h],t[7]=h,t[8]=g,t[9]=_),(0,x.useEffect)(g,_);let v;t[10]===p?v=t[11]:(v=async()=>{try{await p()}catch(e){let t=e,n=t instanceof Error?t:Error(String(t));throw a.current?.(n),n}},t[10]=p,t[11]=v);let y;return t[12]!==h||t[13]!==v||t[14]!==n?(y={start:v,stop:h,volume:n},t[12]=h,t[13]=v,t[14]=n,t[15]=y):y=t[15],y}function oe(e){try{e.stop()}catch{}}function se(e){try{e.stop()}catch{}}function ce(e){return e.stop()}function le(){}function ue(e){return e.stop()}var de=1e3,fe=e=>e instanceof Error?e:Error(String(e));function pe(e={}){let{t}=u(),{onTranscript:r,onError:i,canStart:a}=e,[o,s]=(0,x.useState)(`idle`),[c,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(``),[m,h]=(0,x.useState)(0),[g,_]=(0,x.useState)(null),[v,y]=(0,x.useState)(null),b=(0,x.useRef)(o);(0,x.useEffect)(()=>{b.current=o},[o]);let S=(0,x.useRef)(``),C=(0,x.useRef)(null),w=(0,x.useRef)({starting:!1,confirming:!1,cancelling:!1}),T=(0,x.useRef)(0),E=(0,x.useRef)(r),D=(0,x.useRef)(i);(0,x.useEffect)(()=>{E.current=r,D.current=i},[r,i]);let O=(0,x.useRef)(null);O.current||=new ee({client:R});let k=l(()=>{C.current&&=(clearInterval(C.current),null)}),A=l(()=>{C.current||=setInterval(()=>{h(e=>e+1)},de)}),j=l(e=>{let n=fe(e),r=n.name===`NotFoundError`||n.name===`DevicesNotFoundError`?Error(t(`chat.dictation.error.microphoneNotFound`),{cause:n}):n;_(r.message);let i=n.reasonCode;y(typeof i==`string`?i:null),D.current?.(r)}),M=l(()=>{_(null),y(null)}),N=l(()=>{O.current?.clearAll(),S.current=``,p(``)}),P=l(t=>e.onPartialTranscript?.(t));(0,x.useEffect)(()=>R.onPartial((e,t)=>{let n=O.current?.getDictationId();!n||e!==n||(S.current=t,p(t),P(t))}),[P]),(0,x.useEffect)(()=>R.subscribeConnectionStatus(e=>{if(!e){b.current===`recording`&&O.current?.resetStreamForReplay();return}if(b.current!==`recording`||O.current?.getDictationId())return;let t=T.current;O.current?.restartStream().catch(e=>{T.current===t&&j(e)})}),[j]);let F=ae({onPcmSegment:e=>{b.current===`recording`&&O.current?.enqueueSegment(e)},onError:e=>{D.current?.(e)}}),I=(0,x.useRef)(F.stop);(0,x.useEffect)(()=>{I.current=F.stop},[F.stop]);let L=l(e=>{h(0),s(`idle`),b.current=`idle`;let t=e.trim();return N(),t?(E.current?.(t),t):null}),z=l(e=>{O.current?.hasSegments()?(s(`failed`),b.current=`failed`):(s(`idle`),b.current=`idle`),j(e)}),B=l(async()=>{let e=w.current;if(e.starting||e.confirming||e.cancelling||b.current!==`idle`||a&&!a())return;e.starting=!0,d(!0);let t=++T.current;M(),p(``),h(0),s(`recording`),b.current=`recording`,N();try{if(await F.start(),T.current!==t||b.current!==`recording`)return;d(!1),A(),await O.current?.restartStream().catch(e=>{T.current===t&&j(e)})}catch(e){if(T.current!==t)return;await F.stop().catch(()=>void 0),k(),s(`idle`),b.current=`idle`,j(e)}finally{T.current===t&&d(!1),e.starting=!1}}),V=l(async()=>{let e=w.current;if(!e.cancelling&&(b.current===`recording`||b.current===`uploading`)){e.cancelling=!0,d(!1),T.current+=1,k(),h(0),M(),s(`idle`),b.current=`idle`;try{O.current?.cancel()}catch{}N();try{await F.stop()}catch{}finally{e.cancelling=!1}}}),H=l(async()=>{let e=w.current;if(e.confirming||b.current!==`recording`)return null;e.confirming=!0,d(!1);let t=++T.current;M(),k();try{if(await F.stop(),T.current!==t)return null;s(`uploading`),b.current=`uploading`;let e=O.current?.getFinalSeq()??-1;if(e<0)return O.current?.cancel(),L(``);let n=await O.current.finish(e);return T.current===t?L(n.text):null}catch(e){return T.current===t&&z(e),null}finally{e.confirming=!1}}),U=l(async()=>{if(b.current!==`failed`||!O.current?.hasSegments())return null;M();let e=++T.current;s(`uploading`),b.current=`uploading`;try{O.current.resetStreamForReplay();let t=O.current.getFinalSeq(),n=await O.current.finish(t);return T.current===e?L(n.text):null}catch(t){return T.current===e&&z(t),null}}),W=l(()=>{if(b.current!==`failed`)return null;let e=S.current.trim();h(0),s(`idle`),b.current=`idle`,M();try{O.current?.cancel()}catch{}return N(),e?(E.current?.(e),e):null}),G=l(()=>{h(0),s(`idle`),b.current=`idle`,M(),N()});return(0,x.useEffect)(()=>n(()=>{b.current===`failed`?(T.current+=1,G()):V()}),[V,G]),(0,x.useEffect)(()=>{if(o!==`recording`||v!==`model_download_in_progress`)return;let e=setInterval(()=>{b.current!==`recording`||O.current?.getDictationId()||O.current?.restartStream().then(()=>{M()}).catch(e=>{j(e)})},3e3);return()=>clearInterval(e)},[o,v,M,j]),(0,x.useEffect)(()=>()=>{T.current+=1,k(),I.current().catch(()=>void 0),O.current?.cancel()},[k]),{status:o,isRecording:o===`recording`,isStarting:c,isProcessing:o===`uploading`,partialTranscript:f,volume:F.volume,duration:m,error:g,errorReason:v,startDictation:B,confirmDictation:H,cancelDictation:V,retryFailedDictation:U,acceptPartialTranscript:W,discardFailedDictation:G}}var me=`app-region-no-drag transition-[opacity,transform] duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 z-50 max-h-[var(--available-height)] min-w-[8rem] origin-[var(--transform-origin)] overflow-visible rounded-xl p-1 shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,he=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active data-[variant=destructive]:text-destructive data-[variant=destructive]:hover:bg-destructive/10 dark:data-[variant=destructive]:hover:bg-destructive/20 data-[variant=destructive]:hover:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,ge=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,_e=`bg-border -mx-1 my-0.5 h-px`;export{m as S,f as _,pe as a,_ as b,te as c,j as d,A as f,d as g,C as h,ge as i,G as l,S as m,me as n,ie as o,O as p,_e as r,K as s,he as t,k as u,p as v,y as x,b as y};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t}from"./runtime-auth-DBn9yahL.js";import{c as n,f as r,i}from"./runtime-switch-DEZ1K7qW.js";import{n as a}from"./runtime-fetch-D4ja813o.js";import{it as o}from"./vendor-base-ui-CdzJ6My_.js";import{yt as s}from"./gitApiHttp-BBRKl9WX.js";import{n as c}from"./vendor-react-BP2cRVqX.js";import{r as l}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{f as u}from"./button-Be1cqulG.js";var d=`yuri:close-embedded-session-chat`,f=`yuri:embedded-visibility`,p=`yuri:embedded-visibility-request`,m=e=>new URLSearchParams(e).get(`yuriPanel`)===`session-chat`,h=(e,t,n)=>JSON.stringify({sessionID:e,directory:t||``,readOnly:n===!0}),g=(e,t,n,r)=>{if(typeof window>`u`)return``;let i=new URL(window.location.pathname,window.location.origin);return i.searchParams.set(`yuriPanel`,`session-chat`),i.searchParams.set(`surface`,`desktop`),i.searchParams.set(`sessionId`,e),n?i.searchParams.set(`readOnly`,`1`):i.searchParams.delete(`readOnly`),t&&t.trim().length>0?i.searchParams.set(`directory`,t):i.searchParams.delete(`directory`),i.searchParams.set(`themeMode`,r.mode),i.searchParams.set(`lightThemeId`,r.lightThemeId),i.searchParams.set(`darkThemeId`,r.darkThemeId),i.searchParams.set(`themeVariant`,r.currentTheme.metadata.variant===`dark`?`dark`:`light`),i.searchParams.set(`currentTheme`,JSON.stringify(r.currentTheme)),i.hash=``,i.toString()},_=(e,t,n,r,i,a)=>{let o=h(n,r,i),s=e.get(t);if(s?.signature===o)return s.src;let c=g(n,r,i,a);return e.set(t,{signature:o,src:c}),c},v=null,y=()=>{if(v!==null)return v;if(typeof window>`u`)return v=!1,!1;try{return v=new URLSearchParams(window.location.search).get(`yuriPanel`)===`session-chat`,v}catch{return v=!1,!1}},b=()=>{if(!y())return null;try{let e=new URLSearchParams(window.location.search).get(`sessionId`);return e&&e.trim().length>0?e.trim():null}catch{return null}},x=e(o(),1);async function S(e,t){let n=i(),r=await a(`/api/voice/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e}),signal:AbortSignal.any([t,AbortSignal.timeout(2e4)])});if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`))return await r.body?.cancel(),null;if(!r.ok)throw await r.body?.cancel(),Error(`Unable to create speech session`);let o=await r.json();if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(o?.transport===`host`)return null;if(o?.transport!==`volcengine-direct`||typeof o.token!=`string`||o.token.length>16384||!/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(o.token)||typeof o.appId!=`string`||!/^[A-Za-z0-9_-]{1,128}$/.test(o.appId)||typeof o.resourceId!=`string`||!/^[A-Za-z0-9._-]{1,128}$/.test(o.resourceId)||!Number.isFinite(o.expiresAt)||o.expiresAt<=Date.now()+5e3||o.expiresAt>Date.now()+36e4||e===`tts`&&(typeof o.voice!=`string`||!/^[A-Za-z0-9_-]{1,200}$/.test(o.voice)||!Number.isFinite(o.speed)||o.speed<.5||o.speed>2||!Number.isFinite(o.pitch)||o.pitch<.5||o.pitch>2||!Number.isFinite(o.volume)||o.volume<0||o.volume>1)||e===`asr`&&o.asrContext!==void 0&&(typeof o.asrContext!=`string`||o.asrContext.length>2e3||/\0/.test(o.asrContext)))throw Error(`Invalid speech session`);return o}function C(e,t){let n=new URL(t===`asr`?`wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async`:`wss://openspeech.bytedance.com/api/v3/tts/bidirection`);return n.search=new URLSearchParams({api_app_key:e.appId,api_access_key:`Jwt; ${e.token}`,api_resource_id:e.resourceId}).toString(),n.toString()}var w=new TextEncoder,T=new TextDecoder,E=1048576;function D(e,t=!1,n=!1){let r=new Uint8Array(8+e.length);return r.set([17,(t?2:1)<<4|(n?2:0),t?0:16,0]),new DataView(r.buffer).setUint32(4,e.length),r.set(e,8),r}function O(e,t=``,n={}){let r=w.encode(t),i=w.encode(JSON.stringify(n)),a=new Uint8Array(12+i.length+(t?4+r.length:0));a.set([17,20,16,0]);let o=new DataView(a.buffer);o.setInt32(4,e);let s=8;return t&&(o.setUint32(s,r.length),a.set(r,s+4),s+=4+r.length),o.setUint32(s,i.length),a.set(i,s+4),a}async function k(e,t){if(e.byteLength<8||e.byteLength>E)throw Error(`Invalid speech frame size`);let n=new Uint8Array(e),r=new DataView(e),i=n[1]>>4,a=n[1]&15,o=n[2]&15,s=(n[0]&15)*4;if(n[0]>>4!=1||s<4||s>n.length-4)throw Error(`Invalid speech frame`);let c=()=>{if(s+4>n.length)throw Error(`Truncated speech frame`);let e=r.getUint32(s);return s+=4,e};if(i===15)throw Error(`Speech provider failed (code ${c()})`);if(i!==9&&(t!==`tts`||i!==11))throw Error(`Unexpected speech frame`);a&1&&c();let l=0,u=``;if(a&4&&(l=c(),t===`tts`)){let e=c();if(e>256||s+e>n.length)throw Error(`Invalid speech session ID`);u=T.decode(n.subarray(s,s+e)),s+=e}let d=c();if(s+d!==n.length)throw Error(`Truncated speech payload`);let f=n.slice(s);if(o===1){let e=new Blob([f]).stream().pipeThrough(new DecompressionStream(`gzip`)).getReader(),t=[],n=0;try{for(;;){let r=await e.read();if(r.done)break;if(n+=r.value.length,n>E)throw Error(`Speech payload exceeds size limit`);t.push(r.value)}}finally{await e.cancel().catch(()=>void 0),e.releaseLock()}f=new Uint8Array(n);let r=0;for(let e of t)f.set(e,r),r+=e.length}else if(o!==0)throw Error(`Unsupported speech compression`);return{type:i,event:l,sessionId:u,final:!!(a&2),payload:f}}function A(e){let t=JSON.parse(T.decode(e));if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid speech response`);return t}async function j(e,t){t.throwIfAborted();let n=new WebSocket(e);n.binaryType=`arraybuffer`;let r=[],i=0,a=null,o=null,s=null,c=(e=!0)=>{t.removeEventListener(`abort`,u),n.onmessage=null,n.onclose=null,n.onerror=null,n.onopen=null,e&&(r.length=0,i=0),n.close(),o?.()},l=(e,t=!0)=>{a??=e,s?.(a),c(t)},u=()=>l(new DOMException(`Speech cancelled`,`AbortError`));t.addEventListener(`abort`,u,{once:!0}),n.onmessage=e=>{if(!(e.data instanceof ArrayBuffer)||e.data.byteLength>E){l(Error(`Invalid speech message`));return}if(i+=e.data.byteLength,i>33554432||r.length>=4096){l(Error(`Speech receive buffer exceeded`));return}r.push(e.data),o?.()},n.onerror=()=>l(Error(`Speech connection failed`)),n.onclose=()=>l(Error(`Speech connection ended before completion`),!1);let d=setTimeout(()=>l(Error(`Speech connection timed out`)),1e4);try{await new Promise((e,t)=>{s=t,n.onopen=()=>e()})}finally{clearTimeout(d),s=null}return{send(e){if(t.throwIfAborted(),a)throw a;if(n.readyState!==WebSocket.OPEN||n.bufferedAmount+e.length>E)throw Error(`Speech send buffer exceeded`);n.send(e)},async read(){let e=setTimeout(()=>l(Error(`Speech response timed out`)),6e4);try{for(;!r.length&&!a;)await new Promise(e=>{o=e});if(t.throwIfAborted(),!r.length&&a)throw a;let e=r.shift();return i-=e.byteLength,e}finally{clearTimeout(e),o=null}},close(){a??=new DOMException(`Speech closed`,`AbortError`),c()}}}var M=class{abort;partial;disconnected;socket=null;failure=null;completion=null;text=``;final=!1;finishing=!1;sequence=0;constructor(e,t,n){this.abort=e,this.partial=t,this.disconnected=n}get connected(){return this.socket!==null&&!this.failure&&!this.abort.signal.aborted}async start(e,t){if(t!==`audio/pcm;rate=16000;bits=16`)throw Error(`Direct speech requires 16 kHz PCM16 audio`);let n=await j(C(e,`asr`),this.abort.signal);this.socket=n;try{n.send(D(new TextEncoder().encode(JSON.stringify({user:{uid:`yuri`},audio:{format:`pcm`,codec:`raw`,rate:16e3,bits:16,channel:1},request:{model_name:`bigmodel`,result_type:`full`,enable_itn:!0,enable_punc:!0,enable_nonstream:!0,show_utterances:!0,...e.asrContext?.trim()?{corpus:{context:JSON.stringify({context_type:`dialog_ctx`,context_data:[{text:e.asrContext.trim()}]})}}:{}}}))))}catch(e){throw n.close(),e}this.completion=this.receive().catch(e=>{this.failure=e instanceof Error?e:Error(`Speech recognition failed`),n.close(),!this.abort.signal.aborted&&!this.finishing&&this.disconnected()})}send(e,t){if(!this.connected||this.finishing||this.final||e!==this.sequence)return!1;try{if(t.length>128e3)throw Error(`Speech audio chunk exceeds size limit`);let e=atob(t);if(e.length%2)throw Error(`Invalid PCM audio`);let n=Uint8Array.from(e,e=>e.charCodeAt(0));return this.socket.send(D(n,!0)),this.sequence++,!0}catch{return this.failure=Error(`Unable to send speech audio`),this.socket?.close(),!1}}async finish(e){if(this.failure)throw this.failure;if(!this.socket||e!==this.sequence-1)throw Error(`Incomplete speech audio`);this.finishing=!0,this.socket.send(D(new Uint8Array,!0,!0));let t=setTimeout(()=>{this.failure=Error(`Speech finalization timed out`),this.socket?.close()},3e4);try{if(await this.completion,this.abort.signal.throwIfAborted(),this.failure)throw this.failure;if(!this.final)throw Error(`Incomplete speech recognition`);return{text:this.text}}finally{clearTimeout(t),this.socket.close()}}cancel(){this.abort.abort(),this.socket?.close()}async receive(){for(;;){let e=await k(await this.socket.read(),`asr`);this.abort.signal.throwIfAborted();let t=A(e.payload);if(t.code!==void 0&&![0,1e3,2e7].includes(Number(t.code)))throw Error(`Speech recognition failed`);let n=t.result;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Invalid speech transcript`);if(n&&typeof n==`object`&&`text`in n){if(typeof n.text!=`string`)throw Error(`Invalid speech transcript`);this.text=n.text,e.final||this.partial(this.text)}if(e.final){if(!this.finishing)throw Error(`Speech recognition ended unexpectedly`);this.final=!0;return}}}},N=(e,t,n)=>{let r=Error(e);return r.name=`DictationStreamError`,r.retryable=t,n&&(r.reasonCode=n),r},P=1e4,F=15e3,I=3e4,L=3e4,R=new class{socket=null;connectPromise=null;idleCloseTimer=null;pendingStarts=new Map;pendingFinishes=new Map;connectionListeners=new Set;partialListeners=new Set;activeDictations=0;directStarts=new Map;directSessions=new Map;get isConnected(){if(this.socket?.readyState===WebSocket.OPEN)return!0;for(let e of this.directSessions.values())if(e.connected)return!0;return!1}subscribeConnectionStatus(e){return this.connectionListeners.add(e),()=>{this.connectionListeners.delete(e)}}onPartial(e){return this.partialListeners.add(e),()=>{this.partialListeners.delete(e)}}async ensureConnected(){if(this.socket?.readyState!==WebSocket.OPEN){if(this.connectPromise){await this.connectPromise;return}try{await t()}catch{}this.connectPromise=new Promise((e,t)=>{let n=!1,i;try{let e=r().websocket(`/api/dictation/ws`);i=s(e)}catch(e){this.connectPromise=null,t(e instanceof Error?e:Error(String(e)));return}let a=setTimeout(()=>{if(!n){n=!0,this.connectPromise=null;try{i.close()}catch{}t(Error(`Dictation connection timed out`))}},P);i.onopen=()=>{},i.onmessage=t=>{let r;try{r=JSON.parse(String(t.data))}catch{return}if(!n&&r.type===`ready`){n=!0,clearTimeout(a),this.socket=i,this.connectPromise=null,this.notifyConnection(!0),e();return}this.handleMessage(r)},i.onerror=()=>{window.setTimeout(()=>{n||(n=!0,clearTimeout(a),this.connectPromise=null,t(Error(`Dictation connection failed`)))},250)},i.onclose=e=>{if(!n){n=!0,clearTimeout(a),this.connectPromise=null;let r=e?.reason?`: ${e.reason}`:``;t(Error(`Dictation connection failed${r}`));return}this.socket===i&&(this.socket=null,this.rejectAllPending(Error(`Dictation connection lost`)),this.notifyConnection(!1))}}),await this.connectPromise}}async startDictationStream(e,t){let n=new AbortController;this.directStarts.set(e,n);try{let r=await S(`asr`,n.signal);if(n.signal.throwIfAborted(),r){let i=new M(n,t=>{for(let n of this.partialListeners)n(e,t)},()=>{this.directSessions.delete(e),i.cancel(),this.notifyConnection(!1)});this.directSessions.set(e,i),await i.start(r,t),n.signal.throwIfAborted(),this.notifyConnection(!0);return}await this.ensureConnected(),n.signal.throwIfAborted()}catch(t){throw this.directSessions.get(e)?.cancel(),this.directSessions.delete(e),t}finally{this.directStarts.delete(e)}return this.activeDictations+=1,this.clearIdleCloseTimer(),new Promise((n,r)=>{let i=setTimeout(()=>{this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation start timed out`))},F);this.pendingStarts.set(e,{resolve:()=>{clearTimeout(i),n()},reject:e=>{clearTimeout(i),this.releaseDictation(),r(e)},timeout:i}),this.send({type:`start`,dictationId:e,format:t})||(clearTimeout(i),this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation connection lost`)))})}sendDictationStreamChunk(e,t,n){let r=this.directSessions.get(e);return r?r.send(t,n):this.send({type:`chunk`,dictationId:e,seq:t,audio:n})}finishDictationStream(e,t){let n=this.directSessions.get(e);return n?n.finish(t).finally(()=>{n.cancel(),this.directSessions.delete(e)}):new Promise((n,r)=>{let i={resolve:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),n(e)},reject:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),r(e)},timeout:null};i.timeout=setTimeout(()=>{this.pendingFinishes.delete(e),this.releaseDictation(),r(Error(`Timed out waiting for transcription`))},L),this.pendingFinishes.set(e,i),this.send({type:`finish`,dictationId:e,finalSeq:t})||(this.pendingFinishes.delete(e),i.reject(Error(`Dictation connection lost`)))})}cancelDictationStream(e){this.directStarts.get(e)?.abort(),this.directStarts.delete(e);let t=this.directSessions.get(e);if(t){t.cancel(),this.directSessions.delete(e);return}this.send({type:`cancel`,dictationId:e});let n=this.pendingStarts.get(e);n&&(this.pendingStarts.delete(e),n.reject(Error(`Dictation cancelled`)));let r=this.pendingFinishes.get(e);r&&(this.pendingFinishes.delete(e),r.reject(Error(`Dictation cancelled`))),this.releaseDictation(),this.scheduleIdleCloseIfReady()}handleMessage(e){let t=e.dictationId;if(t)switch(e.type){case`ack`:{let e=this.pendingStarts.get(t);e&&(this.pendingStarts.delete(t),e.resolve());return}case`partial`:for(let n of this.partialListeners)n(t,e.text??``);return;case`finish_accepted`:{let n=this.pendingFinishes.get(t);n&&typeof e.timeoutMs==`number`&&(n.timeout&&clearTimeout(n.timeout),n.timeout=setTimeout(()=>{this.pendingFinishes.delete(t),n.reject(Error(`Timed out waiting for transcription`))},e.timeoutMs+5e3));return}case`final`:{let n=this.pendingFinishes.get(t);n&&(this.pendingFinishes.delete(t),n.resolve({text:e.text??``})),this.scheduleIdleCloseIfReady();return}case`error`:{let n=N(e.error||`Dictation failed`,e.retryable!==!1,e.reasonCode),r=this.pendingStarts.get(t);r&&(this.pendingStarts.delete(t),r.reject(n));let i=this.pendingFinishes.get(t);i&&(this.pendingFinishes.delete(t),i.reject(n)),this.scheduleIdleCloseIfReady();return}}}send(e){if(!this.isConnected||!this.socket)return!1;try{return this.socket.send(JSON.stringify(e)),!0}catch{return!1}}notifyConnection(e){for(let t of this.connectionListeners)t(e)}rejectAllPending(e){for(let[t,n]of this.pendingStarts)this.pendingStarts.delete(t),n.reject(e);for(let[t,n]of this.pendingFinishes)this.pendingFinishes.delete(t),n.reject(e);this.activeDictations=0}releaseDictation(){this.activeDictations=Math.max(0,this.activeDictations-1),this.scheduleIdleCloseIfReady()}scheduleIdleCloseIfReady(){this.activeDictations>0||this.pendingFinishes.size>0||this.pendingStarts.size>0||(this.clearIdleCloseTimer(),this.idleCloseTimer=setTimeout(()=>{if(this.activeDictations===0&&this.pendingFinishes.size===0&&this.pendingStarts.size===0){let e=this.socket;if(this.socket=null,e){try{e.close(1e3,`idle`)}catch{}this.notifyConnection(!1)}}},I))}cancelAllForRuntimeSwitch(){for(let e of this.directStarts.values())e.abort();this.directStarts.clear();for(let e of this.directSessions.values())e.cancel();this.directSessions.clear(),this.clearIdleCloseTimer();let e=this.socket;if(this.socket=null,this.connectPromise=null,this.rejectAllPending(Error(`Runtime changed`)),e){try{e.close(1e3,`runtime switch`)}catch{}this.notifyConnection(!1)}}clearIdleCloseTimer(){this.idleCloseTimer&&=(clearTimeout(this.idleCloseTimer),null)}};typeof window<`u`&&window.addEventListener(`yuri:runtime-endpoint-changed`,()=>{R.cancelAllForRuntimeSwitch()});var z=128,B=`audio/pcm;rate=16000;bits=16`,V=()=>new Promise(e=>setTimeout(e,0)),H=()=>{let e=Math.random().toString(36).slice(2,10);return`dic_${Date.now().toString(16)}${e}`},ee=class{client;format;createDictationId;dictationId=null;sendSeq=0;segments=[];streamReady=!1;flushTimer=null;drainWaiters=[];startGeneration=0;startPromise=null;constructor(e){this.client=e.client,this.format=e.format??B,this.createDictationId=e.createDictationId??H}getDictationId(){return this.dictationId}getFinalSeq(){return this.segments.length-1}hasSegments(){return this.segments.length>0}clearAll(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.segments=[],this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}resetStreamForReplay(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}enqueueSegment(e){if(this.segments.push(e),this.client.isConnected){if(!this.dictationId){this.startPromise||this.restartStream().catch(()=>{});return}this.flush()}}flush(){let e=this.dictationId;if(!this.client.isConnected||!e||!this.streamReady)return 0;let t=0;for(;this.sendSeq<this.segments.length&&t<z;){let n=this.sendSeq,r=this.segments[n];if(!this.client.sendDictationStreamChunk(e,n,r))break;this.sendSeq=n+1,t+=1}return this.hasPendingSegments()?this.scheduleFlush():this.resolveDrainWaiters(),t}async restartStream(){this.startGeneration+=1;let e=this.startGeneration,t=this.createDictationId();this.dictationId=t,this.sendSeq=0,this.streamReady=!1;let n=(async()=>{await this.client.startDictationStream(t,this.format),this.startGeneration===e&&this.dictationId===t&&(this.streamReady=!0,this.flush())})().catch(n=>{throw this.startGeneration===e&&this.dictationId===t&&(this.dictationId=null,this.streamReady=!1),n}).finally(()=>{this.startPromise===n&&(this.startPromise=null)});this.startPromise=n,await n}async finish(e){this.dictationId||await this.restartStream(),this.startPromise&&await this.startPromise;let t=this.dictationId;if(!t||!this.streamReady)throw Error(`Failed to start dictation stream`);return this.flush(),await this.waitForFlushDrain(),{dictationId:t,text:(await this.client.finishDictationStream(t,e)).text}}cancel(){this.resetStreamForReplay()}hasPendingSegments(){return this.sendSeq<this.segments.length}scheduleFlush(){this.flushTimer||=setTimeout(()=>{this.flushTimer=null,this.flush()},0)}clearScheduledFlush(){this.resolveDrainWaiters(),this.flushTimer&&=(clearTimeout(this.flushTimer),null)}async waitForFlushDrain(){for(;this.hasPendingSegments();){if(!this.client.isConnected||!this.dictationId||!this.streamReady)throw Error(`Failed to flush dictation stream`);await new Promise(e=>{this.drainWaiters.push(e)}),await V()}}resolveDrainWaiters(){let e=this.drainWaiters;this.drainWaiters=[];for(let t of e)t()}},U=c(),W=new Set;function G(e){return W.add(e),()=>{W.delete(e)}}function K(){for(let e of W)e();if(typeof window<`u`&&window.speechSynthesis?.cancel(),typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type=`play-and-record`}catch{}}function te(){if(typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type!==`playback`&&(e.type=`playback`)}catch{}}var q=16e3,J=q/5,Y=()=>{if(typeof window>`u`)return null;let e=window;return e.AudioContext||e.webkitAudioContext||null},X=e=>{let t=Math.max(-1,Math.min(1,e));return Math.round(t<0?t*32768:t*32767)},ne=(e,t,n)=>{if(e.length===0)return new Int16Array;if(t===n){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++)t[n]=X(e[n]);return t}let r=t/n,i=Math.max(1,Math.round(e.length/r)),a=new Int16Array(i);for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=X(e[i]*(1-s)+e[o]*s)}return a},re=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Int16Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},Z=e=>{let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)},Q=()=>({stream:null,context:null,source:null,processor:null,gain:null,pending:new Int16Array,started:!1}),$=e=>{if(e)try{e.disconnect()}catch{}},ie=()=>typeof navigator>`u`||typeof window>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`?!1:Y()!==null;function ae(e){let t=(0,U.c)(16),[n,r]=(0,x.useState)(0),i=(0,x.useRef)(e.onPcmSegment),a=(0,x.useRef)(e.onError),o,s;t[0]!==e.onError||t[1]!==e.onPcmSegment?(o=()=>{i.current=e.onPcmSegment,a.current=e.onError},s=[e.onPcmSegment,e.onError],t[0]=e.onError,t[1]=e.onPcmSegment,t[2]=o,t[3]=s):(o=t[2],s=t[3]),(0,x.useEffect)(o,s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=Q(),t[4]=c):c=t[4];let u=(0,x.useRef)(c),d=(0,x.useRef)(0),f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=async()=>{if(u.current.started)return;if(typeof navigator>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`)throw Error(`Microphone capture is not supported in this environment`);let e=Y();if(!e)throw Error(`AudioContext unavailable`);let t=d.current+=1;K();let n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}});if(t!==d.current){n.getTracks().forEach(ue);return}let a=new e;try{if(a.state===`suspended`&&await a.resume().catch(le),t!==d.current){n.getTracks().forEach(ce),await a.close();return}let e=a.createMediaStreamSource(n),o=a.createScriptProcessor(4096,1,1),s=a.createGain();s.gain.value=0,u.current={stream:n,context:a,source:e,processor:o,gain:s,pending:new Int16Array,started:!0},o.onaudioprocess=e=>{let t=u.current;if(!t.started)return;let n=e.inputBuffer.getChannelData(0),o=0;for(let e=0;e<n.length;e++)o+=n[e]*n[e];let s=Math.sqrt(o/Math.max(1,n.length));r(Math.min(1,Math.max(0,s*2)));let c=ne(n,a.sampleRate,q);for(t.pending=re(t.pending,c);t.pending.length>=J;){let e=t.pending.slice(0,J);t.pending=t.pending.slice(J),i.current(Z(e))}},e.connect(o),o.connect(s),s.connect(a.destination)}catch(e){let t=e;n.getTracks().forEach(se);try{await a.close()}catch{}throw u.current=Q(),t instanceof Error?t:Error(String(t))}},t[5]=f):f=t[5];let p=l(f),m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=async()=>{d.current+=1;let e=u.current;if(e.started=!1,r(0),e.processor)try{e.processor.onaudioprocess=null}catch{}$(e.processor),$(e.source),$(e.gain),e.stream&&e.stream.getTracks().forEach(oe);let t=e.pending;if(e.pending=new Int16Array,t.length>0&&i.current(Z(t)),e.context)try{await e.context.close()}catch{}u.current===e&&(u.current=Q())},t[6]=m):m=t[6];let h=l(m),g,_;t[7]===h?(g=t[8],_=t[9]):(g=()=>()=>{h().catch(e=>{a.current?.(e instanceof Error?e:Error(String(e)))})},_=[h],t[7]=h,t[8]=g,t[9]=_),(0,x.useEffect)(g,_);let v;t[10]===p?v=t[11]:(v=async()=>{try{await p()}catch(e){let t=e,n=t instanceof Error?t:Error(String(t));throw a.current?.(n),n}},t[10]=p,t[11]=v);let y;return t[12]!==h||t[13]!==v||t[14]!==n?(y={start:v,stop:h,volume:n},t[12]=h,t[13]=v,t[14]=n,t[15]=y):y=t[15],y}function oe(e){try{e.stop()}catch{}}function se(e){try{e.stop()}catch{}}function ce(e){return e.stop()}function le(){}function ue(e){return e.stop()}var de=1e3,fe=e=>e instanceof Error?e:Error(String(e));function pe(e={}){let{t}=u(),{onTranscript:r,onError:i,canStart:a}=e,[o,s]=(0,x.useState)(`idle`),[c,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(``),[m,h]=(0,x.useState)(0),[g,_]=(0,x.useState)(null),[v,y]=(0,x.useState)(null),b=(0,x.useRef)(o);(0,x.useEffect)(()=>{b.current=o},[o]);let S=(0,x.useRef)(``),C=(0,x.useRef)(null),w=(0,x.useRef)({starting:!1,confirming:!1,cancelling:!1}),T=(0,x.useRef)(0),E=(0,x.useRef)(r),D=(0,x.useRef)(i);(0,x.useEffect)(()=>{E.current=r,D.current=i},[r,i]);let O=(0,x.useRef)(null);O.current||=new ee({client:R});let k=l(()=>{C.current&&=(clearInterval(C.current),null)}),A=l(()=>{C.current||=setInterval(()=>{h(e=>e+1)},de)}),j=l(e=>{let n=fe(e),r=n.name===`NotFoundError`||n.name===`DevicesNotFoundError`?Error(t(`chat.dictation.error.microphoneNotFound`),{cause:n}):n;_(r.message);let i=n.reasonCode;y(typeof i==`string`?i:null),D.current?.(r)}),M=l(()=>{_(null),y(null)}),N=l(()=>{O.current?.clearAll(),S.current=``,p(``)}),P=l(t=>e.onPartialTranscript?.(t));(0,x.useEffect)(()=>R.onPartial((e,t)=>{let n=O.current?.getDictationId();!n||e!==n||(S.current=t,p(t),P(t))}),[P]),(0,x.useEffect)(()=>R.subscribeConnectionStatus(e=>{if(!e){b.current===`recording`&&O.current?.resetStreamForReplay();return}if(b.current!==`recording`||O.current?.getDictationId())return;let t=T.current;O.current?.restartStream().catch(e=>{T.current===t&&j(e)})}),[j]);let F=ae({onPcmSegment:e=>{b.current===`recording`&&O.current?.enqueueSegment(e)},onError:e=>{D.current?.(e)}}),I=(0,x.useRef)(F.stop);(0,x.useEffect)(()=>{I.current=F.stop},[F.stop]);let L=l(e=>{h(0),s(`idle`),b.current=`idle`;let t=e.trim();return N(),t?(E.current?.(t),t):null}),z=l(e=>{O.current?.hasSegments()?(s(`failed`),b.current=`failed`):(s(`idle`),b.current=`idle`),j(e)}),B=l(async()=>{let e=w.current;if(e.starting||e.confirming||e.cancelling||b.current!==`idle`||a&&!a())return;e.starting=!0,d(!0);let t=++T.current;M(),p(``),h(0),s(`recording`),b.current=`recording`,N();try{if(await F.start(),T.current!==t||b.current!==`recording`)return;d(!1),A(),await O.current?.restartStream().catch(e=>{T.current===t&&j(e)})}catch(e){if(T.current!==t)return;await F.stop().catch(()=>void 0),k(),s(`idle`),b.current=`idle`,j(e)}finally{T.current===t&&d(!1),e.starting=!1}}),V=l(async()=>{let e=w.current;if(!e.cancelling&&(b.current===`recording`||b.current===`uploading`)){e.cancelling=!0,d(!1),T.current+=1,k(),h(0),M(),s(`idle`),b.current=`idle`;try{O.current?.cancel()}catch{}N();try{await F.stop()}catch{}finally{e.cancelling=!1}}}),H=l(async()=>{let e=w.current;if(e.confirming||b.current!==`recording`)return null;e.confirming=!0,d(!1);let t=++T.current;M(),k();try{if(await F.stop(),T.current!==t)return null;s(`uploading`),b.current=`uploading`;let e=O.current?.getFinalSeq()??-1;if(e<0)return O.current?.cancel(),L(``);let n=await O.current.finish(e);return T.current===t?L(n.text):null}catch(e){return T.current===t&&z(e),null}finally{e.confirming=!1}}),U=l(async()=>{if(b.current!==`failed`||!O.current?.hasSegments())return null;M();let e=++T.current;s(`uploading`),b.current=`uploading`;try{O.current.resetStreamForReplay();let t=O.current.getFinalSeq(),n=await O.current.finish(t);return T.current===e?L(n.text):null}catch(t){return T.current===e&&z(t),null}}),W=l(()=>{if(b.current!==`failed`)return null;let e=S.current.trim();h(0),s(`idle`),b.current=`idle`,M();try{O.current?.cancel()}catch{}return N(),e?(E.current?.(e),e):null}),G=l(()=>{h(0),s(`idle`),b.current=`idle`,M(),N()});return(0,x.useEffect)(()=>n(()=>{b.current===`failed`?(T.current+=1,G()):V()}),[V,G]),(0,x.useEffect)(()=>{if(o!==`recording`||v!==`model_download_in_progress`)return;let e=setInterval(()=>{b.current!==`recording`||O.current?.getDictationId()||O.current?.restartStream().then(()=>{M()}).catch(e=>{j(e)})},3e3);return()=>clearInterval(e)},[o,v,M,j]),(0,x.useEffect)(()=>()=>{T.current+=1,k(),I.current().catch(()=>void 0),O.current?.cancel()},[k]),{status:o,isRecording:o===`recording`,isStarting:c,isProcessing:o===`uploading`,partialTranscript:f,volume:F.volume,duration:m,error:g,errorReason:v,startDictation:B,confirmDictation:H,cancelDictation:V,retryFailedDictation:U,acceptPartialTranscript:W,discardFailedDictation:G}}var me=`app-region-no-drag transition-[opacity,transform] duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 z-50 max-h-[var(--available-height)] min-w-[8rem] origin-[var(--transform-origin)] overflow-visible rounded-xl p-1 shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,he=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active data-[variant=destructive]:text-destructive data-[variant=destructive]:hover:bg-destructive/10 dark:data-[variant=destructive]:hover:bg-destructive/20 data-[variant=destructive]:hover:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,ge=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,_e=`bg-border -mx-1 my-0.5 h-px`;export{m as S,f as _,pe as a,_ as b,te as c,j as d,A as f,d as g,C as h,ge as i,G as l,S as m,me as n,ie as o,O as p,_e as r,K as s,he as t,k as u,p as v,y as x,b as y};
|
package/dist/assets/{fileMentionTouchSelection-BHQaa6JY.js → fileMentionTouchSelection-CTh0Mc2g.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,nt as n,rt as r}from"./vendor-base-ui-CdzJ6My_.js";import{at as i}from"./persistence-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,nt as n,rt as r}from"./vendor-base-ui-CdzJ6My_.js";import{at as i}from"./persistence-CBL0OOdj.js";import{n as a}from"./vendor-react-BP2cRVqX.js";import{r as o}from"./button-Be1cqulG.js";import{ht as s,mt as c,st as l}from"./useMobileNavigationStore-hhiMBg5n.js";import{t as u}from"./vendor-fuzzysort-ukaRp9PC.js";import{r as d,t as f}from"./Icon-Bn4Eec3Y.js";var p=e=>{switch(e.name){case`new`:return`add`;case`init`:return`file`;case`undo`:return`arrow-go-back`;case`redo`:return`arrow-go-forward`;case`timeline`:return`time`;case`compact`:return`scissors`;case`reload`:return`refresh`;case`goal`:return`target`;case`review`:return`search-eye`;case`test`:case`build`:case`run`:return`terminal-box`;default:return e.isBuiltIn?`flashlight`:`command`}},m=()=>`book-open`,h=e=>{if(e.isDirectory)return`folder-3-fill`;switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`json`:return`code`;case`md`:case`mdx`:return`file`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return`file-image`;default:return`file-pdf`}},g=()=>`ai-agent`,_=()=>`chat-thread`,v=32,y=(e,t)=>{let n=d[e];return typeof n!=`string`||n.length===0?null:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${t}" stroke-width="${f}" stroke-linecap="round" stroke-linejoin="round">${n}</svg>`},b=(e,t)=>{let n=y(e,t);return!n||typeof document>`u`?Promise.resolve(null):new Promise(e=>{let t=new Image;t.decoding=`async`,t.onload=()=>{try{let n=document.createElement(`canvas`);n.width=v,n.height=v;let r=n.getContext(`2d`);if(!r){e(null);return}r.clearRect(0,0,v,v),r.drawImage(t,0,0,v,v);let i=n.toDataURL(`image/png`),a=i.indexOf(`,`);e(a>=0?i.slice(a+1):null)}catch{e(null)}},t.onerror=()=>e(null),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`})},x=e(u(),1),S=(e,t)=>e.map(e=>{let n=e.isSkill?t.skill:e.isYuri?`Yuri`:e.isBuiltIn?t.system:e.scope||e.agent||t.command;return{id:e.id,title:`/${e.name}`,subtitle:e.description,badge:n,iconName:p(e)}}),C=({skills:e=[],agents:t,sessions:n,recentFiles:r,pathHits:i,untitledSession:a,sessionBadge:o,skillBadge:l,searchQuery:u=``})=>{let d=[];for(let t of e)d.push({id:`skill:${t.name}-${t.scope}`,title:`@${t.name}`,subtitle:t.description,badge:l??t.scope,iconName:m()});for(let e of t)d.push({id:`agent:${e.name}`,title:`@${e.name}`,subtitle:e.description,iconName:g(),agentName:e.name});for(let e of n)d.push({id:`session:${e.id}`,title:e.title||a,badge:o,iconName:_()});let f=u.trim(),p=new Map(d.map((e,t)=>[e.id,t])),v=(e,t)=>x.default.go(f,e,{keys:[`title`,e=>e.id.startsWith(`skill:`)?e.subtitle??``:``,e=>e.id.startsWith(`session:`)?e.id.slice(8):``],threshold:.5,limit:t,scoreFn:e=>{let t=e[0];return Math.max(c(f,e.obj.title,t?.score??0),e[1]?.score??0,e.obj.id.startsWith(`session:`)?s(f,e.obj.id.slice(8)):0)}}),y=f?[...v(d.filter(e=>!e.id.startsWith(`session:`)),10),...v(d.filter(e=>e.id.startsWith(`session:`)),1/0)].sort((e,t)=>t.score-e.score||(p.get(e.obj.id)??0)-(p.get(t.obj.id)??0)).map(e=>e.obj):d.slice();d.length=0;for(let e of r)d.push({id:`recent:${e.path}`,title:e.relativePath||e.name,iconName:h(e)});for(let e of i)d.push({id:`file:${e.path}`,title:e.relativePath||e.name,iconName:h(e)});if(!f)return[...y.filter(e=>!e.id.startsWith(`session:`)),...d,...y.filter(e=>e.id.startsWith(`session:`))];let b=0;return[...y,...d].filter(e=>e.id.startsWith(`session:`)||b++<10)},w=(e,t)=>{if(!e.includes(`/`)||t.size===0)return[];let n=RegExp(`(^|\\s)/(${i})?([A-Za-z0-9][A-Za-z0-9_-]*)(?=$|\\s)`,`g`),r=[],a;for(;(a=n.exec(e))!==null;){let e=a[3]??``;if(!t.has(e.toLowerCase()))continue;let n=a[2]??``,i=a.index+(a[1]?.length??0);r.push({start:i,end:i+1+n.length+e.length,name:e,hasSlot:n.length>0})}return r},T=(e,t,n=e.length)=>{let r=w(e,t).filter(e=>!e.hasSlot);if(r.length===0)return null;let a=e,o=n;for(let e=r.length-1;e>=0;--e){let t=r[e].start+1;a=`${a.slice(0,t)}${i}${a.slice(t)}`,o>t&&(o+=i.length)}return a===e?null:{text:a,caret:o}},E=e=>e.startsWith(i)?e.slice(i.length):e,D=e=>{if(e.inputMode===`shell`)return null;let t=e.text,n=Math.max(0,Math.min(e.cursor,t.length));if(t.startsWith(`/`)){let e=t.indexOf(` `),r=t.indexOf(`
|
|
2
2
|
`),i=Math.min(e===-1?t.length:e,r===-1?t.length:r);if(n<=i&&e===-1)return{kind:`slash-command`,query:E(t.substring(1,i)),tokenStart:0,tokenEnd:i}}let r=t.substring(0,n),i=l({value:t,cursorPosition:n,inputSource:e.mentionInputSource??`manual`,insertedText:e.insertedText});return i===null?null:{kind:`mention`,query:i,tokenStart:r.lastIndexOf(`@`),tokenEnd:n}},O=e=>e===`mention`?`@`:`/`,k=(e,t,n)=>{if(n&&n.tokenStart>=0&&n.tokenEnd>=n.tokenStart&&n.tokenEnd<=e.length&&e.startsWith(O(n.kind),n.tokenStart))return{start:n.tokenStart,end:n.tokenEnd};let r=D({text:e,cursor:t});return r?{start:r.tokenStart,end:r.tokenEnd}:null},A=e(t(),1),j=a(),M=e(n(),1),N=`absolute z-[100] min-w-0 w-full bottom-full mb-2 left-0 flex flex-col rounded-xl`,P=`pointer-events-auto absolute z-[100] min-w-0 flex flex-col rounded-xl`;function F(e,t){return o(e?P:N,`yuri-mobile-overlay-surface yuri-mobile-overlay-surface--translucent yuri-composer-autocomplete-surface`,t)}function I(e,t){return e?`yuri-composer-autocomplete-row`:o(`mx-1.5 hover:bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,t&&`bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`)}var L=.4,R=e=>{let t=e.gap??8,n=Math.min(e.composerTop-t,e.visibleBottom-t);return{left:e.composerLeft,width:e.composerWidth,bottom:Math.max(0,e.fixedContainingBottom-n),maxHeight:z({popupBottom:n,boundaryTop:e.boundaryTop,viewportHeight:e.viewportHeight,gap:t})}},z=e=>{let t=e.gap??8,n=Math.max(0,e.popupBottom-e.boundaryTop-t),r=e.viewportHeight*L,i=Math.floor(Math.min(n,r));return n>=120?Math.min(n,Math.max(120,i)):i},B=(e,t=0)=>{let n=e.closest(`main`);if(!n)return null;let r=(e.closest(`.mobile-chat-screen__content`)?.parentElement??n.parentElement?.closest(`main`)??n).querySelector(`:scope > .yuri-mobile-detail-navigation`)?.getBoundingClientRect().bottom,i=n.getBoundingClientRect().top;return Math.max(r===void 0?i:Math.max(r,i),t)},V=(e,t)=>{let n=(0,j.c)(5),[r,i]=A.useState(void 0),a;n[0]!==t||n[1]!==e?(a=()=>{if(!t){i(void 0);return}let n=0,r=0,a=()=>{let t=e.current?.parentElement;if(!t)return;let n=t.getBoundingClientRect(),r=window.visualViewport,a=r?.offsetTop??0,o=r?.height??window.innerHeight,s=window.innerHeight,c=a+o,l=B(t,a)??a,u=R({composerTop:n.top,composerLeft:n.left,composerWidth:n.width,fixedContainingBottom:s,visibleBottom:c,boundaryTop:l,viewportHeight:o});i(e=>e&&e.left===u.left&&e.width===u.width&&e.bottom===u.bottom&&e.maxHeight===u.maxHeight?e:u)},o=()=>{a(),n&&window.cancelAnimationFrame(n),r&&window.clearTimeout(r),n=window.requestAnimationFrame(()=>{a(),r=window.setTimeout(a,220)})};return a(),window.addEventListener(`resize`,a),window.addEventListener(`yuri:keyboard-settled`,o),window.addEventListener(`yuri:keyboard-anim`,o),window.visualViewport?.addEventListener(`resize`,a),window.visualViewport?.addEventListener(`scroll`,a),()=>{n&&window.cancelAnimationFrame(n),r&&window.clearTimeout(r),window.removeEventListener(`resize`,a),window.removeEventListener(`yuri:keyboard-settled`,o),window.removeEventListener(`yuri:keyboard-anim`,o),window.visualViewport?.removeEventListener(`resize`,a),window.visualViewport?.removeEventListener(`scroll`,a)}},n[0]=t,n[1]=e,n[2]=a):a=n[2];let o;return n[3]===t?o=n[4]:(o=[t],n[3]=t,n[4]=o),A.useLayoutEffect(a,o),t?r:void 0},H=r(),U=A.forwardRef((e,t)=>{let n=(0,j.c)(24),{isMobile:r,className:i,style:a,children:o}=e,s=A.useRef(null),c=V(s,r),l=typeof document<`u`?document.body:null;if(!r){let e;n[0]===i?e=n[1]:(e=F(!1,i),n[0]=i,n[1]=e);let r;return n[2]!==o||n[3]!==t||n[4]!==a||n[5]!==e?(r=(0,H.jsx)(`div`,{ref:t,className:e,style:a,children:o}),n[2]=o,n[3]=t,n[4]=a,n[5]=e,n[6]=r):r=n[6],r}let u;n[7]===i?u=n[8]:(u=F(!0,i),n[7]=i,n[8]=u);let d;n[9]===c?d=n[10]:(d=c?{left:c.left,width:c.width,bottom:c.bottom,maxHeight:c.maxHeight,overflow:`hidden`}:{visibility:`hidden`},n[9]=c,n[10]=d);let f;n[11]!==a||n[12]!==d?(f={...a,...d},n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;n[14]!==o||n[15]!==t||n[16]!==u||n[17]!==f?(p=(0,H.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[100]`,children:(0,H.jsx)(`div`,{ref:t,className:u,style:f,children:o})}),n[14]=o,n[15]=t,n[16]=u,n[17]=f,n[18]=p):p=n[18];let m=p,h;n[19]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,H.jsx)(`span`,{ref:s,className:`hidden`,"aria-hidden":!0}),n[19]=h):h=n[19];let g;n[20]===m?g=n[21]:(g=l?(0,M.createPortal)(m,l):m,n[20]=m,n[21]=g);let _;return n[22]===g?_=n[23]:(_=(0,H.jsxs)(H.Fragment,{children:[h,g]}),n[22]=g,n[23]=_),_});U.displayName=`ComposerAutocompleteLayer`;var W=()=>{let e=null,t=!1,n=!1;return{pointerDown:(n,r)=>{e={x:n,y:r},t=!1},pointerMove:(n,r)=>{e&&Math.hypot(n-e.x,r-e.y)>6&&(t=!0)},pointerCancel:()=>{e=null,t=!1},pointerUp:r=>{if(!e)return!1;let i=!t;return e=null,t=!1,i?(n=!0,r(),!0):(n=!0,!1)},click:e=>n?(n=!1,!1):(e(),!0)}};export{D as a,C as c,p as d,k as i,S as l,U as n,T as o,I as r,E as s,W as t,b as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./runtime-switch-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./runtime-switch-DEZ1K7qW.js";import{it as n}from"./vendor-base-ui-CdzJ6My_.js";import{n as r}from"./vendor-react-BP2cRVqX.js";import{s as i}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a,o}from"./queryRuntime-Dkpnq3Z1.js";var s=r(),c=e(n(),1),l=c.createContext(null),u=()=>{let e=c.useContext(l);if(!e)throw Error(`Runtime APIs are not available. Did you forget to wrap the app in <RuntimeAPIProvider>?`);return e},d=e=>{let t=(0,s.c)(3),n=u(),r;return t[0]!==n||t[1]!==e?(r=e(n),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},f=()=>d(p);function p(e){return e.runtime.isVSCode}var m=e=>e,h=(e,n=t())=>o.files.content(e.scopeDirectory,e.path,m(e.options),n),g=(e,n,r=t())=>({queryKey:o.files.directory(n.scopeDirectory,n.directory,n.respectGitignore,r),queryFn:async()=>{if(!n.directory)throw Error(`A directory is required to list files`);return n.respectGitignore===void 0?e.listDirectory(n.directory):e.listDirectory(n.directory,{respectGitignore:n.respectGitignore})}}),_=(e,n,r=t())=>({queryKey:o.files.search(n.directory,n.query,n.maxResults,n.includeHidden,n.respectGitignore,r),queryFn:async()=>{if(!n.directory)throw Error(`A directory is required to search files`);let t={directory:n.directory,query:n.query.trim(),maxResults:n.maxResults,...n.includeHidden===void 0?{}:{includeHidden:n.includeHidden},...n.respectGitignore===void 0?{}:{respectGitignore:n.respectGitignore}};return e.search(t)}}),v=(e,n,r=t())=>({queryKey:h(n,r),queryFn:async()=>{if(!n.path)throw Error(`A file path is required to read file content`);if(!e.readFile)throw Error(`File content reads are unavailable in this runtime`);return(await(n.options===void 0?e.readFile(n.path):e.readFile(n.path,n.options))).content}}),y=(e,t,n,r)=>{e.setQueryData(h(t,n),r)},b=(e,n,r=t())=>({queryKey:n.options?.fingerprint?[...o.files.stat(n.scopeDirectory,n.path,m(n.options),r),`sha256`]:o.files.stat(n.scopeDirectory,n.path,m(n.options),r),queryFn:async()=>{if(!n.path)throw Error(`A file path is required to read file status`);if(!e.statFile)throw Error(`File status reads are unavailable in this runtime`);return n.options===void 0?e.statFile(n.path):e.statFile(n.path,n.options)}}),x=(e,n)=>{let r=(0,s.c)(9),a;r[0]===n?a=r[1]:(a=n===void 0?{}:n,r[0]=n,r[1]=a);let o=a,{files:c}=u(),l,d;if(r[2]!==c||r[3]!==e){let n=t();d=i,l=g(c,e,n),r[2]=c,r[3]=e,r[4]=l,r[5]=d}else l=r[4],d=r[5];let f;return r[6]!==o||r[7]!==l?(f={...l,...o},r[6]=o,r[7]=l,r[8]=f):f=r[8],d(f)},S=(e,n)=>{let r=(0,s.c)(9),a;r[0]===n?a=r[1]:(a=n===void 0?{}:n,r[0]=n,r[1]=a);let o=a,{files:c}=u(),l,d;if(r[2]!==c||r[3]!==e){let n=t();d=i,l=_(c,e,n),r[2]=c,r[3]=e,r[4]=l,r[5]=d}else l=r[4],d=r[5];let f;return r[6]!==o||r[7]!==l?(f={...l,...o},r[6]=o,r[7]=l,r[8]=f):f=r[8],d(f)},C=(e,n)=>{let r=(0,s.c)(9),a;r[0]===n?a=r[1]:(a=n===void 0?{}:n,r[0]=n,r[1]=a);let o=a,{files:c}=u(),l,d;if(r[2]!==c||r[3]!==e){let n=t();d=i,l=v(c,e,n),r[2]=c,r[3]=e,r[4]=l,r[5]=d}else l=r[4],d=r[5];let f;return r[6]!==o||r[7]!==l?(f={...l,...o},r[6]=o,r[7]=l,r[8]=f):f=r[8],d(f)},w=2e3,T=(e,n)=>{let r=(0,s.c)(7),o=n===void 0?{}:n,{files:l}=u(),d=t(),f=!!(o.enabled&&e.path&&l.statFile),p=i({...b(l,e,d),enabled:f,refetchInterval:o.intervalMs??w,refetchIntervalInBackground:!1,staleTime:0}),m=JSON.stringify(h(e,d)),g=c.useRef(null),_=c.useRef(null),v;return r[0]!==f||r[1]!==e||r[2]!==o||r[3]!==p||r[4]!==d||r[5]!==m?(v=()=>{let t=p.data;if(!f||!t)return;g.current!==m&&(g.current=m,_.current=null);let n=`${t.size}:${t.mtimeMs??``}:${t.isBinary??``}`,r=_.current;_.current=n,!(r===null||r===n||t.isBinary)&&(o.client??a).invalidateQueries({queryKey:h(e,d)})},r[0]=f,r[1]=e,r[2]=o,r[3]=p,r[4]=d,r[5]=m,r[6]=v):v=r[6],c.useEffect(v),p};export{C as a,T as c,l as d,y as i,f as l,v as n,x as o,b as r,S as s,h as t,u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./runtime-switch-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./runtime-switch-DEZ1K7qW.js";import{n}from"./runtime-fetch-D4ja813o.js";import{b as r,w as i,x as a,y as o}from"./desktop-JwYqThiw.js";import{n as s}from"./useUIStore-96W41KFb.js";import{i as c,o as l,t as u}from"./path-utils-jGozTg9d.js";import{c as d,i as f,s as p}from"./toolHelpers-iEHVHQ9p.js";import{a as m,i as h,n as g,o as _,r as ee,t as v}from"./fileReferenceParser-1HHDBUum.js";var y=`data-yuri-block-path-token`,b=`[${y}]`,x=`data-yuri-file-link`,S=`[${x}="true"]`,C=[x,`data-yuri-file-ref`,`data-yuri-file-path`,`data-yuri-file-binary`,`title`,`role`,`tabindex`],w=`data-yuri-block-paths-scanned`,T=`data-yuri-paragraph-paths-scanned`,E=`pre, code, a, script, style, button, [${x}], ${b}`,D=2e5,O=e=>{let t=_(e);return t?h(t.path):!1},te=e=>{let t=e.trim();return!t||t.startsWith(`#`)||t.startsWith(`?`)||t.startsWith(`//`)?!1:/^[A-Za-z]:[\\/]/.test(t)||/^file:/i.test(t)||O(t)&&/:\d+(?:-\d+|:\d+)?$/.test(t)?!0:!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(t)},k=(e,t)=>{let n=0;for(let r of e){let e=n+r.data.length;if(t<=e)return{node:r,offset:Math.max(0,t-n)};n=e}let r=e.at(-1);return r?{node:r,offset:r.data.length}:null},A=e=>{let t=e.querySelectorAll(`pre code`);if(t.length===0)return;let n=e.ownerDocument;if(n)for(let e of Array.from(t)){if(e.getAttribute(w)===`true`)continue;if((e.textContent??``).length>D){e.setAttribute(w,`true`);continue}let t=n.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=[],i=t.nextNode();for(;i;)r.push(i),i=t.nextNode();let a=e.textContent??``;if(!a.includes(`.`)){e.setAttribute(w,`true`);continue}v.lastIndex=0;let o=[],s=v.exec(a);for(;s;){let e=s[0];e&&O(e)&&o.push({start:s.index,end:s.index+e.length,raw:e}),s=v.exec(a)}for(let{start:e,end:t,raw:i}of o.reverse()){let a=k(r,e),o=k(r,t);if(!a||!o)continue;let s=n.createRange();s.setStart(a.node,a.offset),s.setEnd(o.node,o.offset);let c=n.createElement(`span`);c.setAttribute(y,`true`),c.textContent=i,s.deleteContents(),s.insertNode(c)}e.setAttribute(w,`true`)}},j=e=>{let t=e.ownerDocument;if(!t)return;let n=e.querySelectorAll(`p, li, blockquote, h1, h2, h3, h4, h5, h6, td, th`);if(n.length!==0)for(let e of Array.from(n)){if(e.getAttribute(T)===`true`)continue;if(e.closest(E)){e.setAttribute(T,`true`);continue}let n=t.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>{let t=e.parentElement;return!t||t.closest(E)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),r=[],i=n.nextNode();for(;i;)r.push(i),i=n.nextNode();if(r.length===0){e.setAttribute(T,`true`);continue}let a=r.map(e=>e.data).join(``);if(!a.includes(`/`)||!a.includes(`.`)){e.setAttribute(T,`true`);continue}g.lastIndex=0;let o=[],s=g.exec(a);for(;s;){let e=s[0];if(!e){s=g.exec(a);continue}let t=s.index>=2?a.slice(s.index-2,s.index):``;if((s.index>=1?a.charAt(s.index-1):``)===`:`||t===`:/`){s=g.exec(a);continue}O(e)&&o.push({start:s.index,end:s.index+e.length,raw:e}),s=g.exec(a)}for(let{start:e,end:n,raw:i}of o.reverse()){let a=k(r,e),o=k(r,n);if(!a||!o)continue;let s=t.createRange();s.setStart(a.node,a.offset),s.setEnd(o.node,o.offset);let c=t.createElement(`span`);c.setAttribute(y,`true`),c.textContent=i,s.deleteContents(),s.insertNode(c)}e.setAttribute(T,`true`)}},M=e=>{A(e),j(e)},N=(e,t)=>{if(e.getAttribute(`data-yuri-file-link`)!==`true`)return;let n=(e.getAttribute(`data-yuri-file-ref`)||e.textContent||``).trim(),r=(t.textContent||``).trim();if(!(!n||n!==r))for(let n of C){let r=e.getAttribute(n);r===null?t.removeAttribute(n):t.setAttribute(n,r)}},P=e({FILE_REFERENCE_OPEN_TITLE:()=>F,extractPathCandidateFromElement:()=>q,getFileReferenceInfo:()=>Y,getFileReferenceLinkLimit:()=>H,getResolvedReference:()=>J,openFileReference:()=>Q,openFileReferenceFromElement:()=>$,peekFileReferenceInfo:()=>K,probeFileReference:()=>X,resetFileReferenceStatCacheForTests:()=>ce,shouldOfferFileReference:()=>Z}),F=`Open file`,ne=4,re=1e3,ie=200,ae=80,oe=40,I=new Map,L=new Map,R=(e,n)=>JSON.stringify([t(),n,e]),z=0,B=[],V=()=>i()?ie:re,H=()=>i()?oe:ae,U=(e,t)=>{L.set(e,t)},W=()=>{let e=I.keys().next().value;typeof e==`string`&&(I.delete(e),L.delete(e))},G=(e,t)=>{let n=V();for(;I.size>=n;)W();I.set(e,t)},K=(e,t=``)=>{let n=m(e);if(n)return L.get(R(n,t))},q=e=>{if(e.tagName.toLowerCase()===`a`){let t=e.getAttribute(`href`)?.trim();if(t&&O(t))return t}return(e.textContent||``).trim()},J=(e,t,n=`path`)=>{let r=_(e);if(r&&n===`href`&&!/^file:/i.test(e.trim()))try{r.path=decodeURIComponent(r.path)}catch{}if(!r||!h(r.path))return null;let i=ee(r.path)?m(r.path):l(t,r.path);return i?{...r,resolvedPath:i}:null},Y=(e,t=``)=>{let r=m(e);if(!r)return Promise.resolve({exists:!1,isBinary:!1});let i=R(r,t),a=I.get(i);if(a)return I.delete(i),I.set(i,a),a;let o=new Promise((e,a)=>{let s=()=>{z+=1,n(`/api/fs/stat?path=${encodeURIComponent(r)}&optional=true`,{method:`GET`,cache:`no-store`,...t?{query:{directory:t}}:{}}).then(async t=>{if(!t.ok)throw Error(`File reference probe failed (${t.status})`);let n=await t.json();if(!n||typeof n.exists!=`boolean`&&n.isFile!==!0)throw Error(`Invalid file reference probe response`);let r={exists:n.exists!==!1,isBinary:n.isBinary===!0};U(i,r),e(r)}).catch(e=>{I.get(i)===o&&(I.delete(i),L.delete(i)),a(e)}).finally(()=>{z=Math.max(0,z-1),B.shift()?.()})};if(z<ne){s();return}B.push(s)});return G(i,o),o},X=(e,t)=>{if(!(a()&&r()&&!c(e,t)))return Y(e,t);let n=m(e);if(!n)return Promise.resolve({exists:!1,isBinary:!1});let i=R(n,t),s=I.get(i);if(s)return I.delete(i),I.set(i,s),s;let l=o(e).then(e=>{let t={exists:!0,isBinary:e===!0};return U(i,t),t});return G(i,l),l},Z=(e,t,n)=>!(!t.exists||n&&t.isBinary&&!d(e)&&!p(e)),se=(e,t)=>e||u(e,t),Q=async(e,t,n)=>{let r=J(e,n.effectiveDirectory,n.referenceKind);if(!r)return;if(d(r.resolvedPath)&&n.onShowPopup){let e=r.resolvedPath.split(`/`).filter(Boolean).pop()??r.resolvedPath;n.onShowPopup({open:!0,title:e,content:``,metadata:{tool:`image-preview`,filename:e,mime:f(r.resolvedPath)},image:{url:r.resolvedPath,filename:e,mimeType:f(r.resolvedPath)}});return}let i=se(n.effectiveDirectory,r.resolvedPath),a=p(r.resolvedPath);if(n.preferRuntimeEditor&&n.editor&&!a){n.editor.openFile(r.resolvedPath,Number.isFinite(r.line??NaN)?Math.max(1,Math.trunc(r.line)):void 0,Number.isFinite(r.column??NaN)?Math.max(1,Math.trunc(r.column)):void 0);return}let o=s.getState();if(a){o.openContextFile(i,r.resolvedPath,{viewerMode:`preview`});return}if(Number.isFinite(r.line??NaN)){o.openContextFileAtLine(i,r.resolvedPath,Math.max(1,Math.trunc(r.line)),Number.isFinite(r.column??NaN)?Math.max(1,Math.trunc(r.column)):1);return}o.openContextFile(i,r.resolvedPath)},$=async(e,t)=>{let n=e.matches(`a[href]`)?e:e.querySelector(`a[href]`);await Q(n?.getAttribute(`href`)||e.getAttribute(`data-yuri-file-ref`)||q(e),e.getAttribute(`data-yuri-file-binary`)===`true`,{...t,referenceKind:n?`href`:`path`})},ce=()=>{I.clear(),L.clear(),z=0,B.length=0};export{J as a,X as c,x as d,S as f,M as g,te as h,H as i,Z as l,O as m,q as n,$ as o,N as p,P as r,K as s,F as t,b as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{n as r}from"./runtime-fetch-D4ja813o.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{$ as a,A as o,At as s,D as c,F as l,G as u,H as d,I as f,J as p,K as m,M as ee,P as te,S as ne,T as re,U as ie,X as ae,Y as oe,_ as se,a as ce,b as le,c as ue,d as de,et as fe,f as pe,ft as me,gt as he,h as ge,ht as _e,k as ve,m as ye,nt as be,ot as xe,pt as Se,q as Ce,r as we,s as Te,st as Ee,tt as De,ut as Oe,v as ke,vt as Ae,x as je,y as Me}from"./gitApiHttp-BBRKl9WX.js";import{Da as h,d as g,l as Ne,ya as _}from"./useMobileNavigationStore-hhiMBg5n.js";var Pe=e({COMMIT_DIFF_FILE_LIMIT:()=>30,COMMIT_DIFF_TOTAL_CHAR_LIMIT:()=>A,SESSION_GENERATE_TIMEOUT_MS:()=>j,applyGitStash:()=>G,checkIsGitRepository:()=>b,checkoutCommit:()=>$e,cherryPick:()=>et,collectSelectedFileDiffs:()=>M,countGitStashFiles:()=>U,createBranch:()=>J,createGitIdentity:()=>Z,createGitWorktree:()=>z,deleteGitIdentity:()=>Je,deleteGitWorktree:()=>B,deleteRemoteBranch:()=>k,discoverGitCredentials:()=>Ye,discoverGitRepositories:()=>x,dropGitStash:()=>q,generateCommitMessage:()=>P,getCommitFileDiff:()=>Y,getConflictDetails:()=>$,getGitBranches:()=>O,getGitIdentities:()=>X,getGitStatus:()=>S,getGitWorktreeBootstrapStatus:()=>L,getGlobalGitIdentity:()=>Xe,git:()=>V,listGitStashes:()=>H,listGitWorktrees:()=>F,merge:()=>Qe,popGitStash:()=>K,previewGitWorktree:()=>R,rebase:()=>Ze,resetToCommit:()=>nt,resolveGitPrimaryRoot:()=>C,resolveGitTopLevel:()=>w,revertCommit:()=>tt,stageGitFile:()=>T,stageGitFiles:()=>E,stashGitChanges:()=>W,unstageGitFile:()=>Fe,unstageGitFiles:()=>D,updateGitIdentity:()=>Q,validateGitWorktree:()=>I}),v=()=>i()?.git??null,y=e=>{let t=e.trim(),n=(t.match(/```(?:json)?\s*([\s\S]*?)```/i)?.[1]??t).trim(),r=[n.indexOf(`{`)].filter(e=>e>=0);for(let e of r)for(let t=n.length;t>e;--t)if(n[t-1]===`}`)try{let r=JSON.parse(n.slice(e,t));if(r&&typeof r==`object`&&!Array.isArray(r))return r}catch{}return null};async function b(e){let t=v();return t?t.checkIsGitRepository(e):ce(e)}async function x(e){return je(e)}async function S(e,t){let n=v();return n?n.getGitStatus(e,t):te(e,t)}async function C(e){return(await fe(e)).root}async function w(e){return(await De(e)).root}async function T(e,t){let n=v();return n?.stageGitFile?n.stageGitFile(e,t):xe(e,t)}async function E(e,t){let n=v();return n?.stageGitFiles?n.stageGitFiles(e,t):Ee(e,t)}async function Fe(e,t){let n=v();return n?.unstageGitFile?n.unstageGitFile(e,t):me(e,t)}async function D(e,t){let n=v();return n?.unstageGitFiles?n.unstageGitFiles(e,t):Se(e,t)}async function O(e,t){let n=v();if(t?.signal?.throwIfAborted(),n){let r=await n.getGitBranches(e,t);return t?.signal?.throwIfAborted(),r}return ve(e,t)}async function k(e,t){let n=v();return n?n.deleteRemoteBranch(e,t):Me(e,t)}var A=12e4,j=9e4,Ie=[`This is an auxiliary structured generation request (git copy).`,`Use the active session context plus the materials below.`,`Answer with the required JSON only.`,`Do not call any tools and do not take any actions.`,`Model and instructions follow the session.generate session contract.`].join(` `),Le=`Select an active session for generation. session.generate uses that session model contract and does not mutate chat history.`,Re=`No default provider or model configured. Please select a provider and model in settings first.`,ze=`Runtime changed during session.generate`,Be=`session.generate returned empty text`,Ve=`session.generate returned invalid structured output`,He=e=>{let t=[`Diff budget: included ${e.includedFileCount} of ${e.selectedFileCount} selected files`,`fileLimit=${e.fileLimit}`,`charLimit=${e.charLimit}`,`truncatedByCharLimit=${e.truncatedByCharLimit?`yes`:`no`}`,`omittedFiles=${e.omittedFileCount}`],n=e.omittedFileCount>0||e.truncatedByCharLimit?` Materials are partial under this budget — do not invent diffs for omitted or truncated files; base the message only on provided material.`:` Materials cover the full selected set within the budget.`;return`${t.join(`; `)}.${n}`};async function M(e,t){let n=t.length,r=t.slice(0,30),i=await Promise.all(r.map(async t=>{try{let[n,r]=await Promise.all([o(e,{path:t,staged:!0}).catch(()=>null),o(e,{path:t,staged:!1}).catch(()=>null)]);return[n?.diff,r?.diff].filter(e=>typeof e==`string`&&e.trim().length>0).join(`
|
|
2
2
|
`)||`--- ${t} (no textual diff available)`}catch{return`--- ${t} (diff unavailable)`}})),a=``,s=0,c=!1;for(let e of i){let t=a?`
|
|
3
3
|
|
|
4
4
|
`:``;if(a.length+t.length+e.length>12e4){a+=`
|