@usepatch/widget 0.6.0 → 0.7.1
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 +13 -13
- package/dist/index.js +13 -13
- package/package.json +9 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {createContext,useMemo,useEffect,Component,useState,useRef,useCallback,useLayoutEffect,use,createElement,useId}from'react';import {AnimatePresence,useReducedMotion,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';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=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]=useState(()=>({viewport:c,width:a,height:l,scale:We(r,a,l)})),[v,f]=useState("stable"),[b,h]=useState(false),[y,T]=useState(false),x=useRef(false),z=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=useCallback(E=>{z.current=E,n(E);},[n]),vt=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=useCallback(()=>{m(E=>{let tt=We(r,E.width,E.height);return E.scale===tt?E:{...E,scale:tt}});},[r]);useEffect(()=>(st(),r.addEventListener("resize",st),()=>r.removeEventListener("resize",st)),[r,st]),useEffect(()=>{x.current=false,h(false),T(false);let E=r.setTimeout(()=>{x.current||T(true);},xa);return ()=>r.clearTimeout(E)},[t,r]),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]),useEffect(()=>{o(at);},[at,o]),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 jsx(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:jsxs(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:[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: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}})}),jsx(Oa,{visible:y})]})})}function Oa({visible:t}){return t?jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children: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=createContext(null),hn=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=useMemo(()=>vn(),[]),[r,n]=useState("desktop"),[o,s]=useState(null),[i,a]=useState(false),[l,c]=useState(false),[d,u]=useState(false),p=r!=="desktop",m=p||d,v=Tt[r],f=v.width&&v.height?{width:v.width,height:v.height}:null;useEffect(()=>{a(false),c(false);},[r]);let b=useRef(p);useEffect(()=>{b.current&&!p?u(true):!b.current&&p&&u(false),b.current=p;},[p]);let h=useMemo(()=>e?!p||!i||l||!o||!f?e:Ba(e,o,f)??e:null,[l,o,i,p,f,e]),y=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?p&&i&&!l:true,previewBlocked:p&&l}),[r,l,i,p,m]),T=useMemo(()=>e?$a(e.targetWindow):"",[e]);return !h||!e?null:jsx(hn.Provider,{value:y,children:jsxs(fn.Provider,{value:h,children:[t,jsx(AnimatePresence,{onExitComplete:()=>u(false),children:p&&f?jsx(un,{src:T,viewport:v,overlayWindow:e.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function mt(){let t=use(fn),e=useMemo(()=>vn(),[]);if(t)return t;if(e)return e;throw new Error("useTargetSurface must run in a browser document")}function ne(){let t=use(hn),[e,r]=useState("desktop"),n=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=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]=useState(()=>typeof window>"u"?null:Cr(t)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":Sn(t)),[c,d]=useState(null),[u,p]=useState("client"),[m,v]=useState(null),[f,b]=useState([]),[h,y]=useState(null),[T,x]=useState([]),[z,D]=useState(false),[g,I]=useState(null),U=useRef(g);U.current=g;let at=useRef(o);at.current=o;let pt=h===o,vt=useMemo(()=>kn({apiBase:e,token:t,clientUserId:i?.clientUserId,clientSecret:i?.secret}),[e,t,i?.clientUserId,i?.secret]),st=useRef(vt);st.current=vt;let Q=useRef(0),K=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=useRef(K);k.current=K,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]),useEffect(()=>{!z||!g||K();},[z,g,K]),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]),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=useCallback(async P=>(Ar(t,P),a(P),P),[t]),M=useCallback(()=>{a(null),An(t);},[t]),A=useCallback(P=>{x(W=>[...W.filter(_=>_.tempId!==P.tempId),P]);},[]),H=useCallback(P=>{x(W=>W.filter(_=>_.tempId!==P));},[]),F=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=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=useCallback((P,W)=>{b(_=>_.map(G=>G.id===P?{...G,id:W,deliveryStatus:"sent"}:G));},[]),xt=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 jsx(En.Provider,{value:xt,children:r})}function rt(){let t=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=createContext(null);function Hn({children:t}){let[e,r]=useState(null),[n,o]=useState(""),[s,i]=useState([]),[a,l]=useState(0),[c,d]=useState(false),u=useRef([]),p=useCallback(()=>{for(let g of u.current)URL.revokeObjectURL(g.previewUrl);u.current=[],i([]);},[]),m=useCallback(()=>{r(null),o(""),p(),d(false);},[p]),v=useCallback(g=>{r({kind:"existing",annotationId:g}),o(""),p(),d(false);},[p]),f=useCallback(g=>{r({kind:"composer",...g}),o(""),p(),d(false);},[p]),b=useCallback(g=>u.current.length>=4?false:(u.current=[...u.current,g],i(u.current),true),[]),h=useCallback((g,I)=>{u.current=u.current.map(U=>U.localId===g?{...U,...I}:U),i(u.current);},[]),y=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=useCallback(()=>{if(n.trim().length>0||u.current.length>0){l(g=>g+1);return}m();},[n,m]),x=useCallback(()=>{m();},[m]),z=n.trim().length>0||s.length>0,D=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 jsx(zn.Provider,{value:D,children:t})}function ft(){let t=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(`,
|
|
2
|
+
import {LazyMotion,domAnimation,AnimatePresence,useReducedMotion,m}from'motion/react';import {createContext,useMemo,useEffect,Component,useState,useRef,useCallback,useLayoutEffect,use,createElement,useId}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';function Jr(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 ha=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 ba(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function Qr(t){return t.replace(/\s+/g," ").trim()}function hr(t){return ha.has(Qr(t))}function va(t){return t.length<2||t.startsWith("_")?false:/^[A-Z]/.test(t)}function tn(t){if(!t)return null;let e=[],r=t.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Qr(n[1]??"");!o||hr(o)||va(o)&&e[e.length-1]!==o&&e.push(o);}return e.length===0?null:ba(e.map(n=>`<${n}>`).join(" "),1e3)}var en="seed:";function We(t){return t?t.startsWith(en)?{url:null,seed:t.slice(en.length)||null}:/^https?:\/\//i.test(t)?{url:t,seed:null}:{url:null,seed:t}:{url:null,seed:null}}var br=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],rn=[{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]}],nn=Math.PI*2;function xa(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 wa(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 Z(t,e,r){return e+t()*(r-e)}function bt(t,e=3){let r=10**e;return Math.round(t*r)/r}function on(t,e,r){return `hsl(${bt((t%360+360)%360,1)} ${bt(e,1)}% ${bt(r,1)}%)`}function an(t){let e=xa(t?.trim()||"patch-client"),r=wa(e),n=e.toString(36),o=(br[e%br.length]??br[0])+Z(r,-10,10),s=r()<.5?-1:1,i=r()<.5?-1:1,a=o+i*Z(r,52,116),l=o-i*Z(r,26,66),c=o+s*Z(r,12,38),d=on(o+s*Z(r,0,14),Z(r,80,92),Z(r,44,54)),u=Z(r,0,nn),p=rn.map((m,x)=>{let b=(m.hue==="accent"?a:m.hue==="accent2"?l:m.hue==="near"?c:o)+Z(r,-11,11),h=u+x/rn.length*nn+Z(r,-0.6,.6),k=Z(r,m.reach[0],m.reach[1]),E=bt(.5+Math.cos(h)*k),w=bt(.5+Math.sin(h)*k),H=bt(Z(r,0,180),1),L=bt(Z(r,.62,1.5),3),g=bt(Z(r,.62,1.5),3);return {id:`cav-${n}-${x}`,cx:E,cy:w,r:bt(Z(r,m.r[0],m.r[1])),color:on(b,Z(r,m.sat[0],m.sat[1]),Z(r,m.light[0],m.light[1])),opacity:bt(Z(r,m.opacity[0],m.opacity[1]),2),gradientTransform:`rotate(${H} ${E} ${w}) translate(${E} ${w}) scale(${L} ${g}) translate(${bt(-E)} ${bt(-w)})`}});return {id:n,background:d,spots:p,blur:bt(Z(r,3.4,5.4),2),grain:bt(Z(r,.09,.15),2)}}function Vt(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 ot(t){try{let e=new URL(t);return Vt(`${e.origin}${e.pathname}`)}catch{return Vt(t)}}var vr="patch:locationchange",sn="__patchHistoryPatched";function ya(t){let e=t.history;if(e[sn])return;e[sn]=true;let r=()=>t.dispatchEvent(new Event(vr)),{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 ln(t,e){ya(t);let r=()=>e();return t.addEventListener("popstate",r),t.addEventListener("hashchange",r),t.addEventListener(vr,r),()=>{t.removeEventListener("popstate",r),t.removeEventListener("hashchange",r),t.removeEventListener(vr,r);}}var Et={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"}},cn=["desktop","tablet","mobile"];function ee(t){let e=Et[t];return e.width===null||e.height===null?e.label:`${e.label} (${e.width}px \xD7 ${e.height}px)`}function dn(t,e){let r=Et[t];return {width:r.width??e.width,height:r.height??e.height}}var Ca=32,Aa=32,Sa=3e3,mn="cubic-bezier(0.16, 1, 0.3, 1)",Ye=[.22,.61,.36,1],gn=.3,fn=.5,Ta=.34,Ea=.5,Ra=.24,Pa=.22,hn=.12,Ia=.42,bn=.2,Na=200,Ma=260,_a=70,La=180,Da=260,Oa=8,za=4,Ha="#d9d9dd",$a=30,Fa=["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 Ge(t,e,r){let n=Math.max(320,t.innerWidth-Ca*2),o=Math.max(320,t.innerHeight-Aa*2);return Math.min(1,n/e,o/r)}function Ba(t){try{return !!(t.contentWindow&&t.contentDocument?.body)}catch{return false}}function vn({src:t,viewport:e,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:s}){let i=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$1]=useState(()=>({viewport:c,width:a,height:l,scale:Ge(r,a,l)})),[x,f]=useState("stable"),[b,h]=useState(false),[k,E]=useState(false),w=useRef(false),H=useRef(null),g=`${p.viewport}:${p.width}:${p.height}`!==d,U=b&&!k&&!(g||x==="cover"||x==="resize"),ct=b&&!k&&x==="stable"&&!g,dt=useCallback(v=>{H.current=v,n(v);},[n]),ht=useCallback(()=>{let v=H.current;if(!v||!Ba(v)){w.current=false,h(false),E(true);return}w.current=true,h(true),E(false);},[]),ut=useCallback(()=>{m$1(v=>{let $=Ge(r,v.width,v.height);return v.scale===$?v:{...v,scale:$}});},[r]);useEffect(()=>(ut(),r.addEventListener("resize",ut),()=>r.removeEventListener("resize",ut)),[r,ut]),useEffect(()=>{w.current=false,h(false),E(false);let v=r.setTimeout(()=>{w.current||E(true);},Sa);return ()=>r.clearTimeout(v)},[t,r]),useEffect(()=>{if(i){g&&m$1({viewport:c,width:a,height:l,scale:Ge(r,a,l)}),x!=="stable"&&f("stable");return}switch(x){case "stable":{g&&f("cover");return}case "cover":{let v=r.setTimeout(()=>f("resize"),_a);return ()=>r.clearTimeout(v)}case "resize":{g&&m$1({viewport:c,width:a,height:l,scale:Ge(r,a,l)});let v=r.setTimeout(()=>f("reveal"),La);return ()=>r.clearTimeout(v)}case "reveal":{let v=r.setTimeout(()=>f("stable"),Da);return ()=>r.clearTimeout(v)}}},[x,g,i,r,c,a,l]),useEffect(()=>{o(ct);},[ct,o]),useEffect(()=>{s(k);},[k,s]);let pt=i?{duration:0}:{duration:Ra,ease:Ye},rt=i?{duration:0}:{duration:Pa,ease:Ye,delay:bn*.5},j=i?{duration:0}:{duration:bn,ease:Ye},A=i?{duration:0}:{opacity:{duration:Ia,ease:Ye,delay:hn},scale:{type:"spring",bounce:Ta,duration:Ea,delay:hn},width:{type:"spring",bounce:gn,duration:fn},height:{type:"spring",bounce:gn,duration:fn}},R=(U?Ma:Na)/1e3,D=i?void 0:`opacity ${R}s ${mn}, filter ${R}s ${mn}`,G=p.width*p.scale,W=p.height*p.scale;return jsx(m.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:pt},exit:{opacity:0,transition:rt},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:jsxs(m.div,{initial:i?{opacity:0,width:G,height:W}:{opacity:0,scale:.8,width:G,height:W},animate:{opacity:1,scale:1,width:G,height:W},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:j},transition:A,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${za}px solid ${Ha}`,borderRadius:$a,boxShadow:Fa,willChange:"width, height"},children:[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(${Oa}px)`,transition:D,pointerEvents:U?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:dt,"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:ht,className:"block bg-white",style:{width:p.width,height:p.height,border:0}})}),jsx(Va,{visible:k})]})})}function Va({visible:t}){return t?jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children: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 kn=createContext(null),Cn=createContext(null),An="__patch_preview";function Sn(){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:()=>Vt(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:t=>({...t}),targetRectToOverlay:t=>({...t}),eventTargetElement:t=>t instanceof window.Element?t:null}}function Ga(t){let e=new URL(t.location.href);return e.searchParams.set(An,"1"),e.toString()}function Tn(t=window){try{return new URL(t.location.href).searchParams.get(An)==="1"}catch{return false}}function Xa(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:()=>Vt(`${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 En(t,e){let r=t.ResizeObserver??ResizeObserver;return new r(e)}function Rn({children:t}){let e=useMemo(()=>Sn(),[]),[r,n]=useState("desktop"),[o,s]=useState(null),[i,a]=useState(false),[l,c]=useState(false),[d,u]=useState(false),p=r!=="desktop",m=p||d,x=Et[r],f=x.width&&x.height?{width:x.width,height:x.height}:null;useEffect(()=>{a(false),c(false);},[r]);let b=useRef(p);useEffect(()=>{b.current&&!p?u(true):!b.current&&p&&u(false),b.current=p;},[p]);let h=useMemo(()=>e?!p||!i||l||!o||!f?e:Xa(e,o,f)??e:null,[l,o,i,p,f,e]),k=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?p&&i&&!l:true,previewBlocked:p&&l}),[r,l,i,p,m]),E=useMemo(()=>e?Ga(e.targetWindow):"",[e]);return !h||!e?null:jsx(Cn.Provider,{value:k,children:jsxs(kn.Provider,{value:h,children:[t,jsx(AnimatePresence,{onExitComplete:()=>u(false),children:p&&f?jsx(vn,{src:E,viewport:x,overlayWindow:e.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function vt(){let t=use(kn),e=useMemo(()=>Sn(),[]);if(t)return t;if(e)return e;throw new Error("useTargetSurface must run in a browser document")}function ie(){let t=use(Cn),[e,r]=useState("desktop"),n=useMemo(()=>({activeViewport:e,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[e]);return t??n}var qa="X-Patch-Client-Id",ja="X-Patch-Client-Secret";function Ct(t,e){return {...e?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${t.token}`,...t.clientUserId?{[qa]:t.clientUserId}:{},...t.clientSecret?{[ja]:t.clientSecret}:{}}}async function Mt(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 Za(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 Pn(t){return {async listAnnotations(e){let r=new URLSearchParams;e?.viewport&&r.set("viewport",e.viewport),e?.url&&r.set("url",e.url);let n=r.toString(),o=new Headers(Ct(t,false));e?.etag&&o.set("If-None-Match",e.etag);try{let s=await fetch(`${t.apiBase}/api/widget/annotations${n?`?${n}`:""}`,{method:"GET",credentials:"include",cache:"no-store",headers:o});if(s.status===304)return {status:"not-modified"};if(!s.ok)return {status:"error"};let i=s.headers.get("ETag"),a=await s.text();return {status:"ok",annotations:(a?JSON.parse(a):{}).annotations??[],etag:i}}catch{return {status:"error"}}},async listRoster(){return (await Mt(`${t.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:Ct(t,false)}))?.entries??[]},async fetchMe(){try{let e=await fetch(`${t.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:Ct(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 Mt(`${t.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:Ct(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 Mt(`${t.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:Ct(t,true),body:JSON.stringify(e)})},async reply(e,r){return Mt(`${t.apiBase}/api/widget/annotations/${e}/reply`,{method:"POST",credentials:"include",headers:Ct(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 Mt(`${t.apiBase}/api/widget/uploads?${n}`,{method:"POST",credentials:"include",headers:{...Ct(t,false),"Content-Type":e.type},body:e}))?.attachment??null},async deleteAnnotation(e){return Mt(`${t.apiBase}/api/widget/annotations/${e}`,{method:"DELETE",credentials:"include",headers:Ct(t,false)})},async deleteMessage(e,r){return Mt(`${t.apiBase}/api/widget/annotations/${e}/messages/${r}`,{method:"DELETE",credentials:"include",headers:Ct(t,false)})},async kickoff(e,r){return Za(`${t.apiBase}/api/widget/annotations/${e}/kickoff`,{method:"POST",credentials:"include",headers:Ct(t,true),body:JSON.stringify(r)})},async resolve(e){return Mt(`${t.apiBase}/api/widget/annotations/${e}/resolve`,{method:"POST",credentials:"include",headers:Ct(t,true)})},async reopen(e){return Mt(`${t.apiBase}/api/widget/annotations/${e}/reopen`,{method:"POST",credentials:"include",headers:Ct(t,true)})},async reportAnchorStatuses(e){e.length!==0&&await Mt(`${t.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:Ct(t,true),body:JSON.stringify({reports:e})});}}}var kr="patch.clientIdentity",In="patch.clientAvatarSeed";function Cr(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(kr);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function Ar(t){let e=Cr()[t];return e?.secret?e:null}function Sr(t,e){if(!(typeof window>"u"))try{let r=Cr();r[t]=e,window.localStorage.setItem(kr,JSON.stringify(r));}catch{}}function Nn(t){if(!(typeof window>"u"))try{let e=Cr();delete e[t],window.localStorage.setItem(kr,JSON.stringify(e));}catch{}}function Ja(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(In);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function yr(){let t=globalThis.crypto;return `client-avatar:${typeof t?.randomUUID=="function"?t.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function Mn(t){if(typeof window>"u")return yr();try{let e=Ja(),r=e[t];if(r)return r;let n=yr();return e[t]=n,window.localStorage.setItem(In,JSON.stringify(e)),n}catch{return yr()}}var es=2e4,Ln=createContext(null);function rs(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 Dn({projectToken:t,apiBase:e,children:r}){let n=vt(),{activeViewport:o,setActiveViewport:s}=ie(),[i,a]=useState(()=>typeof window>"u"?null:Ar(t)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":Mn(t)),[c,d]=useState(null),[u,p]=useState("client"),[m,x]=useState(null),[f,b]=useState([]),[h,k]=useState(null),[E,w]=useState([]),[H,L]=useState(false),[g,I]=useState(null),U=useRef(g);U.current=g;let ct=useRef(o);ct.current=o;let dt=h===o,ht=useMemo(()=>Pn({apiBase:e,token:t,clientUserId:i?.clientUserId,clientSecret:i?.secret}),[e,t,i?.clientUserId,i?.secret]),ut=useRef(ht);ut.current=ht;let pt=useRef(0),rt=useRef(new Map),j=useCallback(async()=>{let S=o,P=n.getPageUrl(),N=`${S}|${P}`,K=++pt.current,tt=await ut.current.listAnnotations({viewport:S==="desktop"?void 0:S,url:P,etag:rt.current.get(N)??null});if(K!==pt.current||S!==ct.current||tt.status!=="ok")return;tt.etag?rt.current.set(N,tt.etag):rt.current.delete(N);let It=tt.annotations.filter(Tt=>ot(Tt.payload.url)===P);b(Tt=>rs(Tt,It)),k(S);},[o,n]),A=useRef(j);A.current=j,useEffect(()=>{rt.current.clear();},[ht]),useEffect(()=>{let S=false;return (async()=>{let P=await ut.current.fetchMe();if(S)return;if(P.status==="unauthorized"){I(false),L(true);return}let N=P.status==="ok"?P.me:null;if(N?.active===false){I(false),L(true);return}if(I(true),N?.studio)d(N.studio),p("studio"),x(N.agentRunReadiness??{ready:true,message:null});else if(d(null),p("client"),x(null),N?.client){let K=Ar(t);if(K?.secret){let tt={clientUserId:N.client.id,name:N.client.name,email:N.client.email,avatarSeed:N.client.avatarSeed,secret:K.secret};a(tt),Sr(t,tt);}}await A.current(),S||L(true);})(),()=>{S=true;}},[t]),useEffect(()=>{!H||!g||j();},[H,g,j]),useEffect(()=>{if(!g)return;let{overlayDocument:S,overlayWindow:P}=n,N=P.setInterval(()=>{S.visibilityState==="visible"&&j();},es),K=()=>{S.visibilityState==="visible"&&j();};return S.addEventListener("visibilitychange",K),()=>{P.clearInterval(N),S.removeEventListener("visibilitychange",K);}},[g,j,n]),useEffect(()=>{if(g)return ln(n.targetWindow,()=>{let S=n.getPageUrl();b(P=>P.filter(N=>ot(N.payload.url)===S)),A.current();})},[g,n]);let R=useCallback(async S=>(Sr(t,S),a(S),S),[t]),D=useCallback(()=>{a(null),Nn(t);},[t]),G=useCallback(S=>{w(P=>[...P.filter(N=>N.tempId!==S.tempId),S]);},[]),W=useCallback(S=>{w(P=>P.filter(N=>N.tempId!==S));},[]),v=useCallback(S=>{b(P=>{let N=P.findIndex(tt=>tt.id===S.id);if(N===-1)return [...P,S];let K=P.slice();return K[N]=S,K});},[]),$=useCallback((S,P)=>{b(N=>{let K=false,tt=N.flatMap(It=>{if(It.id!==S)return [It];K=true;let Tt=P(It);return Tt?[Tt]:[]});return K?tt:N});},[]),O=useCallback((S,P)=>{b(N=>N.map(K=>K.id===S?{...K,id:P,deliveryStatus:"sent"}:K));},[]),X=useMemo(()=>({apiClient:ht,active:g,ready:H,viewerKind:u,agentRunReadiness:m,activeViewport:o,clientAvatarSeed:l,identity:i,studio:c,annotations:f,annotationsReady:dt,ephemerals:E,refresh:j,setActiveViewport:s,setIdentity:R,signOut:D,addEphemeral:G,removeEphemeral:W,applyAnnotationUpdate:v,updateAnnotation:$,replaceAnnotationId:O}),[ht,g,H,u,m,o,l,i,c,f,dt,E,j,s,R,D,G,W,v,$,O]);return jsx(Ln.Provider,{value:X,children:r})}function it(){let t=use(Ln);if(!t)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return t}var On=createContext(null);function zn({children:t}){let[e,r]=useState(null),[n,o]=useState(""),[s,i]=useState([]),[a,l]=useState(0),[c,d]=useState(false),u=useRef([]),p=useCallback(()=>{for(let g of u.current)URL.revokeObjectURL(g.previewUrl);u.current=[],i([]);},[]),m=useCallback(()=>{r(null),o(""),p(),d(false);},[p]),x=useCallback(g=>{r({kind:"existing",annotationId:g}),o(""),p(),d(false);},[p]),f=useCallback(g=>{r({kind:"composer",...g}),o(""),p(),d(false);},[p]),b=useCallback(g=>u.current.length>=4?false:(u.current=[...u.current,g],i(u.current),true),[]),h=useCallback((g,I)=>{u.current=u.current.map(U=>U.localId===g?{...U,...I}:U),i(u.current);},[]),k=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);},[]),E=useCallback(()=>{if(n.trim().length>0||u.current.length>0){l(g=>g+1);return}m();},[n,m]),w=useCallback(()=>{m();},[m]),H=n.trim().length>0||s.length>0,L=useMemo(()=>({active:e,draftText:n,draftAttachments:s,hasDraft:H,shakeNonce:a,confirmDiscardOpen:c,openExisting:x,openComposer:f,setDraftText:o,addDraftAttachment:b,updateDraftAttachment:h,removeDraftAttachment:k,clearDraftAttachments:p,attemptClose:E,forceClose:w,setConfirmDiscardOpen:d}),[e,n,s,H,a,c,x,f,b,h,k,p,E,w]);return jsx(On.Provider,{value:L,children:t})}function xt(){let t=use(On);if(!t)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return t}var Fn=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"]),cs=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"},qt=40,ds=1500,Hn=200,us=5,ps=10;function Vn(t){return Fn.has(t.tagName.toLowerCase())}function $t(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1)}\u2026`}function se(t){return `"${t}"`}function ms(t){let e="";for(let r of Array.from(t.childNodes))r.nodeType===3&&(e+=r.textContent??"");return e.replace(/\s+/g," ").trim()}function Xe(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function gs(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 Re(t){let e=Array.from(t.classList),r=e.filter(gs).slice(0,ps);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=cs.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 fs(t){let e=t.tagName.toLowerCase(),r=Bn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${se($t(n,qt))}`;let o=t.placeholder;if(o)return `${r} ${se($t(o,qt))}`;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 hs(t){let e=t.alt?.trim();return e?`img ${se($t(e,qt))}`:"img"}function Ke(t){let e=t.tagName.toLowerCase();if(e==="img")return hs(t);if(e==="input"||e==="textarea"||e==="select")return fs(t);let r=Bn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${se($t(n,qt))}`;if(e==="a"||e==="button"||Fn.has(e)||e==="label"){let s=Xe(t);if(s)return `${r} ${se($t(s,qt))}`;if(e==="a"||e==="button"){let i=t.querySelector("svg");if(i){let l=i.getAttribute("aria-label");return l?`${r} ${se($t(l,qt))}`:`${r} (icon)`}let a=t.getAttribute("href");if(e==="a"&&a)return `link[href="${$t(a,qt)}"]`}return r}if(t.id)return `${e}#${t.id}`;let o=Re(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(Ke(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&e.unshift("body"),e.join(" > ").slice(0,ds)}function Yn(t){let e=Xe(t),r=t.parentElement;if(!r)return;let n=Xe(r);if(n){if(e&&n===e){let o=r.parentElement;if(!o)return;let s=Xe(o);return !s||s===e?void 0:$t(s,Hn)}return $t(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(Ke(n)),r.length>=us))break;return r}var bs=["role","aria-label","name"],vs=10,$n=100;function qe(t){let e={};for(let r of bs){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>=vs)break;r.name.startsWith("data-")&&r.value!==""&&(e[r.name]=r.value.slice(0,$n));}return e}function je(t){return ms(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 xs=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"]),ws={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"},ys={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"},ks={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 Cs(t){return `"${t}"`}function Ze(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 gt(t,e){let r=e?.trim();return r?`${t}: ${Cs(jn(r,48))}`:t}function As(t){let e=t.trim(),r=e.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??e,text:r[2]}:{base:e}}function Ss(t){let e=t.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=ks[e];if(r)return r;let n=t.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":ys[n]??"Area":"Area"}function Ts(t){let e=t.getAttribute("aria-label");if(e)return gt("Field",e);let r=t.placeholder;if(r)return gt("Field",r);let n=t.getAttribute("name");if(n)return gt("Field",qn(n));if(t.tagName.toLowerCase()==="input"){let o=t.type||"text";if(o!=="text")return gt("Field",qn(o))}return "Field"}function Pe(t,e){if(e?.trim())return gt("Selected text",e);let r=t.tagName.toLowerCase(),n=t.getAttribute("aria-label");if(r==="button")return gt("Button",n??Ze(t));if(r==="a")return gt("Link",n??Ze(t));if(r==="input"||r==="textarea"||r==="select")return Ts(t);if(r==="img"){let s=t.alt;return gt("Image",s)}if(r==="svg")return gt("Icon",n);if(/^h[1-6]$/.test(r))return gt("Heading",Ze(t));if(xs.has(r))return gt("Text",Ze(t));let o=ws[r];return gt(o||"Area",n)}function Zn(t){if(t.targetLabel?.trim())return jn(t.targetLabel,120);if(t.selectedText?.trim())return gt("Selected text",t.selectedText);let e=t.element?.trim()||t.elementPath?.trim();if(!e)return "Annotation";let r=As(e.split(">").at(-1)??e);return gt(Ss(r.base),r.text)}var Jn="patch-capture-cursor-style";function Es(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 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=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]=useState(false),l=useRef(null),c=useRef(e),d=useRef(r);c.current=e,d.current=r;let u=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);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=useCallback(()=>{i||a(true);},[i]),v=useCallback(()=>{a(false);},[]),f=useRef(null);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]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let b=useMemo(()=>({isCapturing:i,enter:m,exit:v}),[i,m,v]);return jsx(no.Provider,{value:b,children:t})}function io(){let t=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=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]=useState([]),[c,d]=useState(false),[u,p]=useState(null),m=useRef(r);m.current=r;let v=useCallback(async()=>{if(!i){l([]),d(true);return}let g=await m.current.listRoster();l(g),d(true);},[i]);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=useMemo(()=>s.map(g=>`${g.id}:${g.status}`).sort().join(","),[s]),b=useRef(null);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=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=useCallback(()=>p(null),[]),T=useMemo(()=>{let g=new Map;for(let I of s)g.set(I.id,I.status);return g},[s]),x=useMemo(()=>a.map(g=>{let I=T.get(g.id);return I&&I!==g.status?{...g,status:I}:g}),[a,T]),z=useMemo(()=>x.filter(g=>Us(g.status)).length,[x]),D=useMemo(()=>({entries:x,ready:c,unresolvedCount:z,refresh:v,focusPin:h,pendingFocus:u,clearFocus:y}),[x,c,z,v,h,u,y]);return jsx(lo.Provider,{value:D,children:e})}function ae(){let t=use(lo);if(!t)throw new Error("useRosterStore must be used inside <RosterProvider>");return t}var po=createContext(null);function mo({children:t}){let[e,r]=useState(false),[n,o]=useState(false),s=useMemo(()=>({dockOpen:e,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[e,n]);return jsx(po.Provider,{value:s,children:t})}function Bt(){let t=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 import.meta>"u"?void 0:import.meta.env}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 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=useId().replace(/[^a-zA-Z0-9_-]/g,""),s=`${n.id}-${o}`,i=`cav-blur-${s}`,a=`cav-grain-${s}`;return 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:[jsxs("defs",{children:[jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxs("radialGradient",{id:`${s}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsx("rect",{width:"64",height:"64",fill:n.background}),jsx("g",{filter:`url(#${i})`,children:n.spots.map(l=>jsx("rect",{width:"64",height:"64",fill:`url(#${s}-${l.id})`},l.id))}),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 jsx(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:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:Qs[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:tl[r],background:"var(--color-muted-foreground)"},children:[i?jsx(tr,{seed:i,style:{borderRadius:0,filter:a||"none"}}):null,o?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&&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&&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 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)=>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=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=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 jsxs(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:[jsxs("div",{className:"flex items-baseline justify-between gap-2 px-4 pt-3.5 pb-2.5",children:[jsx("span",{className:"text-[13px] font-semibold",children:"Feedback"}),jsx("span",{className:"text-[11.5px] font-medium text-popover-foreground/50",children:a()})]}),s.length===0?jsx("div",{className:"px-4 pt-2 pb-6 text-center text-[12.5px] text-popover-foreground/50",children:"No feedback yet."}):jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-2",children:s.map(c=>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 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:[jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsx(N,{name:"check",size:10,stroke:2.6})}):t.status==="dismissed"?jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxs("span",{className:"min-w-0 flex-1",children:[jsx("span",{className:C("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:t.label}),jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsx(N,{name:Tt[t.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsx("span",{className:"truncate",children:e?"This page":il(t.url)}),jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsx("span",{className:"shrink-0",children:nr(t.createdAt)}),o?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:[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 jsxs("span",{className:C(sl,ll[s],i),style:{background:e,...a},children:[jsx("span",{children:t}),!l&&d?jsx(tr,{seed:d}):null,l?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 jsx("svg",{width:t,height:t,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:e,children: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 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: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]=useState(false),[a,l]=useState(false),c=useRef(null),d=useRef(false);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 jsxs("span",{className:C("relative inline-flex items-center justify-center",r),onMouseEnter:p,onMouseLeave:m,onMouseDown:m,children:[jsx("span",{className:v,children:jsx(AnimatePresence,{children:s&&jsxs(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"?jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[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"}),jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsx("span",{className:"min-w-0 flex-1",children:t}),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]=useState(false),[p,m]=useState(false),[v,f]=useState(false),[b,h]=useState(false),[y,T]=useState(false),[x,z]=useState(false),D=useRef(null),g=useRef(null),I=useRef(false),[U,at]=useState(false),pt=useRef(null),[vt,st]=useState(No);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=useRef(()=>{});P.current=()=>{!I.current&&D.current===null||(tt(),xt(),I.current=false,z(true));};let W=useRef(()=>P.current()).current;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();}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 jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxs(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:[jsx(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: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:jsx(Ie,{size:18})})}),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:[jsx(ge,{visible:o,index:0,children:jsx(ot,{text:t.isCapturing?"Stop commenting":"Add comment",children: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:jsx(To,{variant:"outline",size:16})})})}),l?jsx(ge,{visible:o,index:1,children:jsx(ot,{text:"Feedback",children: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:[jsx(N,{name:"list",size:15}),c>0?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,jsx(ge,{visible:o,index:2,children:jsxs("div",{className:"relative flex items-center",children:[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:jsx(N,{name:E.glyph,size:15})}),jsx(AnimatePresence,{children:p?jsxs(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:[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 jsx(ot,{text:Qt($),children: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:jsx(N,{name:lt.glyph,size:15})})},$)})]}):null})]})}),jsx(ge,{visible:o,index:3,children:jsxs("div",{className:"relative flex items-center",children:[jsx(ot,{text:"Settings",children: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:jsx(N,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:v?jsxs(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:[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"}),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:[jsx("input",{type:"checkbox",checked:s,"aria-label":"Hide resolved annotations",onChange:V,className:"peer sr-only"}),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:jsx(N,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(ge,{visible:o,index:4,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:wt,onMouseLeave:yt,onFocus:G,onBlur:B,children:[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?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)}):jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsx(AnimatePresence,{children:d?jsxs(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:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:bl}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Vt,{initials:K,tint:A,src:k,generatedSeed:M,alt:r.studio.name,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Vt,{initials:K,tint:A,generatedSeed:M,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsx("div",{className:"my-3 h-px bg-white/10"}),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"})]}):jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsx(ge,{visible:o,index:5,children:jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsx(ot,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:Fe,className:C(me,"text-white/70"),children:jsx(N,{name:"x",size:14})})})]})})]})]}),l&&!o&&c>0?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,jsx(AnimatePresence,{children:b?jsx(So,{onClose:()=>h(false)}):null})]})}function ge({children:t,visible:e,index:r}){return jsx(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=useReducedMotion(),v=a.active,f=a.forceClose,b=e&&(!u||p),h=useMemo(()=>l&&e?t.filter(k=>!c||k.status!=="resolved"):[],[l,e,t,c]),y=useMemo(()=>l&&e?r:[],[l,e,r]);useEffect(()=>{if(!c||v?.kind!=="existing")return;t.find(R=>R.id===v.annotationId)?.status==="resolved"&&f();},[v,t,f,c]);let T=useRef(new Map),x=useRef(new Map),z=useRef(new Map),D=useRef(new Map),g=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=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;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=useRef(new Map);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=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 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:[jsx(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 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)})}),jsx(AnimatePresence,{initial:false,children:y.map(k=>{let R=d.targetPointToOverlay({viewportX:k.viewportX,viewportY:k.viewportY});return 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=useReducedMotion(),i=t.pendingFocus,a=useRef(null),l=useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return 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]),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=useReducedMotion(),[o,s]=useState(null),[i,a]=useState(null),[l,c]=useState(null);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=useCallback(f=>({x:Math.min(Math.max(f.x,0),window.innerWidth),y:Math.min(Math.max(f.y,0),window.innerHeight)}),[]),u=useCallback((f,b)=>{let h=jo(f,b);s(null),a(null),!(h.width<Wr||h.height<Wr)&&(c(h),e(h));},[e]);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 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?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: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?jsxs("span",{className:"inline-flex items-center gap-1.5",children:[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?jsxs(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",jsx("span",{className:"mx-2 opacity-40",children:"\xB7"}),jsx("kbd",{className:"rounded bg-white/16 px-1.5 py-0.5 font-sans text-[11px]",children:"Esc"}),jsx("span",{className:"ml-1.5 opacity-70",children:"to cancel"})]}):null]})}var ti=createContext(null);function ei({children:t}){let e=ft(),[r,n]=useState("idle"),o=useRef(null),s=useRef(false);s.current=r!=="idle";let i=useCallback(()=>{o.current=null,n("idle");},[]),a=e.active!==null;useEffect(()=>{!a&&s.current&&i();},[a,i]);let l=useCallback(async u=>{s.current||(o.current=u,n("select"));},[]),c=useCallback(async u=>{n("capturing");let p=await Xo(u),m=o.current;i(),p&&m&&m(p);},[i]),d=useMemo(()=>({supported:true,active:r!=="idle",begin:l}),[r,l]);return jsxs(ti.Provider,{value:d,children:[jsx("div",{style:r==="idle"?{transition:"opacity 150ms ease-out"}:{opacity:0,pointerEvents:"none",transition:"opacity 150ms ease-out"},children:t}),r!=="idle"?jsx(Zo,{capturing:r==="capturing",onSelect:u=>{c(u);},onCancel:i}):null]})}var Ql={supported:false,active:false,begin:async()=>{}};function ri(){return use(ti)??Ql}var ni=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
|
|
4
|
+
`)}function Rs(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=Es(e),r.head.appendChild(o),o}function Tr(t,e,r){let n=t.eventTargetElement(e);return n?n.closest(`[${r}]`)!==null:false}var le=1.5,Ps="#0287FE",Is="rgba(2, 135, 254, 0.032)";function Ns(t){let e=t.split(" ")[0]??"",r=Number.parseFloat(e);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Ms(t,e){let r=t.targetDocument,n=r.createElement("div");n.setAttribute(e,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${le}px solid ${Ps}`,background:Is,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-le}px`,n.style.left=`${a.left-le}px`,n.style.width=`${a.width+le*2}px`,n.style.height=`${a.height+le*2}px`,n.style.borderRadius=`${Ns(t.targetWindow.getComputedStyle(i).borderRadius)+le}px`,i!==s&&(o.textContent=Pe(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=Rs(n,e),i=Ms(n,e),a=false,l=x=>{let f=x;if(Tr(n,f.target,e))return;let b=n.eventTargetElement(f.target);b&&Vn(b)||(f.preventDefault(),f.stopPropagation());},c=l,d=l,u=x=>{let f=x;Tr(n,f.target,e)||(f.preventDefault(),f.stopPropagation(),!a&&r(f));},p=x=>{let f=x;if(a)return;let b=n.eventTargetElement(f.target);if(!b){i.hide();return}if(Tr(n,b,e)){i.hide();return}let h=b.tagName.toLowerCase();if(h==="html"||h==="body"){i.hide();return}i.update(b);},m=x=>{x.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 zs="data-patch-internal",ro=createContext(null),eo=0;function Hs(){return eo+=1,`tmp-${Date.now().toString(36)}-${eo}`}function no({children:t}){let e=xt(),r=it(),n=vt(),{isPreviewing:o,previewReady:s}=ie(),[i,a]=useState(false),l=useRef(null),c=useRef(e),d=useRef(r);c.current=e,d.current=r;let u=useCallback(h=>{let k=c.current;if(k.active&&k.hasDraft){k.attemptClose();return}let E=n.eventTargetElement(h.target)??n.targetDocument.body,w=n.targetWindow.getSelection(),H=to({clickTarget:E,selection:w}),L=Hs(),g={viewportX:h.clientX,viewportY:h.clientY,documentY:h.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:L,viewportX:g.viewportX,viewportY:g.viewportY,documentY:g.documentY}),c.current.openComposer({tempId:L,target:H,anchor:g}),l.current?.pause();},[n]),p=r.annotationsReady&&(!o||s);useEffect(()=>{if(!i||!p){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=Qn({internalAttr:zs,surface:n,onClick:u}),()=>{l.current?.exit(),l.current=null;}},[i,u,n,p]);let m=useCallback(()=>{i||a(true);},[i]),x=useCallback(()=>{a(false);},[]),f=useRef(null);useEffect(()=>{let h=f.current,k=e.active;h?.kind==="composer"&&k?.kind!=="composer"&&(d.current.removeEphemeral(h.tempId),l.current?.resume()),h?.kind==="composer"&&k?.kind==="composer"&&h.tempId!==k.tempId&&d.current.removeEphemeral(h.tempId),f.current=k;},[e.active]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let b=useMemo(()=>({isCapturing:i,enter:m,exit:x}),[i,m,x]);return jsx(ro.Provider,{value:b,children:t})}function oo(){let t=use(ro);if(!t)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return t}var Vs="patch:focus-intent";function Nr(t){return `${Vs}:${t}`}function Ws(t){try{let e=window.sessionStorage.getItem(Nr(t));if(!e)return null;window.sessionStorage.removeItem(Nr(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 Us(t,e){try{window.sessionStorage.setItem(Nr(t),JSON.stringify(e));}catch{}}var so=createContext(null);function Ys(t){return t==="pending"||t==="acknowledged"}function lo({projectToken:t,children:e}){let{apiClient:r,active:n,viewerKind:o,annotations:s}=it(),i=o==="studio",[a,l]=useState([]),[c,d]=useState(false),[u,p]=useState(null),m=useRef(r);m.current=r;let x=useCallback(async()=>{if(!i){l([]),d(true);return}let g=await m.current.listRoster();l(g),d(true);},[i]);useEffect(()=>{if(!n||!i)return;let g=Ws(t);g&&ot(g.url)===ot(window.location.href)&&p(g),x();},[n,i,t,x]);let f=useMemo(()=>s.map(g=>`${g.id}:${g.status}`).sort().join(","),[s]),b=useRef(null);useEffect(()=>{if(!(!n||!i)){if(b.current===null){b.current=f;return}b.current!==f&&(b.current=f,x());}},[f,n,i,x]);let h=useCallback(g=>{let I={id:g.id,url:g.url,viewport:g.viewport};if(ot(g.url)===ot(window.location.href)){p(I);return}Us(t,I),window.location.assign(g.url);},[t]),k=useCallback(()=>p(null),[]),E=useMemo(()=>{let g=new Map;for(let I of s)g.set(I.id,I.status);return g},[s]),w=useMemo(()=>a.map(g=>{let I=E.get(g.id);return I&&I!==g.status?{...g,status:I}:g}),[a,E]),H=useMemo(()=>w.filter(g=>Ys(g.status)).length,[w]),L=useMemo(()=>({entries:w,ready:c,unresolvedCount:H,refresh:x,focusPin:h,pendingFocus:u,clearFocus:k}),[w,c,H,x,h,u,k]);return jsx(so.Provider,{value:L,children:e})}function ce(){let t=use(so);if(!t)throw new Error("useRosterStore must be used inside <RosterProvider>");return t}var uo=createContext(null);function po({children:t}){let[e,r]=useState(false),[n,o]=useState(false),s=useMemo(()=>({dockOpen:e,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[e,n]);return jsx(uo.Provider,{value:s,children:t})}function Ut(){let t=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 import.meta>"u"?void 0:import.meta.env}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}}var Qe=class extends 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 Ne(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 er({seed:t,className:e,style:r}){let n=an(t),o=useId().replace(/[^a-zA-Z0-9_-]/g,""),s=`${n.id}-${o}`,i=`cav-blur-${s}`,a=`cav-grain-${s}`;return 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:[jsxs("defs",{children:[jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxs("radialGradient",{id:`${s}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsx("rect",{width:"64",height:"64",fill:n.background}),jsx("g",{filter:`url(#${i})`,children:n.spots.map(l=>jsx("rect",{width:"64",height:"64",fill:`url(#${s}-${l.id})`},l.id))}),jsx("rect",{width:"64",height:"64",filter:`url(#${a})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Dt=32,bo=[.22,.61,.36,1],rr=["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 de(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 ue(t){if(!t)return rr[0];let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return rr[Math.abs(e)%rr.length]??rr[0]}var tl={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},el={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function Yt(t,e){let{placement:r}=Ne({anchor:{x:t.viewportX-Dt/2,y:t.viewportY-Dt/2,width:Dt,height:Dt},popover:{width:332,height:200},viewport:e});return r==="right"?"left":"right"}function pe(t,e){return {x:e==="left"?t.viewportX:t.viewportX-Dt,y:t.viewportY-Dt,width:Dt,height:Dt}}function Mr({ref:t,...e}){let r=e.pointSide??"right",n=!e.resolved&&e.attention?rl[e.attention]:null,{url:o,seed:s}=We(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 jsx(m.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:Dt,height:Dt},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:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:tl[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:el[r],background:"var(--color-muted-foreground)"},children:[i?jsx(er,{seed:i,style:{borderRadius:0,filter:a||"none"}}):null,o?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&&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&&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 rl={"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 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 M({name:t,size:e=16,stroke:r=2,color:n,className:o}){return 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)=>createElement(s,{key:a,...i}))})}var Co=[.16,1,.3,1];function al(t){try{let r=new URL(t).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return t}}function or(t){return t==="pending"||t==="acknowledged"}function Ao({onClose:t}){let e=ce(),{hideResolvedAnnotations:r}=Ut(),n=e.focusPin,o=typeof window>"u"?"":ot(window.location.href),s=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=useMemo(()=>{let c=e.entries.filter(u=>or(u.status)&&ot(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 jsxs(m.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:[jsxs("div",{className:"flex items-baseline justify-between gap-2 px-4 pt-3.5 pb-2.5",children:[jsx("span",{className:"text-[13px] font-semibold",children:"Feedback"}),jsx("span",{className:"text-[11.5px] font-medium text-popover-foreground/50",children:a()})]}),s.length===0?jsx("div",{className:"px-4 pt-2 pb-6 text-center text-[12.5px] text-popover-foreground/50",children:"No feedback yet."}):jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-2",children:s.map(c=>jsx(sl,{entry:c,onCurrentPage:ot(c.url)===o,onClick:()=>l(c)},c.id))})]})}function sl({entry:t,onCurrentPage:e,onClick:r}){let n=t.status==="resolved",o=t.anchorStatus==="detached";return 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:[jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsx(M,{name:"check",size:10,stroke:2.6})}):t.status==="dismissed"?jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxs("span",{className:"min-w-0 flex-1",children:[jsx("span",{className:C("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:t.label}),jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsx(M,{name:Et[t.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsx("span",{className:"truncate",children:e?"This page":al(t.url)}),jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsx("span",{className:"shrink-0",children:nr(t.createdAt)}),o?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:[jsx(M,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var ll="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",cl={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Gt({initials:t,tint:e,src:r,generatedSeed:n,alt:o="",size:s="md",className:i,style:a}){let{url:l,seed:c}=We(r),d=c??n;return jsxs("span",{className:C(ll,cl[s],i),style:{background:e,...a},children:[jsx("span",{children:t}),!l&&d?jsx(er,{seed:d}):null,l?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 ul="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",pl="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 Le({size:t=16,className:e}){return jsx("svg",{width:t,height:t,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:e,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:ul})})}function So({size:t=16,variant:e="filled",stroke:r=2,className:n}){let o=e==="outline";return 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:jsx("path",{d:pl})})}var Lr=false,jt=null,ar=null,Rt={openDelay:700,isInstant(){return Lr},onOpen(t){ar&&ar!==t&&ar(),ar=t??null,Lr=true,jt&&(clearTimeout(jt),jt=null);},onClose(){jt&&clearTimeout(jt),jt=setTimeout(()=>{Lr=false,jt=null;},300);}};var Ro="easeOut";function st({text:t,children:e,className:r,tone:n="default",placement:o="top"}){let[s,i]=useState(false),[a,l]=useState(false),c=useRef(null),d=useRef(false);useEffect(()=>()=>{c.current&&clearTimeout(c.current),d.current&&Rt.onClose();},[]);let u=w=>{l(w),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$1=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,Rt.onClose()),i(false);},x=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",k=o==="bottom"&&n!=="warning"?-3:3,E=o==="bottom"&&n!=="warning"?-2:2;return jsxs("span",{className:C("relative inline-flex items-center justify-center",r),onMouseEnter:p,onMouseLeave:m$1,onMouseDown:m$1,children:[jsx("span",{className:x,children:jsx(AnimatePresence,{children:s&&jsxs(m.span,{initial:a?false:{opacity:0,y:k,scale:.98},animate:{opacity:1,y:0,scale:1,transition:a?{duration:0}:{duration:.1,ease:Ro}},exit:{opacity:0,y:E,scale:.98,transition:{duration:.08,ease:Ro}},className:b,children:[n==="warning"?jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[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"}),jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsx("span",{className:"min-w-0 flex-1",children:t}),jsx("span",{className:h})]})})}),e]})}var Io=44,Ot=[.16,1,.3,1],No="easeOut",bl=.08,vl=60,xl="calc(100% - 64px) calc(100% + 4px)",he="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function Mo(){let t=oo(),e=xt(),r=it(),n=ce(),{dockOpen:o,hideResolvedAnnotations:s,setDockOpen:i,setHideResolvedAnnotations:a}=Ut(),l=!!r.studio,c=n.unresolvedCount,[d,u]=useState(false),[p,m$1]=useState(false),[x,f]=useState(false),[b,h]=useState(false),[k,E]=useState(false),[w,H]=useState(false),L=useRef(null),g=useRef(null),I=useRef(false),[U,ct]=useState(false),dt=useRef(null),[ht,ut]=useState(Io);useLayoutEffect(()=>{let F=dt.current;if(!F)return;let mt=()=>ut(F.offsetWidth);mt();let St=new ResizeObserver(mt);return St.observe(F),()=>St.disconnect()},[]);let pt=r.studio?r.studio.name:r.identity?.name??null,rt=de(pt),j=r.studio?.image??null,A=r.identity?.avatarSeed??r.clientAvatarSeed,R=r.studio?.userId??A,D=r.studio?"var(--color-foreground)":ue(A),G=r.studio&&!j?"#FFFFFF":D,W=r.studio&&!j?"text-foreground":"text-white",v=Et[r.activeViewport];function $(){L.current!==null&&(window.clearTimeout(L.current),L.current=null);}function O(){g.current!==null&&(window.clearTimeout(g.current),g.current=null);}let X=useRef(()=>{});X.current=()=>{!I.current&&L.current===null||($(),O(),I.current=false,H(true));};let S=useRef(()=>X.current()).current;useEffect(()=>{w&&d&&u(false);},[w,d]);function P(F){m$1(false),f(false),h(false),$(),O(),I.current=true,H(false),E(F),Rt.onOpen(S),u(true);}function N(){P(false);}function K(){if($(),!(I.current||g.current!==null)){if(Rt.isInstant()){P(true);return}g.current=window.setTimeout(()=>{g.current=null,P(false);},Rt.openDelay);}}function tt(){O(),$(),I.current&&(I.current=false,Rt.onClose()),L.current=window.setTimeout(()=>{u(false),L.current=null;},120);}function It(){ct(true),i(true);}function Tt(){m$1(false),f(false),h(false),O(),I.current=false,u(false),t.isCapturing?t.exit():t.enter();}function Fe(){m$1(false),f(false),O(),I.current=false,u(false),h(F=>{let mt=!F;return mt&&n.refresh(),mt});}function Be(){ct(true),i(false),m$1(false),f(false),h(false),O(),I.current=false,u(false),t.exit(),e.active&&e.forceClose();}useEffect(()=>()=>{L.current!==null&&window.clearTimeout(L.current),g.current!==null&&window.clearTimeout(g.current);},[]);let gr=()=>{r.signOut(),u(false);};function T(){f(false),h(false),O(),I.current=false,u(false),m$1(F=>!F);}function z(F){m$1(false),r.activeViewport!==F&&(e.active&&e.forceClose(),r.setActiveViewport(F));}function _(){m$1(false),h(false),O(),I.current=false,u(false),f(F=>!F);}function V(){a(!s);}function B(F){let mt=F.relatedTarget;mt instanceof Node&&F.currentTarget.contains(mt)||tt();}return jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxs(m.div,{initial:false,animate:{width:o?ht:Io},transition:{duration:.36,ease:Ot},onAnimationComplete:()=>ct(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Ot}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Ot}},"data-patch-fab-dock":"",className:C("pkey-fab relative h-11 rounded-full",U?"overflow-hidden":"overflow-visible"),children:[jsx(m.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Ot},className:C("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsx("button",{type:"button",onClick:It,"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:jsx(Le,{size:18})})}),jsxs("div",{ref:dt,"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:[jsx(be,{visible:o,index:0,children:jsx(st,{text:t.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":t.isCapturing?"Stop commenting":"Add comment","aria-pressed":t.isCapturing,onClick:Tt,className:C(he,"transition-colors",t.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(So,{variant:"outline",size:16})})})}),l?jsx(be,{visible:o,index:1,children:jsx(st,{text:"Feedback",children: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:Fe,className:C(he,"relative transition-colors",b||c>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsx(M,{name:"list",size:15}),c>0?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,jsx(be,{visible:o,index:2,children:jsxs("div",{className:"relative flex items-center",children:[jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${v.label}`,"aria-expanded":p,onClick:T,className:C(he,"transition-colors",r.activeViewport==="desktop"&&!p?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx(M,{name:v.glyph,size:15})}),jsx(AnimatePresence,{children:p?jsxs(m.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Ot}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Ot}},"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:[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"}),cn.map(F=>{let mt=Et[F],St=r.activeViewport===F;return jsx(st,{text:ee(F),children:jsx("button",{type:"button","data-patch-viewport-option":F,"aria-label":ee(F),"aria-pressed":St,onClick:()=>z(F),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:jsx(M,{name:mt.glyph,size:15})})},F)})]}):null})]})}),jsx(be,{visible:o,index:3,children:jsxs("div",{className:"relative flex items-center",children:[jsx(st,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":x,onClick:_,className:C(he,"transition-colors",x||s?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(M,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:x?jsxs(m.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Ot}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Ot}},"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:[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"}),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:[jsx("input",{type:"checkbox",checked:s,"aria-label":"Hide resolved annotations",onChange:V,className:"peer sr-only"}),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:jsx(M,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(be,{visible:o,index:4,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:K,onMouseLeave:tt,onFocus:N,onBlur:B,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":pt?`Account: ${pt}`:"Identify",className:C(he,"text-white"),children:pt?jsx(Gt,{initials:rt,tint:G,src:j,generatedSeed:R,alt:pt,size:"sm",className:C("size-[22px] text-[9.5px] ring-1 ring-white/20",W)}):jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsx(AnimatePresence,{children:d?jsxs(m.div,{initial:k?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:k?{duration:0}:{duration:.12,delay:bl,ease:No}},exit:{opacity:0,y:2,scale:.98,transition:w?{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:xl},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:vl}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Gt,{initials:rt,tint:D,src:j,generatedSeed:R,alt:r.studio.name,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Gt,{initials:rt,tint:D,generatedSeed:R,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsx("div",{className:"my-3 h-px bg-white/10"}),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"})]}):jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsx(be,{visible:o,index:5,children:jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsx(st,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:Be,className:C(he,"text-white/70"),children:jsx(M,{name:"x",size:14})})})]})})]})]}),l&&!o&&c>0?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,jsx(AnimatePresence,{children:b?jsx(Ao,{onClose:()=>h(false)}):null})]})}function be({children:t,visible:e,index:r}){return jsx(m.div,{initial:{opacity:0,x:6},animate:e?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Ot}}:{opacity:0,x:6,transition:{duration:.12,ease:Ot}},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 yl=.6,kl=.5,lr={text:.4,attrs:.3,classes:.2,position:.1},Cl=5e3,Al=.08,Sl=.12;function Tl(t,e){return e===void 0||e===""?.5:t===e?1:t&&(t.includes(e)||e.includes(t))?.5:0}function El(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 Rl(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 Or(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 Pl(t,e){let r=je(t),n=qe(t),o=Re(t),s=t.getBoundingClientRect(),i=Tl(r,e.payload.domHints?.textSignature),a=El(n,e.payload.domHints?.attributeSignature),l=Rl(o,e.payload.cssClasses),c=Or(s,Oo(e),e);return lr.text*i+lr.attrs*a+lr.classes*l+lr.position*c}function Il(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>=Cl);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"||Il(a))continue;let c=Pl(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<Al){let i=Oo(e),a=Or(n.el.getBoundingClientRect(),i,e),l=Or(o.el.getBoundingClientRect(),i,e);if(a-l<Sl)return null}return n.el}function Nl(t){return {viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.documentY-t.scrollY}}function Ml(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 _l(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=_l(t);if(e.length>0){let n=Do(e,t,kl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Do(t.doc.querySelectorAll("*"),t,yl);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function zr(t,e){return t.kind==="anchored"&&t.el?Ml(t.el,e):Nl(e)}function zo(t){let e=cr(t);return {kind:e.kind,tier:e.tier,el:e.el,position:zr(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 Dl="data-patch-internal",Bo=[2e4,6e4,3e5];function Ol(t){let e=Math.min(Math.max(1,t),Bo.length)-1;return Bo[e]??3e5}function Vo(t,e,r){let n=Yt(r,e.getOverlayViewport()),o=pe(r,n);t.style.top=`${o.y}px`,t.style.left=`${o.x}px`;}function Wo(t,e){return Math.abs(t.viewportX-e.viewportX)<.5&&Math.abs(t.viewportY-e.viewportY)<.5}function zl(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:Dl}}function Uo(t,e,r){let n=Fr(t,e);return {kind:r.kind,position:t.targetPointToOverlay(zr(r,n))}}function Hl(t,e){return t.targetPointToOverlay({viewportX:e.viewportX,viewportY:e.documentY-t.getTargetScrollY()})}function Yo(){let{annotations:t,annotationsReady:e,ephemerals:r,identity:n,studio:o,clientAvatarSeed:s,apiClient:i}=it(),a=xt(),{dockOpen:l,hideResolvedAnnotations:c}=Ut(),d=vt(),{isPreviewing:u,previewReady:p}=ie(),m=useReducedMotion(),x=a.active,f=a.forceClose,b=e&&(!u||p),h=useMemo(()=>l&&e?t.filter(A=>!c||A.status!=="resolved"):[],[l,e,t,c]),k=useMemo(()=>l&&e?r:[],[l,e,r]);useEffect(()=>{if(!c||x?.kind!=="existing")return;t.find(R=>R.id===x.annotationId)?.status==="resolved"&&f();},[x,t,f,c]);let E=useRef(new Map),w=useRef(new Map),H=useRef(new Map),L=useRef(new Map),g=useRef(new Map),I=useMemo(()=>{let A=L.current,R=g.current,D=performance.now(),G=new Set,W=new Map;for(let v of h){G.add(v.id);let $=A.get(v.id),O=$?.kind==="anchored"&&$.el?.isConnected,X;if(O)X=$,R.delete(v.id);else {let S=R.get(v.id);if($?.kind==="detached"&&S&&D<S.nextAt)X=$;else if(X=cr(Fr(d,v)),X.kind==="detached"){let P=(S?.attempts??0)+1;R.set(v.id,{attempts:P,nextAt:D+Ol(P)});}else R.delete(v.id);}A.set(v.id,X),W.set(v.id,Uo(d,v,X));}for(let v of A.keys())G.has(v)||(A.delete(v),R.delete(v));return W},[d,h]),U=useCallback(()=>{let A=L.current,R=H.current,D=new Set,G=d.getOverlayViewport(),W=[];for(let v of h){let $=E.current.get(v.id);if(!$)continue;D.add(v.id);let O=A.get(v.id);if((!O||O.kind==="anchored"&&O.el&&!O.el.isConnected)&&(O=cr(Fr(d,v)),A.set(v.id,O)),O.kind==="detached"||O.kind==="anchored"&&O.el&&zl(O.el)){W.push({el:$,id:v.id,kind:"hide"});continue}let X=Uo(d,v,O).position,S=R.get(v.id);if(S&&Wo(S,X)&&$.style.visibility!=="hidden")continue;let P=Yt(X,G),N=pe(X,P);W.push({el:$,id:v.id,kind:"place",position:X,box:{viewportX:N.x,viewportY:N.y}});}for(let v of k){let $=w.current.get(v.tempId);if(!$)continue;D.add(v.tempId);let O=Hl(d,v),X=R.get(v.tempId);if(X&&Wo(X,O))continue;let S=Yt(O,G),P=pe(O,S);W.push({el:$,id:v.tempId,kind:"place",position:O,box:{viewportX:P.x,viewportY:P.y}});}for(let v of W){if(v.kind==="hide"){v.el.style.visibility!=="hidden"&&(v.el.style.visibility="hidden"),R.delete(v.id);continue}v.el.style.visibility==="hidden"&&(v.el.style.visibility=""),v.el.style.top=`${v.box.viewportY}px`,v.el.style.left=`${v.box.viewportX}px`,R.set(v.id,v.position);}for(let v of R.keys())D.has(v)||R.delete(v);},[d,h,k]),ct=h.length>0||k.length>0;useEffect(()=>{if(!ct)return;let A=d.overlayWindow,R=A.requestAnimationFrame(function D(){U(),R=A.requestAnimationFrame(D);});return ()=>A.cancelAnimationFrame(R)},[ct,U,d]);let dt=useRef(new Map);useEffect(()=>{if(!e||h.length===0)return;let A=setTimeout(()=>{let R=[];for(let D of h){let G=I.get(D.id);if(!G)continue;let W=G.kind!=="detached";dt.current.get(D.id)!==W&&(dt.current.set(D.id,W),R.push({id:D.id,present:W}));}i.reportAnchorStatuses(R);},1500);return ()=>clearTimeout(A)},[I,h,e,i]);let ht=useCallback(A=>{if(a.active&&a.hasDraft){a.attemptClose();return}a.openExisting(A);},[a]),ut=o?o.name:n?.name??null,pt=o?.image??null,rt=n?.avatarSeed??s,j=o?.userId??rt;return 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:[jsx(AnimatePresence,{initial:false,children:h.map(A=>{let R=I.get(A.id);if(R?.kind==="detached")return null;let D=$l(A),G=!o&&!!n?.clientUserId&&A.payload.authorRole==="client"&&A.payload.authorId===n.clientUserId,W=o?Ho(A):null,v=R?Yt(R.position,d.getOverlayViewport()):"right";return jsx(Mr,{ref:$=>{$?(E.current.set(A.id,$),R&&Vo($,d,R.position)):E.current.delete(A.id);},avatarSrc:D.image,generatedSeed:G?rt:D.generatedSeed,avatarAlt:D.name??"",resolved:A.status==="resolved",attention:W,pointSide:v,ariaLabel:`Annotation by ${A.authorName??"someone"}`,onClick:()=>ht(A.id),pinId:A.id},A.id)})}),jsx(AnimatePresence,{initial:false,children:k.map(A=>{let R=d.targetPointToOverlay({viewportX:A.viewportX,viewportY:A.viewportY});return jsx(Mr,{ref:D=>{D?(w.current.set(A.tempId,D),Vo(D,d,R)):w.current.delete(A.tempId);},avatarSrc:pt,generatedSeed:j,avatarAlt:ut??"",resolved:false,pointSide:Yt(R,d.getOverlayViewport()),ephemeral:true},A.tempId)})})]})}function $l(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 Ul=5e3;function Xo(){let t=ce(),e=it(),r=xt(),n=Ut(),o=vt(),s=useReducedMotion(),i=t.pendingFocus,a=useRef(null),l=useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return useEffect(()=>{if(!i)return;if(ot(window.location.href)!==ot(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();},Ul));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]),useEffect(()=>()=>l(),[l]),null}function Yl(){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 Ko(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=Yl(),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 Kl='<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>',ql=`url("data:image/svg+xml,${encodeURIComponent(Kl)}") 12 12, crosshair`,Vr=4;function Zo(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=useReducedMotion(),[o,s]=useState(null),[i,a]=useState(null),[l,c]=useState(null);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=useCallback(f=>({x:Math.min(Math.max(f.x,0),window.innerWidth),y:Math.min(Math.max(f.y,0),window.innerHeight)}),[]),u=useCallback((f,b)=>{let h=Zo(f,b);s(null),a(null),!(h.width<Vr||h.height<Vr)&&(c(h),e(h));},[e]);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?Zo(o,i):null),m$1=!!p&&p.width>=Vr/2,x=p?p.y+p.height+30<window.innerHeight:true;return 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":ql},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$1&&p?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: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)]",x?"top-[calc(100%+6px)]":"bottom-[calc(100%+6px)]"),children:t?jsxs("span",{className:"inline-flex items-center gap-1.5",children:[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?jsxs(m.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",jsx("span",{className:"mx-2 opacity-40",children:"\xB7"}),jsx("kbd",{className:"rounded bg-white/16 px-1.5 py-0.5 font-sans text-[11px]",children:"Esc"}),jsx("span",{className:"ml-1.5 opacity-70",children:"to cancel"})]}):null]})}var ei=createContext(null);function ri({children:t}){let e=xt(),[r,n]=useState("idle"),o=useRef(null),s=useRef(false);s.current=r!=="idle";let i=useCallback(()=>{o.current=null,n("idle");},[]),a=e.active!==null;useEffect(()=>{!a&&s.current&&i();},[a,i]);let l=useCallback(async u=>{s.current||(o.current=u,n("select"));},[]),c=useCallback(async u=>{n("capturing");let p=await Ko(u),m=o.current;i(),p&&m&&m(p);},[i]),d=useMemo(()=>({supported:true,active:r!=="idle",begin:l}),[r,l]);return jsxs(ei.Provider,{value:d,children:[jsx("div",{style:r==="idle"?{transition:"opacity 150ms ease-out"}:{opacity:0,pointerEvents:"none",transition:"opacity 150ms ease-out"},children:t}),r!=="idle"?jsx(Jo,{capturing:r==="capturing",onSelect:u=>{c(u);},onCancel:i}):null]})}var ec={supported:false,active:false,begin:async()=>{}};function ni(){return use(ei)??ec}var oi=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
|
|
5
5
|
@layer properties;
|
|
6
6
|
@layer theme, base, components, utilities;
|
|
7
7
|
@layer theme {
|
|
@@ -2269,19 +2269,19 @@ button:not(:disabled):not(.pkey):active {
|
|
|
2269
2269
|
}
|
|
2270
2270
|
}
|
|
2271
2271
|
}
|
|
2272
|
-
`;var oi="patch-widget-root";function ii({children:t}){let[e,r]=useState(null),n=useRef(null);return 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?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=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]=useState(false),[l,c]=useState(null),[d,u]=useState(null),p=useRef(false),m=t?.thread??[],v=t?.latestRun??null,f=t?.status==="resolved",b=t?Xr(t):false,h=n.viewerKind,y=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=useMemo(()=>y(),[y]),x=!!t&&t.deliveryStatus!=="sending"&&t.deliveryStatus!=="failed"&&!!T.authorId&&t.payload.authorRole===T.role&&t.payload.authorId===T.authorId,z=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=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=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=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=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=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=useCallback(S=>!T.authorId||S.deliveryStatus&&S.deliveryStatus!=="sent"?false:S.role===T.role&&S.authorId===T.authorId,[T]),vt=useCallback(()=>{x&&(c(null),u({kind:"annotation"}));},[x]),st=useCallback(S=>{pt(S)&&(c(null),u({kind:"message",messageId:S.id}));},[pt]),Q=useCallback(()=>{c(null),u(null);},[]),K=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=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=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=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=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=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=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,_=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=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 jsx(Ri.Provider,{value:fr,children:r})}function j(){let t=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 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 jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children: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:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsx("div",{className:"text-xs text-muted-foreground",children:s}),t.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:t.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(Ct,{variant:"neutral",disabled:t.busy,onClick:e.cancelDelete,children:"Cancel"}),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?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children: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:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(Ct,{variant:"neutral",onClick:()=>e.setConfirmDiscardOpen(false),children:"Keep editing"}),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 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:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx(zc,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(Fc,{})})]}),t.actionError?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]=useState(false),[o,s]=useState(""),[i,a]=useState(false),l=t.runState,c=l?.status;if(t.annotation?.status==="resolved")return 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 jsx("div",{className:"min-w-0 flex-1",children:jsxs(Ct,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(p){let y=yo(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:_e("brand","no-underline"),children:[jsx(N,{name:"pr",size:12}),y==="PR"?"View PR":`View PR ${y}`]})})}let h=jsxs(Ct,{variant:v,disabled:t.busy||f,className:f?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(Ie,{size:12})," ",m]});return jsxs("div",{className:"min-w-0 flex-1",children:[f&&t.agentRunSetupMessage?jsx(ot,{text:t.agentRunSetupMessage,tone:"warning",children:h}):h,r?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 jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),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:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg bg-brand text-white",children:jsx(Ie,{size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:t})]}),jsx(Pt,{size:"sm",title:"Close",onClick:o,children:jsx(N,{name:"x",size:12})})]}),jsxs("label",{className:"flex flex-col gap-1.5",children:[jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),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"})]}),jsxs("div",{className:"flex justify-end gap-2",children:[jsx(Ct,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),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"?jsxs(Ct,{variant:"neutral",disabled:t.busy,onClick:()=>e.reopen(),children:[jsx(N,{name:"refresh",size:12}),"Reopen"]}):jsxs(Ct,{variant:"neutral",disabled:t.busy,onClick:()=>e.markResolved(),children:[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
|
|
2272
|
+
`;var ii="patch-widget-root";function ai({children:t}){let[e,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(ii);o||(o=document.createElement(ii),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=oi,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?createPortal(t,e):null}var sc=/[\s#.:[\]()>+~,\\]/;function lc(t){return !(!t||sc.test(t)||/^\d/.test(t))}function cc(t){let e=1,r=t.previousElementSibling,n=t.tagName;for(;r;)r.tagName===n&&e++,r=r.previousElementSibling;return e}function si(t,e,r){try{let n=t.querySelectorAll(e);return n.length===1&&n[0]===r}catch{return false}}function dc(t,e){return t.id&&lc(t.id)&&(!e||si(e,`#${t.id}`,t))?`#${t.id}`:`${t.tagName.toLowerCase()}:nth-of-type(${cc(t)})`}function li(t,e){if(!t.tagName)return "";let r=t.ownerDocument??null,n=[],o=t,s=0;for(;o&&s<12;){let i=dc(o,r);if(n.unshift(i),i.startsWith("#"))break;let a=n.join(" > ");if(r&&si(r,a,t))return a;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,s++;}return n.join(" > ")}var uc=80,pc=500;function di(t){return t!==null&&typeof t=="object"}function mc(t){return di(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(!di(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 ui(t){return t.replace(/\s+/g," ").trim()}function pi(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function gc(t){let e=ui(t).replace(/[<>]/g,"");return !e||/^[a-z]/.test(e)?null:pi(e,uc)}function fc(t){let e=ur(t.elementType)??ur(t.type);return e?gc(e):null}function ci(t){return pi(ui(t),pc)}function hc(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 bc(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 ci(e.slice(o+1))}let r=e.split("/").filter(Boolean);return ci(r.slice(-3).join("/"))}function vc(t){let e=t._debugSource?.fileName;return typeof e!="string"||!e.trim()||hc(e)?null:bc(e)}function xc(t){let e=t;for(let r of Object.getOwnPropertyNames(t)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=e[r];if(mc(n))return n}return null}function mi(t){let e=xc(t);if(!e)return null;let r=[],n=null,o=0;for(;e&&o<30;){let a=fc(e),l=a?hr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=vc(e)),e=e.return??e._debugOwner??null,o+=1;}let s=r.length>0?tn(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 gi=500;function wc(t){return t.length<=gi?t:t.slice(0,gi)}function yc(t){return {viewportX:t.viewportX,viewportY:t.viewportY,documentY:t.viewportY+t.scrollY,isFixed:false}}function kc(t){return {x:t.x,y:t.y,width:t.width,height:t.height}}function Cc(t){let e={cssSelector:li(t)},r=je(t);r&&(e.textSignature=r);let n=qe(t);return Object.keys(n).length>0&&(e.attributeSignature=n),e}function fi(t){return Pe(t.element,t.selectedText)}function hi(t){let{target:e,click:r,comment:n,url:o}=t,s=e.element,i=e.rect,a=Wn(s),l=Yn(s),c=Re(s),d=Gn(s),u=mi(s),p={comment:n,element:Ke(s),elementPath:Un(s),targetLabel:Pe(s,e.selectedText),timestamp:Date.now(),url:Vt(o),kind:"feedback",coordinates:yc(r),boundingBox:kc(i),domHints:Cc(s)};return e.selectedText&&(p.selectedText=wc(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 Ac=2e3,Sc=.82,Tc=.85;function vi(t,e,r){return new Promise(n=>t.toBlob(n,e,r))}function xi(t){return t.startsWith("image/")&&t!=="image/gif"}async function wi(t){let e;try{e=await createImageBitmap(t);}catch{return null}try{let r=Math.min(1,Ac/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=Jr(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 vi(s,"image/webp",Sc);return (!a||a.type!=="image/webp")&&(a=await vi(s,"image/jpeg",Tc)),!a||a.size>3145728?null:{blob:a,width:n,height:o}}finally{e.close();}}async function De(t,e){return t.kind==="composer"?e.createAnnotation(t.payload):e.reply(t.annotationId,{content:t.content,attachmentIds:t.attachmentIds})}async function yi(t,e){return e.resolve(t)}async function ki(t,e){return e.deleteAnnotation(t)}async function Ci(t,e){return e.deleteMessage(t.annotationId,t.messageId)}async function Ai(t,e){return t.viewerKind!=="studio"?null:e.reopen(t.annotationId)}async function Si(t,e){return t.viewerKind!=="studio"?null:e.kickoff(t.annotationId,{guidance:t.guidance})}async function Ti(t,e){return e.postIdentity(t)}var Pi=createContext(null),Ri=0;function pr(t){return Ri+=1,`${t}-${Date.now().toString(36)}-${Ri}`}function Gr(t){return t.deliveryStatus==="sending"||t.deliveryStatus==="failed"}function Ii({annotation:t,draftTargetLabel:e,children:r}){let n=it(),o=xt(),s=vt(),[i,a]=useState(false),[l,c]=useState(null),[d,u]=useState(null),p=useRef(false),m=t?.thread??[],x=t?.latestRun??null,f=t?.status==="resolved",b=t?Gr(t):false,h=n.viewerKind,k=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]),E=useMemo(()=>k(),[k]),w=!!t&&t.deliveryStatus!=="sending"&&t.deliveryStatus!=="failed"&&!!E.authorId&&t.payload.authorRole===E.role&&t.payload.authorId===E.authorId,H=useCallback((T,z)=>{let _=k();return {id:pr("tmp-msg"),role:_.role,authorId:_.authorId,authorName:_.authorName,authorImage:_.authorImage,content:T,createdAt:new Date().toISOString(),deliveryStatus:"sending",attachments:z}},[k]),L=useCallback(async(T,z="upload")=>{let _=Array.from(T).filter(V=>xi(V.type));await Promise.all(_.map(async V=>{let B=await wi(V);if(!B)return;let F=pr("tmp-att"),mt=URL.createObjectURL(B.blob);if(!o.addDraftAttachment({localId:F,status:"uploading",previewUrl:mt,width:B.width,height:B.height,kind:z,attachment:null})){URL.revokeObjectURL(mt);return}let Kt=await n.apiClient.uploadAttachment(B.blob,{kind:z,width:B.width,height:B.height});o.updateDraftAttachment(F,Kt?{status:"uploaded",attachment:Kt}:{status:"failed"});}));},[o,n.apiClient]),g=useCallback(async T=>{if(p.current)return Promise.reject(new Error("busy"));p.current=true,a(true);try{return await T()}finally{p.current=false,a(false);}},[]),I=useCallback(async()=>{let T=o.draftText.trim(),z=o.draftAttachments.flatMap(nt=>nt.status==="uploaded"&&nt.attachment?[nt.attachment]:[]);if(o.draftAttachments.some(nt=>nt.status!=="uploaded"))return;if(t){if(!T&&z.length===0||f||Gr(t))return;let nt=H(T,z);o.setDraftText(""),o.clearDraftAttachments(),n.updateAnnotation(t.id,Nt=>({...Nt,thread:[...Nt.thread,nt]}));let Ae=await De({kind:"reply",annotationId:t.id,content:T,attachmentIds:z.map(Nt=>Nt.id)},n.apiClient);if(Ae){let Nt=Ae.attachments??[];n.updateAnnotation(t.id,te=>({...te,thread:te.thread.map(fr=>fr.id===nt.id?{...fr,id:Ae.id,deliveryStatus:"sent",attachments:Nt}:fr)})),Nt.length<z.length&&c("Some images expired before sending and were removed."),n.refresh();return}n.updateAnnotation(t.id,Nt=>({...Nt,thread:Nt.thread.map(te=>te.id===nt.id?{...te,deliveryStatus:"failed"}:te)}));return}if(!T)return;let _=o.active;if(!_||_.kind!=="composer")return;let V=_.target,B={viewportX:_.anchor.viewportX,viewportY:_.anchor.viewportY,scrollY:_.anchor.documentY-_.anchor.viewportY},F=s.getPageUrl(),mt=dn(n.activeViewport,s.getTargetViewport()),St=hi({target:V,click:B,comment:T,url:F});St.viewport=n.activeViewport,St.viewportSize=mt,St.attachmentIds=z.map(nt=>nt.id);let Kt=k(),Ve=pr("tmp-ann");n.applyAnnotationUpdate({id:Ve,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:Kt.authorName,authorImage:Kt.authorImage,payload:{...St,authorRole:Kt.role,authorId:Kt.authorId},attachments:z,thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(Ve);let Ce=await De({kind:"composer",payload:St},n.apiClient);if(Ce){let nt=Ce.attachments??[];n.replaceAnnotationId(Ve,Ce.id),n.updateAnnotation(Ce.id,Ae=>({...Ae,attachments:nt})),nt.length<z.length&&c("Some images expired before sending and were removed."),o.openExisting(Ce.id),n.refresh();return}n.updateAnnotation(Ve,nt=>({...nt,deliveryStatus:"failed"}));},[t,k,f,H,n,o,s]),U=useCallback(async T=>{if(!t||Gr(t))return;let z=t.thread.find(V=>V.id===T);if(!z||z.deliveryStatus!=="failed")return;n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===T?{...B,deliveryStatus:"sending"}:B)}));let _=await De({kind:"reply",annotationId:t.id,content:z.content,attachmentIds:(z.attachments??[]).map(V=>V.id)},n.apiClient);if(_){n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===T?{...B,id:_.id,deliveryStatus:"sent"}:B)})),n.refresh();return}n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===T?{...B,deliveryStatus:"failed"}:B)}));},[t,n]),ct=useCallback(async()=>{if(!t||t.deliveryStatus!=="failed")return;let T=t.id;n.updateAnnotation(T,_=>({..._,deliveryStatus:"sending"}));let z=await De({kind:"composer",payload:t.payload},n.apiClient);if(z){n.replaceAnnotationId(T,z.id),o.openExisting(z.id),n.refresh();return}n.updateAnnotation(T,_=>({..._,deliveryStatus:"failed"}));},[t,n,o]),dt=useCallback(T=>!E.authorId||T.deliveryStatus&&T.deliveryStatus!=="sent"?false:T.role===E.role&&T.authorId===E.authorId,[E]),ht=useCallback(()=>{w&&(c(null),u({kind:"annotation"}));},[w]),ut=useCallback(T=>{dt(T)&&(c(null),u({kind:"message",messageId:T.id}));},[dt]),pt=useCallback(()=>{c(null),u(null);},[]),rt=useCallback(async T=>{if(!t)return false;let z=t.thread;return g(async()=>(c(null),n.updateAnnotation(t.id,V=>({...V,thread:V.thread.filter(B=>B.id!==T)})),await Ci({annotationId:t.id,messageId:T},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(t.id,V=>({...V,thread:z})),c("Couldn't delete message. Try again."),false)))},[t,n,g]),j=useCallback(async()=>!t||!w?false:g(async()=>(c(null),await ki(t.id,n.apiClient)?(n.updateAnnotation(t.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[t,w,n,o,g]),A=useCallback(async()=>{if(d)try{(d.kind==="annotation"?await j():await rt(d.messageId))&&u(null);}catch{c("Couldn't delete. Try again.");}},[d,j,rt]),R=useCallback(async()=>{t&&await g(async()=>{c(null);let T={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 yi(t.id,n.apiClient)){n.updateAnnotation(t.id,_=>({..._,...T})),c("Couldn't resolve. Try again.");return}n.refresh();});},[t,n,g]),D=useCallback(async()=>{t&&await g(async()=>{c(null);let T={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 Ai({annotationId:t.id,viewerKind:h},n.apiClient)){n.updateAnnotation(t.id,_=>({..._,...T})),c("Couldn't reopen. Try again.");return}n.refresh();});},[t,h,n,g]),G=useCallback(async T=>{t&&await g(async()=>{c(null);let z=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 Si({annotationId:t.id,viewerKind:h,guidance:T},n.apiClient);if(!V?.ok){n.updateAnnotation(t.id,B=>({...B,latestRun:z,optimisticAction:_})),c(V?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[t,h,n,g]),W=useCallback(async T=>{let z=await Ti({...T,avatarSeed:n.clientAvatarSeed},n.apiClient);return z&&await n.setIdentity(z),z},[n]),$=h==="client"&&!n.identity&&m.length===0,O=!!t||m.length>0,X=n.agentRunReadiness?.ready??true,S=n.agentRunReadiness?.message??null,P=useCallback(()=>{if(o.hasDraft){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),N=t?Zn(t.payload):e||"annotation",K=t?.payload.viewport??n.activeViewport,tt=n.studio?n.studio.name:n.identity?.name??null,It=n.identity?.avatarSeed??n.clientAvatarSeed,Tt=n.studio?.userId??It,Fe=n.studio?.image??null,Be=n.studio?.userId??It,gr=useMemo(()=>({state:{annotation:t,messages:m,runState:x,draftText:o.draftText,draftAttachments:o.draftAttachments,busy:i,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:h==="studio",agentRunReady:X,agentRunSetupMessage:S,needsIdentity:$,isResolved:f,initialMessageLocked:b,threadVisible:O,canDeleteAnnotation:w},actions:{setDraftText:o.setDraftText,attachFiles:L,removeDraftAttachment:o.removeDraftAttachment,submit:I,retryMessage:U,retryInitialMessage:ct,requestDeleteAnnotation:ht,requestDeleteMessage:ut,canDeleteMessage:dt,cancelDelete:pt,confirmDelete:A,markResolved:R,reopen:D,runPatch:G,setIdentity:W,attemptClose:o.attemptClose,requestClose:P,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:N,viewport:K,shakeNonce:o.shakeNonce,viewer:{kind:h,authorId:E.authorId,name:tt,avatarKey:Tt,avatarSrc:Fe,generatedSeed:Be}}}),[t,m,x,o.draftText,o.draftAttachments,o.removeDraftAttachment,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,l,d,L,I,U,ct,ht,ut,dt,pt,A,R,D,G,W,h,X,S,$,f,b,O,w,P,N,K,E.authorId,tt,Tt,Fe,Be]);return jsx(Pi.Provider,{value:gr,children:r})}function J(){let t=use(Pi);if(!t)throw new Error("useThreadContext must be used inside <ThreadProvider>");return t}var Mc="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",_c={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 Oe(t="brand",e){return C(Mc,_c[t],e)}function At({variant:t="brand",className:e,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:Oe(t,e),...o})}function Mi(){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 jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children: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:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsx("div",{className:"text-xs text-muted-foreground",children:s}),t.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:t.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(At,{variant:"neutral",disabled:t.busy,onClick:e.cancelDelete,children:"Cancel"}),jsx(At,{variant:"destructive",disabled:t.busy,onClick:e.confirmDelete,children:t.busy?"Deleting\u2026":i})]})]})})}function Li(){let{state:t,actions:e}=J();return t.confirmDiscardOpen?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children: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:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(At,{variant:"neutral",onClick:()=>e.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(At,{variant:"destructive",onClick:()=>e.forceClose(),children:"Discard"})]})]})}):null}var Dc="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",Oc={sm:"size-7",md:"size-8"},zc={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 jsx("button",{ref:o,type:n,className:C(Dc,Oc[t],zc[e],r),...s})}function Di(){let{state:t}=J();return !t.showDevFooter||!t.annotation?null:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx($c,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(Bc,{})})]}),t.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:t.actionError}):null]})}function $c(){let{state:t,actions:e}=J(),[r,n]=useState(false),[o,s]=useState(""),[i,a]=useState(false),l=t.runState,c=l?.status;if(t.annotation?.status==="resolved")return 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",x=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 jsx("div",{className:"min-w-0 flex-1",children:jsxs(At,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(p){let k=wo(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Oe("brand","no-underline"),children:[jsx(M,{name:"pr",size:12}),k==="PR"?"View PR":`View PR ${k}`]})})}let h=jsxs(At,{variant:x,disabled:t.busy||f,className:f?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(Le,{size:12})," ",m]});return jsxs("div",{className:"min-w-0 flex-1",children:[f&&t.agentRunSetupMessage?jsx(st,{text:t.agentRunSetupMessage,tone:"warning",children:h}):h,r?jsx(Fc,{title:m,guidance:o,submitting:i||t.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:b}):null]})}function Fc({title:t,guidance:e,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:s}){return jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),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:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg bg-brand text-white",children:jsx(Le,{size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:t})]}),jsx(Pt,{size:"sm",title:"Close",onClick:o,children:jsx(M,{name:"x",size:12})})]}),jsxs("label",{className:"flex flex-col gap-1.5",children:[jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),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"})]}),jsxs("div",{className:"flex justify-end gap-2",children:[jsx(At,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(At,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function Bc(){let{state:t,actions:e}=J();return t.annotation?t.annotation.status==="resolved"?jsxs(At,{variant:"neutral",disabled:t.busy,onClick:()=>e.reopen(),children:[jsx(M,{name:"refresh",size:12}),"Reopen"]}):jsxs(At,{variant:"neutral",disabled:t.busy,onClick:()=>e.markResolved(),children:[jsx(M,{name:"check",size:12}),"Resolve"]}):null}var Vc={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"};function Ft(t,e){let r=t?.replace(/\s+/g," ").trim();return r?r.length<=e?r:`${r.slice(0,e-1)}...`:null}function zi(t){let e=t?.trim();return e||null}function Zt(t){return Number.isInteger(t)?String(t):t.toFixed(1)}function Wc(t){let e=t.viewport??"desktop",r=Vc[e],n=t.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function Uc(t){let e=t.coordinates,r=[`viewport (${Zt(e.viewportX)}, ${Zt(e.viewportY)})`,`documentY ${Zt(e.documentY)}`];return e.isFixed&&r.push("fixed"),r.join(", ")}function Yc(t){let e=t.boundingBox;return e?`x ${Zt(e.x)}, y ${Zt(e.y)}, ${Zt(e.width)}x${Zt(e.height)}`:null}function Gc(t){let e=t.domHints?.attributeSignature;if(!e)return null;let r=Object.entries(e).slice(0,12).map(([n,o])=>`${n}="${Ft(o,120)??""}"`);return r.length>0?r.join(", "):null}function Xc(t){let e=[`- Page: ${t.url}`,`- Element: ${Ft(t.elementPath||t.element,500)??"unknown"}`,`- Viewport: ${Wc(t)}`,`- Anchor: ${Uc(t)}`],r=Ft(t.targetLabel,160),n=Yc(t);return r&&e.push(`- Visible target: ${r}`),n&&e.push(`- Bounding box: ${n}`),`## Target
|
|
2273
2273
|
${e.join(`
|
|
2274
|
-
`)}`}function
|
|
2275
|
-
${e}`:null}function
|
|
2276
|
-
`)}${i}`}function
|
|
2274
|
+
`)}`}function Kc(t){let e=Ft(t.selectedText,1500);return e?`## Selected text
|
|
2275
|
+
${e}`:null}function qc(t){let e=t.role==="studio"?"workspace":"client",r=Ft(t.authorName,80),n=r?`${e} (${r})`:e,o=zi(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 Oi(t,e){return `- ${t.kind==="screenshot"?"Screenshot":"Image"} ${e} (${t.width}\xD7${t.height}): ${t.url}`}function jc(t){let e=[...(t.attachments??[]).map(r=>Oi(r,"attached to the feedback")),...t.thread.flatMap(r=>(r.attachments??[]).map(n=>Oi(n,"attached to a thread reply")))];return e.length===0?null:`## Attached images
|
|
2277
2277
|
View these images before making changes \u2014 they usually show the exact visual issue being reported.
|
|
2278
2278
|
${e.join(`
|
|
2279
|
-
`)}`}function
|
|
2280
|
-
${t.map(
|
|
2281
|
-
`)}`}function
|
|
2279
|
+
`)}`}function Zc(t){return t.length===0?null:`## Thread
|
|
2280
|
+
${t.map(qc).join(`
|
|
2281
|
+
`)}`}function Jc(t){let e=[],r=Ft(t.reactComponents,1e3),n=Ft(t.sourceFile,500),o=Ft(t.domHints?.cssSelector,500),s=Ft(t.domHints?.textSignature,300),i=Gc(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
|
|
2282
2282
|
${e.join(`
|
|
2283
|
-
`)}`:null}function
|
|
2284
|
-
${
|
|
2283
|
+
`)}`:null}function Hi(t){return ["Address this feedback in the repository.",`## Feedback
|
|
2284
|
+
${zi(t.payload.comment)??"(no feedback text)"}`,Xc(t.payload),Kc(t.payload),jc(t),Zc(t.thread),Jc(t.payload)].filter(Boolean).join(`
|
|
2285
2285
|
|
|
2286
|
-
`)}function Fi(){let{state:t,meta:e}=j(),r=t.annotation,n=Tt[e.viewport],o=r?.payload.selectedText;return 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:[jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[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}),jsx(ot,{text:Qt(e.viewport),placement:"bottom",children: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:jsx(N,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.isResolved?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:[jsx(N,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[t.showDevFooter&&r?jsx(td,{annotation:r}):null,jsx(rd,{}),jsx(ed,{})]})]})]}),o?jsx("div",{className:"rounded-lg bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children: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]=useState(false),n=useRef(null);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 jsx(ot,{text:e?"Copied":"Copy agent prompt",placement:"bottom",children:jsx(Pt,{"aria-label":e?"Copied agent prompt":"Copy agent prompt",onClick:s=>{o(s.currentTarget.ownerDocument);},children:jsxs("span",{className:"relative block",style:{width:14,height:14},children:[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:jsx(N,{name:"copy",size:14})}),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:jsx(N,{name:"check",size:13})})]})})})}function ed(){let{actions:t}=j();return jsx(Pt,{onClick:t.requestClose,title:"Close",children:jsx(N,{name:"x",size:14})})}function rd(){let{state:t,actions:e}=j(),[r,n]=useState(false);return t.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(Pt,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(N,{name:"more",size:14})}),r?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: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:[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=useReducedMotion(),s=ad(),i=t[e],a=t.length>1;return 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:createPortal(jsxs(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:[jsx(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),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:jsx(N,{name:"x",size:15})}),a?jsxs(Fragment,{children:[jsx(Bi,{side:"left",label:"Previous image",onClick:()=>n((e-1+t.length)%t.length)}),jsx(Bi,{side:"right",label:"Next image",onClick:()=>n((e+1)%t.length)}),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 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:jsx(N,{name:t==="left"?"chevron-left":"chevron-right",size:16})})}function Wi({attachments:t}){let[e,r]=useState(null);if(t.length===0)return null;let n=t.length===1;return jsxs("div",{className:C("mt-1.5 flex flex-wrap gap-1.5",n&&"max-w-[230px]"),children:[t.map((o,s)=>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: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?jsx(Vi,{attachments:t,index:e,onClose:()=>r(null),onNavigate:r}):null]})}function Ki(){let{state:t,actions:e,meta:r}=j(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,s=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),t.threadVisible?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?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=>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 jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(Vt,{initials:e,tint:r,src:t.avatarSrc,generatedSeed:t.generatedSeed,alt:t.name}),jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:t.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:nr(t.createdAt)})]}),t.canDelete&&t.onDelete?jsx(md,{onDelete:t.onDelete}):null,t.content?jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:t.content}):null,jsx(Wi,{attachments:t.attachments??[]}),n?jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsx("span",{className:"text-destructive",children:"Failed to send"}),t.onRetry?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]=useState(false),[n,o]=useState("down"),s=useRef(null),i=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=useCallback(()=>{r(l=>{let c=!l;return c&&i(),c});},[i]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx(Pt,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":e,"aria-haspopup":"menu",onClick:a,children:jsx(N,{name:"more",size:14})}),e?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: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:[jsx(N,{name:"trash",size:13}),"Delete"]})}):null]})}function qi({attachments:t,onRemove:e}){let r=useReducedMotion();return t.length===0?null:jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:jsx(AnimatePresence,{initial:false,children:t.map(n=>jsxs(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:[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"?jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg bg-black/28",children:jsx("span",{className:"size-4 animate-spin rounded-full border-[1.5px] border-white/40 border-t-white"})}):null,n.status==="failed"?jsx(ot,{text:"Upload failed",placement:"top",children:jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg text-destructive",children:jsx(N,{name:"x",size:16,stroke:2.2})})}):null,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: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 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]=useState(""),[n,o]=useState(""),[s,i]=useState(null),[a,l]=useState(false),c=useRef(null);return useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),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:[jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsx("input",{ref:c,type:"text",placeholder:"Name",value:e,onChange:u=>r(u.target.value),className:Zi}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:u=>o(u.target.value),className:Zi}),s?jsx("div",{className:"text-xs text-destructive",children:s}):null,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=useRef(null),s=useRef(null),[i,a]=useState(false);if(useEffect(()=>{t.needsIdentity||setTimeout(()=>o.current?.focus(),0);},[t.needsIdentity]),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 jsx("div",{className:C("bg-white px-4 py-3",t.threadVisible&&"border-t border-black/6"),children: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 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:jsxs("div",{className:C("bg-black/4 px-3 py-2.5 transition-colors",i||t.draftAttachments.length>0?"rounded-xl":"rounded-full"),children:[jsx(qi,{attachments:t.draftAttachments,onRemove:e.removeDraftAttachment}),jsxs("div",{className:"flex items-end gap-2",children:[jsx(Vt,{initials:m,tint:v,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:p??"",className:"self-start"}),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"}}),jsx("input",{ref:s,type:"file",accept:Sd,multiple:true,className:"hidden",onChange:x=>y(x.target.files)}),n.supported?jsx(ot,{text:"Capture screenshot",placement:"top",children:jsx(Pt,{"aria-label":"Capture screenshot",disabled:n.active,onClick:T,children:jsx(N,{name:"camera",size:15})})}):null,jsx(ot,{text:"Attach image",placement:"top",children:jsx(Pt,{"aria-label":"Attach image",onClick:()=>s.current?.click(),children:jsx(N,{name:"paperclip",size:15})})}),jsx(Td,{enabled:u})]})]})})}function Td({enabled:t}){return 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: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=useRef(null),[l,c]=useState(()=>Ld(i,e??t())),d=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]);useLayoutEffect(()=>{d();}),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]),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=useRef(s);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 jsx(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 jsxs(ut.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsx(ut.Header,{}),jsx(ut.Messages,{}),jsx(ut.Reply,{}),jsx(ut.ConfirmDiscard,{}),jsx(ut.ConfirmDelete,{})]})}function ca({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxs(ut.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsx(ut.Header,{}),jsx(ut.Messages,{}),jsx(ut.Reply,{}),jsx(ut.DevFooter,{}),jsx(ut.ConfirmDiscard,{}),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=useMemo(()=>!n||n.kind!=="existing"?null:e.annotations.find(u=>u.id===n.annotationId)??null,[n,e.annotations]),s=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=useMemo(()=>ua(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:a?jsx(Pi,{annotation:o,draftTargetLabel:c,children: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=useMemo(()=>fo({prop:t.projectToken,processEnv:bo(),importMetaEnv:ho()}),[t.projectToken]),n=t.apiBase??Xd;return useEffect(()=>{r||console.warn(go);},[r]),e||!r?null:jsx(Je,{children:jsx(ii,{children:jsx(yn,{children:jsx(Rn,{projectToken:r,apiBase:n,children:jsx(Kd,{children:jsx(Hn,{children:jsx(mo,{children:jsx(co,{projectToken:r,children:jsx(oo,{children:jsxs(ei,{children:[jsx(Uo,{}),jsx(ma,{}),jsx(Go,{}),jsx(_o,{})]})})})})})})})})})})}var qd=ga;
|
|
2287
|
-
export{
|
|
2286
|
+
`)}function Fi(){let{state:t,meta:e}=J(),r=t.annotation,n=Et[e.viewport],o=r?.payload.selectedText;return 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:[jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[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}),jsx(st,{text:ee(e.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":e.viewport,role:"img","aria-label":ee(e.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx(M,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.isResolved?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:[jsx(M,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[t.showDevFooter&&r?jsx(rd,{annotation:r}):null,jsx(od,{}),jsx(nd,{})]})]})]}),o?jsx("div",{className:"rounded-lg bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children: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 ed(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 rd({annotation:t}){let[e,r]=useState(false),n=useRef(null);useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async s=>{await ed(Hi(t),s)&&(r(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(false),1500));};return jsx(st,{text:e?"Copied":"Copy agent prompt",placement:"bottom",children:jsx(Pt,{"aria-label":e?"Copied agent prompt":"Copy agent prompt",onClick:s=>{o(s.currentTarget.ownerDocument);},children:jsxs("span",{className:"relative block",style:{width:14,height:14},children:[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:jsx(M,{name:"copy",size:14})}),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:jsx(M,{name:"check",size:13})})]})})})}function nd(){let{actions:t}=J();return jsx(Pt,{onClick:t.requestClose,title:"Close",children:jsx(M,{name:"x",size:14})})}function od(){let{state:t,actions:e}=J(),[r,n]=useState(false);return t.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(Pt,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(M,{name:"more",size:14})}),r?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: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:[jsx(M,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function ld(){return document.querySelector("patch-widget-root")?.shadowRoot?.querySelector("[data-patch-mount]")??null}function Wi({attachments:t,index:e,onClose:r,onNavigate:n}){let o=useReducedMotion(),s=ld(),i=t[e],a=t.length>1;return 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:createPortal(jsxs(m.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:[jsx(m.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),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:jsx(M,{name:"x",size:15})}),a?jsxs(Fragment,{children:[jsx(Vi,{side:"left",label:"Previous image",onClick:()=>n((e-1+t.length)%t.length)}),jsx(Vi,{side:"right",label:"Next image",onClick:()=>n((e+1)%t.length)}),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 Vi({side:t,label:e,onClick:r}){return 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:jsx(M,{name:t==="left"?"chevron-left":"chevron-right",size:16})})}function Ui({attachments:t}){let[e,r]=useState(null);if(t.length===0)return null;let n=t.length===1;return jsxs("div",{className:C("mt-1.5 flex flex-wrap gap-1.5",n&&"max-w-[230px]"),children:[t.map((o,s)=>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: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?jsx(Wi,{attachments:t,index:e,onClose:()=>r(null),onNavigate:r}):null]})}function qi(){let{state:t,actions:e,meta:r}=J(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,s=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),t.threadVisible?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?jsx(Xi,{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=>jsx(Xi,{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 Xi(t){let e=de(t.name),r=ue(t.authorKey),n=t.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(Gt,{initials:e,tint:r,src:t.avatarSrc,generatedSeed:t.generatedSeed,alt:t.name}),jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:t.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:nr(t.createdAt)})]}),t.canDelete&&t.onDelete?jsx(fd,{onDelete:t.onDelete}):null,t.content?jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:t.content}):null,jsx(Ui,{attachments:t.attachments??[]}),n?jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsx("span",{className:"text-destructive",children:"Failed to send"}),t.onRetry?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 md=44,gd=8;function fd({onDelete:t}){let[e,r]=useState(false),[n,o]=useState("down"),s=useRef(null),i=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<md+gd&&m>p?"up":"down");},[]),a=useCallback(()=>{r(l=>{let c=!l;return c&&i(),c});},[i]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx(Pt,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":e,"aria-haspopup":"menu",onClick:a,children:jsx(M,{name:"more",size:14})}),e?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: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:[jsx(M,{name:"trash",size:13}),"Delete"]})}):null]})}function ji({attachments:t,onRemove:e}){let r=useReducedMotion();return t.length===0?null:jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:jsx(AnimatePresence,{initial:false,children:t.map(n=>jsxs(m.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:[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"?jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg bg-black/28",children:jsx("span",{className:"size-4 animate-spin rounded-full border-[1.5px] border-white/40 border-t-white"})}):null,n.status==="failed"?jsx(st,{text:"Upload failed",placement:"top",children:jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg text-destructive",children:jsx(M,{name:"x",size:16,stroke:2.2})})}):null,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:jsx(M,{name:"x",size:9,stroke:2.4})})]},n.localId))})})}var wd={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 Zi({variant:t="default",className:e,ref:r,...n}){return jsx("textarea",{ref:r,className:C(wd[t],e),...n})}var Ad=/^[^\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 Qi(){let{actions:t}=J(),[e,r]=useState(""),[n,o]=useState(""),[s,i]=useState(null),[a,l]=useState(false),c=useRef(null);return useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxs("form",{onSubmit:async u=>{u.preventDefault();let p=e.trim(),m=n.trim();if(!p){i("Name is required.");return}if(!Ad.test(m)){i("Enter a valid email.");return}i(null),l(true);let x=await t.setIdentity({name:p,email:m});l(false),x||i("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsx("input",{ref:c,type:"text",placeholder:"Name",value:e,onChange:u=>r(u.target.value),className:Ji}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:u=>o(u.target.value),className:Ji}),s?jsx("div",{className:"text-xs text-destructive",children:s}):null,jsx("button",{type:"submit",disabled:a,className:C(Oe("brand"),"self-end",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}var Ed="image/jpeg,image/png,image/webp";function na(){let{state:t,actions:e,meta:r}=J(),n=ni(),o=useRef(null),s=useRef(null),[i,a]=useState(false);if(useEffect(()=>{t.needsIdentity||setTimeout(()=>o.current?.focus(),0);},[t.needsIdentity]),useEffect(()=>{let w=o.current;if(!w)return;w.style.height="0px";let H=Math.min(w.scrollHeight,140);w.style.height=`${H}px`,a(H>28);},[t.draftText]),t.isResolved||t.initialMessageLocked)return null;if(t.needsIdentity)return jsx("div",{className:C("bg-white px-4 py-3",t.threadVisible&&"border-t border-black/6"),children:jsx(Qi,{})});let l=t.draftText.trim().length>0,c=t.draftAttachments.some(w=>w.status==="uploaded"),d=t.draftAttachments.every(w=>w.status==="uploaded"),u=(t.annotation?l||c:l)&&d,p=r.viewer.name,m=de(p),x=r.viewer.kind==="studio"?"var(--color-foreground)":ue(r.viewer.avatarKey),f=w=>{w.preventDefault(),e.submit();},b=w=>{w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),e.submit());},h=w=>{let H=Array.from(w.clipboardData?.items??[]).filter(L=>L.kind==="file"&&L.type.startsWith("image/")).flatMap(L=>{let g=L.getAsFile();return g?[g]:[]});H.length!==0&&(w.preventDefault(),e.attachFiles(H));},k=w=>{!w||w.length===0||(e.attachFiles(Array.from(w)),s.current&&(s.current.value=""));},E=()=>{n.begin(w=>{e.attachFiles([w],"screenshot");});};return 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:jsxs("div",{className:C("bg-black/4 px-3 py-2.5 transition-colors",i||t.draftAttachments.length>0?"rounded-xl":"rounded-full"),children:[jsx(ji,{attachments:t.draftAttachments,onRemove:e.removeDraftAttachment}),jsxs("div",{className:"flex items-end gap-2",children:[jsx(Gt,{initials:m,tint:x,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:p??"",className:"self-start"}),jsx(Zi,{ref:o,variant:"bare",value:t.draftText,onChange:w=>e.setDraftText(w.target.value),onKeyDown:b,onPaste:h,rows:1,placeholder:t.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsx("input",{ref:s,type:"file",accept:Ed,multiple:true,className:"hidden",onChange:w=>k(w.target.files)}),n.supported?jsx(st,{text:"Capture screenshot",placement:"top",children:jsx(Pt,{"aria-label":"Capture screenshot",disabled:n.active,onClick:E,children:jsx(M,{name:"camera",size:15})})}):null,jsx(st,{text:"Attach image",placement:"top",children:jsx(Pt,{"aria-label":"Attach image",onClick:()=>s.current?.click(),children:jsx(M,{name:"paperclip",size:15})})}),jsx(Rd,{enabled:u})]})]})})}function Rd({enabled:t}){return 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:jsx(M,{name:"arrow-up",size:13})})}var _d=[.4,0,.2,1],Ld=[.22,.61,.36,1],Dd={x:-8,y:-8,origin:"top left"},ia=200;function aa(t,e,r){return Math.max(e,Math.min(r,t))}function sa(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:aa((n.x-o.x)*.08,-12,12),y:aa((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Od(t,e){if(!e)return Dd;let r=Ne({anchor:e,popover:{width:332,height:ia},viewport:t.getOverlayViewport()});return sa(e,r,ia)}function zd(t,e){return t.x===e.x&&t.y===e.y&&t.origin===e.origin}function la({getAnchorRect:t,initialAnchorRect:e,entryDelay:r=0,children:n}){let{actions:{attemptClose:o},meta:{shakeNonce:s}}=J(),i=vt(),a=useRef(null),[l,c]=useState(()=>Od(i,e??t())),d=useCallback(()=>{let m=a.current;if(!m)return;let x=t();if(!x)return;let f=m.offsetHeight||200,b=Ne({anchor:x,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=sa(x,b,f);c(k=>zd(k,h)?k:h);},[t,i]);useLayoutEffect(()=>{d();}),useEffect(()=>{let m=null,x=()=>{m===null&&(m=i.overlayWindow.requestAnimationFrame(()=>{m=null,d();}));},f=new Set([i.targetWindow,i.overlayWindow]);for(let h of f)h.addEventListener("resize",x),h.addEventListener("scroll",x,{passive:true});let b=En(i.overlayWindow,x);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",x),h.removeEventListener("scroll",x);b.disconnect();}},[d,i]),useEffect(()=>{let m=b=>{xo(b)||o();},x=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",x);return ()=>{for(let b of f)b.removeEventListener("mousedown",m,true),b.removeEventListener("keydown",x);}},[o,i]);let u=useRef(s);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 jsx(m.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:_d}},transition:{layout:{duration:.42,ease:Ld}},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 ft={Root:la,Header:Fi,Messages:qi,Reply:na,DevFooter:Di,ConfirmDiscard:Li,ConfirmDelete:Mi};function ca({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxs(ft.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsx(ft.Header,{}),jsx(ft.Messages,{}),jsx(ft.Reply,{}),jsx(ft.ConfirmDiscard,{}),jsx(ft.ConfirmDelete,{})]})}function da({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxs(ft.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsx(ft.Header,{}),jsx(ft.Messages,{}),jsx(ft.Reply,{}),jsx(ft.DevFooter,{}),jsx(ft.ConfirmDiscard,{}),jsx(ft.ConfirmDelete,{})]})}var Wd="data-patch-internal";function ma(t,e,r){let n={viewportX:e,viewportY:r},o=Yt(n,t.getOverlayViewport());return pe(n,o)}function Ud(t,e){return t.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(e)??null}function Yd(t,e){let r=Ud(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 Gd(t,e){if(!e)return null;let r=zo({payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Wd}),n=t.targetPointToOverlay(r.position);return ma(t,n.viewportX,n.viewportY)}function pa(t,e,r){if(!e)return null;if(e.kind==="existing")return Yd(t,e.annotationId)??Gd(t,r);let n=t.targetPointToOverlay({viewportX:e.anchor.viewportX,viewportY:e.anchor.documentY-t.getTargetScrollY()});return ma(t,n.viewportX,n.viewportY)}function ga(){let t=xt(),e=it(),r=vt(),n=t.active,o=useMemo(()=>!n||n.kind!=="existing"?null:e.annotations.find(u=>u.id===n.annotationId)??null,[n,e.annotations]),s=useCallback(()=>pa(r,n,o),[n,o,r]),i=e.viewerKind==="studio"?da:ca,a=n&&(n.kind==="composer"||!!o),l=n?.kind==="composer"?.04:0,c=n?.kind==="composer"?fi(n.target):null,d=useMemo(()=>pa(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:a?jsx(Ii,{annotation:o,draftTargetLabel:c,children:jsx(i,{getAnchorRect:s,initialAnchorRect:d,entryDelay:l})},"active-popover"):null})}var Zd="https://app.usepatch.dev";function Jd({children:t}){let{active:e}=it();return e?t:null}function fa(t){let e=typeof window<"u"&&Tn(window),r=useMemo(()=>go({prop:t.projectToken,processEnv:ho(),importMetaEnv:fo()}),[t.projectToken]),n=t.apiBase??Zd;return useEffect(()=>{r||console.warn(mo);},[r]),e||!r?null:jsx(Qe,{children:jsx(ai,{children:jsx(LazyMotion,{features:domAnimation,strict:true,children:jsx(Rn,{children:jsx(Dn,{projectToken:r,apiBase:n,children:jsx(Jd,{children:jsx(zn,{children:jsx(po,{children:jsx(lo,{projectToken:r,children:jsx(no,{children:jsxs(ri,{children:[jsx(Yo,{}),jsx(ga,{}),jsx(Xo,{}),jsx(Mo,{})]})})})})})})})})})})})}var Qd=fa;
|
|
2287
|
+
export{fa as Patch,Qd as default};
|