@usepatch/widget 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),react$1=require('motion/react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function Gt(t){if(t.length<=1||!t.endsWith("/"))return t;try{let e=new URL(t);if(e.pathname==="/"&&t.endsWith("/"))return `${e.origin}${e.search}${e.hash}`}catch{}return t.slice(0,-1)}function ct(t){try{let e=new URL(t);return Gt(`${e.origin}${e.pathname}`)}catch{return Gt(t)}}var hr="patch:locationchange",Zr="__patchHistoryPatched";function ga(t){let e=t.history;if(e[Zr])return;e[Zr]=true;let r=()=>t.dispatchEvent(new Event(hr)),{pushState:n,replaceState:o}=e;try{e.pushState=function(...s){let i=n.apply(this,s);return r(),i},e.replaceState=function(...s){let i=o.apply(this,s);return r(),i};}catch{}}function Jr(t,e){ga(t);let r=()=>e();return t.addEventListener("popstate",r),t.addEventListener("hashchange",r),t.addEventListener(hr,r),()=>{t.removeEventListener("popstate",r),t.removeEventListener("hashchange",r),t.removeEventListener(hr,r);}}var Tt={desktop:{viewport:"desktop",label:"Desktop",width:null,height:null,glyph:"desktop"},tablet:{viewport:"tablet",label:"Tablet",width:834,height:1194,glyph:"tablet"},mobile:{viewport:"mobile",label:"Mobile",width:390,height:844,glyph:"mobile"}},Qr=["desktop","tablet","mobile"];function Qt(t){let e=Tt[t];return e.width===null||e.height===null?e.label:`${e.label} (${e.width}px \xD7 ${e.height}px)`}function tn(t,e){let r=Tt[t];return {width:r.width??e.width,height:r.height??e.height}}var ha=32,ba=32,va=3e3,nn="cubic-bezier(0.16, 1, 0.3, 1)",Ve=[.22,.61,.36,1],on=.3,an=.5,xa=.34,wa=.5,ya=.24,ka=.22,sn=.12,Ca=.42,ln=.2,Aa=200,Sa=260,Ta=70,Ea=180,Ra=260,Pa=8,Ia=4,Na="#d9d9dd",Ma=30,_a=["0 2px 8px rgba(0,0,0,0.20)","0 30px 60px -18px rgba(0,0,0,0.55)","0 70px 130px -52px rgba(0,0,0,0.55)"].join(", ");function We(t,e,r){let n=Math.max(320,t.innerWidth-ha*2),o=Math.max(320,t.innerHeight-ba*2);return Math.min(1,n/e,o/r)}function La(t){try{return !!(t.contentWindow&&t.contentDocument?.body)}catch{return false}}function cn({src:t,viewport:e,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:s}){let i=react$1.useReducedMotion(),a=e.width??r.innerWidth,l=e.height??r.innerHeight,c=e.viewport,d=`${c}:${a}:${l}`,u=!!r.happyDOM?.settings?.disableIframePageLoading,[p,m]=react.useState(()=>({viewport:c,width:a,height:l,scale:We(r,a,l)})),[v,f]=react.useState("stable"),[b,h]=react.useState(false),[y,T]=react.useState(false),x=react.useRef(false),z=react.useRef(null),g=`${p.viewport}:${p.width}:${p.height}`!==d,U=b&&!y&&!(g||v==="cover"||v==="resize"),at=b&&!y&&v==="stable"&&!g,pt=react.useCallback(E=>{z.current=E,n(E);},[n]),vt=react.useCallback(()=>{let E=z.current;if(!E||!La(E)){x.current=false,h(false),T(true);return}x.current=true,h(true),T(false);},[]),st=react.useCallback(()=>{m(E=>{let tt=We(r,E.width,E.height);return E.scale===tt?E:{...E,scale:tt}});},[r]);react.useEffect(()=>(st(),r.addEventListener("resize",st),()=>r.removeEventListener("resize",st)),[r,st]),react.useEffect(()=>{x.current=false,h(false),T(false);let E=r.setTimeout(()=>{x.current||T(true);},va);return ()=>r.clearTimeout(E)},[t,r]),react.useEffect(()=>{if(i){g&&m({viewport:c,width:a,height:l,scale:We(r,a,l)}),v!=="stable"&&f("stable");return}switch(v){case "stable":{g&&f("cover");return}case "cover":{let E=r.setTimeout(()=>f("resize"),Ta);return ()=>r.clearTimeout(E)}case "resize":{g&&m({viewport:c,width:a,height:l,scale:We(r,a,l)});let E=r.setTimeout(()=>f("reveal"),Ea);return ()=>r.clearTimeout(E)}case "reveal":{let E=r.setTimeout(()=>f("stable"),Ra);return ()=>r.clearTimeout(E)}}},[v,g,i,r,c,a,l]),react.useEffect(()=>{o(at);},[at,o]),react.useEffect(()=>{s(y);},[y,s]);let Q=i?{duration:0}:{duration:ya,ease:Ve},X=i?{duration:0}:{duration:ka,ease:Ve,delay:ln*.5},k=i?{duration:0}:{duration:ln,ease:Ve},R=i?{duration:0}:{opacity:{duration:Ca,ease:Ve,delay:sn},scale:{type:"spring",bounce:xa,duration:wa,delay:sn},width:{type:"spring",bounce:on,duration:an},height:{type:"spring",bounce:on,duration:an}},M=(U?Sa:Aa)/1e3,A=i?void 0:`opacity ${M}s ${nn}, filter ${M}s ${nn}`,H=p.width*p.scale,F=p.height*p.scale;return jsxRuntime.jsx(react$1.motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:Q},exit:{opacity:0,transition:X},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxRuntime.jsxs(react$1.motion.div,{initial:i?{opacity:0,width:H,height:F}:{opacity:0,scale:.8,width:H,height:F},animate:{opacity:1,scale:1,width:H,height:F},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:k},transition:R,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${Ia}px solid ${Na}`,borderRadius:Ma,boxShadow:_a,willChange:"width, height"},children:[jsxRuntime.jsx("div",{"aria-hidden":!U,className:"absolute top-0 left-0 origin-top-left",style:{width:p.width,height:p.height,transform:`scale(${p.scale})`,opacity:U?1:0,filter:i||U?"none":`blur(${Pa}px)`,transition:A,pointerEvents:U?"auto":"none",willChange:"opacity, filter"},children:jsxRuntime.jsx("iframe",{ref:pt,"data-patch-preview-frame":"","data-patch-preview-src":t,title:`${e.label} preview`,tabIndex:U?0:-1,src:u?void 0:t,srcDoc:u?"<!doctype html><html><body></body></html>":void 0,onLoad:vt,className:"block bg-white",style:{width:p.width,height:p.height,border:0}})}),jsxRuntime.jsx(Da,{visible:y})]})})}function Da({visible:t}){return t?jsxRuntime.jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsxRuntime.jsx("div",{className:"max-w-[320px] rounded-xl bg-white px-5 py-4 text-center text-[13px] leading-[1.45] text-foreground shadow-[0_18px_44px_-18px_rgba(0,0,0,0.28)]",children:"This site blocks embedding. Add X-Frame-Options: SAMEORIGIN or frame-ancestors 'self' to enable viewport previews."})}):null}var mn=react.createContext(null),gn=react.createContext(null),fn="__patch_preview";function hn(){return typeof window>"u"||typeof document>"u"?null:{targetWindow:window,targetDocument:document,overlayWindow:window,overlayDocument:document,getTargetViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getOverlayViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getTargetScrollY:()=>window.scrollY,getPageUrl:()=>Gt(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:t=>({...t}),targetRectToOverlay:t=>({...t}),eventTargetElement:t=>t instanceof window.Element?t:null}}function Fa(t){let e=new URL(t.location.href);return e.searchParams.set(fn,"1"),e.toString()}function bn(t=window){try{return new URL(t.location.href).searchParams.get(fn)==="1"}catch{return false}}function $a(t,e,r){let n=e.contentWindow,o=e.contentDocument;if(!n||!o)return null;function s(){return e.getBoundingClientRect()}function i(){let l=s();return r.width>0?l.width/r.width:1}function a(l){if(!l)return null;let c=n.Element;return l instanceof c?l:null}return {targetWindow:n,targetDocument:o,overlayWindow:t.overlayWindow,overlayDocument:t.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:t.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>Gt(`${n.location.origin}${n.location.pathname}`),targetPointToOverlay:l=>{let c=s(),d=i();return {viewportX:c.left+l.viewportX*d,viewportY:c.top+l.viewportY*d}},targetRectToOverlay:l=>{let c=s(),d=i();return {x:c.left+l.x*d,y:c.top+l.y*d,width:l.width*d,height:l.height*d}},eventTargetElement:a}}function vn(t,e){let r=t.ResizeObserver??ResizeObserver;return new r(e)}function xn({children:t}){let e=react.useMemo(()=>hn(),[]),[r,n]=react.useState("desktop"),[o,s]=react.useState(null),[i,a]=react.useState(false),[l,c]=react.useState(false),[d,u]=react.useState(false),p=r!=="desktop",m=p||d,v=Tt[r],f=v.width&&v.height?{width:v.width,height:v.height}:null;react.useEffect(()=>{a(false),c(false);},[r]);let b=react.useRef(p);react.useEffect(()=>{b.current&&!p?u(true):!b.current&&p&&u(false),b.current=p;},[p]);let h=react.useMemo(()=>e?!p||!i||l||!o||!f?e:$a(e,o,f)??e:null,[l,o,i,p,f,e]),y=react.useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?p&&i&&!l:true,previewBlocked:p&&l}),[r,l,i,p,m]),T=react.useMemo(()=>e?Fa(e.targetWindow):"",[e]);return !h||!e?null:jsxRuntime.jsx(gn.Provider,{value:y,children:jsxRuntime.jsxs(mn.Provider,{value:h,children:[t,jsxRuntime.jsx(react$1.AnimatePresence,{onExitComplete:()=>u(false),children:p&&f?jsxRuntime.jsx(cn,{src:T,viewport:v,overlayWindow:e.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function mt(){let t=react.use(mn),e=react.useMemo(()=>hn(),[]);if(t)return t;if(e)return e;throw new Error("useTargetSurface must run in a browser document")}function ne(){let t=react.use(gn),[e,r]=react.useState("desktop"),n=react.useMemo(()=>({activeViewport:e,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[e]);return t??n}var Va="X-Patch-Client-Id";function yt(t,e){return {...e?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${t.token}`,...t.clientUserId?{[Va]:t.clientUserId}:{}}}async function At(t,e){try{let r=await fetch(t,e);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function Wa(t,e){try{let r=await fetch(t,e),n=await r.text(),o=n?JSON.parse(n):null;return r.ok?o??{ok:!0}:{ok:!1,error:o&&typeof o=="object"&&typeof o.error=="string"?o.error:"Request failed."}}catch{return null}}function wn(t){return {async listAnnotations(e){let r=e?`?viewport=${encodeURIComponent(e)}`:"";return (await At(`${t.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:yt(t,false)}))?.annotations??[]},async listRoster(){return (await At(`${t.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:yt(t,false)}))?.entries??[]},async fetchMe(){return At(`${t.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:yt(t,false)})},async postIdentity(e){let r=await At(`${t.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify(e)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(e){return At(`${t.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify(e)})},async reply(e,r){return At(`${t.apiBase}/api/widget/annotations/${e}/reply`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify(r)})},async uploadAttachment(e,r){let n=new URLSearchParams({kind:r.kind,width:String(r.width),height:String(r.height)});return (await At(`${t.apiBase}/api/widget/uploads?${n}`,{method:"POST",credentials:"include",headers:{...yt(t,false),"Content-Type":e.type},body:e}))?.attachment??null},async deleteAnnotation(e){return At(`${t.apiBase}/api/widget/annotations/${e}`,{method:"DELETE",credentials:"include",headers:yt(t,false)})},async deleteMessage(e,r){return At(`${t.apiBase}/api/widget/annotations/${e}/messages/${r}`,{method:"DELETE",credentials:"include",headers:yt(t,false)})},async kickoff(e,r){return Wa(`${t.apiBase}/api/widget/annotations/${e}/kickoff`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify(r)})},async resolve(e){return At(`${t.apiBase}/api/widget/annotations/${e}/resolve`,{method:"POST",credentials:"include",headers:yt(t,true)})},async reopen(e){return At(`${t.apiBase}/api/widget/annotations/${e}/reopen`,{method:"POST",credentials:"include",headers:yt(t,true)})},async reportAnchorStatuses(e){e.length!==0&&await At(`${t.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify({reports:e})});}}}var wr="patch.clientIdentity",yn="patch.clientAvatarSeed";function yr(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(wr);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function kn(t){return yr()[t]??null}function kr(t,e){if(!(typeof window>"u"))try{let r=yr();r[t]=e,window.localStorage.setItem(wr,JSON.stringify(r));}catch{}}function Cn(t){if(!(typeof window>"u"))try{let e=yr();delete e[t],window.localStorage.setItem(wr,JSON.stringify(e));}catch{}}function Ua(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(yn);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function xr(){let t=globalThis.crypto;return `client-avatar:${typeof t?.randomUUID=="function"?t.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function An(t){if(typeof window>"u")return xr();try{let e=Ua(),r=e[t];if(r)return r;let n=xr();return e[t]=n,window.localStorage.setItem(yn,JSON.stringify(e)),n}catch{return xr()}}var Xa=2e4,Tn=react.createContext(null);function Ka(t,e){let r=new Map(t.map(i=>[i.id,i])),n=new Set(e.map(i=>i.id)),o=e.map(i=>{let a=r.get(i.id);if(!a)return i;let l=new Set(i.thread.map(u=>u.id)),c=a.thread.filter(u=>u.deliveryStatus&&!l.has(u.id)),d=c.length>0?{...i,thread:[...i.thread,...c]}:i;if(a.optimisticAction==="resolve-pending"&&i.status!=="resolved"&&(d={...d,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="reopen-pending"&&i.status==="resolved"&&(d={...d,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="run-pending"&&a.latestRun?.id.startsWith("tmp-run")){let u=i.latestRun?Date.parse(i.latestRun.createdAt):Number.NaN,p=Date.parse(a.latestRun.createdAt);i.latestRun!=null&&(Number.isNaN(p)||Number.isNaN(u)||u>=p)||(d={...d,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return d}),s=t.filter(i=>(i.deliveryStatus||i.optimisticAction)&&!n.has(i.id));return [...o,...s]}function En({projectToken:t,apiBase:e,children:r}){let n=mt(),{activeViewport:o,setActiveViewport:s}=ne(),[i,a]=react.useState(()=>typeof window>"u"?null:kn(t)),[l]=react.useState(()=>typeof window>"u"?"client-avatar:ssr":An(t)),[c,d]=react.useState(null),[u,p]=react.useState("client"),[m,v]=react.useState(null),[f,b]=react.useState([]),[h,y]=react.useState(null),[T,x]=react.useState([]),[z,O]=react.useState(false),[g,N]=react.useState(null),U=react.useRef(g);U.current=g;let at=react.useRef(o);at.current=o;let pt=h===o,vt=react.useMemo(()=>wn({apiBase:e,token:t,clientUserId:i?.clientUserId}),[e,t,i?.clientUserId]),st=react.useRef(vt);st.current=vt;let Q=react.useRef(0),X=react.useCallback(async()=>{let P=o,L=++Q.current,W=await st.current.listAnnotations(P==="desktop"?void 0:P);if(L!==Q.current||P!==at.current)return;let j=n.getPageUrl(),Pt=W.filter(wt=>ct(wt.payload.url)===j);b(wt=>Ka(wt,Pt)),y(P);},[o,n]),k=react.useRef(X);k.current=X,react.useEffect(()=>{let P=false;return (async()=>{let L=await st.current.fetchMe();if(!P){if(L?.active===false){N(false),O(true);return}if(N(true),L?.studio)d(L.studio),p("studio"),v(L.agentRunReadiness??{ready:true,message:null});else if(d(null),p("client"),v(null),L?.client){let W={clientUserId:L.client.id,name:L.client.name,email:L.client.email,avatarSeed:L.client.avatarSeed};a(W),kr(t,W);}await k.current(),P||O(true);}})(),()=>{P=true;}},[t]),react.useEffect(()=>{!z||!g||X();},[z,g,X]),react.useEffect(()=>{if(!g)return;let{overlayDocument:P,overlayWindow:L}=n,W=L.setInterval(()=>{P.visibilityState==="visible"&&X();},Xa),j=()=>{P.visibilityState==="visible"&&X();};return P.addEventListener("visibilitychange",j),()=>{L.clearInterval(W),P.removeEventListener("visibilitychange",j);}},[g,X,n]),react.useEffect(()=>{if(g)return Jr(n.targetWindow,()=>{let P=n.getPageUrl();b(L=>L.filter(W=>ct(W.payload.url)===P)),k.current();})},[g,n]);let R=react.useCallback(async P=>(kr(t,P),a(P),P),[t]),M=react.useCallback(()=>{a(null),Cn(t);},[t]),A=react.useCallback(P=>{x(L=>[...L.filter(W=>W.tempId!==P.tempId),P]);},[]),H=react.useCallback(P=>{x(L=>L.filter(W=>W.tempId!==P));},[]),F=react.useCallback(P=>{b(L=>{let W=L.findIndex(Pt=>Pt.id===P.id);if(W===-1)return [...L,P];let j=L.slice();return j[W]=P,j});},[]),E=react.useCallback((P,L)=>{b(W=>{let j=false,Pt=W.flatMap(wt=>{if(wt.id!==P)return [wt];j=true;let Ut=L(wt);return Ut?[Ut]:[]});return j?Pt:W});},[]),tt=react.useCallback((P,L)=>{b(W=>W.map(j=>j.id===P?{...j,id:L,deliveryStatus:"sent"}:j));},[]),xt=react.useMemo(()=>({apiClient:vt,active:g,ready:z,viewerKind:u,agentRunReadiness:m,activeViewport:o,clientAvatarSeed:l,identity:i,studio:c,annotations:f,annotationsReady:pt,ephemerals:T,refresh:X,setActiveViewport:s,setIdentity:R,signOut:M,addEphemeral:A,removeEphemeral:H,applyAnnotationUpdate:F,updateAnnotation:E,replaceAnnotationId:tt}),[vt,g,z,u,m,o,l,i,c,f,pt,T,X,s,R,M,A,H,F,E,tt]);return jsxRuntime.jsx(Tn.Provider,{value:xt,children:r})}function rt(){let t=react.use(Tn);if(!t)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return t}function Rn(t){if(t.length<12)return null;if(t[0]===255&&t[1]===216&&t[2]===255)return "image/jpeg";if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return "image/png";let e=(r,n)=>n.split("").every((o,s)=>t[r+s]===o.charCodeAt(0));return e(0,"RIFF")&&e(8,"WEBP")?"image/webp":null}var ja=new Set(["AmpStateContext","AppRouter","AppRouterContext","ClientPageRoot","ClientSegmentRoot","ErrorBoundary","ForbiddenBoundary","GlobalLayoutRouterContext","HTTPAccessFallbackBoundary","HTTPAccessFallbackErrorBoundary","HeadManagerContext","HotReload","ImageConfigContext","InnerLayoutRouter","InnerScrollAndFocusHandler","InnerScrollAndFocusHandlerOld","LayoutRouterContext","LoadingBoundary","NavigationPromisesContext","NotFoundBoundary","OuterLayoutRouter","PathParamsContext","PathnameContext","ReactDevOverlay","RedirectBoundary","RedirectErrorBoundary","RenderFromTemplateContext","RouterContext","ScrollAndMaybeFocusHandler","SearchParamsContext","SegmentStateProvider","SegmentViewNode","ServerInsertedHTMLContext","Suspense","TemplateContext","UnauthorizedBoundary","AwaitContext","BrowserRouter","DataRouterContext","DataRouterStateContext","DataRoutes","FetchersContext","HashRouter","LocationContext","MemoryRouter","NavigationContext","Outlet","RenderErrorBoundary","RenderedRoute","Route","RouteContext","RouteErrorContext","Router","RouterProvider","Routes","StaticRouter","StaticRouterProvider","ViewTransitionContext"]);function Za(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function Pn(t){return t.replace(/\s+/g," ").trim()}function Cr(t){return ja.has(Pn(t))}function Ja(t){return t.length<2||t.startsWith("_")?false:/^[A-Z]/.test(t)}function In(t){if(!t)return null;let e=[],r=t.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Pn(n[1]??"");!o||Cr(o)||Ja(o)&&e[e.length-1]!==o&&e.push(o);}return e.length===0?null:Za(e.map(n=>`<${n}>`).join(" "),1e3)}var Nn="seed:";function Ye(t){return t?t.startsWith(Nn)?{url:null,seed:t.slice(Nn.length)||null}:/^https?:\/\//i.test(t)?{url:t,seed:null}:{url:null,seed:t}:{url:null,seed:null}}var Ar=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],Mn=[{hue:"near",sat:[88,98],light:[68,82],r:[.44,.62],opacity:[.9,1],reach:[.14,.32]},{hue:"base",sat:[85,96],light:[44,56],r:[.5,.74],opacity:[.85,1],reach:[.2,.42]},{hue:"accent",sat:[84,97],light:[50,66],r:[.42,.64],opacity:[.8,.98],reach:[.26,.48]},{hue:"accent2",sat:[82,95],light:[30,46],r:[.44,.66],opacity:[.72,.94],reach:[.24,.46]}],_n=Math.PI*2;function Qa(t){let e=2166136261;for(let r=0;r<t.length;r++)e^=t.charCodeAt(r),e=Math.imul(e,16777619);return e>>>0}function ts(t){return ()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function K(t,e,r){return e+t()*(r-e)}function gt(t,e=3){let r=10**e;return Math.round(t*r)/r}function Ln(t,e,r){return `hsl(${gt((t%360+360)%360,1)} ${gt(e,1)}% ${gt(r,1)}%)`}function Dn(t){let e=Qa(t?.trim()||"patch-client"),r=ts(e),n=e.toString(36),o=(Ar[e%Ar.length]??Ar[0])+K(r,-10,10),s=r()<.5?-1:1,i=r()<.5?-1:1,a=o+i*K(r,52,116),l=o-i*K(r,26,66),c=o+s*K(r,12,38),d=Ln(o+s*K(r,0,14),K(r,80,92),K(r,44,54)),u=K(r,0,_n),p=Mn.map((m,v)=>{let b=(m.hue==="accent"?a:m.hue==="accent2"?l:m.hue==="near"?c:o)+K(r,-11,11),h=u+v/Mn.length*_n+K(r,-0.6,.6),y=K(r,m.reach[0],m.reach[1]),T=gt(.5+Math.cos(h)*y),x=gt(.5+Math.sin(h)*y),z=gt(K(r,0,180),1),O=gt(K(r,.62,1.5),3),g=gt(K(r,.62,1.5),3);return {id:`cav-${n}-${v}`,cx:T,cy:x,r:gt(K(r,m.r[0],m.r[1])),color:Ln(b,K(r,m.sat[0],m.sat[1]),K(r,m.light[0],m.light[1])),opacity:gt(K(r,m.opacity[0],m.opacity[1]),2),gradientTransform:`rotate(${z} ${T} ${x}) translate(${T} ${x}) scale(${O} ${g}) translate(${gt(-T)} ${gt(-x)})`}});return {id:n,background:d,spots:p,blur:gt(K(r,3.4,5.4),2),grain:gt(K(r,.09,.15),2)}}var On=react.createContext(null);function zn({children:t}){let[e,r]=react.useState(null),[n,o]=react.useState(""),[s,i]=react.useState([]),[a,l]=react.useState(0),[c,d]=react.useState(false),u=react.useRef([]),p=react.useCallback(()=>{for(let g of u.current)URL.revokeObjectURL(g.previewUrl);u.current=[],i([]);},[]),m=react.useCallback(()=>{r(null),o(""),p(),d(false);},[p]),v=react.useCallback(g=>{r({kind:"existing",annotationId:g}),o(""),p(),d(false);},[p]),f=react.useCallback(g=>{r({kind:"composer",...g}),o(""),p(),d(false);},[p]),b=react.useCallback(g=>u.current.length>=4?false:(u.current=[...u.current,g],i(u.current),true),[]),h=react.useCallback((g,N)=>{u.current=u.current.map(U=>U.localId===g?{...U,...N}:U),i(u.current);},[]),y=react.useCallback(g=>{let N=u.current.find(U=>U.localId===g);N&&URL.revokeObjectURL(N.previewUrl),u.current=u.current.filter(U=>U.localId!==g),i(u.current);},[]),T=react.useCallback(()=>{if(n.trim().length>0||u.current.length>0){l(g=>g+1);return}m();},[n,m]),x=react.useCallback(()=>{m();},[m]),z=n.trim().length>0||s.length>0,O=react.useMemo(()=>({active:e,draftText:n,draftAttachments:s,hasDraft:z,shakeNonce:a,confirmDiscardOpen:c,openExisting:v,openComposer:f,setDraftText:o,addDraftAttachment:b,updateDraftAttachment:h,removeDraftAttachment:y,clearDraftAttachments:p,attemptClose:T,forceClose:x,setConfirmDiscardOpen:d}),[e,n,s,z,a,c,v,f,b,h,y,p,T,x]);return jsxRuntime.jsx(On.Provider,{value:O,children:t})}function ft(){let t=react.use(On);if(!t)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return t}var $n=new Set(["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),as=new Set(["a","button","input","select","textarea"]),Bn={a:"link",button:"button",input:"input",select:"select",textarea:"textarea",img:"img",svg:"icon",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"paragraph",li:"list item",td:"cell",th:"header cell",label:"label",blockquote:"quote",figcaption:"caption",code:"code",pre:"code block"},Xt=40,ss=1500,Hn=200,ls=5,cs=10;function Vn(t){return $n.has(t.tagName.toLowerCase())}function zt(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1)}\u2026`}function oe(t){return `"${t}"`}function ds(t){let e="";for(let r of Array.from(t.childNodes))r.nodeType===3&&(e+=r.textContent??"");return e.replace(/\s+/g," ").trim()}function Ge(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function us(t){return !(!t||t.length>40||/__[A-Za-z0-9]{4,}$/.test(t)||/_[a-z0-9]{4,}$/i.test(t)&&/[0-9]/.test(t)||/_[A-Za-z0-9]{5,}_/.test(t)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(t)||/^[a-z]{2,}:[\w-]+$/.test(t)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(t)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(t)||(t.match(/\d/g)?.length??0)/t.length>.4)}function Ae(t){let e=Array.from(t.classList),r=e.filter(us).slice(0,cs);return r.length>0?r:e.length>0?["container"]:[]}function Wn(t){let e=t.getAttribute("role")??void 0,r=t.getAttribute("aria-label")??void 0,n=t.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,s=t.tagName.toLowerCase(),i=as.has(s)||o!==void 0&&Number.isFinite(o)&&o>=0;if(e===void 0&&r===void 0&&o===void 0&&!i)return;let a={focusable:i};return e!==void 0&&(a.role=e),r!==void 0&&(a.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(a.tabIndex=o),a}function ps(t){let e=t.tagName.toLowerCase(),r=Bn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${oe(zt(n,Xt))}`;let o=t.placeholder;if(o)return `${r} ${oe(zt(o,Xt))}`;let s=t.getAttribute("name");if(s)return `${r}[name="${s}"]`;if(e==="input"){let i=t.type||"text";return `${r}[type=${i}]`}return r}function ms(t){let e=t.alt?.trim();return e?`img ${oe(zt(e,Xt))}`:"img"}function Xe(t){let e=t.tagName.toLowerCase();if(e==="img")return ms(t);if(e==="input"||e==="textarea"||e==="select")return ps(t);let r=Bn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${oe(zt(n,Xt))}`;if(e==="a"||e==="button"||$n.has(e)||e==="label"){let s=Ge(t);if(s)return `${r} ${oe(zt(s,Xt))}`;if(e==="a"||e==="button"){let i=t.querySelector("svg");if(i){let l=i.getAttribute("aria-label");return l?`${r} ${oe(zt(l,Xt))}`:`${r} (icon)`}let a=t.getAttribute("href");if(e==="a"&&a)return `link[href="${zt(a,Xt)}"]`}return r}if(t.id)return `${e}#${t.id}`;let o=Ae(t);return o.length>0?`${e}.${o[0]}`:e}function Un(t){let e=[],r=t,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)e.unshift(Xe(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&e.unshift("body"),e.join(" > ").slice(0,ss)}function Yn(t){let e=Ge(t),r=t.parentElement;if(!r)return;let n=Ge(r);if(n){if(e&&n===e){let o=r.parentElement;if(!o)return;let s=Ge(o);return !s||s===e?void 0:zt(s,Hn)}return zt(n,Hn)}}function Gn(t){let e=t.parentElement;if(!e)return [];let r=[];for(let n of Array.from(e.children))if(n!==t&&n.tagName.toLowerCase()!=="script"&&(r.push(Xe(n)),r.length>=ls))break;return r}var gs=["role","aria-label","name"],fs=10,Fn=100;function Ke(t){let e={};for(let r of gs){let n=t.getAttribute(r);n!==null&&n!==""&&(e[r]=n.slice(0,Fn));}for(let r of Array.from(t.attributes)){if(Object.keys(e).length>=fs)break;r.name.startsWith("data-")&&r.value!==""&&(e[r.name]=r.value.slice(0,Fn));}return e}function qe(t){return ds(t)}function Xn(t){let e=t;for(;e&&e.nodeType!==1;)e=e.parentNode;return e}function Kn(t,e){return t.closest(`[${e}]`)!==null}var hs=new Set(["p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),bs={article:"Article",aside:"Sidebar",dialog:"Dialog",fieldset:"Form section",figure:"Image",footer:"Footer",form:"Form",header:"Header",main:"Main content",nav:"Navigation",section:"Section",summary:"Summary"},vs={a:"Link",article:"Article",aside:"Sidebar",blockquote:"Text",button:"Button",code:"Text",div:"Area",figcaption:"Text",figure:"Image",footer:"Footer",form:"Form",header:"Header",img:"Image",input:"Field",label:"Text",li:"Text",main:"Main content",nav:"Navigation",p:"Text",pre:"Text",section:"Section",select:"Field",span:"Text",svg:"Icon",textarea:"Field"},xs={caption:"Text",cell:"Text","code block":"Text",icon:"Icon",input:"Field",label:"Text",link:"Link","list item":"Text",paragraph:"Text",quote:"Text",select:"Field",textarea:"Field"};function jn(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1).trim()}\u2026`}function ws(t){return `"${t}"`}function je(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function qn(t){let e=t.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):""}function dt(t,e){let r=e?.trim();return r?`${t}: ${ws(jn(r,48))}`:t}function ys(t){let e=t.trim(),r=e.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??e,text:r[2]}:{base:e}}function ks(t){let e=t.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=xs[e];if(r)return r;let n=t.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":vs[n]??"Area":"Area"}function Cs(t){let e=t.getAttribute("aria-label");if(e)return dt("Field",e);let r=t.placeholder;if(r)return dt("Field",r);let n=t.getAttribute("name");if(n)return dt("Field",qn(n));if(t.tagName.toLowerCase()==="input"){let o=t.type||"text";if(o!=="text")return dt("Field",qn(o))}return "Field"}function Se(t,e){if(e?.trim())return dt("Selected text",e);let r=t.tagName.toLowerCase(),n=t.getAttribute("aria-label");if(r==="button")return dt("Button",n??je(t));if(r==="a")return dt("Link",n??je(t));if(r==="input"||r==="textarea"||r==="select")return Cs(t);if(r==="img"){let s=t.alt;return dt("Image",s)}if(r==="svg")return dt("Icon",n);if(/^h[1-6]$/.test(r))return dt("Heading",je(t));if(hs.has(r))return dt("Text",je(t));let o=bs[r];return dt(o||"Area",n)}function Zn(t){if(t.targetLabel?.trim())return jn(t.targetLabel,120);if(t.selectedText?.trim())return dt("Selected text",t.selectedText);let e=t.element?.trim()||t.elementPath?.trim();if(!e)return "Annotation";let r=ys(e.split(">").at(-1)??e);return dt(ks(r.base),r.text)}var Jn="patch-capture-cursor-style";function As(t){let e=`:not([${t}]):not([${t}] *)`,r=["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"].map(n=>`body ${n}${e}`).join(`,
2
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),react$1=require('motion/react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function Gt(t){if(t.length<=1||!t.endsWith("/"))return t;try{let e=new URL(t);if(e.pathname==="/"&&t.endsWith("/"))return `${e.origin}${e.search}${e.hash}`}catch{}return t.slice(0,-1)}function ct(t){try{let e=new URL(t);return Gt(`${e.origin}${e.pathname}`)}catch{return Gt(t)}}var br="patch:locationchange",Qr="__patchHistoryPatched";function fa(t){let e=t.history;if(e[Qr])return;e[Qr]=true;let r=()=>t.dispatchEvent(new Event(br)),{pushState:n,replaceState:o}=e;try{e.pushState=function(...s){let i=n.apply(this,s);return r(),i},e.replaceState=function(...s){let i=o.apply(this,s);return r(),i};}catch{}}function tn(t,e){fa(t);let r=()=>e();return t.addEventListener("popstate",r),t.addEventListener("hashchange",r),t.addEventListener(br,r),()=>{t.removeEventListener("popstate",r),t.removeEventListener("hashchange",r),t.removeEventListener(br,r);}}var Tt={desktop:{viewport:"desktop",label:"Desktop",width:null,height:null,glyph:"desktop"},tablet:{viewport:"tablet",label:"Tablet",width:834,height:1194,glyph:"tablet"},mobile:{viewport:"mobile",label:"Mobile",width:390,height:844,glyph:"mobile"}},en=["desktop","tablet","mobile"];function Qt(t){let e=Tt[t];return e.width===null||e.height===null?e.label:`${e.label} (${e.width}px \xD7 ${e.height}px)`}function rn(t,e){let r=Tt[t];return {width:r.width??e.width,height:r.height??e.height}}var ba=32,va=32,xa=3e3,an="cubic-bezier(0.16, 1, 0.3, 1)",Ve=[.22,.61,.36,1],sn=.3,ln=.5,wa=.34,ya=.5,ka=.24,Ca=.22,cn=.12,Aa=.42,dn=.2,Sa=200,Ta=260,Ea=70,Ra=180,Pa=260,Ia=8,Na=4,Ma="#d9d9dd",_a=30,La=["0 2px 8px rgba(0,0,0,0.20)","0 30px 60px -18px rgba(0,0,0,0.55)","0 70px 130px -52px rgba(0,0,0,0.55)"].join(", ");function We(t,e,r){let n=Math.max(320,t.innerWidth-ba*2),o=Math.max(320,t.innerHeight-va*2);return Math.min(1,n/e,o/r)}function Da(t){try{return !!(t.contentWindow&&t.contentDocument?.body)}catch{return false}}function un({src:t,viewport:e,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:s}){let i=react$1.useReducedMotion(),a=e.width??r.innerWidth,l=e.height??r.innerHeight,c=e.viewport,d=`${c}:${a}:${l}`,u=!!r.happyDOM?.settings?.disableIframePageLoading,[p,m]=react.useState(()=>({viewport:c,width:a,height:l,scale:We(r,a,l)})),[v,f]=react.useState("stable"),[b,h]=react.useState(false),[y,T]=react.useState(false),x=react.useRef(false),z=react.useRef(null),g=`${p.viewport}:${p.width}:${p.height}`!==d,U=b&&!y&&!(g||v==="cover"||v==="resize"),at=b&&!y&&v==="stable"&&!g,pt=react.useCallback(E=>{z.current=E,n(E);},[n]),vt=react.useCallback(()=>{let E=z.current;if(!E||!Da(E)){x.current=false,h(false),T(true);return}x.current=true,h(true),T(false);},[]),st=react.useCallback(()=>{m(E=>{let tt=We(r,E.width,E.height);return E.scale===tt?E:{...E,scale:tt}});},[r]);react.useEffect(()=>(st(),r.addEventListener("resize",st),()=>r.removeEventListener("resize",st)),[r,st]),react.useEffect(()=>{x.current=false,h(false),T(false);let E=r.setTimeout(()=>{x.current||T(true);},xa);return ()=>r.clearTimeout(E)},[t,r]),react.useEffect(()=>{if(i){g&&m({viewport:c,width:a,height:l,scale:We(r,a,l)}),v!=="stable"&&f("stable");return}switch(v){case "stable":{g&&f("cover");return}case "cover":{let E=r.setTimeout(()=>f("resize"),Ea);return ()=>r.clearTimeout(E)}case "resize":{g&&m({viewport:c,width:a,height:l,scale:We(r,a,l)});let E=r.setTimeout(()=>f("reveal"),Ra);return ()=>r.clearTimeout(E)}case "reveal":{let E=r.setTimeout(()=>f("stable"),Pa);return ()=>r.clearTimeout(E)}}},[v,g,i,r,c,a,l]),react.useEffect(()=>{o(at);},[at,o]),react.useEffect(()=>{s(y);},[y,s]);let Q=i?{duration:0}:{duration:ka,ease:Ve},K=i?{duration:0}:{duration:Ca,ease:Ve,delay:dn*.5},k=i?{duration:0}:{duration:dn,ease:Ve},R=i?{duration:0}:{opacity:{duration:Aa,ease:Ve,delay:cn},scale:{type:"spring",bounce:wa,duration:ya,delay:cn},width:{type:"spring",bounce:sn,duration:ln},height:{type:"spring",bounce:sn,duration:ln}},M=(U?Ta:Sa)/1e3,A=i?void 0:`opacity ${M}s ${an}, filter ${M}s ${an}`,H=p.width*p.scale,F=p.height*p.scale;return jsxRuntime.jsx(react$1.motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:Q},exit:{opacity:0,transition:K},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxRuntime.jsxs(react$1.motion.div,{initial:i?{opacity:0,width:H,height:F}:{opacity:0,scale:.8,width:H,height:F},animate:{opacity:1,scale:1,width:H,height:F},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:k},transition:R,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${Na}px solid ${Ma}`,borderRadius:_a,boxShadow:La,willChange:"width, height"},children:[jsxRuntime.jsx("div",{"aria-hidden":!U,className:"absolute top-0 left-0 origin-top-left",style:{width:p.width,height:p.height,transform:`scale(${p.scale})`,opacity:U?1:0,filter:i||U?"none":`blur(${Ia}px)`,transition:A,pointerEvents:U?"auto":"none",willChange:"opacity, filter"},children:jsxRuntime.jsx("iframe",{ref:pt,"data-patch-preview-frame":"","data-patch-preview-src":t,title:`${e.label} preview`,tabIndex:U?0:-1,src:u?void 0:t,srcDoc:u?"<!doctype html><html><body></body></html>":void 0,onLoad:vt,className:"block bg-white",style:{width:p.width,height:p.height,border:0}})}),jsxRuntime.jsx(Oa,{visible:y})]})})}function Oa({visible:t}){return t?jsxRuntime.jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsxRuntime.jsx("div",{className:"max-w-[320px] rounded-xl bg-white px-5 py-4 text-center text-[13px] leading-[1.45] text-foreground shadow-[0_18px_44px_-18px_rgba(0,0,0,0.28)]",children:"This site blocks embedding. Add X-Frame-Options: SAMEORIGIN or frame-ancestors 'self' to enable viewport previews."})}):null}var fn=react.createContext(null),hn=react.createContext(null),bn="__patch_preview";function vn(){return typeof window>"u"||typeof document>"u"?null:{targetWindow:window,targetDocument:document,overlayWindow:window,overlayDocument:document,getTargetViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getOverlayViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getTargetScrollY:()=>window.scrollY,getPageUrl:()=>Gt(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:t=>({...t}),targetRectToOverlay:t=>({...t}),eventTargetElement:t=>t instanceof window.Element?t:null}}function $a(t){let e=new URL(t.location.href);return e.searchParams.set(bn,"1"),e.toString()}function xn(t=window){try{return new URL(t.location.href).searchParams.get(bn)==="1"}catch{return false}}function Ba(t,e,r){let n=e.contentWindow,o=e.contentDocument;if(!n||!o)return null;function s(){return e.getBoundingClientRect()}function i(){let l=s();return r.width>0?l.width/r.width:1}function a(l){if(!l)return null;let c=n.Element;return l instanceof c?l:null}return {targetWindow:n,targetDocument:o,overlayWindow:t.overlayWindow,overlayDocument:t.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:t.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>Gt(`${n.location.origin}${n.location.pathname}`),targetPointToOverlay:l=>{let c=s(),d=i();return {viewportX:c.left+l.viewportX*d,viewportY:c.top+l.viewportY*d}},targetRectToOverlay:l=>{let c=s(),d=i();return {x:c.left+l.x*d,y:c.top+l.y*d,width:l.width*d,height:l.height*d}},eventTargetElement:a}}function wn(t,e){let r=t.ResizeObserver??ResizeObserver;return new r(e)}function yn({children:t}){let e=react.useMemo(()=>vn(),[]),[r,n]=react.useState("desktop"),[o,s]=react.useState(null),[i,a]=react.useState(false),[l,c]=react.useState(false),[d,u]=react.useState(false),p=r!=="desktop",m=p||d,v=Tt[r],f=v.width&&v.height?{width:v.width,height:v.height}:null;react.useEffect(()=>{a(false),c(false);},[r]);let b=react.useRef(p);react.useEffect(()=>{b.current&&!p?u(true):!b.current&&p&&u(false),b.current=p;},[p]);let h=react.useMemo(()=>e?!p||!i||l||!o||!f?e:Ba(e,o,f)??e:null,[l,o,i,p,f,e]),y=react.useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?p&&i&&!l:true,previewBlocked:p&&l}),[r,l,i,p,m]),T=react.useMemo(()=>e?$a(e.targetWindow):"",[e]);return !h||!e?null:jsxRuntime.jsx(hn.Provider,{value:y,children:jsxRuntime.jsxs(fn.Provider,{value:h,children:[t,jsxRuntime.jsx(react$1.AnimatePresence,{onExitComplete:()=>u(false),children:p&&f?jsxRuntime.jsx(un,{src:T,viewport:v,overlayWindow:e.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function mt(){let t=react.use(fn),e=react.useMemo(()=>vn(),[]);if(t)return t;if(e)return e;throw new Error("useTargetSurface must run in a browser document")}function ne(){let t=react.use(hn),[e,r]=react.useState("desktop"),n=react.useMemo(()=>({activeViewport:e,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[e]);return t??n}var Wa="X-Patch-Client-Id",Ua="X-Patch-Client-Secret";function kt(t,e){return {...e?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${t.token}`,...t.clientUserId?{[Wa]:t.clientUserId}:{},...t.clientSecret?{[Ua]:t.clientSecret}:{}}}async function Et(t,e){try{let r=await fetch(t,e);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function Ya(t,e){try{let r=await fetch(t,e),n=await r.text(),o=n?JSON.parse(n):null;return r.ok?o??{ok:!0}:{ok:!1,error:o&&typeof o=="object"&&typeof o.error=="string"?o.error:"Request failed."}}catch{return null}}function kn(t){return {async listAnnotations(e){let r=e?`?viewport=${encodeURIComponent(e)}`:"";return (await Et(`${t.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:kt(t,false)}))?.annotations??[]},async listRoster(){return (await Et(`${t.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:kt(t,false)}))?.entries??[]},async fetchMe(){try{let e=await fetch(`${t.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:kt(t,!1)});if(e.status===401||e.status===403)return {status:"unauthorized"};if(!e.ok)return {status:"error"};let r=await e.text();return {status:"ok",me:r?JSON.parse(r):{}}}catch{return {status:"error"}}},async postIdentity(e){let r=await Et(`${t.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:kt(t,true),body:JSON.stringify(e)});if(!r)return null;let n=r.secret??t.clientSecret;return n?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id,secret:n}:null},async createAnnotation(e){return Et(`${t.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:kt(t,true),body:JSON.stringify(e)})},async reply(e,r){return Et(`${t.apiBase}/api/widget/annotations/${e}/reply`,{method:"POST",credentials:"include",headers:kt(t,true),body:JSON.stringify(r)})},async uploadAttachment(e,r){let n=new URLSearchParams({kind:r.kind,width:String(r.width),height:String(r.height)});return (await Et(`${t.apiBase}/api/widget/uploads?${n}`,{method:"POST",credentials:"include",headers:{...kt(t,false),"Content-Type":e.type},body:e}))?.attachment??null},async deleteAnnotation(e){return Et(`${t.apiBase}/api/widget/annotations/${e}`,{method:"DELETE",credentials:"include",headers:kt(t,false)})},async deleteMessage(e,r){return Et(`${t.apiBase}/api/widget/annotations/${e}/messages/${r}`,{method:"DELETE",credentials:"include",headers:kt(t,false)})},async kickoff(e,r){return Ya(`${t.apiBase}/api/widget/annotations/${e}/kickoff`,{method:"POST",credentials:"include",headers:kt(t,true),body:JSON.stringify(r)})},async resolve(e){return Et(`${t.apiBase}/api/widget/annotations/${e}/resolve`,{method:"POST",credentials:"include",headers:kt(t,true)})},async reopen(e){return Et(`${t.apiBase}/api/widget/annotations/${e}/reopen`,{method:"POST",credentials:"include",headers:kt(t,true)})},async reportAnchorStatuses(e){e.length!==0&&await Et(`${t.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:kt(t,true),body:JSON.stringify({reports:e})});}}}var yr="patch.clientIdentity",Cn="patch.clientAvatarSeed";function kr(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(yr);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function Cr(t){let e=kr()[t];return e?.secret?e:null}function Ar(t,e){if(!(typeof window>"u"))try{let r=kr();r[t]=e,window.localStorage.setItem(yr,JSON.stringify(r));}catch{}}function An(t){if(!(typeof window>"u"))try{let e=kr();delete e[t],window.localStorage.setItem(yr,JSON.stringify(e));}catch{}}function Ga(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(Cn);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function wr(){let t=globalThis.crypto;return `client-avatar:${typeof t?.randomUUID=="function"?t.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function Sn(t){if(typeof window>"u")return wr();try{let e=Ga(),r=e[t];if(r)return r;let n=wr();return e[t]=n,window.localStorage.setItem(Cn,JSON.stringify(e)),n}catch{return wr()}}var qa=2e4,En=react.createContext(null);function ja(t,e){let r=new Map(t.map(i=>[i.id,i])),n=new Set(e.map(i=>i.id)),o=e.map(i=>{let a=r.get(i.id);if(!a)return i;let l=new Set(i.thread.map(u=>u.id)),c=a.thread.filter(u=>u.deliveryStatus&&!l.has(u.id)),d=c.length>0?{...i,thread:[...i.thread,...c]}:i;if(a.optimisticAction==="resolve-pending"&&i.status!=="resolved"&&(d={...d,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="reopen-pending"&&i.status==="resolved"&&(d={...d,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="run-pending"&&a.latestRun?.id.startsWith("tmp-run")){let u=i.latestRun?Date.parse(i.latestRun.createdAt):Number.NaN,p=Date.parse(a.latestRun.createdAt);i.latestRun!=null&&(Number.isNaN(p)||Number.isNaN(u)||u>=p)||(d={...d,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return d}),s=t.filter(i=>(i.deliveryStatus||i.optimisticAction)&&!n.has(i.id));return [...o,...s]}function Rn({projectToken:t,apiBase:e,children:r}){let n=mt(),{activeViewport:o,setActiveViewport:s}=ne(),[i,a]=react.useState(()=>typeof window>"u"?null:Cr(t)),[l]=react.useState(()=>typeof window>"u"?"client-avatar:ssr":Sn(t)),[c,d]=react.useState(null),[u,p]=react.useState("client"),[m,v]=react.useState(null),[f,b]=react.useState([]),[h,y]=react.useState(null),[T,x]=react.useState([]),[z,D]=react.useState(false),[g,I]=react.useState(null),U=react.useRef(g);U.current=g;let at=react.useRef(o);at.current=o;let pt=h===o,vt=react.useMemo(()=>kn({apiBase:e,token:t,clientUserId:i?.clientUserId,clientSecret:i?.secret}),[e,t,i?.clientUserId,i?.secret]),st=react.useRef(vt);st.current=vt;let Q=react.useRef(0),K=react.useCallback(async()=>{let P=o,W=++Q.current,_=await st.current.listAnnotations(P==="desktop"?void 0:P);if(W!==Q.current||P!==at.current)return;let G=n.getPageUrl(),wt=_.filter(yt=>ct(yt.payload.url)===G);b(yt=>ja(yt,wt)),y(P);},[o,n]),k=react.useRef(K);k.current=K,react.useEffect(()=>{let P=false;return (async()=>{let W=await st.current.fetchMe();if(P)return;if(W.status==="unauthorized"){I(false),D(true);return}let _=W.status==="ok"?W.me:null;if(_?.active===false){I(false),D(true);return}if(I(true),_?.studio)d(_.studio),p("studio"),v(_.agentRunReadiness??{ready:true,message:null});else if(d(null),p("client"),v(null),_?.client){let G=Cr(t);if(G?.secret){let wt={clientUserId:_.client.id,name:_.client.name,email:_.client.email,avatarSeed:_.client.avatarSeed,secret:G.secret};a(wt),Ar(t,wt);}}await k.current(),P||D(true);})(),()=>{P=true;}},[t]),react.useEffect(()=>{!z||!g||K();},[z,g,K]),react.useEffect(()=>{if(!g)return;let{overlayDocument:P,overlayWindow:W}=n,_=W.setInterval(()=>{P.visibilityState==="visible"&&K();},qa),G=()=>{P.visibilityState==="visible"&&K();};return P.addEventListener("visibilitychange",G),()=>{W.clearInterval(_),P.removeEventListener("visibilitychange",G);}},[g,K,n]),react.useEffect(()=>{if(g)return tn(n.targetWindow,()=>{let P=n.getPageUrl();b(W=>W.filter(_=>ct(_.payload.url)===P)),k.current();})},[g,n]);let R=react.useCallback(async P=>(Ar(t,P),a(P),P),[t]),M=react.useCallback(()=>{a(null),An(t);},[t]),A=react.useCallback(P=>{x(W=>[...W.filter(_=>_.tempId!==P.tempId),P]);},[]),H=react.useCallback(P=>{x(W=>W.filter(_=>_.tempId!==P));},[]),F=react.useCallback(P=>{b(W=>{let _=W.findIndex(wt=>wt.id===P.id);if(_===-1)return [...W,P];let G=W.slice();return G[_]=P,G});},[]),E=react.useCallback((P,W)=>{b(_=>{let G=false,wt=_.flatMap(yt=>{if(yt.id!==P)return [yt];G=true;let Ut=W(yt);return Ut?[Ut]:[]});return G?wt:_});},[]),tt=react.useCallback((P,W)=>{b(_=>_.map(G=>G.id===P?{...G,id:W,deliveryStatus:"sent"}:G));},[]),xt=react.useMemo(()=>({apiClient:vt,active:g,ready:z,viewerKind:u,agentRunReadiness:m,activeViewport:o,clientAvatarSeed:l,identity:i,studio:c,annotations:f,annotationsReady:pt,ephemerals:T,refresh:K,setActiveViewport:s,setIdentity:R,signOut:M,addEphemeral:A,removeEphemeral:H,applyAnnotationUpdate:F,updateAnnotation:E,replaceAnnotationId:tt}),[vt,g,z,u,m,o,l,i,c,f,pt,T,K,s,R,M,A,H,F,E,tt]);return jsxRuntime.jsx(En.Provider,{value:xt,children:r})}function rt(){let t=react.use(En);if(!t)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return t}function Pn(t){if(t.length<12)return null;if(t[0]===255&&t[1]===216&&t[2]===255)return "image/jpeg";if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return "image/png";let e=(r,n)=>n.split("").every((o,s)=>t[r+s]===o.charCodeAt(0));return e(0,"RIFF")&&e(8,"WEBP")?"image/webp":null}var Ja=new Set(["AmpStateContext","AppRouter","AppRouterContext","ClientPageRoot","ClientSegmentRoot","ErrorBoundary","ForbiddenBoundary","GlobalLayoutRouterContext","HTTPAccessFallbackBoundary","HTTPAccessFallbackErrorBoundary","HeadManagerContext","HotReload","ImageConfigContext","InnerLayoutRouter","InnerScrollAndFocusHandler","InnerScrollAndFocusHandlerOld","LayoutRouterContext","LoadingBoundary","NavigationPromisesContext","NotFoundBoundary","OuterLayoutRouter","PathParamsContext","PathnameContext","ReactDevOverlay","RedirectBoundary","RedirectErrorBoundary","RenderFromTemplateContext","RouterContext","ScrollAndMaybeFocusHandler","SearchParamsContext","SegmentStateProvider","SegmentViewNode","ServerInsertedHTMLContext","Suspense","TemplateContext","UnauthorizedBoundary","AwaitContext","BrowserRouter","DataRouterContext","DataRouterStateContext","DataRoutes","FetchersContext","HashRouter","LocationContext","MemoryRouter","NavigationContext","Outlet","RenderErrorBoundary","RenderedRoute","Route","RouteContext","RouteErrorContext","Router","RouterProvider","Routes","StaticRouter","StaticRouterProvider","ViewTransitionContext"]);function Qa(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function In(t){return t.replace(/\s+/g," ").trim()}function Sr(t){return Ja.has(In(t))}function ts(t){return t.length<2||t.startsWith("_")?false:/^[A-Z]/.test(t)}function Nn(t){if(!t)return null;let e=[],r=t.matchAll(/<([^<>]+)>/g);for(let n of r){let o=In(n[1]??"");!o||Sr(o)||ts(o)&&e[e.length-1]!==o&&e.push(o);}return e.length===0?null:Qa(e.map(n=>`<${n}>`).join(" "),1e3)}var Mn="seed:";function Ye(t){return t?t.startsWith(Mn)?{url:null,seed:t.slice(Mn.length)||null}:/^https?:\/\//i.test(t)?{url:t,seed:null}:{url:null,seed:t}:{url:null,seed:null}}var Tr=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],_n=[{hue:"near",sat:[88,98],light:[68,82],r:[.44,.62],opacity:[.9,1],reach:[.14,.32]},{hue:"base",sat:[85,96],light:[44,56],r:[.5,.74],opacity:[.85,1],reach:[.2,.42]},{hue:"accent",sat:[84,97],light:[50,66],r:[.42,.64],opacity:[.8,.98],reach:[.26,.48]},{hue:"accent2",sat:[82,95],light:[30,46],r:[.44,.66],opacity:[.72,.94],reach:[.24,.46]}],Ln=Math.PI*2;function es(t){let e=2166136261;for(let r=0;r<t.length;r++)e^=t.charCodeAt(r),e=Math.imul(e,16777619);return e>>>0}function rs(t){return ()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function q(t,e,r){return e+t()*(r-e)}function gt(t,e=3){let r=10**e;return Math.round(t*r)/r}function Dn(t,e,r){return `hsl(${gt((t%360+360)%360,1)} ${gt(e,1)}% ${gt(r,1)}%)`}function On(t){let e=es(t?.trim()||"patch-client"),r=rs(e),n=e.toString(36),o=(Tr[e%Tr.length]??Tr[0])+q(r,-10,10),s=r()<.5?-1:1,i=r()<.5?-1:1,a=o+i*q(r,52,116),l=o-i*q(r,26,66),c=o+s*q(r,12,38),d=Dn(o+s*q(r,0,14),q(r,80,92),q(r,44,54)),u=q(r,0,Ln),p=_n.map((m,v)=>{let b=(m.hue==="accent"?a:m.hue==="accent2"?l:m.hue==="near"?c:o)+q(r,-11,11),h=u+v/_n.length*Ln+q(r,-0.6,.6),y=q(r,m.reach[0],m.reach[1]),T=gt(.5+Math.cos(h)*y),x=gt(.5+Math.sin(h)*y),z=gt(q(r,0,180),1),D=gt(q(r,.62,1.5),3),g=gt(q(r,.62,1.5),3);return {id:`cav-${n}-${v}`,cx:T,cy:x,r:gt(q(r,m.r[0],m.r[1])),color:Dn(b,q(r,m.sat[0],m.sat[1]),q(r,m.light[0],m.light[1])),opacity:gt(q(r,m.opacity[0],m.opacity[1]),2),gradientTransform:`rotate(${z} ${T} ${x}) translate(${T} ${x}) scale(${D} ${g}) translate(${gt(-T)} ${gt(-x)})`}});return {id:n,background:d,spots:p,blur:gt(q(r,3.4,5.4),2),grain:gt(q(r,.09,.15),2)}}var zn=react.createContext(null);function Hn({children:t}){let[e,r]=react.useState(null),[n,o]=react.useState(""),[s,i]=react.useState([]),[a,l]=react.useState(0),[c,d]=react.useState(false),u=react.useRef([]),p=react.useCallback(()=>{for(let g of u.current)URL.revokeObjectURL(g.previewUrl);u.current=[],i([]);},[]),m=react.useCallback(()=>{r(null),o(""),p(),d(false);},[p]),v=react.useCallback(g=>{r({kind:"existing",annotationId:g}),o(""),p(),d(false);},[p]),f=react.useCallback(g=>{r({kind:"composer",...g}),o(""),p(),d(false);},[p]),b=react.useCallback(g=>u.current.length>=4?false:(u.current=[...u.current,g],i(u.current),true),[]),h=react.useCallback((g,I)=>{u.current=u.current.map(U=>U.localId===g?{...U,...I}:U),i(u.current);},[]),y=react.useCallback(g=>{let I=u.current.find(U=>U.localId===g);I&&URL.revokeObjectURL(I.previewUrl),u.current=u.current.filter(U=>U.localId!==g),i(u.current);},[]),T=react.useCallback(()=>{if(n.trim().length>0||u.current.length>0){l(g=>g+1);return}m();},[n,m]),x=react.useCallback(()=>{m();},[m]),z=n.trim().length>0||s.length>0,D=react.useMemo(()=>({active:e,draftText:n,draftAttachments:s,hasDraft:z,shakeNonce:a,confirmDiscardOpen:c,openExisting:v,openComposer:f,setDraftText:o,addDraftAttachment:b,updateDraftAttachment:h,removeDraftAttachment:y,clearDraftAttachments:p,attemptClose:T,forceClose:x,setConfirmDiscardOpen:d}),[e,n,s,z,a,c,v,f,b,h,y,p,T,x]);return jsxRuntime.jsx(zn.Provider,{value:D,children:t})}function ft(){let t=react.use(zn);if(!t)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return t}var Bn=new Set(["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),ls=new Set(["a","button","input","select","textarea"]),Vn={a:"link",button:"button",input:"input",select:"select",textarea:"textarea",img:"img",svg:"icon",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"paragraph",li:"list item",td:"cell",th:"header cell",label:"label",blockquote:"quote",figcaption:"caption",code:"code",pre:"code block"},Xt=40,cs=1500,Fn=200,ds=5,us=10;function Wn(t){return Bn.has(t.tagName.toLowerCase())}function zt(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1)}\u2026`}function oe(t){return `"${t}"`}function ps(t){let e="";for(let r of Array.from(t.childNodes))r.nodeType===3&&(e+=r.textContent??"");return e.replace(/\s+/g," ").trim()}function Ge(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function ms(t){return !(!t||t.length>40||/__[A-Za-z0-9]{4,}$/.test(t)||/_[a-z0-9]{4,}$/i.test(t)&&/[0-9]/.test(t)||/_[A-Za-z0-9]{5,}_/.test(t)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(t)||/^[a-z]{2,}:[\w-]+$/.test(t)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(t)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(t)||(t.match(/\d/g)?.length??0)/t.length>.4)}function Ae(t){let e=Array.from(t.classList),r=e.filter(ms).slice(0,us);return r.length>0?r:e.length>0?["container"]:[]}function Un(t){let e=t.getAttribute("role")??void 0,r=t.getAttribute("aria-label")??void 0,n=t.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,s=t.tagName.toLowerCase(),i=ls.has(s)||o!==void 0&&Number.isFinite(o)&&o>=0;if(e===void 0&&r===void 0&&o===void 0&&!i)return;let a={focusable:i};return e!==void 0&&(a.role=e),r!==void 0&&(a.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(a.tabIndex=o),a}function gs(t){let e=t.tagName.toLowerCase(),r=Vn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${oe(zt(n,Xt))}`;let o=t.placeholder;if(o)return `${r} ${oe(zt(o,Xt))}`;let s=t.getAttribute("name");if(s)return `${r}[name="${s}"]`;if(e==="input"){let i=t.type||"text";return `${r}[type=${i}]`}return r}function fs(t){let e=t.alt?.trim();return e?`img ${oe(zt(e,Xt))}`:"img"}function Xe(t){let e=t.tagName.toLowerCase();if(e==="img")return fs(t);if(e==="input"||e==="textarea"||e==="select")return gs(t);let r=Vn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${oe(zt(n,Xt))}`;if(e==="a"||e==="button"||Bn.has(e)||e==="label"){let s=Ge(t);if(s)return `${r} ${oe(zt(s,Xt))}`;if(e==="a"||e==="button"){let i=t.querySelector("svg");if(i){let l=i.getAttribute("aria-label");return l?`${r} ${oe(zt(l,Xt))}`:`${r} (icon)`}let a=t.getAttribute("href");if(e==="a"&&a)return `link[href="${zt(a,Xt)}"]`}return r}if(t.id)return `${e}#${t.id}`;let o=Ae(t);return o.length>0?`${e}.${o[0]}`:e}function Yn(t){let e=[],r=t,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)e.unshift(Xe(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&e.unshift("body"),e.join(" > ").slice(0,cs)}function Gn(t){let e=Ge(t),r=t.parentElement;if(!r)return;let n=Ge(r);if(n){if(e&&n===e){let o=r.parentElement;if(!o)return;let s=Ge(o);return !s||s===e?void 0:zt(s,Fn)}return zt(n,Fn)}}function Xn(t){let e=t.parentElement;if(!e)return [];let r=[];for(let n of Array.from(e.children))if(n!==t&&n.tagName.toLowerCase()!=="script"&&(r.push(Xe(n)),r.length>=ds))break;return r}var hs=["role","aria-label","name"],bs=10,$n=100;function Ke(t){let e={};for(let r of hs){let n=t.getAttribute(r);n!==null&&n!==""&&(e[r]=n.slice(0,$n));}for(let r of Array.from(t.attributes)){if(Object.keys(e).length>=bs)break;r.name.startsWith("data-")&&r.value!==""&&(e[r.name]=r.value.slice(0,$n));}return e}function qe(t){return ps(t)}function Kn(t){let e=t;for(;e&&e.nodeType!==1;)e=e.parentNode;return e}function qn(t,e){return t.closest(`[${e}]`)!==null}var vs=new Set(["p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),xs={article:"Article",aside:"Sidebar",dialog:"Dialog",fieldset:"Form section",figure:"Image",footer:"Footer",form:"Form",header:"Header",main:"Main content",nav:"Navigation",section:"Section",summary:"Summary"},ws={a:"Link",article:"Article",aside:"Sidebar",blockquote:"Text",button:"Button",code:"Text",div:"Area",figcaption:"Text",figure:"Image",footer:"Footer",form:"Form",header:"Header",img:"Image",input:"Field",label:"Text",li:"Text",main:"Main content",nav:"Navigation",p:"Text",pre:"Text",section:"Section",select:"Field",span:"Text",svg:"Icon",textarea:"Field"},ys={caption:"Text",cell:"Text","code block":"Text",icon:"Icon",input:"Field",label:"Text",link:"Link","list item":"Text",paragraph:"Text",quote:"Text",select:"Field",textarea:"Field"};function Zn(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1).trim()}\u2026`}function ks(t){return `"${t}"`}function je(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function jn(t){let e=t.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):""}function dt(t,e){let r=e?.trim();return r?`${t}: ${ks(Zn(r,48))}`:t}function Cs(t){let e=t.trim(),r=e.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??e,text:r[2]}:{base:e}}function As(t){let e=t.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=ys[e];if(r)return r;let n=t.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":ws[n]??"Area":"Area"}function Ss(t){let e=t.getAttribute("aria-label");if(e)return dt("Field",e);let r=t.placeholder;if(r)return dt("Field",r);let n=t.getAttribute("name");if(n)return dt("Field",jn(n));if(t.tagName.toLowerCase()==="input"){let o=t.type||"text";if(o!=="text")return dt("Field",jn(o))}return "Field"}function Se(t,e){if(e?.trim())return dt("Selected text",e);let r=t.tagName.toLowerCase(),n=t.getAttribute("aria-label");if(r==="button")return dt("Button",n??je(t));if(r==="a")return dt("Link",n??je(t));if(r==="input"||r==="textarea"||r==="select")return Ss(t);if(r==="img"){let s=t.alt;return dt("Image",s)}if(r==="svg")return dt("Icon",n);if(/^h[1-6]$/.test(r))return dt("Heading",je(t));if(vs.has(r))return dt("Text",je(t));let o=xs[r];return dt(o||"Area",n)}function Jn(t){if(t.targetLabel?.trim())return Zn(t.targetLabel,120);if(t.selectedText?.trim())return dt("Selected text",t.selectedText);let e=t.element?.trim()||t.elementPath?.trim();if(!e)return "Annotation";let r=Cs(e.split(">").at(-1)??e);return dt(As(r.base),r.text)}var Qn="patch-capture-cursor-style";function Ts(t){let e=`:not([${t}]):not([${t}] *)`,r=["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"].map(n=>`body ${n}${e}`).join(`,
3
3
  `);return ["html, body { cursor: crosshair !important; }",`body *${e} { cursor: crosshair !important; }`,`${r} { cursor: text !important; }`].join(`
4
- `)}function Ss(t,e){let r=t.targetDocument,n=r.getElementById(Jn);n&&n.remove();let o=r.createElement("style");return o.id=Jn,o.setAttribute(e,""),o.textContent=As(e),r.head.appendChild(o),o}function Sr(t,e,r){let n=t.eventTargetElement(e);return n?n.closest(`[${r}]`)!==null:false}var ie=1.5,Ts="#0287FE",Es="rgba(2, 135, 254, 0.032)";function Rs(t){let e=t.split(" ")[0]??"",r=Number.parseFloat(e);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Ps(t,e){let r=t.targetDocument,n=r.createElement("div");n.setAttribute(e,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${ie}px solid ${Ts}`,background:Es,boxSizing:"border-box",zIndex:"2147483645",display:"none",borderRadius:"6px",transition:"top 80ms ease-out, left 80ms ease-out, width 80ms ease-out, height 80ms ease-out, border-radius 80ms ease-out"});let o=r.createElement("div");o.setAttribute(e,""),Object.assign(o.style,{position:"fixed",pointerEvents:"none",background:"#111",color:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"12px",fontWeight:"500",padding:"6px 10px",borderRadius:"6px",zIndex:"2147483646",maxWidth:"240px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"none",boxShadow:"0 10px 24px -12px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.08)"}),r.body.appendChild(n),r.body.appendChild(o);let s=null;return {update(i){let a=i.getBoundingClientRect();if(a.width===0&&a.height===0){this.hide();return}n.style.display="block",n.style.top=`${a.top-ie}px`,n.style.left=`${a.left-ie}px`,n.style.width=`${a.width+ie*2}px`,n.style.height=`${a.height+ie*2}px`,n.style.borderRadius=`${Rs(t.targetWindow.getComputedStyle(i).borderRadius)+ie}px`,i!==s&&(o.textContent=Se(i),s=i),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),d=t.getTargetViewport().width-8;l+240<=d?(o.style.left=`${l}px`,o.style.top=`${c}px`):(o.style.left=`${Math.max(8,a.right-240)}px`,o.style.top=`${Math.max(8,a.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function Qn(t){let{internalAttr:e,onClick:r,surface:n}=t,o=n.targetDocument,s=Ss(n,e),i=Ps(n,e),a=false,l=v=>{let f=v;if(Sr(n,f.target,e))return;let b=n.eventTargetElement(f.target);b&&Vn(b)||(f.preventDefault(),f.stopPropagation());},c=l,d=l,u=v=>{let f=v;Sr(n,f.target,e)||(f.preventDefault(),f.stopPropagation(),!a&&r(f));},p=v=>{let f=v;if(a)return;let b=n.eventTargetElement(f.target);if(!b){i.hide();return}if(Sr(n,b,e)){i.hide();return}let h=b.tagName.toLowerCase();if(h==="html"||h==="body"){i.hide();return}i.update(b);},m=v=>{v.relatedTarget||i.hide();};return o.addEventListener("mousedown",c,true),o.addEventListener("mouseup",d,true),o.addEventListener("click",u,true),o.addEventListener("mousemove",p,true),o.addEventListener("mouseout",m,true),{exit(){s.remove(),i.destroy(),o.removeEventListener("mousedown",c,true),o.removeEventListener("mouseup",d,true),o.removeEventListener("click",u,true),o.removeEventListener("mousemove",p,true),o.removeEventListener("mouseout",m,true);},pause(){a=true,i.hide();},resume(){a=false;}}}function to(t){let{clickTarget:e,selection:r}=t,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),s=Xn(o.commonAncestorContainer);if(s)return {kind:"element",element:s,rect:s.getBoundingClientRect(),selectedText:n,clickTarget:e}}return {kind:"element",element:e,rect:e.getBoundingClientRect(),clickTarget:e}}var Ls="data-patch-internal",ro=react.createContext(null),eo=0;function Ds(){return eo+=1,`tmp-${Date.now().toString(36)}-${eo}`}function no({children:t}){let e=ft(),r=rt(),n=mt(),{isPreviewing:o,previewReady:s}=ne(),[i,a]=react.useState(false),l=react.useRef(null),c=react.useRef(e),d=react.useRef(r);c.current=e,d.current=r;let u=react.useCallback(h=>{let y=c.current;if(y.active&&y.hasDraft){y.attemptClose();return}let T=n.eventTargetElement(h.target)??n.targetDocument.body,x=n.targetWindow.getSelection(),z=to({clickTarget:T,selection:x}),O=Ds(),g={viewportX:h.clientX,viewportY:h.clientY,documentY:h.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:O,viewportX:g.viewportX,viewportY:g.viewportY,documentY:g.documentY}),c.current.openComposer({tempId:O,target:z,anchor:g}),l.current?.pause();},[n]),p=r.annotationsReady&&(!o||s);react.useEffect(()=>{if(!i||!p){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=Qn({internalAttr:Ls,surface:n,onClick:u}),()=>{l.current?.exit(),l.current=null;}},[i,u,n,p]);let m=react.useCallback(()=>{i||a(true);},[i]),v=react.useCallback(()=>{a(false);},[]),f=react.useRef(null);react.useEffect(()=>{let h=f.current,y=e.active;h?.kind==="composer"&&y?.kind!=="composer"&&(d.current.removeEphemeral(h.tempId),l.current?.resume()),h?.kind==="composer"&&y?.kind==="composer"&&h.tempId!==y.tempId&&d.current.removeEphemeral(h.tempId),f.current=y;},[e.active]),react.useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let b=react.useMemo(()=>({isCapturing:i,enter:m,exit:v}),[i,m,v]);return jsxRuntime.jsx(ro.Provider,{value:b,children:t})}function oo(){let t=react.use(ro);if(!t)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return t}var Fs="patch:focus-intent";function Ir(t){return `${Fs}:${t}`}function $s(t){try{let e=window.sessionStorage.getItem(Ir(t));if(!e)return null;window.sessionStorage.removeItem(Ir(t));let r=JSON.parse(e);return typeof r.id!="string"||typeof r.url!="string"?null:{id:r.id,url:r.url,viewport:r.viewport??"desktop"}}catch{return null}}function Bs(t,e){try{window.sessionStorage.setItem(Ir(t),JSON.stringify(e));}catch{}}var so=react.createContext(null);function Vs(t){return t==="pending"||t==="acknowledged"}function lo({projectToken:t,children:e}){let{apiClient:r,active:n,viewerKind:o,annotations:s}=rt(),i=o==="studio",[a,l]=react.useState([]),[c,d]=react.useState(false),[u,p]=react.useState(null),m=react.useRef(r);m.current=r;let v=react.useCallback(async()=>{if(!i){l([]),d(true);return}let g=await m.current.listRoster();l(g),d(true);},[i]);react.useEffect(()=>{if(!n||!i)return;let g=$s(t);g&&ct(g.url)===ct(window.location.href)&&p(g),v();},[n,i,t,v]);let f=react.useMemo(()=>s.map(g=>`${g.id}:${g.status}`).sort().join(","),[s]),b=react.useRef(null);react.useEffect(()=>{if(!(!n||!i)){if(b.current===null){b.current=f;return}b.current!==f&&(b.current=f,v());}},[f,n,i,v]);let h=react.useCallback(g=>{let N={id:g.id,url:g.url,viewport:g.viewport};if(ct(g.url)===ct(window.location.href)){p(N);return}Bs(t,N),window.location.assign(g.url);},[t]),y=react.useCallback(()=>p(null),[]),T=react.useMemo(()=>{let g=new Map;for(let N of s)g.set(N.id,N.status);return g},[s]),x=react.useMemo(()=>a.map(g=>{let N=T.get(g.id);return N&&N!==g.status?{...g,status:N}:g}),[a,T]),z=react.useMemo(()=>x.filter(g=>Vs(g.status)).length,[x]),O=react.useMemo(()=>({entries:x,ready:c,unresolvedCount:z,refresh:v,focusPin:h,pendingFocus:u,clearFocus:y}),[x,c,z,v,h,u,y]);return jsxRuntime.jsx(so.Provider,{value:O,children:e})}function ae(){let t=react.use(so);if(!t)throw new Error("useRosterStore must be used inside <RosterProvider>");return t}var uo=react.createContext(null);function po({children:t}){let[e,r]=react.useState(false),[n,o]=react.useState(false),s=react.useMemo(()=>({dockOpen:e,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[e,n]);return jsxRuntime.jsx(uo.Provider,{value:s,children:t})}function Bt(){let t=react.use(uo);if(!t)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return t}var mo="[Patch] No project token found, widget disabled. Pass `projectToken` as a prop, or set NEXT_PUBLIC_PATCH_TOKEN (Next.js), VITE_PATCH_TOKEN (Vite / React Router), or PUBLIC_PATCH_TOKEN (Astro) in your env.";function go(t){let e=t.prop?.trim();if(e)return e;let r=t.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=t.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=t.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();return o||null}function fo(){try{return typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) })>"u"?void 0:undefined}catch{return}}function ho(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}function Ee(t){let e=t.gap??12,r=t.margin??16,n=Math.min(t.popover.width,Math.max(0,t.viewport.width-r*2)),o="right",s=t.anchor.x+t.anchor.width+e;s+n>t.viewport.width-r&&(o="left",s=t.anchor.x-n-e),s<r&&(s=r);let i=t.anchor.y;return i+t.popover.height>t.viewport.height-r&&(i=t.viewport.height-r-t.popover.height),i<r&&(i=r),{x:s,y:i,width:n,placement:o}}function C(...t){return t.filter(Boolean).join(" ")}function Qe({seed:t,className:e,style:r}){let n=Dn(t),o=react.useId().replace(/[^a-zA-Z0-9_-]/g,""),s=`${n.id}-${o}`,i=`cav-blur-${s}`,a=`cav-grain-${s}`;return jsxRuntime.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:C("absolute inset-0 size-full! overflow-hidden rounded-full",e),style:r,children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsxRuntime.jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxRuntime.jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsxRuntime.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsxRuntime.jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxRuntime.jsxs("radialGradient",{id:`${s}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsxRuntime.jsx("rect",{width:"64",height:"64",fill:n.background}),jsxRuntime.jsx("g",{filter:`url(#${i})`,children:n.spots.map(l=>jsxRuntime.jsx("rect",{width:"64",height:"64",fill:`url(#${s}-${l.id})`},l.id))}),jsxRuntime.jsx("rect",{width:"64",height:"64",filter:`url(#${a})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var _t=32,bo=[.22,.61,.36,1],tr=["var(--color-avatar-tint-1)","var(--color-avatar-tint-2)","var(--color-avatar-tint-3)","var(--color-avatar-tint-4)","var(--color-avatar-tint-5)"];function se(t){if(!t)return "?";let e=t.trim().split(/\s+/),r=e[0],n=e[e.length-1];if(!r||!n)return "?";if(e.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",s=n[0]??"";return (o+s).toUpperCase()||"?"}function le(t){if(!t)return tr[0];let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return tr[Math.abs(e)%tr.length]??tr[0]}var js={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},Zs={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function ce(t,e){let{placement:r}=Ee({anchor:{x:t.viewportX-_t/2,y:t.viewportY-_t/2,width:_t,height:_t},popover:{width:332,height:200},viewport:e});return r==="right"?"left":"right"}function er(t,e){return {x:e==="left"?t.viewportX:t.viewportX-_t,y:t.viewportY-_t,width:_t,height:_t}}function Nr({ref:t,...e}){let r=e.pointSide??"right",n=!e.resolved&&e.attention?Js[e.attention]:null,{url:o,seed:s}=Ye(e.avatarSrc),i=s??e.generatedSeed,a=e.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",l=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsxRuntime.jsx(react$1.motion.button,{ref:t,type:"button",onClick:e.onClick,"aria-label":e.ariaLabel??"Open annotation","data-patch-ephemeral":e.ephemeral?"":void 0,"data-patch-pin-id":e.pinId,className:"patch-pin-button fixed z-[2147483645] border-0 bg-transparent p-0",style:{width:_t,height:_t},initial:e.ephemeral?{opacity:0,scale:.45}:false,animate:e.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:e.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:bo}}:{opacity:0,scale:.9,transition:{duration:.12,ease:bo}},children:jsxRuntime.jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:js[r]},children:[jsxRuntime.jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:Zs[r],background:"var(--color-muted-foreground)"},children:[i?jsxRuntime.jsx(Qe,{seed:i,style:{borderRadius:0,filter:a||"none"}}):null,o?jsxRuntime.jsx("img",{src:o,alt:e.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:a||"none"},onError:c=>{c.currentTarget.remove();}}):null]}),e.resolved&&jsxRuntime.jsx("span",{className:`absolute ${l} grid size-[14px] place-items-center rounded-full bg-brand-green text-[9px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsxRuntime.jsx("span",{"data-patch-attention":e.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[10px] rounded-full border-[1.5px] border-white ${n}`})]})})}var Js={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function rr(t){let e=new Date(t).getTime(),r=Date.now()-e,n=Math.round(r/6e4);if(Number.isNaN(n))return "";if(n<1)return "just now";if(n<60)return `${n}m ago`;let o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function xo(t){let e=t.composedPath();for(let r of e)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function wo(t){let e=t.match(/\/pull\/(\d+)/);return e?`#${e[1]}`:"PR"}var yo={"arrow-up":[["path",{d:"M12 5.5V19"}],["path",{d:"M18 11C18 11 13.5811 5.00001 12 5C10.4188 4.99999 6 11 6 11"}]],camera:[["path",{d:"M12.6974 3.5H11.303C10.5884 3.5 10.2311 3.5 9.91067 3.612C9.71499 3.68039 9.53113 3.77879 9.36568 3.90367C9.09474 4.10816 8.89655 4.40544 8.50018 5L8.50017 5.00001C8.29717 5.30453 7.99794 5.75337 7.87867 5.87871C7.58314 6.18927 7.19563 6.39666 6.77329 6.47029C6.60284 6.5 6.41985 6.5 6.05387 6.5C5.07379 6.5 4.58376 6.5 4.18307 6.61342C3.18074 6.89716 2.39734 7.68055 2.1136 8.68289C2.00018 9.08357 2.00018 9.57361 2.00018 10.5537V14.5C2.00018 17.3284 2.00018 18.7426 2.87886 19.6213C3.75754 20.5 5.17176 20.5 8.00018 20.5H16.0002C18.8286 20.5 20.2428 20.5 21.1215 19.6213C22.0002 18.7426 22.0002 17.3284 22.0002 14.5V10.5537C22.0002 9.57361 22.0002 9.08357 21.8868 8.68289C21.603 7.68055 20.8196 6.89716 19.8173 6.61342C19.4166 6.5 18.9266 6.5 17.9465 6.5C17.5805 6.5 17.3975 6.5 17.2271 6.47029C16.8047 6.39666 16.4172 6.18927 16.1217 5.87871C16.0024 5.75336 15.7032 5.30451 15.5002 5C15.1038 4.40544 14.9056 4.10816 14.6347 3.90367C14.4692 3.77879 14.2854 3.68039 14.0897 3.612C13.7693 3.5 13.412 3.5 12.6974 3.5Z"}],["path",{d:"M16.0002 13C16.0002 15.2091 14.2093 17 12.0002 17C9.79104 17 8.00018 15.2091 8.00018 13C8.00018 10.7909 9.79104 9 12.0002 9C14.2093 9 16.0002 10.7909 16.0002 13Z"}],["path",{d:"M19.1252 9.5H19.0002M19.2502 9.5C19.2502 9.63807 19.1383 9.75 19.0002 9.75C18.8621 9.75 18.7502 9.63807 18.7502 9.5C18.7502 9.36193 18.8621 9.25 19.0002 9.25C19.1383 9.25 19.2502 9.36193 19.2502 9.5Z"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],"chevron-left":[["path",{d:"M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18"}]],"chevron-right":[["path",{d:"M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18"}]],copy:[["path",{d:"M9 15C9 12.1716 9 10.7574 9.87868 9.87868C10.7574 9 12.1716 9 15 9L16 9C18.8284 9 20.2426 9 21.1213 9.87868C22 10.7574 22 12.1716 22 15V16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H15C12.1716 22 10.7574 22 9.87868 21.1213C9 20.2426 9 18.8284 9 16L9 15Z"}],["path",{d:"M16.9999 9C16.9975 6.04291 16.9528 4.51121 16.092 3.46243C15.9258 3.25989 15.7401 3.07418 15.5376 2.90796C14.4312 2 12.7875 2 9.5 2C6.21252 2 4.56878 2 3.46243 2.90796C3.25989 3.07417 3.07418 3.25989 2.90796 3.46243C2 4.56878 2 6.21252 2 9.5C2 12.7875 2 14.4312 2.90796 15.5376C3.07417 15.7401 3.25989 15.9258 3.46243 16.092C4.51121 16.9528 6.04291 16.9975 9 16.9999"}]],cursor:[["path",{d:"M12.669 8.35811L17.6969 10.3256C20.5969 11.4604 22.0469 12.0277 21.9988 12.9278C21.9508 13.8278 20.4375 14.2405 17.4111 15.0659C16.5099 15.3117 16.0593 15.4346 15.7469 15.7469C15.4346 16.0593 15.3117 16.5099 15.0659 17.4111C14.2405 20.4375 13.8278 21.9508 12.9278 21.9988C12.0277 22.0469 11.4604 20.5969 10.3256 17.6969L8.35811 12.669C7.17004 9.63279 6.57601 8.1147 7.34535 7.34535C8.1147 6.57601 9.63279 7.17004 12.669 8.35811Z"}],["path",{d:"M9 4V2M5 5L3.5 3.5M4 9H2M5 13L3.5 14.5M14.5 3.5L13 5"}]],desktop:[["path",{d:"M14 21H16M14 21C13.1716 21 12.5 20.3284 12.5 19.5V17L12 17M14 21H10M10 21H8M10 21C10.8284 21 11.5 20.3284 11.5 19.5V17L12 17M12 17V21"}],["path",{d:"M16 3H8C5.17157 3 3.75736 3 2.87868 3.87868C2 4.75736 2 6.17157 2 9V11C2 13.8284 2 15.2426 2.87868 16.1213C3.75736 17 5.17157 17 8 17H16C18.8284 17 20.2426 17 21.1213 16.1213C22 15.2426 22 13.8284 22 11V9C22 6.17157 22 4.75736 21.1213 3.87868C20.2426 3 18.8284 3 16 3Z"}]],globe:[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12C8 18 12 22 12 22C12 22 16 18 16 12C16 6 12 2 12 2C12 2 8 6 8 12Z"}],["path",{d:"M21 15H3"}],["path",{d:"M21 9H3"}]],list:[["path",{d:"M8 5.5L20 5.5"}],["path",{d:"M8 12.5L20 12.5"}],["path",{d:"M8 19.5L20 19.5"}],["path",{d:"M4.375 5.5H4.25M4.5 5.5C4.5 5.63807 4.38807 5.75 4.25 5.75C4.11193 5.75 4 5.63807 4 5.5C4 5.36193 4.11193 5.25 4.25 5.25C4.38807 5.25 4.5 5.36193 4.5 5.5Z"}],["path",{d:"M4.375 12.5H4.25M4.5 12.5C4.5 12.6381 4.38807 12.75 4.25 12.75C4.11193 12.75 4 12.6381 4 12.5C4 12.3619 4.11193 12.25 4.25 12.25C4.38807 12.25 4.5 12.3619 4.5 12.5Z"}],["path",{d:"M4.375 19.5H4.25M4.5 19.5C4.5 19.6381 4.38807 19.75 4.25 19.75C4.11193 19.75 4 19.6381 4 19.5C4 19.3619 4.11193 19.25 4.25 19.25C4.38807 19.25 4.5 19.3619 4.5 19.5Z"}]],lock:[["path",{d:"M4.26781 18.8447C4.49269 20.515 5.87613 21.8235 7.55966 21.9009C8.97627 21.966 10.4153 22 12 22C13.5847 22 15.0237 21.966 16.4403 21.9009C18.1239 21.8235 19.5073 20.515 19.7322 18.8447C19.879 17.7547 20 16.6376 20 15.5C20 14.3624 19.879 13.2453 19.7322 12.1553C19.5073 10.485 18.1239 9.17649 16.4403 9.09909C15.0237 9.03397 13.5847 9 12 9C10.4153 9 8.97627 9.03397 7.55966 9.09909C5.87613 9.17649 4.49269 10.485 4.26781 12.1553C4.12104 13.2453 4 14.3624 4 15.5C4 16.6376 4.12104 17.7547 4.26781 18.8447Z"}],["path",{d:"M7.5 9V6.5C7.5 4.01472 9.51472 2 12 2C14.4853 2 16.5 4.01472 16.5 6.5V9"}],["path",{d:"M12.125 15.5H12M12.25 15.5C12.25 15.6381 12.1381 15.75 12 15.75C11.8619 15.75 11.75 15.6381 11.75 15.5C11.75 15.3619 11.8619 15.25 12 15.25C12.1381 15.25 12.25 15.3619 12.25 15.5Z"}]],mobile:[["path",{d:"M13.5 2H10.5C8.14298 2 6.96447 2 6.23223 2.73223C5.5 3.46447 5.5 4.64298 5.5 7V17C5.5 19.357 5.5 20.5355 6.23223 21.2678C6.96447 22 8.14298 22 10.5 22H13.5C15.857 22 17.0355 22 17.7678 21.2678C18.5 20.5355 18.5 19.357 18.5 17V7C18.5 4.64298 18.5 3.46447 17.7678 2.73223C17.0355 2 15.857 2 13.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],more:[["path",{d:"M12 12.002H12.5M19 12.002H19.5M5 12.002H5.5M12 13.002C12.5523 13.002 13 12.5542 13 12.002C13 11.4497 12.5523 11.002 12 11.002C11.4477 11.002 11 11.4497 11 12.002C11 12.5542 11.4477 13.002 12 13.002ZM19 13.002C19.5523 13.002 20 12.5542 20 12.002C20 11.4497 19.5523 11.002 19 11.002C18.4477 11.002 18 11.4497 18 12.002C18 12.5542 18.4477 13.002 19 13.002ZM5 13.002C5.55228 13.002 6 12.5542 6 12.002C6 11.4497 5.55228 11.002 5 11.002C4.44772 11.002 4 11.4497 4 12.002C4 12.5542 4.44772 13.002 5 13.002Z"}]],paperclip:[["path",{d:"M5.82338 12L4.27922 10.4558C2.57359 8.75022 2.57359 5.98485 4.27922 4.27922C5.98485 2.57359 8.75022 2.57359 10.4558 4.27922L19.7208 13.5442C21.4264 15.2498 21.4264 18.0152 19.7208 19.7208C18.0152 21.4264 15.2498 21.4264 13.5442 19.7208L10.0698 16.2464C9.00379 15.1804 9.00379 13.4521 10.0698 12.386C11.1358 11.32 12.8642 11.32 13.9302 12.386L15.8604 14.3162"}]],play:[["path",{d:"M18.8906 12.846C18.5371 14.189 16.8667 15.138 13.5257 17.0361C10.296 18.8709 8.6812 19.7884 7.37983 19.4196C6.8418 19.2671 6.35159 18.9776 5.95624 18.5787C5 17.6139 5 15.7426 5 12C5 8.2574 5 6.3861 5.95624 5.42132C6.35159 5.02245 6.8418 4.73288 7.37983 4.58042C8.6812 4.21165 10.296 5.12907 13.5257 6.96393C16.8667 8.86197 18.5371 9.811 18.8906 11.154C19.0365 11.7084 19.0365 12.2916 18.8906 12.846Z"}]],pr:[["path",{d:"M6 8L6 16"}],["path",{d:"M18 16V12C18 9.17156 18 7.75735 17.1213 6.87867C16.2426 5.99999 14.8284 5.99999 12 5.99999L11 5.99999M11 5.99999C11 5.29976 12.9943 3.99152 13.5 3.49999M11 5.99999C11 6.70022 12.9943 8.00846 13.5 8.49999"}],["circle",{cx:"6",cy:"18",r:"2"}],["circle",{cx:"6",cy:"6",r:"2"}],["circle",{cx:"18",cy:"18",r:"2"}]],refresh:[["path",{d:"M20.0092 2V5.13219C20.0092 5.42605 19.6418 5.55908 19.4537 5.33333C17.6226 3.2875 14.9617 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12"}]],robot:[["path",{d:"M19 16V14C19 11.1716 19 9.75736 18.1213 8.87868C17.2426 8 15.8284 8 13 8H11C8.17157 8 6.75736 8 5.87868 8.87868C5 9.75736 5 11.1716 5 14V16C5 18.8284 5 20.2426 5.87868 21.1213C6.75736 22 8.17157 22 11 22H13C15.8284 22 17.2426 22 18.1213 21.1213C19 20.2426 19 18.8284 19 16Z"}],["path",{d:"M19 18C20.4142 18 21.1213 18 21.5607 17.5607C22 17.1213 22 16.4142 22 15C22 13.5858 22 12.8787 21.5607 12.4393C21.1213 12 20.4142 12 19 12"}],["path",{d:"M5 18C3.58579 18 2.87868 18 2.43934 17.5607C2 17.1213 2 16.4142 2 15C2 13.5858 2 12.8787 2.43934 12.4393C2.87868 12 3.58579 12 5 12"}],["path",{d:"M13.5 3.5C13.5 4.32843 12.8284 5 12 5C11.1716 5 10.5 4.32843 10.5 3.5C10.5 2.67157 11.1716 2 12 2C12.8284 2 13.5 2.67157 13.5 3.5Z"}],["path",{d:"M12 5V8"}],["path",{d:"M9 13V14"}],["path",{d:"M15 13V14"}],["path",{d:"M10 17.5C10 17.5 10.6667 18 12 18C13.3333 18 14 17.5 14 17.5"}]],settings:[["path",{d:"M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z"}],["path",{d:"M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z"}]],tablet:[["path",{d:"M14.5 2H9.5C6.67157 2 5.25736 2 4.37868 2.87868C3.5 3.75736 3.5 5.17157 3.5 8V16C3.5 18.8284 3.5 20.2426 4.37868 21.1213C5.25736 22 6.67157 22 9.5 22H14.5C17.3284 22 18.7426 22 19.6213 21.1213C20.5 20.2426 20.5 18.8284 20.5 16V8C20.5 5.17157 20.5 3.75736 19.6213 2.87868C18.7426 2 17.3284 2 14.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],trash:[["path",{d:"M19.5 5.5L18.8803 15.5251C18.7219 18.0864 18.6428 19.3671 18.0008 20.2879C17.6833 20.7431 17.2747 21.1273 16.8007 21.416C15.8421 22 14.559 22 11.9927 22C9.42312 22 8.1383 22 7.17905 21.4149C6.7048 21.1257 6.296 20.7408 5.97868 20.2848C5.33688 19.3626 5.25945 18.0801 5.10461 15.5152L4.5 5.5"}],["path",{d:"M3 5.5H21M16.0557 5.5L15.3731 4.09173C14.9196 3.15626 14.6928 2.68852 14.3017 2.39681C14.215 2.3321 14.1231 2.27454 14.027 2.2247C13.5939 2 13.0741 2 12.0345 2C10.9688 2 10.436 2 9.99568 2.23412C9.8981 2.28601 9.80498 2.3459 9.71729 2.41317C9.32164 2.7167 9.10063 3.20155 8.65861 4.17126L8.05292 5.5"}],["path",{d:"M9.5 16.5L9.5 10.5"}],["path",{d:"M14.5 16.5L14.5 10.5"}]],unlink:[["path",{d:"M12.1434 10.691L12.3503 10.4841C14.329 8.50532 17.5372 8.50532 19.5159 10.4841C21.4947 12.4628 21.4947 15.671 19.5159 17.6497L16.6497 20.5159C14.671 22.4947 11.4628 22.4947 9.48405 20.5159C7.50532 18.5372 7.50532 15.329 9.48405 13.3503L9.9484 12.886"}],["path",{d:"M20.0516 11.114L20.5159 10.6497C22.4947 8.67095 22.4947 5.46279 20.5159 3.48405C18.5372 1.50532 15.329 1.50532 13.3503 3.48405L10.4841 6.35031C8.50532 8.32904 8.50532 11.5372 10.4841 13.5159C12.4628 15.4947 15.671 15.4947 17.6497 13.5159L17.8566 13.309"}],["path",{d:"M4.5 4L6 6M2 8L5 9M3 13.5L5 12"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function I({name:t,size:e=16,stroke:r=2,color:n,className:o}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:yo[t].map(([s,i],a)=>react.createElement(s,{key:a,...i}))})}var Co=[.16,1,.3,1];function rl(t){try{let r=new URL(t).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return t}}function nr(t){return t==="pending"||t==="acknowledged"}function Ao({onClose:t}){let e=ae(),{hideResolvedAnnotations:r}=Bt(),n=e.focusPin,o=typeof window>"u"?"":ct(window.location.href),s=react.useMemo(()=>[...r?e.entries.filter(d=>d.status!=="resolved"):e.entries].sort((d,u)=>(nr(d.status)?0:1)-(nr(u.status)?0:1)),[e.entries,r]),i=react.useMemo(()=>{let c=e.entries.filter(u=>nr(u.status)&&ct(u.url)===o).length,d=e.entries.filter(u=>nr(u.status)).length;return {here:c,elsewhere:d-c,total:d}},[e.entries,o]);function a(){if(i.total===0)return "No open feedback";let c=[`${i.total} open`];return i.here>0&&c.push(`${i.here} here`),i.elsewhere>0&&c.push(`${i.elsewhere} elsewhere`),c.join(" \xB7 ")}function l(c){t(),n(c);}return jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease:Co}},exit:{opacity:0,y:4,scale:.985,transition:{duration:.12,ease:Co}},"data-patch-fab-dock":"","data-patch-roster-panel":"",className:"absolute right-0 bottom-[54px] z-[2147483647] flex max-h-[min(480px,calc(100vh-120px))] w-[min(360px,calc(100vw-40px))] flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:{transformOrigin:"100% 100%"},children:[jsxRuntime.jsxs("div",{className:"flex items-baseline justify-between gap-2 px-4 pt-3.5 pb-2.5",children:[jsxRuntime.jsx("span",{className:"text-[13px] font-semibold",children:"Feedback"}),jsxRuntime.jsx("span",{className:"text-[11.5px] font-medium text-popover-foreground/50",children:a()})]}),s.length===0?jsxRuntime.jsx("div",{className:"px-4 pt-2 pb-6 text-center text-[12.5px] text-popover-foreground/50",children:"No feedback yet."}):jsxRuntime.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-2",children:s.map(c=>jsxRuntime.jsx(nl,{entry:c,onCurrentPage:ct(c.url)===o,onClick:()=>l(c)},c.id))})]})}function nl({entry:t,onCurrentPage:e,onClick:r}){let n=t.status==="resolved",o=t.anchorStatus==="detached";return jsxRuntime.jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-row":t.id,onClick:r,className:"flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-black/[0.04]",children:[jsxRuntime.jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsxRuntime.jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsxRuntime.jsx(I,{name:"check",size:10,stroke:2.6})}):t.status==="dismissed"?jsxRuntime.jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsxRuntime.jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:C("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:t.label}),jsxRuntime.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsxRuntime.jsx(I,{name:Tt[t.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsxRuntime.jsx("span",{className:"truncate",children:e?"This page":rl(t.url)}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsxRuntime.jsx("span",{className:"shrink-0",children:rr(t.createdAt)}),o?jsxRuntime.jsxs("span",{className:"ml-0.5 inline-flex shrink-0 items-center gap-1 rounded-full bg-black/[0.05] px-1.5 py-px text-[10px] font-medium text-popover-foreground/55",children:[jsxRuntime.jsx(I,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var ol="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",il={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Vt({initials:t,tint:e,src:r,generatedSeed:n,alt:o="",size:s="md",className:i,style:a}){let{url:l,seed:c}=Ye(r),d=c??n;return jsxRuntime.jsxs("span",{className:C(ol,il[s],i),style:{background:e,...a},children:[jsxRuntime.jsx("span",{children:t}),!l&&d?jsxRuntime.jsx(Qe,{seed:d}):null,l?jsxRuntime.jsx("img",{src:l,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:u=>{u.currentTarget.remove();}}):null]})}var sl="M48 0C67.8823 0 84 16.1178 84 36V63C84 67.9706 79.9706 72 75 72H48C42.2522 72 36.8201 70.6505 32 68.2549V87C32 91.9706 27.9706 96 23 96H14C12.8954 96 12 95.1046 12 94V36C12 16.1178 28.1178 0 48 0ZM48 18C38.0589 18 30 26.0589 30 36C30 45.9411 38.0589 54 48 54C57.9411 54 66 45.9411 66 36C66 26.0589 57.9411 18 48 18Z",ll="M12 2A10 10 0 0 1 22 12V20.6A1.4 1.4 0 0 1 20.6 22H12A10 10 0 0 1 2 12A10 10 0 0 1 12 2Z";function Ie({size:t=16,className:e}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:e,children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:sl})})}function So({size:t=16,variant:e="filled",stroke:r=2,className:n}){let o=e==="outline";return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:o?"none":"currentColor",stroke:o?"currentColor":"none",strokeWidth:o?r:void 0,strokeLinejoin:o?"round":void 0,strokeLinecap:o?"round":void 0,"aria-hidden":"true",focusable:"false",className:n,children:jsxRuntime.jsx("path",{d:ll})})}var _r=false,Kt=null,ir=null,Et={openDelay:700,isInstant(){return _r},onOpen(t){ir&&ir!==t&&ir(),ir=t??null,_r=true,Kt&&(clearTimeout(Kt),Kt=null);},onClose(){Kt&&clearTimeout(Kt),Kt=setTimeout(()=>{_r=false,Kt=null;},300);}};var Ro="easeOut";function ot({text:t,children:e,className:r,tone:n="default",placement:o="top"}){let[s,i]=react.useState(false),[a,l]=react.useState(false),c=react.useRef(null),d=react.useRef(false);react.useEffect(()=>()=>{c.current&&clearTimeout(c.current),d.current&&Et.onClose();},[]);let u=x=>{l(x),i(true),d.current=true,Et.onOpen();},p=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),Et.isInstant()){u(true);return}c.current=setTimeout(()=>{c.current=null,u(false);},Et.openDelay);},m=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,Et.onClose()),i(false);},v=n==="warning"?"pointer-events-none absolute bottom-[calc(100%+8px)] left-0 z-[1]":o==="bottom"?"pointer-events-none absolute top-[calc(100%+8px)] left-1/2 z-[1] -translate-x-1/2":"pointer-events-none absolute -top-[38px] left-1/2 z-[1] -translate-x-1/2",f="shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45),0_3px_8px_-3px_rgba(0,0,0,0.3)] ring-1 ring-white/10",b=n==="warning"?`relative flex w-[200px] items-start gap-1.5 rounded-lg bg-foreground px-3 py-2.5 text-left text-[11px] leading-[1.35] font-medium text-white ${f}`:`relative block whitespace-nowrap rounded-md bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${f}`,h=n==="warning"?"absolute -bottom-1 left-6 size-2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground":o==="bottom"?"absolute -top-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-l border-t border-white/10 bg-foreground":"absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground",y=o==="bottom"&&n!=="warning"?-3:3,T=o==="bottom"&&n!=="warning"?-2:2;return jsxRuntime.jsxs("span",{className:C("relative inline-flex items-center justify-center",r),onMouseEnter:p,onMouseLeave:m,onMouseDown:m,children:[jsxRuntime.jsx("span",{className:v,children:jsxRuntime.jsx(react$1.AnimatePresence,{children:s&&jsxRuntime.jsxs(react$1.motion.span,{initial:a?false:{opacity:0,y,scale:.98},animate:{opacity:1,y:0,scale:1,transition:a?{duration:0}:{duration:.1,ease:Ro}},exit:{opacity:0,y:T,scale:.98,transition:{duration:.08,ease:Ro}},className:b,children:[n==="warning"?jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsxRuntime.jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsxRuntime.jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsxRuntime.jsx("span",{className:"min-w-0 flex-1",children:t}),jsxRuntime.jsx("span",{className:h})]})})}),e]})}var Io=44,Lt=[.16,1,.3,1],No="easeOut",ml=.08,gl=60,fl="calc(100% - 64px) calc(100% + 4px)",me="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function Mo(){let t=oo(),e=ft(),r=rt(),n=ae(),{dockOpen:o,hideResolvedAnnotations:s,setDockOpen:i,setHideResolvedAnnotations:a}=Bt(),l=!!r.studio,c=n.unresolvedCount,[d,u]=react.useState(false),[p,m]=react.useState(false),[v,f]=react.useState(false),[b,h]=react.useState(false),[y,T]=react.useState(false),[x,z]=react.useState(false),O=react.useRef(null),g=react.useRef(null),N=react.useRef(false),[U,at]=react.useState(false),pt=react.useRef(null),[vt,st]=react.useState(Io);react.useLayoutEffect(()=>{let $=pt.current;if(!$)return;let lt=()=>st($.offsetWidth);lt();let Ct=new ResizeObserver(lt);return Ct.observe($),()=>Ct.disconnect()},[]);let Q=r.studio?r.studio.name:r.identity?.name??null,X=se(Q),k=r.studio?.image??null,R=r.identity?.avatarSeed??r.clientAvatarSeed,M=r.studio?.userId??R,A=r.studio?"var(--color-foreground)":le(R),H=r.studio&&!k?"#FFFFFF":A,F=r.studio&&!k?"text-foreground":"text-white",E=Tt[r.activeViewport];function tt(){O.current!==null&&(window.clearTimeout(O.current),O.current=null);}function xt(){g.current!==null&&(window.clearTimeout(g.current),g.current=null);}let P=react.useRef(()=>{});P.current=()=>{!N.current&&O.current===null||(tt(),xt(),N.current=false,z(true));};let L=react.useRef(()=>P.current()).current;react.useEffect(()=>{x&&d&&u(false);},[x,d]);function W($){m(false),f(false),h(false),tt(),xt(),N.current=true,z(false),T($),Et.onOpen(L),u(true);}function j(){W(false);}function Pt(){if(tt(),!(N.current||g.current!==null)){if(Et.isInstant()){W(true);return}g.current=window.setTimeout(()=>{g.current=null,W(false);},Et.openDelay);}}function wt(){xt(),tt(),N.current&&(N.current=false,Et.onClose()),O.current=window.setTimeout(()=>{u(false),O.current=null;},120);}function Ut(){at(true),i(true);}function ze(){m(false),f(false),h(false),xt(),N.current=false,u(false),t.isCapturing?t.exit():t.enter();}function He(){m(false),f(false),xt(),N.current=false,u(false),h($=>{let lt=!$;return lt&&n.refresh(),lt});}function Fe(){at(true),i(false),m(false),f(false),h(false),xt(),N.current=false,u(false),t.exit(),e.active&&e.forceClose();}react.useEffect(()=>()=>{O.current!==null&&window.clearTimeout(O.current),g.current!==null&&window.clearTimeout(g.current);},[]);let gr=()=>{r.signOut(),u(false);};function S(){f(false),h(false),xt(),N.current=false,u(false),m($=>!$);}function D($){m(false),r.activeViewport!==$&&(e.active&&e.forceClose(),r.setActiveViewport($));}function _(){m(false),h(false),xt(),N.current=false,u(false),f($=>!$);}function V(){a(!s);}function B($){let lt=$.relatedTarget;lt instanceof Node&&$.currentTarget.contains(lt)||wt();}return jsxRuntime.jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxRuntime.jsxs(react$1.motion.div,{initial:false,animate:{width:o?vt:Io},transition:{duration:.36,ease:Lt},onAnimationComplete:()=>at(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Lt}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Lt}},"data-patch-fab-dock":"",className:C("pkey-fab relative h-11 rounded-full",U?"overflow-hidden":"overflow-visible"),children:[jsxRuntime.jsx(react$1.motion.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Lt},className:C("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsxRuntime.jsx("button",{type:"button",onClick:Ut,"data-patch-fab-dock":"","aria-label":l&&c>0?`Leave feedback \u2014 ${c} open`:"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsxRuntime.jsx(Ie,{size:18})})}),jsxRuntime.jsxs("div",{ref:pt,"data-patch-fab-dock":"",className:C("absolute inset-y-0 left-0 flex w-max items-center gap-1.5 px-1.5",o?"pointer-events-auto":"pointer-events-none"),children:[jsxRuntime.jsx(ge,{visible:o,index:0,children:jsxRuntime.jsx(ot,{text:t.isCapturing?"Stop commenting":"Add comment",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":t.isCapturing?"Stop commenting":"Add comment","aria-pressed":t.isCapturing,onClick:ze,className:C(me,"transition-colors",t.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(So,{variant:"outline",size:16})})})}),l?jsxRuntime.jsx(ge,{visible:o,index:1,children:jsxRuntime.jsx(ot,{text:"Feedback",children:jsxRuntime.jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-btn":"","aria-label":c>0?`Feedback \u2014 ${c} open`:"Feedback","aria-expanded":b,onClick:He,className:C(me,"relative transition-colors",b||c>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsxRuntime.jsx(I,{name:"list",size:15}),c>0?jsxRuntime.jsx("span",{className:"pointer-events-none absolute -top-0.5 -right-0.5 grid h-[15px] min-w-[15px] place-items-center rounded-full bg-brand px-1 text-[9px] font-semibold text-white",children:c>99?"99+":c}):null]})})}):null,jsxRuntime.jsx(ge,{visible:o,index:2,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${E.label}`,"aria-expanded":p,onClick:S,className:C(me,"transition-colors",r.activeViewport==="desktop"&&!p?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsxRuntime.jsx(I,{name:E.glyph,size:15})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:p?jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Lt}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Lt}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsxRuntime.jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),Qr.map($=>{let lt=Tt[$],Ct=r.activeViewport===$;return jsxRuntime.jsx(ot,{text:Qt($),children:jsxRuntime.jsx("button",{type:"button","data-patch-viewport-option":$,"aria-label":Qt($),"aria-pressed":Ct,onClick:()=>D($),className:C("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",Ct?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(I,{name:lt.glyph,size:15})})},$)})]}):null})]})}),jsxRuntime.jsx(ge,{visible:o,index:3,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx(ot,{text:"Settings",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":v,onClick:_,className:C(me,"transition-colors",v||s?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(I,{name:"settings",size:15})})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:v?jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Lt}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Lt}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-xl p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsxRuntime.jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxRuntime.jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:s,"aria-label":"Hide resolved annotations",onChange:V,className:"peer sr-only"}),jsxRuntime.jsx("span",{"aria-hidden":"true",className:C("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",s?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsxRuntime.jsx(I,{name:"check",size:10,stroke:2.4})}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsxRuntime.jsx(ge,{visible:o,index:4,children:jsxRuntime.jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Pt,onMouseLeave:wt,onFocus:j,onBlur:B,children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":Q?`Account: ${Q}`:"Identify",className:C(me,"text-white"),children:Q?jsxRuntime.jsx(Vt,{initials:X,tint:H,src:k,generatedSeed:M,alt:Q,size:"sm",className:C("size-[22px] text-[9.5px] ring-1 ring-white/20",F)}):jsxRuntime.jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:d?jsxRuntime.jsxs(react$1.motion.div,{initial:y?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:y?{duration:0}:{duration:.12,delay:ml,ease:No}},exit:{opacity:0,y:2,scale:.98,transition:x?{duration:0}:{duration:.08,ease:No}},"data-patch-fab-dock":"","data-patch-identity-popover":"",className:"fixed right-8 bottom-[72px] z-[2147483647] w-[min(272px,calc(100vw-40px))] min-w-[220px] rounded-xl bg-foreground p-3.5 font-sans text-[13px] text-white shadow-[0_18px_44px_-14px_rgba(0,0,0,0.5),0_6px_14px_-6px_rgba(0,0,0,0.45)] ring-1 ring-white/10",style:{transformOrigin:fl},children:[jsxRuntime.jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:gl}}),r.studio?jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(Vt,{initials:X,tint:A,src:k,generatedSeed:M,alt:r.studio.name,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(Vt,{initials:X,tint:A,generatedSeed:M,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsxRuntime.jsx("div",{className:"my-3 h-px bg-white/10"}),jsxRuntime.jsx("button",{type:"button",onClick:gr,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsxRuntime.jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsxRuntime.jsx(ge,{visible:o,index:5,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsxRuntime.jsx(ot,{text:"Close",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:Fe,className:C(me,"text-white/70"),children:jsxRuntime.jsx(I,{name:"x",size:14})})})]})})]})]}),l&&!o&&c>0?jsxRuntime.jsx("span",{"data-patch-fab-dock":"","data-patch-roster-badge":"","aria-hidden":"true",className:"pointer-events-none absolute -top-1 -right-1 grid h-[18px] min-w-[18px] place-items-center rounded-full bg-brand px-1 text-[10.5px] font-semibold text-white shadow-[0_1px_3px_rgba(0,0,0,0.3)]",children:c>99?"99+":c}):null,jsxRuntime.jsx(react$1.AnimatePresence,{children:b?jsxRuntime.jsx(Ao,{onClose:()=>h(false)}):null})]})}function ge({children:t,visible:e,index:r}){return jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0,x:6},animate:e?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Lt}}:{opacity:0,x:6,transition:{duration:.12,ease:Lt}},children:t})}function _o(t,e){return e.width<=0||e.height<=0?{fx:0,fy:0}:{fx:(t.viewportX-e.x)/e.width,fy:(t.viewportY-e.y)/e.height}}function Lo(t,e){return {viewportX:e.x+t.fx*e.width,viewportY:e.y+t.fy*e.height}}var bl=.6,vl=.5,sr={text:.4,attrs:.3,classes:.2,position:.1},xl=5e3,wl=.08,yl=.12;function kl(t,e){return e===void 0||e===""?.5:t===e?1:t&&(t.includes(e)||e.includes(t))?.5:0}function Cl(t,e){if(!e)return .5;let r=Object.keys(e);if(r.length===0)return .5;let n=0;for(let o of r)t[o]===e[o]&&n++;return n/r.length}function Al(t,e){let r=new Set(t),n=new Set(e??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let i of r)n.has(i)&&o++;let s=r.size+n.size-o;return s===0?0:o/s}function Oo(t){let e=t.payload.boundingBox;if(!e)return null;let r=t.payload.coordinates.documentY-t.payload.coordinates.viewportY;return {x:e.x+e.width/2,y:e.y+e.height/2+r}}function Dr(t,e,r){if(!e)return .5;let n=t.left+t.width/2,o=t.top+r.scrollY+t.height/2,s=(n-e.x)/Math.max(1,r.viewport.width),i=(o-e.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(s*s+i*i))}function Sl(t,e){let r=qe(t),n=Ke(t),o=Ae(t),s=t.getBoundingClientRect(),i=kl(r,e.payload.domHints?.textSignature),a=Cl(n,e.payload.domHints?.attributeSignature),l=Al(o,e.payload.cssClasses),c=Dr(s,Oo(e),e);return sr.text*i+sr.attrs*a+sr.classes*l+sr.position*c}function Tl(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Do(t,e,r){let n=null,o=null,s=0;for(let i=0;i<t.length&&!(s>=xl);i++){let a=t[i];if(!a||(s++,Kn(a,e.internalAttr)))continue;let l=a.tagName.toLowerCase();if(l==="html"||l==="head"||l==="script"||l==="style"||Tl(a))continue;let c=Sl(a,e);!n||c>n.score?(o=n,n={el:a,score:c}):(!o||c>o.score)&&(o={el:a,score:c});}if(!n||n.score<r)return null;if(o&&n.score-o.score<wl){let i=Oo(e),a=Dr(n.el.getBoundingClientRect(),i,e),l=Dr(o.el.getBoundingClientRect(),i,e);if(a-l<yl)return null}return n.el}function El(t){return {viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.documentY-t.scrollY}}function Rl(t,e){let r=t.getBoundingClientRect();if(!e.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=_o({viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.viewportY},e.payload.boundingBox);return Lo(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Pl(t){let e=t.payload.domHints?.cssSelector;if(!e)return [];try{return Array.from(t.doc.querySelectorAll(e))}catch{return []}}function lr(t){if(!t.payload.domHints)return {kind:"detached",el:null};let e=Pl(t);if(e.length>0){let n=Do(e,t,vl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Do(t.doc.querySelectorAll("*"),t,bl);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function Or(t,e){return t.kind==="anchored"&&t.el?Rl(t.el,e):El(e)}function zo(t){let e=lr(t);return {kind:e.kind,tier:e.tier,el:e.el,position:Or(e,t)}}function Ho(t){if(t.status==="resolved")return null;let e=t.latestRun;return e?e.status==="failed"?"patch-failed":e.status!=="succeeded"?null:e.prClosedUnmerged?"rerun-after-closed":e.prUrl?"review-pr":null:null}var Nl="data-patch-internal";function cr(t,e,r){let n=ce(r,e.getOverlayViewport()),o=er(r,n);t.style.top=`${o.y}px`,t.style.left=`${o.x}px`;}function Bo(t,e){return Math.abs(t.viewportX-e.viewportX)<.5&&Math.abs(t.viewportY-e.viewportY)<.5}function Ml(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Fr(t,e){return {payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Nl}}function Vo(t,e,r){let n=Fr(t,e);return {kind:r.kind,position:t.targetPointToOverlay(Or(r,n))}}function _l(t,e){return t.targetPointToOverlay({viewportX:e.viewportX,viewportY:e.documentY-t.getTargetScrollY()})}function Wo(){let{annotations:t,annotationsReady:e,ephemerals:r,identity:n,studio:o,clientAvatarSeed:s,apiClient:i}=rt(),a=ft(),{dockOpen:l,hideResolvedAnnotations:c}=Bt(),d=mt(),{isPreviewing:u,previewReady:p}=ne(),m=react$1.useReducedMotion(),v=a.active,f=a.forceClose,b=e&&(!u||p),h=react.useMemo(()=>l&&e?t.filter(k=>!c||k.status!=="resolved"):[],[l,e,t,c]),y=react.useMemo(()=>l&&e?r:[],[l,e,r]);react.useEffect(()=>{if(!c||v?.kind!=="existing")return;t.find(R=>R.id===v.annotationId)?.status==="resolved"&&f();},[v,t,f,c]);let T=react.useRef(new Map),x=react.useRef(new Map),z=react.useRef(new Map),O=react.useRef(new Map),g=react.useMemo(()=>{let k=O.current,R=new Set,M=new Map;for(let A of h){R.add(A.id);let H=k.get(A.id),E=H?.kind==="anchored"&&H.el?.isConnected?H:lr(Fr(d,A));k.set(A.id,E),M.set(A.id,Vo(d,A,E));}for(let A of k.keys())R.has(A)||k.delete(A);return M},[d,h]),N=react.useCallback(()=>{let k=O.current,R=z.current,M=new Set;for(let A of h){let H=T.current.get(A.id);if(!H)continue;M.add(A.id);let F=k.get(A.id);if((!F||F.kind==="anchored"&&F.el&&!F.el.isConnected)&&(F=lr(Fr(d,A)),k.set(A.id,F)),F.kind==="detached"||F.kind==="anchored"&&F.el&&Ml(F.el)){H.style.visibility!=="hidden"&&(H.style.visibility="hidden"),R.delete(A.id);continue}H.style.visibility==="hidden"&&(H.style.visibility="");let E=Vo(d,A,F).position,tt=R.get(A.id);tt&&Bo(tt,E)||(R.set(A.id,E),cr(H,d,E));}for(let A of y){let H=x.current.get(A.tempId);if(!H)continue;M.add(A.tempId);let F=_l(d,A),E=R.get(A.tempId);E&&Bo(E,F)||(R.set(A.tempId,F),cr(H,d,F));}for(let A of R.keys())M.has(A)||R.delete(A);},[d,h,y]),U=h.length>0||y.length>0;react.useEffect(()=>{if(!U)return;let k=d.overlayWindow,R=k.requestAnimationFrame(function M(){N(),R=k.requestAnimationFrame(M);});return ()=>k.cancelAnimationFrame(R)},[U,N,d]);let at=react.useRef(new Map);react.useEffect(()=>{if(!e||h.length===0)return;let k=setTimeout(()=>{let R=[];for(let M of h){let A=g.get(M.id);if(!A)continue;let H=A.kind!=="detached";at.current.get(M.id)!==H&&(at.current.set(M.id,H),R.push({id:M.id,present:H}));}i.reportAnchorStatuses(R);},1500);return ()=>clearTimeout(k)},[g,h,e,i]);let pt=react.useCallback(k=>{if(a.active&&a.hasDraft){a.attemptClose();return}a.openExisting(k);},[a]),vt=o?o.name:n?.name??null,st=o?.image??null,Q=n?.avatarSeed??s,X=o?.userId??Q;return jsxRuntime.jsxs("div",{"data-patch-pin-layer":"",style:{opacity:b?1:0,transition:m||!b?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:b?void 0:"none"},children:[jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:h.map(k=>{let R=g.get(k.id);if(R?.kind==="detached")return null;let M=Ll(k),A=!o&&!!n?.clientUserId&&k.payload.authorRole==="client"&&k.payload.authorId===n.clientUserId,H=o?Ho(k):null,F=R?ce(R.position,d.getOverlayViewport()):"right";return jsxRuntime.jsx(Nr,{ref:E=>{E?(T.current.set(k.id,E),R&&cr(E,d,R.position)):T.current.delete(k.id);},avatarSrc:M.image,generatedSeed:A?Q:M.generatedSeed,avatarAlt:M.name??"",resolved:k.status==="resolved",attention:H,pointSide:F,ariaLabel:`Annotation by ${k.authorName??"someone"}`,onClick:()=>pt(k.id),pinId:k.id},k.id)})}),jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:y.map(k=>{let R=d.targetPointToOverlay({viewportX:k.viewportX,viewportY:k.viewportY});return jsxRuntime.jsx(Nr,{ref:M=>{M?(x.current.set(k.tempId,M),cr(M,d,R)):x.current.delete(k.tempId);},avatarSrc:st,generatedSeed:X,avatarAlt:vt??"",resolved:false,pointSide:ce(R,d.getOverlayViewport()),ephemeral:true},k.tempId)})})]})}function Ll(t){let e=t.authorAvatarSeed??t.payload.authorId??(t.authorName?`annotation-author:${t.authorName}`:null);if(t.authorImage||e||t.authorName)return {name:t.authorName,image:t.authorImage??null,generatedSeed:e??t.id,key:t.payload.authorId??t.authorName??t.id};let r=t.thread.find(n=>n.authorImage||n.authorId||n.authorName);if(r){let n=r.authorAvatarSeed??r.authorId??(r.authorName?`thread-author:${r.authorName}`:null);return {name:r.authorName,image:r.authorImage??null,generatedSeed:n??t.id,key:r.authorId??r.authorName??t.id}}return {name:t.authorName,image:t.authorImage??null,generatedSeed:t.id,key:t.id}}var Fl=5e3;function Yo(){let t=ae(),e=rt(),r=ft(),n=Bt(),o=mt(),s=react$1.useReducedMotion(),i=t.pendingFocus,a=react.useRef(null),l=react.useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return react.useEffect(()=>{if(!i)return;if(ct(window.location.href)!==ct(i.url)){t.clearFocus();return}if(n.dockOpen||n.setDockOpen(true),e.activeViewport!==i.viewport){e.setActiveViewport(i.viewport);return}if(!e.annotationsReady)return;let c=e.annotations.find(u=>u.id===i.id);if(!c){a.current===null&&(a.current=window.setTimeout(()=>{a.current=null,t.clearFocus();},Fl));return}l();let d=c.payload.coordinates?.documentY;if(typeof d=="number"){let u=o.getTargetViewport().height;o.targetWindow.scrollTo({top:Math.max(0,d-u/3),behavior:s?"auto":"smooth"});}r.openExisting(i.id),t.clearFocus();},[i,e,n,o,s,r,t,l]),react.useEffect(()=>()=>l(),[l]),null}function $l(){for(let t of [document.body,document.documentElement]){let e=window.getComputedStyle(t).backgroundColor;if(e&&e!=="transparent"&&e!=="rgba(0, 0, 0, 0)")return e}return "#ffffff"}async function Go(t){try{let{snapdom:e}=await import('@zumer/snapdom'),r=Math.min(window.devicePixelRatio||1,2),n=await e.toCanvas(document.body,{dpr:r,exclude:["[data-patch-internal]"],embedFonts:!0}),o=document.body.getBoundingClientRect(),s=n.width/Math.max(1,o.width),i=document.createElement("canvas");i.width=Math.max(1,Math.round(t.width*r)),i.height=Math.max(1,Math.round(t.height*r));let a=i.getContext("2d");return a?(a.fillStyle=$l(),a.fillRect(0,0,i.width,i.height),a.drawImage(n,(t.x-o.left)*s,(t.y-o.top)*s,t.width*s,t.height*s,0,0,i.width,i.height),await new Promise(l=>i.toBlob(l,"image/webp",.92))):null}catch{return null}}var Wl='<svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 34 34"><g stroke="#fff" stroke-width="3.5" stroke-linecap="round"><path d="M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21"/></g><g stroke="#1F1F1F" stroke-width="1.5" stroke-linecap="round"><path d="M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21"/></g><g><rect x="20" y="22" width="13" height="10" rx="2.5" fill="#1F1F1F" stroke="#fff"/><circle cx="26.5" cy="27" r="2.6" fill="none" stroke="#fff" stroke-width="1.4"/></g></svg>',Ul=`url("data:image/svg+xml,${encodeURIComponent(Wl)}") 12 12, crosshair`,Br=4;function qo(t,e){return {x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function jo({capturing:t,onSelect:e,onCancel:r}){let n=react$1.useReducedMotion(),[o,s]=react.useState(null),[i,a]=react.useState(null),[l,c]=react.useState(null);react.useEffect(()=>{let f=b=>{b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),t||r());};return document.addEventListener("keydown",f,true),()=>document.removeEventListener("keydown",f,true)},[t,r]);let d=react.useCallback(f=>({x:Math.min(Math.max(f.x,0),window.innerWidth),y:Math.min(Math.max(f.y,0),window.innerHeight)}),[]),u=react.useCallback((f,b)=>{let h=qo(f,b);s(null),a(null),!(h.width<Br||h.height<Br)&&(c(h),e(h));},[e]);react.useEffect(()=>{if(!o)return;let f=h=>{a(d({x:h.clientX,y:h.clientY}));},b=h=>{u(o,d({x:h.clientX,y:h.clientY}));};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",b);}},[o,d,u]);let p=l??(o&&i?qo(o,i):null),m=!!p&&p.width>=Br/2,v=p?p.y+p.height+30<window.innerHeight:true;return jsxRuntime.jsxs("div",{"data-patch-screenshot-overlay":"",role:"dialog","aria-label":"Capture a screenshot",className:"fixed inset-0 z-[2147483647] select-none",style:{cursor:t?"progress":Ul},onMouseDown:f=>{if(f.button!==0||t)return;f.preventDefault();let b=d({x:f.clientX,y:f.clientY});s(b),a(b);},children:[m&&p?jsxRuntime.jsx("div",{className:"pointer-events-none absolute rounded-[3px] border-[1.5px] border-brand bg-brand/10 shadow-[0_0_0_1px_rgba(255,255,255,0.55)]",style:{left:p.x,top:p.y,width:p.width,height:p.height},children:jsxRuntime.jsx("span",{className:C("absolute right-0 whitespace-nowrap rounded-md bg-foreground px-2 py-1 font-sans text-[11px] font-medium tabular-nums text-white shadow-[0_3px_8px_-3px_rgba(0,0,0,0.3)]",v?"top-[calc(100%+6px)]":"bottom-[calc(100%+6px)]"),children:t?jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"size-2.5 animate-spin rounded-full border border-white/40 border-t-white"}),"Capturing\u2026"]}):`${Math.round(p.width)} \xD7 ${Math.round(p.height)}`})}):null,!o&&!t?jsxRuntime.jsxs(react$1.motion.div,{initial:n?false:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{duration:.15,ease:"easeOut"}},className:"pointer-events-none absolute top-4 left-1/2 -translate-x-1/2 rounded-full bg-foreground/90 px-3.5 py-2 font-sans text-[12px] font-medium text-white shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45)]",children:["Drag to capture",jsxRuntime.jsx("span",{className:"mx-2 opacity-40",children:"\xB7"}),jsxRuntime.jsx("kbd",{className:"rounded bg-white/16 px-1.5 py-0.5 font-sans text-[11px]",children:"Esc"}),jsxRuntime.jsx("span",{className:"ml-1.5 opacity-70",children:"to cancel"})]}):null]})}var Qo=react.createContext(null);function ti({children:t}){let e=ft(),[r,n]=react.useState("idle"),o=react.useRef(null),s=react.useRef(false);s.current=r!=="idle";let i=react.useCallback(()=>{o.current=null,n("idle");},[]),a=e.active!==null;react.useEffect(()=>{!a&&s.current&&i();},[a,i]);let l=react.useCallback(async u=>{s.current||(o.current=u,n("select"));},[]),c=react.useCallback(async u=>{n("capturing");let p=await Go(u),m=o.current;i(),p&&m&&m(p);},[i]),d=react.useMemo(()=>({supported:true,active:r!=="idle",begin:l}),[r,l]);return jsxRuntime.jsxs(Qo.Provider,{value:d,children:[jsxRuntime.jsx("div",{style:r==="idle"?{transition:"opacity 150ms ease-out"}:{opacity:0,pointerEvents:"none",transition:"opacity 150ms ease-out"},children:t}),r!=="idle"?jsxRuntime.jsx(jo,{capturing:r==="capturing",onSelect:u=>{c(u);},onCancel:i}):null]})}var jl={supported:false,active:false,begin:async()=>{}};function ei(){return react.use(Qo)??jl}var ri=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
4
+ `)}function Es(t,e){let r=t.targetDocument,n=r.getElementById(Qn);n&&n.remove();let o=r.createElement("style");return o.id=Qn,o.setAttribute(e,""),o.textContent=Ts(e),r.head.appendChild(o),o}function Er(t,e,r){let n=t.eventTargetElement(e);return n?n.closest(`[${r}]`)!==null:false}var ie=1.5,Rs="#0287FE",Ps="rgba(2, 135, 254, 0.032)";function Is(t){let e=t.split(" ")[0]??"",r=Number.parseFloat(e);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Ns(t,e){let r=t.targetDocument,n=r.createElement("div");n.setAttribute(e,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${ie}px solid ${Rs}`,background:Ps,boxSizing:"border-box",zIndex:"2147483645",display:"none",borderRadius:"6px",transition:"top 80ms ease-out, left 80ms ease-out, width 80ms ease-out, height 80ms ease-out, border-radius 80ms ease-out"});let o=r.createElement("div");o.setAttribute(e,""),Object.assign(o.style,{position:"fixed",pointerEvents:"none",background:"#111",color:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"12px",fontWeight:"500",padding:"6px 10px",borderRadius:"6px",zIndex:"2147483646",maxWidth:"240px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"none",boxShadow:"0 10px 24px -12px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.08)"}),r.body.appendChild(n),r.body.appendChild(o);let s=null;return {update(i){let a=i.getBoundingClientRect();if(a.width===0&&a.height===0){this.hide();return}n.style.display="block",n.style.top=`${a.top-ie}px`,n.style.left=`${a.left-ie}px`,n.style.width=`${a.width+ie*2}px`,n.style.height=`${a.height+ie*2}px`,n.style.borderRadius=`${Is(t.targetWindow.getComputedStyle(i).borderRadius)+ie}px`,i!==s&&(o.textContent=Se(i),s=i),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),d=t.getTargetViewport().width-8;l+240<=d?(o.style.left=`${l}px`,o.style.top=`${c}px`):(o.style.left=`${Math.max(8,a.right-240)}px`,o.style.top=`${Math.max(8,a.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function to(t){let{internalAttr:e,onClick:r,surface:n}=t,o=n.targetDocument,s=Es(n,e),i=Ns(n,e),a=false,l=v=>{let f=v;if(Er(n,f.target,e))return;let b=n.eventTargetElement(f.target);b&&Wn(b)||(f.preventDefault(),f.stopPropagation());},c=l,d=l,u=v=>{let f=v;Er(n,f.target,e)||(f.preventDefault(),f.stopPropagation(),!a&&r(f));},p=v=>{let f=v;if(a)return;let b=n.eventTargetElement(f.target);if(!b){i.hide();return}if(Er(n,b,e)){i.hide();return}let h=b.tagName.toLowerCase();if(h==="html"||h==="body"){i.hide();return}i.update(b);},m=v=>{v.relatedTarget||i.hide();};return o.addEventListener("mousedown",c,true),o.addEventListener("mouseup",d,true),o.addEventListener("click",u,true),o.addEventListener("mousemove",p,true),o.addEventListener("mouseout",m,true),{exit(){s.remove(),i.destroy(),o.removeEventListener("mousedown",c,true),o.removeEventListener("mouseup",d,true),o.removeEventListener("click",u,true),o.removeEventListener("mousemove",p,true),o.removeEventListener("mouseout",m,true);},pause(){a=true,i.hide();},resume(){a=false;}}}function eo(t){let{clickTarget:e,selection:r}=t,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),s=Kn(o.commonAncestorContainer);if(s)return {kind:"element",element:s,rect:s.getBoundingClientRect(),selectedText:n,clickTarget:e}}return {kind:"element",element:e,rect:e.getBoundingClientRect(),clickTarget:e}}var Os="data-patch-internal",no=react.createContext(null),ro=0;function zs(){return ro+=1,`tmp-${Date.now().toString(36)}-${ro}`}function oo({children:t}){let e=ft(),r=rt(),n=mt(),{isPreviewing:o,previewReady:s}=ne(),[i,a]=react.useState(false),l=react.useRef(null),c=react.useRef(e),d=react.useRef(r);c.current=e,d.current=r;let u=react.useCallback(h=>{let y=c.current;if(y.active&&y.hasDraft){y.attemptClose();return}let T=n.eventTargetElement(h.target)??n.targetDocument.body,x=n.targetWindow.getSelection(),z=eo({clickTarget:T,selection:x}),D=zs(),g={viewportX:h.clientX,viewportY:h.clientY,documentY:h.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:D,viewportX:g.viewportX,viewportY:g.viewportY,documentY:g.documentY}),c.current.openComposer({tempId:D,target:z,anchor:g}),l.current?.pause();},[n]),p=r.annotationsReady&&(!o||s);react.useEffect(()=>{if(!i||!p){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=to({internalAttr:Os,surface:n,onClick:u}),()=>{l.current?.exit(),l.current=null;}},[i,u,n,p]);let m=react.useCallback(()=>{i||a(true);},[i]),v=react.useCallback(()=>{a(false);},[]),f=react.useRef(null);react.useEffect(()=>{let h=f.current,y=e.active;h?.kind==="composer"&&y?.kind!=="composer"&&(d.current.removeEphemeral(h.tempId),l.current?.resume()),h?.kind==="composer"&&y?.kind==="composer"&&h.tempId!==y.tempId&&d.current.removeEphemeral(h.tempId),f.current=y;},[e.active]),react.useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let b=react.useMemo(()=>({isCapturing:i,enter:m,exit:v}),[i,m,v]);return jsxRuntime.jsx(no.Provider,{value:b,children:t})}function io(){let t=react.use(no);if(!t)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return t}var Bs="patch:focus-intent";function Mr(t){return `${Bs}:${t}`}function Vs(t){try{let e=window.sessionStorage.getItem(Mr(t));if(!e)return null;window.sessionStorage.removeItem(Mr(t));let r=JSON.parse(e);return typeof r.id!="string"||typeof r.url!="string"?null:{id:r.id,url:r.url,viewport:r.viewport??"desktop"}}catch{return null}}function Ws(t,e){try{window.sessionStorage.setItem(Mr(t),JSON.stringify(e));}catch{}}var lo=react.createContext(null);function Us(t){return t==="pending"||t==="acknowledged"}function co({projectToken:t,children:e}){let{apiClient:r,active:n,viewerKind:o,annotations:s}=rt(),i=o==="studio",[a,l]=react.useState([]),[c,d]=react.useState(false),[u,p]=react.useState(null),m=react.useRef(r);m.current=r;let v=react.useCallback(async()=>{if(!i){l([]),d(true);return}let g=await m.current.listRoster();l(g),d(true);},[i]);react.useEffect(()=>{if(!n||!i)return;let g=Vs(t);g&&ct(g.url)===ct(window.location.href)&&p(g),v();},[n,i,t,v]);let f=react.useMemo(()=>s.map(g=>`${g.id}:${g.status}`).sort().join(","),[s]),b=react.useRef(null);react.useEffect(()=>{if(!(!n||!i)){if(b.current===null){b.current=f;return}b.current!==f&&(b.current=f,v());}},[f,n,i,v]);let h=react.useCallback(g=>{let I={id:g.id,url:g.url,viewport:g.viewport};if(ct(g.url)===ct(window.location.href)){p(I);return}Ws(t,I),window.location.assign(g.url);},[t]),y=react.useCallback(()=>p(null),[]),T=react.useMemo(()=>{let g=new Map;for(let I of s)g.set(I.id,I.status);return g},[s]),x=react.useMemo(()=>a.map(g=>{let I=T.get(g.id);return I&&I!==g.status?{...g,status:I}:g}),[a,T]),z=react.useMemo(()=>x.filter(g=>Us(g.status)).length,[x]),D=react.useMemo(()=>({entries:x,ready:c,unresolvedCount:z,refresh:v,focusPin:h,pendingFocus:u,clearFocus:y}),[x,c,z,v,h,u,y]);return jsxRuntime.jsx(lo.Provider,{value:D,children:e})}function ae(){let t=react.use(lo);if(!t)throw new Error("useRosterStore must be used inside <RosterProvider>");return t}var po=react.createContext(null);function mo({children:t}){let[e,r]=react.useState(false),[n,o]=react.useState(false),s=react.useMemo(()=>({dockOpen:e,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[e,n]);return jsxRuntime.jsx(po.Provider,{value:s,children:t})}function Bt(){let t=react.use(po);if(!t)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return t}var go="[Patch] No project token found, widget disabled. Pass `projectToken` as a prop, or set NEXT_PUBLIC_PATCH_TOKEN (Next.js), VITE_PATCH_TOKEN (Vite / React Router), or PUBLIC_PATCH_TOKEN (Astro) in your env.";function fo(t){let e=t.prop?.trim();if(e)return e;let r=t.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=t.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=t.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();return o||null}function ho(){try{return typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) })>"u"?void 0:undefined}catch{return}}function bo(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var Je=class extends react.Component{state={failed:false};static getDerivedStateFromError(){return {failed:true}}componentDidCatch(e,r){console.error("[patch] widget crashed and was unmounted",e,r.componentStack);}render(){return this.state.failed?null:this.props.children}};function Ee(t){let e=t.gap??12,r=t.margin??16,n=Math.min(t.popover.width,Math.max(0,t.viewport.width-r*2)),o="right",s=t.anchor.x+t.anchor.width+e;s+n>t.viewport.width-r&&(o="left",s=t.anchor.x-n-e),s<r&&(s=r);let i=t.anchor.y;return i+t.popover.height>t.viewport.height-r&&(i=t.viewport.height-r-t.popover.height),i<r&&(i=r),{x:s,y:i,width:n,placement:o}}function C(...t){return t.filter(Boolean).join(" ")}function tr({seed:t,className:e,style:r}){let n=On(t),o=react.useId().replace(/[^a-zA-Z0-9_-]/g,""),s=`${n.id}-${o}`,i=`cav-blur-${s}`,a=`cav-grain-${s}`;return jsxRuntime.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:C("absolute inset-0 size-full! overflow-hidden rounded-full",e),style:r,children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsxRuntime.jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxRuntime.jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsxRuntime.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsxRuntime.jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxRuntime.jsxs("radialGradient",{id:`${s}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsxRuntime.jsx("rect",{width:"64",height:"64",fill:n.background}),jsxRuntime.jsx("g",{filter:`url(#${i})`,children:n.spots.map(l=>jsxRuntime.jsx("rect",{width:"64",height:"64",fill:`url(#${s}-${l.id})`},l.id))}),jsxRuntime.jsx("rect",{width:"64",height:"64",filter:`url(#${a})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var _t=32,vo=[.22,.61,.36,1],er=["var(--color-avatar-tint-1)","var(--color-avatar-tint-2)","var(--color-avatar-tint-3)","var(--color-avatar-tint-4)","var(--color-avatar-tint-5)"];function se(t){if(!t)return "?";let e=t.trim().split(/\s+/),r=e[0],n=e[e.length-1];if(!r||!n)return "?";if(e.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",s=n[0]??"";return (o+s).toUpperCase()||"?"}function le(t){if(!t)return er[0];let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return er[Math.abs(e)%er.length]??er[0]}var Qs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},tl={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function ce(t,e){let{placement:r}=Ee({anchor:{x:t.viewportX-_t/2,y:t.viewportY-_t/2,width:_t,height:_t},popover:{width:332,height:200},viewport:e});return r==="right"?"left":"right"}function rr(t,e){return {x:e==="left"?t.viewportX:t.viewportX-_t,y:t.viewportY-_t,width:_t,height:_t}}function _r({ref:t,...e}){let r=e.pointSide??"right",n=!e.resolved&&e.attention?el[e.attention]:null,{url:o,seed:s}=Ye(e.avatarSrc),i=s??e.generatedSeed,a=e.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",l=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsxRuntime.jsx(react$1.motion.button,{ref:t,type:"button",onClick:e.onClick,"aria-label":e.ariaLabel??"Open annotation","data-patch-ephemeral":e.ephemeral?"":void 0,"data-patch-pin-id":e.pinId,className:"patch-pin-button fixed z-[2147483645] border-0 bg-transparent p-0",style:{width:_t,height:_t},initial:e.ephemeral?{opacity:0,scale:.45}:false,animate:e.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:e.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:vo}}:{opacity:0,scale:.9,transition:{duration:.12,ease:vo}},children:jsxRuntime.jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:Qs[r]},children:[jsxRuntime.jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:tl[r],background:"var(--color-muted-foreground)"},children:[i?jsxRuntime.jsx(tr,{seed:i,style:{borderRadius:0,filter:a||"none"}}):null,o?jsxRuntime.jsx("img",{src:o,alt:e.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:a||"none"},onError:c=>{c.currentTarget.remove();}}):null]}),e.resolved&&jsxRuntime.jsx("span",{className:`absolute ${l} grid size-[14px] place-items-center rounded-full bg-brand-green text-[9px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsxRuntime.jsx("span",{"data-patch-attention":e.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[10px] rounded-full border-[1.5px] border-white ${n}`})]})})}var el={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function nr(t){let e=new Date(t).getTime(),r=Date.now()-e,n=Math.round(r/6e4);if(Number.isNaN(n))return "";if(n<1)return "just now";if(n<60)return `${n}m ago`;let o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function wo(t){let e=t.composedPath();for(let r of e)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function yo(t){let e=t.match(/\/pull\/(\d+)/);return e?`#${e[1]}`:"PR"}var ko={"arrow-up":[["path",{d:"M12 5.5V19"}],["path",{d:"M18 11C18 11 13.5811 5.00001 12 5C10.4188 4.99999 6 11 6 11"}]],camera:[["path",{d:"M12.6974 3.5H11.303C10.5884 3.5 10.2311 3.5 9.91067 3.612C9.71499 3.68039 9.53113 3.77879 9.36568 3.90367C9.09474 4.10816 8.89655 4.40544 8.50018 5L8.50017 5.00001C8.29717 5.30453 7.99794 5.75337 7.87867 5.87871C7.58314 6.18927 7.19563 6.39666 6.77329 6.47029C6.60284 6.5 6.41985 6.5 6.05387 6.5C5.07379 6.5 4.58376 6.5 4.18307 6.61342C3.18074 6.89716 2.39734 7.68055 2.1136 8.68289C2.00018 9.08357 2.00018 9.57361 2.00018 10.5537V14.5C2.00018 17.3284 2.00018 18.7426 2.87886 19.6213C3.75754 20.5 5.17176 20.5 8.00018 20.5H16.0002C18.8286 20.5 20.2428 20.5 21.1215 19.6213C22.0002 18.7426 22.0002 17.3284 22.0002 14.5V10.5537C22.0002 9.57361 22.0002 9.08357 21.8868 8.68289C21.603 7.68055 20.8196 6.89716 19.8173 6.61342C19.4166 6.5 18.9266 6.5 17.9465 6.5C17.5805 6.5 17.3975 6.5 17.2271 6.47029C16.8047 6.39666 16.4172 6.18927 16.1217 5.87871C16.0024 5.75336 15.7032 5.30451 15.5002 5C15.1038 4.40544 14.9056 4.10816 14.6347 3.90367C14.4692 3.77879 14.2854 3.68039 14.0897 3.612C13.7693 3.5 13.412 3.5 12.6974 3.5Z"}],["path",{d:"M16.0002 13C16.0002 15.2091 14.2093 17 12.0002 17C9.79104 17 8.00018 15.2091 8.00018 13C8.00018 10.7909 9.79104 9 12.0002 9C14.2093 9 16.0002 10.7909 16.0002 13Z"}],["path",{d:"M19.1252 9.5H19.0002M19.2502 9.5C19.2502 9.63807 19.1383 9.75 19.0002 9.75C18.8621 9.75 18.7502 9.63807 18.7502 9.5C18.7502 9.36193 18.8621 9.25 19.0002 9.25C19.1383 9.25 19.2502 9.36193 19.2502 9.5Z"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],"chevron-left":[["path",{d:"M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18"}]],"chevron-right":[["path",{d:"M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18"}]],copy:[["path",{d:"M9 15C9 12.1716 9 10.7574 9.87868 9.87868C10.7574 9 12.1716 9 15 9L16 9C18.8284 9 20.2426 9 21.1213 9.87868C22 10.7574 22 12.1716 22 15V16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H15C12.1716 22 10.7574 22 9.87868 21.1213C9 20.2426 9 18.8284 9 16L9 15Z"}],["path",{d:"M16.9999 9C16.9975 6.04291 16.9528 4.51121 16.092 3.46243C15.9258 3.25989 15.7401 3.07418 15.5376 2.90796C14.4312 2 12.7875 2 9.5 2C6.21252 2 4.56878 2 3.46243 2.90796C3.25989 3.07417 3.07418 3.25989 2.90796 3.46243C2 4.56878 2 6.21252 2 9.5C2 12.7875 2 14.4312 2.90796 15.5376C3.07417 15.7401 3.25989 15.9258 3.46243 16.092C4.51121 16.9528 6.04291 16.9975 9 16.9999"}]],cursor:[["path",{d:"M12.669 8.35811L17.6969 10.3256C20.5969 11.4604 22.0469 12.0277 21.9988 12.9278C21.9508 13.8278 20.4375 14.2405 17.4111 15.0659C16.5099 15.3117 16.0593 15.4346 15.7469 15.7469C15.4346 16.0593 15.3117 16.5099 15.0659 17.4111C14.2405 20.4375 13.8278 21.9508 12.9278 21.9988C12.0277 22.0469 11.4604 20.5969 10.3256 17.6969L8.35811 12.669C7.17004 9.63279 6.57601 8.1147 7.34535 7.34535C8.1147 6.57601 9.63279 7.17004 12.669 8.35811Z"}],["path",{d:"M9 4V2M5 5L3.5 3.5M4 9H2M5 13L3.5 14.5M14.5 3.5L13 5"}]],desktop:[["path",{d:"M14 21H16M14 21C13.1716 21 12.5 20.3284 12.5 19.5V17L12 17M14 21H10M10 21H8M10 21C10.8284 21 11.5 20.3284 11.5 19.5V17L12 17M12 17V21"}],["path",{d:"M16 3H8C5.17157 3 3.75736 3 2.87868 3.87868C2 4.75736 2 6.17157 2 9V11C2 13.8284 2 15.2426 2.87868 16.1213C3.75736 17 5.17157 17 8 17H16C18.8284 17 20.2426 17 21.1213 16.1213C22 15.2426 22 13.8284 22 11V9C22 6.17157 22 4.75736 21.1213 3.87868C20.2426 3 18.8284 3 16 3Z"}]],globe:[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12C8 18 12 22 12 22C12 22 16 18 16 12C16 6 12 2 12 2C12 2 8 6 8 12Z"}],["path",{d:"M21 15H3"}],["path",{d:"M21 9H3"}]],list:[["path",{d:"M8 5.5L20 5.5"}],["path",{d:"M8 12.5L20 12.5"}],["path",{d:"M8 19.5L20 19.5"}],["path",{d:"M4.375 5.5H4.25M4.5 5.5C4.5 5.63807 4.38807 5.75 4.25 5.75C4.11193 5.75 4 5.63807 4 5.5C4 5.36193 4.11193 5.25 4.25 5.25C4.38807 5.25 4.5 5.36193 4.5 5.5Z"}],["path",{d:"M4.375 12.5H4.25M4.5 12.5C4.5 12.6381 4.38807 12.75 4.25 12.75C4.11193 12.75 4 12.6381 4 12.5C4 12.3619 4.11193 12.25 4.25 12.25C4.38807 12.25 4.5 12.3619 4.5 12.5Z"}],["path",{d:"M4.375 19.5H4.25M4.5 19.5C4.5 19.6381 4.38807 19.75 4.25 19.75C4.11193 19.75 4 19.6381 4 19.5C4 19.3619 4.11193 19.25 4.25 19.25C4.38807 19.25 4.5 19.3619 4.5 19.5Z"}]],lock:[["path",{d:"M4.26781 18.8447C4.49269 20.515 5.87613 21.8235 7.55966 21.9009C8.97627 21.966 10.4153 22 12 22C13.5847 22 15.0237 21.966 16.4403 21.9009C18.1239 21.8235 19.5073 20.515 19.7322 18.8447C19.879 17.7547 20 16.6376 20 15.5C20 14.3624 19.879 13.2453 19.7322 12.1553C19.5073 10.485 18.1239 9.17649 16.4403 9.09909C15.0237 9.03397 13.5847 9 12 9C10.4153 9 8.97627 9.03397 7.55966 9.09909C5.87613 9.17649 4.49269 10.485 4.26781 12.1553C4.12104 13.2453 4 14.3624 4 15.5C4 16.6376 4.12104 17.7547 4.26781 18.8447Z"}],["path",{d:"M7.5 9V6.5C7.5 4.01472 9.51472 2 12 2C14.4853 2 16.5 4.01472 16.5 6.5V9"}],["path",{d:"M12.125 15.5H12M12.25 15.5C12.25 15.6381 12.1381 15.75 12 15.75C11.8619 15.75 11.75 15.6381 11.75 15.5C11.75 15.3619 11.8619 15.25 12 15.25C12.1381 15.25 12.25 15.3619 12.25 15.5Z"}]],mobile:[["path",{d:"M13.5 2H10.5C8.14298 2 6.96447 2 6.23223 2.73223C5.5 3.46447 5.5 4.64298 5.5 7V17C5.5 19.357 5.5 20.5355 6.23223 21.2678C6.96447 22 8.14298 22 10.5 22H13.5C15.857 22 17.0355 22 17.7678 21.2678C18.5 20.5355 18.5 19.357 18.5 17V7C18.5 4.64298 18.5 3.46447 17.7678 2.73223C17.0355 2 15.857 2 13.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],more:[["path",{d:"M12 12.002H12.5M19 12.002H19.5M5 12.002H5.5M12 13.002C12.5523 13.002 13 12.5542 13 12.002C13 11.4497 12.5523 11.002 12 11.002C11.4477 11.002 11 11.4497 11 12.002C11 12.5542 11.4477 13.002 12 13.002ZM19 13.002C19.5523 13.002 20 12.5542 20 12.002C20 11.4497 19.5523 11.002 19 11.002C18.4477 11.002 18 11.4497 18 12.002C18 12.5542 18.4477 13.002 19 13.002ZM5 13.002C5.55228 13.002 6 12.5542 6 12.002C6 11.4497 5.55228 11.002 5 11.002C4.44772 11.002 4 11.4497 4 12.002C4 12.5542 4.44772 13.002 5 13.002Z"}]],paperclip:[["path",{d:"M5.82338 12L4.27922 10.4558C2.57359 8.75022 2.57359 5.98485 4.27922 4.27922C5.98485 2.57359 8.75022 2.57359 10.4558 4.27922L19.7208 13.5442C21.4264 15.2498 21.4264 18.0152 19.7208 19.7208C18.0152 21.4264 15.2498 21.4264 13.5442 19.7208L10.0698 16.2464C9.00379 15.1804 9.00379 13.4521 10.0698 12.386C11.1358 11.32 12.8642 11.32 13.9302 12.386L15.8604 14.3162"}]],play:[["path",{d:"M18.8906 12.846C18.5371 14.189 16.8667 15.138 13.5257 17.0361C10.296 18.8709 8.6812 19.7884 7.37983 19.4196C6.8418 19.2671 6.35159 18.9776 5.95624 18.5787C5 17.6139 5 15.7426 5 12C5 8.2574 5 6.3861 5.95624 5.42132C6.35159 5.02245 6.8418 4.73288 7.37983 4.58042C8.6812 4.21165 10.296 5.12907 13.5257 6.96393C16.8667 8.86197 18.5371 9.811 18.8906 11.154C19.0365 11.7084 19.0365 12.2916 18.8906 12.846Z"}]],pr:[["path",{d:"M6 8L6 16"}],["path",{d:"M18 16V12C18 9.17156 18 7.75735 17.1213 6.87867C16.2426 5.99999 14.8284 5.99999 12 5.99999L11 5.99999M11 5.99999C11 5.29976 12.9943 3.99152 13.5 3.49999M11 5.99999C11 6.70022 12.9943 8.00846 13.5 8.49999"}],["circle",{cx:"6",cy:"18",r:"2"}],["circle",{cx:"6",cy:"6",r:"2"}],["circle",{cx:"18",cy:"18",r:"2"}]],refresh:[["path",{d:"M20.0092 2V5.13219C20.0092 5.42605 19.6418 5.55908 19.4537 5.33333C17.6226 3.2875 14.9617 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12"}]],robot:[["path",{d:"M19 16V14C19 11.1716 19 9.75736 18.1213 8.87868C17.2426 8 15.8284 8 13 8H11C8.17157 8 6.75736 8 5.87868 8.87868C5 9.75736 5 11.1716 5 14V16C5 18.8284 5 20.2426 5.87868 21.1213C6.75736 22 8.17157 22 11 22H13C15.8284 22 17.2426 22 18.1213 21.1213C19 20.2426 19 18.8284 19 16Z"}],["path",{d:"M19 18C20.4142 18 21.1213 18 21.5607 17.5607C22 17.1213 22 16.4142 22 15C22 13.5858 22 12.8787 21.5607 12.4393C21.1213 12 20.4142 12 19 12"}],["path",{d:"M5 18C3.58579 18 2.87868 18 2.43934 17.5607C2 17.1213 2 16.4142 2 15C2 13.5858 2 12.8787 2.43934 12.4393C2.87868 12 3.58579 12 5 12"}],["path",{d:"M13.5 3.5C13.5 4.32843 12.8284 5 12 5C11.1716 5 10.5 4.32843 10.5 3.5C10.5 2.67157 11.1716 2 12 2C12.8284 2 13.5 2.67157 13.5 3.5Z"}],["path",{d:"M12 5V8"}],["path",{d:"M9 13V14"}],["path",{d:"M15 13V14"}],["path",{d:"M10 17.5C10 17.5 10.6667 18 12 18C13.3333 18 14 17.5 14 17.5"}]],settings:[["path",{d:"M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z"}],["path",{d:"M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z"}]],tablet:[["path",{d:"M14.5 2H9.5C6.67157 2 5.25736 2 4.37868 2.87868C3.5 3.75736 3.5 5.17157 3.5 8V16C3.5 18.8284 3.5 20.2426 4.37868 21.1213C5.25736 22 6.67157 22 9.5 22H14.5C17.3284 22 18.7426 22 19.6213 21.1213C20.5 20.2426 20.5 18.8284 20.5 16V8C20.5 5.17157 20.5 3.75736 19.6213 2.87868C18.7426 2 17.3284 2 14.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],trash:[["path",{d:"M19.5 5.5L18.8803 15.5251C18.7219 18.0864 18.6428 19.3671 18.0008 20.2879C17.6833 20.7431 17.2747 21.1273 16.8007 21.416C15.8421 22 14.559 22 11.9927 22C9.42312 22 8.1383 22 7.17905 21.4149C6.7048 21.1257 6.296 20.7408 5.97868 20.2848C5.33688 19.3626 5.25945 18.0801 5.10461 15.5152L4.5 5.5"}],["path",{d:"M3 5.5H21M16.0557 5.5L15.3731 4.09173C14.9196 3.15626 14.6928 2.68852 14.3017 2.39681C14.215 2.3321 14.1231 2.27454 14.027 2.2247C13.5939 2 13.0741 2 12.0345 2C10.9688 2 10.436 2 9.99568 2.23412C9.8981 2.28601 9.80498 2.3459 9.71729 2.41317C9.32164 2.7167 9.10063 3.20155 8.65861 4.17126L8.05292 5.5"}],["path",{d:"M9.5 16.5L9.5 10.5"}],["path",{d:"M14.5 16.5L14.5 10.5"}]],unlink:[["path",{d:"M12.1434 10.691L12.3503 10.4841C14.329 8.50532 17.5372 8.50532 19.5159 10.4841C21.4947 12.4628 21.4947 15.671 19.5159 17.6497L16.6497 20.5159C14.671 22.4947 11.4628 22.4947 9.48405 20.5159C7.50532 18.5372 7.50532 15.329 9.48405 13.3503L9.9484 12.886"}],["path",{d:"M20.0516 11.114L20.5159 10.6497C22.4947 8.67095 22.4947 5.46279 20.5159 3.48405C18.5372 1.50532 15.329 1.50532 13.3503 3.48405L10.4841 6.35031C8.50532 8.32904 8.50532 11.5372 10.4841 13.5159C12.4628 15.4947 15.671 15.4947 17.6497 13.5159L17.8566 13.309"}],["path",{d:"M4.5 4L6 6M2 8L5 9M3 13.5L5 12"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function N({name:t,size:e=16,stroke:r=2,color:n,className:o}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:ko[t].map(([s,i],a)=>react.createElement(s,{key:a,...i}))})}var Ao=[.16,1,.3,1];function il(t){try{let r=new URL(t).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return t}}function or(t){return t==="pending"||t==="acknowledged"}function So({onClose:t}){let e=ae(),{hideResolvedAnnotations:r}=Bt(),n=e.focusPin,o=typeof window>"u"?"":ct(window.location.href),s=react.useMemo(()=>[...r?e.entries.filter(d=>d.status!=="resolved"):e.entries].sort((d,u)=>(or(d.status)?0:1)-(or(u.status)?0:1)),[e.entries,r]),i=react.useMemo(()=>{let c=e.entries.filter(u=>or(u.status)&&ct(u.url)===o).length,d=e.entries.filter(u=>or(u.status)).length;return {here:c,elsewhere:d-c,total:d}},[e.entries,o]);function a(){if(i.total===0)return "No open feedback";let c=[`${i.total} open`];return i.here>0&&c.push(`${i.here} here`),i.elsewhere>0&&c.push(`${i.elsewhere} elsewhere`),c.join(" \xB7 ")}function l(c){t(),n(c);}return jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease:Ao}},exit:{opacity:0,y:4,scale:.985,transition:{duration:.12,ease:Ao}},"data-patch-fab-dock":"","data-patch-roster-panel":"",className:"absolute right-0 bottom-[54px] z-[2147483647] flex max-h-[min(480px,calc(100vh-120px))] w-[min(360px,calc(100vw-40px))] flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:{transformOrigin:"100% 100%"},children:[jsxRuntime.jsxs("div",{className:"flex items-baseline justify-between gap-2 px-4 pt-3.5 pb-2.5",children:[jsxRuntime.jsx("span",{className:"text-[13px] font-semibold",children:"Feedback"}),jsxRuntime.jsx("span",{className:"text-[11.5px] font-medium text-popover-foreground/50",children:a()})]}),s.length===0?jsxRuntime.jsx("div",{className:"px-4 pt-2 pb-6 text-center text-[12.5px] text-popover-foreground/50",children:"No feedback yet."}):jsxRuntime.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-2",children:s.map(c=>jsxRuntime.jsx(al,{entry:c,onCurrentPage:ct(c.url)===o,onClick:()=>l(c)},c.id))})]})}function al({entry:t,onCurrentPage:e,onClick:r}){let n=t.status==="resolved",o=t.anchorStatus==="detached";return jsxRuntime.jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-row":t.id,onClick:r,className:"flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-black/[0.04]",children:[jsxRuntime.jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsxRuntime.jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsxRuntime.jsx(N,{name:"check",size:10,stroke:2.6})}):t.status==="dismissed"?jsxRuntime.jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsxRuntime.jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:C("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:t.label}),jsxRuntime.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsxRuntime.jsx(N,{name:Tt[t.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsxRuntime.jsx("span",{className:"truncate",children:e?"This page":il(t.url)}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsxRuntime.jsx("span",{className:"shrink-0",children:nr(t.createdAt)}),o?jsxRuntime.jsxs("span",{className:"ml-0.5 inline-flex shrink-0 items-center gap-1 rounded-full bg-black/[0.05] px-1.5 py-px text-[10px] font-medium text-popover-foreground/55",children:[jsxRuntime.jsx(N,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var sl="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",ll={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Vt({initials:t,tint:e,src:r,generatedSeed:n,alt:o="",size:s="md",className:i,style:a}){let{url:l,seed:c}=Ye(r),d=c??n;return jsxRuntime.jsxs("span",{className:C(sl,ll[s],i),style:{background:e,...a},children:[jsxRuntime.jsx("span",{children:t}),!l&&d?jsxRuntime.jsx(tr,{seed:d}):null,l?jsxRuntime.jsx("img",{src:l,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:u=>{u.currentTarget.remove();}}):null]})}var dl="M48 0C67.8823 0 84 16.1178 84 36V63C84 67.9706 79.9706 72 75 72H48C42.2522 72 36.8201 70.6505 32 68.2549V87C32 91.9706 27.9706 96 23 96H14C12.8954 96 12 95.1046 12 94V36C12 16.1178 28.1178 0 48 0ZM48 18C38.0589 18 30 26.0589 30 36C30 45.9411 38.0589 54 48 54C57.9411 54 66 45.9411 66 36C66 26.0589 57.9411 18 48 18Z",ul="M12 2A10 10 0 0 1 22 12V20.6A1.4 1.4 0 0 1 20.6 22H12A10 10 0 0 1 2 12A10 10 0 0 1 12 2Z";function Ie({size:t=16,className:e}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:e,children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:dl})})}function To({size:t=16,variant:e="filled",stroke:r=2,className:n}){let o=e==="outline";return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:o?"none":"currentColor",stroke:o?"currentColor":"none",strokeWidth:o?r:void 0,strokeLinejoin:o?"round":void 0,strokeLinecap:o?"round":void 0,"aria-hidden":"true",focusable:"false",className:n,children:jsxRuntime.jsx("path",{d:ul})})}var Dr=false,Kt=null,ar=null,Rt={openDelay:700,isInstant(){return Dr},onOpen(t){ar&&ar!==t&&ar(),ar=t??null,Dr=true,Kt&&(clearTimeout(Kt),Kt=null);},onClose(){Kt&&clearTimeout(Kt),Kt=setTimeout(()=>{Dr=false,Kt=null;},300);}};var Po="easeOut";function ot({text:t,children:e,className:r,tone:n="default",placement:o="top"}){let[s,i]=react.useState(false),[a,l]=react.useState(false),c=react.useRef(null),d=react.useRef(false);react.useEffect(()=>()=>{c.current&&clearTimeout(c.current),d.current&&Rt.onClose();},[]);let u=x=>{l(x),i(true),d.current=true,Rt.onOpen();},p=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),Rt.isInstant()){u(true);return}c.current=setTimeout(()=>{c.current=null,u(false);},Rt.openDelay);},m=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,Rt.onClose()),i(false);},v=n==="warning"?"pointer-events-none absolute bottom-[calc(100%+8px)] left-0 z-[1]":o==="bottom"?"pointer-events-none absolute top-[calc(100%+8px)] left-1/2 z-[1] -translate-x-1/2":"pointer-events-none absolute -top-[38px] left-1/2 z-[1] -translate-x-1/2",f="shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45),0_3px_8px_-3px_rgba(0,0,0,0.3)] ring-1 ring-white/10",b=n==="warning"?`relative flex w-[200px] items-start gap-1.5 rounded-lg bg-foreground px-3 py-2.5 text-left text-[11px] leading-[1.35] font-medium text-white ${f}`:`relative block whitespace-nowrap rounded-md bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${f}`,h=n==="warning"?"absolute -bottom-1 left-6 size-2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground":o==="bottom"?"absolute -top-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-l border-t border-white/10 bg-foreground":"absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground",y=o==="bottom"&&n!=="warning"?-3:3,T=o==="bottom"&&n!=="warning"?-2:2;return jsxRuntime.jsxs("span",{className:C("relative inline-flex items-center justify-center",r),onMouseEnter:p,onMouseLeave:m,onMouseDown:m,children:[jsxRuntime.jsx("span",{className:v,children:jsxRuntime.jsx(react$1.AnimatePresence,{children:s&&jsxRuntime.jsxs(react$1.motion.span,{initial:a?false:{opacity:0,y,scale:.98},animate:{opacity:1,y:0,scale:1,transition:a?{duration:0}:{duration:.1,ease:Po}},exit:{opacity:0,y:T,scale:.98,transition:{duration:.08,ease:Po}},className:b,children:[n==="warning"?jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsxRuntime.jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsxRuntime.jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsxRuntime.jsx("span",{className:"min-w-0 flex-1",children:t}),jsxRuntime.jsx("span",{className:h})]})})}),e]})}var No=44,Lt=[.16,1,.3,1],Mo="easeOut",hl=.08,bl=60,vl="calc(100% - 64px) calc(100% + 4px)",me="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function _o(){let t=io(),e=ft(),r=rt(),n=ae(),{dockOpen:o,hideResolvedAnnotations:s,setDockOpen:i,setHideResolvedAnnotations:a}=Bt(),l=!!r.studio,c=n.unresolvedCount,[d,u]=react.useState(false),[p,m]=react.useState(false),[v,f]=react.useState(false),[b,h]=react.useState(false),[y,T]=react.useState(false),[x,z]=react.useState(false),D=react.useRef(null),g=react.useRef(null),I=react.useRef(false),[U,at]=react.useState(false),pt=react.useRef(null),[vt,st]=react.useState(No);react.useLayoutEffect(()=>{let $=pt.current;if(!$)return;let lt=()=>st($.offsetWidth);lt();let St=new ResizeObserver(lt);return St.observe($),()=>St.disconnect()},[]);let Q=r.studio?r.studio.name:r.identity?.name??null,K=se(Q),k=r.studio?.image??null,R=r.identity?.avatarSeed??r.clientAvatarSeed,M=r.studio?.userId??R,A=r.studio?"var(--color-foreground)":le(R),H=r.studio&&!k?"#FFFFFF":A,F=r.studio&&!k?"text-foreground":"text-white",E=Tt[r.activeViewport];function tt(){D.current!==null&&(window.clearTimeout(D.current),D.current=null);}function xt(){g.current!==null&&(window.clearTimeout(g.current),g.current=null);}let P=react.useRef(()=>{});P.current=()=>{!I.current&&D.current===null||(tt(),xt(),I.current=false,z(true));};let W=react.useRef(()=>P.current()).current;react.useEffect(()=>{x&&d&&u(false);},[x,d]);function _($){m(false),f(false),h(false),tt(),xt(),I.current=true,z(false),T($),Rt.onOpen(W),u(true);}function G(){_(false);}function wt(){if(tt(),!(I.current||g.current!==null)){if(Rt.isInstant()){_(true);return}g.current=window.setTimeout(()=>{g.current=null,_(false);},Rt.openDelay);}}function yt(){xt(),tt(),I.current&&(I.current=false,Rt.onClose()),D.current=window.setTimeout(()=>{u(false),D.current=null;},120);}function Ut(){at(true),i(true);}function ze(){m(false),f(false),h(false),xt(),I.current=false,u(false),t.isCapturing?t.exit():t.enter();}function He(){m(false),f(false),xt(),I.current=false,u(false),h($=>{let lt=!$;return lt&&n.refresh(),lt});}function Fe(){at(true),i(false),m(false),f(false),h(false),xt(),I.current=false,u(false),t.exit(),e.active&&e.forceClose();}react.useEffect(()=>()=>{D.current!==null&&window.clearTimeout(D.current),g.current!==null&&window.clearTimeout(g.current);},[]);let fr=()=>{r.signOut(),u(false);};function S(){f(false),h(false),xt(),I.current=false,u(false),m($=>!$);}function O($){m(false),r.activeViewport!==$&&(e.active&&e.forceClose(),r.setActiveViewport($));}function L(){m(false),h(false),xt(),I.current=false,u(false),f($=>!$);}function V(){a(!s);}function B($){let lt=$.relatedTarget;lt instanceof Node&&$.currentTarget.contains(lt)||yt();}return jsxRuntime.jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxRuntime.jsxs(react$1.motion.div,{initial:false,animate:{width:o?vt:No},transition:{duration:.36,ease:Lt},onAnimationComplete:()=>at(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Lt}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Lt}},"data-patch-fab-dock":"",className:C("pkey-fab relative h-11 rounded-full",U?"overflow-hidden":"overflow-visible"),children:[jsxRuntime.jsx(react$1.motion.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Lt},className:C("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsxRuntime.jsx("button",{type:"button",onClick:Ut,"data-patch-fab-dock":"","aria-label":l&&c>0?`Leave feedback \u2014 ${c} open`:"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsxRuntime.jsx(Ie,{size:18})})}),jsxRuntime.jsxs("div",{ref:pt,"data-patch-fab-dock":"",className:C("absolute inset-y-0 left-0 flex w-max items-center gap-1.5 px-1.5",o?"pointer-events-auto":"pointer-events-none"),children:[jsxRuntime.jsx(ge,{visible:o,index:0,children:jsxRuntime.jsx(ot,{text:t.isCapturing?"Stop commenting":"Add comment",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":t.isCapturing?"Stop commenting":"Add comment","aria-pressed":t.isCapturing,onClick:ze,className:C(me,"transition-colors",t.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(To,{variant:"outline",size:16})})})}),l?jsxRuntime.jsx(ge,{visible:o,index:1,children:jsxRuntime.jsx(ot,{text:"Feedback",children:jsxRuntime.jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-btn":"","aria-label":c>0?`Feedback \u2014 ${c} open`:"Feedback","aria-expanded":b,onClick:He,className:C(me,"relative transition-colors",b||c>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsxRuntime.jsx(N,{name:"list",size:15}),c>0?jsxRuntime.jsx("span",{className:"pointer-events-none absolute -top-0.5 -right-0.5 grid h-[15px] min-w-[15px] place-items-center rounded-full bg-brand px-1 text-[9px] font-semibold text-white",children:c>99?"99+":c}):null]})})}):null,jsxRuntime.jsx(ge,{visible:o,index:2,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${E.label}`,"aria-expanded":p,onClick:S,className:C(me,"transition-colors",r.activeViewport==="desktop"&&!p?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsxRuntime.jsx(N,{name:E.glyph,size:15})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:p?jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Lt}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Lt}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsxRuntime.jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),en.map($=>{let lt=Tt[$],St=r.activeViewport===$;return jsxRuntime.jsx(ot,{text:Qt($),children:jsxRuntime.jsx("button",{type:"button","data-patch-viewport-option":$,"aria-label":Qt($),"aria-pressed":St,onClick:()=>O($),className:C("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",St?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(N,{name:lt.glyph,size:15})})},$)})]}):null})]})}),jsxRuntime.jsx(ge,{visible:o,index:3,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx(ot,{text:"Settings",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":v,onClick:L,className:C(me,"transition-colors",v||s?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(N,{name:"settings",size:15})})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:v?jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Lt}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Lt}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-xl p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsxRuntime.jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxRuntime.jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:s,"aria-label":"Hide resolved annotations",onChange:V,className:"peer sr-only"}),jsxRuntime.jsx("span",{"aria-hidden":"true",className:C("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",s?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsxRuntime.jsx(N,{name:"check",size:10,stroke:2.4})}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsxRuntime.jsx(ge,{visible:o,index:4,children:jsxRuntime.jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:wt,onMouseLeave:yt,onFocus:G,onBlur:B,children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":Q?`Account: ${Q}`:"Identify",className:C(me,"text-white"),children:Q?jsxRuntime.jsx(Vt,{initials:K,tint:H,src:k,generatedSeed:M,alt:Q,size:"sm",className:C("size-[22px] text-[9.5px] ring-1 ring-white/20",F)}):jsxRuntime.jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:d?jsxRuntime.jsxs(react$1.motion.div,{initial:y?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:y?{duration:0}:{duration:.12,delay:hl,ease:Mo}},exit:{opacity:0,y:2,scale:.98,transition:x?{duration:0}:{duration:.08,ease:Mo}},"data-patch-fab-dock":"","data-patch-identity-popover":"",className:"fixed right-8 bottom-[72px] z-[2147483647] w-[min(272px,calc(100vw-40px))] min-w-[220px] rounded-xl bg-foreground p-3.5 font-sans text-[13px] text-white shadow-[0_18px_44px_-14px_rgba(0,0,0,0.5),0_6px_14px_-6px_rgba(0,0,0,0.45)] ring-1 ring-white/10",style:{transformOrigin:vl},children:[jsxRuntime.jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:bl}}),r.studio?jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(Vt,{initials:K,tint:A,src:k,generatedSeed:M,alt:r.studio.name,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(Vt,{initials:K,tint:A,generatedSeed:M,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsxRuntime.jsx("div",{className:"my-3 h-px bg-white/10"}),jsxRuntime.jsx("button",{type:"button",onClick:fr,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsxRuntime.jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsxRuntime.jsx(ge,{visible:o,index:5,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsxRuntime.jsx(ot,{text:"Close",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:Fe,className:C(me,"text-white/70"),children:jsxRuntime.jsx(N,{name:"x",size:14})})})]})})]})]}),l&&!o&&c>0?jsxRuntime.jsx("span",{"data-patch-fab-dock":"","data-patch-roster-badge":"","aria-hidden":"true",className:"pointer-events-none absolute -top-1 -right-1 grid h-[18px] min-w-[18px] place-items-center rounded-full bg-brand px-1 text-[10.5px] font-semibold text-white shadow-[0_1px_3px_rgba(0,0,0,0.3)]",children:c>99?"99+":c}):null,jsxRuntime.jsx(react$1.AnimatePresence,{children:b?jsxRuntime.jsx(So,{onClose:()=>h(false)}):null})]})}function ge({children:t,visible:e,index:r}){return jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0,x:6},animate:e?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Lt}}:{opacity:0,x:6,transition:{duration:.12,ease:Lt}},children:t})}function Lo(t,e){return e.width<=0||e.height<=0?{fx:0,fy:0}:{fx:(t.viewportX-e.x)/e.width,fy:(t.viewportY-e.y)/e.height}}function Do(t,e){return {viewportX:e.x+t.fx*e.width,viewportY:e.y+t.fy*e.height}}var wl=.6,yl=.5,lr={text:.4,attrs:.3,classes:.2,position:.1},kl=5e3,Cl=.08,Al=.12;function Sl(t,e){return e===void 0||e===""?.5:t===e?1:t&&(t.includes(e)||e.includes(t))?.5:0}function Tl(t,e){if(!e)return .5;let r=Object.keys(e);if(r.length===0)return .5;let n=0;for(let o of r)t[o]===e[o]&&n++;return n/r.length}function El(t,e){let r=new Set(t),n=new Set(e??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let i of r)n.has(i)&&o++;let s=r.size+n.size-o;return s===0?0:o/s}function zo(t){let e=t.payload.boundingBox;if(!e)return null;let r=t.payload.coordinates.documentY-t.payload.coordinates.viewportY;return {x:e.x+e.width/2,y:e.y+e.height/2+r}}function zr(t,e,r){if(!e)return .5;let n=t.left+t.width/2,o=t.top+r.scrollY+t.height/2,s=(n-e.x)/Math.max(1,r.viewport.width),i=(o-e.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(s*s+i*i))}function Rl(t,e){let r=qe(t),n=Ke(t),o=Ae(t),s=t.getBoundingClientRect(),i=Sl(r,e.payload.domHints?.textSignature),a=Tl(n,e.payload.domHints?.attributeSignature),l=El(o,e.payload.cssClasses),c=zr(s,zo(e),e);return lr.text*i+lr.attrs*a+lr.classes*l+lr.position*c}function Pl(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Oo(t,e,r){let n=null,o=null,s=0;for(let i=0;i<t.length&&!(s>=kl);i++){let a=t[i];if(!a||(s++,qn(a,e.internalAttr)))continue;let l=a.tagName.toLowerCase();if(l==="html"||l==="head"||l==="script"||l==="style"||Pl(a))continue;let c=Rl(a,e);!n||c>n.score?(o=n,n={el:a,score:c}):(!o||c>o.score)&&(o={el:a,score:c});}if(!n||n.score<r)return null;if(o&&n.score-o.score<Cl){let i=zo(e),a=zr(n.el.getBoundingClientRect(),i,e),l=zr(o.el.getBoundingClientRect(),i,e);if(a-l<Al)return null}return n.el}function Il(t){return {viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.documentY-t.scrollY}}function Nl(t,e){let r=t.getBoundingClientRect();if(!e.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=Lo({viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.viewportY},e.payload.boundingBox);return Do(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Ml(t){let e=t.payload.domHints?.cssSelector;if(!e)return [];try{return Array.from(t.doc.querySelectorAll(e))}catch{return []}}function cr(t){if(!t.payload.domHints)return {kind:"detached",el:null};let e=Ml(t);if(e.length>0){let n=Oo(e,t,yl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Oo(t.doc.querySelectorAll("*"),t,wl);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function Hr(t,e){return t.kind==="anchored"&&t.el?Nl(t.el,e):Il(e)}function Ho(t){let e=cr(t);return {kind:e.kind,tier:e.tier,el:e.el,position:Hr(e,t)}}function Fo(t){if(t.status==="resolved")return null;let e=t.latestRun;return e?e.status==="failed"?"patch-failed":e.status!=="succeeded"?null:e.prClosedUnmerged?"rerun-after-closed":e.prUrl?"review-pr":null:null}var Ll="data-patch-internal";function dr(t,e,r){let n=ce(r,e.getOverlayViewport()),o=rr(r,n);t.style.top=`${o.y}px`,t.style.left=`${o.x}px`;}function Vo(t,e){return Math.abs(t.viewportX-e.viewportX)<.5&&Math.abs(t.viewportY-e.viewportY)<.5}function Dl(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Br(t,e){return {payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Ll}}function Wo(t,e,r){let n=Br(t,e);return {kind:r.kind,position:t.targetPointToOverlay(Hr(r,n))}}function Ol(t,e){return t.targetPointToOverlay({viewportX:e.viewportX,viewportY:e.documentY-t.getTargetScrollY()})}function Uo(){let{annotations:t,annotationsReady:e,ephemerals:r,identity:n,studio:o,clientAvatarSeed:s,apiClient:i}=rt(),a=ft(),{dockOpen:l,hideResolvedAnnotations:c}=Bt(),d=mt(),{isPreviewing:u,previewReady:p}=ne(),m=react$1.useReducedMotion(),v=a.active,f=a.forceClose,b=e&&(!u||p),h=react.useMemo(()=>l&&e?t.filter(k=>!c||k.status!=="resolved"):[],[l,e,t,c]),y=react.useMemo(()=>l&&e?r:[],[l,e,r]);react.useEffect(()=>{if(!c||v?.kind!=="existing")return;t.find(R=>R.id===v.annotationId)?.status==="resolved"&&f();},[v,t,f,c]);let T=react.useRef(new Map),x=react.useRef(new Map),z=react.useRef(new Map),D=react.useRef(new Map),g=react.useMemo(()=>{let k=D.current,R=new Set,M=new Map;for(let A of h){R.add(A.id);let H=k.get(A.id),E=H?.kind==="anchored"&&H.el?.isConnected?H:cr(Br(d,A));k.set(A.id,E),M.set(A.id,Wo(d,A,E));}for(let A of k.keys())R.has(A)||k.delete(A);return M},[d,h]),I=react.useCallback(()=>{let k=D.current,R=z.current,M=new Set;for(let A of h){let H=T.current.get(A.id);if(!H)continue;M.add(A.id);let F=k.get(A.id);if((!F||F.kind==="anchored"&&F.el&&!F.el.isConnected)&&(F=cr(Br(d,A)),k.set(A.id,F)),F.kind==="detached"||F.kind==="anchored"&&F.el&&Dl(F.el)){H.style.visibility!=="hidden"&&(H.style.visibility="hidden"),R.delete(A.id);continue}H.style.visibility==="hidden"&&(H.style.visibility="");let E=Wo(d,A,F).position,tt=R.get(A.id);tt&&Vo(tt,E)||(R.set(A.id,E),dr(H,d,E));}for(let A of y){let H=x.current.get(A.tempId);if(!H)continue;M.add(A.tempId);let F=Ol(d,A),E=R.get(A.tempId);E&&Vo(E,F)||(R.set(A.tempId,F),dr(H,d,F));}for(let A of R.keys())M.has(A)||R.delete(A);},[d,h,y]),U=h.length>0||y.length>0;react.useEffect(()=>{if(!U)return;let k=d.overlayWindow,R=k.requestAnimationFrame(function M(){I(),R=k.requestAnimationFrame(M);});return ()=>k.cancelAnimationFrame(R)},[U,I,d]);let at=react.useRef(new Map);react.useEffect(()=>{if(!e||h.length===0)return;let k=setTimeout(()=>{let R=[];for(let M of h){let A=g.get(M.id);if(!A)continue;let H=A.kind!=="detached";at.current.get(M.id)!==H&&(at.current.set(M.id,H),R.push({id:M.id,present:H}));}i.reportAnchorStatuses(R);},1500);return ()=>clearTimeout(k)},[g,h,e,i]);let pt=react.useCallback(k=>{if(a.active&&a.hasDraft){a.attemptClose();return}a.openExisting(k);},[a]),vt=o?o.name:n?.name??null,st=o?.image??null,Q=n?.avatarSeed??s,K=o?.userId??Q;return jsxRuntime.jsxs("div",{"data-patch-pin-layer":"",style:{opacity:b?1:0,transition:m||!b?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:b?void 0:"none"},children:[jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:h.map(k=>{let R=g.get(k.id);if(R?.kind==="detached")return null;let M=zl(k),A=!o&&!!n?.clientUserId&&k.payload.authorRole==="client"&&k.payload.authorId===n.clientUserId,H=o?Fo(k):null,F=R?ce(R.position,d.getOverlayViewport()):"right";return jsxRuntime.jsx(_r,{ref:E=>{E?(T.current.set(k.id,E),R&&dr(E,d,R.position)):T.current.delete(k.id);},avatarSrc:M.image,generatedSeed:A?Q:M.generatedSeed,avatarAlt:M.name??"",resolved:k.status==="resolved",attention:H,pointSide:F,ariaLabel:`Annotation by ${k.authorName??"someone"}`,onClick:()=>pt(k.id),pinId:k.id},k.id)})}),jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:y.map(k=>{let R=d.targetPointToOverlay({viewportX:k.viewportX,viewportY:k.viewportY});return jsxRuntime.jsx(_r,{ref:M=>{M?(x.current.set(k.tempId,M),dr(M,d,R)):x.current.delete(k.tempId);},avatarSrc:st,generatedSeed:K,avatarAlt:vt??"",resolved:false,pointSide:ce(R,d.getOverlayViewport()),ephemeral:true},k.tempId)})})]})}function zl(t){let e=t.authorAvatarSeed??t.payload.authorId??(t.authorName?`annotation-author:${t.authorName}`:null);if(t.authorImage||e||t.authorName)return {name:t.authorName,image:t.authorImage??null,generatedSeed:e??t.id,key:t.payload.authorId??t.authorName??t.id};let r=t.thread.find(n=>n.authorImage||n.authorId||n.authorName);if(r){let n=r.authorAvatarSeed??r.authorId??(r.authorName?`thread-author:${r.authorName}`:null);return {name:r.authorName,image:r.authorImage??null,generatedSeed:n??t.id,key:r.authorId??r.authorName??t.id}}return {name:t.authorName,image:t.authorImage??null,generatedSeed:t.id,key:t.id}}var Vl=5e3;function Go(){let t=ae(),e=rt(),r=ft(),n=Bt(),o=mt(),s=react$1.useReducedMotion(),i=t.pendingFocus,a=react.useRef(null),l=react.useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return react.useEffect(()=>{if(!i)return;if(ct(window.location.href)!==ct(i.url)){t.clearFocus();return}if(n.dockOpen||n.setDockOpen(true),e.activeViewport!==i.viewport){e.setActiveViewport(i.viewport);return}if(!e.annotationsReady)return;let c=e.annotations.find(u=>u.id===i.id);if(!c){a.current===null&&(a.current=window.setTimeout(()=>{a.current=null,t.clearFocus();},Vl));return}l();let d=c.payload.coordinates?.documentY;if(typeof d=="number"){let u=o.getTargetViewport().height;o.targetWindow.scrollTo({top:Math.max(0,d-u/3),behavior:s?"auto":"smooth"});}r.openExisting(i.id),t.clearFocus();},[i,e,n,o,s,r,t,l]),react.useEffect(()=>()=>l(),[l]),null}function Wl(){for(let t of [document.body,document.documentElement]){let e=window.getComputedStyle(t).backgroundColor;if(e&&e!=="transparent"&&e!=="rgba(0, 0, 0, 0)")return e}return "#ffffff"}async function Xo(t){try{let{snapdom:e}=await import('@zumer/snapdom'),r=Math.min(window.devicePixelRatio||1,2),n=await e.toCanvas(document.body,{dpr:r,exclude:["[data-patch-internal]"],embedFonts:!0}),o=document.body.getBoundingClientRect(),s=n.width/Math.max(1,o.width),i=document.createElement("canvas");i.width=Math.max(1,Math.round(t.width*r)),i.height=Math.max(1,Math.round(t.height*r));let a=i.getContext("2d");return a?(a.fillStyle=Wl(),a.fillRect(0,0,i.width,i.height),a.drawImage(n,(t.x-o.left)*s,(t.y-o.top)*s,t.width*s,t.height*s,0,0,i.width,i.height),await new Promise(l=>i.toBlob(l,"image/webp",.92))):null}catch{return null}}var Gl='<svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 34 34"><g stroke="#fff" stroke-width="3.5" stroke-linecap="round"><path d="M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21"/></g><g stroke="#1F1F1F" stroke-width="1.5" stroke-linecap="round"><path d="M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21"/></g><g><rect x="20" y="22" width="13" height="10" rx="2.5" fill="#1F1F1F" stroke="#fff"/><circle cx="26.5" cy="27" r="2.6" fill="none" stroke="#fff" stroke-width="1.4"/></g></svg>',Xl=`url("data:image/svg+xml,${encodeURIComponent(Gl)}") 12 12, crosshair`,Wr=4;function jo(t,e){return {x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function Zo({capturing:t,onSelect:e,onCancel:r}){let n=react$1.useReducedMotion(),[o,s]=react.useState(null),[i,a]=react.useState(null),[l,c]=react.useState(null);react.useEffect(()=>{let f=b=>{b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),t||r());};return document.addEventListener("keydown",f,true),()=>document.removeEventListener("keydown",f,true)},[t,r]);let d=react.useCallback(f=>({x:Math.min(Math.max(f.x,0),window.innerWidth),y:Math.min(Math.max(f.y,0),window.innerHeight)}),[]),u=react.useCallback((f,b)=>{let h=jo(f,b);s(null),a(null),!(h.width<Wr||h.height<Wr)&&(c(h),e(h));},[e]);react.useEffect(()=>{if(!o)return;let f=h=>{a(d({x:h.clientX,y:h.clientY}));},b=h=>{u(o,d({x:h.clientX,y:h.clientY}));};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",b);}},[o,d,u]);let p=l??(o&&i?jo(o,i):null),m=!!p&&p.width>=Wr/2,v=p?p.y+p.height+30<window.innerHeight:true;return jsxRuntime.jsxs("div",{"data-patch-screenshot-overlay":"",role:"dialog","aria-label":"Capture a screenshot",className:"fixed inset-0 z-[2147483647] select-none",style:{cursor:t?"progress":Xl},onMouseDown:f=>{if(f.button!==0||t)return;f.preventDefault();let b=d({x:f.clientX,y:f.clientY});s(b),a(b);},children:[m&&p?jsxRuntime.jsx("div",{className:"pointer-events-none absolute rounded-[3px] border-[1.5px] border-brand bg-brand/10 shadow-[0_0_0_1px_rgba(255,255,255,0.55)]",style:{left:p.x,top:p.y,width:p.width,height:p.height},children:jsxRuntime.jsx("span",{className:C("absolute right-0 whitespace-nowrap rounded-md bg-foreground px-2 py-1 font-sans text-[11px] font-medium tabular-nums text-white shadow-[0_3px_8px_-3px_rgba(0,0,0,0.3)]",v?"top-[calc(100%+6px)]":"bottom-[calc(100%+6px)]"),children:t?jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"size-2.5 animate-spin rounded-full border border-white/40 border-t-white"}),"Capturing\u2026"]}):`${Math.round(p.width)} \xD7 ${Math.round(p.height)}`})}):null,!o&&!t?jsxRuntime.jsxs(react$1.motion.div,{initial:n?false:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{duration:.15,ease:"easeOut"}},className:"pointer-events-none absolute top-4 left-1/2 -translate-x-1/2 rounded-full bg-foreground/90 px-3.5 py-2 font-sans text-[12px] font-medium text-white shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45)]",children:["Drag to capture",jsxRuntime.jsx("span",{className:"mx-2 opacity-40",children:"\xB7"}),jsxRuntime.jsx("kbd",{className:"rounded bg-white/16 px-1.5 py-0.5 font-sans text-[11px]",children:"Esc"}),jsxRuntime.jsx("span",{className:"ml-1.5 opacity-70",children:"to cancel"})]}):null]})}var ti=react.createContext(null);function ei({children:t}){let e=ft(),[r,n]=react.useState("idle"),o=react.useRef(null),s=react.useRef(false);s.current=r!=="idle";let i=react.useCallback(()=>{o.current=null,n("idle");},[]),a=e.active!==null;react.useEffect(()=>{!a&&s.current&&i();},[a,i]);let l=react.useCallback(async u=>{s.current||(o.current=u,n("select"));},[]),c=react.useCallback(async u=>{n("capturing");let p=await Xo(u),m=o.current;i(),p&&m&&m(p);},[i]),d=react.useMemo(()=>({supported:true,active:r!=="idle",begin:l}),[r,l]);return jsxRuntime.jsxs(ti.Provider,{value:d,children:[jsxRuntime.jsx("div",{style:r==="idle"?{transition:"opacity 150ms ease-out"}:{opacity:0,pointerEvents:"none",transition:"opacity 150ms ease-out"},children:t}),r!=="idle"?jsxRuntime.jsx(Zo,{capturing:r==="capturing",onSelect:u=>{c(u);},onCancel:i}):null]})}var Ql={supported:false,active:false,begin:async()=>{}};function ri(){return react.use(ti)??Ql}var ni=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
5
5
  @layer properties;
