PageSourceSearch

https://app.dynamicode.ai/_next/static/chunks/13193.4a2bc26ca00c28b2.js

js dynamicode.ai collected 2026-10-05 12:10:03 UTC 93,960 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[13193],{4973:(e,t,s)=>{s.d(t,{T:()=>k});var r=s(95155),n=s(7198),a=s(94248),i=s(80642),l=s(6296),o=s(20232),c=s(33591),d=s(1164),u=s(41585),m=s(92972),h=s(52484),p=s(84980),x=s(91958),f=s(91020),g=s(89239),w=s(89385),j=s(97199),b=s(40980),v=s(43904),y=s(31027);function N({frontends:e,onSelectFrontend:t,isSelectPending:s=!1}){let n=s?l.A:o.A;return(0,r.jsx)("div",{className:"mb-4 grid w-full min-w-0 max-w-full gap-2 pb-4 sm:mb-6 sm:gap-3 sm:pb-0",children:e.map((e,i)=>{var l;let o=(l=e.framework,({react:"https://cdn.simpleicons.org/react",nextjs:"https://cdn.simpleicons.org/nextdotjs",next:"https://cdn.simpleicons.org/nextdotjs",vue:"https://cdn.simpleicons.org/vuedotjs",nuxt:"https://cdn.simpleicons.org/nuxtdotjs",angular:"https://cdn.simpleicons.org/angular",svelte:"https://cdn.simpleicons.org/svelte",flutter:"https://cdn.simpleicons.org/flutter",astro:"https://cdn.simpleicons.org/astro",vite:"https://cdn.simpleicons.org/vite",gatsby:"https://cdn.simpleicons.org/gatsby",remix:"https://cdn.simpleicons.org/remix"})[l?.toLowerCase()??""]||""),u=e.envVars&&e.envVars.length>0,m=e.envVars?.filter(e=>e.required&&"random_base64_32"!==e.autoGenerate&&"rsa_key_pair"!==e.previewAutoGenerate).length??0,h=(e.envVars?.length??0)-m;return(0,r.jsxs)(a.P.button,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1*i},onClick:()=>t(e),disabled:s,className:"group relative flex w-full min-w-0 max-w-full items-start gap-3 overflow-hidden rounded-lg border bg-card p-3 text-left transition-all hover:border-primary/50 hover:bg-accent/50 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-50 sm:items-center sm:gap-4 sm:p-4",children:[(0,r.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 sm:h-12 sm:w-12",children:o?(0,r.jsx)("img",{src:o,alt:e.framework||"Framework",className:"h-5 w-5 sm:h-6 sm:w-6"}):(0,r.jsx)(c.A,{className:"h-5 w-5 text-primary sm:h-6 sm:w-6"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 overflow-hidden",children:[(0,r.jsx)("h4",{className:"max-w-full truncate text-sm font-semibold sm:text-base",children:e.name||e.id}),(0,r.jsx)("p",{className:"block max-w-full truncate text-xs text-muted-foreground",children:"compose"===e.launchMode?"Docker Compose preview":e.framework||"Web application"}),u&&(0,r.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-1",children:[(0,r.jsx)(d.A,{className:"h-3 w-3 shrink-0 text-primary"}),(0,r.jsx)("span",{className:"min-w-0 truncate text-xs text-primary",children:m>0?(0,r.jsxs)(r.Fragment,{children:["Requires ",m," setting",1!==m?"s":"",h>0&&` (+${h} optional)`]}):`${h} optional setting${1!==h?"s":""}`})]})]}),(0,r.jsx)(n,{className:(0,b.cn)("mt-2 h-4 w-4 shrink-0 text-muted-foreground transition-colors group-hover:text-primary sm:mt-0 sm:h-5 sm:w-5",s&&"animate-spin motion-reduce:animate-none")})]},e.id)})})}function k({state:e,frontends:t,startingFrontend:s,onSelectFrontend:c,onRescan:k,onDiagnose:S,onOpenSettings:C,error:$,errorCode:A,retryable:T,recoveryAction:E,isRescanPending:R=!1,discoveryPhase:I,isSelectPending:L=!1,isDiagnosePending:_=!1,teamState:M,onStartTeam:F,isStartTeamPending:P=!1,startTeamError:O=!1}){let q=(0,n.a)(I,R),z=_?"repairing":e,{data:U}=(0,y.TG)(),D=["discovering","starting","building","restarting","repairing"].includes(z),B=D?l.A:"error"===z?u.A:m.A,W="select-frontend"===z||"error"===z&&t.length>1,H=(0,j.n)({errorCode:A,error:$,retryable:T,recoveryAction:E}),V=1===t.length?t[0]:null,K="MISSING_ENVIRONMENT"===H.errorCode||"COMPOSE_ENV_INVALID"===H.errorCode;return(0,r.jsx)(i.N,{mode:"wait",children:(0,r.jsx)(a.P.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},"data-preview-overlay":z,className:"absolute inset-0 isolate flex flex-col overflow-y-auto overscroll-contain bg-background px-3 py-6 text-center text-foreground sm:px-6 sm:py-8","aria-label":"Preview status",children:(0,r.jsxs)("div",{className:(0,b.cn)("relative mx-auto w-full min-w-0 max-w-lg shrink-0",W?"my-0":"my-auto"),children:[(0,r.jsx)("div",{"aria-hidden":"true",className:"mx-auto mb-5 flex h-12 w-12 items-center justify-center rounded-2xl border border-border/60 bg-muted/50 text-muted-foreground",children:(0,r.jsx)(B,{className:(0,b.cn)("h-5 w-5",D&&"animate-spin motion-reduce:animate-none")})}),R&&!D&&(0,r.jsxs)("p",{role:"status",className:"mb-4 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none"}),(0,r.jsxs)("span",{children:[q?.title," ",q?.description]})]}),D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h3",{className:"mb-2 text-lg font-semibold tracking-tight",children:"repairing"===z?"Repairing your preview":"discovering"===z?q?.title??"Looking for your app":"building"===z?"Preparing your preview":"restarting"===z?"Restarting your preview":s?`Starting ${s.name}`:"Connecting to your app"}),(0,r.jsx)("p",{role:"status",className:"mx-auto max-w-sm text-sm leading-relaxed text-muted-foreground",children:"repairing"===z?"Checking what went wrong and preparing a fix. Your preview will return when it’s ready.":"discovering"===z?q?.description??"Checking your project for an app to preview.":"building"===z?"Getting everything ready. This may take a few minutes.":"restarting"===z?"Your preview will return when the environment is ready.":"Your preview will appear as soon as your app is ready."}),("discovering"===z||"starting"===z)&&U?.is_active&&(0,r.jsxs)("div",{className:"mt-6 text-left",children:[U.summary.total>0&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("div",{className:"mb-1 flex justify-between text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:"Starting previews"}),(0,r.jsxs)("span",{children:[U.summary.done,"/",U.summary.total," complete"]})]}),(0,r.jsx)("div",{role:"progressbar","aria-label":"Preview startup progress","aria-valuemin":0,"aria-valuemax":U.summary.total,"aria-valuenow":U.summary.done,className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:(0,r.jsx)(a.P.div,{className:"h-full bg-primary",initial:{width:0},animate:{width:`${U.summary.done/U.summary.total*100}%`},transition:{duration:.3}})})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[U.completed?.slice(-3).map(e=>(0,r.jsxs)(a.P.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:"flex items-center gap-2 rounded-md bg-green-500/10 px-3 py-2 text-sm",children:[(0,r.jsx)(h.A,{className:"h-4 w-4 flex-shrink-0 text-green-500"}),(0,r.jsx)("span",{className:"flex-1 truncate",children:e.frontend_name||e.project_id}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.wait_time,"s"]})]},`completed-${e.project_id}`)),U.current&&(0,r.jsxs)(a.P.div,{initial:{opacity:0}
1,animate:{opacity:1},className:"flex items-center gap-2 rounded-md bg-blue-500/10 px-3 py-2 text-sm",children:[(0,r.jsx)(l.A,{className:"h-4 w-4 flex-shrink-0 animate-spin text-blue-500 motion-reduce:animate-none"}),(0,r.jsx)("span",{className:"flex-1 truncate font-medium",children:U.current.frontend_name||U.current.project_id}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Starting..."})]}),U.queued?.map(e=>(0,r.jsxs)(a.P.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},className:"flex items-center gap-2 rounded-md bg-muted/50 px-3 py-2 text-sm",children:[(0,r.jsx)(p.A,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",children:e.frontend_name||e.project_id}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["#",e.position]})]},`queued-${e.project_id}`))]}),(0,r.jsx)("p",{className:"mt-4 text-xs text-muted-foreground",children:"Starting one at a time to keep your system fast"})]}),"starting"===z&&s?.setupInstructions?.length?(0,r.jsx)("div",{className:"mt-6 text-left",children:(0,r.jsx)(v.dv,{instructions:s.setupInstructions})}):null]}),"select-frontend"===z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.P.h3,{className:"mb-2 text-lg font-semibold tracking-tight",initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:1===t.length?`${t[0].name} is ready to preview`:"Which app would you like to preview?"}),(0,r.jsx)(a.P.p,{className:"mb-4 text-sm text-muted-foreground sm:mb-6",initial:{opacity:0}
1,animate:{opacity:1},children:1===t.length?"We found one runnable app. Start it when you're ready.":"We found multiple apps in your project. Pick one to see it in action."}),(0,r.jsx)(N,{frontends:t,onSelectFrontend:c,isSelectPending:L}),t.length>1&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground/60",children:"We'll remember your choice for next time"})]}),"no-frontends"===z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h3",{className:"mb-2 text-lg font-semibold tracking-tight",children:"Your preview will appear here"}),(0,r.jsx)("p",{role:"status",className:"mx-auto max-w-sm text-sm leading-relaxed text-muted-foreground",children:"working"===M?"Your team is working on the project. When there’s an app ready to preview, it will appear here.":"paused"===M?"Your team is paused. Start the team to continue working on your project.":"pausing"===M?"Your team is finishing its current work before pausing. There’s no app to preview yet.":"enabled"===M?"Your team is ready for work. Once your project has an app to preview, it will appear here.":"Once your project has an app ready to preview, it will appear here."}),(0,r.jsxs)("div",{className:"mt-5 flex flex-wrap justify-center gap-2",children:["paused"===M&&F&&(0,r.jsxs)(g.$,{onClick:F,disabled:P,className:"gap-2",children:[P?(0,r.jsx)(l.A,{"aria-hidden":"true",className:"h-4 w-4 animate-spin motion-reduce:animate-none"}):(0,r.jsx)(o.A,{"aria-hidden":"true",className:"h-4 w-4"}),P?"Starting team…":"Start team"]}),(0,r.jsxs)(g.$,{variant:"outline",onClick:k,disabled:R,className:"gap-2",children:[(0,r.jsx)(x.A,{"aria-hidden":"true",className:(0,b.cn)("h-4 w-4",R&&"animate-spin motion-reduce:animate-none")}),R?"Checking…":"Check for preview"]})]}),O&&(0,r.jsx)("p",{role:"alert",className:"mt-3 text-sm text-muted-foreground",children:"We couldn’t start the team. Please try again."})]}),"error"===z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.P.h3,{className:"mb-2 text-lg font-semibold tracking-tight",initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:H.title}),(0,r.jsx)(a.P.p,{className:"mx-auto mb-4 max-w-sm text-sm text-muted-foreground",initial:{opacity:0}
1,animate:{opacity:1},children:H.description}),t.length>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Available frontends"}),(0,r.jsx)(N,{frontends:t,onSelectFrontend:c,isSelectPending:L})]}),"reconnect_codex"===H.recoveryAction?(0,r.jsx)("div",{className:"mx-auto w-full max-w-md text-left",children:(0,r.jsx)(w.q,{assistant:"codex",onConnected:async()=>k()})}):(0,r.jsxs)("div",{className:"flex flex-wrap justify-center gap-2",children:[V&&S&&(0,r.jsx)(g.$,{onClick:S,disabled:_,className:"gap-2",children:_?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none"}),"Repairing..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f.A,{className:"h-4 w-4"}),"Fix with AI"]})}),V&&(0,r.jsx)(g.$,{onClick:()=>c(V),disabled:L,className:"gap-2",variant:S?"outline":"default",children:L?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none"}),"Starting..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A,{className:"h-4 w-4"}),"Retry preview"]})}),K&&C&&(0,r.jsxs)(g.$,{onClick:C,className:"gap-2",variant:V?"outline":"default",children:[(0,r.jsx)(d.A,{className:"h-4 w-4"}),"Open preview settings"]}),!V&&!K&&(0,r.jsx)(g.$,{onClick:k,disabled:R,className:"gap-2",variant:V||K?"outline":"default",children:R?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none"}),"Checking..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.A,{className:"h-4 w-4"}),"Rediscover frontends"]})})]}),"reconnect_codex"===H.recoveryAction&&(0,r.jsx)("div",{className:"mt-3 flex justify-center gap-2",children:(0,r.jsxs)(g.$,{variant:"outline",onClick:k,disabled:R,className:"gap-2",children:[(0,r.jsx)(x.A,{className:(0,b.cn)("h-4 w-4",R&&"animate-spin motion-reduce:animate-none")}),"Retry discovery"]})})]})]})},z)})}},7198:(e,t,s)=>{s.d(t,{a:()=>r});function r(e,t=!1){return"queued"===e?{title:"Rediscovery queued",description:"Waiting for a discovery slot. Your project will be scanned automatically; you don’t need to click again."}:"running"===e?{title:"Scanning project…",description:"Looking for apps that can run in the preview. This may take a few minutes."}:t?{title:"Requesting rediscovery…",description:"Sending your request. You don’t need to click again."}:null}},11369:(e,t,s)=>{s.d(t,{x:()=>n});var r=s(95155);function n({toolbar:e,overlay:t,children:s}){return(0,r.jsxs)("div",{className:"relative isolate flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background text-foreground",children:[(0,r.jsx)("div",{className:"relative z-20 shrink-0",children:e}),(0,r.jsxs)("div",{"data-preview-canvas":!0,className:"relative isolate min-h-0 flex-1 overflow-hidden bg-background",children:[s,t&&(0,r.jsx)("div",{className:"absolute inset-0 z-10",children:t})]})]})}},13977:(e,t,s)=>{s.d(t,{o:()=>g});var r=s(95155),n=s(89239),a=s(28344),i=s(14400),l=s(81612),o=s(6296),c=s(78697),d=s(66088),u=s(92451),m=s(32880),h=s(17243),p=s(6962),x=s(50910),f=s(40980);function g({isCapturing:e,screenshotMethod:t,onScreenshotMethodChange:s,onCapture:g,className:w,buttonClassName:j,menuButtonClassName:b}){let v=(0,x.c)("captureDropdown");return(0,r.jsx)(l.Bc,{children:(0,r.jsxs)("div",{className:(0,f.cn)("flex items-center",w),children:[(0,r.jsxs)(l.m_,{children:[(0,r.jsx)(l.k$,{asChild:!0,children:(0,r.jsx)(n.$,{variant:"outline",size:"sm",onClick:()=>g({}),disabled:e,className:(0,f.cn)("gap-2 rounded-r-none border-r-0",j),"aria-label":v("captureScreenshot"),children:e?(0,r.jsx)(o.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(c.A,{className:"h-4 w-4"})})}),(0,r.jsx)(l.ZI,{children:v("captureScreenshot")})]}),(0,r.jsxs)(i.rI,{children:[(0,r.jsx)(i.ty,{asChild:!0,children:(0,r.jsx)(n.$,{variant:"outline",size:"sm",className:(0,f.cn)("px-1.5 rounded-l-none",b),disabled:e,"aria-label":v("captureScreenshot")+" options",children:(0,r.jsx)(d.A,{className:"h-3 w-3"})})}),(0,r.jsxs)(i.SQ,{align:"end",className:"w-56",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:["browser"===t?(0,r.jsx)(u.A,{className:"h-4 w-4 text-muted-foreground"}):(0,r.jsx)(m.A,{className:"h-4 w-4 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm",children:v("browser"===t?"viewport":"fullscreen")})]}),(0,r.jsx)(a.d,{checked:"server"===t,onCheckedChange:e=>
1s(e?"server":"browser")})]}),(0,r.jsx)("div",{className:"px-2 pb-2",children:(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:v("browser"===t?"viewportDesc":"fullscreenDesc")})}),(0,r.jsx)(i.mB,{}),(0,r.jsxs)(i._2,{onClick:()=>g({savePath:"screenshots"}),children:[(0,r.jsx)(h.A,{className:"mr-2 h-4 w-4"}),v("saveToProject")]}),(0,r.jsx)(i.mB,{}),(0,r.jsxs)(i._2,{onClick:()=>g({format:"png"}),children:[(0,r.jsx)(p.A,{className:"mr-2 h-4 w-4"}),v("downloadPng")]}),(0,r.jsxs)(i._2,{onClick:()=>g({format:"jpeg",quality:90}),children:[(0,r.jsx)(p.A,{className:"mr-2 h-4 w-4"}),v("downloadJpeg")]}),(0,r.jsxs)(i._2,{onClick:()=>g({format:"webp",quality:90}),children:[(0,r.jsx)(p.A,{className:"mr-2 h-4 w-4"}),v("downloadWebp")]})]})]})]})})}},19200:(e,t,s)=>{s.d(t,{G:()=>m});var r=s(95155),n=s(12115),a=s(80723),i=s(21628),l=s(20986),o=s(66614),c=s(96544),d=s(89239),u=s(49171);function m({previewUrl:e,path:t,canGoBack:s,canGoForward:m,disabled:h,onNavigate:p,onBack:x,onForward:f,onReload:g,onHome:w}){let[j,b]=(0,n.useState)(t),[v,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{b(t),y(!1)},[t,e]);let N="Preview";try{N=new URL(e).host}catch{}let k=[{label:"Back",icon:a.A,action:x,unavailable:!s},{label:"Forward",icon:i.A,action:f,unavailable:!m},{label:"Reload preview",icon:l.A,action:g},{label:"Preview home",icon:o.A,action:w}];return(0,r.jsxs)("div",{className:"shrink-0 border-b bg-background px-2 py-1.5 text-foreground","aria-label":"Preview browser",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-1",children:[k.map(({label:e,icon:t,action:s,unavailable:n})=>(0,r.jsx)(d.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":e,title:e,disabled:h||n,onClick:s,children:(0,r.jsx)(t,{className:"h-3.5 w-3.5"})},e)),(0,r.jsxs)("form",{className:"ml-1 flex min-w-0 flex-1 items-center rounded-md border bg-muted/30 focus-within:ring-1 focus-within:ring-ring",onSubmit:t=>{if(t.preventDefault(),h)return;let s=(0,u.C)(j,e);y(null===s),null!==s&&(b(s),p(s))},children:[(0,r.jsx)("span",{className:"hidden max-w-[40%] truncate pl-2 text-xs text-muted-foreground sm:block",title:e,children:N}),(0,r.jsx)("input",{"aria-label":"Preview path","aria-invalid":v,"aria-describedby":v?"preview-address-error":void 0,className:"h-7 min-w-0 flex-1 bg-transparent px-2 font-mono text-xs text-foreground outline-none disabled:text-muted-foreground disabled:opacity-100",value:j,disabled:h,spellCheck:!1,autoComplete:"off",placeholder:"/admin",onChange:e=>{b(e.target.value),y(!1)},onKeyDown:e=>{"Escape"===e.key&&(b(t),y(!1),e.currentTarget.blur())}}),(0,r.jsx)(d.$,{type:"submit",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":"Go to preview path",title:"Go",disabled:h,children:(0,r.jsx)(c.A,{className:"h-3.5 w-3.5"})})]})]}),v&&(0,r.jsxs)("p",{id:"preview-address-error",role:"alert",className:"mt-1 text-xs text-destructive",children:["Enter a path or a URL on ",N,"."]})]})}},30904:(e,t,s)=>{s.d(t,{g:()=>S});var r=s(95155),n=s(12115),a=s(50910),i=s(26708),l=s(93219),o=s(33210),c=s(6296),d=s(57734),u=s(89239),m=s(59446),h=s(40980);let p=n.forwardRef(({className:e,...t},s)=>(0,r.jsx)(m.bL,{ref:s,className:(0,h.cn)("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));p.displayName=m.bL.displayName;let x=n.forwardRef(({className:e,...t},s)=>(0,r.jsx)(m._V,{ref:s,className:(0,h.cn)("aspect-square h-full w-full",e),...t}));x.displayName=m._V.displayName;let f=n.forwardRef(({className:e,...t},s)=>(0,r.jsx)(m.H4,{ref:s,className:(0,h.cn)("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));f.displayName=m.H4.displayName;var g=s(29991),w=s(66173),j=s(56526),b=s(94472),v=s(31509),y=s(64776),N=s(21211);function k({notification:e,persona:t,fallbackAssistant:s,identityLoading:i,isExpanded:l,onToggle:o}){let c=(0,a.c)("agentActivity"),u=(0,b.Wd)(e),m=(0,b.Sq)(u,e.type),g=(0,b.Yg)(e),w=(0,b.ge)(t?.name)||(0,b.dz)(e),j=(0,b.n2)(e),v=(0,y.w)(s)??(0,y.w)(j),N=(0,n.useRef)(null),k=function(e,t,s){let[r,a]=(0,n.useState)(!1);return(0,n.useLayoutEffect)(()=>
1{if(!t||!e.current)return;let s=e.current,r=()=>a(s.scrollHeight-s.clientHeight>1);r();let n=new ResizeObserver(r);return n.observe(s),()=>n.disconnect()},[e,t,s]),r}(N,!l,g),S=l||k;return(0,r.jsxs)("article",{className:"rounded-md border bg-card px-3 py-3 shadow-sm",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsxs)(p,{className:"h-8 w-8 shrink-0 border",children:[(0,r.jsx)(x,{src:t?.avatar||void 0}),(0,r.jsx)(f,{className:"text-base leading-none",children:i?(0,r.jsx)("span",{className:"h-full w-full bg-muted","aria-hidden":!0}):t?.icon?(0,r.jsx)("span",{"aria-hidden":!0,children:t.icon}):v?(0,r.jsx)("img",{src:v,alt:"",className:"h-full w-full rounded-full object-cover"}):(0,r.jsx)("span",{className:"text-xs font-semibold",children:"AI"})})]}),(0,r.jsx)("div",{className:"truncate text-sm font-medium",children:w})]}),(0,r.jsx)("p",{ref:N,className:(0,h.cn)("mt-2 text-xs leading-relaxed text-muted-foreground",!l&&"line-clamp-3",l&&"whitespace-pre-wrap break-words"),children:g}),S&&(0,r.jsx)("button",{type:"button",className:"mt-1 text-[11px] font-medium text-primary hover:underline",onClick:()=>o(e.id),children:c(l?"showLess":"readMore")}),(0,r.jsxs)("div",{className:"mt-2 flex items-center justify-end gap-1.5 text-[10px] text-muted-foreground",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:(0,h.cn)("h-1.5 w-1.5 shrink-0 rounded-full","running"===m&&"animate-pulse bg-blue-500","success"===m&&"bg-emerald-500","error"===m&&"bg-red-500","neutral"===m&&"bg-muted-foreground/50")}),(0,r.jsxs)("span",{children:[c(`status.${u}`)," ",(0,d.m)(new Date(e.created_at),{addSuffix:!0})]})]})]})}function S({projectId:e,className:t,onClose:s}){let d=(0,a.c)("agentActivity"),{selectedAssistant:m,isLoading:p,secrets:x}=(0,N.QP)(),[f,y]=(0,n.useState)("all"),[S,C]=(0,n.useState)("all"),[$,A]=(0,n.useState)(()=>new Set),{data:T,isLoading:E,isFetchingNextPage:R,hasNextPage:I,fetchNextPage:L}=(0,w.ET)({filters:{projectId:e,channel:"coding-agent",actorKey:"all"===f?void 0:f,eventStatus:"all"===S?void 0:S,pageSize:10},refetchInterval:5e3,refetchOnWindowFocus:!1}),_=(0,i.I)({queryKey:["marketplace-personas","agent-activity"],queryFn:v.P3,staleTime:3e5}),M=(0,j.UP)({projectId:e,enabled:!0,staleTime:15e3,refetchInterval:3e4}),F="credits"===x.BILLING_MODE?"opencode":m,P=_.isLoading||M.isLoading||p,O=(0,n.useMemo)(()=>{let e=new Map,t=new Map,s=(s,r)=>{if(!s)return;e.set(s,r);let n=(0,b.Wg)(s);n&&!t.has(n)&&t.set(n,r)};for(let e of _.data??[]){let t={name:e.name,avatar:e.avatar,icon:e.icon};s(e.key,t),e.base_task_id&&s(e.base_task_id,t)}return{byKey:e,byNormalized:t}},[_.data]),q=(0,n.useMemo)(()=>{let e=new Map;for(let t of M.data?.tasks??[]){if(!t.persona_key)continue;let s=O.byKey.get(t.persona_key)??O.byNormalized.get((0,b.Wg)(t.persona_key));s&&(e.set((0,b.Wg)(t.task_id),s),t.short_id&&e.set((0,b.Wg)(t.short_id),s))}return e},[O,M.data?.tasks]),z=e=>{let t=(0,b.Cp)(e),s=e.metadata;for(let e of[t,"string"==typeof s?.persona_key?s.persona_key:null,"string"==typeof s?.scheduled_task_id?s.scheduled_task_id:null,"string"==typeof s?.agent_name?s.agent_name:null].filter(e=>!!e)){let t=(0,b.Wg)(e),s=q.get(t)??O.byKey.get(e)??O.byNormalized.get(t);if(s)return s}return O.byKey.get(t)??O.byNormalized.get((0,b.Wg)(t))},U=(0,n.useMemo)(()=>(T?.pages??[]).flatMap(e=>e.notifications).filter(b.Fp),[T]),D=(0,n.useMemo)(()=>(0,b.V$)((M.data?.tasks??[]).map(e=>({taskId:e.task_id,name:e.name})),U,e=>{let t=z(e);return(0,b.ge)(t?.name)||(0,b.dz)(e)}),[U,O,q,M.data?.tasks]),B=e=>{A(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};return(0,r.jsxs)("div",{className:(0,h.cn)("flex h-full min-h-0 w-full min-w-0 flex-1 flex-col self-stretch bg-background",t),children:[(0,r.jsxs)("div",{className:"flex h-11 w-full min-w-0 items-center justify-between gap-2 border-b border-border px-4",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(l.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,r.jsx)("div",{className:"truncate text-sm font-medium",children:d("title")})]}),s&&(0,r.jsx)(u.$,{variant:"ghost",size:"icon",onClick:s,className:"h-8 w-8 shrink-0","aria-label":d("close"),title:d("close"),children:(0,r.jsx)(o.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3 py-2",children:[(0,r.jsxs)(g.l6,{value:f,onValueChange:y,children:[(0,r.jsx)(g.bq,{className:"h-8 min-w-0 flex-1 text-xs",children:(0,r.jsx)(g.yv,{})}),(0,r.jsxs)(g.gC,{children:[(0,r.jsx)(g.eb,{value:"all",children:d("filters.allTeammates")}),D.map(e=>(0,r.jsx)(g.eb,{value:e.key,children:e.label},e.key))]})]}),(0,r.jsxs)(g.l6,{value:S,onValueChange:e=>C(e),children:[(0,r.jsx)(g.bq,{className:"h-8 w-[122px] text-xs",children:(0,r.jsx)(g.yv,{})}),(0,r.jsxs)(g.gC,{children:[(0,r.jsx)(g.eb,{value:"all",children:d("filters.allStatus")}),(0,r.jsx)(g.eb,{value:"started",children:d("status.started")}),(0,r.jsx)(g.eb,{value:"completed",children:d("status.completed")}),(0,r.jsx)(g.eb,{value:"failed",children:d("status.failed")}),(0,r.jsx)(g.eb,{value:"updated",children:d("status.updated")})]})]})]}),(0,r.jsx)("div",{className:"min-h-0 w-full min-w-0 flex-1 overflow-y-auto p-3",onScroll:e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight>120||I&&!R&&L()},children:E?(0,r.jsx)("div",{className:"flex h-28 items-center justify-center text-muted-foreground",children:(0,r.jsx)(c.A,{className:"h-4 w-4 animate-spin"})}):0===U.length?(0,r.jsx)("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground",children:d("empty")}):(0,r.jsxs)("div",{className:"space-y-2",children:[U.map(e=>(0,r.jsx)(k,{notification:e,persona:z(e),fallbackAssistant:F,identityLoading:P,isExpanded:$.has(e.id),onToggle:B},e.id)),(I||R)&&(0,r.jsx)("div",{className:"flex items-center justify-center gap-2 py-3 text-xs text-muted-foreground",children:R?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c.A,{className:"h-3.5 w-3.5 animate-spin"}),(0,r.jsx)("span",{children:d("loadingMore")})]}):(0,r.jsx)(u.$,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>
1void L(),children:d("loadMore")})})]})})]})}},38777:(e,t,s)=>{s.d(t,{A:()=>r});function r(e){let t,s="localhost"===(t=window.location.hostname)||"127.0.0.1"===t?`${e}.localhost`:"staging.dynamicode.ai"===t||t?.endsWith(".staging.dynamicode.ai")?`${e}.staging.dynamicode.ai`:`${e}.dynamicode.ai`,r=s.endsWith(".localhost")?"http":"https";return`${r}://${s}`}},40192:(e,t,s)=>{s.d(t,{e:()=>x});var r=s(95155),n=s(92972),a=s(96618),i=s(25237),l=s(33940),o=s(89239),c=s(14400),d=s(95553),u=s(85779),m=s(40980),h=s(50910);let p=[{id:"desktop",icon:n.A},{id:"tablet",icon:a.A},{id:"mobile",icon:i.A}];function x({selection:e,onChange:t,compact:s=!1,triggerClassName:n}){let a=(0,h.c)("preview.viewports"),i=s=>t((0,u.h1)(e,s));return(0,r.jsxs)(c.rI,{children:[(0,r.jsx)(c.ty,{asChild:!0,children:(0,r.jsxs)(o.$,{variant:"outline",size:"sm",className:(0,m.cn)(s?"h-8 w-8 px-0":"w-full justify-between gap-2",n),"aria-label":a("selected",{viewports:e.enabled.join(", ")}),children:[(0,r.jsx)(l.A,{className:"h-4 w-4"}),!s&&(0,r.jsx)("span",{children:a("title")})]})}),(0,r.jsxs)(c.SQ,{align:"start",className:"w-72",children:[(0,r.jsx)(c.lp,{children:a("title")}),(0,r.jsxs)(c.hO,{checked:e.enabled.includes("responsive"),onCheckedChange:()=>i("responsive"),children:[(0,r.jsx)(l.A,{className:"mr-2 h-4 w-4"}),a("responsive")]}),(0,r.jsx)(c.mB,{}),p.map(({id:s,icon:n})=>(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)(c.hO,{checked:e.enabled.includes(s),onCheckedChange:()=>i(s),onSelect:e=>e.preventDefault(),className:"min-w-0 flex-1",children:[(0,r.jsx)(n,{className:"mr-2 h-4 w-4"}),a(s)]}),(0,r.jsxs)(c.lv,{children:[(0,r.jsx)(c.nV,{className:"w-28 justify-end px-2 text-xs text-muted-foreground","aria-label":a("chooseSize",{category:a(s)}),children:a("size")}),(0,r.jsx)(c.M5,{className:"w-64",children:(0,r.jsx)(c.Hr,{value:e.deviceIds[s],children:d.cj.filter(e=>e.category===s&&"responsive"!==e.id).map(s=>(0,r.jsxs)(c.Ht,{value:s.id,onSelect:()=>t((0,u.HJ)(e,s)),children:[(0,r.jsx)("span",{className:"truncate",children:s.name}),(0,r.jsxs)("span",{className:"ml-auto text-xs text-muted-foreground",children:[s.width,"\xd7",s.height]})]},s.id))})})]})]},s))]})]})}},43021:(e,t,s)=>{s.d(t,{T:()=>x});var r=s(95155),n=s(89239),a=s(14400),i=s(6296),l=s(20232),o=s(66088),c=s(91958),d=s(36201),u=s(61878),m=s(1164),h=s(40980),p=s(50910);function x({isRunning:e,isRebuilding:t,isStopping:s,isDiscovering:x,isStarting:f,hasEnvVars:g,onRebuild:w,onStop:j,onRediscover:b,onSettings:v,onStart:y,startDisabledReason:N,disabled:k,compact:S=!1,triggerClassName:C}){let $=(0,p.c)("preview.actions"),A=t||s||x||f;return(0,r.jsxs)(a.rI,{children:[(0,r.jsx)(a.ty,{asChild:!0,children:(0,r.jsxs)(n.$,{variant:"outline",size:"sm",className:(0,h.cn)(S?"h-8 w-8 px-0":"gap-2",C),disabled:k,"aria-label":$(e?"menuLabel":"startPreview"),children:[A?(0,r.jsx)(i.A,{className:"h-4 w-4 animate-spin"}):e?(0,r.jsx)(l.A,{className:"h-4 w-4 fill-current"}):(0,r.jsx)(l.A,{className:"h-4 w-4"}),!S&&(0,r.jsxs)(r.Fragment,{children:[$(e?"preview":"start"),(0,r.jsx)(o.A,{className:"h-3 w-3 opacity-50"})]})]})}),(0,r.jsx)(a.SQ,{align:"end",className:"w-64",children:e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(a._2,{onClick:w,disabled:t,className:"flex flex-col items-start gap-0.5 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(c.A,{className:(0,h.cn)("h-4 w-4",t&&"animate-spin")}),(0,r.jsx)("span",{className:"font-medium",children:$("rebuild")})]}),(0,r.jsx)("span",{className:"ml-6 text-xs text-muted-foreground",children:$("rebuildDescription")})]}),(0,r.jsxs)(a._2,{onClick:j,disabled:s,className:"flex flex-col items-start gap-0.5 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(d.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"font-medium",children:$("stop")})]}),(0,r.jsx)("span",{className:"ml-6 text-xs text-muted-foreground",children:$("stopDescription")})]}),(0,r.jsx)(a.mB,{}),(0,r.jsxs)(a._2,{onClick:b,disabled:x,className:"flex flex-col items-start gap-0.5 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[x?(0,r.jsx)(i.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(u.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"font-medium",children:$("rediscover")})]}),(0,r.jsx)("span",{className:"ml-6 text-xs text-muted-foreground",children:$("rediscoverDescription")})]}),g&&(0,r.jsxs)(a._2,{onClick:v,className:"flex flex-col items-start gap-0.5 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(m.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"font-medium",children:$("settings")})]}),(0,r.jsx)("span",{className:"ml-6 text-xs text-muted-foreground",children:$("settingsDescription")})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(a._2,{onClick:y,disabled:f||!y||!!N,className:"flex flex-col items-start gap-0.5 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[f?(0,r.jsx)(i.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(l.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"font-medium",children:$("startPreview")})]}),(0,r.jsx)("span",{className:(0,h.cn)("ml-6 text-xs text-muted-foreground",N&&"text-amber-600 dar
1k:text-amber-400"),children:N||$("startDescription")})]}),(0,r.jsx)(a.mB,{}),(0,r.jsxs)(a._2,{onClick:b,disabled:x,className:"flex flex-col items-start gap-0.5 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[x?(0,r.jsx)(i.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(u.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"font-medium",children:$("rediscover")})]}),(0,r.jsx)("span",{className:"ml-6 text-xs text-muted-foreground",children:$("rediscoverDescription")})]}),g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.mB,{}),(0,r.jsxs)(a._2,{onClick:v,className:"flex flex-col items-start gap-0.5 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(m.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"font-medium",children:$("settings")})]}),(0,r.jsx)("span",{className:"ml-6 text-xs text-muted-foreground",children:$("settingsDescription")})]})]})]})})]})}},44364:(e,t,s)=>{s.d(t,{b:()=>F});var r=s(95155),n=s(12115),a=s(26708),i=s(35625),l=s(6296),o=s(96035),c=s(93219),d=s(51914),u=s(33210),m=s(21362),h=s(13175),p=s(12651),x=s(62791),f=s(66088),g=s(45160),w=s(89239),j=s(19382),b=s(60529),v=s(12036),y=s(95856),N=s(79743),k=s(99412),S=s(6695),C=s(40980);let $={high:0,medium:1,low:2};function A(e){let t=[e.desktopScore,e.mobileScore].filter(e=>"number"==typeof e);return t.length?Math.min(...t):1e3}async function T(e,t){let s=await fetch(e,{...t,cache:"no-store"}),r=await s.json().catch(()=>null);if(!s.ok)throw Error(r?.error||r?.detail||"Request failed");return r}function E(e){return null==e?"text-muted-foreground":e>=90?"text-emerald-600":e>=50?"text-amber-600":"text-red-600"}function R(e,t){return e?.metrics?.[t]?.displayValue||"-"}function I(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:e>=100?0:1}).format(e)}function L(e){return null==e?null:e>=1e3?`${I(e/1e3)} s`:`${I(e)} ms`}function _(e){try{let t=new URL(e.trim());return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}}function M({projectId:e,batchId:t,item:s,checkedKeys:i,onToggleTask:c,onReport:d,onAttachToChat:u}){let m=(0,a.I)({queryKey:["lighthouse-batch-result",e,t,s.urlHash],queryFn:()=>T(`/api/v1/projects/${e}/lighthouse/batch/${t}/results/${s.urlHash}`),enabled:"succeeded"===s.status,staleTime:3e5}),h=m.data;if((0,n.useEffect)(()=>{h&&d(s.urlHash,h)},[h,s.urlHash,d]),m.isLoading)return(0,r.jsxs)("div",{className:"flex items-center gap-2 border-t p-3 text-xs text-muted-foreground",children:[(0,r.jsx)(l.A,{className:"h-3 w-3 animate-spin"}),"Loading report…"]});if(m.isError||!h)return(0,r.jsx)("div",{className:"border-t p-3 text-xs text-destructive",children:"Failed to load the report for this URL."});let p=h.profiles.desktop,x=h.profiles.mobile,f=h.taskSuggestions??[];return(0,r.jsxs)("div",{className:"space-y-3 border-t p-3",children:[(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[["Desktop",p],["Mobile",x]].map(([e,t])=>{let s=t?.scores?.performance;return(0,r.jsxs)("div",{className:"rounded-md border p-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:e}),(0,r.jsx)("span",{className:(0,C.cn)("text-2xl font-semibold",E(s)),children:s??"-"})]}),(0,r.jsxs)("div",{className:"mt-3 grid grid-cols-1 gap-2 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{children:["LCP ",R(t,"largestContentfulPaint")]}),(0,r.jsxs)("span",{children:["TBT ",R(t,"totalBlockingTime")]}),(0,r.jsxs)("span",{children:["CLS ",R(t,"cumulativeLayoutShift")]})]})]},e)})}),(0,r.jsxs)(w.$,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let e,t,s,r;return u((e=h.profiles.desktop,t=h.profiles.mobile,s=(e,t)=>[`${e} scores: performance ${t?.scores?.performance??"n/a"}, accessibility ${t?.scores?.accessibility??"n/a"}, best practices ${t?.scores?.["best-practices"]??"n/a"}, SEO ${t?.scores?.seo??"n/a"}`,`${e} metrics: FCP ${R(t,"firstContentfulPaint")}; LCP ${R(t,"largestContentfulPaint")}; Speed Index ${R(t,"speedIndex")}; TBT ${R(t,"totalBlockingTime")}; CLS ${R(t,"cumulativeLayoutShift")}; total weight ${R(t,"totalByteWeight")}`,t?.finalUrl?`${e} final URL: ${t.finalUrl}
1`:null].filter(Boolean).join("\n"),r=h.findings.map((e,t)=>{let s=e.profiles.join(", "),r=Object.entries(e.displayValues||{}).filter(([,e])=>e).map(([e,t])=>`${e}: ${t}`).join("; "),n=Object.entries(e.scores||{}).filter(([,e])=>null!=e).map(([e,t])=>`${e}: ${t}`).join("; "),a=Object.entries(e.evidenceByProfile||{}).map(([e,t])=>t?.length?[`  ${e} evidence:`,...t.map(e=>{let t,s;return`  - ${t=e.url||e.source||e.node||e.selector||e.snippet||e.groupLabel||e.resourceType||"item",(s=[null!=e.totalBytes&&`total ${I(e.totalBytes/1024)} KiB`,null!=e.wastedBytes&&`wasted ${I(e.wastedBytes/1024)} KiB`,null!=e.wastedMs&&`wasted ${L(e.wastedMs)}`,null!=e.duration&&`duration ${L(e.duration)}`,null!=e.mainThreadTime&&`main thread ${L(e.mainThreadTime)}`,null!=e.transferSize&&`transfer ${I(e.transferSize/1024)} KiB`,null!=e.resourceSize&&`resource ${I(e.resourceSize/1024)} KiB`,e.resourceType&&`type ${e.resourceType}`,e.mimeType&&`mime ${e.mimeType}`,e.protocol&&`protocol ${e.protocol}`].filter(Boolean)).length?`${t} (${s.join(", ")})`:t}`})].join("\n"):null).filter(Boolean).join("\n");return[`${t+1}. [${e.priority}] ${e.title} (${s})`,r?`   Observed: ${r}`:null,n?`   Audit scores: ${n}`:null,e.description?`   Audit description: ${e.description}`:null,a||null].filter(Boolean).join("\n")}),["Use this Lighthouse preview speed analysis as context.","",`URL: ${h.url}`,`Run ID: ${h.runId}`,`Generated: ${h.generatedAt}`,`Duration: ${L(h.durationMs)}`,"",s("Desktop",e),"",s("Mobile",t),"",`Findings (${h.findings.length}):`,...r,"","Full structured extracted Lighthouse report JSON:",JSON.stringify(h,null,2)].join("\n")))},children:[(0,r.jsx)(o.A,{className:"h-4 w-4"}),"Attach this page to chat"]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase text-muted-foreground",children:"Findings"}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[h.findings.length," found"]})]}),0===h.findings.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"No failing audits for this page."}),h.findings.map(e=>{var t;let n=e.key,a=f.find(e=>e.sourceFindingKey===n),l=`${s.urlHash}::${n}`;return(0,r.jsx)("div",{className:"rounded-md border p-3",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)(j.S,{checked:i.has(l),onCheckedChange:e=>c(l,!0===e),disabled:!a,"aria-label":`Select ${e.title}`}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:e.title}),(0,r.jsx)(g.E,{variant:"high"===(t=e.priority)?"destructive":"medium"===t?"secondary":"outline",children:e.priority})]}),(0,r.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.profiles.join(", "),Object.values(e.displayValues||{}).filter(Boolean).length?` - ${Object.values(e.displayValues||{}).filter(Boolean).join("; ")}`:""]})]})]})},n)})]})]})}function F({open:e,onOpenChange:t,projectId:s,previewUrl:R,isPreviewRunning:I,focusSlug:L,onAttachToChat:F}){let{toast:P}=(0,S.dj)(),O=(0,i.jE)(),[q,z]=(0,n.useState)([]),[U,D]=(0,n.useState)(""),[B,W]=(0,n.useState)(!1),[H,V]=(0,n.useState)(""),[K,G]=(0,n.useState)([]),[J,Q]=(0,n.useState)(new Set),[Y,Z]=(0,n.useState)(""),[X,ee]=(0,n.use
1State)(!1),[et,es]=(0,n.useState)(!1),[er,en]=(0,n.useState)(null),[ea,ei]=(0,n.useState)(new Set),[el,eo]=(0,n.useState)({}),[ec,ed]=(0,n.useState)(new Set),[eu,em]=(0,n.useState)(!1),[eh,ep]=(0,n.useState)(!1),[ex,ef]=(0,n.useState)(!1);(0,n.useEffect)(()=>{e&&!U&&R&&D(R)},[e,U,R]);let eg=(0,a.I)({queryKey:["lighthouse-batch",s,er??"latest"],queryFn:()=>er?T(`/api/v1/projects/${s}/lighthouse/batch/${er}`):T(`/api/v1/projects/${s}/lighthouse/batch/latest`),enabled:e,refetchInterval:e=>e.state.data?.status==="running"&&5e3}),ew=(0,a.I)({queryKey:["lighthouse-history",s],queryFn:()=>T(`/api/v1/projects/${s}/lighthouse/history?limit=10`),enabled:e}),ej=eg.data&&"none"!==eg.data.status?eg.data:null,eb=ej?.status==="running",ev=(0,n.useMemo)(()=>{let e=[];for(let t of ec){let[s]=t.split("::",1),r=el[s??""];if(!r)continue;let n=(r.taskSuggestions??[]).find(e=>{var r;return r=s??"",`${r}::${e.sourceFindingKey||e.title}`===t});n&&e.push({urlHash:s,url:r.url,suggestion:n})}return e},[ec,el]);function ey(e){let t=e.trim();if(t){if(!_(t))return void P({title:"Invalid URL",description:"Enter a full http(s) URL, e.g. https://example.com/pricing",variant:"destructive"});if(q.includes(t))return void P({title:"URL already in the list"});if(q.length>=25)return void P({title:"Maximum 25 URLs per batch",variant:"destructive"});z(e=>[...e,t])}}async function eN(){let e=H.trim();if(!_(e))return void P({title:"Invalid sitemap URL",description:"Enter the full URL of a sitemap.xml file",variant:"destructive"});ee(!0);try{let t=await T(`/api/v1/projects/${s}/lighthouse/sitemap`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})});G(t.urls),es(!!t.truncated),Q(new Set(t.urls.length<=50?t.urls:[])),Z(""),t.urls.length||P({title:"No URLs found in that sitemap"})}catch(e){P({title:"Failed to import sitemap",description:e instanceof Error?e.message:"Unknown error",variant:"destructive"})}finally{ee(!1)}}async function ek(){if(q.length){em(!0);try{let e=await T(`/api/v1/projects/${s}/lighthouse/batch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({urls:q})});e.accepted?P({title:`Speed analysis started for ${e.total??q.length} URL${(e.total??q.length)===1?"":"s"}`}):P({title:"A batch is already running",description:"Wait for it to finish before starting another."}),en(e.batch?.batchId??null),await eg.refetch()}catch(e){P({title:"Failed to start batch",description:e instanceof Error?e.message:"Unknown error",variant:"destructive"})}finally{em(!1)}}}async function eS(){if(ej?.batchId){ep(!0);try{await T(`/api/v1/projects/${s}/lighthouse/batch/${ej.batchId}/cancel`,{method:"POST"}),P({title:"Cancelling batch — running pages will finish"}),await eg.refetch()}catch(e){P({title:"Failed to cancel batch",description:e instanceof Error?e.message:"Unknown error",variant:"destructive"})}finally{ep(!1)}}}async function eC(){if(!ej)return el;let e=ej.items.filter(e=>"succeeded"===e.status).filter(e=>!el[e.urlHash]);if(e.length){let t=await Promise.all(e.map(e=>T(`/api/v1/projects/${s}/lighthouse/batch/${ej.batchId}/results/${e.urlHash}`).then(t=>[e.urlHash,t]))),r={...el};for(let[e,s]of t)r[e]=s;return eo(r),r}return el}async function e$(){if(ej)try{let e=await eC();F(function(e,t,s=8){let r=e.items.filter(e=>"succeeded"===e.status),n=e.items.filter(e=>"failed"===e.status),a=r.filter(e=>t[e.urlHash]),i=["Use this Lighthouse batch speed analysis as context.","",`Batch: ${e.batchId} (${e.status}) — ${r.length} of ${e.total} URLs analyzed`+(n.length?`, ${n.length} failed`:"")],l=n.length?["","Failed URLs:",...n.map(e=>`- ${e.url} (${e.error||"unknown error"})`)]:[],o=[...r].sort((e,t)=>A(e)-A(t)).map(e=>{let r=t[e.urlHash],n=[`URL: ${e.url}`,`Desktop performance: ${e.desktopScore??"n/a"} | Mobile performance: ${e.mobileScore??"n/a"}`];if(r){let e=[...r.findings].sort((e,t)=>($[e.priority]??3)-($[t.priority]??3)).slice(0,s);if(e.length)for(let t of(n.push(`Findings (top ${e.length} of ${r.findings.length}):`),e)){let e=Object.entries(t.displayValues||{}).filter(([,e])=>e).map(([e,t])=>`${e}: ${t}`).join("; ");n.push(`- [${t.priority}] ${t.title} (${t.profiles.join(", ")})`+(e?` — ${e}`:""))}else n.push("Findings: none — this page passed the analyzed audits.")}else n.push("(Detailed report not loaded for this URL.)");return n.join("\n")}),c=e.total<=5&&a.length===r.length&&r.length>0,d=c?["","Full structured extracted Lighthouse reports (per URL):",...a.map(e=>`--- ${e.url} ---
2${JSON.stringify(t[e.urlHash],null,2)}`)]:[],u=r.length&&!c?["","Raw Lighthouse JSON per URL is stored in the project workspace under .dynamicode/lighthouse/batches/ (see each report's rawReportFiles)."]:[];return[...i,...l,"",...o.flatMap(e=>[e,""]),...d,...u].join("\n").replace(/\n{3,}/g,"\n\n").trim()}(ej,e))}catch(e){P({title:"Failed to build the batch report",description:e instanceof Error?e.message:"Unknown error",variant:"destructive"})}}async function eA(){if(ev.length){if(!L||!L.trim())return void P({title:"No active focus",description:"Select an active focus before adding Task Master work items.",variant:"destructive"});ef(!0);try{for(let r of ev){var e,t;await T(`/api/v1/taskmaster/projects/${s}/tasks?focus=${encodeURIComponent(L.trim())}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:(e=r.url,t=r.suggestion.title,`[${function(e){try{let t=new URL(e),s=t.pathname.replace(/\/+$/,"");return`${t.host}${s||"/"}`}catch{return e}}(e)}] ${t}`),description:r.suggestion.description,priority:r.suggestion.priority,details:r.suggestion.details,test_strategy:r.suggestion.test_strategy})})}P({title:`Added ${ev.length} Lighthouse task${1===ev.length?"":"s"}`}),ed(new Set),O.invalidateQueries({queryKey:["projectTasks"]})}catch(e){P({title:"Failed to add tasks",description:e instanceof Error?e.message:"Unknown error",variant:"destructive"})}finally{ef(!1)}}}function eT(e,t){ed(s=>{let r=new Set(s);return t?r.add(e):r.delete(e),r})}function eE(e){ei(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}function eR(e,t){eo(s=>s[e]===t?s:{...s,[e]:t})}let eI=(ej?.completedCount??0)+(ej?.failedCount??0)+(ej?.cancelledCount??0),eL=ej&&ej.total?Math.round(eI/ej.total*100):0,e_=K.filter(e=>!Y||e.toLowerCase().includes(Y.toLowerCase())),eM=q.some(e=>R&&e.startsWith(R.replace(/\/+$/,"")));return(0,r.jsx)(k.cj,{open:e,onOpenChange:t,children:(0,r.jsxs)(k.h,{side:"right",className:"flex w-[92vw] flex-col p-0 sm:max-w-xl",children:[(0,r.jsxs)(k.Fm,{className:"shrink-0 border-b px-5 py-4 pr-12",children:[(0,r.jsxs)(k.qp,{className:"flex items-center gap-2",children:[(0,r.jsx)(c.A,{className:"h-4 w-4"}),"Speed analysis"]}),(0,r.jsx)(k.Qs,{children:"Lighthouse desktop and mobile runs for this preview or any live page."})]}),(0,r.jsx)(y.F,{className:"flex-1",children:(0,r.jsxs)("div",{className:"space-y-5 p-5",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Analyze URLs"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(b.p,{value:U,onChange:e=>D(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),ey(U))},placeholder:"https://example.com/pricing",className:"h-9 min-w-0 flex-1"}),(0,r.jsxs)(w.$,{size:"sm",className:"gap-2",onClick:()=>ey(U),children:[(0,r.jsx)(d.A,{className:"h-4 w-4"}),"Add"]})]}),q.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:[q.length," of ",25," URLs in this batch"]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:q.map(e=>(0,r.jsxs)("span",{className:"inline-flex max-w-full items-center gap-1 rounded-md border px-2 py-1 text-xs",children:[(0,r.jsx)("span",{className:"truncate",children:e}),(0,r.jsx)("button",{type:"button","aria-label":`Remove ${e}`,onClick:()=>{z(t=>t.filter(t=>t!==e))},className:"text-muted-foreground hover:text-destructive",children:(0,r.jsx)(u.A,{className:"h-3 w-3"})})]},e))}),eM&&!I&&(0,r.jsx)("p",{className:"text-xs text-amber-600",children:"The preview is not running — preview URLs may fail to analyze."})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)(w.$,{variant:"ghost",size:"sm",className:"gap-2 px-0 text-muted-foreground",onClick:()=>{W(e=>!e),H||V(function(e){for(let t of e)try{let e=new URL(t);return`${e.origin}/sitemap.xml`}catch{continue}return""}(q.length?q:R?[R]:[]))},children:[(0,r.jsx)(m.A,{className:(0,C.cn)("h-4 w-4 transition-transform",B&&"rotate-90")}),"Import from sitemap"]}),B&&(0,r.jsxs)("div",{className:"mt-2 space-y-3 rounded-md border p-3",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(b.p,{value:H,onChange:e=>V(e.target.value),placeholder:"https://example.com/sitemap.xml",className:"h-9 min-w-0 flex-1"}),(0,r.jsxs)(w.$,{size:"sm",onClick:eN,disabled:X,className:"gap-2",children:[X&&(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin"}),"Fetch"]})]}),K.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:[J.size," of ",K.length," ","selected",et?" (sitemap truncated at 500 URLs)":""]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w.$,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>Q(new Set(e_)),children:"Select all"}),(0,r.jsx)(w.$,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>Q(new Set),children:"None"})]})]}),(0,r.jsx)(b.p,{value:Y,onChange:e=>Z(e.target.value),placeholder:"Filter URLs…",className:"h-8 text-xs"}),(0,r.jsxs)("div",{className:"max-h-64 space-y-1 overflow-y-auto rounded-md border p-2",children:[e_.map(e=>(0,r.jsxs)("label",{className:"flex items-start gap-2 rounded px-1 py-0.5 text-xs hover:bg-muted/50",children:[(0,r.jsx)(j.S,{checked:J.has(e),onCheckedChange:t=>Q(s=>{let r=new Set(s);return t?r.add(e):r.delete(e),r})}),(0,r.jsx)("span",{className:"break-all",children:e})]},e)),!e_.length&&(0,r.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground",children:"No URLs match the filter."})]}),(0,r.jsxs)(w.$,{size:"sm",className:"w-full",onClick:function(){let e=K.filter(e=>J.has(e)).filter(e=>!q.includes(e)),t=e.slice(0,25-q.length);t.length?(z(e=>[...e,...t]),W(!1),G([]),Q(new Set),es(!1),e.length>t.length?P({title:`Added ${t.length} URLs`,description:"Selection was capped at the 25-URL batch limit."}):P({title:`Added ${t.length} URLs`})):P({title:e.length?"Batch limit reached (25 URLs)":"Select at least one new URL",variant:"destructive"})},disabled:!J.size,children:["Add ",J.size," URL",1===J.size?"":"s"," to batch"]})]})]})]}),(0,r.jsxs)(w.$,{onClick:ek,disabled:!q.length||eu||eb,size:"sm",className:"gap-2",children:[(eu||eb)&&(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin"}),eb?"Batch running…":`Analyze ${q.length||""} URL${1===q.length?"":"s"}`]})]}),ej&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.w,{}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Results"}),(0,r.jsx)(g.E,{variant:"outline",children:ej.status})]}),eb&&(0,r.jsxs)(w.$,{variant:"outline",size:"sm",onClick:eS,disabled:eh,className:"gap-2",children:[eh?(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(h.A,{className:"h-4 w-4"}),"Cancel"]})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{children:[eI," of ",ej.total," URLs analyzed",ej.failedCount?` — ${ej.failedCount} failed`:""]}),(0,r.jsxs)("span",{children:[eL,"%"]})]}),(0,r.jsx)(v.k,{value:eL,className:"h-2"})]}),ej.error&&(0,r.jsx)("p",{className:"rounded-md border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive",children:ej.error}),(0,r.jsx)("div",{className:"space-y-2",children:ej.items.map(e=>{let t=ea.has(e.urlHash);return(0,r.jsxs)("div",{className:"rounded-md border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 p-3",children:["running"===e.status&&(0,r.jsx)(l.A,{className:"h-4 w-4 shrink-0 animate-spin text-muted-foreground"}),"pending"===e.status&&(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full border"}),"succeeded"===e.status&&(0,r.jsx)(p.A,{className:"h-4 w-4 shrink-0 text-emerald-600"}),"failed"===e.status&&(0,r.jsx)(x.A,{className:"h-4 w-4 shrink-0 text-red-600"}),"cancelled"===e.status&&(0,r.jsx)(h.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:(0,C.cn)("truncate text-sm","succeeded"===e.status&&"cursor-pointer font-medium"),onClick:()=>"succeeded"===e.status&&eE(e.urlHash),children:e.url}),e.error&&(0,r.jsx)("p",{className:"truncate text-xs text-destructive",children:e.error})]}),"succeeded"===e.status&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:(0,C.cn)("shrink-0 text-sm",E(e.desktopScore)),children:["D ",e.desktopScore??"-"]}),(0,r.jsxs)("span",{className:(0,C.cn)("shrink-0 text-sm",E(e.mobileScore)),children:["M ",e.mobileScore??"-"]}),(0,r.jsx)("button",{type:"button","aria-label":"Toggle details",onClick:()=>eE(e.urlHash),className:"text-muted-foreground",children:t?(0,r.jsx)(f.A,{className:"h-4 w-4"}):(0,r.jsx)(m.A,{className:"h-4 w-4"})})]})]}),t&&"succeeded"===e.status&&(0,r.jsx)(M,{projectId:s,batchId:ej.batchId,item:e,checkedKeys:ec,onToggleTask:eT,onReport:eR,onAttachToChat:F})]},e.urlHash)})}),!eb&&ej.completedCount>0&&(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsxs)(w.$,{variant:"outline",size:"sm",className:"gap-2",onClick:e$,children:[(0,r.jsx)(o.A,{className:"h-4 w-4"}),"Attach report to chat"]}),(0,r.jsxs)(w.$,{variant:"outline",size:"sm",className:"gap-2",disabled:!ev.length||ex,onClick:eA,children:[ex?(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(d.A,{className:"h-4 w-4"}),"Add ",ev.length||""," task",1===ev.length?"":"s"]})]}),!eb&&!L&&ev.length>0&&(0,r.jsx)("p",{className:"text-xs text-amber-600",children:"No active focus — select one on the Tasks tab before adding these work items."})]})]}),(0,r.jsx)(N.w,{}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"History"}),0===(ew.data?.runs??[]).length&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Completed runs will appear here."}),(ew.data?.runs??[]).map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-md border p-3",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"truncate text-sm font-medium",children:new Date(e.generated_at).toLocaleStr
2ing()}),(0,r.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:e.url||e.run_id})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-3 text-sm",children:[(0,r.jsxs)("span",{className:E(e.performance_desktop),children:["D ",e.performance_desktop??"-"]}),(0,r.jsxs)("span",{className:E(e.performance_mobile),children:["M ",e.performance_mobile??"-"]})]})]},e.id))]})]})})]})})}},44372:(e,t,s)=>{s.d(t,{NH:()=>i,gv:()=>a,ri:()=>l});var r=s(40980);let n="h-8 min-h-8 w-8 px-0 shadow-none",a=(0,r.cn)(n,"border-border/60 bg-card/55 hover:bg-accent/70"),i="data-[state=open]:border-primary data-[state=open]:bg-primary data-[state=open]:text-primary-foreground data-[state=open]:hover:bg-primary/90 data-[state=open]:hover:text-primary-foreground";function l(e,t){return(0,r.cn)(n,e?"border-primary bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground":"border-border/60 bg-card/55 hover:bg-accent/70",t)}},63569:(e,t,s)=>{s.d(t,{A:()=>n});var r=s(12115);function n({identity:e,isRunning:t,isBuilding:s,reload:n,routesReady:a=!0}){let[i,l]=(0,r.useState)(!1),o=(0,r.useRef)(!1),c=(0,r.useRef)(!1);(0,r.useEffect)(()=>
2{l(!1),o.current=!1,c.current=!1},[e]),(0,r.useEffect)(()=>{s?(l(!1),o.current=!1,c.current=!0):t&&(o.current?l(!0):a&&c.current&&(c.current=!1,n()))},[e,t,s,n,a]);let d=(0,r.useCallback)(()=>{!s&&(o.current=!0,c.current=!1,t&&l(!0))},[t,s]),u=(0,r.useCallback)(()=>{!s&&(t&&a?l(!0):o.current||(c.current=!0))},[t,s,a]);return{ready:i,reset:(0,r.useCallback)(()=>{l(!1),o.current=!1,c.current=!0},[]),onReady:d,onLoad:u}}},67365:(e,t,s)=>{s.d(t,{Ci:()=>i,Pb:()=>a,q$:()=>n,y2:()=>o});var r=s(97199);function n({discoveryStatus:e,isRunning:t,isStarting:s,isRebuilding:r,isDiscovering:n}){return!!t||!s&&!r&&!n&&("failed"===e||"stopped"===e||"idle"===e)}function a({selectedFrontendId:e,serverSelection:t,lastServerSelection:s,runnableFrontendIds:r}){let n=t!==s,a=!!(t&&r.includes(t));return n&&a?{selectedFrontendId:t,lastServerSelection:t}:1===r.length?{selectedFrontendId:r[0],lastServerSelection:t}:{selectedFrontendId:r.includes(e)?e:"",lastServerSelection:t}}function i({projectId:e,reportedPort:t,sticky:s,now:r=Date.now()}){return"number"==typeof t&&t>0?{port:t,nextSticky:{projectId:e,port:t,confirmedAt:r}}:s&&s.projectId===e&&r-s.confirmedAt<12e3?{port:s.port,nextSticky:s}:{port:null,nextSticky:null}}let l=new Set(["DISCOVERY_FAILED","SKILLS_CONTEXT_BUDGET_EXCEEDED","COMPOSE_VALIDATION_FAILED","COMPOSE_DESCRIPTOR_INVALID"]);function o({discoveryStatus:e,isRunning:t,previewReadyForDisplay:s,hostReason:n,isDiscoveryLoading:a,hasDiscoveryError:i,isStarting:o,hasLocalStartingFrontend:c,runnableFrontendCount:d,errorCode:u,error:m}){return"building"===e?"building":!function({isRunning:e,previewReadyForDisplay:t,hostReason:s,discoveryStatus:r}){return e&&t&&"building"!==r&&"auth"!==s&&"host-blocked"!==s}({isRunning:t,previewReadyForDisplay:s,hostReason:n,discoveryStatus:e})?i&&!a?"error":t?"auth"===n||"host-blocked"===n?"error":"starting":"starting"===e?"starting":"failed"===e?!function({runnableFrontendCount:e,errorCode:t,error:s}){let n=(0,r.n)({errorCode:t,error:s});return 0===e&&l.has(n.errorCode)}({runnableFrontendCount:d,errorCode:u,error:m})?"error":"no-frontends":c||o?"starting":0===d?"no-frontends":a||"queued"===e||"running"===e||!e?"discovering":"select-frontend":null}},78520:(e,t,s)=>{s.d(t,{g:()=>o});var r=s(95155),n=s(6489),a=s(95856),i=s(99412),l=s(30810);function o({open:e,onOpenChange:t,projectId:s}){return(0,r.jsx)(i.cj,{open:e,onOpenChange:t,children:(0,r.jsxs)(i.h,{side:"right",className:"flex w-[92vw] flex-col p-0 sm:max-w-xl",children:[(0,r.jsxs)(i.Fm,{className:"shrink-0 border-b px-5 py-4 pr-12",children:[(0,r.jsxs)(i.qp,{className:"flex items-center gap-2",children:[(0,r.jsx)(n.A,{className:"h-4 w-4"}),"Design rules"]}),(0,r.jsx)(i.Qs,{children:"The palette, typography, and style the assistant applies on every turn. Changes take effect the next time the assistant starts."})]}),(0,r.jsx)(a.F,{className:"flex-1",children:(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(l.DesignSystemSection,{projectId:s})})})]})})}},78760:(e,t,s)=>{s.d(t,{V:()=>c});var r=s(95155);s(12115);var n=s(6296),a=s(84980),i=s(40980),l=s(31027);function o(e){if(!e)return"-";if(e<60)return`${e}s`;let t=Math.floor(e/60),s=e%60;return s>0?`${t}m ${s}s`:`${t}m`}function c({currentProjectId:e,compactOnMobile:t=!1}){let{data:s}=(0,l.TG)();if(!s?.is_active)return null;let{summary:c,current:d,queued:u}=s,m=u?.find(t=>t.project_id===e);if(d?.project_id===e){let e=d?.wait_time!==void 0?`Starting preview, ${o(d.wait_time)} elapsed`:"Starting preview";return(0,r.jsxs)("div",{className:(0,i.cn)("inline-flex min-w-0 items-center gap-1.5 text-sm text-blue-600 dark:text-blue-400",t&&"max-sm:gap-0"),"aria-label":e,children:[(0,r.jsx)(n.A,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}),(0,r.jsx)("span",{className:(0,i.cn)(t&&"max-sm:sr-only"),children:"Starting..."}),d?.wait_time!==void 0&&(0,r.jsxs)("span",{className:(0,i.cn)("text-xs text-muted-foreground",t&&"max-sm:sr-only"),children:["(",o(d.wait_time),")"]})]})}if(m){let e=`Preview queued ${m.position} of ${c.pending+1}`;return(0,r.jsxs)("div",{className:(0,i.cn)("inline-flex min-w-0 items-center gap-1.5 text-sm text-amber-600 dar
2k:text-amber-400",t&&"max-sm:gap-0"),"aria-label":e,children:[(0,r.jsx)(a.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,r.jsxs)("span",{className:(0,i.cn)("truncate",t&&"max-sm:sr-only"),children:["Queued #",m.position," of ",c.pending+1]})]})}return null}},84454:(e,t,s)=>{s.d(t,{x:()=>L});var r=s(95155),n=s(12115),a=s(56052),i=s(10762),l=s(49619),o=s(6296),c=s(91958),d=s(68459),u=s(36201),m=s(33210),h=s(51914),p=s(20184),x=s(50910),f=s(89239),g=s(14400),w=s(81612),j=s(6695),b=s(26708),v=s(73936),y=s(41463);let N=new Set([1008,4001,4003,4401,4403]),k={transportState:"idle",runtimeState:null,sessionId:null,error:null};class S extends Error{constructor(e,t,s){super(e),this.retryable=t,this.delayMs=s,this.name="TerminalConnectionFailure"}}class C{push(e){if(this.ended||this.failure)return;let t=this.waiters.shift();t?t.resolve({value:e,done:!1}):this.values.push(e)}end(){if(!this.ended&&!this.failure)for(let e of(this.ended=!0,this.waiters.splice(0)))e.resolve({value:void 0,done:!0})}fail(e){if(!this.ended&&!this.failure&&(this.failure=e,!(this.values.length>0)))for(let t of this.waiters.splice(0))t.reject(e)}[Symbol.asyncIterator](){return{next:()=>{let e=this.values.shift();return void 0!==e?Promise.resolve({value:e,done:!1}):this.failure?Promise.reject(this.failure):this.ended?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})})}}}constructor(){this.values=[],this.waiters=[],this.ended=!1,this.failure=null}}function $(e,t=Math.random){let s=Math.max(0,e),r=Math.min(250*2**s,3e4);return Math.round(r+(Math.min(1e3*2**s,3e4)-r)*t())}function A(e,t){return(e.getQueryCache().find({queryKey:t,exact:!0})?.getObserversCount()??0)>0}var T=s(40980),E=s(21211),R=s(48606);function I({projectId:e,visible:t,online:s,sessionKey:m,launchRequestId:h,variant:p="tab"}){let g=(0,x.c)("developTab.terminal"),I=(0,n.useRef)(null),L=(0,n.useRef)([]),P=(0,n.useRef)(!1),O=(0,n.useRef)(0),q=(0,n.useRef)({cols:120,rows:32}),z=(0,n.useRef)(null),U=(0,n.useRef)(null),D=(0,n.useRef)(null),B=(0,n.useRef)(t),W=(0,n.useRef)("panel"===p||!!h),[H,V]=(0,n.useState)(!1),[K,G]=(0,n.useState)(W.current),J=(0,n.useRef)(h),Q=(0,n.useRef)(W.current&&t),{toast:Y}=(0,j.dj)(),{selectedAssistant:Z,secrets:X}=(0,E.QP)();B.current=t,K&&t&&(Q.current=!0),h&&h!==J.current&&(J.current=h,K||G(!0));let ee=(0,n.useMemo)(()=>"credits"===(X.BILLING_MODE||"byot")?"opencode":Z,[X.BILLING_MODE,Z]),et=(0,R.K0)(ee)?.label??ee??"AI",es=(0,n.useCallback)(()=>{window.requestAnimationFrame(()=>{I.current?.focus()})},[]),er=(0,n.useCallback)(()=>{B.current&&es()},[es]),en=(0,n.useCallback)(()=>{let e=I.current?.instance?.element,t=e?.querySelector("textarea");t instanceof HTMLTextAreaElement&&t.blur()},[]),ea=(0,n.useCallback)(()=>{if(Date.now()-O.current>=400)return;let e=()=>{if(!B.current)return;let e=document.activeElement;(e?.tagName==="IFRAME"||e===document.body||e===document.documentElement)&&es()};window.requestAnimationFrame(e),window.setTimeout(e,50),window.setTimeout(e,150)},[es]),ei=(0,n.useCallback)(e=>{I.current?I.current.write(e):L.current.push(e),e&&"\x1bc"!==e&&(P.current=!0)},[]),el=(0,n.useCallback)(()=>{ei("\x1bc"),P.current=!1},[ei]),eo=(0,n.useCallback)(()=>({cols:I.current?.instance?.cols??q.current.cols,rows:I.current?.instance?.rows??q.current.rows}),[]),ec=(0,n.useCallback)(e=>{Y({title:g("errorTitle"),description:e,variant:"destructive"})},[g,Y]),ed=function({projectId:e,sessionKey:t,clientId:s,enabled:r,launchRequestId:a,messages:i,onOutput:l,onReset:o,onFocus:c,onToastError:d,getSize:u}){let m=(0,n.useRef)({messages:i,onOutput:l,onReset:o,onFocus:c,onToastError:d,getSize:u});m.current={messages:i,onOutput:l,onReset:o,onFocus:c,onToastError:d,getSize:u};let h=(0,n.useRef)(s??("undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`terminal-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`)),p=(0,n.useRef)(k),x=(0,n.useRef)({epoch:null,seq:0}),f=(0,n.useRef)(null),g=(0,n.useRef)(null),w=(0,n.useRef)(0),j=(0,n.useRef)(0),T=(0,n.useRef)(0),E=(0,n.useRef)(!1),R=(0,n.useRef)(!1),I=(0,n.useRef)(new Set),[L,_]=(0,n.use
2State)(0),[M,F]=(0,n.useState)(!1),P=r&&!M,O=["terminal-transport",e,t??null,h.current,L],q=(0,n.useCallback)(e=>{let t={...p.current,...e};return p.current=t,t},[]),z=(0,n.useCallback)(e=>{e.connectTimeout&&clearTimeout(e.connectTimeout),e.stableTimeout&&clearTimeout(e.stableTimeout),e.connectTimeout=null,e.stableTimeout=null,e.socket.onopen=null,e.socket.onmessage=null,e.socket.onerror=null,e.socket.onclose=null,(e.socket.readyState===WebSocket.OPEN||e.socket.readyState===WebSocket.CONNECTING)&&e.socket.close()},[]),U=(0,n.useCallback)(()=>{let e=f.current;e&&(f.current=null,e.queue.end(),z(e))},[z]),D=(0,n.useCallback)(()=>{g.current?.controller.abort(),g.current=null},[]),B=(0,n.useCallback)(e=>{let t=f.current;return!!t&&t.socket.readyState===WebSocket.OPEN&&(t.socket.send(JSON.stringify(e)),!0)},[]),W=(0,n.useCallback)(()=>{let{cols:e,rows:t}=m.current.getSize();return!(e<20)&&!(t<5)&&B({type:"resize",cols:e,rows:t})},[B]),H=(0,n.useCallback)(()=>{let e=f.current;return!!E.current&&!!e?.handshakeComplete&&e.socket.readyState===WebSocket.OPEN&&(W(),e.socket.send(JSON.stringify({type:"launch-assistant"})),E.current=!1,R.current=!0,m.current.onFocus(),!0)},[W]),V=(0,n.useCallback)(async e=>{let t=j.current+1;j.current=t;let s=new AbortController;g.current={id:t,controller:s};let r=null;try{let t=await Promise.race([fetch("/api/v1/auth/websocket-token",{cache:"no-store",signal:s.signal}),new Promise((t,n)=>{r=setTimeout(()=>{s.abort();let t=new S(m.current.messages.connectionTimeout,!0);e?.(t),n(t)},1e4)})]);if(!t.ok)throw new S(m.current.messages.tokenError,401!==t.status&&403!==t.status);let n=await t.json();if(!n.access_token)throw new S(m.current.messages.tokenError,!0);return n.access_token}catch(t){throw t instanceof S&&e?.(t),t}finally{r&&clearTimeout(r),g.current?.id===t&&(g.current=null)}},[]),K=(0,b.I)({queryKey:O,queryFn:(0,v.I)({refetchMode:"reset",initialValue:k,reducer:(e,t)=>t,streamFn:async function*(s){var r,n,a,i;let l,o;if(await Promise.resolve(),!A(s.client,s.queryKey))throw new S("Terminal observer detached",!1);let c=w.current+1;w.current=c;try{l=await s.client.fetchQuery({queryKey:["terminal-websocket-token",e,t??null,h.current,L,c],queryFn:()=>V(e=>{let t=q({transportState:e.retryable?"reconnecting":"error",error:e.message});s.client.setQueryData(s.queryKey,t)}),staleTime:1/0,gcTime:0,retry:!1,networkMode:"always"})}catch(e){if(!A(s.client,s.queryKey))throw new S("Terminal observer detached",!1);if(e instanceof S)throw e;if(e instanceof DOMException&&"AbortError"===e.name)throw new S("Terminal token request cancelled",!1);throw new S(e instanceof Error?e.message:m.current.messages.connectionError,!0)}if(!A(s.client,s.queryKey))throw new S("Terminal observer detached",!1);let d=s.signal;if(d.aborted)return;let u=T.current>0||"ready"===p.current.transportState;if(yield q({transportState:u?"reconnecting":"connecting",error:null}),d.aborted)return;let g=new C,j=new WebSocket((r=l,n=t??p.current.sessionId,a=h.current,i=x.current,"http:"===(o=new URL(y.env.NEXT_PUBLIC_TERMINAL_BASE_URL?.trim()||"https://api.dynamicode.ai".trim()||window.location.origin,window.location.origin)).protocol?o.protocol="ws:":"https:"===o.protocol&&(o.protocol="wss:"),o.pathname=`/api/v1/projects/${encodeURIComponent(e)}/terminal/ws`,o.searchParams.set("token",r),o.searchParams.set("protocol","2"),o.searchParams.set("clientId",a),o.searchParams.set("resumeSeq",i.seq.toString()),i.epoch&&o.searchParams.set("resumeEpoch",i.epoch),n&&o.searchParams.set("sessionId",n),o.toString())),b={id:c,socket:j,queue:g,handshakeComplete:!1,replayMode:"unknown",legacyReset:!1,connectTimeout:null,stableTimeout:null};f.current=b;let v=()=>!d.aborted&&f.current===b&&b.id===c,k=()=>{b.connectTimeout&&clearTimeout(b.connectTimeout),b.stableTimeout&&clearTimeout(b.stableTimeout),b.connectTimeout=null,b.stableTimeout=null},E=(e,t)=>{if(!v())return;f.current=null,k();let s=q({transportState:e,error:t});g.push(s),g.end()},I=e=>{if(!v())return;let t=$(T.current);T.current+=1,f.current=null,k(),j.onclose=null,(j.readyState===WebSocket.OPEN||j.readyState===WebSocket.CONNECTING)&&j.close(),g.pu
2sh(q({transportState:"reconnecting",error:e})),g.fail(new S(e,!0,t))},_=()=>{!v()||(b.connectTimeout&&clearTimeout(b.connectTimeout),b.connectTimeout=null,("ready"!==p.current.transportState||null!==p.current.error)&&g.push(q({transportState:"ready",error:null})),b.handshakeComplete||(b.handshakeComplete=!0,b.stableTimeout=setTimeout(()=>{v()&&j.readyState===WebSocket.OPEN&&(T.current=0)},3e4),W(),H(),m.current.onFocus()))},M=()=>{f.current===b&&(f.current=null,g.end(),z(b))};d.addEventListener("abort",M,{once:!0}),b.connectTimeout=setTimeout(()=>I(m.current.messages.connectionTimeout),1e4),j.onopen=()=>{v()||j.close()},j.onmessage=e=>{if(!v())return;let t=function(e){if("string"!=typeof e)return null;try{let t=JSON.parse(e);return"string"==typeof t.type?t:null}catch{return null}}(e.data);if(t){if("session"===t.type){if(!t.epoch||!t.disposition||"number"!=typeof t.oldestSeq)return;b.replayMode="v2",_(),t.sessionId&&g.push(q({sessionId:t.sessionId}));let e=x.current;"resumed"!==t.disposition||null!==e.epoch&&e.epoch!==t.epoch?(m.current.onReset(),x.current={epoch:t.epoch,seq:Math.max(0,Math.trunc(t.oldestSeq)-1)}):x.current={epoch:t.epoch,seq:e.epoch===t.epoch?e.seq:0};return}if("output"===t.type){if("string"==typeof t.epoch&&"number"==typeof t.seq&&Number.isSafeInteger(t.seq)&&t.seq>=0){b.replayMode="v2",x.current.epoch!==t.epoch&&(m.current.onReset(),x.current={epoch:t.epoch??null,seq:Math.max(0,(t.seq??1)-1)});let e=x.current,s=t.seq??0;if(s<=e.seq)return;if(s!==e.seq+1)return void I(m.current.messages.connectionError);x.current={epoch:t.epoch??e.epoch,seq:s}}else b.legacyReset||(b.replayMode="v1",b.legacyReset=!0,x.current={epoch:null,seq:0},m.current.onReset());_(),R.current&&(R.current=!1,m.current.onFocus()),m.current.onOutput(t.data??"");return}if("status"===t.type){"unknown"===b.replayMode&&(b.replayMode="v1",b.legacyReset=!0,x.current={epoch:null,seq:0},m.current.onReset()),_();let e={};t.sessionId&&(e.sessionId=t.sessionId),("ready"===t.state||"assistant-running"===t.state||"starting"===t.state||"exited"===t.state)&&(e.runtimeState=t.state),Object.keys(e).length>0&&g.push(q(e)),"assistant-running"===t.state&&R.current&&(R.current=!1,m.current.onFocus());return}if("error"===t.type){_(),m.current.onToastError(t.message||m.current.messages.unknownError);return}"exit"===t.type&&(_(),g.push(q({runtimeState:"exited"})))}},j.onerror=()=>{}
2,j.onclose=e=>{if(v()){if(4009===e.code)return void E("replaced",null);if(N.has(e.code))return void E("error",e.reason||m.current.messages.connectionError);I(e.reason||m.current.messages.connectionError)}};try{for await(let e of g)yield e}finally{d.removeEventListener("abort",M),f.current===b&&(f.current=null),z(b)}}}),enabled:P,staleTime:1/0,gcTime:0,retry:(e,t)=>t instanceof S&&t.retryable,retryDelay:(e,t)=>t instanceof S&&void 0!==t.delayMs?t.delayMs:$(e),networkMode:"always",refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),G=K.failureReason??K.error,J=K.data??(P?{...p.current,transportState:"error"===K.status?"error":K.failureCount>0?"reconnecting":"connecting",error:G instanceof Error?G.message:null}:p.current),Q=(0,n.useCallback)(e=>{if(I.current.has(e))return!0;let t=f.current;return!!t?.handshakeComplete&&t.socket.readyState===WebSocket.OPEN&&(W(),t.socket.send(JSON.stringify({type:"launch-assistant"})),I.current.add(e),R.current=!0,m.current.onFocus(),!0)},[W]);(0,b.I)({queryKey:["terminal-launch",e,t??null,h.current,a??null,L],queryFn:async()=>{if(!a||!Q(a))throw Error("Terminal handshake is not ready");return!0},enabled:P&&!!a&&"ready"===J.transportState,staleTime:1/0,gcTime:6e4,retry:!1,networkMode:"always",refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});let Y=(0,n.useCallback)(e=>{let t=f.current;return!!t?.handshakeComplete&&t.socket.readyState===WebSocket.OPEN&&(t.socket.send(JSON.stringify({type:"input",data:e})),!0)},[]),Z=(0,n.useCallback)((e,t)=>!(e<20)&&!(t<5)&&B({type:"resize",cols:e,rows:t}),[B]),X=(0,n.useCallback)(()=>(E.current=!0,!!H()),[H]),ee=(0,n.useCallback)(()=>{D(),U(),T.current=Math.max(1,T.current),q({transportState:"reconnecting",error:null}),F(!1),_(e=>e+1)},[D,U,q]),et=(0,n.useCallback)(()=>{let e=f.current;e?.socket.readyState===WebSocket.OPEN&&e.socket.send(JSON.stringify({type:"terminate"})),D(),U(),E.current=!1,R.current=!1,T.current=0,q({transportState:"closed",runtimeState:"exited",error:null}),_(e=>e+1)},[D,U,q]),es=(0,n.useCallback)(e=>{D(),U(),q({transportState:"error",error:e}),F(!0),_(e=>e+1)},[D,U,q]),er=(0,n.useMemo)(()=>({sendInput:Y,sendResize:Z,queueLaunch:X,reconnect:ee,terminate:et,reportRenderFailure:es}),[X,ee,es,Y,Z,et]);return{snapshot:J,transportState:J.transportState,runtimeState:J.runtimeState,sessionId:J.sessionId,error:J.error,ready:"ready"===J.transportState,hasSocket:null!==f.current,controller:er}}({projectId:e,sessionKey:m,enabled:K&&Q.current,launchRequestId:h,messages:{connectionTimeout:g("connectionTimeout"),tokenError:g("tokenError"),connectionError:g("connectionError"),unknownError:g("unknownError")},onOutput:ei,onReset:el,onFocus:er,onToastError:ec,getSize:eo}),{transportState:eu,runtimeState:em,error:eh,controller:ep}=ed,ex=(0,n.useCallback)((e,t,s=!1)=>!(e<20)&&!(t<5)&&((q.current={cols:e,rows:t},s)?(U.current&&(clearTimeout(U.current),U.current=null),D.current=null,ep.sendResize(e,t)):(D.current={cols:e,rows:t},U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{U.current=null;let e=D.current;D.current=null,e&&ep.sendResize(e.cols,e.rows)},120),!0)),[ep]),ef=(0,n.useCallback)((e=!1)=>{let{cols:t,rows:s}=eo();return ex(t,s,e)},[eo,ex]),eg=(0,n.useCallback)(()=>{null===z.current&&(z.current=window.requestAnimationFrame(()=>{z.current=null,ef()}))},[ef]);(0,n.useEffect)(()=>()=>{null!==z.current&&window.cancelAnimationFrame(z.current),null!==U.current&&clearTimeout(U.current)},[]),(0,n.useEffect)(()=>{t?H&&(eg(),es()):en()},[en,es,H,eg,t]),(0,n.useEffect)(()=>{if(!H)return;let e=I.current?.instance?.element,t=e?.querySelector("textarea");if(t instanceof HTMLTextAreaElement)return t.addEventListener("blur",ea),()=>t.removeEventListener("blur",ea)},[ea,H]);let ew=(0,n.useCallback)(e=>{for(let e of(V(!0),L.current))I.current?.write(e);L.current=[],B.current&&e&&"object"==typeof e&&es(),eg()},[es,eg]),ej=(0,n.useCallback)(()=>{I.current?.write("\x1bc"),P.current=!1},[]),eb=(0,n.useCallback)(()=>{ep.terminate(),Q.current=!1,G(!1)},[ep]),ev=(0,n.useCallback)(()=>{Q.current=!0,G(!0),ep.reconnect()},[ep]),ey=(0,n.useCallback)(()=>{Q.current=!0,G(!0)},[]),eN=(0,n.useCallback)(()=>{Q.current=!0,G(!0),!ep.queueLaunch()&&K&&("idle"===eu||"closed"===eu||"error"===eu||"replaced"===eu)&&ep.reconnect()},[ep,K,eu]),ek=(0,n.useMemo)(()=>s||"idle"!==eu?"ready"===eu&&"assistant-running"===em?g("assistantRunning"):"connecting"===eu?g("
2connecting"):"reconnecting"===eu?g("reconnecting"):"ready"===eu?g("ready"):"replaced"===eu?g("openedElsewhere"):"error"===eu?g("error"):"closed"===eu?g("closed"):g("idle"):g("offline"),[s,em,g,eu]);return(0,r.jsxs)("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden bg-background",children:[(0,r.jsxs)("div",{className:"flex min-h-10 items-center justify-between gap-2 border-b px-3 py-2",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(i.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"truncate text-sm font-medium",children:g("title")}),(0,r.jsx)("span",{className:(0,T.cn)("hidden rounded-sm border px-1.5 py-0.5 text-xs text-muted-foreground sm:inline-flex","ready"===eu&&"border-emerald-500/40 text-emerald-600","ready"===eu&&"assistant-running"===em&&"border-primary/40 text-primary",("error"===eu||"replaced"===eu)&&"border-destructive/40 text-destructive"),children:ek})]}),(0,r.jsx)(w.Bc,{children:(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,r.jsxs)(w.m_,{children:[(0,r.jsx)(w.k$,{asChild:!0,children:(0,r.jsx)(f.$,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:eN,disabled:"connecting"===eu||"reconnecting"===eu,"aria-label":g("launchAssistant",{assistant:et}),children:(0,r.jsx)(l.A,{className:"h-4 w-4"})})}),(0,r.jsx)(w.ZI,{children:g("launchAssistant",{assistant:et})})]}),(0,r.jsxs)(w.m_,{children:[(0,r.jsx)(w.k$,{asChild:!0,children:(0,r.jsx)(f.$,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:ev,"aria-label":g("reconnect"),children:"connecting"===eu||"reconnecting"===eu?(0,r.jsx)(o.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(c.A,{className:"h-4 w-4"})})}),(0,r.jsx)(w.ZI,{children:g("reconnect")})]}),(0,r.jsxs)(w.m_,{children:[(0,r.jsx)(w.k$,{asChild:!0,children:(0,r.jsx)(f.$,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:ej,disabled:!H,"aria-label":g("clear"),children:(0,r.jsx)(d.A,{className:"h-4 w-4"})})}),(0,r.jsx)(w.ZI,{children:g("clear")})]}),(0,r.jsxs)(w.m_,{children:[(0,r.jsx)(w.k$,{asChild:!0,children:(0,r.jsx)(f.$,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:eb,disabled:"idle"===eu||"closed"===eu||"error"===eu||"replaced"===eu,"aria-label":g("terminate"),children:(0,r.jsx)(u.A,{className:"h-4 w-4"})})}),(0,r.jsx)(w.ZI,{children:g("terminate")})]})]})})]}),K?(0,r.jsxs)("div",{className:(0,T.cn)("relative min-h-0 flex-1 overflow-hidden bg-[#050507] max-md:pb-12","panel"===p?"p-1.5":"p-2"),onClick:es,"data-testid":"terminal-viewport",children:[(0,r.jsx)(a.BK,{ref:I,className:"h-full min-h-0 w-full rounded bg-[#050507] [--term-font-size:12px] [--term-line-height:1.15] md:[--term-font-size:14px] md:[--term-line-height:1.2] [&.wterm]:p-2 md:[&.wterm]:p-3",cols:120,rows:32,autoResize:!0,cursorBlink:!0,onReady:ew,onData:e=>{!t||ep.sendInput(e)&&(O.current=Date.now())},onResize:(e,t)=>
2{ex(e,t)},onError:()=>{ep.reportRenderFailure(g("renderError"))}}),(0,r.jsx)(M,{disabled:!ed.ready,onSend:e=>{ep.sendInput(e)&&es()}}),"ready"!==eu&&(0,r.jsx)(_,{state:eu,error:eh,onRetry:ev})]}):(0,r.jsx)(F,{assistantLabel:et,onConnect:ey,onConnectAssistant:eN})]})}function L({projectId:e,visible:t,online:s,launchAssistantRequestId:a}){let o=(0,x.c)("developTab.terminal"),{selectedAssistant:c,secrets:d}=(0,E.QP)(),u=(0,n.useMemo)(()=>"credits"===(d.BILLING_MODE||"byot")?"opencode":c,[d.BILLING_MODE,c]),p=(0,R.K0)(u)?.label??u??"AI",w=(0,n.useMemo)(()=>`dynamicode-terminal-sessions:${e}`,[e]),j=(0,n.useMemo)(()=>(function(e){try{let t=window.localStorage.getItem(e),s=t?JSON.parse(t):null,r=s?.sessions?.filter(O).map(e=>({id:e.id,label:e.label,kind:e.kind}))??[];if(r.length>0){let e=r.some(e=>e.id===s?.activeSessionId)?s?.activeSessionId:r[0].id;return{sessions:r,activeSessionId:e??r[0].id}}}catch{window.localStorage.removeItem(e)}let t=P("shell",1);return{sessions:[t],activeSessionId:t.id}})(w),[w]),[b,v]=(0,n.useState)(()=>{if(!a)return j;let e=P("assistant",j.sessions.length+1,a);return{sessions:[...j.sessions,e],activeSessionId:e.id,lastHandledLaunchRequestId:a}}),{sessions:y,activeSessionId:N}=b;if(a&&a!==b.lastHandledLaunchRequestId){let e=P("assistant",b.sessions.length+1,a);v({sessions:[...b.sessions,e],activeSessionId:e.id,lastHandledLaunchRequestId:a})}(0,n.useEffect)(()=>{var e,t,s;let r;e=w,t=y,s=N,r={sessions:t.map(({id:e,label:t,kind:s})=>({id:e,label:t,kind:s})),activeSessionId:s},window.localStorage.setItem(e,JSON.stringify(r))},[N,y,w]);let k=(0,n.useCallback)((e,t=!1)=>{v(s=>{let r=P(e,s.sessions.length+1,t?Date.now():void 0);return{...s,sessions:[...s.sessions,r],activeSessionId:r.id}})},[]),S=(0,n.useCallback)(e=>{v(t=>{if(t.sessions.length<=1)return t;let s=t.sessions.filter(t=>t.id!==e);return{...t,sessions:s,activeSessionId:t.activeSessionId===e?s[s.length-1]?.id:t.activeSessionId}})},[]);return(0,r.jsxs)("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden bg-background",children:[(0,r.jsxs)("div",{className:"flex h-11 items-center gap-2 border-b border-border px-3",children:[(0,r.jsx)("div",{className:"flex min-w-0 flex-1 gap-1 overflow-x-auto",children:y.map(e=>{let t=e.id===N;return(0,r.jsxs)("div",{className:(0,T.cn)("group flex h-8 min-w-0 max-w-36 shrink-0 items-center gap-1.5 rounded-sm border px-2 text-xs transition-colors",t?"border-primary bg-primary/10 text-primary":"border-transparent text-muted-foreground hover:border-border hover:bg-muted hover:text-foreground"),children:[(0,r.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-1.5",onClick:()=>v(t=>({...t,activeSessionId:e.id})),children:["assistant"===e.kind?(0,r.jsx)(l.A,{className:"h-3.5 w-3.5 shrink-0"}):(0,r.jsx)(i.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e.label})]}),y.length>1&&(0,r.jsx)("button",{type:"button",className:"ml-0.5 rounded-sm p-0.5 opacity-60 hover:bg-background hover:opacity-100",onClick:()=>S(e.id),"aria-label":`Close ${e.label}`,children:(0,r.jsx)(m.A,{className:"h-3 w-3"})})]},e.id)})}),(0,r.jsxs)(g.rI,{children:[(0,r.jsx)(g.ty,{asChild:!0,children:(0,r.jsx)(f.$,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 shrink-0","aria-label":"New terminal session",children:(0,r.jsx)(h.A,{className:"h-4 w-4"})})}),(0,r.jsxs)(g.SQ,{align:"end",children:[(0,r.jsxs)(g._2,{onClick:()=>k("shell"),children:[(0,r.jsx)(i.A,{className:"mr-2 h-4 w-4"}),o("connect")]}),(0,r.jsxs)(g._2,{onClick:()=>k("assistant",!0),children:[(0,r.jsx)(l.A,{className:"mr-2 h-4 w-4"}),o("connectAssistant",{assistant:p})]})]})]})]}),(0,r.jsx)("div",{className:"relative min-h-0 w-full flex-1 overflow-hidden",children:y.map(n=>{let a=n.id===N;return(0,r.jsx)("div",{className:(0,T.cn)("absolute inset-0 h-full min-h-0 w-full overflow-hidden",a?"z-10 opacity-100":"pointer-events-none z-0 opacity-0"),children:(0,r.jsx)(I,{projectId:e,visible:t&&a,online:s,sessionKey:n.id,launchRequestId:a?n.launchRequestId:void 0,variant:"panel"})},n.id)})})]})}function _({state:e,error:t,onRetry:s}){let n=(0,x.c)("developTab.terminal"),a="connecting"===e||"reconnecting"===e,i="replaced"===e,l=i?n("openedElsewhere"):a?n("connecting"===e?"connecting":"reconnecting"):t||n("connectionError");return(0,r.jsx)("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center bg-black/20 px-4 backdrop-blur-[1px]",children:(0,r.jsxs)("div",{className:"pointer-events-auto flex max-w-sm items-center gap-3 rounded-md border border-white/10 bg-[#111116]/95 px-3 py-2 text-xs text-zinc-200 shadow-lg",children:[a?(0,r.jsx)(o.A,{className:"h-4 w-4 shrink-0 animate-spin text-zinc-400"}):(0,r.jsx)(p.A,{className:"h-4 w-4 shrink-0 text-zinc-400"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"truncate font-medium",children:l}),i&&(0,r.jsx)("p",{className:"mt-0.5 text-zinc-400",children:n("openedElsewhereDescription")})]}),"connecting"!==e&&(0,r.jsx)(f.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 shrink-0 px-2 text-xs",onClick:s,children:n(i?"takeOver":"retryNow")})]})})}function M({onSend:e,disabled:t}
2){let s=function(){let[e,t]=(0,n.useState)(56);return(0,n.useEffect)(()=>{let e=()=>{let e=window.visualViewport;e?t(Math.max(56,Math.max(0,window.innerHeight-e.height-e.offsetTop))):t(56)};return e(),window.visualViewport?.addEventListener("resize",e),window.visualViewport?.addEventListener("scroll",e),window.addEventListener("resize",e),()=>{window.visualViewport?.removeEventListener("resize",e),window.visualViewport?.removeEventListener("scroll",e),window.removeEventListener("resize",e)}},[]),e}();return(0,r.jsx)("div",{className:"fixed inset-x-0 z-[60] flex gap-1 overflow-x-auto border-t border-border bg-background/95 px-2 py-1 shadow-[0_-4px_16px_rgba(0,0,0,0.18)] backdrop-blur md:hidden",style:{bottom:`calc(${s}px + env(safe-area-inset-bottom))`},children:[{label:"Esc",data:"\x1b"},{label:"Tab",data:"	"},{label:"Shift Tab",data:"\x1b[Z"},{label:"↑",data:"\x1b[A"},{label:"↓",data:"\x1b[B"},{label:"←",data:"\x1b[D"},{label:"→",data:"\x1b[C"},{label:"Ctrl-C",data:"\x03"},{label:"Ctrl-D",data:"\x04"},{label:"Ctrl-L",data:"\f"}].map(s=>(0,r.jsx)(f.$,{type:"button",variant:"outline",size:"sm",className:"h-8 shrink-0 rounded-sm border-border/70 bg-muted/60 px-2.5 font-mono text-[11px] shadow-none active:bg-primary/15",disabled:t,onPointerDown:t=>{t.preventDefault(),e(s.data)},children:s.label},s.label))})}function F({assistantLabel:e,onConnect:t,onConnectAssistant:s}){let n=(0,x.c)("developTab.terminal");return(0,r.jsx)("div",{className:"flex flex-1 items-center justify-center p-6",children:(0,r.jsxs)("div",{className:"flex w-full max-w-sm flex-col items-center gap-4 text-center",children:[(0,r.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-md border bg-muted",children:(0,r.jsx)(i.A,{className:"h-5 w-5 text-muted-foreground"})}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:n("readyToConnect")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:n("chooseConnection")})]}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:flex-row",children:[(0,r.jsxs)(f.$,{type:"button",variant:"outline",className:"flex-1 gap-2",onClick:t,children:[(0,r.jsx)(i.A,{className:"h-4 w-4"}),n("connect")]}),(0,r.jsxs)(f.$,{type:"button",className:"flex-1 gap-2",onClick:s,children:[(0,r.jsx)(l.A,{className:"h-4 w-4"}),n("connectAssistant",{assistant:e})]})]})]})})}function P(e,t,s){let r="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;return{id:`term-${r}`,kind:e,label:"assistant"===e?`Assistant ${t}`:`Terminal ${t}`,launchRequestId:s}}function O(e){return!!e&&"object"==typeof e&&"string"==typeof e.id&&"string"==typeof e.label&&("shell"===e.kind||"assistant"===e.kind)}},94157:(e,t,s)=>{s.d(t,{S:()=>x});var r=s(95155),n=s(12115),a=s(80642),i=s(94248),l=s(1164),o=s(33210),c=s(86901),d=s(6296),u=s(20232),m=s(89239),h=s(95856),p=s(43904);function x({frontend:e,envVarValues:t,onEnvVarChange:s,onApplyAndRestart:x,isOpen:f,onClose:g,isApplying:w=!1}){let[j,b]=(0,n.useState)(!1);if(!e)return null;let v=e.envVars||[],y=v.filter(e=>e.required&&"rsa_key_pair"!==e.previewAutoGenerate&&"random_base64_32"!==e.autoGenerate),N=y.length,k=y.filter(e=>t[e.key]?.trim()).length,S=(0,p.Nc)(v,t,!0),C=Object.values(t).some(e=>e?.trim());return(0,r.jsx)(a.N,{children:f&&(0,r.jsxs)(i.P.div,{initial:{x:"100%",opacity:0}
2,animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"absolute right-0 top-0 bottom-0 z-20 w-[360px] flex flex-col border-l bg-background shadow-lg",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-primary/10",children:(0,r.jsx)(l.A,{className:"h-4 w-4 text-primary"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"App Settings"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground truncate max-w-[220px]",children:e.name})]})]}),(0,r.jsx)(m.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:g,title:"Close settings","aria-label":"Close settings",children:(0,r.jsx)(o.A,{className:"h-4 w-4"})})]}),(0,r.jsx)(h.F,{className:"flex-1",children:(0,r.jsxs)("div",{className:"p-4 space-y-4",children:[v.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"rounded-lg bg-primary/5 border border-primary/10 p-3",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(c.A,{className:"h-4 w-4 text-primary mt-0.5 flex-shrink-0"}),(0,r.jsxs)("div",{className:"text-sm",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Make your app work better"}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs mt-0.5",children:"These settings help your app connect to services like email, databases, and more."})]})]})}),(0,r.jsx)("div",{className:"rounded-lg border bg-card p-4",children:(0,r.jsx)(p.SO,{allowPreviewGeneration:!0,onGenerationStateChange:b,envVars:v,values:t,onChange:s,disabled:w,showHeader:!1},e.id)})]}):(0,r.jsxs)("div",{className:"text-center py-8",children:[(0,r.jsx)(l.A,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No settings to configure for this app."})]}),e.setupInstructions&&e.setupInstructions.length>0&&(0,r.jsx)(p.dv,{instructions:e.setupInstructions})]})}),(0,r.jsxs)("div",{className:"border-t px-4 py-3 space-y-3",children:[N>0&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Required settings"}),(0,r.jsxs)("span",{className:k===N?"text-green-600 dark:text-green-400 font-medium":"text-amber-600 dark:text-amber-400",children:[k," / ",N," complete"]})]}),(0,r.jsx)("div",{className:"h-1.5 w-full bg-muted rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:`h-full transition-all duration-300 ${k===N?"bg-green-500":"bg-amber-500"}`,style:{width:`${N>0?k/N*100:0}%`}})})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.$,{variant:"outline",onClick:g,disabled:w,className:"flex-1",children:C?"Close":"Skip for now"}),(0,r.jsx)(m.$,{onClick:x,disabled:w||j||!S,className:"flex-1 gap-2",children:w?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.A,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.A,{className:"h-4 w-4"}),"Apply"]})})]}),!S&&N>0&&(0,r.jsxs)("p",{className:"text-xs text-center text-muted-foreground",children:["Fill in the required settings marked with ",(0,r.jsx)("span",{className:"text-destructive",children:"*"})," to save"]})]})]})})}},94627:(e,t,s)=>{s.d(t,{Q:()=>o});var r=s(12115),n=s(6695);class a extends Error{constructor(){super("Screen capture permission denied"),this.name="ScreenCapturePermissionError"}}class i extends Error{constructor(e){super(e),this.name="UnsupportedCaptureMode"}}async function l(e,t="png",s=.92){let r,n=function(){if("undefined"==typeof navigator)return!1;let e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")&&!e.includes("Chromium")}();try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,preferCurrentTab:!0})}catch(e){if(e instanceof Error&&("NotAllowedError"===e.name||"AbortError"===e.name))throw new a;throw e}try{let a,l,o=r.getVideoTracks()[0].getSettings(),c=o.displaySurface;console.log("Capture settings:",{displaySurface:c,settings:o}),await new Promise(e=>
2setTimeout(e,300));let d=e.getBoundingClientRect(),u=document.createElement("video");u.srcObject=r,u.muted=!0,u.playsInline=!0,await new Promise((e,t)=>{u.onloadedmetadata=()=>{u.play().then(()=>e()).catch(t)},u.onerror=t,setTimeout(()=>t(Error("Video load timeout")),5e3)}),await new Promise(e=>setTimeout(e,100));let m=document.createElement("canvas"),h=m.getContext("2d");if(!h)throw Error("Could not get canvas context");let p=u.videoWidth,x=u.videoHeight,f=window.innerWidth,g=window.innerHeight,w=window.devicePixelRatio||1,j=0;if("browser"!==c&&(c||n))if("window"===c){let e=window.outerWidth,t=window.outerHeight;a=p/e,l=x/t;let s=t-g;j=s*l,console.log("Window capture offsets:",{outerWidth:e,outerHeight:t,viewportWidth:f,viewportHeight:g,chromeHeight:s,offsetY:j,scaleX:a,scaleY:l})}else if("monitor"===c)throw r.getTracks().forEach(e=>e.stop()),new i("Please select 'Share Window' instead of 'Share Screen' for accurate screenshots");else{let e=p/x,t=f/g,s=window.outerWidth/window.outerHeight,n=window.screen.width/window.screen.height,o=Math.abs(e-t),d=Math.abs(e-s),u=Math.abs(e-n);if(console.log("Fallback detection:",{displaySurface:c,videoAspect:e,viewportAspect:t,outerAspect:s,screenAspect:n,viewportDiff:o,outerDiff:d,screenDiff:u}),o<.01)a=p/f,l=x/g;else if(d<o&&d<u)a=p/window.outerWidth,l=x/window.outerHeight,j=(window.outerHeight-g)*l;else throw r.getTracks().forEach(e=>e.stop()),new i("Please select 'Share Window' instead of 'Share Screen' for accurate screenshots")}else a=p/f,l=x/g;console.log("Screenshot calculation:",{displaySurface:c,videoWidth:p,videoHeight:x,viewportWidth:f,viewportHeight:g,dpr:w,scaleX:a,scaleY:l,offsetX:0,offsetY:j,elementRect:d});let b=Math.round(d.left*a+0),v=Math.round(d.top*l+j),y=Math.round(d.width*a),N=Math.round(d.height*l),k=Math.max(0,Math.min(b,p-1)),S=Math.max(0,Math.min(v,x-1)),C=Math.min(y,p-k),$=Math.min(N,x-S);console.log("Final crop:",{cropX:k,cropY:S,cropWidth:C,cropHeight:$}),m.width=C,m.height=$,h.drawImage(u,k,S,C,$,0,0,C,$);let A="jpeg"===t?"image/jpeg":"webp"===t?"image/webp":"image/png";return await new Promise((e,t)=>{m.toBlob(s=>s?e(s):t(Error("Failed to create blob")),A,s)})}finally{r.getTracks().forEach(e=>e.stop())}}function o({projectId:e,previewUrl:t,defaultMethod:s="browser"}){let[a,i]=(0,r.useState)(!1),[o,c]=(0,r.useState)(null),[d,u]=(0,r.useState)(s),{toast:m}=(0,n.dj)(),h=(0,r.useCallback)(async e=>{let{targetElement:t,format:s="png",quality:r=.92}=e;if(!t)throw Error("Target element required for browser capture");let n=await l(t,s,r),a=URL.createObjectURL(n),i=`screenshot-${Date.now()}.${s}`,o=document.createElement("a");return o.href=a,o.download=i,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),m({title:"Screenshot downloaded",description:i}),!0},[m]),p=(0,r.useCallback)(async s=>{let r,n=await fetch(`/api/v1/projects/${e}/preview-screenshot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:s.url??t,width:s.width||1280,height:s.height||800,devicePixelRatio:s.devicePixelRatio||1,format:s.format||"png",quality:s.quality,fullPage:s.fullPage??!0})});if(!n.ok)throw Error((await n.json().catch(()=>({}))).error||"Failed to capture screenshot");let a=n.headers.get("content-type"),i=s.format||"png",l=`screenshot-${Date.now()}.${i}`;if(a?.startsWith("image/"))r=await n.blob();else{let e=await n.json();if(!e.success||!e.data)throw Error(e.error||"Failed to capture screenshot");let t=atob(e.data),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);r=new Blob([s],{type:e.contentType||`image/${i}`})}let o=URL.createObjectURL(r),c=document.createElement("a");return c.href=o,c.download=l,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(o),m({title:"Screenshot downloaded",description:l}),!0},[e,t,m]);return{capture:(0,r.useCallback)(async e=>{i(!0),c(null);try{if("browser"!==d)return await p(e);try{return await h(e)}catch(t){if(e.fallbackToServer)return console.warn("Browser capture failed, falling back to server:",t),m({title:"Using server capture",description:"Browser capture unavailable, using full-page capture"}),await p(e);throw t}}catch(t){let e=t instanceof Error?t.message:"Capture failed";return c(e),t instanceof Error&&"ScreenCapturePermissionError"===t.name?m({title:"Capture cancelled",description:"You cancelled the screen capture"}):t instanceof Error&&"UnsupportedCaptureMode"===t.name?m({title:"Wrong capture mode",description:e,variant:"destructive"}):m({title:"Screenshot failed",description:e,variant:"destructive"}),!1}finally{i(!1)}},[d,h,p,m]),isCapturing:a,error:o,method:d,setMethod:u,clearError:(0,r.useCallback)(()=>c(null),[])}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.