@yuriai/web 0.2.12-beta.2 → 0.2.13
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/{AssistantView-BGwT_cnj.js → AssistantView-B5EPKyjc.js} +3 -3
- package/dist/assets/{DiagramView-DRVSHYyW.js → DiagramView-DN3-JwX_.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CXDLKbI2.js → GuiPluginSurface-CFDUoggO.js} +1 -1
- package/dist/assets/{GuiPluginWindow-BKPe8p8t.js → GuiPluginWindow-pZqqyXGs.js} +1 -1
- package/dist/assets/MarkdownRenderer-CeVBxdVH.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-Do8KAqlC.js → MarkdownRendererImpl-CzMc7cJQ.js} +2 -2
- package/dist/assets/{MarkstreamRendererImpl-L2-fHtpA.js → MarkstreamRendererImpl-PXdPnefG.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-BtLQo_Rl.js → MobileDetailNavigation-BAhnQIV9.js} +1 -1
- package/dist/assets/MobileResizableSheet-BdOIJ61C.js +1 -0
- package/dist/assets/MobileShareBridge-B_gLFJk3.js +4 -0
- package/dist/assets/MobileTabPageHeader-XjU9pvhD.js +2 -0
- package/dist/assets/{MultiRunWindow-CexoBVhb.js → MultiRunWindow-DaGFu0hj.js} +1 -1
- package/dist/assets/{SettingsView-B1Nn2sIu.js → SettingsView-CtvM3d6a.js} +8 -8
- package/dist/assets/{SettingsWindow-DDCNdxmH.js → SettingsWindow-DG_vdz3E.js} +1 -1
- package/dist/assets/{TerminalView-BH93XSrJ.js → TerminalView-C0SiEAbo.js} +1 -1
- package/dist/assets/{ToolOutputDialog-fZ_4z7wi.js → ToolOutputDialog-yrIDk9t9.js} +3 -3
- package/dist/assets/appThemeRegistry-D5kxElNR.js +1 -0
- package/dist/assets/{capgoAdapter-B9VrK7jw.js → capgoAdapter-D7SLqQ-c.js} +1 -1
- package/dist/assets/device-DzWRCXhq.js +2 -0
- package/dist/assets/dropdown-menu.styles-EKni18O6.js +1 -0
- package/dist/assets/{fileMentionTouchSelection-C5BslzWG.js → fileMentionTouchSelection-C7QQFbKl.js} +1 -1
- package/dist/assets/gitApi-fJA_UrSn.js +10 -0
- package/dist/assets/gitApiHttp-BtI23x-7.js +7 -0
- package/dist/assets/host-BoCxB_x4.js +1 -0
- package/dist/assets/insertionBoundaries-BFluaN7h.js +1 -0
- package/dist/assets/main-B1IxtY4b.js +169 -0
- package/dist/assets/main-C50a-hxw.js +2 -0
- package/dist/assets/mcpQueries-CrPSf5Vz.js +1 -0
- package/dist/assets/miniChat-CgTgVMyW.js +2 -0
- package/dist/assets/mobile-ClCcMKiG.js +2 -0
- package/dist/assets/{mobileBackNavigation-B_x92p6I.js → mobileBackNavigation-DD4qKsh9.js} +1 -1
- package/dist/assets/multirun-G_2Gu2aN.js +3 -0
- package/dist/assets/native-config-LhABXuCD.js +1 -0
- package/dist/assets/platform-syRnKuVU.js +1 -0
- package/dist/assets/{projectMeta-BpdNCDci.js → projectMeta-DifhnpC_.js} +1 -1
- package/dist/assets/{readiness-BjyrMWQ4.js → readiness-CuNh57Ra.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-CvHjnTSl.js +2 -0
- package/dist/assets/renderMobileApp-Cm-WgWEU.js +28 -0
- package/dist/assets/runtimeConfig-DypRzlVN.js +2 -0
- package/dist/assets/runtimeEndpointReset-v8Gjb_h8.js +149 -0
- package/dist/assets/{scheduledTaskNavigation-JfDZws7P.js → scheduledTaskNavigation-DPl7XI48.js} +1 -1
- package/dist/assets/{sessionChangeSummary-CnUPwOh6.js → sessionChangeSummary-C1wmWmRX.js} +1 -1
- package/dist/assets/sessionLookup-BUr74urV.js +1 -0
- package/dist/assets/{sortable-tabs-strip-h-raXfd8.js → sortable-tabs-strip-Bp_bMUwf.js} +1 -1
- package/dist/assets/{speechSettingsQueries-JtXEoFYP.js → speechSettingsQueries-CUBdEzKS.js} +1 -1
- package/dist/assets/src-dSUmXLC4.css +2 -0
- package/dist/assets/terminalApi-Dw1h9m3h.js +1 -0
- package/dist/assets/types-DgWYjk5a.js +2 -0
- package/dist/assets/{useAppFontEffects-fKQ6i4QC.js → useAppFontEffects-qq8jA_we.js} +48 -48
- package/dist/assets/{useDesktopWindowControlsLayout-aCAOBpZH.js → useDesktopWindowControlsLayout-DgdTkJrN.js} +1 -1
- package/dist/assets/useEffectiveDirectory-DUZaM7mh.js +1 -0
- package/dist/assets/{useFontPreferences-51P_6ZRi.js → useFontPreferences-B4LGrKaG.js} +1 -1
- package/dist/assets/useMobileNavigationStore-wecwJwNt.js +417 -0
- package/dist/assets/{useWorkerHighlightedLines-DWTiInlP.js → useWorkerHighlightedLines-C9zsX5Pb.js} +1 -1
- package/dist/index.html +9 -8
- package/dist/mini-chat.html +9 -8
- package/dist/mobile.html +9 -8
- package/package.json +1 -1
- package/server/lib/git/DOCUMENTATION.md +1 -0
- package/server/lib/git/routes.js +10 -1
- package/server/lib/git/routes.test.js +76 -0
- package/dist/assets/MarkdownRenderer-B8xi-szc.js +0 -2
- package/dist/assets/MobileResizableSheet-CVZyFmiP.js +0 -1
- package/dist/assets/MobileShareBridge-B3fVcVe4.js +0 -4
- package/dist/assets/MobileTabPageHeader-DnIyAEmt.js +0 -2
- package/dist/assets/appThemeRegistry-PpiWCZgq.js +0 -1
- package/dist/assets/device-B7GyZCPd.js +0 -2
- package/dist/assets/dropdown-menu.styles-BfEkQov6.js +0 -1
- package/dist/assets/gitApi-Q5-lN46d.js +0 -10
- package/dist/assets/host-BlpgWo6Q.js +0 -1
- package/dist/assets/insertionBoundaries-ewtT_GYv.js +0 -1
- package/dist/assets/main-BejI5g8K.js +0 -169
- package/dist/assets/main-DZFZc2Cz.js +0 -2
- package/dist/assets/mcpQueries-DhdyzBPI.js +0 -1
- package/dist/assets/miniChat-BoLIKdEU.js +0 -2
- package/dist/assets/mobile-qUsKQQrt.js +0 -2
- package/dist/assets/multirun-Cs1-2PJ3.js +0 -3
- package/dist/assets/native-config-Qpfr4t6J.js +0 -1
- package/dist/assets/platform-DXeTzJHG.js +0 -7
- package/dist/assets/renderElectronMiniChatApp-DMuZlrFu.js +0 -2
- package/dist/assets/renderMobileApp-BiGLm-5i.js +0 -28
- package/dist/assets/runtimeConfig-B25zh-JV.js +0 -2
- package/dist/assets/runtimeEndpointReset-j5Tq4J9B.js +0 -149
- package/dist/assets/sessionLookup-DpKDj2Pl.js +0 -1
- package/dist/assets/src-DZ4-mHgg.css +0 -2
- package/dist/assets/terminalApi-CIbkfDkE.js +0 -1
- package/dist/assets/types-CM0lXtmR.js +0 -2
- package/dist/assets/useEffectiveDirectory-HWABaJoo.js +0 -1
- package/dist/assets/useMobileNavigationStore-CjljWARe.js +0 -417
package/dist/assets/{useWorkerHighlightedLines-DWTiInlP.js → useWorkerHighlightedLines-C9zsX5Pb.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{v as r}from"./useUIStore-NMQx_cnG.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a,r as o,t as s}from"./button-DFX-UCuQ.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-C1nXIg7J.js";import{i as u,n as d,t as f}from"./tooltip-Byl6nrXB.js";import{n as p}from"./MarkdownRenderer-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{v as r}from"./useUIStore-NMQx_cnG.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a,r as o,t as s}from"./button-DFX-UCuQ.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-C1nXIg7J.js";import{i as u,n as d,t as f}from"./tooltip-Byl6nrXB.js";import{n as p}from"./MarkdownRenderer-CeVBxdVH.js";import{n as m,r as h}from"./toolHelpers-DL452NVK.js";import{t as g}from"./vendor-tanstack-react-virtual-B_EO--9t.js";import{n as _}from"./markdownTheme-DHoKvD6O.js";import{n as v,t as y}from"./markdown-worker-oBGEB9Eg.js";var b=e(t(),1),x=i(),S=n(),C=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl 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)]`,w={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},T=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,E=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,D=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,O=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,k=`${O} max-h-[min(22rem,50vh)] overflow-y-auto`,A=`${O} w-full`,ee={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},j=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,M=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,te=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ne=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,re=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ie={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},ae={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},N=e=>{let t=(0,x.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:s}=a(),c=oe.has(n.status)?n.status:`pending`,p=ae[c],m;t[0]!==s||t[1]!==p?(m=s(p),t[0]=s,t[1]=p,t[2]=m):m=t[2];let h=m,g;t[3]===c?g=t[4]:(g=c===`in_progress`?(0,S.jsx)(l,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):c===`completed`?(0,S.jsx)(l,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,S.jsx)(l,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=c,t[4]=g);let _=g,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=o(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,j,y),t[5]=y,t[6]=b);let C;t[7]!==_||t[8]!==h?(C=(0,S.jsx)(u,{asChild:!0,children:(0,S.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":h,children:_})}),t[7]=_,t[8]=h,t[9]=C):C=t[9];let w;t[10]===h?w=t[11]:(w=(0,S.jsx)(d,{side:`left`,sideOffset:6,children:h}),t[10]=h,t[11]=w);let T;t[12]!==C||t[13]!==w?(T=(0,S.jsxs)(f,{children:[C,w]}),t[12]=C,t[13]=w,t[14]=T):T=t[14];let E=ie[c],D;t[15]===E?D=t[16]:(D=o(`block whitespace-normal break-words`,E),t[15]=E,t[16]=D);let O;t[17]!==D||t[18]!==n.content?(O=(0,S.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,S.jsx)(`span`,{className:D,children:n.content})}),t[17]=D,t[18]=n.content,t[19]=O):O=t[19];let k;return t[20]!==i||t[21]!==O||t[22]!==v||t[23]!==b||t[24]!==T?(k=(0,S.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[T,O]}),t[20]=i,t[21]=O,t[22]=v,t[23]=b,t[24]=T,t[25]=k):k=t[25],k},oe=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),P=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),F=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,I=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=F(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},L=e=>`<pre><code>${P(e)}</code></pre>`,R=e=>{let t=(0,x.c)(21),{code:n,language:r,className:i,style:a,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=b.useRef(null),p;t[0]===d?p=t[1]:(p=_(d),t[0]=d,t[1]=p);let m=p,h,g;t[2]!==n||t[3]!==s||t[4]!==u?(h=()=>{let e=f.current;e&&(e.innerHTML=L(n),I(e,u,s))},g=[n,u,s],t[2]=n,t[3]=s,t[4]=u,t[5]=h,t[6]=g):(h=t[5],g=t[6]),b.useLayoutEffect(h,g);let v,C;t[7]!==n||t[8]!==s||t[9]!==r||t[10]!==u?(v=()=>{let e=f.current;if(!e)return;let t=!0,i=new AbortController;return y(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,I(e,u,s))}),()=>{t=!1,i.abort()}},C=[n,r,u,s],t[7]=n,t[8]=s,t[9]=r,t[10]=u,t[11]=v,t[12]=C):(v=t[11],C=t[12]),b.useEffect(v,C);let w;t[13]===i?w=t[14]:(w=o(`typography-code`,i),t[13]=i,t[14]=w);let T=m,E;t[15]!==a||t[16]!==T?(E={...T,...a},t[15]=a,t[16]=T,t[17]=E):E=t[17];let D;return t[18]!==w||t[19]!==E?(D=(0,S.jsx)(`div`,{ref:f,className:w,style:E}),t[18]=w,t[19]=E,t[20]=D):D=t[20],D},z=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},B=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},V=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,H=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,U=(e,t)=>!e||typeof e!=`object`?String(e):h(e,t||``),W=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},G=e=>{if(!e||typeof e!=`object`)return;let t=W(e.patch)??W(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=W(e.patch)??W(e.diff);if(t)return t}},K=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},q=(e,t,n)=>{let r=z(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&V(r)&&(r=H(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=G(n);if(e)return e}return r},se=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},ce=(e,t)=>{try{let n=e.trim().split(`
|
|
4
4
|
`).filter(Boolean);if(n.length===0)return null;let i=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,S.jsx)(`div`,{className:o(`w-full min-w-0 font-mono space-y-0.5`,t?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:r.tool.popup,children:i.map((e,t)=>(0,S.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,S.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,S.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},le={backgroundColor:`var(--status-info)`,opacity:.6},ue=(e,t,n)=>{try{let i=e.trim().split(`
|
package/dist/index.html
CHANGED
|
@@ -560,7 +560,7 @@
|
|
|
560
560
|
opacity: 0.72;
|
|
561
561
|
}
|
|
562
562
|
</style>
|
|
563
|
-
<script type="module" crossorigin src="/assets/main-
|
|
563
|
+
<script type="module" crossorigin src="/assets/main-C50a-hxw.js"></script>
|
|
564
564
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
565
565
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
|
|
566
566
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
|
|
@@ -588,14 +588,15 @@
|
|
|
588
588
|
<link rel="modulepreload" crossorigin href="/assets/path-utils-jGozTg9d.js">
|
|
589
589
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
590
590
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-resource-D3k0hKDj.js">
|
|
591
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
592
|
-
<link rel="modulepreload" crossorigin href="/assets/terminalApi-
|
|
591
|
+
<link rel="modulepreload" crossorigin href="/assets/gitApiHttp-BtI23x-7.js">
|
|
592
|
+
<link rel="modulepreload" crossorigin href="/assets/terminalApi-Dw1h9m3h.js">
|
|
593
593
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-BzblfnMx.js">
|
|
594
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
595
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
596
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
597
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
598
|
-
<link rel="
|
|
594
|
+
<link rel="modulepreload" crossorigin href="/assets/platform-syRnKuVU.js">
|
|
595
|
+
<link rel="modulepreload" crossorigin href="/assets/types-DgWYjk5a.js">
|
|
596
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-D7SLqQ-c.js">
|
|
597
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-LhABXuCD.js">
|
|
598
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-DypRzlVN.js">
|
|
599
|
+
<link rel="stylesheet" crossorigin href="/assets/src-dSUmXLC4.css">
|
|
599
600
|
</head>
|
|
600
601
|
<body class="h-full bg-background text-foreground">
|
|
601
602
|
<!-- Keep the startup layer outside #root. React replaces every child of
|
package/dist/mini-chat.html
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
.dark #initial-loading img { filter: invert(1); }
|
|
78
78
|
</style>
|
|
79
79
|
|
|
80
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
80
|
+
<script type="module" crossorigin src="/assets/miniChat-CgTgVMyW.js"></script>
|
|
81
81
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
82
82
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
|
|
83
83
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
|
|
@@ -105,14 +105,15 @@
|
|
|
105
105
|
<link rel="modulepreload" crossorigin href="/assets/path-utils-jGozTg9d.js">
|
|
106
106
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
107
107
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-resource-D3k0hKDj.js">
|
|
108
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
109
|
-
<link rel="modulepreload" crossorigin href="/assets/terminalApi-
|
|
108
|
+
<link rel="modulepreload" crossorigin href="/assets/gitApiHttp-BtI23x-7.js">
|
|
109
|
+
<link rel="modulepreload" crossorigin href="/assets/terminalApi-Dw1h9m3h.js">
|
|
110
110
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-BzblfnMx.js">
|
|
111
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
112
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
113
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
114
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
115
|
-
<link rel="
|
|
111
|
+
<link rel="modulepreload" crossorigin href="/assets/platform-syRnKuVU.js">
|
|
112
|
+
<link rel="modulepreload" crossorigin href="/assets/types-DgWYjk5a.js">
|
|
113
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-D7SLqQ-c.js">
|
|
114
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-LhABXuCD.js">
|
|
115
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-DypRzlVN.js">
|
|
116
|
+
<link rel="stylesheet" crossorigin href="/assets/src-dSUmXLC4.css">
|
|
116
117
|
</head>
|
|
117
118
|
<body class="h-full bg-background text-foreground">
|
|
118
119
|
<div id="root" class="h-full">
|
package/dist/mobile.html
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
66
|
<style>.dark #mobile-startup-logo img { filter: invert(1); }</style>
|
|
67
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
67
|
+
<script type="module" crossorigin src="/assets/mobile-ClCcMKiG.js"></script>
|
|
68
68
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
|
|
70
70
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
|
|
@@ -92,14 +92,15 @@
|
|
|
92
92
|
<link rel="modulepreload" crossorigin href="/assets/path-utils-jGozTg9d.js">
|
|
93
93
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
94
94
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-resource-D3k0hKDj.js">
|
|
95
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
96
|
-
<link rel="modulepreload" crossorigin href="/assets/terminalApi-
|
|
95
|
+
<link rel="modulepreload" crossorigin href="/assets/gitApiHttp-BtI23x-7.js">
|
|
96
|
+
<link rel="modulepreload" crossorigin href="/assets/terminalApi-Dw1h9m3h.js">
|
|
97
97
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-BzblfnMx.js">
|
|
98
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
99
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
100
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
101
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
102
|
-
<link rel="
|
|
98
|
+
<link rel="modulepreload" crossorigin href="/assets/platform-syRnKuVU.js">
|
|
99
|
+
<link rel="modulepreload" crossorigin href="/assets/types-DgWYjk5a.js">
|
|
100
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-D7SLqQ-c.js">
|
|
101
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-LhABXuCD.js">
|
|
102
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-DypRzlVN.js">
|
|
103
|
+
<link rel="stylesheet" crossorigin href="/assets/src-dSUmXLC4.css">
|
|
103
104
|
</head>
|
|
104
105
|
<body class="h-full bg-background text-foreground">
|
|
105
106
|
<div id="root" class="h-full">
|
package/package.json
CHANGED
|
@@ -116,6 +116,7 @@ The following functions are internal helpers used by exported functions:
|
|
|
116
116
|
- `diffStats`: Object mapping file paths to `{ insertions, deletions }`. Omitted by light mode and by oversized change sets.
|
|
117
117
|
- `mergeInProgress`: Object with `{ head, message }` if merge in progress.
|
|
118
118
|
- `rebaseInProgress`: Object with `{ headName, onto }` if rebase in progress.
|
|
119
|
+
- `revision`: `/api/git/status` only. Content revision `<light|full>:<sha1 base64url>` of the serialized status for that mode. Clients may echo it as `?since=<revision>`; when the freshly computed snapshot has the same revision the route answers `{ unchanged: true, revision }` without the file list. `getStatus` is still executed on every request, so `unchanged` is authoritative for current state. The shared HTTP client keeps the last snapshot per directory/mode, bound to transport identity and its invalidation version, and drops it on any local mutation. The VS Code runtime computes status in the extension host and never uses this field.
|
|
119
120
|
|
|
120
121
|
### Staged and unstaged change handling
|
|
121
122
|
- `status.files` exposes both `index` and `working_dir` codes. Shared UI uses these as separate scopes: staged rows are derived from non-empty `index` statuses, while unstaged rows are derived from `working_dir` statuses and untracked files.
|
package/server/lib/git/routes.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
|
|
1
3
|
export function registerGitRoutes(app, { messageQueueService = null, createRequestID = () => globalThis.crypto.randomUUID(), broadcastWorktreeTopologyChanged = () => {}, releaseWorktreeLocation } = {}) {
|
|
2
4
|
const normalizeWorktreePath = (value) => typeof value === 'string' ? value.trim().replace(/\\/g, '/').replace(/\/+$/, '') : '';
|
|
3
5
|
const lifecycleOperations = new Map();
|
|
@@ -250,7 +252,14 @@ export function registerGitRoutes(app, { messageQueueService = null, createReque
|
|
|
250
252
|
|
|
251
253
|
const mode = req.query.mode === 'light' ? 'light' : undefined;
|
|
252
254
|
const status = await getStatus(directory, { mode });
|
|
253
|
-
|
|
255
|
+
// Content revision: clients echo it as `since`; an identical snapshot is
|
|
256
|
+
// answered without re-sending (and re-parsing) the full file list.
|
|
257
|
+
const serialized = JSON.stringify(status);
|
|
258
|
+
const revision = `${mode ?? 'full'}:${createHash('sha1').update(serialized).digest('base64url')}`;
|
|
259
|
+
if (typeof req.query.since === 'string' && req.query.since === revision) {
|
|
260
|
+
return res.json({ unchanged: true, revision });
|
|
261
|
+
}
|
|
262
|
+
res.json({ ...status, revision });
|
|
254
263
|
} catch (error) {
|
|
255
264
|
const errorText = extractGitErrorText(error);
|
|
256
265
|
if (/not a git repository/i.test(errorText)) {
|
|
@@ -8,6 +8,7 @@ const gitLibraries = {
|
|
|
8
8
|
getWorktrees: vi.fn(),
|
|
9
9
|
isGitRepository: vi.fn(),
|
|
10
10
|
resolvePrimaryWorktreeRoot: vi.fn(),
|
|
11
|
+
getStatus: vi.fn(),
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
vi.mock('./index.js', () => ({
|
|
@@ -18,6 +19,7 @@ vi.mock('./index.js', () => ({
|
|
|
18
19
|
getWorktrees: gitLibraries.getWorktrees,
|
|
19
20
|
isGitRepository: gitLibraries.isGitRepository,
|
|
20
21
|
resolvePrimaryWorktreeRoot: gitLibraries.resolvePrimaryWorktreeRoot,
|
|
22
|
+
getStatus: gitLibraries.getStatus,
|
|
21
23
|
}));
|
|
22
24
|
|
|
23
25
|
const { registerGitRoutes } = await import('./routes.js');
|
|
@@ -205,6 +207,80 @@ describe('git routes batch discover', () => {
|
|
|
205
207
|
});
|
|
206
208
|
});
|
|
207
209
|
|
|
210
|
+
describe('git routes status revision', () => {
|
|
211
|
+
const statusPayload = (overrides = {}) => ({
|
|
212
|
+
current: 'main',
|
|
213
|
+
tracking: null,
|
|
214
|
+
ahead: 0,
|
|
215
|
+
behind: 0,
|
|
216
|
+
files: [{ path: 'a.ts', index: ' ', working_dir: 'M' }],
|
|
217
|
+
isClean: false,
|
|
218
|
+
oversized: false,
|
|
219
|
+
...overrides,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
beforeEach(() => {
|
|
223
|
+
gitLibraries.isGitRepository.mockReset();
|
|
224
|
+
gitLibraries.getStatus.mockReset();
|
|
225
|
+
gitLibraries.isGitRepository.mockResolvedValue(true);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const requestStatus = async (query) => {
|
|
229
|
+
const { app, getRoute } = createRouteRegistry();
|
|
230
|
+
registerGitRoutes(app);
|
|
231
|
+
const response = createMockResponse();
|
|
232
|
+
await getRoute('GET', '/api/git/status')({ query: { directory: '/repo', ...query } }, response);
|
|
233
|
+
return response;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
it('returns the full status with a stable content revision', async () => {
|
|
237
|
+
gitLibraries.getStatus.mockResolvedValue(statusPayload());
|
|
238
|
+
const first = await requestStatus();
|
|
239
|
+
const second = await requestStatus();
|
|
240
|
+
|
|
241
|
+
expect(first.statusCode).toBe(200);
|
|
242
|
+
expect(first.body).toMatchObject(statusPayload());
|
|
243
|
+
expect(typeof first.body.revision).toBe('string');
|
|
244
|
+
expect(first.body.revision.length).toBeGreaterThan(0);
|
|
245
|
+
expect(second.body.revision).toBe(first.body.revision);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('answers unchanged without the file list when the client revision matches', async () => {
|
|
249
|
+
gitLibraries.getStatus.mockResolvedValue(statusPayload());
|
|
250
|
+
const { body: full } = await requestStatus();
|
|
251
|
+
|
|
252
|
+
const response = await requestStatus({ since: full.revision });
|
|
253
|
+
|
|
254
|
+
expect(response.statusCode).toBe(200);
|
|
255
|
+
expect(response.body).toEqual({ unchanged: true, revision: full.revision });
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('returns the full status when content changed since the client revision', async () => {
|
|
259
|
+
gitLibraries.getStatus.mockResolvedValueOnce(statusPayload());
|
|
260
|
+
const { body: full } = await requestStatus();
|
|
261
|
+
const changed = statusPayload({ files: [{ path: 'a.ts', index: 'M', working_dir: ' ' }] });
|
|
262
|
+
gitLibraries.getStatus.mockResolvedValueOnce(changed);
|
|
263
|
+
|
|
264
|
+
const response = await requestStatus({ since: full.revision });
|
|
265
|
+
|
|
266
|
+
expect(response.body).toMatchObject(changed);
|
|
267
|
+
expect(response.body.unchanged).toBeUndefined();
|
|
268
|
+
expect(response.body.revision).not.toBe(full.revision);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('gives light and full payloads distinct revisions', async () => {
|
|
272
|
+
gitLibraries.getStatus.mockImplementation(async (_directory, options) => (
|
|
273
|
+
options?.mode === 'light' ? statusPayload() : statusPayload({ diffStats: { 'a.ts': { insertions: 1, deletions: 0 } } })
|
|
274
|
+
));
|
|
275
|
+
const { body: full } = await requestStatus();
|
|
276
|
+
|
|
277
|
+
const light = await requestStatus({ mode: 'light', since: full.revision });
|
|
278
|
+
|
|
279
|
+
expect(light.body.unchanged).toBeUndefined();
|
|
280
|
+
expect(light.body.files).toHaveLength(1);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
208
284
|
describe('git routes index mutations', () => {
|
|
209
285
|
beforeEach(() => {
|
|
210
286
|
gitLibraries.stageFiles.mockReset();
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-L2-fHtpA.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-NMQx_cnG.js","assets/runtime-switch-CAZiOV2G.js","assets/runtime-auth-ef9W7A43.js","assets/vendor-zustand-o69pgTEK.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/vendor-react-BP2cRVqX.js","assets/fileQueries-DbUx7NwP.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/queryRuntime-BuRnpVtK.js","assets/runtime-fetch-BAN5Gnnp.js","assets/vendor-markstream-react-Bm0cO70Z.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/vendor-reactuses-core-BJ-jJ4YM.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-DFX-UCuQ.js","assets/desktop-dp2Z0toS.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/store-CKaWYiP4.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useMobileNavigationStore-CjljWARe.js","assets/platform-DXeTzJHG.js","assets/vendor-opencode-client-fxfj4IA_.js","assets/vendor-effect-DV9F8PTZ.js","assets/persistence-BfjCXjLZ.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/runtime-file-resource-D3k0hKDj.js","assets/runtime-file-store-BVRgEtI-.js","assets/path-utils-jGozTg9d.js","assets/vendor-sonner-ZS8XIOVl.js","assets/useAssistantUIStore-rdsbsVts.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/useThemeSystem-8jhE4Zyk.js","assets/tooltip-Byl6nrXB.js","assets/image-loading-FUFYiO1j.js","assets/image-loading-D9Z_BASK.css","assets/url-MRa-FtQa.js","assets/useEffectiveDirectory-HWABaJoo.js","assets/LoadingImage-ByZs_EGY.js","assets/ImageLoadingPlaceholder-B5t9zOYn.js","assets/markdownHeightCache-BsFt9Iuh.js","assets/dualLimitLru-D8Sphgua.js","assets/MarkdownRendererImpl-Do8KAqlC.js","assets/vendor-katex-DNVSTX6g.js","assets/FadeInOnReveal-CxIQc2_J.js","assets/markdownTheme-DHoKvD6O.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/fileReferenceActions-No7p4Kdo.js","assets/toolHelpers-DL452NVK.js","assets/fileReferenceParser-1HHDBUum.js","assets/MarkstreamRendererImpl-EpBnVy9J.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-o69pgTEK.js";import{it as n,rt 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{r as o}from"./button-DFX-UCuQ.js";import{t as s}from"./useEffectiveDirectory-HWABaJoo.js";import{i as c,n as l,t as u}from"./markdownHeightCache-BsFt9Iuh.js";var d=i(),f=e(n(),1),p=`yuri:chunk-import-reload`,m=250,h=3e4,g=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function _(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function v(e){let t=_(e);return g.some(e=>e.test(t))}function y(e){return`0.2.12-beta.2:${_(e).slice(0,500)}`}function b(e){if(typeof window>`u`)return;let t=Date.now(),n=y(e),r=null;try{let e=window.sessionStorage.getItem(p);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<h)){try{window.sessionStorage.setItem(p,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:_(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function x(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!v(e)||t>=n)break;await new Promise(e=>setTimeout(e,m*(t+1)))}throw v(r)&&b(r),r}var S=e=>(0,f.lazy)(()=>x(e)),C=(e,t)=>!!t?.toLowerCase().startsWith(`video/`)||/^data:video\//i.test(e)||/\.(?:mp4|m4v|webm|mov|ogv|ogg)(?:[?#]|$)/i.test(e),w=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},T=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},E=`yuri:markstream-react`,D=e=>w(E,e),O=t(e=>({markstreamReactEnabled:D(),setMarkstreamReactEnabled:t=>{T(E,t),e({markstreamReactEnabled:t})}})),k=null,A=()=>(k??=a(()=>import(`./MarkstreamRendererImpl-L2-fHtpA.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77])).catch(e=>{throw k=null,e}),k),j=()=>{A().catch(()=>void 0)},M=null,N=()=>(M??=a(()=>import(`./MarkdownRendererImpl-Do8KAqlC.js`).then(e=>e.n),__vite__mapDeps([54,1,4,5,24,25,2,30,14,6,31,32,7,8,3,33,9,13,12,34,35,36,10,11,37,38,16,55,20,21,22,23,26,27,28,29,39,40,41,42,43,53,44,46,47,48,49,56,52,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76])).catch(e=>{throw M=null,e}),M),P=()=>{N().catch(()=>void 0),D()&&j()},F=class extends f.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},I=f.createContext(!0),L=()=>f.useContext(I),R=r(),z=S(()=>N().then(e=>({default:e.MarkdownRenderer}))),B=S(()=>A().then(e=>({default:e.MarkstreamRenderer}))),V=S(()=>N().then(e=>({default:e.SimpleMarkdownRenderer}))),H=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,U=e=>{let t=(0,d.c)(15),n=O(K),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?l(u(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let s=a,f;t[5]!==e.className||t[6]!==e.variant?(f=o(`relative break-words w-full min-w-0`,H(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=f):f=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==s?(p=(0,R.jsx)(c,{animated:e.animated,content:r,reservedHeight:s}),t[8]=r,t[9]=e.animated,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,R.jsx)(`div`,{className:f,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m},W=e=>{let t=(0,d.c)(13),n=L(),r=O(q);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(z,{...e})}),t[2]=e,t[3]=i);let a=i,o;t[4]!==a||t[5]!==r||t[6]!==e?(o=r?(0,R.jsx)(F,{fallback:a,children:(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(B,{...e})})}):a,t[4]=a,t[5]=r,t[6]=e,t[7]=o):o=t[7];let c=o,l;t[8]===e?l=t[9]:(l=t=>{if(!e.onShowPopup||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null,r=n?.getAttribute(`href`);if(!r||!C(r))return;t.preventDefault(),t.stopPropagation();let i=n?.textContent?.trim()||r.split(/[/?#]/).filter(Boolean).pop()||r;e.onShowPopup({open:!0,title:i,content:``,video:{url:r,filename:i,directory:s()??``}})},t[8]=e,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,R.jsx)(`div`,{className:`contents`,onClickCapture:l,children:c}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},G=e=>{let t=(0,d.c)(4);if(!L()){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e}),children:(0,R.jsx)(V,{...e})}),t[2]=e,t[3]=n),n};function K(e){return e.markstreamReactEnabled}function q(e){return e.markstreamReactEnabled}export{C as a,P as i,G as n,S as o,I as r,W as t};
|
|
@@ -1 +0,0 @@
|
|
|
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{n as i}from"./vendor-react-BP2cRVqX.js";import{r as a}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{r as o,t as s}from"./button-DFX-UCuQ.js";import{a as c,s as l}from"./vendor-framer-motion-D8hQsul-.js";import{n as u}from"./Icon-C1nXIg7J.js";import{t as d}from"./MobileWindowStack-DGLdgoGr.js";var f=e(t(),1),p=i(),m=r(),h=e(n(),1),g=0,_=()=>{g=Date.now()+800},v=()=>Date.now()<g;function y(e){let t=(0,p.c)(9),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=o(`flex cursor-ns-resize touch-none justify-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,m.jsx)(`div`,{className:`pointer-events-none h-1.5 w-11 rounded-full bg-[var(--interactive-border)]`}),t[5]=a):a=t[5];let s;return t[6]!==r||t[7]!==i?(s=(0,m.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`horizontal`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=s):s=t[8],s}var b=100,x=.35;function S(e,t,n){let r=e.at(-1),i=e.at(-2);for(r&&i&&Math.abs(t-r.height)>2&&(t-r.height)*(r.height-i.height)<0&&e.splice(0,e.length-1),e.push({height:t,time:n});e.length>2&&(e.length>16||e[1].time<n-b);)e.shift()}function C(e,t){let n=e.at(-1);if(!n||t-n.time>=b)return 0;let r=e.find(e=>e.time>=t-b);return!r||n.time<=r.time?0:Math.max(-4,Math.min(4,(n.height-r.height)/Math.max(1,t-r.time)))}function w(e,t,n,r,i){let a=Math.abs(r)>=x&&Math.abs(i)>=8,o=n+(a?r*180:0),s=e.reduce((e,t)=>Math.abs(t.height-o)<Math.abs(e.height-o)?t:e),c=e.find(e=>e.id===t)??s;return!a||Math.abs(s.height-c.height)>1?s.id:[...e].sort((e,t)=>r>0?e.height-t.height:t.height-e.height).find(e=>r>0?e.height>c.height+1:e.height<c.height-1)?.id??s.id}function T(e,t,n){let r=e<t?t:e>n?n:e,i=e-r;return r+Math.sign(i)*48*(1-1/(1+Math.abs(i)*.55/48))}function E(e){let t=(0,p.c)(82),{surfaceRef:n,initialPoint:r,getPoints:i,minimumHeight:o,onRelease:s,onCommit:u,renderMode:d}=e,m=d===void 0?`height`:d,[h,g]=(0,f.useState)(r),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),x=(0,f.useRef)(r),E=(0,f.useRef)(null),k=(0,f.useRef)(null),A=(0,f.useRef)(null),oe=(0,f.useRef)(null),j=(0,f.useRef)(!1),M=(0,f.useRef)(null),N;t[0]===n?N=t[1]:(N=()=>{let e=n.current;if(!e)return 0;if(!M.current)return e.getBoundingClientRect().height;let t=parseFloat(getComputedStyle(e).translate.split(` `)[1])||0;return M.current.layoutHeight-t},t[0]=n,t[1]=N);let P=a(N),F;t[2]===n?F=t[3]:(F=e=>{let t=n.current;t&&(M.current?t.style.translate=`0 ${M.current.layoutHeight-e}px`:t.style.height=`${e}px`)},t[2]=n,t[3]=F);let I=a(F),L;t[4]!==m||t[5]!==n||t[6]!==I?(L=(e,t)=>{let r=n.current;if(r){if(m===`translate`&&!M.current){let e=Math.max(...t.map(ae))+144,{maxHeight:n,position:i,bottom:a,left:o,right:s}=r.style;M.current={layoutHeight:e,styles:{maxHeight:n,position:i,bottom:a,left:o,right:s}},Object.assign(r.style,{position:`absolute`,bottom:`0px`,left:`0px`,right:`0px`}),r.style.maxHeight=`none`,r.style.height=`${e}px`}r.setAttribute(`data-height-snap-active`,``),r.style.willChange=M.current?`translate`:`height`,I(e)}},t[4]=m,t[5]=n,t[6]=I,t[7]=L):L=t[7];let R=a(L),z;t[8]===n?z=t[9]:(z=()=>{let e=n.current;e&&(M.current&&(e.style.translate=``,Object.assign(e.style,M.current.styles),e.style.height=``),e.style.willChange=``,e.removeAttribute(`data-height-snap-active`)),M.current=null},t[8]=n,t[9]=z);let B=a(z),V;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{k.current!==null&&cancelAnimationFrame(k.current),k.current=null,A.current=null,oe.current?.cancel(),oe.current=null},t[10]=V):V=t[10];let H=a(V),U;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{let e=E.current;E.current=null,e?.handle.hasPointerCapture?.(e.pointerId)&&e.handle.releasePointerCapture(e.pointerId)},t[11]=U):U=t[11];let W=a(U),se;t[12]!==H||t[13]!==B||t[14]!==i||t[15]!==u||t[16]!==R||t[17]!==P||t[18]!==W||t[19]!==n||t[20]!==I?(se=(e,t,r,a)=>{let o=r===void 0||r,s=a===void 0?0:a,d=n.current;if(!d)return;let f=t??P();H(),I(f);let p=i(),m=p.find(t=>t.id===e);if(!m)return;if(R(f,p),W(),v(!1),b(!1),x.current=e,g(e),I(m.height),u?.(e),!o||Math.abs(f-m.height)<1||typeof d.animate!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches){B();return}b(!0);let h=M.current?.layoutHeight,_=m.height-f,y=c([d],h===void 0?{height:[`${f}px`,`${m.height}px`]}:{translate:[`0 ${h-f}px`,`0 ${h-m.height}px`]},{type:l,stiffness:576,damping:48,mass:1,velocity:s*1e3*100/_,restDelta:20/Math.abs(_),restSpeed:500/Math.abs(_)});oe.current=y,y.finished.catch(O).then(()=>{oe.current===y&&(oe.current=null,B(),b(!1))})},t[12]=H,t[13]=B,t[14]=i,t[15]=u,t[16]=R,t[17]=P,t[18]=W,t[19]=n,t[20]=I,t[21]=se):se=t[21];let G=a(se),ce;t[22]!==H||t[23]!==i||t[24]!==o||t[25]!==R||t[26]!==P||t[27]!==n||t[28]!==I?(ce=e=>{if(E.current||!e.isPrimary||e.pointerType===`mouse`&&e.button!==0||!n.current)return;let t=P();H(),I(t);let r=i();r.length&&(b(!1),E.current={pointerId:e.pointerId,startY:e.clientY,height:t,point:x.current,points:r,handle:e.currentTarget,minimum:o??Math.min(...r.map(ie)),maximum:Math.max(...r.map(re)),samples:[{height:t,time:e.timeStamp}]},j.current=!1,R(t,r),v(!0),e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault())},t[22]=H,t[23]=i,t[24]=o,t[25]=R,t[26]=P,t[27]=n,t[28]=I,t[29]=ce):ce=t[29];let le=a(ce),K;t[30]!==m||t[31]!==I?(K=e=>{let t=E.current;if(!t||t.pointerId!==e.pointerId)return;let n=t.startY-e.clientY;Math.abs(n)>3&&(j.current=!0),S(t.samples,t.height+n,e.timeStamp);let r=T(t.height+n,t.minimum,t.maximum);A.current=m===`height`?Math.max(t.minimum,r):r,k.current===null&&(k.current=requestAnimationFrame(()=>{k.current=null,A.current!==null&&I(A.current)})),e.preventDefault()},t[30]=m,t[31]=I,t[32]=K):K=t[32];let ue=a(K),q;t[33]!==H||t[34]!==s||t[35]!==P||t[36]!==W||t[37]!==G||t[38]!==n?(q=(e,t)=>{let r=E.current;if(!r||r.pointerId!==e.pointerId)return;let i=A.current??P(),a=r.height+r.startY-e.clientY;t||S(r.samples,a,e.timeStamp);let o=t?0:C(r.samples,e.timeStamp);if(W(),!t&&j.current&&s?.(i,o,r.height))H(),v(!1),n.current&&(n.current.style.willChange=``);else{let e=t||!j.current?r.point:w(r.points,r.point,i,o,a-r.height);G(e,i,!0,o)}e.preventDefault()},t[33]=H,t[34]=s,t[35]=P,t[36]=W,t[37]=G,t[38]=n,t[39]=q):q=t[39];let de=a(q),J;t[40]!==i||t[41]!==G?(J=e=>{let t=[...i()].sort(ne),n=t.find(e=>e.id===x.current);if(!n)return;let r=e>0?t.find(e=>e.height>n.height+1):t.sort(te).find(e=>e.height<n.height-1);r&&G(r.id)},t[40]=i,t[41]=G,t[42]=J):J=t[42];let fe=a(J),pe;t[43]!==i||t[44]!==G||t[45]!==fe?(pe=()=>{if(j.current){j.current=!1;return}let e=[...i()].sort(ee);x.current===e.at(-1)?.id?G(e[0].id):fe(1)},t[43]=i,t[44]=G,t[45]=fe,t[46]=pe):pe=t[46];let Y=a(pe),X;t[47]!==i||t[48]!==Y||t[49]!==G||t[50]!==fe?(X=e=>{if(![`ArrowUp`,`ArrowDown`,`Home`,`End`,`Enter`,` `].includes(e.key))return;e.preventDefault();let t=[...i()].sort(D);t.length&&(e.key===`ArrowUp`?fe(1):e.key===`ArrowDown`?fe(-1):e.key===`Home`?G(t.at(-1).id):e.key===`End`?G(t[0].id):Y())},t[47]=i,t[48]=Y,t[49]=G,t[50]=fe,t[51]=X):X=t[51];let me=a(X),Z;t[52]!==H||t[53]!==B||t[54]!==r||t[55]!==W||t[56]!==n?(Z=()=>{H(),W(),B(),x.current=r,g(r),v(!1),b(!1),j.current=!1,n.current&&(n.current.style.height=``,n.current.style.willChange=``)},t[52]=H,t[53]=B,t[54]=r,t[55]=W,t[56]=n,t[57]=Z):Z=t[57];let Q=a(Z),he,$;t[58]!==H||t[59]!==B||t[60]!==W?(he=()=>()=>{H(),W(),B()},$=[H,W,B],t[58]=H,t[59]=B,t[60]=W,t[61]=he,t[62]=$):(he=t[61],$=t[62]),(0,f.useLayoutEffect)(he,$);let ge;t[63]===de?ge=t[64]:(ge=e=>de(e,!1),t[63]=de,t[64]=ge);let _e=a(ge),ve;t[65]===de?ve=t[66]:(ve=e=>de(e,!0),t[65]=de,t[66]=ve);let ye=a(ve),be;t[67]===de?be=t[68]:(be=e=>de(e,!0),t[67]=de,t[68]=be);let xe=a(be),Se;return t[69]!==_||t[70]!==Y||t[71]!==me||t[72]!==le||t[73]!==ue||t[74]!==Q||t[75]!==G||t[76]!==y||t[77]!==h||t[78]!==_e||t[79]!==ye||t[80]!==xe?(Se={snapPoint:h,dragging:_,settling:y,settleAt:G,reset:Q,handlePointerDown:le,handlePointerMove:ue,handlePointerUp:_e,handlePointerCancel:ye,handleLostPointerCapture:xe,handleClick:Y,handleKeyDown:me},t[69]=_,t[70]=Y,t[71]=me,t[72]=le,t[73]=ue,t[74]=Q,t[75]=G,t[76]=y,t[77]=h,t[78]=_e,t[79]=ye,t[80]=xe,t[81]=Se):Se=t[81],Se}function D(e,t){return e.height-t.height}function ee(e,t){return e.height-t.height}function te(e,t){return t.height-e.height}function ne(e,t){return e.height-t.height}function re(e){return e.height}function ie(e){return e.height}function O(){}function ae(e){return e.height}var k=.72,A=.98,oe=64,j=()=>Math.max(1,window.innerHeight),M=(e,t)=>{let n=Math.max(1,e)*k;return t==null||!Number.isFinite(t)?n:Math.min(n,Math.max(0,t))},N=e=>{let t=(0,p.c)(20),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{initialSnapPoint:r,fitContent:i,onDismiss:o,dismissThresholdPx:s}=n,c=r===void 0?k:r,l=i!==void 0&&i,u=s===void 0?oe:s,d=f.useRef(null),m=f.useRef(null),h=f.useRef(c),g=o?0:void 0,_;t[2]===l?_=t[3]:(_=()=>{let e=j(),t=d.current?.parentElement?.clientHeight||e;return l&&h.current===.72&&d.current&&!d.current.hasAttribute(`data-height-snap-active`)&&(m.current=M(e,d.current.getBoundingClientRect().height)),[{id:k,height:Math.min(t,M(e,l?m.current:void 0))},{id:A,height:Math.min(t,e*A)}]},t[2]=l,t[3]=_);let v;t[4]!==u||t[5]!==l||t[6]!==o?(v=(e,t,n)=>{let r=d.current?.parentElement?.clientHeight||j(),i=Math.min(r,M(j(),l?m.current:void 0)),a=t<-.55&&n<=i+1&&e<i-8;return!o||!a&&e>i-u?!1:(o(),!0)},t[4]=u,t[5]=l,t[6]=o,t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{h.current=e},t[8]=y):y=t[8];let b;t[9]!==c||t[10]!==g||t[11]!==_||t[12]!==v?(b={surfaceRef:d,initialPoint:c,renderMode:`translate`,minimumHeight:g,getPoints:_,onRelease:v,onCommit:y},t[9]=c,t[10]=g,t[11]=_,t[12]=v,t[13]=b):b=t[13];let x=E(b),S;t[14]!==x||t[15]!==c?(S=()=>{m.current=null,h.current=c,x.reset()},t[14]=x,t[15]=c,t[16]=S):S=t[16];let C=a(S),w;return t[17]!==x||t[18]!==C?(w={...x,surfaceRef:d,reset:C},t[17]=x,t[18]=C,t[19]=w):w=t[19],w},P=e=>{let t=(0,p.c)(12),{controller:n,ariaLabel:r}=e,i;t[0]===n.snapPoint?i=t[1]:(i=Math.round(n.snapPoint*100),t[0]=n.snapPoint,t[1]=i);let a;return t[2]!==r||t[3]!==n.handleClick||t[4]!==n.handleKeyDown||t[5]!==n.handleLostPointerCapture||t[6]!==n.handlePointerCancel||t[7]!==n.handlePointerDown||t[8]!==n.handlePointerMove||t[9]!==n.handlePointerUp||t[10]!==i?(a=(0,m.jsx)(y,{"data-mobile-sheet-snap-handle":!0,role:`separator`,tabIndex:0,"aria-label":r,"aria-orientation":`horizontal`,"aria-valuemin":k*100,"aria-valuemax":A*100,"aria-valuenow":i,className:`flex min-h-8 cursor-ns-resize touch-none justify-center pt-2.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,onPointerDown:n.handlePointerDown,onPointerMove:n.handlePointerMove,onPointerUp:n.handlePointerUp,onPointerCancel:n.handlePointerCancel,onLostPointerCapture:n.handleLostPointerCapture,onClick:n.handleClick,onKeyDown:n.handleKeyDown}),t[2]=r,t[3]=n.handleClick,t[4]=n.handleKeyDown,t[5]=n.handleLostPointerCapture,t[6]=n.handlePointerCancel,t[7]=n.handlePointerDown,t[8]=n.handlePointerMove,t[9]=n.handlePointerUp,t[10]=i,t[11]=a):a=t[11],a},F=new WeakMap;function I(e){F.set(e.currentTarget,!0)}function L(e){if(F.delete(e.currentTarget))return!0;if(e.detail!==0)return!1;if(typeof document>`u`)return!0;let t=document.activeElement,n=e.currentTarget;return n instanceof Node&&t instanceof Node&&n.contains(t)}function R(e){e.target===e.currentTarget&&I(e)}function z(e){return e.target===e.currentTarget&&L(e)}var B=(0,f.createContext)(!0),V=(e,t)=>{let n=`flex min-h-0 flex-col bg-background shadow-none`;if(e===`page`)return`${n} h-full w-full`;let r=`${n} pwa-overlay-panel`;return t===`top`?`${r} mx-auto mb-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-b-xl border-x border-b border-border/50`:t===`left`?`${r} h-full w-[min(86vw,24rem)] rounded-r-xl border-r border-y border-border/50`:t===`right`?`${r} ml-auto h-full w-[min(86vw,24rem)] rounded-l-xl border-l border-y border-border/50`:`${r} mx-auto mt-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-t-2xl border-x border-t border-border/50 pb-[max(0.5rem,var(--yuri-app-bottom-safe,0px),var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px)))]`},H=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),U=(e,t)=>{let n=H(t),r=`${(1-n)*100}%`;return{progress:n,scrimOpacity:n,surfaceOpacity:n,surfaceTransform:e===`left`?`translate3d(-${r}, 0, 0)`:e===`right`?`translate3d(${r}, 0, 0)`:e===`top`?`translate3d(0, -${r}, 0)`:`translate3d(0, ${r}, 0)`}},W=(e,t)=>{let n=H(t);return e===`present`?n:1-n},se=(e,t)=>e===`present`?+(t===`commit`):t===`commit`?0:1,G=e=>+!!e,ce=`mobile-sessions`,le=new Map,K=e=>le.get(e)??null,ue=(e,t)=>(le.set(e,t),()=>{le.get(e)===t&&le.delete(e)}),q=`.overlay-scrollbar-container`,de=1,J=e=>e===`left`||e===`right`?`x`:`y`,fe=e=>e===`bottom`||e===`right`?1:-1,pe=(e,t,n)=>{let r=J(e)===`x`?t:n;return Math.max(0,r*fe(e))},Y=(e,t,n,r,i)=>{let a=pe(e,t,n),o=Math.abs(J(e)===`x`?n:t);return Math.hypot(t,n)>r&&a>0&&o<a*i},X=(e,t)=>Math.min(1,Math.max(0,e/Math.max(1,t))),me=(e,t,n,r)=>Math.min(r,Math.max(n,e*t)),Z=(e,t,n,r,i)=>e>=n||e>=i&&t>=r,Q=(e,t,n,r,i)=>t!==0&&n>0?t*i/n:r>80?0:e,he=(e,t,n=de)=>{if(t===`bottom`)return e.scrollTop<=n;if(t===`top`)return e.scrollTop>=e.scrollHeight-e.clientHeight-n;if(e.matches?.(`:dir(rtl)`)){let r=e.scrollWidth-e.clientWidth;return t===`right`?Math.abs(e.scrollLeft)<=n:Math.abs(e.scrollLeft)>=r-n}return t===`right`?e.scrollLeft<=n:e.scrollLeft>=e.scrollWidth-e.clientWidth-n},$=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=e.item(n);if(r?.identifier===t)return r}return null},ge=(e,t)=>{let n=window.getComputedStyle(e),r=J(t),i=r===`x`?n.overflowX:n.overflowY,a=r===`x`?e.scrollWidth:e.scrollHeight,o=r===`x`?e.clientWidth:e.clientHeight;return(i===`auto`||i===`scroll`||i===`overlay`)&&a>o},_e=(e,t,n,r)=>{let i=t instanceof Element?t:null,a=i instanceof HTMLElement?i:i?.parentElement??null;for(;a&&e.contains(a);){if(ge(a,n))return a;if(a===e)break;a=a.parentElement}let o=i?.closest(r)??null;return o&&e.contains(o)&&ge(o,n)?o:null},ve=e=>{let t=f.useRef(e),n=f.useRef(null),r=f.useRef(null);return t.current=e,f.useCallback(e=>{if(n.current?.(),n.current=null,!e)return;let i=()=>{let e=r.current;r.current=null,e?.active&&e.controller?.finish(`cancel`)},a=(e,t,n)=>{let r=J(e.edge)===`x`?t.clientX:t.clientY,i=n-e.lastTime,a=r-e.lastPrimary;e.velocity=Q(e.velocity,a,i,n-e.lastVelocityTime,fe(e.edge)),a!==0&&i>0&&(e.lastVelocityTime=n),e.lastPrimary=r,e.lastTime=n,e.distance=pe(e.edge,t.clientX-e.startX,t.clientY-e.startY)},o=n=>{i();let a=t.current;if(a.disabled||n.touches.length!==1)return;let o=n.target instanceof Element?n.target:null,s=a.reservedTargetSelector?o?.closest(a.reservedTargetSelector):null;if(s&&e.contains(s)||o?.closest(`input, textarea, select, [contenteditable=""], [contenteditable="true"], [data-mobile-sheet-no-dismiss]`))return;let c=n.touches[0],l=_e(e,n.target,a.edge,a.scrollContainerSelector??q);if(l&&!he(l,a.edge))return;let u=e.getBoundingClientRect(),d=J(a.edge)===`x`?u.width||window.innerWidth:u.height||window.innerHeight;r.current={edge:a.edge,motionId:a.motionId,touchId:c.identifier,startX:c.clientX,startY:c.clientY,lastPrimary:J(a.edge)===`x`?c.clientX:c.clientY,lastTime:n.timeStamp,lastVelocityTime:n.timeStamp,velocity:0,distance:0,commitDistance:me(d,a.commitDistanceRatio??.1,a.minCommitDistance??40,a.maxCommitDistance??64),motionDistance:d,intentDistance:a.intentDistance??8,maxOffAxisRatio:a.maxOffAxisRatio??1,flingVelocity:a.flingVelocity??.65,flingMinDistance:a.flingMinDistance??12,controller:null,active:!1}},s=e=>{let n=r.current;if(!n)return;if(t.current.disabled||e.touches.length!==1){i();return}let o=$(e.touches,n.touchId);if(!o){i();return}if(a(n,o,e.timeStamp),!n.active){if(Math.hypot(o.clientX-n.startX,o.clientY-n.startY)<=n.intentDistance)return;if(!Y(n.edge,o.clientX-n.startX,o.clientY-n.startY,n.intentDistance,n.maxOffAxisRatio)){r.current=null;return}let e=K(n.motionId);if(!e){r.current=null;return}if(!e.begin(`dismiss`)){r.current=null;return}n.active=!0,n.controller=e}n.controller?.update(X(n.distance,n.motionDistance)),e.preventDefault()},c=e=>{let t=r.current;if(!t)return;let n=$(e.changedTouches,t.touchId);if(!n){i();return}if(r.current=null,!t.active)return;a(t,n,e.timeStamp),t.controller?.update(X(t.distance,t.motionDistance));let o=Z(t.distance,t.velocity,t.commitDistance,t.flingVelocity,t.flingMinDistance);t.controller?.finish(o?`commit`:`cancel`),e.preventDefault()},l=()=>i();e.addEventListener(`touchstart`,o,{passive:!0,capture:!0}),e.addEventListener(`touchmove`,s,{passive:!1,capture:!0}),e.addEventListener(`touchend`,c,{passive:!1,capture:!0}),e.addEventListener(`touchcancel`,l,{passive:!0,capture:!0}),n.current=()=>{i(),e.removeEventListener(`touchstart`,o,!0),e.removeEventListener(`touchmove`,s,!0),e.removeEventListener(`touchend`,c,!0),e.removeEventListener(`touchcancel`,l,!0)}},[])},ye=`mobile-overlay-root`,be=200,xe=80,Se=`cubic-bezier(0.32, 0.72, 0, 1)`,Ce=`a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`,we=()=>{if(typeof document>`u`)return null;let e=document.getElementById(ye);return e||(e=document.createElement(`div`),e.id=ye,document.body.appendChild(e)),e},Te=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Ee=({id:e,open:t,onOpenChange:n,keepMounted:r=!1,presentation:i=`sheet`,edge:a=`bottom`,children:s,className:c,scrimClassName:l,surfaceClassName:u,surfaceElementRef:p,dismissGesture:g=!1,onExitComplete:_,onPreviewChange:y,ariaLabel:b})=>{let x=f.useRef(null),S=f.useRef(null),C=f.useRef(null),w=f.useRef(t),T=f.useRef(n),E=f.useRef(_),D=f.useRef(y),ee=f.useRef(0),te=f.useRef(0),ne=f.useRef(null),re=f.useRef([]),ie=f.useRef(null),O=f.useRef(`standard`),ae=f.useRef(`present`),k=f.useRef(0),A=f.useRef(!1),oe=f.useRef(t),j=f.useRef(!1),M=f.useRef(t),N=f.useRef(null),[P,F]=f.useState(t),[I,L]=f.useState(t),[H,ce]=f.useState(`standard`),[le,K]=f.useState(!1),q=H===`interactive-present`,de=f.useSyncExternalStore(d.subscribe,d.getSnapshot,d.getSnapshot),J=I&&!q&&de===e,fe=ve({motionId:e,edge:a,disabled:!g,...typeof g==`object`?g:{}}),pe=f.useCallback(e=>{C.current=e,fe(e),typeof p==`function`?p(e):p&&typeof p==`object`&&(p.current=e)},[fe,p]),Y=f.useCallback(()=>{M.current&&(M.current=!1,L(!1),r||F(!1),E.current?.())},[r]);w.current=t,T.current=n,E.current=_,D.current=y,f.useLayoutEffect(()=>{D.current?.(I&&q)},[I,q]),typeof document<`u`&&!x.current&&(x.current=we());let X=f.useCallback(e=>{let t=U(a,e);ee.current=t.progress,!(!S.current||!C.current)&&(S.current.style.opacity=String(t.scrimOpacity),C.current.style.transform=t.surfaceTransform,C.current.style.opacity=String(t.surfaceOpacity))},[a]),me=f.useCallback(()=>{ne.current!==null&&window.cancelAnimationFrame(ne.current),ne.current=null},[]),Z=f.useCallback(()=>{S.current&&(S.current.style.willChange=``),C.current&&(C.current.style.willChange=``)},[]),Q=f.useCallback((e=re.current)=>{for(let t of e)t.cancel();re.current=[]},[]),he=f.useCallback(()=>{me();let e=ie.current;if(e){let t=e.animations[1]?.effect?.getComputedTiming().progress;X(typeof t==`number`&&Number.isFinite(t)?e.from+(e.target-e.from)*t:ee.current),Q(e.animations),ie.current=null}else Q();Z(),K(!1)},[X,Q,me,Z]),$=f.useCallback((e,t)=>{if(ie.current?.target===e)return;he();let n=ee.current,r=S.current,i=C.current;if(K(!0),!r||!i||Te()||n===e){X(e),Z(),K(!1),t?.();return}let o=U(a,n),s=U(a,e);r.style.willChange=`opacity`,i.style.willChange=`transform, opacity`;let c=Math.max(xe,be*Math.abs(e-n)),l=[r.animate([{opacity:o.scrimOpacity},{opacity:s.scrimOpacity}],{duration:c,easing:Se,fill:`forwards`}),i.animate([{transform:o.surfaceTransform,opacity:o.surfaceOpacity},{transform:s.surfaceTransform,opacity:s.surfaceOpacity}],{duration:c,easing:Se,fill:`forwards`})];re.current=l;let u={from:n,target:e,animations:l};ie.current=u,Promise.all(l.map(e=>e.finished.catch(()=>void 0))).then(()=>{ie.current===u&&(X(e),Q(l),ie.current=null,Z(),K(!1),t?.())})},[X,Q,Z,a,he]);if(f.useLayoutEffect(()=>{j.current=P,P&&X(te.current)},[X,P]),f.useLayoutEffect(()=>{M.current=I},[I]),f.useEffect(()=>{t&&!j.current&&(te.current=ee.current,F(!0)),t&&!M.current&&(M.current=!0,L(!0)),j.current&&O.current===`standard`&&$(G(t),()=>{!w.current&&O.current===`standard`&&Y()})},[Y,t,$]),f.useLayoutEffect(()=>{!P||O.current!==`standard`||$(+!!t,()=>{!w.current&&O.current===`standard`&&Y()})},[Y,P,t,$]),f.useEffect(()=>{if(!(!I||q))return window.dispatchEvent(new Event(`yuri:mobile-overlay-opened`)),()=>{window.dispatchEvent(new Event(`yuri:mobile-overlay-closed`))}},[I,q]),f.useEffect(()=>{if(!(!I||q))return d.add({id:e,onClose:()=>T.current(!1)},document.body)},[I,e,q]),f.useEffect(()=>{if(!I||q||!J)return;let e=C.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null;e?.focus({preventScroll:!0});let n=t=>{if(t.key===`Escape`&&d.closeTop(),t.key!==`Tab`||!e)return;let n=Array.from(e.querySelectorAll(Ce)).filter(e=>!e.closest(`[data-mobile-sheet-snap-handle]`)),r=n[0]??e,i=n.at(-1)??e;t.shiftKey&&document.activeElement===r&&(t.preventDefault(),i.focus({preventScroll:!0})),!t.shiftKey&&document.activeElement===i&&(t.preventDefault(),r.focus({preventScroll:!0}))};return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n),v()||t?.focus({preventScroll:!0})}},[I,q,J]),N.current={begin:e=>{if(e===`dismiss`&&(!M.current||O.current===`interactive-present`))return!1;he(),k.current+=1,A.current=!0,ae.current=e;let t=e===`present`?`interactive-present`:`interactive-dismiss`;return O.current=t,ce(t),K(!0),e===`present`&&(te.current=ee.current,M.current=!0,L(!0),F(!0)),!0},update:e=>{A.current&&(te.current=W(ae.current,e),ne.current===null&&(ne.current=window.requestAnimationFrame(()=>{ne.current=null,A.current&&X(te.current)})))},finish:e=>{if(!A.current)return;A.current=!1;let t=k.current,n=ae.current,r=se(n,e);ne.current!==null&&(me(),X(te.current)),$(r,()=>{t===k.current&&(e===`commit`&&T.current(n===`present`),n===`present`&&e===`cancel`&&!w.current&&Y(),O.current=`standard`,ce(`standard`),r===0&&Y())})},interrupt:()=>{k.current+=1,A.current=!1;let e=O.current===`interactive-present`&&!w.current;e||(O.current=`standard`,ce(`standard`)),he(),$(G(w.current),()=>{w.current||Y(),e&&(O.current=`standard`,ce(`standard`))})}},f.useLayoutEffect(()=>{let e=oe.current;oe.current=t,e&&!t&&O.current!==`standard`&&N.current?.interrupt()},[t]),f.useEffect(()=>{let t=ue(e,{begin:e=>N.current?.begin(e)??!1,update:e=>N.current?.update(e),finish:e=>N.current?.finish(e),interrupt:()=>N.current?.interrupt()});return()=>{t(),me(),Q(),ie.current=null,Z(),N.current=null}},[Q,me,Z,e]),!P||!x.current)return null;let ge=(0,m.jsx)(`div`,{ref:S,className:o(`yuri-mobile-window-motion yuri-keyboard-inset-surface fixed inset-0 z-[60] flex flex-col bg-[rgb(0_0_0_/_0.45)]`,le&&`yuri-mobile-window-motion-active`,!I&&!q&&`pointer-events-none invisible`,l,c),"data-mobile-overlay-active":String(I),role:q?void 0:`dialog`,"aria-label":q?void 0:b,"aria-modal":I&&J?`true`:void 0,"aria-hidden":q||!I||!J||void 0,inert:q||!I||!J||void 0,onPointerDown:R,onClick:e=>{!I||q||!J||z(e)&&T.current(!1)},children:(0,m.jsx)(`div`,{ref:pe,tabIndex:-1,className:o(`yuri-mobile-floating-shell`,V(i,a),u),"data-yuri-motion-id":e,style:{contain:`layout paint style`},onClick:e=>e.stopPropagation(),children:(0,m.jsx)(B.Provider,{value:J,children:s})})});return(0,h.createPortal)(ge,x.current)},De=f.createContext(null),Oe=e=>{let t=(0,p.c)(5),{children:n}=e,r=f.useContext(De);if(!r)return null;let i;t[0]===n?i=t[1]:(i=(0,m.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,h.createPortal)(i,r),t[2]=r,t[3]=i,t[4]=a):a=t[4],a},ke=e=>{let t=(0,p.c)(47),{id:n,open:r,onOpenChange:i,title:a,leading:c,trailing:l,ariaLabel:d,closeAriaLabel:h,resizeAriaLabel:g,initiallyExpanded:_,fitContent:v,bodyClassName:y,className:b,children:x}=e,S=_!==void 0&&_,C=v!==void 0&&v,w=S?A:void 0,T;t[0]!==i||t[1]!==r?(T=r?()=>i(!1):void 0,t[0]=i,t[1]=r,t[2]=T):T=t[2];let E;t[3]!==C||t[4]!==w||t[5]!==T?(E={initialSnapPoint:w,fitContent:C,onDismiss:T},t[3]=C,t[4]=w,t[5]=T,t[6]=E):E=t[6];let D=N(E),[ee,te]=f.useState(null),ne=a!=null||c!=null||l!=null,re=D.snapPoint===A,ie=re||!C,O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(O={reservedTargetSelector:`[data-mobile-sheet-snap-handle]`},t[7]=O):O=t[7];let ae=re?`h-[98dvh] max-h-[98dvh]`:C?`h-auto max-h-[72dvh]`:`h-[72dvh] max-h-[98dvh]`,k=D.surfaceRef,oe=D.reset,j=ie&&`flex-1`,M;t[8]===j?M=t[9]:(M=o(`flex min-h-0 flex-col`,j),t[8]=j,t[9]=M);let F;t[10]!==g||t[11]!==D?(F=(0,m.jsx)(P,{controller:D,ariaLabel:g}),t[10]=g,t[11]=D,t[12]=F):F=t[12];let I;t[13]!==h||t[14]!==C||t[15]!==ne||t[16]!==c||t[17]!==i||t[18]!==a||t[19]!==l?(I=ne?(0,m.jsxs)(`div`,{className:C?`flex min-h-9 items-center gap-2 px-4 pb-1`:`flex min-h-10 items-center gap-2 px-4 pb-2`,children:[c?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center`,children:c}):null,(0,m.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),l?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:l}):null,(0,m.jsx)(`div`,{ref:te,className:`contents`}),(0,m.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i(!1),"aria-label":h,className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,m.jsx)(u,{name:`close`,className:`size-5`})})]}):null,t[13]=h,t[14]=C,t[15]=ne,t[16]=c,t[17]=i,t[18]=a,t[19]=l,t[20]=I):I=t[20];let L;t[21]!==F||t[22]!==I?(L=(0,m.jsxs)(`div`,{className:`shrink-0`,children:[F,I]}),t[21]=F,t[22]=I,t[23]=L):L=t[23];let R=ie&&`flex-1`,z;t[24]!==y||t[25]!==R?(z=o(`flex min-h-0 flex-col overflow-hidden`,R,y),t[24]=y,t[25]=R,t[26]=z):z=t[26];let B;t[27]!==x||t[28]!==z?(B=(0,m.jsx)(`div`,{className:z,"data-page-scroll-lock":`true`,children:x}),t[27]=x,t[28]=z,t[29]=B):B=t[29];let V;t[30]!==M||t[31]!==L||t[32]!==B?(V=(0,m.jsxs)(`div`,{className:M,children:[L,B]}),t[30]=M,t[31]=L,t[32]=B,t[33]=V):V=t[33];let H;t[34]!==d||t[35]!==b||t[36]!==n||t[37]!==i||t[38]!==r||t[39]!==D.reset||t[40]!==D.surfaceRef||t[41]!==V||t[42]!==ae?(H=(0,m.jsx)(Ee,{id:n,className:b,open:r,onOpenChange:i,presentation:`sheet`,edge:`bottom`,dismissGesture:O,ariaLabel:d,surfaceClassName:ae,surfaceElementRef:k,onExitComplete:oe,children:V}),t[34]=d,t[35]=b,t[36]=n,t[37]=i,t[38]=r,t[39]=D.reset,t[40]=D.surfaceRef,t[41]=V,t[42]=ae,t[43]=H):H=t[43];let U;return t[44]!==ee||t[45]!==H?(U=(0,m.jsx)(De.Provider,{value:ee,children:H}),t[44]=ee,t[45]=H,t[46]=U):U=t[46],U};export{_ as C,v as S,P as _,pe as a,E as b,Y as c,K as d,B as f,z as g,R as h,me as i,Z as l,I as m,Oe as n,X as o,L as p,Ee as r,Q as s,ke as t,ce as u,A as v,y as x,N as y};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-push-notifications-D5cqJIPw.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/assistant-attachment-cache-lEUFn3mr.js","assets/runtime-auth-ef9W7A43.js","assets/runtime-switch-CAZiOV2G.js","assets/runtime-fetch-BAN5Gnnp.js","assets/runtime-file-resource-D3k0hKDj.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/queryRuntime-BuRnpVtK.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/fileQueries-DbUx7NwP.js","assets/vendor-base-ui-CdzJ6My_.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/path-utils-jGozTg9d.js","assets/useAssistantUIStore-rdsbsVts.js","assets/vendor-zustand-o69pgTEK.js","assets/useUIStore-NMQx_cnG.js","assets/brand-storage-bootstrap-D4BW3w-M.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{E as n,b as r,w as i}from"./runtime-auth-ef9W7A43.js";import{c as a,i as o,l as s,n as c,r as l,t as u}from"./runtime-switch-CAZiOV2G.js";import{n as d}from"./runtime-fetch-BAN5Gnnp.js";import{it as f,rt as p}from"./vendor-base-ui-CdzJ6My_.js";import{n as m,r as h,t as g}from"./platform-DXeTzJHG.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as _}from"./useUIStore-NMQx_cnG.js";import{$ as v,bt as y,kt as b,tt as ee,yt as x}from"./persistence-BfjCXjLZ.js";import{n as te}from"./vendor-react-BP2cRVqX.js";import{a as ne}from"./runtime-file-resource-D3k0hKDj.js";import{a as re,n as S,o as C,t as ie}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as w}from"./vendor-reactuses-core-BJ-jJ4YM.js";import{f as ae}from"./button-DFX-UCuQ.js";import{N as oe,c as T,l as se,m as ce,s as le,t as ue,w as de}from"./MobileDetailNavigation-BtLQo_Rl.js";import{So as E,o as fe}from"./useMobileNavigationStore-CjljWARe.js";import{i as D,n as pe}from"./useAssistantUIStore-rdsbsVts.js";import{i as me,t as he}from"./AgentAvatar-DJCC3Aqe.js";import{n as ge}from"./Icon-C1nXIg7J.js";import{n as _e,t as ve}from"./dialog-jQrYy1B7.js";import{t as ye}from"./rasterizePng-056Poix7.js";var O=t(f(),1),be=te(),xe=e=>`yuri.${e}PushOnboardingAttempted`,Se=e=>{if(typeof window>`u`)return!0;try{return window.localStorage.getItem(xe(e))===`1`}catch{return!0}},Ce=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(xe(e),`1`)}catch{}},we=()=>{Se(`ios`)||(Ce(`ios`),C(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([0,1,2])).then(async({PushNotifications:e})=>{(await e.checkPermissions().catch(()=>null))?.receive!==`granted`&&await e.requestPermissions().catch(()=>null)}).catch(()=>void 0))},Te=()=>{Se(`android`)||Ce(`android`)},Ee=()=>{if(typeof window>`u`)return;let e=g();if(e!==`ios`&&e!==`android`)return;let t=_.getState();if(t.nativeNotificationsEnabled||t.setNativeNotificationsEnabled(!0),e===`ios`){we();return}Te()},De=`yuri.mobile.connections.v1`,Oe=`yuri.mobile.`,ke=`yuri.mobile.deviceId`,Ae=()=>{try{let e=window.localStorage.getItem(ke);if(e&&e.trim())return e.trim();let t=v();return window.localStorage.setItem(ke,t),t}catch{return v()}},je=()=>`mobile:${Ae()}`,Me=()=>{try{let e=S.getPlatform();return e===`ios`||e===`android`?e:void 0}catch{return}},Ne=12,Pe=8e3,Fe=2500,Ie=3e3,Le=2500,k=e=>{let t=e.trim();if(!t)return``;let n=/^https?:\/\//i.test(t)?t:`http://${t}`,r=new URL(n);return r.hash=``,r.search=``,r.pathname=r.pathname.replace(/\/+$/,``),r.toString().replace(/\/+$/,``)},Re=e=>{try{return new URL(e).host}catch{return e}},A=e=>{try{return k(e)}catch{return e.trim().replace(/\/+$/g,``)}},ze=(e,t)=>A(e)===A(t),Be=e=>`relay:${e.serverId}@${e.relayUrl.trim()}`,Ve=e=>`relay://${e.serverId}`,He=e=>e.candidates.filter(e=>e.kind===`direct`),j=e=>{let t=e.candidates.find(e=>e.kind===`relay`);return t&&t.kind===`relay`?t.relay:null},M=e=>{let t=He(e)[0];if(t)return t.url;let n=j(e);return n?Ve(n):``},N=e=>{let t=j(e);if(t)return Be(t);let n=He(e)[0];return n?A(n.url):``},Ue=N,We=(e,t)=>{let n=e.find(e=>e.kind===`relay`),r=n&&n.kind===`relay`?n.relay.serverId:null,i=n&&n.kind===`relay`?n.relay.relayUrl.trim():null,a=new Set(e.filter(e=>e.kind===`direct`).map(e=>A(e.url)));return t.some(e=>e.kind===`relay`?r!==null&&e.relay.serverId===r&&e.relay.relayUrl.trim()===i:a.has(A(e.url)))},Ge=(e,t)=>t.id&&e.id===t.id?!0:We(e.candidates,t.candidates),Ke=e=>{let t=(()=>{try{return k(e)}catch{return``}})();return t?[{kind:`direct`,url:t}]:[]},qe=e=>{if(e.candidates&&e.candidates.length>0)return e.candidates;let t=[];return typeof e.url==`string`&&e.url.trim()&&!/^relay:\/\//i.test(e.url.trim())&&t.push(...Ke(e.url)),e.relay&&t.push({kind:`relay`,relay:e.relay}),t},Je=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(typeof t.relayUrl!=`string`||!t.relayUrl.trim()||typeof t.serverId!=`string`||!t.serverId.trim())return null;let n=t.hostEncPubJwk;if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n;return r.kty!==`EC`||r.crv!==`P-256`||typeof r.x!=`string`||!r.x||typeof r.y!=`string`||!r.y?null:{relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:{kty:`EC`,crv:`P-256`,x:r.x,y:r.y}}},Ye=e=>{try{return JSON.stringify(e)}catch{return String(e)}},P=(e,t={})=>{Ye(t)},F=(e,t={})=>{Ye(t)},Xe=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},Ze=e=>{if(typeof e!=`string`)return e??void 0;try{return JSON.parse(e)}catch{return e}},Qe=async(e,t)=>{if(!m())return null;try{let{CapacitorHttp:n}=await C(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),r=Object.fromEntries(new Headers(t?.headers).entries()),i=await n.request({url:e,method:t?.method||`GET`,headers:r,data:Ze(t?.body)});return{ok:i.status>=200&&i.status<300,status:i.status,source:`native-http`,json:async()=>Xe(i.data)}}catch(t){return console.warn(`[mobile-connect]`,`native-http failed`,Ye({url:e,error:t instanceof Error?t.message:String(t)})),null}},$e=async(e,t)=>{let n=await fetch(e,t).catch(t=>(console.warn(`[mobile-connect]`,`browser-fetch failed`,Ye({url:e,error:t instanceof Error?t.message:String(t)})),null));return n?{ok:n.ok,status:n.status,source:`browser-fetch`,json:()=>n.json()}:null},I=async(e,t,n)=>{let r,i=new Promise(t=>{r=window.setTimeout(()=>{n?.(),t(null)},e)});try{return await Promise.race([t,i])}catch{return null}finally{r!==void 0&&window.clearTimeout(r)}},L=async(e,t,n)=>{let r=n?.totalTimeoutMs??Pe,i=Date.now(),a=await I(Math.min(Fe,r),Qe(e,t));if(a)return a;let o=new AbortController;return I(Math.max(500,r-(Date.now()-i)),$e(e,{...t,signal:o.signal}),()=>o.abort())},et=async e=>{if(!e)return null;let t=await e.json().catch(()=>null);if(!t||typeof t!=`object`)return null;let n=t;return{authenticated:typeof n.authenticated==`boolean`?n.authenticated:void 0,disabled:typeof n.disabled==`boolean`?n.disabled:void 0,scope:typeof n.scope==`string`?n.scope:void 0}},R=15e3,tt=async(e,t,r,i=R,a)=>{let o=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...r?{grant:r}:{}}),s=e=>e===`ok`&&a?.keepTunnel?{outcome:e,tunnel:o}:(o.close(),{outcome:e});try{let e=t?{Authorization:`Bearer ${t}`}:void 0,n=await I(i,o.fetch(`/auth/session`,{headers:e}).catch(()=>null));if(P(`relay:session`,{ok:n?.ok===!0,status:n?.status??null,hasToken:!!t}),!n)return s(`unreachable`);if(n.status===401)return s(t?`auth-failed`:`needs-login`);if(!n.ok&&n.status!==404)return s(`auth-failed`);let r=await et(n);return r&&r.disabled!==!0&&r.authenticated===!1?s(t?`auth-failed`:`needs-login`):s(`ok`)}catch(e){throw o.close(),e}},nt=(e,t,n,i,a)=>{let o=typeof window<`u`?window.location.origin:``,c={relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...n?{grant:n}:{}};a&&r(c,a),s({apiBaseUrl:o,clientToken:t,runtimeKey:i??Be(e),relay:c})},rt=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.kind===`direct`)return typeof t.url==`string`&&t.url.trim()?{kind:`direct`,url:t.url}:null;if(t.kind===`relay`){let e=Je(t.relay);return e?{kind:`relay`,relay:e}:null}return null},it=e=>{if(e.mode===`relay`){let t=Je(e.relay);return t?[{kind:`relay`,relay:t}]:[]}return typeof e.url==`string`?Ke(e.url):[]},z=()=>{if(typeof window>`u`)return[];let e;try{e=JSON.parse(window.localStorage.getItem(De)||`[]`)}catch{return[]}if(!Array.isArray(e))return[];let t=m();return e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let n=e;if(typeof n.id!=`string`)return[];let r=Array.isArray(n.candidates)?n.candidates.map(rt).filter(e=>!!e):it(n);if(r.length===0)return[];let i=typeof n.clientToken==`string`&&n.clientToken.trim()?n.clientToken:void 0,a=typeof n.label==`string`&&n.label.trim()?n.label:Re(M({candidates:r})),o={id:n.id,label:a,candidates:r,lastUsedAt:typeof n.lastUsedAt==`number`?n.lastUsedAt:0};return t?[{...o,hasToken:!!n.hasToken||!!i}]:[{...o,clientToken:i,hasToken:!!i}]}).sort((e,t)=>t.lastUsedAt-e.lastUsedAt)},at=e=>e.kind===`relay`?{kind:`relay`,relay:{relayUrl:e.relay.relayUrl,serverId:e.relay.serverId,hostEncPubJwk:e.relay.hostEncPubJwk}}:{kind:`direct`,url:e.url},B=e=>{if(typeof window>`u`)return;let t=m(),n=e.slice(0,Ne).map(e=>{let n={id:e.id,label:e.label,candidates:e.candidates.map(at),lastUsedAt:e.lastUsedAt};return t?{...n,hasToken:!!(e.hasToken||e.clientToken)}:{...n,clientToken:e.clientToken}});try{window.localStorage.setItem(De,JSON.stringify(n))}catch(e){throw console.warn(`[mobile-storage] failed to persist connection metadata`,e),e}},ot=(e,t,n=!0)=>{let r=e.find(e=>Ge(e,t)),i=m(),a={id:t.id||r?.id||v(),label:t.label,candidates:t.candidates,lastUsedAt:n?Date.now():r?.lastUsedAt??0,...i?{hasToken:t.hasToken??(!!t.clientToken||r?.hasToken||!1)}:{clientToken:t.clientToken??r?.clientToken,hasToken:!!(t.clientToken??r?.clientToken)}};return[a,...e.filter(e=>e.id!==a.id&&!Ge(e,t))].sort((e,t)=>t.lastUsedAt-e.lastUsedAt).slice(0,Ne)},st=ie,ct=0,lt=e=>`${Oe}token.${encodeURIComponent(e)}`,ut=async(e,t)=>{let n,r=new Promise(e=>{n=window.setTimeout(()=>e(t),Ie)});try{return await Promise.race([e.catch(()=>t),r])}finally{n!==void 0&&window.clearTimeout(n)}},dt=async(e,t,n)=>m()?ut(t().catch(t=>(console.warn(`[mobile-storage] ${e} failed`,t),n)),n):n,V=async e=>{F(`secure:read-start`,{key:e});let t=await dt(`secure:read`,async()=>(await st.internalGetItem({prefixedKey:lt(e),sync:!1})).data,null),n=typeof t==`string`&&t.trim()?t:void 0;return F(`secure:read`,{key:e,hasToken:!!n}),n},H=async(e,t)=>{F(`secure:write-start`,{key:e});let n=await dt(`secure:write`,async()=>(await st.internalSetItem({prefixedKey:lt(e),data:t,sync:!1,access:ct}),!0),!1);return F(`secure:write`,{key:e,ok:n}),n},ft=async e=>{await dt(`secure:delete`,async()=>(await st.internalRemoveItem({prefixedKey:lt(e),sync:!1}),!0),!1)},pt=async()=>{if(typeof window>`u`||!m())return;let e;try{e=JSON.parse(window.localStorage.getItem(De)||`[]`)}catch{return}if(!Array.isArray(e))return;let t=e.filter(e=>!!e&&typeof e==`object`&&typeof e.url==`string`&&typeof e.clientToken==`string`&&!!e.clientToken.trim());if(t.length!==0){F(`secure:migrate-start`,{count:t.length});for(let{url:e,clientToken:n}of t)await H(A(e),n);B(z()),F(`secure:migrate-done`,{count:t.length})}},mt=async()=>(await pt(),z()),ht=async e=>{let t=ot(z(),e);if(B(t),m()&&e.clientToken){let n=t[0];n&&await H(N(n),e.clientToken)}return t},gt=async e=>{let t=z(),n=t.find(t=>t.id===e)??null,r=t.filter(t=>t.id!==e);if(n){let e;if(m())try{e=await V(N(n))||void 0}catch{e=void 0}else typeof n.clientToken==`string`&&n.clientToken.trim()&&(e=n.clientToken.trim());if(e)try{let{clearAssistantAttachmentCacheForBearer:t}=await C(async()=>{let{clearAssistantAttachmentCacheForBearer:e}=await import(`./assistant-attachment-cache-lEUFn3mr.js`).then(e=>e.t);return{clearAssistantAttachmentCacheForBearer:e}},__vite__mapDeps([3,1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,2]));await t(e,`forget-connection`)}catch{}}if(B(r),n&&m()&&await ft(N(n)),n){let e=N(n);try{let{useAssistantUIStore:t}=await C(async()=>{let{useAssistantUIStore:e}=await import(`./useAssistantUIStore-rdsbsVts.js`).then(e=>e.a);return{useAssistantUIStore:e}},__vite__mapDeps([18,1,5,4,19,12,20,21,16]));t.getState().removeCatalogPartition(e);let{publishNativeAssistantCatalog:n}=await C(async()=>{let{publishNativeAssistantCatalog:e}=await Promise.resolve().then(()=>ln);return{publishNativeAssistantCatalog:e}},void 0);await n().catch(()=>void 0)}catch{console.warn(`[mobile-storage] connection catalog cleanup failed`)}}return r},_t=1500,U=async(e,t,n)=>{let r=n?.fast?{totalTimeoutMs:Le}:void 0,i=j({candidates:e})?.serverId??null,a=e.find(e=>e.kind===`relay`)??null,o=e.filter(e=>e.kind===`direct`),s=async()=>{for(let e of o){let n=k(e.url)||e.url,a=t?{Authorization:`Bearer ${t}`}:void 0,o=await L(`${n}/health`,{method:`GET`},r);if(!o?.ok)continue;if(i){let e=await o.json().catch(()=>null),t=e&&typeof e==`object`?e.serverId:null;if(typeof t==`string`&&t&&t!==i){P(`probe:server-id-mismatch`,{url:n});continue}}let s=await L(`${n}/auth/session`,{method:`GET`,credentials:`include`,headers:a},r);if(s?.status===401)return{status:`needs-login`};if(!s||!s.ok&&s.status!==404)continue;let c=await et(s);if(c&&c.disabled!==!0&&c.authenticated===!1)return{status:`needs-login`};let l=c?.disabled===!0;return!t&&m()&&!l&&c?.scope!==`client`?{status:`needs-login`}:{status:`ok`,transport:{kind:`direct`,url:n}}}return{status:`unreachable`}},c=async()=>{if(!a)return{status:`unreachable`};let{outcome:e,tunnel:r}=await tt(a.relay,t,void 0,n?.fast?Le:void 0,{keepTunnel:!0});return e===`ok`?{status:`ok`,transport:{kind:`relay`,relay:a.relay,tunnel:r}}:e===`needs-login`||e===`auth-failed`?{status:`needs-login`}:{status:`unreachable`}};return a?o.length===0?c():new Promise(e=>{let t=!1,n=!1,r,i=null,a=null,o=e=>{e?.status===`ok`&&e.transport.kind===`relay`&&e.transport.tunnel?.close()},l=n=>{t||(t=!0,e(n))},u=()=>{n||t||(r!==void 0&&(window.clearTimeout(r),r=void 0),c().then(e=>{if(a=e,t||n){o(e);return}if(e.status===`ok`||e.status===`needs-login`){l(e);return}i&&l(i)}))};s().then(e=>{if(i=e,!t){if(e.status===`ok`||e.status===`needs-login`){n=!0,r!==void 0&&window.clearTimeout(r),o(a),l(e);return}if(a){l(a);return}u()}}),r=window.setTimeout(u,_t)}):s()},W=(e,t,n)=>{e.kind===`relay`?nt(e.relay,t,n?.grant,n?.runtimeKey,e.tunnel):s({apiBaseUrl:e.url,clientToken:t,runtimeKey:n?.runtimeKey}),Mt()},vt=()=>{let e=z()[0];return e?.label?.trim()?e.label:null},yt=async()=>{await pt();let e=z()[0];if(!e)return!1;let t;if(m()){if(!e.hasToken||(t=await V(N(e)),!t))return!1}else if(t=e.clientToken,!t)return!1;let n=await U(e.candidates,t);return n.status===`ok`&&(await ht({id:e.id,label:e.label,candidates:e.candidates}),W(n.transport,t,{runtimeKey:N(e)}),!0)},bt=async(e,t)=>{let n=(await mt()).find(t=>N(t)===e);if(!n)return`missing`;let r=m()?n.hasToken?await V(e):void 0:n.clientToken;if(!r)return`auth-required`;let i=t?.transportPreference===`relay`?n.candidates.filter(e=>e.kind===`relay`):n.candidates;if(i.length===0)return`offline`;let a=await U(i,r,{fast:!0});return a.status===`needs-login`?`auth-required`:a.status===`ok`?(W(a.transport,r,{runtimeKey:e}),`connected`):`offline`},xt=async(e,t)=>{let n=``;try{n=k(e.url)}catch{return!1}if(!n)return!1;let r=e.clientToken?.trim()||void 0,i=r?{Authorization:`Bearer ${r}`}:void 0,a=t?.fast?{totalTimeoutMs:Le}:void 0;if(!(await L(`${n}/health`,{method:`GET`,headers:i},a))?.ok)return!1;let o=await L(`${n}/auth/session`,{method:`GET`,credentials:`include`,headers:i},a);if(!o||!o.ok&&o.status!==404)return!1;let s=await et(o);return!(s&&s.disabled!==!0&&s.authenticated===!1)},St=e=>[...e].sort((e,t)=>{let n=(e.priority??100)-(t.priority??100);if(n!==0)return n;let r=e=>e.type===`relay`?2:+!e.url.startsWith(`https://`);return r(e)-r(t)}).flatMap(e=>{if(e.type===`relay`){let t=Je({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return t?[{kind:`relay`,relay:t}]:[]}return Ke(e.url)}),Ct=async e=>{let t=j({candidates:e})?.serverId??null;for(let r of e){if(r.kind===`relay`){let e=n(r.relay),t=await I(R,e.fetch(`/health`).catch(()=>null));if(P(`establish:relay:health`,{ok:t?.ok===!0,status:t?.status??null}),t?.ok)return{kind:`relay`,relay:r.relay,tunnel:e};e.close();continue}let e=k(r.url)||r.url,i=await L(`${e}/health`,{method:`GET`});if(P(`establish:direct:health`,{ok:i?.ok===!0,status:i?.status??null}),i?.ok){if(t){let n=await i.json().catch(()=>null),r=n&&typeof n==`object`?n.serverId:null;if(typeof r==`string`&&r&&r!==t){P(`establish:server-id-mismatch`,{url:e});continue}}return{kind:`direct`,url:e}}}return null},wt=async(e,t)=>{if(!i())return xt(e,t);let n=await I(t?.fast?Le:R,d(`/auth/session`).then(e=>e).catch(()=>null));if(!n)return!0;if(n.status===401)return!1;if(!n.ok&&n.status!==404)return!0;let r=await et(n);return!(r&&r.disabled!==!0&&r.authenticated===!1)},Tt=e=>e.kind===`relay`?i():!i()&&ze(e.url,u()),Et=()=>{let e=l();return e?z().find(t=>N(t)===e)??null:null},Dt=e=>{let t=l();return!!t&&N(e)===t},Ot=async()=>{let e=Et();if(!e)return`no-connection`;let t;if(t=m()?e.hasToken?await V(N(e)):void 0:e.clientToken,!t)return`unreachable`;let n=e.candidates.findIndex(e=>Tt(e.kind===`relay`?{kind:`relay`,relay:e.relay}:{kind:`direct`,url:e.url})),r=await U(n>=0?e.candidates.slice(0,n):e.candidates,t,{fast:!0});if(r.status===`ok`)return await ht({id:e.id,label:e.label,candidates:e.candidates}),W(r.transport,t,{runtimeKey:N(e)}),`switched`;if(r.status===`needs-login`)return`unreachable`;if(n>=0&&await wt({url:u(),clientToken:t},{fast:!0}))return Mt(),`unchanged`;let i=await U(n>=0?e.candidates.slice(n+1):[],t,{fast:!0});return i.status===`ok`?(await ht({id:e.id,label:e.label,candidates:e.candidates}),W(i.transport,t,{runtimeKey:N(e)}),`switched`):`unreachable`},kt=5e3,At=!1,jt=async()=>{if(At)return`skipped`;let e=Et();if(!e)return P(`candidates:refresh-skip`,{reason:`no-active-connection`}),`skipped`;let t=j(e);if(!t)return P(`candidates:refresh-skip`,{reason:`no-relay-candidate`}),`skipped`;At=!0;try{let n=await I(R,d(`/api/client-auth/connection/candidates`).then(e=>e).catch(()=>null));if(!n?.ok)return P(`candidates:refresh-skip`,{reason:`fetch-failed`,status:n?.status??null}),`skipped`;let r=await n.json().catch(()=>null);if(!r||r.serverId!==t.serverId)return P(`candidates:refresh-skip`,{reason:`server-id-mismatch`}),`skipped`;let i=Array.isArray(r.candidates)?r.candidates:[],a=[];for(let e of i){if(!e||typeof e!=`object`)continue;let t=e;if(t.type===`lan`&&typeof t.url==`string`)try{let e=k(t.url);e&&!a.includes(e)&&a.push(e)}catch{}}if(a.length===0)return P(`candidates:refresh-skip`,{reason:`no-lan-reported`}),`skipped`;let o=He(e).filter(e=>e.url.startsWith(`https://`)),s=[...a.map(e=>({kind:`direct`,url:e})),...o,{kind:`relay`,relay:t}];return JSON.stringify(e.candidates.map(at))===JSON.stringify(s.map(at))?`unchanged`:(P(`candidates:refreshed`,{lanCount:a.length}),await ht({id:e.id,label:e.label,candidates:s}),`updated`)}finally{At=!1}},Mt=()=>{typeof window>`u`||window.setTimeout(()=>{(async()=>{let e=await jt().catch(()=>`skipped`);P(`candidates:refresh-result`,{result:e}),e===`updated`&&i()&&await Ot().catch(()=>null)})()},kt)},Nt=e=>{let{t}=ae(),[n,r]=O.useState(()=>z()),[i,a]=O.useState(null),[o,s]=O.useState(null),[c,l]=O.useState(null),u=O.useRef(n),d=O.useRef(0),f=O.useRef(null),p=O.useRef(new Set),h=w(()=>{Ee(),e(),p.current.forEach(e=>e())}),g=w(e=>(p.current.add(e),()=>p.current.delete(e))),_=w(e=>{d.current+=1,u.current=e,r(e)}),y=w(e=>{f.current=e,a(e)}),b=w(e=>{f.current===e&&(f.current=null,a(null))}),ee=w(()=>s(t(`mobile.connect.history.updateFailed`)));O.useEffect(()=>{let e=!1,t=d.current;return mt().then(n=>{!e&&d.current===t&&_(n)}).catch(()=>{e||ee()}),()=>{e=!0}},[_,ee]);let x=w((e,t=!0)=>{let n=ot(u.current,e,t);return B(n),_(n),n}),te=w(async e=>{if(!f.current){s(null),y(`connect`);try{let n=qe(e);if(n.length===0){s(t(`mobile.connect.error.urlRequired`));return}let r=e.id?u.current.find(t=>t.id===e.id):u.current.find(e=>We(e.candidates,n)),i=e.label?.trim()||r?.label||Re(M({candidates:n})),a=e.relayGrant,o=e.clientToken?.trim()||void 0,c=!!o;o||(m()?r?.hasToken&&(o=await V(N(r))):o=r?.clientToken),P(`connect:start`,{candidates:n.map(e=>e.kind),hasToken:!!o});let d=await U(n,o);if(P(`connect:probe`,{status:d.status}),d.status===`unreachable`){s(t(`mobile.connect.error.unreachable`));return}if(d.status===`needs-login`){x({id:r?.id,label:i,candidates:n},!1),l({id:r?.id??v(),label:i,candidates:n,relay:j({candidates:n})??void 0,relayGrant:a});return}let f=N({candidates:n});o&&c&&m()&&await H(f,o),x({id:r?.id,label:i,candidates:n,clientToken:o}),W(d.transport,o??null,{runtimeKey:f,grant:a}),h()}catch(e){console.warn(`[mobile-connect] connect threw`,e),s(t(`mobile.connect.error.invalidUrl`))}finally{b(`connect`)}}}),ne=w(async e=>{if(f.current)return;s(null),y(`pairing`);let n=St(e.candidates),r=null,i=!1;try{if(r=await Ct(n),!r){s(t(`mobile.connect.error.unreachable`));return}let a={method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({pairingId:e.pairingId,secret:e.secret,clientLabel:`Yuri Mobile`,clientKind:`mobile`,deviceName:`Yuri Mobile`,devicePlatform:Me(),dedupeKey:je()})},o=r.kind===`relay`?await I(R,r.tunnel.fetch(`/api/client-auth/pairing/redeem`,a).catch(()=>null)):await L(`${r.url}/api/client-auth/pairing/redeem`,a);if(!o?.ok){s(t(`mobile.connect.error.authRequired`));return}let c=await o.json().catch(()=>null),l=typeof c?.clientToken==`string`?c.clientToken.trim():``;if(!l){s(t(`mobile.connect.error.authRequired`));return}let u=typeof c?.server?.label==`string`?c.server.label:``,d=e.label||u||Re(M({candidates:n})),f=N({candidates:n});if(m()&&!await H(f,l)){s(t(`mobile.connect.error.authRequired`));return}x({label:d,candidates:n,clientToken:l}),W(r.kind===`relay`?{kind:`relay`,relay:r.relay,tunnel:r.tunnel}:{kind:`direct`,url:r.url},l,{runtimeKey:f}),i=r.kind===`relay`,h()}catch(e){console.warn(`[mobile-connect] pairing threw`,e),s(t(`mobile.connect.error.authRequired`))}finally{!i&&r?.kind===`relay`&&r.tunnel.close(),b(`pairing`)}}),re=w(async e=>{if(!c||!e.trim()||f.current)return;s(null),y(`password`);let{id:n,label:r,candidates:i}=c,a=null,o=!1;try{if(a=await Ct(i),!a){s(t(`mobile.connect.error.unreachable`));return}let c={method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({password:e,trustDevice:!0,issueClientToken:!0,clientLabel:`Yuri Mobile`,clientKind:`mobile`,devicePlatform:Me(),dedupeKey:je()})};P(`password:start`,{transport:a.kind});let u=a.kind===`relay`?await I(R,a.tunnel.fetch(`/auth/session`,c).catch(()=>null)):await L(`${a.url}/auth/session`,c);if(P(`password:done`,{ok:u?.ok===!0,status:u?.status??null}),!u?.ok){s(t(`mobile.connect.error.passwordFailed`));return}let d=await u.json().catch(()=>null),f=typeof d?.clientToken==`string`?d.clientToken.trim():``;if(P(`password:token`,{issued:!!f}),!f){if(a.kind===`direct`&&!m()){x({id:n,label:r,candidates:i}),l(null),W({kind:`direct`,url:a.url},null,{runtimeKey:N({candidates:i})}),h();return}s(t(`mobile.connect.error.authRequired`));return}m()&&await H(N({candidates:i}),f),x({id:n,label:r,candidates:i,clientToken:f}),l(null),W(a.kind===`relay`?{kind:`relay`,relay:a.relay,tunnel:a.tunnel}:{kind:`direct`,url:a.url},f,{runtimeKey:N({candidates:i})}),o=a.kind===`relay`,h()}catch(e){console.warn(`[mobile-connect] password threw`,e),s(t(`mobile.connect.error.passwordFailed`))}finally{!o&&a?.kind===`relay`&&a.tunnel.close(),b(`password`)}}),S=w(()=>{l(null),s(null)}),C=w(async e=>{if(f.current)return null;y(`metadata`);try{s(null);let n=qe(e),r=e.id?u.current.find(t=>t.id===e.id)??null:null;if(r){let e=n.filter(e=>e.kind===`direct`),t=He(r).filter(t=>t.url.startsWith(`https://`)&&!e.some(e=>ze(e.url,t.url))),i=j(r);n=[...e,...t,...i?[{kind:`relay`,relay:i}]:[]]}if(n.length===0)return s(t(`mobile.connect.error.urlRequired`)),null;let i=e.clientToken?.trim()||void 0,a=e.label?.trim()||Re(M({candidates:n}));if(m()){let e=N({candidates:n});if(i)await H(e,i);else if(r?.hasToken){let t=N(r);if(t&&e&&t!==e){let n=await V(t);n&&await H(e,n)}}}return x({id:e.id,label:a,candidates:n,clientToken:i},!1).find(e=>We(e.candidates,n))??null}catch{return s(t(`mobile.connect.history.updateFailed`)),null}finally{b(`metadata`)}}),ie=w(async(e,n)=>{if(f.current||!n.trim())return null;let r=u.current.find(t=>t.id===e);if(!r)return null;y(`metadata`),s(null);try{let t={...r,label:n.trim()},i=u.current.map(n=>n.id===e?t:n);return B(i),_(i),t}catch{return s(t(`mobile.connect.history.updateFailed`)),null}finally{b(`metadata`)}}),oe=w(async e=>{if(f.current)return null;y(`metadata`),s(null);try{let t=u.current.find(t=>t.id===e)??null,n=await gt(e);return _(n),t}catch{return s(t(`mobile.connect.history.updateFailed`)),null}finally{b(`metadata`)}});return{connections:n,isBusy:i!==null,isPasswordBusy:i===`password`,error:o,pendingConnection:c,connect:te,redeemPairingConnection:ne,submitPassword:re,cancelPassword:S,saveConnection:C,renameConnection:ie,removeConnection:oe,subscribeConnected:g,setError:s}},Pt=async(e,t=3)=>{let n;for(let r=0;r<t;r+=1)try{await e();return}catch(e){n=e}throw n},Ft=async(e,t,n=2)=>{let r=[...new Map(e.map(e=>[e.operationID,e])).values()],i=0;await Promise.all(Array.from({length:Math.min(Math.max(1,n),r.length)},async()=>{for(;i<r.length;){let e=r[i++];try{e.cleanupPhase&&e.cleanupPhase!==`files-released`?await t.cleanup(e.operationID):await t.deliver(e.operationID)}catch{}}}))},It=e=>!!(e.serverInstanceID&&e.assistantID&&e.name&&e.avatarSeed&&e.serverLabel&&e.connectionKey),Lt=`yuri.mobile-share.draft-handoff.v1`,Rt=`mobile-share-handoff:`,zt=20971520,Bt=20971520,Vt=e=>`${Rt}${e}`,Ht=e=>e??(typeof window>`u`?null:window.localStorage),G=e=>{if(!e)return{};try{let t=JSON.parse(e.getItem(`yuri.mobile-share.draft-handoff.v1`)||`{}`);return Object.fromEntries(Object.entries(t).flatMap(([e,t])=>{let n=typeof t.assistantID==`string`?t.assistantID:Yt(t),r=typeof t.transportIdentity==`string`?t.transportIdentity:t.targetDraftKey?.transportIdentity;if(!n||typeof t.serverInstanceID!=`string`||typeof t.connectionKey!=`string`||!r)return[];let i=t.phase===`cancelled`?`cancelled`:t.phase===`materialized`?`materialized`:`materializing`;return[[e,{...t,draftID:e,assistantID:n,transportIdentity:r,phase:i}]]}))}catch{return{}}},Ut=(e,t)=>{if(!e)return!1;try{return e.setItem(Lt,JSON.stringify(t)),!0}catch{return!1}},Wt=(e,t)=>{let n=G(e);if(delete n[t],e)try{e.setItem(Lt,JSON.stringify(n))}catch{return}},K=(e,t)=>Ut(e,{...G(e),[t.draftID]:t}),Gt=(e,t)=>`native-share:${e}:${t}`,Kt=(e,t)=>t?e?`${e}\n\n${t}`:t:e,qt=e=>e.mime.startsWith(`image/`)&&e.byteSize>0&&e.byteSize<=zt,Jt=(e,t)=>!!t?.syntheticParts.some(t=>t.partID===Vt(e.draftID)&&t.text===``&&t.attachments.length===0&&t.synthetic===!0),Yt=e=>{let t=e.targetDraftKey?.owner;return t?.kind!==`surface`||typeof t.ownerID!=`string`||!t.ownerID.startsWith(`assistant:`)?null:t.ownerID.slice(10)||null},Xt=e=>({draftID:e.draftID,serverInstanceID:e.serverInstanceID,connectionKey:e.connectionKey,assistantID:e.assistantID,transportIdentity:e.transportIdentity}),Zt=async(e,t)=>{let n=Ht(t),r=[];for(let t of Object.values(G(n))){if(t.phase===`cancelled`){r.push(Xt(t));continue}if(t.phase===`materialized`)try{await e(t.draftID);let i={...t,phase:`cancelled`};if(!K(n,i))continue;r.push(Xt(i))}catch{continue}}return r},Qt=(e,t)=>{let n=Ht(t),r=G(n)[e.draftID];return!r||r.phase!==`cancelled`||r.serverInstanceID!==e.serverInstanceID||r.connectionKey!==e.connectionKey||r.assistantID!==e.assistantID||r.transportIdentity!==e.transportIdentity?!1:(Wt(n,e.draftID),!G(n)[e.draftID])},$t=async(e,t)=>{let n=b({transportIdentity:e.transportIdentity},`assistant:${e.assistantID}`),r=t.captureDraftRuntime();if(r.transportIdentity!==e.transportIdentity)return!1;let i=t.getDraft(n),a=Vt(e.draftID);try{if(!i||!i.syntheticParts.some(e=>e.partID===a)){await t.flushDraftPersistence();let n=t.captureDraftRuntime();return n.transportIdentity===e.transportIdentity&&n.generation===r.generation}let o=await t.commitDraftSnapshot({key:n,expectedRevision:i.revision,runtime:r,values:new Map,snapshot:{text:i.text,attachments:i.attachments,syntheticParts:i.syntheticParts.filter(e=>e.partID!==a),mentions:i.mentions,...i.composerReferences===void 0?{}:{composerReferences:i.composerReferences}}});if(!o.current||!o.durable)return!1;await t.flushDraftPersistence();let s=t.captureDraftRuntime();return s.transportIdentity===e.transportIdentity&&s.generation===r.generation}catch{return!1}},en=async(e,t)=>{if(e.attachments.length>10||!e.attachments.every(qt)||e.attachments.reduce((e,t)=>e+t.byteSize,0)>Bt)throw Error(`invalid_share_attachment`);let n=Ht(t.storage),r=b({transportIdentity:t.transportIdentity},`assistant:${e.assistantID}`),i=G(n)[e.draftID],a=!1;if(!i||x(i.targetDraftKey)!==x(r)){let a=t.input.getDraft(r);if(i={draftID:e.draftID,serverInstanceID:e.serverInstanceID,connectionKey:e.connectionKey,assistantID:e.assistantID,transportIdentity:t.transportIdentity,targetDraftKey:r,baseRevision:a?.revision??`absent`,resultText:Kt(a?.text??``,e.text),attachmentIDs:e.attachments.map((t,n)=>Gt(e.draftID,n)),phase:`materializing`},!K(n,i))throw Error(`handoff_journal_unavailable`)}if(i.phase===`cancelled`)return{durable:!0,cancelled:!0};(i.phase===`materialized`||Jt(i,t.input.getDraft(r)))&&(a=!0);for(let o=0;!a&&o<3;o++){let o=t.input.getDraft(r),s={...i,baseRevision:o?.revision??`absent`,resultText:Kt(o?.text??``,e.text),phase:`materializing`};if(!K(n,s))throw Error(`handoff_journal_unavailable`);i=s;let c=new Map,l=[];for(let n=0;n<e.attachments.length;n++){let r=e.attachments[n],a=i.attachmentIDs[n],o=y(a),s=await t.readAttachment(r);if(s.size!==r.byteSize)throw Error(`staged_file_unavailable`);c.set(o,s.type===r.mime?s:new Blob([s],{type:r.mime})),l.push({attachmentID:a,attachmentRefID:o,filename:r.originalName,mimeType:r.mime,size:r.byteSize,locator:{kind:`blob`,blobID:a},source:`local`})}let u={partID:Vt(e.draftID),text:``,attachments:[],synthetic:!0},d=o?.syntheticParts??[],f=await t.input.commitDraftSnapshot({key:r,expectedRevision:o?.revision??`absent`,runtime:t.input.captureDraftRuntime(),snapshot:{text:i.resultText,attachments:[...o?.attachments??[],...l],syntheticParts:d.some(e=>e.partID===u.partID)?d:[...d,u],mentions:o?.mentions??[],...o?.composerReferences===void 0?{}:{composerReferences:o.composerReferences}},values:c});if(f.durable&&f.current)a=!0;else if(f.status!==`conflict`)throw Error(`draft_handoff_${f.status}`)}if(!a)throw Error(`draft_handoff_conflict`);if(i.phase!==`materialized`&&(i={...i,phase:`materialized`},!K(n,i)))throw Error(`handoff_journal_unavailable`);try{await t.cancelDraft(e.draftID)}catch{return{durable:!0,cancelled:!1}}if(i={...i,phase:`cancelled`},!K(n,i))throw Error(`handoff_journal_unavailable`);return{durable:!0,cancelled:!0}},tn=re(`YuriShare`),nn=null,rn=(e,t)=>l()===e&&c()===t,an=e=>{if(h()){pe(e);return}let t=fe.getState();t.setActiveTab(`assistant`),t.openAssistant(e)},on=async()=>{let e=(await tn.pendingAssistantOpen().catch(()=>null))?.request;if(!e)return!1;let t=await bt(e.connectionKey);if(t===`missing`)return await tn.ackAssistantOpen({requestID:e.requestID}).catch(()=>void 0),!0;if(t!==`connected`)return!0;let n=c();if(!rn(e.connectionKey,n))return!0;try{let[t,r]=await Promise.all([T(),se()]);if(!rn(e.connectionKey,n))return!0;let i=r.assistants.some(t=>t.id===e.assistantID&&t.enabled);if(!t.supported||!t.enabled||t.serverInstanceID!==e.serverInstanceID||!i)return await tn.ackAssistantOpen({requestID:e.requestID}),!0;an(e.assistantID),await tn.ackAssistantOpen({requestID:e.requestID})}catch{}return!0},q=async()=>S.getPlatform()===`android`?nn||(nn=on().finally(()=>{nn=null}),nn):!1,sn=e=>({displayName:e}),J=p();function cn(e){let t=(0,be.c)(30),{draft:n,entries:r,busy:i,onSelect:a,onCancel:o}=e,{t:s}=ae(),c;t[0]!==i||t[1]!==n||t[2]!==o?(c=()=>{n&&!i&&o(n)},t[0]=i,t[1]=n,t[2]=o,t[3]=c):c=t[3];let l=w(c),u;t[4]===l?u=t[5]:(u=e=>{e||l()},t[4]=l,t[5]=u);let d=w(u),f;t[6]!==n||t[7]!==a?(f=e=>{n&&a(n,e)},t[6]=n,t[7]=a,t[8]=f):f=t[8];let p=w(f),m=!!n,h;t[9]===s?h=t[10]:(h=s(`assistants.shareWelcome.example.note.title`),t[9]=s,t[10]=h);let g;t[11]===s?g=t[12]:(g=s(`settings.common.actions.cancel`),t[11]=s,t[12]=g);let _;t[13]!==i||t[14]!==l||t[15]!==h||t[16]!==g?(_=(0,J.jsx)(ue,{title:h,backAriaLabel:g,onBack:l,backDisabled:i,overlay:!0}),t[13]=i,t[14]=l,t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==i||t[19]!==r||t[20]!==p||t[21]!==s?(v=r.length?(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-[calc(max(0.25rem,var(--yuri-safe-area-top,0px))+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.75rem)]`,role:`listbox`,"aria-label":s(`assistants.listAria`),children:r.map(e=>{let t=sn(e.name).displayName||e.name;return(0,J.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,disabled:i,className:`flex w-full items-center gap-3 border-b border-border/60 px-3 py-4 text-left text-foreground transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-60`,onClick:()=>p(e),children:[(0,J.jsx)(he,{kind:`assistant`,name:e.avatarSeed,size:40,label:t,shape:`rounded`,className:`rounded-[0.5rem]`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate font-semibold`,children:t}),(0,J.jsx)(`span`,{className:`block truncate typography-small text-muted-foreground`,children:e.serverLabel})]}),(0,J.jsx)(ge,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]},`${e.connectionKey}:${e.assistantID}`)})}):(0,J.jsx)(`p`,{className:`px-5 pb-[max(1.25rem,env(safe-area-inset-bottom))] pt-[calc(max(0.25rem,var(--yuri-safe-area-top,0px))+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.75rem)] typography-ui text-muted-foreground`,children:s(`assistants.state.unavailable`)}),t[18]=i,t[19]=r,t[20]=p,t[21]=s,t[22]=v):v=t[22];let y;t[23]!==_||t[24]!==v?(y=(0,J.jsxs)(_e,{className:`h-[100dvh] max-h-none w-screen max-w-none gap-0 overflow-hidden rounded-none border-0 bg-background p-0`,containerClassName:`items-stretch p-0`,overlayClassName:`bg-background`,showCloseButton:!1,children:[_,v]}),t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;return t[26]!==d||t[27]!==m||t[28]!==y?(b=(0,J.jsx)(ve,{open:m,onOpenChange:d,children:y}),t[26]=d,t[27]=m,t[28]=y,t[29]=b):b=t[29],b}var ln=e({MobileShareBridge:()=>Un,donateNativeAssistantInteraction:()=>Mn,publishNativeAssistantCatalog:()=>jn,refreshNativeAssistantCatalog:()=>Q}),Y=re(`YuriShare`),un=`yuri.mobile-share.outbox.v1`,dn=()=>S.isNativePlatform(),fn=()=>{try{return JSON.parse(window.localStorage.getItem(un)||`{}`)}catch{return{}}},pn=e=>{try{window.localStorage.setItem(un,JSON.stringify(e))}catch{}},X=e=>{let t=fn(),n=t[e.envelope.operationID];n&&n.updatedAt>e.updatedAt||(t[e.envelope.operationID]=e,pn(t))},Z=(e,t)=>l()===e&&c()===t,mn=new Map,hn=null,gn=null,_n=!1,vn=[],yn=0,bn=new Set,xn=new Map,Sn=1,Cn=e=>{e.map(e=>e.draftID).join(`
|
|
3
|
-
`)!==vn.map(e=>e.draftID).join(`
|
|
4
|
-
`)&&(vn=e,yn+=1,bn.forEach(e=>e()))},wn=e=>Cn(vn.filter(t=>t.draftID!==e)),Tn=e=>(bn.add(e),()=>bn.delete(e)),En=()=>yn,Dn=async e=>{if(!e.mime.startsWith(`image/`))throw Error(`unsupported_share_attachment`);let t=e.stagedPath.trim();if(!t)throw Error(`staged_file_unavailable`);let n=/^(?:data:|https?:|content:|file:)/i.test(t)?t:`file://${t}`,r=/^(?:data:|https?:)/i.test(n)?n:S.convertFileSrc(n);return ne(()=>fetch(r).then(e=>{if(!e.ok)throw Error(`staged_file_unavailable`);return e.blob()}))},On=async e=>{let t=await Dn(e);return await new Promise((e,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`staged_file_unavailable`)),r.onload=()=>typeof r.result==`string`?e(r.result):n(Error(`staged_file_unavailable`)),r.readAsDataURL(t)})},kn=async e=>{let t=[];if(e.text?.trim()&&t.push({type:`text`,text:e.text}),e.attachments.length>10)throw Error(`too_many_share_attachments`);for(let n of e.attachments){if(n.byteSize<=0||n.byteSize>20971520)throw Error(`invalid_share_attachment`);t.push({type:`file`,mime:n.mime,url:await On(n)})}if(t.length===0)throw Error(`empty_share`);return t},Q=async()=>{if(!dn())return;let e=l(),t=(await mt()).find(t=>Ue(t)===e);if(!t)return;let n=c();try{let[r,i]=await Promise.all([T(),le()]);if(!Z(e,n)||!r.supported||!r.serverInstanceID)return;let a=r.serverInstanceID,o=i.assistants.map(n=>({serverInstanceID:a,assistantID:n.id,name:n.name,avatarSeed:n.avatarSeed??n.id,serverLabel:t.label,connectionKey:e,enabled:r.enabled&&n.enabled,isDefaultShareTarget:!1}));D.getState().replaceCatalogPartition({serverInstanceID:a,connectionKey:e,revision:i.revision,lastLoadedAt:Date.now(),entries:o}),await jn()}catch{}},An=0,jn=async()=>{if(!dn())return;let e=++An,t=[];for(let n of Object.values(D.getState().assistantCatalogByConnection).flatMap(e=>e.entries)){let r=sn(n.name),i=await ye(me(`assistant`,n.avatarSeed),128);if(e!==An)return;t.push({...n,name:r.displayName||n.name,...i?{avatarPng:i}:{}})}await Y.updateCatalog({entries:t})},Mn=async e=>{if(S.getPlatform()!==`ios`)return;let t=await ye(me(`assistant`,e.avatarSeed),128);await Y.donateAssistantInteraction({...e,...t?{avatarPng:t}:{}})},Nn=e=>{let t=mn.get(e.operationID);if(t)return t;let n=Fn(e);return mn.set(e.operationID,n),n.finally(()=>{mn.get(e.operationID)===n&&mn.delete(e.operationID)}).catch(()=>void 0),n},Pn=async e=>{e.cleanupPhase!==`files-released`&&(e.cleanupPhase===`server-completed`&&(await Pt(()=>Y.ack({operationID:e.envelope.operationID})),e={...e,state:`delivered`,cleanupPhase:`native-acked`,updatedAt:Date.now()},X(e)),e.cleanupPhase===`native-acked`&&(await Pt(()=>Y.releaseFiles({operationID:e.envelope.operationID})),X({...e,state:`delivered`,cleanupPhase:`files-released`,updatedAt:Date.now()})))},Fn=async e=>{let t=fn()[e.operationID];if(t?.cleanupPhase){await Pn(t);return}let n=t?.messageID?t:{envelope:e,messageID:ee(`msg`),state:t?.state??`pending`,cleanupPhase:t?.cleanupPhase,updatedAt:Date.now(),error:t?.error};X(n),n={...n,state:`resolving-instance`,updatedAt:Date.now()},X(n);let r=Object.values(D.getState().assistantCatalogByConnection).find(t=>t.serverInstanceID===e.serverInstanceID&&t.entries.some(t=>t.assistantID===e.assistantID));if(!r){X({...n,state:`target-stale`,updatedAt:Date.now()});return}n={...n,state:`connecting`,updatedAt:Date.now()},X(n);let i=await bt(r.connectionKey);if(i===`auth-required`){X({...n,state:`auth-required`,updatedAt:Date.now()});return}if(i!==`connected`){X({...n,state:`offline`,updatedAt:Date.now()});return}let a=c(),s=null;if(Z(r.connectionKey,a)){try{if(await d(`/api/config/settings`).catch(()=>void 0),!Z(r.connectionKey,a))return;let[t,i]=await Promise.all([T(),le()]);if(!Z(r.connectionKey,a)||!t.supported||t.serverInstanceID!==e.serverInstanceID){X({...n,state:`target-stale`,updatedAt:Date.now()});return}let c=i.assistants.find(t=>t.id===e.assistantID&&t.enabled);if(!t.enabled||!c){X({...n,state:`target-stale`,updatedAt:Date.now()});return}n={...n,state:`dispatching`,updatedAt:Date.now()},X(n);let l=await kn(e);if(!Z(r.connectionKey,a))return;n={...n,state:`reconciling`,updatedAt:Date.now()},X(n);let u=await ce(c.id,e.operationID,n.messageID,l,e.source),f=await de(u,o(),a),p=await se().catch(e=>(X({...n,state:`reconciling`,updatedAt:Date.now(),error:e instanceof Error?e.message:`snapshot_refresh_failed`}),null));if(!p)return;if(!Z(r.connectionKey,a)){X({...n,state:`reconciling`,updatedAt:Date.now(),error:`runtime_stale`});return}let m=p.assistants.find(e=>e.id===c.id);if(!m||m.sessionID!==f.sessionID){X({...n,state:`reconciling`,updatedAt:Date.now(),error:`assistant_binding_mismatch`});return}s=m.id}catch(e){if(e instanceof oe&&e.code===`share_unresolved`||e instanceof Error&&e.message===`runtime_stale`){X({...n,state:`reconciling`,updatedAt:Date.now(),error:e instanceof Error?e.message:`share_unresolved`});return}X({...n,state:`failed`,updatedAt:Date.now(),error:e instanceof Error?e.message:`dispatch_failed`});return}n={...n,state:`delivered`,cleanupPhase:`server-completed`,updatedAt:Date.now()},X(n),an(s),await Pn(n)}},In=async()=>hn||(hn=Ln().finally(()=>{hn=null}),hn),Ln=async()=>{if(!dn())return;let e=await Y.listPending().catch(()=>null),t=new Map((e?.envelopes??[]).map(e=>[e.operationID,e])),n=fn();await Ft([...[...t.values()].map(e=>({operationID:e.operationID,cleanupPhase:n[e.operationID]?.cleanupPhase})),...Object.values(n).filter(e=>!t.has(e.envelope.operationID)&&(!!(e.cleanupPhase&&e.cleanupPhase!==`files-released`)||e.state!==`delivered`&&e.state!==`auth-required`&&e.state!==`target-stale`)).map(e=>({operationID:e.envelope.operationID,cleanupPhase:e.cleanupPhase}))],{deliver:async e=>{let r=t.get(e)??n[e]?.envelope;r&&await Nn(r)},cleanup:async e=>{let t=fn()[e];t&&await Pn(t)}},Sn)},$=async()=>(_n=!0,gn||(gn=(async()=>{do _n=!1,await Hn();while(_n)})().finally(()=>{gn=null,_n&&$()}),gn)),Rn=async e=>{if(l()!==e.connectionKey&&await bt(e.connectionKey)!==`connected`)return!1;let t=c();if(!Z(e.connectionKey,t)||o()!==e.transportIdentity||(await d(`/api/config/settings`).catch(()=>void 0),!Z(e.connectionKey,t)||o()!==e.transportIdentity)||!await E.getState().hydrateDraftMetadata(e.transportIdentity)||!Z(e.connectionKey,t)||o()!==e.transportIdentity)return!1;let[n,r]=await Promise.all([T(),se()]);return!Z(e.connectionKey,t)||o()!==e.transportIdentity||!n.supported||!n.enabled||n.serverInstanceID!==e.serverInstanceID||!r.assistants.some(t=>t.id===e.assistantID&&t.enabled)?!1:(an(e.assistantID),!0)},zn=async e=>{let t=l(),n=c();if(await d(`/api/config/settings`).catch(()=>void 0),!Z(t,n))return null;try{let[r,i]=await Promise.all([T(),se()]);return!Z(t,n)||!r.supported||!r.enabled||r.serverInstanceID!==e.serverInstanceID||!i.assistants.some(t=>t.id===e.assistantID&&t.enabled)?null:{runtimeKey:t,generation:n,transportIdentity:o()}}catch{return null}},Bn=async e=>{let t=Object.values(D.getState().assistantCatalogByConnection).find(t=>t.serverInstanceID===e.serverInstanceID&&t.connectionKey===e.connectionKey&&t.entries.some(t=>t.assistantID===e.assistantID));if(!t)return!1;let n=await zn(e);if(!n&&(await bt(t.connectionKey,{transportPreference:`relay`})!==`connected`||(n=await zn(e),!n)))return!1;let{runtimeKey:r,generation:i,transportIdentity:a}=n;if(!await E.getState().hydrateDraftMetadata(a)||!Z(r,i)||o()!==a)return!1;let s=await en(e,{input:E.getState(),transportIdentity:a,cancelDraft:e=>Y.cancelDraft({draftID:e}),readAttachment:Dn});if(!s.durable||!s.cancelled||!Z(r,i)||o()!==a)return!1;let c={draftID:e.draftID,serverInstanceID:e.serverInstanceID,connectionKey:e.connectionKey,assistantID:e.assistantID,transportIdentity:a};return an(e.assistantID),await $t(c,E.getState())&&Qt(c),!0},Vn=e=>{let t=xn.get(e.draftID);if(t)return t;let n=Bn(e).catch(()=>!1).finally(()=>{xn.get(e.draftID)===n&&xn.delete(e.draftID)});return xn.set(e.draftID,n),n},Hn=async()=>{if(S.getPlatform()!==`android`)return;let e=await Zt(e=>Y.cancelDraft({draftID:e}));for(let t of e)try{await Rn(t)&&await $t(t,E.getState())&&Qt(t)}catch{}let t=await Y.listDrafts().catch(()=>null);if(!t)return;let n=[...t?.drafts??[]].sort((e,t)=>e.createdAt-t.createdAt);Cn(n.filter(e=>!It(e)));for(let e of n)It(e)&&await Vn(e)},Un=()=>{let e=(0,be.c)(11);O.useSyncExternalStore(Tn,En,En);let t=D(Wn),[n,r]=O.useState(null),i=O.useRef(null),a;e[0]===t?a=e[1]:(a=Object.values(t).flatMap(Gn).filter(Kn).sort(qn),e[0]=t,e[1]=a);let o=a,s=vn[0]??null,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{i.current||(i.current=e.draftID,r(e.draftID),Vn({...e,serverInstanceID:t.serverInstanceID,assistantID:t.assistantID,name:t.name,avatarSeed:t.avatarSeed,serverLabel:t.serverLabel,connectionKey:t.connectionKey}).then(t=>{t&&wn(e.draftID)}).finally(()=>{i.current===e.draftID&&(i.current=null),r(t=>t===e.draftID?null:t)}))},e[2]=c):c=e[2];let l=w(c),u;e[3]===n?u=e[4]:(u=e=>{n!==e.draftID&&(wn(e.draftID),Y.cancelDraft({draftID:e.draftID}).catch(Jn))},e[3]=n,e[4]=u);let d=w(u),f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=[],e[5]=f):f=e[5],O.useEffect(rr,f);let p=n===s?.draftID,m;return e[6]!==d||e[7]!==o||e[8]!==l||e[9]!==p?(m=(0,J.jsx)(cn,{draft:s,entries:o,busy:p,onSelect:l,onCancel:d}),e[6]=d,e[7]=o,e[8]=l,e[9]=p,e[10]=m):m=e[10],m};function Wn(e){return e.assistantCatalogByConnection}function Gn(e){return e.entries}function Kn(e){return e.enabled}function qn(e,t){return Number(t.isDefaultShareTarget)-Number(e.isDefaultShareTarget)||e.serverLabel.localeCompare(t.serverLabel)||e.name.localeCompare(t.name)}function Jn(){$()}function Yn(){Q(),$(),q()}function Xn(){Q(),In(),$(),q()}function Zn(){In()}function Qn(){}function $n(){$()}function er(){}function tr(){q()}function nr(){}function rr(){if(!dn())return;Q(),In(),$(),q();let e=a(Yn),t=Xn;window.addEventListener(`yuri:system-resume`,t);let n=!1,r=null,i=null,o=null;return Y.addListener(`shareReceived`,Zn).then(e=>{n?e.remove():r=e}).catch(Qn),Y.addListener(`shareDraftReceived`,$n).then(e=>{n?e.remove():i=e}).catch(er),Y.addListener(`assistantOpenRequested`,tr).then(e=>{n?e.remove():o=e}).catch(nr),()=>{n=!0,e(),window.removeEventListener(`yuri:system-resume`,t),r&&r.remove(),i&&i.remove(),o&&o.remove()}}export{q as a,vt as c,Ue as d,Ot as f,sn as i,Dt as l,Mn as n,yt as o,Nt as p,Q as r,M as s,Un as t,mt as u};
|