6
6
  @layer theme, base, components, utilities;
7
7
  @layer theme {
@@ -236,6 +236,9 @@
236
236
  .relative {
237
237
  position: relative;
238
238
  }
239
+ .static {
240
+ position: static;
241
+ }
239
242
  .inset-0 {
240
243
  inset: calc(var(--spacing) * 0);
241
244
  }
@@ -2266,19 +2269,19 @@ button:not(:disabled):not(.pkey):active {
2266
2269
  }
2267
2270
  }
2268
2271
  }
2269
- `;var ni="patch-widget-root";function oi({children:t}){let[e,r]=react.useState(null),n=react.useRef(null);return react.useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(ni);o||(o=document.createElement(ni),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let s=o.shadowRoot??o.attachShadow({mode:"open"});if(!s.querySelector("style[data-patch-css]")){let a=document.createElement("style");a.setAttribute("data-patch-css",""),a.textContent=ri,s.appendChild(a);}let i=s.querySelector("div[data-patch-mount]");return i||(i=document.createElement("div"),i.setAttribute("data-patch-mount",""),s.appendChild(i)),r(i),()=>{}},[]),e?reactDom.createPortal(t,e):null}var rc=/[\s#.:[\]()>+~,\\]/;function nc(t){return !(!t||rc.test(t)||/^\d/.test(t))}function oc(t){let e=1,r=t.previousElementSibling,n=t.tagName;for(;r;)r.tagName===n&&e++,r=r.previousElementSibling;return e}function ii(t,e,r){try{let n=t.querySelectorAll(e);return n.length===1&&n[0]===r}catch{return false}}function ic(t,e){return t.id&&nc(t.id)&&(!e||ii(e,`#${t.id}`,t))?`#${t.id}`:`${t.tagName.toLowerCase()}:nth-of-type(${oc(t)})`}function ai(t,e){if(!t.tagName)return "";let r=t.ownerDocument??null,n=[],o=t,s=0;for(;o&&s<12;){let i=ic(o,r);if(n.unshift(i),i.startsWith("#"))break;let a=n.join(" > ");if(r&&ii(r,a,t))return a;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,s++;}return n.join(" > ")}var ac=80,sc=500;function li(t){return t!==null&&typeof t=="object"}function lc(t){return li(t)?"return"in t||"type"in t||"elementType"in t||"_debugOwner"in t:false}function ur(t){if(typeof t=="function")return t.displayName||t.name||null;if(!li(t))return null;let e=t.displayName;if(typeof e=="string"&&e)return e;let r=ur(t.render);if(r)return r;let n=ur(t.type);return n||null}function ci(t){return t.replace(/\s+/g," ").trim()}function di(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function cc(t){let e=ci(t).replace(/[<>]/g,"");return !e||/^[a-z]/.test(e)?null:di(e,ac)}function dc(t){let e=ur(t.elementType)??ur(t.type);return e?cc(e):null}function si(t){return di(ci(t),sc)}function uc(t){let e=t.replace(/\\/g,"/");return e.includes("/.next/")||e.includes("/node_modules/next/")||e.includes("/node_modules/react/")||e.includes("/node_modules/react-dom/")||e.includes("/node_modules/react-router/")||e.includes("/node_modules/react-router-dom/")||e.includes("/node_modules/@remix-run/")||e.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(e)}function pc(t){let e=t.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=e.lastIndexOf(n);if(o>=0)return si(e.slice(o+1))}let r=e.split("/").filter(Boolean);return si(r.slice(-3).join("/"))}function mc(t){let e=t._debugSource?.fileName;return typeof e!="string"||!e.trim()||uc(e)?null:pc(e)}function gc(t){let e=t;for(let r of Object.getOwnPropertyNames(t)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=e[r];if(lc(n))return n}return null}function ui(t){let e=gc(t);if(!e)return null;let r=[],n=null,o=0;for(;e&&o<30;){let a=dc(e),l=a?Cr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=mc(e)),e=e.return??e._debugOwner??null,o+=1;}let s=r.length>0?In(r.reverse().map(a=>`<${a}>`).join(" ")):null,i={};return s&&(i.reactComponents=s),n&&(i.sourceFile=n),Object.keys(i).length>0?i:null}var pi=500;function fc(t){return t.length<=pi?t:t.slice(0,pi)}function hc(t){return {viewportX:t.viewportX,viewportY:t.viewportY,documentY:t.viewportY+t.scrollY,isFixed:false}}function bc(t){return {x:t.x,y:t.y,width:t.width,height:t.height}}function vc(t){let e={cssSelector:ai(t)},r=qe(t);r&&(e.textSignature=r);let n=Ke(t);return Object.keys(n).length>0&&(e.attributeSignature=n),e}function mi(t){return Se(t.element,t.selectedText)}function gi(t){let{target:e,click:r,comment:n,url:o}=t,s=e.element,i=e.rect,a=Wn(s),l=Yn(s),c=Ae(s),d=Gn(s),u=ui(s),p={comment:n,element:Xe(s),elementPath:Un(s),targetLabel:Se(s,e.selectedText),timestamp:Date.now(),url:Gt(o),kind:"feedback",coordinates:hc(r),boundingBox:bc(i),domHints:vc(s)};return e.selectedText&&(p.selectedText=fc(e.selectedText)),l&&(p.nearbyText=l),c.length>0&&(p.cssClasses=c),d.length>0&&(p.nearbyElements=d),a&&(p.accessibility=a),u?.reactComponents&&(p.reactComponents=u.reactComponents),u?.sourceFile&&(p.sourceFile=u.sourceFile),p}var xc=2e3,wc=.82,yc=.85;function hi(t,e,r){return new Promise(n=>t.toBlob(n,e,r))}function bi(t){return t.startsWith("image/")&&t!=="image/gif"}async function vi(t){let e;try{e=await createImageBitmap(t);}catch{return null}try{let r=Math.min(1,xc/Math.max(e.width,e.height)),n=Math.max(1,Math.round(e.width*r)),o=Math.max(1,Math.round(e.height*r));if(r===1&&t.size<=3145728){let l=new Uint8Array(await t.slice(0,16).arrayBuffer()),c=Rn(l);if(c==="image/webp"||c==="image/jpeg")return {blob:c===t.type?t:new Blob([t],{type:c}),width:n,height:o}}let s=document.createElement("canvas");s.width=n,s.height=o;let i=s.getContext("2d");if(!i)return null;i.drawImage(e,0,0,n,o);let a=await hi(s,"image/webp",wc);return (!a||a.type!=="image/webp")&&(a=await hi(s,"image/jpeg",yc)),!a||a.size>3145728?null:{blob:a,width:n,height:o}}finally{e.close();}}async function Me(t,e){return t.kind==="composer"?e.createAnnotation(t.payload):e.reply(t.annotationId,{content:t.content,attachmentIds:t.attachmentIds})}async function xi(t,e){return e.resolve(t)}async function wi(t,e){return e.deleteAnnotation(t)}async function yi(t,e){return e.deleteMessage(t.annotationId,t.messageId)}async function ki(t,e){return t.viewerKind!=="studio"?null:e.reopen(t.annotationId)}async function Ci(t,e){return t.viewerKind!=="studio"?null:e.kickoff(t.annotationId,{guidance:t.guidance})}async function Ai(t,e){return e.postIdentity(t)}var Ei=react.createContext(null),Ti=0;function pr(t){return Ti+=1,`${t}-${Date.now().toString(36)}-${Ti}`}function Yr(t){return t.deliveryStatus==="sending"||t.deliveryStatus==="failed"}function Ri({annotation:t,draftTargetLabel:e,children:r}){let n=rt(),o=ft(),s=mt(),[i,a]=react.useState(false),[l,c]=react.useState(null),[d,u]=react.useState(null),p=react.useRef(false),m=t?.thread??[],v=t?.latestRun??null,f=t?.status==="resolved",b=t?Yr(t):false,h=n.viewerKind,y=react.useCallback(()=>h==="studio"?{role:"studio",authorId:n.studio?.userId??null,authorName:n.studio?.name??null,authorImage:n.studio?.image??null}:{role:"client",authorId:n.identity?.clientUserId??null,authorName:n.identity?.name??null,authorImage:null},[n.identity,n.studio,h]),T=react.useMemo(()=>y(),[y]),x=!!t&&t.deliveryStatus!=="sending"&&t.deliveryStatus!=="failed"&&!!T.authorId&&t.payload.authorRole===T.role&&t.payload.authorId===T.authorId,z=react.useCallback((S,D)=>{let _=y();return {id:pr("tmp-msg"),role:_.role,authorId:_.authorId,authorName:_.authorName,authorImage:_.authorImage,content:S,createdAt:new Date().toISOString(),deliveryStatus:"sending",attachments:D}},[y]),O=react.useCallback(async(S,D="upload")=>{let _=Array.from(S).filter(V=>bi(V.type));await Promise.all(_.map(async V=>{let B=await vi(V);if(!B)return;let $=pr("tmp-att"),lt=URL.createObjectURL(B.blob);if(!o.addDraftAttachment({localId:$,status:"uploading",previewUrl:lt,width:B.width,height:B.height,kind:D,attachment:null})){URL.revokeObjectURL(lt);return}let Yt=await n.apiClient.uploadAttachment(B.blob,{kind:D,width:B.width,height:B.height});o.updateDraftAttachment($,Yt?{status:"uploaded",attachment:Yt}:{status:"failed"});}));},[o,n.apiClient]),g=react.useCallback(async S=>{if(p.current)return Promise.reject(new Error("busy"));p.current=true,a(true);try{return await S()}finally{p.current=false,a(false);}},[]),N=react.useCallback(async()=>{let S=o.draftText.trim(),D=o.draftAttachments.flatMap(et=>et.status==="uploaded"&&et.attachment?[et.attachment]:[]);if(o.draftAttachments.some(et=>et.status!=="uploaded"))return;if(t){if(!S&&D.length===0||f||Yr(t))return;let et=z(S,D);o.setDraftText(""),o.clearDraftAttachments(),n.updateAnnotation(t.id,It=>({...It,thread:[...It.thread,et]}));let we=await Me({kind:"reply",annotationId:t.id,content:S,attachmentIds:D.map(It=>It.id)},n.apiClient);if(we){let It=we.attachments??[];n.updateAnnotation(t.id,Jt=>({...Jt,thread:Jt.thread.map(fr=>fr.id===et.id?{...fr,id:we.id,deliveryStatus:"sent",attachments:It}:fr)})),It.length<D.length&&c("Some images expired before sending and were removed."),n.refresh();return}n.updateAnnotation(t.id,It=>({...It,thread:It.thread.map(Jt=>Jt.id===et.id?{...Jt,deliveryStatus:"failed"}:Jt)}));return}if(!S)return;let _=o.active;if(!_||_.kind!=="composer")return;let V=_.target,B={viewportX:_.anchor.viewportX,viewportY:_.anchor.viewportY,scrollY:_.anchor.documentY-_.anchor.viewportY},$=s.getPageUrl(),lt=tn(n.activeViewport,s.getTargetViewport()),Ct=gi({target:V,click:B,comment:S,url:$});Ct.viewport=n.activeViewport,Ct.viewportSize=lt,Ct.attachmentIds=D.map(et=>et.id);let Yt=y(),$e=pr("tmp-ann");n.applyAnnotationUpdate({id:$e,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:Yt.authorName,authorImage:Yt.authorImage,payload:{...Ct,authorRole:Yt.role,authorId:Yt.authorId},attachments:D,thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting($e);let xe=await Me({kind:"composer",payload:Ct},n.apiClient);if(xe){let et=xe.attachments??[];n.replaceAnnotationId($e,xe.id),n.updateAnnotation(xe.id,we=>({...we,attachments:et})),et.length<D.length&&c("Some images expired before sending and were removed."),o.openExisting(xe.id),n.refresh();return}n.updateAnnotation($e,et=>({...et,deliveryStatus:"failed"}));},[t,y,f,z,n,o,s]),U=react.useCallback(async S=>{if(!t||Yr(t))return;let D=t.thread.find(V=>V.id===S);if(!D||D.deliveryStatus!=="failed")return;n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"sending"}:B)}));let _=await Me({kind:"reply",annotationId:t.id,content:D.content,attachmentIds:(D.attachments??[]).map(V=>V.id)},n.apiClient);if(_){n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,id:_.id,deliveryStatus:"sent"}:B)})),n.refresh();return}n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"failed"}:B)}));},[t,n]),at=react.useCallback(async()=>{if(!t||t.deliveryStatus!=="failed")return;let S=t.id;n.updateAnnotation(S,_=>({..._,deliveryStatus:"sending"}));let D=await Me({kind:"composer",payload:t.payload},n.apiClient);if(D){n.replaceAnnotationId(S,D.id),o.openExisting(D.id),n.refresh();return}n.updateAnnotation(S,_=>({..._,deliveryStatus:"failed"}));},[t,n,o]),pt=react.useCallback(S=>!T.authorId||S.deliveryStatus&&S.deliveryStatus!=="sent"?false:S.role===T.role&&S.authorId===T.authorId,[T]),vt=react.useCallback(()=>{x&&(c(null),u({kind:"annotation"}));},[x]),st=react.useCallback(S=>{pt(S)&&(c(null),u({kind:"message",messageId:S.id}));},[pt]),Q=react.useCallback(()=>{c(null),u(null);},[]),X=react.useCallback(async S=>{if(!t)return false;let D=t.thread;return g(async()=>(c(null),n.updateAnnotation(t.id,V=>({...V,thread:V.thread.filter(B=>B.id!==S)})),await yi({annotationId:t.id,messageId:S},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(t.id,V=>({...V,thread:D})),c("Couldn't delete message. Try again."),false)))},[t,n,g]),k=react.useCallback(async()=>!t||!x?false:g(async()=>(c(null),await wi(t.id,n.apiClient)?(n.updateAnnotation(t.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[t,x,n,o,g]),R=react.useCallback(async()=>{if(d)try{(d.kind==="annotation"?await k():await X(d.messageId))&&u(null);}catch{c("Couldn't delete. Try again.");}},[d,k,X]),M=react.useCallback(async()=>{t&&await g(async()=>{c(null);let S={status:t.status,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt,optimisticAction:t.optimisticAction};if(n.updateAnnotation(t.id,_=>({..._,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await xi(t.id,n.apiClient)){n.updateAnnotation(t.id,_=>({..._,...S})),c("Couldn't resolve. Try again.");return}n.refresh();});},[t,n,g]),A=react.useCallback(async()=>{t&&await g(async()=>{c(null);let S={status:t.status,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt,optimisticAction:t.optimisticAction};if(n.updateAnnotation(t.id,_=>({..._,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await ki({annotationId:t.id,viewerKind:h},n.apiClient)){n.updateAnnotation(t.id,_=>({..._,...S})),c("Couldn't reopen. Try again.");return}n.refresh();});},[t,h,n,g]),H=react.useCallback(async S=>{t&&await g(async()=>{c(null);let D=t.latestRun,_=t.optimisticAction;n.updateAnnotation(t.id,B=>({...B,latestRun:{id:pr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let V=await Ci({annotationId:t.id,viewerKind:h,guidance:S},n.apiClient);if(!V?.ok){n.updateAnnotation(t.id,B=>({...B,latestRun:D,optimisticAction:_})),c(V?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[t,h,n,g]),F=react.useCallback(async S=>{let D=await Ai({...S,avatarSeed:n.clientAvatarSeed},n.apiClient);return D&&await n.setIdentity(D),D},[n]),tt=h==="client"&&!n.identity&&m.length===0,xt=!!t||m.length>0,P=n.agentRunReadiness?.ready??true,L=n.agentRunReadiness?.message??null,W=react.useCallback(()=>{if(o.hasDraft){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),j=t?Zn(t.payload):e||"annotation",Pt=t?.payload.viewport??n.activeViewport,wt=n.studio?n.studio.name:n.identity?.name??null,Ut=n.identity?.avatarSeed??n.clientAvatarSeed,ze=n.studio?.userId??Ut,He=n.studio?.image??null,Fe=n.studio?.userId??Ut,gr=react.useMemo(()=>({state:{annotation:t,messages:m,runState:v,draftText:o.draftText,draftAttachments:o.draftAttachments,busy:i,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:h==="studio",agentRunReady:P,agentRunSetupMessage:L,needsIdentity:tt,isResolved:f,initialMessageLocked:b,threadVisible:xt,canDeleteAnnotation:x},actions:{setDraftText:o.setDraftText,attachFiles:O,removeDraftAttachment:o.removeDraftAttachment,submit:N,retryMessage:U,retryInitialMessage:at,requestDeleteAnnotation:vt,requestDeleteMessage:st,canDeleteMessage:pt,cancelDelete:Q,confirmDelete:R,markResolved:M,reopen:A,runPatch:H,setIdentity:F,attemptClose:o.attemptClose,requestClose:W,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:j,viewport:Pt,shakeNonce:o.shakeNonce,viewer:{kind:h,authorId:T.authorId,name:wt,avatarKey:ze,avatarSrc:He,generatedSeed:Fe}}}),[t,m,v,o.draftText,o.draftAttachments,o.removeDraftAttachment,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,l,d,O,N,U,at,vt,st,pt,Q,R,M,A,H,F,h,P,L,tt,f,b,xt,x,W,j,Pt,T.authorId,wt,ze,He,Fe]);return jsxRuntime.jsx(Ei.Provider,{value:gr,children:r})}function q(){let t=react.use(Ei);if(!t)throw new Error("useThreadContext must be used inside <ThreadProvider>");return t}var Ec="inline-flex shrink-0 items-center justify-center gap-1.5 h-8 px-3.5 rounded-lg whitespace-nowrap text-[13px] font-semibold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",Rc={brand:"pkey pkey-brand text-white",brandTint:"bg-brand-tint text-brand hover:bg-brand-tint/70",destructive:"pkey pkey-destructive text-white",destructiveTint:"bg-destructive/10 text-destructive hover:bg-destructive/15",successTint:"bg-brand-green/10 text-brand-green hover:bg-brand-green/15",warn:"pkey pkey-warn text-white",warnTint:"bg-brand-orange/10 text-brand-orange hover:bg-brand-orange/15",neutral:"pkey pkey-outline text-foreground",subtle:"bg-black/8 text-muted-foreground"};function _e(t="brand",e){return C(Ec,Rc[t],e)}function kt({variant:t="brand",className:e,type:r="button",ref:n,...o}){return jsxRuntime.jsx("button",{ref:n,type:r,className:_e(t,e),...o})}function Ii(){let{state:t,actions:e}=q(),r=t.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",s=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",i=n?"Delete annotation":"Delete message";return jsxRuntime.jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:s}),t.actionError?jsxRuntime.jsx("div",{className:"text-[11px] font-medium text-destructive",children:t.actionError}):null,jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(kt,{variant:"neutral",disabled:t.busy,onClick:e.cancelDelete,children:"Cancel"}),jsxRuntime.jsx(kt,{variant:"destructive",disabled:t.busy,onClick:e.confirmDelete,children:t.busy?"Deleting\u2026":i})]})]})})}function Mi(){let{state:t,actions:e}=q();return t.confirmDiscardOpen?jsxRuntime.jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(kt,{variant:"neutral",onClick:()=>e.setConfirmDiscardOpen(false),children:"Keep editing"}),jsxRuntime.jsx(kt,{variant:"destructive",onClick:()=>e.forceClose(),children:"Discard"})]})]})}):null}var Ic="inline-grid place-items-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",Nc={sm:"size-7",md:"size-8"},Mc={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Rt({size:t="sm",tone:e="default",className:r,type:n="button",ref:o,...s}){return jsxRuntime.jsx("button",{ref:o,type:n,className:C(Ic,Nc[t],Mc[e],r),...s})}function _i(){let{state:t}=q();return !t.showDevFooter||!t.annotation?null:jsxRuntime.jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsx(Lc,{}),jsxRuntime.jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsxRuntime.jsx(Oc,{})})]}),t.actionError?jsxRuntime.jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:t.actionError}):null]})}function Lc(){let{state:t,actions:e}=q(),[r,n]=react.useState(false),[o,s]=react.useState(""),[i,a]=react.useState(false),l=t.runState,c=l?.status;if(t.annotation?.status==="resolved")return jsxRuntime.jsx("div",{className:"min-w-0 flex-1"});let u=c==="queued"||c==="running",p=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,m=l?"Run Patch again":"Run Patch",v=c==="failed"?"destructiveTint":"brand",f=!t.agentRunReady,b=async()=>{try{a(!0),await e.runPatch(o.trim()||void 0),s(""),n(!1);}finally{a(false);}};if(u)return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs(kt,{variant:"brandTint",disabled:true,children:[jsxRuntime.jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(p){let y=wo(l.prUrl);return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:_e("brand","no-underline"),children:[jsxRuntime.jsx(I,{name:"pr",size:12}),y==="PR"?"View PR":`View PR ${y}`]})})}let h=jsxRuntime.jsxs(kt,{variant:v,disabled:t.busy||f,className:f?"opacity-60":void 0,onClick:()=>n(true),children:[jsxRuntime.jsx(Ie,{size:12})," ",m]});return jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[f&&t.agentRunSetupMessage?jsxRuntime.jsx(ot,{text:t.agentRunSetupMessage,tone:"warning",children:h}):h,r?jsxRuntime.jsx(Dc,{title:m,guidance:o,submitting:i||t.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:b}):null]})}function Dc({title:t,guidance:e,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:s}){return jsxRuntime.jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsxRuntime.jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxRuntime.jsxs("form",{role:"dialog","aria-label":t,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-xl bg-popover p-4 shadow-dialog",onSubmit:i=>{i.preventDefault(),s();},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg bg-brand text-white",children:jsxRuntime.jsx(Ie,{size:13})}),jsxRuntime.jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:t})]}),jsxRuntime.jsx(Rt,{size:"sm",title:"Close",onClick:o,children:jsxRuntime.jsx(I,{name:"x",size:12})})]}),jsxRuntime.jsxs("label",{className:"flex flex-col gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsxRuntime.jsx("textarea",{value:e,onChange:i=>n(i.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-md border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(kt,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsxRuntime.jsx(kt,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function Oc(){let{state:t,actions:e}=q();return t.annotation?t.annotation.status==="resolved"?jsxRuntime.jsxs(kt,{variant:"neutral",disabled:t.busy,onClick:()=>e.reopen(),children:[jsxRuntime.jsx(I,{name:"refresh",size:12}),"Reopen"]}):jsxRuntime.jsxs(kt,{variant:"neutral",disabled:t.busy,onClick:()=>e.markResolved(),children:[jsxRuntime.jsx(I,{name:"check",size:12}),"Resolve"]}):null}var zc={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"};function Ht(t,e){let r=t?.replace(/\s+/g," ").trim();return r?r.length<=e?r:`${r.slice(0,e-1)}...`:null}function Di(t){let e=t?.trim();return e||null}function qt(t){return Number.isInteger(t)?String(t):t.toFixed(1)}function Hc(t){let e=t.viewport??"desktop",r=zc[e],n=t.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function Fc(t){let e=t.coordinates,r=[`viewport (${qt(e.viewportX)}, ${qt(e.viewportY)})`,`documentY ${qt(e.documentY)}`];return e.isFixed&&r.push("fixed"),r.join(", ")}function $c(t){let e=t.boundingBox;return e?`x ${qt(e.x)}, y ${qt(e.y)}, ${qt(e.width)}x${qt(e.height)}`:null}function Bc(t){let e=t.domHints?.attributeSignature;if(!e)return null;let r=Object.entries(e).slice(0,12).map(([n,o])=>`${n}="${Ht(o,120)??""}"`);return r.length>0?r.join(", "):null}function Vc(t){let e=[`- Page: ${t.url}`,`- Element: ${Ht(t.elementPath||t.element,500)??"unknown"}`,`- Viewport: ${Hc(t)}`,`- Anchor: ${Fc(t)}`],r=Ht(t.targetLabel,160),n=$c(t);return r&&e.push(`- Visible target: ${r}`),n&&e.push(`- Bounding box: ${n}`),`## Target
2272
+ `;var oi="patch-widget-root";function ii({children:t}){let[e,r]=react.useState(null),n=react.useRef(null);return react.useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(oi);o||(o=document.createElement(oi),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let s=o.shadowRoot??o.attachShadow({mode:"open"});if(!s.querySelector("style[data-patch-css]")){let a=document.createElement("style");a.setAttribute("data-patch-css",""),a.textContent=ni,s.appendChild(a);}let i=s.querySelector("div[data-patch-mount]");return i||(i=document.createElement("div"),i.setAttribute("data-patch-mount",""),s.appendChild(i)),r(i),()=>{}},[]),e?reactDom.createPortal(t,e):null}var ic=/[\s#.:[\]()>+~,\\]/;function ac(t){return !(!t||ic.test(t)||/^\d/.test(t))}function sc(t){let e=1,r=t.previousElementSibling,n=t.tagName;for(;r;)r.tagName===n&&e++,r=r.previousElementSibling;return e}function ai(t,e,r){try{let n=t.querySelectorAll(e);return n.length===1&&n[0]===r}catch{return false}}function lc(t,e){return t.id&&ac(t.id)&&(!e||ai(e,`#${t.id}`,t))?`#${t.id}`:`${t.tagName.toLowerCase()}:nth-of-type(${sc(t)})`}function si(t,e){if(!t.tagName)return "";let r=t.ownerDocument??null,n=[],o=t,s=0;for(;o&&s<12;){let i=lc(o,r);if(n.unshift(i),i.startsWith("#"))break;let a=n.join(" > ");if(r&&ai(r,a,t))return a;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,s++;}return n.join(" > ")}var cc=80,dc=500;function ci(t){return t!==null&&typeof t=="object"}function uc(t){return ci(t)?"return"in t||"type"in t||"elementType"in t||"_debugOwner"in t:false}function pr(t){if(typeof t=="function")return t.displayName||t.name||null;if(!ci(t))return null;let e=t.displayName;if(typeof e=="string"&&e)return e;let r=pr(t.render);if(r)return r;let n=pr(t.type);return n||null}function di(t){return t.replace(/\s+/g," ").trim()}function ui(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function pc(t){let e=di(t).replace(/[<>]/g,"");return !e||/^[a-z]/.test(e)?null:ui(e,cc)}function mc(t){let e=pr(t.elementType)??pr(t.type);return e?pc(e):null}function li(t){return ui(di(t),dc)}function gc(t){let e=t.replace(/\\/g,"/");return e.includes("/.next/")||e.includes("/node_modules/next/")||e.includes("/node_modules/react/")||e.includes("/node_modules/react-dom/")||e.includes("/node_modules/react-router/")||e.includes("/node_modules/react-router-dom/")||e.includes("/node_modules/@remix-run/")||e.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(e)}function fc(t){let e=t.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=e.lastIndexOf(n);if(o>=0)return li(e.slice(o+1))}let r=e.split("/").filter(Boolean);return li(r.slice(-3).join("/"))}function hc(t){let e=t._debugSource?.fileName;return typeof e!="string"||!e.trim()||gc(e)?null:fc(e)}function bc(t){let e=t;for(let r of Object.getOwnPropertyNames(t)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=e[r];if(uc(n))return n}return null}function pi(t){let e=bc(t);if(!e)return null;let r=[],n=null,o=0;for(;e&&o<30;){let a=mc(e),l=a?Sr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=hc(e)),e=e.return??e._debugOwner??null,o+=1;}let s=r.length>0?Nn(r.reverse().map(a=>`<${a}>`).join(" ")):null,i={};return s&&(i.reactComponents=s),n&&(i.sourceFile=n),Object.keys(i).length>0?i:null}var mi=500;function vc(t){return t.length<=mi?t:t.slice(0,mi)}function xc(t){return {viewportX:t.viewportX,viewportY:t.viewportY,documentY:t.viewportY+t.scrollY,isFixed:false}}function wc(t){return {x:t.x,y:t.y,width:t.width,height:t.height}}function yc(t){let e={cssSelector:si(t)},r=qe(t);r&&(e.textSignature=r);let n=Ke(t);return Object.keys(n).length>0&&(e.attributeSignature=n),e}function gi(t){return Se(t.element,t.selectedText)}function fi(t){let{target:e,click:r,comment:n,url:o}=t,s=e.element,i=e.rect,a=Un(s),l=Gn(s),c=Ae(s),d=Xn(s),u=pi(s),p={comment:n,element:Xe(s),elementPath:Yn(s),targetLabel:Se(s,e.selectedText),timestamp:Date.now(),url:Gt(o),kind:"feedback",coordinates:xc(r),boundingBox:wc(i),domHints:yc(s)};return e.selectedText&&(p.selectedText=vc(e.selectedText)),l&&(p.nearbyText=l),c.length>0&&(p.cssClasses=c),d.length>0&&(p.nearbyElements=d),a&&(p.accessibility=a),u?.reactComponents&&(p.reactComponents=u.reactComponents),u?.sourceFile&&(p.sourceFile=u.sourceFile),p}var kc=2e3,Cc=.82,Ac=.85;function bi(t,e,r){return new Promise(n=>t.toBlob(n,e,r))}function vi(t){return t.startsWith("image/")&&t!=="image/gif"}async function xi(t){let e;try{e=await createImageBitmap(t);}catch{return null}try{let r=Math.min(1,kc/Math.max(e.width,e.height)),n=Math.max(1,Math.round(e.width*r)),o=Math.max(1,Math.round(e.height*r));if(r===1&&t.size<=3145728){let l=new Uint8Array(await t.slice(0,16).arrayBuffer()),c=Pn(l);if(c==="image/webp"||c==="image/jpeg")return {blob:c===t.type?t:new Blob([t],{type:c}),width:n,height:o}}let s=document.createElement("canvas");s.width=n,s.height=o;let i=s.getContext("2d");if(!i)return null;i.drawImage(e,0,0,n,o);let a=await bi(s,"image/webp",Cc);return (!a||a.type!=="image/webp")&&(a=await bi(s,"image/jpeg",Ac)),!a||a.size>3145728?null:{blob:a,width:n,height:o}}finally{e.close();}}async function Me(t,e){return t.kind==="composer"?e.createAnnotation(t.payload):e.reply(t.annotationId,{content:t.content,attachmentIds:t.attachmentIds})}async function wi(t,e){return e.resolve(t)}async function yi(t,e){return e.deleteAnnotation(t)}async function ki(t,e){return e.deleteMessage(t.annotationId,t.messageId)}async function Ci(t,e){return t.viewerKind!=="studio"?null:e.reopen(t.annotationId)}async function Ai(t,e){return t.viewerKind!=="studio"?null:e.kickoff(t.annotationId,{guidance:t.guidance})}async function Si(t,e){return e.postIdentity(t)}var Ri=react.createContext(null),Ei=0;function mr(t){return Ei+=1,`${t}-${Date.now().toString(36)}-${Ei}`}function Xr(t){return t.deliveryStatus==="sending"||t.deliveryStatus==="failed"}function Pi({annotation:t,draftTargetLabel:e,children:r}){let n=rt(),o=ft(),s=mt(),[i,a]=react.useState(false),[l,c]=react.useState(null),[d,u]=react.useState(null),p=react.useRef(false),m=t?.thread??[],v=t?.latestRun??null,f=t?.status==="resolved",b=t?Xr(t):false,h=n.viewerKind,y=react.useCallback(()=>h==="studio"?{role:"studio",authorId:n.studio?.userId??null,authorName:n.studio?.name??null,authorImage:n.studio?.image??null}:{role:"client",authorId:n.identity?.clientUserId??null,authorName:n.identity?.name??null,authorImage:null},[n.identity,n.studio,h]),T=react.useMemo(()=>y(),[y]),x=!!t&&t.deliveryStatus!=="sending"&&t.deliveryStatus!=="failed"&&!!T.authorId&&t.payload.authorRole===T.role&&t.payload.authorId===T.authorId,z=react.useCallback((S,O)=>{let L=y();return {id:mr("tmp-msg"),role:L.role,authorId:L.authorId,authorName:L.authorName,authorImage:L.authorImage,content:S,createdAt:new Date().toISOString(),deliveryStatus:"sending",attachments:O}},[y]),D=react.useCallback(async(S,O="upload")=>{let L=Array.from(S).filter(V=>vi(V.type));await Promise.all(L.map(async V=>{let B=await xi(V);if(!B)return;let $=mr("tmp-att"),lt=URL.createObjectURL(B.blob);if(!o.addDraftAttachment({localId:$,status:"uploading",previewUrl:lt,width:B.width,height:B.height,kind:O,attachment:null})){URL.revokeObjectURL(lt);return}let Yt=await n.apiClient.uploadAttachment(B.blob,{kind:O,width:B.width,height:B.height});o.updateDraftAttachment($,Yt?{status:"uploaded",attachment:Yt}:{status:"failed"});}));},[o,n.apiClient]),g=react.useCallback(async S=>{if(p.current)return Promise.reject(new Error("busy"));p.current=true,a(true);try{return await S()}finally{p.current=false,a(false);}},[]),I=react.useCallback(async()=>{let S=o.draftText.trim(),O=o.draftAttachments.flatMap(et=>et.status==="uploaded"&&et.attachment?[et.attachment]:[]);if(o.draftAttachments.some(et=>et.status!=="uploaded"))return;if(t){if(!S&&O.length===0||f||Xr(t))return;let et=z(S,O);o.setDraftText(""),o.clearDraftAttachments(),n.updateAnnotation(t.id,It=>({...It,thread:[...It.thread,et]}));let we=await Me({kind:"reply",annotationId:t.id,content:S,attachmentIds:O.map(It=>It.id)},n.apiClient);if(we){let It=we.attachments??[];n.updateAnnotation(t.id,Jt=>({...Jt,thread:Jt.thread.map(hr=>hr.id===et.id?{...hr,id:we.id,deliveryStatus:"sent",attachments:It}:hr)})),It.length<O.length&&c("Some images expired before sending and were removed."),n.refresh();return}n.updateAnnotation(t.id,It=>({...It,thread:It.thread.map(Jt=>Jt.id===et.id?{...Jt,deliveryStatus:"failed"}:Jt)}));return}if(!S)return;let L=o.active;if(!L||L.kind!=="composer")return;let V=L.target,B={viewportX:L.anchor.viewportX,viewportY:L.anchor.viewportY,scrollY:L.anchor.documentY-L.anchor.viewportY},$=s.getPageUrl(),lt=rn(n.activeViewport,s.getTargetViewport()),St=fi({target:V,click:B,comment:S,url:$});St.viewport=n.activeViewport,St.viewportSize=lt,St.attachmentIds=O.map(et=>et.id);let Yt=y(),$e=mr("tmp-ann");n.applyAnnotationUpdate({id:$e,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:Yt.authorName,authorImage:Yt.authorImage,payload:{...St,authorRole:Yt.role,authorId:Yt.authorId},attachments:O,thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting($e);let xe=await Me({kind:"composer",payload:St},n.apiClient);if(xe){let et=xe.attachments??[];n.replaceAnnotationId($e,xe.id),n.updateAnnotation(xe.id,we=>({...we,attachments:et})),et.length<O.length&&c("Some images expired before sending and were removed."),o.openExisting(xe.id),n.refresh();return}n.updateAnnotation($e,et=>({...et,deliveryStatus:"failed"}));},[t,y,f,z,n,o,s]),U=react.useCallback(async S=>{if(!t||Xr(t))return;let O=t.thread.find(V=>V.id===S);if(!O||O.deliveryStatus!=="failed")return;n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"sending"}:B)}));let L=await Me({kind:"reply",annotationId:t.id,content:O.content,attachmentIds:(O.attachments??[]).map(V=>V.id)},n.apiClient);if(L){n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,id:L.id,deliveryStatus:"sent"}:B)})),n.refresh();return}n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"failed"}:B)}));},[t,n]),at=react.useCallback(async()=>{if(!t||t.deliveryStatus!=="failed")return;let S=t.id;n.updateAnnotation(S,L=>({...L,deliveryStatus:"sending"}));let O=await Me({kind:"composer",payload:t.payload},n.apiClient);if(O){n.replaceAnnotationId(S,O.id),o.openExisting(O.id),n.refresh();return}n.updateAnnotation(S,L=>({...L,deliveryStatus:"failed"}));},[t,n,o]),pt=react.useCallback(S=>!T.authorId||S.deliveryStatus&&S.deliveryStatus!=="sent"?false:S.role===T.role&&S.authorId===T.authorId,[T]),vt=react.useCallback(()=>{x&&(c(null),u({kind:"annotation"}));},[x]),st=react.useCallback(S=>{pt(S)&&(c(null),u({kind:"message",messageId:S.id}));},[pt]),Q=react.useCallback(()=>{c(null),u(null);},[]),K=react.useCallback(async S=>{if(!t)return false;let O=t.thread;return g(async()=>(c(null),n.updateAnnotation(t.id,V=>({...V,thread:V.thread.filter(B=>B.id!==S)})),await ki({annotationId:t.id,messageId:S},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(t.id,V=>({...V,thread:O})),c("Couldn't delete message. Try again."),false)))},[t,n,g]),k=react.useCallback(async()=>!t||!x?false:g(async()=>(c(null),await yi(t.id,n.apiClient)?(n.updateAnnotation(t.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[t,x,n,o,g]),R=react.useCallback(async()=>{if(d)try{(d.kind==="annotation"?await k():await K(d.messageId))&&u(null);}catch{c("Couldn't delete. Try again.");}},[d,k,K]),M=react.useCallback(async()=>{t&&await g(async()=>{c(null);let S={status:t.status,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt,optimisticAction:t.optimisticAction};if(n.updateAnnotation(t.id,L=>({...L,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await wi(t.id,n.apiClient)){n.updateAnnotation(t.id,L=>({...L,...S})),c("Couldn't resolve. Try again.");return}n.refresh();});},[t,n,g]),A=react.useCallback(async()=>{t&&await g(async()=>{c(null);let S={status:t.status,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt,optimisticAction:t.optimisticAction};if(n.updateAnnotation(t.id,L=>({...L,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await Ci({annotationId:t.id,viewerKind:h},n.apiClient)){n.updateAnnotation(t.id,L=>({...L,...S})),c("Couldn't reopen. Try again.");return}n.refresh();});},[t,h,n,g]),H=react.useCallback(async S=>{t&&await g(async()=>{c(null);let O=t.latestRun,L=t.optimisticAction;n.updateAnnotation(t.id,B=>({...B,latestRun:{id:mr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let V=await Ai({annotationId:t.id,viewerKind:h,guidance:S},n.apiClient);if(!V?.ok){n.updateAnnotation(t.id,B=>({...B,latestRun:O,optimisticAction:L})),c(V?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[t,h,n,g]),F=react.useCallback(async S=>{let O=await Si({...S,avatarSeed:n.clientAvatarSeed},n.apiClient);return O&&await n.setIdentity(O),O},[n]),tt=h==="client"&&!n.identity&&m.length===0,xt=!!t||m.length>0,P=n.agentRunReadiness?.ready??true,W=n.agentRunReadiness?.message??null,_=react.useCallback(()=>{if(o.hasDraft){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),G=t?Jn(t.payload):e||"annotation",wt=t?.payload.viewport??n.activeViewport,yt=n.studio?n.studio.name:n.identity?.name??null,Ut=n.identity?.avatarSeed??n.clientAvatarSeed,ze=n.studio?.userId??Ut,He=n.studio?.image??null,Fe=n.studio?.userId??Ut,fr=react.useMemo(()=>({state:{annotation:t,messages:m,runState:v,draftText:o.draftText,draftAttachments:o.draftAttachments,busy:i,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:h==="studio",agentRunReady:P,agentRunSetupMessage:W,needsIdentity:tt,isResolved:f,initialMessageLocked:b,threadVisible:xt,canDeleteAnnotation:x},actions:{setDraftText:o.setDraftText,attachFiles:D,removeDraftAttachment:o.removeDraftAttachment,submit:I,retryMessage:U,retryInitialMessage:at,requestDeleteAnnotation:vt,requestDeleteMessage:st,canDeleteMessage:pt,cancelDelete:Q,confirmDelete:R,markResolved:M,reopen:A,runPatch:H,setIdentity:F,attemptClose:o.attemptClose,requestClose:_,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:G,viewport:wt,shakeNonce:o.shakeNonce,viewer:{kind:h,authorId:T.authorId,name:yt,avatarKey:ze,avatarSrc:He,generatedSeed:Fe}}}),[t,m,v,o.draftText,o.draftAttachments,o.removeDraftAttachment,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,l,d,D,I,U,at,vt,st,pt,Q,R,M,A,H,F,h,P,W,tt,f,b,xt,x,_,G,wt,T.authorId,yt,ze,He,Fe]);return jsxRuntime.jsx(Ri.Provider,{value:fr,children:r})}function j(){let t=react.use(Ri);if(!t)throw new Error("useThreadContext must be used inside <ThreadProvider>");return t}var Ic="inline-flex shrink-0 items-center justify-center gap-1.5 h-8 px-3.5 rounded-lg whitespace-nowrap text-[13px] font-semibold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",Nc={brand:"pkey pkey-brand text-white",brandTint:"bg-brand-tint text-brand hover:bg-brand-tint/70",destructive:"pkey pkey-destructive text-white",destructiveTint:"bg-destructive/10 text-destructive hover:bg-destructive/15",successTint:"bg-brand-green/10 text-brand-green hover:bg-brand-green/15",warn:"pkey pkey-warn text-white",warnTint:"bg-brand-orange/10 text-brand-orange hover:bg-brand-orange/15",neutral:"pkey pkey-outline text-foreground",subtle:"bg-black/8 text-muted-foreground"};function _e(t="brand",e){return C(Ic,Nc[t],e)}function Ct({variant:t="brand",className:e,type:r="button",ref:n,...o}){return jsxRuntime.jsx("button",{ref:n,type:r,className:_e(t,e),...o})}function Ni(){let{state:t,actions:e}=j(),r=t.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",s=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",i=n?"Delete annotation":"Delete message";return jsxRuntime.jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:s}),t.actionError?jsxRuntime.jsx("div",{className:"text-[11px] font-medium text-destructive",children:t.actionError}):null,jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(Ct,{variant:"neutral",disabled:t.busy,onClick:e.cancelDelete,children:"Cancel"}),jsxRuntime.jsx(Ct,{variant:"destructive",disabled:t.busy,onClick:e.confirmDelete,children:t.busy?"Deleting\u2026":i})]})]})})}function _i(){let{state:t,actions:e}=j();return t.confirmDiscardOpen?jsxRuntime.jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(Ct,{variant:"neutral",onClick:()=>e.setConfirmDiscardOpen(false),children:"Keep editing"}),jsxRuntime.jsx(Ct,{variant:"destructive",onClick:()=>e.forceClose(),children:"Discard"})]})]})}):null}var _c="inline-grid place-items-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",Lc={sm:"size-7",md:"size-8"},Dc={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Pt({size:t="sm",tone:e="default",className:r,type:n="button",ref:o,...s}){return jsxRuntime.jsx("button",{ref:o,type:n,className:C(_c,Lc[t],Dc[e],r),...s})}function Li(){let{state:t}=j();return !t.showDevFooter||!t.annotation?null:jsxRuntime.jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsx(zc,{}),jsxRuntime.jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsxRuntime.jsx(Fc,{})})]}),t.actionError?jsxRuntime.jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:t.actionError}):null]})}function zc(){let{state:t,actions:e}=j(),[r,n]=react.useState(false),[o,s]=react.useState(""),[i,a]=react.useState(false),l=t.runState,c=l?.status;if(t.annotation?.status==="resolved")return jsxRuntime.jsx("div",{className:"min-w-0 flex-1"});let u=c==="queued"||c==="running",p=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,m=l?"Run Patch again":"Run Patch",v=c==="failed"?"destructiveTint":"brand",f=!t.agentRunReady,b=async()=>{try{a(!0),await e.runPatch(o.trim()||void 0),s(""),n(!1);}finally{a(false);}};if(u)return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs(Ct,{variant:"brandTint",disabled:true,children:[jsxRuntime.jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(p){let y=yo(l.prUrl);return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:_e("brand","no-underline"),children:[jsxRuntime.jsx(N,{name:"pr",size:12}),y==="PR"?"View PR":`View PR ${y}`]})})}let h=jsxRuntime.jsxs(Ct,{variant:v,disabled:t.busy||f,className:f?"opacity-60":void 0,onClick:()=>n(true),children:[jsxRuntime.jsx(Ie,{size:12})," ",m]});return jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[f&&t.agentRunSetupMessage?jsxRuntime.jsx(ot,{text:t.agentRunSetupMessage,tone:"warning",children:h}):h,r?jsxRuntime.jsx(Hc,{title:m,guidance:o,submitting:i||t.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:b}):null]})}function Hc({title:t,guidance:e,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:s}){return jsxRuntime.jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsxRuntime.jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxRuntime.jsxs("form",{role:"dialog","aria-label":t,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-xl bg-popover p-4 shadow-dialog",onSubmit:i=>{i.preventDefault(),s();},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg bg-brand text-white",children:jsxRuntime.jsx(Ie,{size:13})}),jsxRuntime.jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:t})]}),jsxRuntime.jsx(Pt,{size:"sm",title:"Close",onClick:o,children:jsxRuntime.jsx(N,{name:"x",size:12})})]}),jsxRuntime.jsxs("label",{className:"flex flex-col gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsxRuntime.jsx("textarea",{value:e,onChange:i=>n(i.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-md border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Ct,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsxRuntime.jsx(Ct,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function Fc(){let{state:t,actions:e}=j();return t.annotation?t.annotation.status==="resolved"?jsxRuntime.jsxs(Ct,{variant:"neutral",disabled:t.busy,onClick:()=>e.reopen(),children:[jsxRuntime.jsx(N,{name:"refresh",size:12}),"Reopen"]}):jsxRuntime.jsxs(Ct,{variant:"neutral",disabled:t.busy,onClick:()=>e.markResolved(),children:[jsxRuntime.jsx(N,{name:"check",size:12}),"Resolve"]}):null}var $c={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"};function Ht(t,e){let r=t?.replace(/\s+/g," ").trim();return r?r.length<=e?r:`${r.slice(0,e-1)}...`:null}function Oi(t){let e=t?.trim();return e||null}function qt(t){return Number.isInteger(t)?String(t):t.toFixed(1)}function Bc(t){let e=t.viewport??"desktop",r=$c[e],n=t.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function Vc(t){let e=t.coordinates,r=[`viewport (${qt(e.viewportX)}, ${qt(e.viewportY)})`,`documentY ${qt(e.documentY)}`];return e.isFixed&&r.push("fixed"),r.join(", ")}function Wc(t){let e=t.boundingBox;return e?`x ${qt(e.x)}, y ${qt(e.y)}, ${qt(e.width)}x${qt(e.height)}`:null}function Uc(t){let e=t.domHints?.attributeSignature;if(!e)return null;let r=Object.entries(e).slice(0,12).map(([n,o])=>`${n}="${Ht(o,120)??""}"`);return r.length>0?r.join(", "):null}function Yc(t){let e=[`- Page: ${t.url}`,`- Element: ${Ht(t.elementPath||t.element,500)??"unknown"}`,`- Viewport: ${Bc(t)}`,`- Anchor: ${Vc(t)}`],r=Ht(t.targetLabel,160),n=Wc(t);return r&&e.push(`- Visible target: ${r}`),n&&e.push(`- Bounding box: ${n}`),`## Target
2270
2273
  ${e.join(`
2271
- `)}`}function Wc(t){let e=Ht(t.selectedText,1500);return e?`## Selected text
2272
- ${e}`:null}function Uc(t){let e=t.role==="studio"?"workspace":"client",r=Ht(t.authorName,80),n=r?`${e} (${r})`:e,o=Di(t.content)??"(empty)",s=t.attachments?.length??0,i=s>0?` [${s} attached image${s===1?"":"s"}, see Attached images]`:"";return `- ${n}: ${o.replace(/\n/g,`
2273
- `)}${i}`}function Li(t,e){return `- ${t.kind==="screenshot"?"Screenshot":"Image"} ${e} (${t.width}\xD7${t.height}): ${t.url}`}function Yc(t){let e=[...(t.attachments??[]).map(r=>Li(r,"attached to the feedback")),...t.thread.flatMap(r=>(r.attachments??[]).map(n=>Li(n,"attached to a thread reply")))];return e.length===0?null:`## Attached images
2274
+ `)}`}function Gc(t){let e=Ht(t.selectedText,1500);return e?`## Selected text
2275
+ ${e}`:null}function Xc(t){let e=t.role==="studio"?"workspace":"client",r=Ht(t.authorName,80),n=r?`${e} (${r})`:e,o=Oi(t.content)??"(empty)",s=t.attachments?.length??0,i=s>0?` [${s} attached image${s===1?"":"s"}, see Attached images]`:"";return `- ${n}: ${o.replace(/\n/g,`
2276
+ `)}${i}`}function Di(t,e){return `- ${t.kind==="screenshot"?"Screenshot":"Image"} ${e} (${t.width}\xD7${t.height}): ${t.url}`}function Kc(t){let e=[...(t.attachments??[]).map(r=>Di(r,"attached to the feedback")),...t.thread.flatMap(r=>(r.attachments??[]).map(n=>Di(n,"attached to a thread reply")))];return e.length===0?null:`## Attached images
2274
2277
  View these images before making changes \u2014 they usually show the exact visual issue being reported.
2275
2278
  ${e.join(`
2276
- `)}`}function Gc(t){return t.length===0?null:`## Thread
2277
- ${t.map(Uc).join(`
2278
- `)}`}function Xc(t){let e=[],r=Ht(t.reactComponents,1e3),n=Ht(t.sourceFile,500),o=Ht(t.domHints?.cssSelector,500),s=Ht(t.domHints?.textSignature,300),i=Bc(t),a=t.cssClasses?.slice(0,20).join(" ");return r&&e.push(`- React components: ${r}`),n&&e.push(`- Source file hint: ${n}`),o&&e.push(`- CSS selector: ${o}`),s&&e.push(`- Text signature: ${s}`),i&&e.push(`- Attributes: ${i}`),a&&e.push(`- CSS classes: ${a}`),e.length>0?`## Implementation hints
2279
+ `)}`}function qc(t){return t.length===0?null:`## Thread
2280
+ ${t.map(Xc).join(`
2281
+ `)}`}function jc(t){let e=[],r=Ht(t.reactComponents,1e3),n=Ht(t.sourceFile,500),o=Ht(t.domHints?.cssSelector,500),s=Ht(t.domHints?.textSignature,300),i=Uc(t),a=t.cssClasses?.slice(0,20).join(" ");return r&&e.push(`- React components: ${r}`),n&&e.push(`- Source file hint: ${n}`),o&&e.push(`- CSS selector: ${o}`),s&&e.push(`- Text signature: ${s}`),i&&e.push(`- Attributes: ${i}`),a&&e.push(`- CSS classes: ${a}`),e.length>0?`## Implementation hints
2279
2282
  ${e.join(`
2280
- `)}`:null}function Oi(t){return ["Address this feedback in the repository.",`## Feedback
2281
- ${Di(t.payload.comment)??"(no feedback text)"}`,Vc(t.payload),Wc(t.payload),Yc(t),Gc(t.thread),Xc(t.payload)].filter(Boolean).join(`
2283
+ `)}`:null}function zi(t){return ["Address this feedback in the repository.",`## Feedback
2284
+ ${Oi(t.payload.comment)??"(no feedback text)"}`,Yc(t.payload),Gc(t.payload),Kc(t),qc(t.thread),jc(t.payload)].filter(Boolean).join(`
2282
2285
 
2283
- `)}function Hi(){let{state:t,meta:e}=q(),r=t.annotation,n=Tt[e.viewport],o=r?.payload.selectedText;return jsxRuntime.jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{title:e.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:e.targetLabel}),jsxRuntime.jsx(ot,{text:Qt(e.viewport),placement:"bottom",children:jsxRuntime.jsx("span",{"data-patch-thread-viewport":e.viewport,role:"img","aria-label":Qt(e.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsxRuntime.jsx(I,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.isResolved?jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsxRuntime.jsx(I,{name:"check",size:10})," Resolved"]}):null,jsxRuntime.jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[t.showDevFooter&&r?jsxRuntime.jsx(Zc,{annotation:r}):null,jsxRuntime.jsx(Qc,{}),jsxRuntime.jsx(Jc,{})]})]})]}),o?jsxRuntime.jsx("div",{className:"rounded-lg bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsxRuntime.jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:o.length>200?`${o.slice(0,199).trim()}\u2026`:o})}):null]})}async function jc(t,e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}let r=e.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",e.body.appendChild(r),r.select();try{return e.execCommand("copy")}catch{return false}finally{r.remove();}}function Zc({annotation:t}){let[e,r]=react.useState(false),n=react.useRef(null);react.useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async s=>{await jc(Oi(t),s)&&(r(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(false),1500));};return jsxRuntime.jsx(ot,{text:e?"Copied":"Copy agent prompt",placement:"bottom",children:jsxRuntime.jsx(Rt,{"aria-label":e?"Copied agent prompt":"Copy agent prompt",onClick:s=>{o(s.currentTarget.ownerDocument);},children:jsxRuntime.jsxs("span",{className:"relative block",style:{width:14,height:14},children:[jsxRuntime.jsx("span",{className:C("absolute inset-0 grid place-items-center transition-all duration-200 ease-out",e?"scale-50 opacity-0 blur-[2px]":"scale-100 opacity-100 blur-0"),children:jsxRuntime.jsx(I,{name:"copy",size:14})}),jsxRuntime.jsx("span",{className:C("absolute inset-0 grid place-items-center text-brand-green transition-all duration-200 ease-out",e?"scale-100 opacity-100 blur-0":"scale-50 opacity-0 blur-[2px]"),children:jsxRuntime.jsx(I,{name:"check",size:13})})]})})})}function Jc(){let{actions:t}=q();return jsxRuntime.jsx(Rt,{onClick:t.requestClose,title:"Close",children:jsxRuntime.jsx(I,{name:"x",size:14})})}function Qc(){let{state:t,actions:e}=q(),[r,n]=react.useState(false);return t.canDeleteAnnotation?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Rt,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsxRuntime.jsx(I,{name:"more",size:14})}),r?jsxRuntime.jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxRuntime.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),e.requestDeleteAnnotation();},children:[jsxRuntime.jsx(I,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function nd(){return document.querySelector("patch-widget-root")?.shadowRoot?.querySelector("[data-patch-mount]")??null}function Bi({attachments:t,index:e,onClose:r,onNavigate:n}){let o=react$1.useReducedMotion(),s=nd(),i=t[e],a=t.length>1;return react.useEffect(()=>{let l=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),r();return}a&&(c.key==="ArrowRight"&&n((e+1)%t.length),c.key==="ArrowLeft"&&n((e-1+t.length)%t.length));};return document.addEventListener("keydown",l,true),()=>document.removeEventListener("keydown",l,true)},[t.length,e,a,r,n]),!s||!i?null:reactDom.createPortal(jsxRuntime.jsxs(react$1.motion.div,{initial:o?false:{opacity:0},animate:{opacity:1,transition:{duration:.15,ease:"easeOut"}},role:"dialog","aria-modal":"true","aria-label":"Image preview","data-patch-lightbox":"",className:"fixed inset-0 z-[2147483647] grid place-items-center bg-black/78 font-sans",onMouseDown:l=>{l.target===l.currentTarget&&r();},children:[jsxRuntime.jsx(react$1.motion.img,{src:i.url,alt:"",width:i.width,height:i.height,initial:o?false:{opacity:0,scale:.96},animate:{opacity:1,scale:1,transition:{duration:.18,ease:"easeOut"}},className:"max-h-[86vh] max-w-[92vw] rounded-lg object-contain shadow-[0_32px_80px_-24px_rgba(0,0,0,0.6)]",draggable:false},i.id),jsxRuntime.jsx("button",{type:"button","aria-label":"Close preview",onClick:r,className:"absolute top-4 right-4 grid size-9 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:jsxRuntime.jsx(I,{name:"x",size:15})}),a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx($i,{side:"left",label:"Previous image",onClick:()=>n((e-1+t.length)%t.length)}),jsxRuntime.jsx($i,{side:"right",label:"Next image",onClick:()=>n((e+1)%t.length)}),jsxRuntime.jsxs("span",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 rounded-full bg-white/10 px-2.5 py-1 text-[11px] font-medium tabular-nums text-white",children:[e+1," / ",t.length]})]}):null]}),s)}function $i({side:t,label:e,onClick:r}){return jsxRuntime.jsx("button",{type:"button","aria-label":e,onClick:r,className:C("absolute top-1/2 grid size-9 -translate-y-1/2 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",t==="left"?"left-4":"right-4"),children:jsxRuntime.jsx(I,{name:t==="left"?"chevron-left":"chevron-right",size:16})})}function Vi({attachments:t}){let[e,r]=react.useState(null);if(t.length===0)return null;let n=t.length===1;return jsxRuntime.jsxs("div",{className:C("mt-1.5 flex flex-wrap gap-1.5",n&&"max-w-[230px]"),children:[t.map((o,s)=>jsxRuntime.jsx("button",{type:"button","aria-label":"View image",onClick:()=>r(s),className:C("block cursor-zoom-in overflow-hidden rounded-lg ring-1 ring-black/8 transition-[filter] hover:brightness-[0.96]",n?"w-full":"size-20"),children:jsxRuntime.jsx("img",{src:o.url,alt:"",width:o.width,height:o.height,loading:"lazy",draggable:false,className:C("block h-full w-full object-cover",n&&"max-h-40"),style:n?{aspectRatio:`${o.width} / ${o.height}`}:void 0})},o.id)),e!==null?jsxRuntime.jsx(Bi,{attachments:t,index:e,onClose:()=>r(null),onNavigate:r}):null]})}function Xi(){let{state:t,actions:e,meta:r}=q(),n=react.useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,s=r.viewer.kind==="client"?r.viewer.authorId:null;return react.useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),t.threadVisible?jsxRuntime.jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:C("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",t.showDevFooter&&t.isResolved&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[t.annotation?jsxRuntime.jsx(Yi,{name:t.annotation.authorName??"Someone",createdAt:t.annotation.createdAt,content:t.annotation.payload.comment,attachments:t.annotation.attachments,authorKey:t.annotation.payload.authorId??t.annotation.authorName??t.annotation.id,avatarSrc:t.annotation.authorImage,generatedSeed:t.annotation.payload.authorRole==="client"&&t.annotation.payload.authorId===s?o:t.annotation.authorAvatarSeed??t.annotation.payload.authorId??null,deliveryStatus:t.annotation.deliveryStatus,onRetry:t.annotation.deliveryStatus==="failed"?e.retryInitialMessage:void 0}):null,t.messages.map(a=>jsxRuntime.jsx(Yi,{name:a.authorName??a.role,createdAt:a.createdAt,content:a.content,attachments:a.attachments,authorKey:a.authorId??a.authorName??a.role,avatarSrc:a.authorImage,generatedSeed:a.role==="client"&&a.authorId===s?o:a.authorAvatarSeed??a.authorId,deliveryStatus:a.deliveryStatus,canDelete:e.canDeleteMessage(a),onDelete:()=>e.requestDeleteMessage(a),onRetry:a.deliveryStatus==="failed"?()=>{e.retryMessage(a.id);}:void 0},a.id))]}):null}function Yi(t){let e=se(t.name),r=le(t.authorKey),n=t.deliveryStatus==="failed";return jsxRuntime.jsxs("div",{className:"group/message flex gap-2.5",children:[jsxRuntime.jsx(Vt,{initials:e,tint:r,src:t.avatarSrc,generatedSeed:t.generatedSeed,alt:t.name}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:t.name}),jsxRuntime.jsx("span",{className:"text-[11px] text-muted-foreground",children:rr(t.createdAt)})]}),t.canDelete&&t.onDelete?jsxRuntime.jsx(dd,{onDelete:t.onDelete}):null,t.content?jsxRuntime.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:t.content}):null,jsxRuntime.jsx(Vi,{attachments:t.attachments??[]}),n?jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsxRuntime.jsx("span",{className:"text-destructive",children:"Failed to send"}),t.onRetry?jsxRuntime.jsx("button",{type:"button",onClick:t.onRetry,className:"rounded-full bg-black/8 px-2 py-1 font-medium text-foreground transition-colors hover:bg-black/12",children:"Retry"}):null]}):null]})]})}var ld=44,cd=8;function dd({onDelete:t}){let[e,r]=react.useState(false),[n,o]=react.useState("down"),s=react.useRef(null),i=react.useCallback(()=>{let l=s.current,c=l?.closest("[data-patch-thread-scroller]");if(!l||!c){o("down");return}let d=l.getBoundingClientRect(),u=c.getBoundingClientRect(),p=u.bottom-d.bottom,m=d.top-u.top;o(p<ld+cd&&m>p?"up":"down");},[]),a=react.useCallback(()=>{r(l=>{let c=!l;return c&&i(),c});},[i]);return jsxRuntime.jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsxRuntime.jsx(Rt,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":e,"aria-haspopup":"menu",onClick:a,children:jsxRuntime.jsx(I,{name:"more",size:14})}),e?jsxRuntime.jsx("div",{role:"menu",className:C("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxRuntime.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),t();},children:[jsxRuntime.jsx(I,{name:"trash",size:13}),"Delete"]})}):null]})}function Ki({attachments:t,onRemove:e}){let r=react$1.useReducedMotion();return t.length===0?null:jsxRuntime.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:t.map(n=>jsxRuntime.jsxs(react$1.motion.div,{layout:true,initial:r?false:{opacity:0,scale:.95},animate:{opacity:1,scale:1,transition:{duration:.15,ease:"easeOut"}},exit:{opacity:0,scale:.95,transition:{duration:.12,ease:"easeOut"}},className:"group/attachment relative",children:[jsxRuntime.jsx("img",{src:n.previewUrl,alt:"",width:n.width,height:n.height,className:C("size-14 rounded-lg object-cover ring-1 ring-black/8",n.status==="failed"&&"opacity-60 ring-destructive/60")}),n.status==="uploading"?jsxRuntime.jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg bg-black/28",children:jsxRuntime.jsx("span",{className:"size-4 animate-spin rounded-full border-[1.5px] border-white/40 border-t-white"})}):null,n.status==="failed"?jsxRuntime.jsx(ot,{text:"Upload failed",placement:"top",children:jsxRuntime.jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg text-destructive",children:jsxRuntime.jsx(I,{name:"x",size:16,stroke:2.2})})}):null,jsxRuntime.jsx("button",{type:"button","aria-label":"Remove image",onClick:()=>e(n.localId),className:"absolute -top-1.5 -right-1.5 grid size-[18px] place-items-center rounded-full bg-foreground text-white opacity-0 shadow-[0_1px_4px_rgba(0,0,0,0.3)] transition-opacity group-focus-within/attachment:opacity-100 group-hover/attachment:opacity-100 focus-visible:opacity-100",children:jsxRuntime.jsx(I,{name:"x",size:9,stroke:2.4})})]},n.localId))})})}var fd={default:"w-full min-h-[60px] resize-y rounded-md border border-border bg-popover px-3 py-2 text-[13px] leading-[1.45] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",bare:"w-full resize-none self-center overflow-y-auto bg-transparent border-0 outline-none text-[13px] leading-normal text-foreground placeholder:text-muted-foreground"};function qi({variant:t="default",className:e,ref:r,...n}){return jsxRuntime.jsx("textarea",{ref:r,className:C(fd[t],e),...n})}var xd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ji="w-full rounded-md border border-border bg-popover px-2.5 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function Zi(){let{actions:t}=q(),[e,r]=react.useState(""),[n,o]=react.useState(""),[s,i]=react.useState(null),[a,l]=react.useState(false),c=react.useRef(null);return react.useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxRuntime.jsxs("form",{onSubmit:async u=>{u.preventDefault();let p=e.trim(),m=n.trim();if(!p){i("Name is required.");return}if(!xd.test(m)){i("Enter a valid email.");return}i(null),l(true);let v=await t.setIdentity({name:p,email:m});l(false),v||i("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsxRuntime.jsx("input",{ref:c,type:"text",placeholder:"Name",value:e,onChange:u=>r(u.target.value),className:ji}),jsxRuntime.jsx("input",{type:"email",placeholder:"Email",value:n,onChange:u=>o(u.target.value),className:ji}),s?jsxRuntime.jsx("div",{className:"text-xs text-destructive",children:s}):null,jsxRuntime.jsx("button",{type:"submit",disabled:a,className:C(_e("brand"),"self-end",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}var kd="image/jpeg,image/png,image/webp";function ea(){let{state:t,actions:e,meta:r}=q(),n=ei(),o=react.useRef(null),s=react.useRef(null),[i,a]=react.useState(false);if(react.useEffect(()=>{t.needsIdentity||setTimeout(()=>o.current?.focus(),0);},[t.needsIdentity]),react.useEffect(()=>{let x=o.current;if(!x)return;x.style.height="0px";let z=Math.min(x.scrollHeight,140);x.style.height=`${z}px`,a(z>28);},[t.draftText]),t.isResolved||t.initialMessageLocked)return null;if(t.needsIdentity)return jsxRuntime.jsx("div",{className:C("bg-white px-4 py-3",t.threadVisible&&"border-t border-black/6"),children:jsxRuntime.jsx(Zi,{})});let l=t.draftText.trim().length>0,c=t.draftAttachments.some(x=>x.status==="uploaded"),d=t.draftAttachments.every(x=>x.status==="uploaded"),u=(t.annotation?l||c:l)&&d,p=r.viewer.name,m=se(p),v=r.viewer.kind==="studio"?"var(--color-foreground)":le(r.viewer.avatarKey),f=x=>{x.preventDefault(),e.submit();},b=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),e.submit());},h=x=>{let z=Array.from(x.clipboardData?.items??[]).filter(O=>O.kind==="file"&&O.type.startsWith("image/")).flatMap(O=>{let g=O.getAsFile();return g?[g]:[]});z.length!==0&&(x.preventDefault(),e.attachFiles(z));},y=x=>{!x||x.length===0||(e.attachFiles(Array.from(x)),s.current&&(s.current.value=""));},T=()=>{n.begin(x=>{e.attachFiles([x],"screenshot");});};return jsxRuntime.jsx("form",{onSubmit:f,className:C("bg-white p-3",t.threadVisible&&"border-t border-black/6",t.showDevFooter&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxRuntime.jsxs("div",{className:C("bg-black/4 px-3 py-2.5 transition-colors",i||t.draftAttachments.length>0?"rounded-xl":"rounded-full"),children:[jsxRuntime.jsx(Ki,{attachments:t.draftAttachments,onRemove:e.removeDraftAttachment}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx(Vt,{initials:m,tint:v,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:p??"",className:"self-start"}),jsxRuntime.jsx(qi,{ref:o,variant:"bare",value:t.draftText,onChange:x=>e.setDraftText(x.target.value),onKeyDown:b,onPaste:h,rows:1,placeholder:t.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsxRuntime.jsx("input",{ref:s,type:"file",accept:kd,multiple:true,className:"hidden",onChange:x=>y(x.target.files)}),n.supported?jsxRuntime.jsx(ot,{text:"Capture screenshot",placement:"top",children:jsxRuntime.jsx(Rt,{"aria-label":"Capture screenshot",disabled:n.active,onClick:T,children:jsxRuntime.jsx(I,{name:"camera",size:15})})}):null,jsxRuntime.jsx(ot,{text:"Attach image",placement:"top",children:jsxRuntime.jsx(Rt,{"aria-label":"Attach image",onClick:()=>s.current?.click(),children:jsxRuntime.jsx(I,{name:"paperclip",size:15})})}),jsxRuntime.jsx(Cd,{enabled:u})]})]})})}function Cd({enabled:t}){return jsxRuntime.jsx("button",{type:"submit",disabled:!t,"aria-label":"Send",className:C("grid size-7 shrink-0 place-items-center rounded-full text-white",t?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsxRuntime.jsx(I,{name:"arrow-up",size:13})})}var Rd=[.4,0,.2,1],Pd=[.22,.61,.36,1],Id={x:-8,y:-8,origin:"top left"},na=200;function oa(t,e,r){return Math.max(e,Math.min(r,t))}function ia(t,e,r){let n={x:t.x+t.width/2,y:t.y+t.height/2},o={x:e.x+e.width/2,y:e.y+r/2};return {x:oa((n.x-o.x)*.08,-12,12),y:oa((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Nd(t,e){if(!e)return Id;let r=Ee({anchor:e,popover:{width:332,height:na},viewport:t.getOverlayViewport()});return ia(e,r,na)}function Md(t,e){return t.x===e.x&&t.y===e.y&&t.origin===e.origin}function aa({getAnchorRect:t,initialAnchorRect:e,entryDelay:r=0,children:n}){let{actions:{attemptClose:o},meta:{shakeNonce:s}}=q(),i=mt(),a=react.useRef(null),[l,c]=react.useState(()=>Nd(i,e??t())),d=react.useCallback(()=>{let m=a.current;if(!m)return;let v=t();if(!v)return;let f=m.offsetHeight||200,b=Ee({anchor:v,popover:{width:332,height:f},viewport:i.getOverlayViewport()});m.style.left=`${b.x}px`,m.style.top=`${b.y}px`,m.style.right="auto";let h=ia(v,b,f);c(y=>Md(y,h)?y:h);},[t,i]);react.useLayoutEffect(()=>{d();}),react.useEffect(()=>{let m=null,v=()=>{m===null&&(m=i.overlayWindow.requestAnimationFrame(()=>{m=null,d();}));},f=new Set([i.targetWindow,i.overlayWindow]);for(let h of f)h.addEventListener("resize",v),h.addEventListener("scroll",v,{passive:true});let b=vn(i.overlayWindow,v);return b.observe(i.overlayDocument.body),i.targetDocument.body!==i.overlayDocument.body&&b.observe(i.targetDocument.body),a.current&&b.observe(a.current),()=>{m!==null&&i.overlayWindow.cancelAnimationFrame(m);for(let h of f)h.removeEventListener("resize",v),h.removeEventListener("scroll",v);b.disconnect();}},[d,i]),react.useEffect(()=>{let m=b=>{xo(b)||o();},v=b=>{b.key==="Escape"&&o();},f=new Set([i.targetDocument,i.overlayDocument]);for(let b of f)b.addEventListener("mousedown",m,true),b.addEventListener("keydown",v);return ()=>{for(let b of f)b.removeEventListener("mousedown",m,true),b.removeEventListener("keydown",v);}},[o,i]);let u=react.useRef(s);react.useEffect(()=>{if(s===u.current)return;u.current=s;let m=a.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[s]);let p={width:`${332}px`,height:"auto",transformOrigin:l.origin};return jsxRuntime.jsx(react$1.motion.div,{ref:a,layout:true,initial:{opacity:0,x:l.x,y:l.y,scale:.985},animate:{opacity:1,x:0,y:0,scale:1,transition:{type:"spring",stiffness:560,damping:34,mass:.7,delay:r}},exit:{opacity:0,x:l.x,y:l.y,scale:.985,transition:{duration:.16,ease:Rd}},transition:{layout:{duration:.42,ease:Pd}},onLayoutAnimationComplete:d,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:p,children:n})}var ut={Root:aa,Header:Hi,Messages:Xi,Reply:ea,DevFooter:_i,ConfirmDiscard:Mi,ConfirmDelete:Ii};function sa({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxRuntime.jsxs(ut.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsxRuntime.jsx(ut.Header,{}),jsxRuntime.jsx(ut.Messages,{}),jsxRuntime.jsx(ut.Reply,{}),jsxRuntime.jsx(ut.ConfirmDiscard,{}),jsxRuntime.jsx(ut.ConfirmDelete,{})]})}function la({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxRuntime.jsxs(ut.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsxRuntime.jsx(ut.Header,{}),jsxRuntime.jsx(ut.Messages,{}),jsxRuntime.jsx(ut.Reply,{}),jsxRuntime.jsx(ut.DevFooter,{}),jsxRuntime.jsx(ut.ConfirmDiscard,{}),jsxRuntime.jsx(ut.ConfirmDelete,{})]})}var Hd="data-patch-internal";function ua(t,e,r){let n={viewportX:e,viewportY:r},o=ce(n,t.getOverlayViewport());return er(n,o)}function Fd(t,e){return t.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(e)??null}function $d(t,e){let r=Fd(t,`[data-patch-pin-id="${e}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function Bd(t,e){if(!e)return null;let r=zo({payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Hd}),n=t.targetPointToOverlay(r.position);return ua(t,n.viewportX,n.viewportY)}function da(t,e,r){if(!e)return null;if(e.kind==="existing")return $d(t,e.annotationId)??Bd(t,r);let n=t.targetPointToOverlay({viewportX:e.anchor.viewportX,viewportY:e.anchor.documentY-t.getTargetScrollY()});return ua(t,n.viewportX,n.viewportY)}function pa(){let t=ft(),e=rt(),r=mt(),n=t.active,o=react.useMemo(()=>!n||n.kind!=="existing"?null:e.annotations.find(u=>u.id===n.annotationId)??null,[n,e.annotations]),s=react.useCallback(()=>da(r,n,o),[n,o,r]),i=e.viewerKind==="studio"?la:sa,a=n&&(n.kind==="composer"||!!o),l=n?.kind==="composer"?.04:0,c=n?.kind==="composer"?mi(n.target):null,d=react.useMemo(()=>da(r,n,o),[n,o,r]);return jsxRuntime.jsx(react$1.AnimatePresence,{children:a?jsxRuntime.jsx(Ri,{annotation:o,draftTargetLabel:c,children:jsxRuntime.jsx(i,{getAnchorRect:s,initialAnchorRect:d,entryDelay:l})},"active-popover"):null})}var Ud="https://app.usepatch.dev";function Yd({children:t}){let{active:e}=rt();return e?t:null}function ma(t){let e=typeof window<"u"&&bn(window),r=react.useMemo(()=>go({prop:t.projectToken,processEnv:ho(),importMetaEnv:fo()}),[t.projectToken]),n=t.apiBase??Ud;return react.useEffect(()=>{r||console.warn(mo);},[r]),e||!r?null:jsxRuntime.jsx(oi,{children:jsxRuntime.jsx(xn,{children:jsxRuntime.jsx(En,{projectToken:r,apiBase:n,children:jsxRuntime.jsx(Yd,{children:jsxRuntime.jsx(zn,{children:jsxRuntime.jsx(po,{children:jsxRuntime.jsx(lo,{projectToken:r,children:jsxRuntime.jsx(no,{children:jsxRuntime.jsxs(ti,{children:[jsxRuntime.jsx(Wo,{}),jsxRuntime.jsx(pa,{}),jsxRuntime.jsx(Yo,{}),jsxRuntime.jsx(Mo,{})]})})})})})})})})})}var Gd=ma;
2284
- exports.Patch=ma;exports.default=Gd;
2286
+ `)}function Fi(){let{state:t,meta:e}=j(),r=t.annotation,n=Tt[e.viewport],o=r?.payload.selectedText;return jsxRuntime.jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{title:e.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:e.targetLabel}),jsxRuntime.jsx(ot,{text:Qt(e.viewport),placement:"bottom",children:jsxRuntime.jsx("span",{"data-patch-thread-viewport":e.viewport,role:"img","aria-label":Qt(e.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsxRuntime.jsx(N,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.isResolved?jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsxRuntime.jsx(N,{name:"check",size:10})," Resolved"]}):null,jsxRuntime.jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[t.showDevFooter&&r?jsxRuntime.jsx(td,{annotation:r}):null,jsxRuntime.jsx(rd,{}),jsxRuntime.jsx(ed,{})]})]})]}),o?jsxRuntime.jsx("div",{className:"rounded-lg bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsxRuntime.jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:o.length>200?`${o.slice(0,199).trim()}\u2026`:o})}):null]})}async function Qc(t,e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}let r=e.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",e.body.appendChild(r),r.select();try{return e.execCommand("copy")}catch{return false}finally{r.remove();}}function td({annotation:t}){let[e,r]=react.useState(false),n=react.useRef(null);react.useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async s=>{await Qc(zi(t),s)&&(r(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(false),1500));};return jsxRuntime.jsx(ot,{text:e?"Copied":"Copy agent prompt",placement:"bottom",children:jsxRuntime.jsx(Pt,{"aria-label":e?"Copied agent prompt":"Copy agent prompt",onClick:s=>{o(s.currentTarget.ownerDocument);},children:jsxRuntime.jsxs("span",{className:"relative block",style:{width:14,height:14},children:[jsxRuntime.jsx("span",{className:C("absolute inset-0 grid place-items-center transition-all duration-200 ease-out",e?"scale-50 opacity-0 blur-[2px]":"scale-100 opacity-100 blur-0"),children:jsxRuntime.jsx(N,{name:"copy",size:14})}),jsxRuntime.jsx("span",{className:C("absolute inset-0 grid place-items-center text-brand-green transition-all duration-200 ease-out",e?"scale-100 opacity-100 blur-0":"scale-50 opacity-0 blur-[2px]"),children:jsxRuntime.jsx(N,{name:"check",size:13})})]})})})}function ed(){let{actions:t}=j();return jsxRuntime.jsx(Pt,{onClick:t.requestClose,title:"Close",children:jsxRuntime.jsx(N,{name:"x",size:14})})}function rd(){let{state:t,actions:e}=j(),[r,n]=react.useState(false);return t.canDeleteAnnotation?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Pt,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsxRuntime.jsx(N,{name:"more",size:14})}),r?jsxRuntime.jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxRuntime.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),e.requestDeleteAnnotation();},children:[jsxRuntime.jsx(N,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function ad(){return document.querySelector("patch-widget-root")?.shadowRoot?.querySelector("[data-patch-mount]")??null}function Vi({attachments:t,index:e,onClose:r,onNavigate:n}){let o=react$1.useReducedMotion(),s=ad(),i=t[e],a=t.length>1;return react.useEffect(()=>{let l=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),r();return}a&&(c.key==="ArrowRight"&&n((e+1)%t.length),c.key==="ArrowLeft"&&n((e-1+t.length)%t.length));};return document.addEventListener("keydown",l,true),()=>document.removeEventListener("keydown",l,true)},[t.length,e,a,r,n]),!s||!i?null:reactDom.createPortal(jsxRuntime.jsxs(react$1.motion.div,{initial:o?false:{opacity:0},animate:{opacity:1,transition:{duration:.15,ease:"easeOut"}},role:"dialog","aria-modal":"true","aria-label":"Image preview","data-patch-lightbox":"",className:"fixed inset-0 z-[2147483647] grid place-items-center bg-black/78 font-sans",onMouseDown:l=>{l.target===l.currentTarget&&r();},children:[jsxRuntime.jsx(react$1.motion.img,{src:i.url,alt:"",width:i.width,height:i.height,initial:o?false:{opacity:0,scale:.96},animate:{opacity:1,scale:1,transition:{duration:.18,ease:"easeOut"}},className:"max-h-[86vh] max-w-[92vw] rounded-lg object-contain shadow-[0_32px_80px_-24px_rgba(0,0,0,0.6)]",draggable:false},i.id),jsxRuntime.jsx("button",{type:"button","aria-label":"Close preview",onClick:r,className:"absolute top-4 right-4 grid size-9 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:jsxRuntime.jsx(N,{name:"x",size:15})}),a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bi,{side:"left",label:"Previous image",onClick:()=>n((e-1+t.length)%t.length)}),jsxRuntime.jsx(Bi,{side:"right",label:"Next image",onClick:()=>n((e+1)%t.length)}),jsxRuntime.jsxs("span",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 rounded-full bg-white/10 px-2.5 py-1 text-[11px] font-medium tabular-nums text-white",children:[e+1," / ",t.length]})]}):null]}),s)}function Bi({side:t,label:e,onClick:r}){return jsxRuntime.jsx("button",{type:"button","aria-label":e,onClick:r,className:C("absolute top-1/2 grid size-9 -translate-y-1/2 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",t==="left"?"left-4":"right-4"),children:jsxRuntime.jsx(N,{name:t==="left"?"chevron-left":"chevron-right",size:16})})}function Wi({attachments:t}){let[e,r]=react.useState(null);if(t.length===0)return null;let n=t.length===1;return jsxRuntime.jsxs("div",{className:C("mt-1.5 flex flex-wrap gap-1.5",n&&"max-w-[230px]"),children:[t.map((o,s)=>jsxRuntime.jsx("button",{type:"button","aria-label":"View image",onClick:()=>r(s),className:C("block cursor-zoom-in overflow-hidden rounded-lg ring-1 ring-black/8 transition-[filter] hover:brightness-[0.96]",n?"w-full":"size-20"),children:jsxRuntime.jsx("img",{src:o.url,alt:"",width:o.width,height:o.height,loading:"lazy",draggable:false,className:C("block h-full w-full object-cover",n&&"max-h-40"),style:n?{aspectRatio:`${o.width} / ${o.height}`}:void 0})},o.id)),e!==null?jsxRuntime.jsx(Vi,{attachments:t,index:e,onClose:()=>r(null),onNavigate:r}):null]})}function Ki(){let{state:t,actions:e,meta:r}=j(),n=react.useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,s=r.viewer.kind==="client"?r.viewer.authorId:null;return react.useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),t.threadVisible?jsxRuntime.jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:C("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",t.showDevFooter&&t.isResolved&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[t.annotation?jsxRuntime.jsx(Gi,{name:t.annotation.authorName??"Someone",createdAt:t.annotation.createdAt,content:t.annotation.payload.comment,attachments:t.annotation.attachments,authorKey:t.annotation.payload.authorId??t.annotation.authorName??t.annotation.id,avatarSrc:t.annotation.authorImage,generatedSeed:t.annotation.payload.authorRole==="client"&&t.annotation.payload.authorId===s?o:t.annotation.authorAvatarSeed??t.annotation.payload.authorId??null,deliveryStatus:t.annotation.deliveryStatus,onRetry:t.annotation.deliveryStatus==="failed"?e.retryInitialMessage:void 0}):null,t.messages.map(a=>jsxRuntime.jsx(Gi,{name:a.authorName??a.role,createdAt:a.createdAt,content:a.content,attachments:a.attachments,authorKey:a.authorId??a.authorName??a.role,avatarSrc:a.authorImage,generatedSeed:a.role==="client"&&a.authorId===s?o:a.authorAvatarSeed??a.authorId,deliveryStatus:a.deliveryStatus,canDelete:e.canDeleteMessage(a),onDelete:()=>e.requestDeleteMessage(a),onRetry:a.deliveryStatus==="failed"?()=>{e.retryMessage(a.id);}:void 0},a.id))]}):null}function Gi(t){let e=se(t.name),r=le(t.authorKey),n=t.deliveryStatus==="failed";return jsxRuntime.jsxs("div",{className:"group/message flex gap-2.5",children:[jsxRuntime.jsx(Vt,{initials:e,tint:r,src:t.avatarSrc,generatedSeed:t.generatedSeed,alt:t.name}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:t.name}),jsxRuntime.jsx("span",{className:"text-[11px] text-muted-foreground",children:nr(t.createdAt)})]}),t.canDelete&&t.onDelete?jsxRuntime.jsx(md,{onDelete:t.onDelete}):null,t.content?jsxRuntime.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:t.content}):null,jsxRuntime.jsx(Wi,{attachments:t.attachments??[]}),n?jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsxRuntime.jsx("span",{className:"text-destructive",children:"Failed to send"}),t.onRetry?jsxRuntime.jsx("button",{type:"button",onClick:t.onRetry,className:"rounded-full bg-black/8 px-2 py-1 font-medium text-foreground transition-colors hover:bg-black/12",children:"Retry"}):null]}):null]})]})}var ud=44,pd=8;function md({onDelete:t}){let[e,r]=react.useState(false),[n,o]=react.useState("down"),s=react.useRef(null),i=react.useCallback(()=>{let l=s.current,c=l?.closest("[data-patch-thread-scroller]");if(!l||!c){o("down");return}let d=l.getBoundingClientRect(),u=c.getBoundingClientRect(),p=u.bottom-d.bottom,m=d.top-u.top;o(p<ud+pd&&m>p?"up":"down");},[]),a=react.useCallback(()=>{r(l=>{let c=!l;return c&&i(),c});},[i]);return jsxRuntime.jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsxRuntime.jsx(Pt,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":e,"aria-haspopup":"menu",onClick:a,children:jsxRuntime.jsx(N,{name:"more",size:14})}),e?jsxRuntime.jsx("div",{role:"menu",className:C("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxRuntime.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),t();},children:[jsxRuntime.jsx(N,{name:"trash",size:13}),"Delete"]})}):null]})}function qi({attachments:t,onRemove:e}){let r=react$1.useReducedMotion();return t.length===0?null:jsxRuntime.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:t.map(n=>jsxRuntime.jsxs(react$1.motion.div,{layout:true,initial:r?false:{opacity:0,scale:.95},animate:{opacity:1,scale:1,transition:{duration:.15,ease:"easeOut"}},exit:{opacity:0,scale:.95,transition:{duration:.12,ease:"easeOut"}},className:"group/attachment relative",children:[jsxRuntime.jsx("img",{src:n.previewUrl,alt:"",width:n.width,height:n.height,className:C("size-14 rounded-lg object-cover ring-1 ring-black/8",n.status==="failed"&&"opacity-60 ring-destructive/60")}),n.status==="uploading"?jsxRuntime.jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg bg-black/28",children:jsxRuntime.jsx("span",{className:"size-4 animate-spin rounded-full border-[1.5px] border-white/40 border-t-white"})}):null,n.status==="failed"?jsxRuntime.jsx(ot,{text:"Upload failed",placement:"top",children:jsxRuntime.jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg text-destructive",children:jsxRuntime.jsx(N,{name:"x",size:16,stroke:2.2})})}):null,jsxRuntime.jsx("button",{type:"button","aria-label":"Remove image",onClick:()=>e(n.localId),className:"absolute -top-1.5 -right-1.5 grid size-[18px] place-items-center rounded-full bg-foreground text-white opacity-0 shadow-[0_1px_4px_rgba(0,0,0,0.3)] transition-opacity group-focus-within/attachment:opacity-100 group-hover/attachment:opacity-100 focus-visible:opacity-100",children:jsxRuntime.jsx(N,{name:"x",size:9,stroke:2.4})})]},n.localId))})})}var vd={default:"w-full min-h-[60px] resize-y rounded-md border border-border bg-popover px-3 py-2 text-[13px] leading-[1.45] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",bare:"w-full resize-none self-center overflow-y-auto bg-transparent border-0 outline-none text-[13px] leading-normal text-foreground placeholder:text-muted-foreground"};function ji({variant:t="default",className:e,ref:r,...n}){return jsxRuntime.jsx("textarea",{ref:r,className:C(vd[t],e),...n})}var kd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Zi="w-full rounded-md border border-border bg-popover px-2.5 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function Ji(){let{actions:t}=j(),[e,r]=react.useState(""),[n,o]=react.useState(""),[s,i]=react.useState(null),[a,l]=react.useState(false),c=react.useRef(null);return react.useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxRuntime.jsxs("form",{onSubmit:async u=>{u.preventDefault();let p=e.trim(),m=n.trim();if(!p){i("Name is required.");return}if(!kd.test(m)){i("Enter a valid email.");return}i(null),l(true);let v=await t.setIdentity({name:p,email:m});l(false),v||i("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsxRuntime.jsx("input",{ref:c,type:"text",placeholder:"Name",value:e,onChange:u=>r(u.target.value),className:Zi}),jsxRuntime.jsx("input",{type:"email",placeholder:"Email",value:n,onChange:u=>o(u.target.value),className:Zi}),s?jsxRuntime.jsx("div",{className:"text-xs text-destructive",children:s}):null,jsxRuntime.jsx("button",{type:"submit",disabled:a,className:C(_e("brand"),"self-end",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}var Sd="image/jpeg,image/png,image/webp";function ra(){let{state:t,actions:e,meta:r}=j(),n=ri(),o=react.useRef(null),s=react.useRef(null),[i,a]=react.useState(false);if(react.useEffect(()=>{t.needsIdentity||setTimeout(()=>o.current?.focus(),0);},[t.needsIdentity]),react.useEffect(()=>{let x=o.current;if(!x)return;x.style.height="0px";let z=Math.min(x.scrollHeight,140);x.style.height=`${z}px`,a(z>28);},[t.draftText]),t.isResolved||t.initialMessageLocked)return null;if(t.needsIdentity)return jsxRuntime.jsx("div",{className:C("bg-white px-4 py-3",t.threadVisible&&"border-t border-black/6"),children:jsxRuntime.jsx(Ji,{})});let l=t.draftText.trim().length>0,c=t.draftAttachments.some(x=>x.status==="uploaded"),d=t.draftAttachments.every(x=>x.status==="uploaded"),u=(t.annotation?l||c:l)&&d,p=r.viewer.name,m=se(p),v=r.viewer.kind==="studio"?"var(--color-foreground)":le(r.viewer.avatarKey),f=x=>{x.preventDefault(),e.submit();},b=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),e.submit());},h=x=>{let z=Array.from(x.clipboardData?.items??[]).filter(D=>D.kind==="file"&&D.type.startsWith("image/")).flatMap(D=>{let g=D.getAsFile();return g?[g]:[]});z.length!==0&&(x.preventDefault(),e.attachFiles(z));},y=x=>{!x||x.length===0||(e.attachFiles(Array.from(x)),s.current&&(s.current.value=""));},T=()=>{n.begin(x=>{e.attachFiles([x],"screenshot");});};return jsxRuntime.jsx("form",{onSubmit:f,className:C("bg-white p-3",t.threadVisible&&"border-t border-black/6",t.showDevFooter&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxRuntime.jsxs("div",{className:C("bg-black/4 px-3 py-2.5 transition-colors",i||t.draftAttachments.length>0?"rounded-xl":"rounded-full"),children:[jsxRuntime.jsx(qi,{attachments:t.draftAttachments,onRemove:e.removeDraftAttachment}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx(Vt,{initials:m,tint:v,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:p??"",className:"self-start"}),jsxRuntime.jsx(ji,{ref:o,variant:"bare",value:t.draftText,onChange:x=>e.setDraftText(x.target.value),onKeyDown:b,onPaste:h,rows:1,placeholder:t.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsxRuntime.jsx("input",{ref:s,type:"file",accept:Sd,multiple:true,className:"hidden",onChange:x=>y(x.target.files)}),n.supported?jsxRuntime.jsx(ot,{text:"Capture screenshot",placement:"top",children:jsxRuntime.jsx(Pt,{"aria-label":"Capture screenshot",disabled:n.active,onClick:T,children:jsxRuntime.jsx(N,{name:"camera",size:15})})}):null,jsxRuntime.jsx(ot,{text:"Attach image",placement:"top",children:jsxRuntime.jsx(Pt,{"aria-label":"Attach image",onClick:()=>s.current?.click(),children:jsxRuntime.jsx(N,{name:"paperclip",size:15})})}),jsxRuntime.jsx(Td,{enabled:u})]})]})})}function Td({enabled:t}){return jsxRuntime.jsx("button",{type:"submit",disabled:!t,"aria-label":"Send",className:C("grid size-7 shrink-0 place-items-center rounded-full text-white",t?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsxRuntime.jsx(N,{name:"arrow-up",size:13})})}var Nd=[.4,0,.2,1],Md=[.22,.61,.36,1],_d={x:-8,y:-8,origin:"top left"},oa=200;function ia(t,e,r){return Math.max(e,Math.min(r,t))}function aa(t,e,r){let n={x:t.x+t.width/2,y:t.y+t.height/2},o={x:e.x+e.width/2,y:e.y+r/2};return {x:ia((n.x-o.x)*.08,-12,12),y:ia((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Ld(t,e){if(!e)return _d;let r=Ee({anchor:e,popover:{width:332,height:oa},viewport:t.getOverlayViewport()});return aa(e,r,oa)}function Dd(t,e){return t.x===e.x&&t.y===e.y&&t.origin===e.origin}function sa({getAnchorRect:t,initialAnchorRect:e,entryDelay:r=0,children:n}){let{actions:{attemptClose:o},meta:{shakeNonce:s}}=j(),i=mt(),a=react.useRef(null),[l,c]=react.useState(()=>Ld(i,e??t())),d=react.useCallback(()=>{let m=a.current;if(!m)return;let v=t();if(!v)return;let f=m.offsetHeight||200,b=Ee({anchor:v,popover:{width:332,height:f},viewport:i.getOverlayViewport()});m.style.left=`${b.x}px`,m.style.top=`${b.y}px`,m.style.right="auto";let h=aa(v,b,f);c(y=>Dd(y,h)?y:h);},[t,i]);react.useLayoutEffect(()=>{d();}),react.useEffect(()=>{let m=null,v=()=>{m===null&&(m=i.overlayWindow.requestAnimationFrame(()=>{m=null,d();}));},f=new Set([i.targetWindow,i.overlayWindow]);for(let h of f)h.addEventListener("resize",v),h.addEventListener("scroll",v,{passive:true});let b=wn(i.overlayWindow,v);return b.observe(i.overlayDocument.body),i.targetDocument.body!==i.overlayDocument.body&&b.observe(i.targetDocument.body),a.current&&b.observe(a.current),()=>{m!==null&&i.overlayWindow.cancelAnimationFrame(m);for(let h of f)h.removeEventListener("resize",v),h.removeEventListener("scroll",v);b.disconnect();}},[d,i]),react.useEffect(()=>{let m=b=>{wo(b)||o();},v=b=>{b.key==="Escape"&&o();},f=new Set([i.targetDocument,i.overlayDocument]);for(let b of f)b.addEventListener("mousedown",m,true),b.addEventListener("keydown",v);return ()=>{for(let b of f)b.removeEventListener("mousedown",m,true),b.removeEventListener("keydown",v);}},[o,i]);let u=react.useRef(s);react.useEffect(()=>{if(s===u.current)return;u.current=s;let m=a.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[s]);let p={width:`${332}px`,height:"auto",transformOrigin:l.origin};return jsxRuntime.jsx(react$1.motion.div,{ref:a,layout:true,initial:{opacity:0,x:l.x,y:l.y,scale:.985},animate:{opacity:1,x:0,y:0,scale:1,transition:{type:"spring",stiffness:560,damping:34,mass:.7,delay:r}},exit:{opacity:0,x:l.x,y:l.y,scale:.985,transition:{duration:.16,ease:Nd}},transition:{layout:{duration:.42,ease:Md}},onLayoutAnimationComplete:d,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:p,children:n})}var ut={Root:sa,Header:Fi,Messages:Ki,Reply:ra,DevFooter:Li,ConfirmDiscard:_i,ConfirmDelete:Ni};function la({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxRuntime.jsxs(ut.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsxRuntime.jsx(ut.Header,{}),jsxRuntime.jsx(ut.Messages,{}),jsxRuntime.jsx(ut.Reply,{}),jsxRuntime.jsx(ut.ConfirmDiscard,{}),jsxRuntime.jsx(ut.ConfirmDelete,{})]})}function ca({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxRuntime.jsxs(ut.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsxRuntime.jsx(ut.Header,{}),jsxRuntime.jsx(ut.Messages,{}),jsxRuntime.jsx(ut.Reply,{}),jsxRuntime.jsx(ut.DevFooter,{}),jsxRuntime.jsx(ut.ConfirmDiscard,{}),jsxRuntime.jsx(ut.ConfirmDelete,{})]})}var Bd="data-patch-internal";function pa(t,e,r){let n={viewportX:e,viewportY:r},o=ce(n,t.getOverlayViewport());return rr(n,o)}function Vd(t,e){return t.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(e)??null}function Wd(t,e){let r=Vd(t,`[data-patch-pin-id="${e}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function Ud(t,e){if(!e)return null;let r=Ho({payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Bd}),n=t.targetPointToOverlay(r.position);return pa(t,n.viewportX,n.viewportY)}function ua(t,e,r){if(!e)return null;if(e.kind==="existing")return Wd(t,e.annotationId)??Ud(t,r);let n=t.targetPointToOverlay({viewportX:e.anchor.viewportX,viewportY:e.anchor.documentY-t.getTargetScrollY()});return pa(t,n.viewportX,n.viewportY)}function ma(){let t=ft(),e=rt(),r=mt(),n=t.active,o=react.useMemo(()=>!n||n.kind!=="existing"?null:e.annotations.find(u=>u.id===n.annotationId)??null,[n,e.annotations]),s=react.useCallback(()=>ua(r,n,o),[n,o,r]),i=e.viewerKind==="studio"?ca:la,a=n&&(n.kind==="composer"||!!o),l=n?.kind==="composer"?.04:0,c=n?.kind==="composer"?gi(n.target):null,d=react.useMemo(()=>ua(r,n,o),[n,o,r]);return jsxRuntime.jsx(react$1.AnimatePresence,{children:a?jsxRuntime.jsx(Pi,{annotation:o,draftTargetLabel:c,children:jsxRuntime.jsx(i,{getAnchorRect:s,initialAnchorRect:d,entryDelay:l})},"active-popover"):null})}var Xd="https://app.usepatch.dev";function Kd({children:t}){let{active:e}=rt();return e?t:null}function ga(t){let e=typeof window<"u"&&xn(window),r=react.useMemo(()=>fo({prop:t.projectToken,processEnv:bo(),importMetaEnv:ho()}),[t.projectToken]),n=t.apiBase??Xd;return react.useEffect(()=>{r||console.warn(go);},[r]),e||!r?null:jsxRuntime.jsx(Je,{children:jsxRuntime.jsx(ii,{children:jsxRuntime.jsx(yn,{children:jsxRuntime.jsx(Rn,{projectToken:r,apiBase:n,children:jsxRuntime.jsx(Kd,{children:jsxRuntime.jsx(Hn,{children:jsxRuntime.jsx(mo,{children:jsxRuntime.jsx(co,{projectToken:r,children:jsxRuntime.jsx(oo,{children:jsxRuntime.jsxs(ei,{children:[jsxRuntime.jsx(Uo,{}),jsxRuntime.jsx(ma,{}),jsxRuntime.jsx(Go,{}),jsxRuntime.jsx(_o,{})]})})})})})})})})})})}var qd=ga;
2287
+ exports.Patch=ga;exports.default=qd;