@usepatch/widget 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),react$1=require('motion/react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function be(e){if(e.length<=1||!e.endsWith("/"))return e;try{let t=new URL(e);if(t.pathname==="/"&&e.endsWith("/"))return `${t.origin}${t.search}${t.hash}`}catch{}return e.slice(0,-1)}var ve={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"}},_r=["desktop","tablet","mobile"];function $e(e){let t=ve[e];return t.width===null||t.height===null?t.label:`${t.label} (${t.width}px \xD7 ${t.height}px)`}function Dr(e,t){let r=ve[e];return {width:r.width??t.width,height:r.height??t.height}}var Ii=32,Ni=32,Pi=3e3,zr="cubic-bezier(0.16, 1, 0.3, 1)",Ct=[.22,.61,.36,1],Hr=.3,Fr=.5,Mi=.34,_i=.5,Di=.24,Oi=.22,$r=.12,Li=.42,Vr=.2,zi=200,Hi=260,Fi=70,$i=180,Vi=260,Bi=8,Wi=4,Yi="#d9d9dd",Xi=30,Ui=["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 At(e,t,r){let n=Math.max(320,e.innerWidth-Ii*2),o=Math.max(320,e.innerHeight-Ni*2);return Math.min(1,n/t,o/r)}function Gi(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function Br({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:i}){let s=react$1.useReducedMotion(),a=t.width??r.innerWidth,l=t.height??r.innerHeight,c=t.viewport,p=`${c}:${a}:${l}`,g=!!r.happyDOM?.settings?.disableIframePageLoading,[u,f]=react.useState(()=>({viewport:c,width:a,height:l,scale:At(r,a,l)})),[x,w]=react.useState("stable"),[E,k]=react.useState(false),[m,d]=react.useState(false),v=react.useRef(false),C=react.useRef(null),P=`${u.viewport}:${u.width}:${u.height}`!==p,X=E&&!m&&!(P||x==="cover"||x==="resize"),G=E&&!m&&x==="stable"&&!P,re=react.useCallback(h=>{C.current=h,n(h);},[n]),b=react.useCallback(()=>{let h=C.current;if(!h||!Gi(h)){v.current=false,k(false),d(true);return}v.current=true,k(true),d(false);},[]),A=react.useCallback(()=>{f(h=>{let N=At(r,h.width,h.height);return h.scale===N?h:{...h,scale:N}});},[r]);react.useEffect(()=>(A(),r.addEventListener("resize",A),()=>r.removeEventListener("resize",A)),[r,A]),react.useEffect(()=>{v.current=false,k(false),d(false);let h=r.setTimeout(()=>{v.current||d(true);},Pi);return ()=>r.clearTimeout(h)},[e,r]),react.useEffect(()=>{if(s){P&&f({viewport:c,width:a,height:l,scale:At(r,a,l)}),x!=="stable"&&w("stable");return}switch(x){case "stable":{P&&w("cover");return}case "cover":{let h=r.setTimeout(()=>w("resize"),Fi);return ()=>r.clearTimeout(h)}case "resize":{P&&f({viewport:c,width:a,height:l,scale:At(r,a,l)});let h=r.setTimeout(()=>w("reveal"),$i);return ()=>r.clearTimeout(h)}case "reveal":{let h=r.setTimeout(()=>w("stable"),Vi);return ()=>r.clearTimeout(h)}}},[x,P,s,r,c,a,l]),react.useEffect(()=>{o(G);},[G,o]),react.useEffect(()=>{i(m);},[m,i]);let M=s?{duration:0}:{duration:Di,ease:Ct},I=s?{duration:0}:{duration:Oi,ease:Ct,delay:Vr*.5},D=s?{duration:0}:{duration:Vr,ease:Ct},ie=s?{duration:0}:{opacity:{duration:Li,ease:Ct,delay:$r},scale:{type:"spring",bounce:Mi,duration:_i,delay:$r},width:{type:"spring",bounce:Hr,duration:Fr},height:{type:"spring",bounce:Hr,duration:Fr}},Q=(X?Hi:zi)/1e3,le=s?void 0:`opacity ${Q}s ${zr}, filter ${Q}s ${zr}`,ce=u.width*u.scale,Ce=u.height*u.scale;return jsxRuntime.jsx(react$1.motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:M},exit:{opacity:0,transition:I},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxRuntime.jsxs(react$1.motion.div,{initial:s?{opacity:0,width:ce,height:Ce}:{opacity:0,scale:.8,width:ce,height:Ce},animate:{opacity:1,scale:1,width:ce,height:Ce},exit:s?{opacity:0}:{opacity:0,scale:.92,transition:D},transition:ie,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${Wi}px solid ${Yi}`,borderRadius:Xi,boxShadow:Ui,willChange:"width, height"},children:[jsxRuntime.jsx("div",{"aria-hidden":!X,className:"absolute top-0 left-0 origin-top-left",style:{width:u.width,height:u.height,transform:`scale(${u.scale})`,opacity:X?1:0,filter:s||X?"none":`blur(${Bi}px)`,transition:le,pointerEvents:X?"auto":"none",willChange:"opacity, filter"},children:jsxRuntime.jsx("iframe",{ref:re,"data-patch-preview-frame":"","data-patch-preview-src":e,title:`${t.label} preview`,tabIndex:X?0:-1,src:g?void 0:e,srcDoc:g?"<!doctype html><html><body></body></html>":void 0,onLoad:b,className:"block bg-white",style:{width:u.width,height:u.height,border:0}})}),jsxRuntime.jsx(Ki,{visible:m})]})})}function Ki({visible:e}){return e?jsxRuntime.jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsxRuntime.jsx("div",{className:"max-w-[320px] rounded-[20px] 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 Ur=react.createContext(null),Gr=react.createContext(null),Kr="__patch_preview";function qr(){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:()=>be(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:e=>({...e}),targetRectToOverlay:e=>({...e}),eventTargetElement:e=>e instanceof window.Element?e:null}}function Ji(e){let t=new URL(e.location.href);return t.searchParams.set(Kr,"1"),t.toString()}function jr(e=window){try{return new URL(e.location.href).searchParams.get(Kr)==="1"}catch{return false}}function Qi(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function i(){return t.getBoundingClientRect()}function s(){let l=i();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:e.overlayWindow,overlayDocument:e.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:e.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>be(`${n.location.origin}${n.location.pathname}`),targetPointToOverlay:l=>{let c=i(),p=s();return {viewportX:c.left+l.viewportX*p,viewportY:c.top+l.viewportY*p}},targetRectToOverlay:l=>{let c=i(),p=s();return {x:c.left+l.x*p,y:c.top+l.y*p,width:l.width*p,height:l.height*p}},eventTargetElement:a}}function Tt(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function Zr({children:e}){let t=react.useMemo(()=>qr(),[]),[r,n]=react.useState("desktop"),[o,i]=react.useState(null),[s,a]=react.useState(false),[l,c]=react.useState(false),[p,g]=react.useState(false),u=r!=="desktop",f=u||p,x=ve[r],w=x.width&&x.height?{width:x.width,height:x.height}:null;react.useEffect(()=>{a(false),c(false);},[r]);let E=react.useRef(u);react.useEffect(()=>{E.current&&!u?g(true):!E.current&&u&&g(false),E.current=u;},[u]);let k=react.useMemo(()=>t?!u||!s||l||!o||!w?t:Qi(t,o,w)??t:null,[l,o,s,u,w,t]),m=react.useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:f,previewReady:f?u&&s&&!l:true,previewBlocked:u&&l}),[r,l,s,u,f]),d=react.useMemo(()=>t?Ji(t.targetWindow):"",[t]);return !k||!t?null:jsxRuntime.jsx(Gr.Provider,{value:m,children:jsxRuntime.jsxs(Ur.Provider,{value:k,children:[e,jsxRuntime.jsx(react$1.AnimatePresence,{onExitComplete:()=>g(false),children:u&&w?jsxRuntime.jsx(Br,{src:d,viewport:x,overlayWindow:t.overlayWindow,onFrameElement:i,onReadyChange:a,onBlockedChange:c}):null})]})})}function se(){let e=react.use(Ur),t=react.useMemo(()=>qr(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function Ye(){let e=react.use(Gr),[t,r]=react.useState("desktop"),n=react.useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var ta="X-Patch-Client-Id";function pe(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[ta]:e.clientUserId}:{}}}async function xe(e,t){try{let r=await fetch(e,t);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function ra(e,t){try{let r=await fetch(e,t),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 Jr(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await xe(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:pe(e,false)}))?.annotations??[]},async fetchMe(){return xe(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:pe(e,false)})},async postIdentity(t){let r=await xe(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(t)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(t){return xe(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(t)})},async reply(t,r){return xe(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return xe(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:pe(e,false)})},async deleteMessage(t,r){return xe(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:pe(e,false)})},async kickoff(t,r){return ra(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(r)})},async resolve(t){return xe(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:pe(e,true)})},async reopen(t){return xe(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:pe(e,true)})}}}var or="patch.clientIdentity",Qr="patch.clientAvatarSeed";function ir(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(or);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function en(e){return ir()[e]??null}function ar(e,t){if(!(typeof window>"u"))try{let r=ir();r[e]=t,window.localStorage.setItem(or,JSON.stringify(r));}catch{}}function tn(e){if(!(typeof window>"u"))try{let t=ir();delete t[e],window.localStorage.setItem(or,JSON.stringify(t));}catch{}}function na(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(Qr);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function nr(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function rn(e){if(typeof window>"u")return nr();try{let t=na(),r=t[e];if(r)return r;let n=nr();return t[e]=n,window.localStorage.setItem(Qr,JSON.stringify(t)),n}catch{return nr()}}var aa=2e4,on=react.createContext(null);function sa(e,t){let r=new Map(e.map(s=>[s.id,s])),n=new Set(t.map(s=>s.id)),o=t.map(s=>{let a=r.get(s.id);if(!a)return s;let l=new Set(s.thread.map(g=>g.id)),c=a.thread.filter(g=>g.deliveryStatus&&!l.has(g.id)),p=c.length>0?{...s,thread:[...s.thread,...c]}:s;if(a.optimisticAction==="resolve-pending"&&s.status!=="resolved"&&(p={...p,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="reopen-pending"&&s.status==="resolved"&&(p={...p,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="run-pending"&&a.latestRun?.id.startsWith("tmp-run")){let g=s.latestRun?Date.parse(s.latestRun.createdAt):Number.NaN,u=Date.parse(a.latestRun.createdAt);s.latestRun!=null&&(Number.isNaN(u)||Number.isNaN(g)||g>=u)||(p={...p,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return p}),i=e.filter(s=>(s.deliveryStatus||s.optimisticAction)&&!n.has(s.id));return [...o,...i]}function an({projectToken:e,apiBase:t,children:r}){let n=se(),{activeViewport:o,setActiveViewport:i}=Ye(),[s,a]=react.useState(()=>typeof window>"u"?null:en(e)),[l]=react.useState(()=>typeof window>"u"?"client-avatar:ssr":rn(e)),[c,p]=react.useState(null),[g,u]=react.useState("client"),[f,x]=react.useState(null),[w,E]=react.useState([]),[k,m]=react.useState(null),[d,v]=react.useState([]),[C,T]=react.useState(false),P=react.useRef(o);P.current=o;let z=k===o,X=react.useMemo(()=>Jr({apiBase:t,token:e,clientUserId:s?.clientUserId}),[t,e,s?.clientUserId]),G=react.useRef(X);G.current=X;let re=react.useRef(0),b=react.useCallback(async()=>{let h=o,N=++re.current,H=await G.current.listAnnotations(h==="desktop"?void 0:h);if(N!==re.current||h!==P.current)return;let U=n.getPageUrl(),ue=H.filter(ae=>be(ae.payload.url)===U);E(ae=>sa(ae,ue)),m(h);},[o,n]),A=react.useRef(b);A.current=b,react.useEffect(()=>{let h=false;return (async()=>{let N=await G.current.fetchMe();if(!h){if(N?.studio)p(N.studio),u("studio"),x(N.agentRunReadiness??{ready:true,message:null});else if(p(null),u("client"),x(null),N?.client){let H={clientUserId:N.client.id,name:N.client.name,email:N.client.email,avatarSeed:N.client.avatarSeed};a(H),ar(e,H);}await A.current(),h||T(true);}})(),()=>{h=true;}},[e]),react.useEffect(()=>{C&&b();},[C,b]),react.useEffect(()=>{let{overlayDocument:h,overlayWindow:N}=n,H=N.setInterval(()=>{h.visibilityState==="visible"&&b();},aa),U=()=>{h.visibilityState==="visible"&&b();};return h.addEventListener("visibilitychange",U),()=>{N.clearInterval(H),h.removeEventListener("visibilitychange",U);}},[b,n]);let M=react.useCallback(async h=>(ar(e,h),a(h),h),[e]),I=react.useCallback(()=>{a(null),tn(e);},[e]),D=react.useCallback(h=>{v(N=>[...N.filter(H=>H.tempId!==h.tempId),h]);},[]),ie=react.useCallback(h=>{v(N=>N.filter(H=>H.tempId!==h));},[]),Q=react.useCallback(h=>{E(N=>{let H=N.findIndex(ue=>ue.id===h.id);if(H===-1)return [...N,h];let U=N.slice();return U[H]=h,U});},[]),le=react.useCallback((h,N)=>{E(H=>{let U=false,ue=H.flatMap(ae=>{if(ae.id!==h)return [ae];U=true;let Me=N(ae);return Me?[Me]:[]});return U?ue:H});},[]),ce=react.useCallback((h,N)=>{E(H=>H.map(U=>U.id===h?{...U,id:N,deliveryStatus:"sent"}:U));},[]),Ce=react.useMemo(()=>({apiClient:X,ready:C,viewerKind:g,agentRunReadiness:f,activeViewport:o,clientAvatarSeed:l,identity:s,studio:c,annotations:w,annotationsReady:z,ephemerals:d,refresh:b,setActiveViewport:i,setIdentity:M,signOut:I,addEphemeral:D,removeEphemeral:ie,applyAnnotationUpdate:Q,updateAnnotation:le,replaceAnnotationId:ce}),[X,C,g,f,o,l,s,c,w,z,d,b,i,M,I,D,ie,Q,le,ce]);return jsxRuntime.jsx(on.Provider,{value:Ce,children:r})}function me(){let e=react.use(on);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var sn=react.createContext(null);function ln({children:e}){let[t,r]=react.useState(null),[n,o]=react.useState(""),[i,s]=react.useState(0),[a,l]=react.useState(false),c=react.useCallback(()=>{r(null),o(""),l(false);},[]),p=react.useCallback(w=>{r({kind:"existing",annotationId:w}),o(""),l(false);},[]),g=react.useCallback(w=>{r({kind:"composer",...w}),o(""),l(false);},[]),u=react.useCallback(()=>{if(n.trim().length>0){s(w=>w+1);return}c();},[n,c]),f=react.useCallback(()=>{c();},[c]),x=react.useMemo(()=>({active:t,draftText:n,shakeNonce:i,confirmDiscardOpen:a,openExisting:p,openComposer:g,setDraftText:o,attemptClose:u,forceClose:f,setConfirmDiscardOpen:l}),[t,n,i,a,p,g,u,f]);return jsxRuntime.jsx(sn.Provider,{value:x,children:e})}function ge(){let e=react.use(sn);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var un=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"]),ma=new Set(["a","button","input","select","textarea"]),pn={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"},Oe=40,ga=1500,cn=200,fa=5,ha=10;function lr(e){return un.has(e.tagName.toLowerCase())}function ye(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Xe(e){return `"${e}"`}function ba(e){let t="";for(let r of Array.from(e.childNodes))r.nodeType===3&&(t+=r.textContent??"");return t.replace(/\s+/g," ").trim()}function Rt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function va(e){return !(!e||e.length>40||/__[A-Za-z0-9]{4,}$/.test(e)||/_[a-z0-9]{4,}$/i.test(e)&&/[0-9]/.test(e)||/_[A-Za-z0-9]{5,}_/.test(e)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(e)||/^[a-z]{2,}:[\w-]+$/.test(e)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(e)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(e)||(e.match(/\d/g)?.length??0)/e.length>.4)}function Le(e){let t=Array.from(e.classList),r=t.filter(va).slice(0,ha);return r.length>0?r:t.length>0?["container"]:[]}function mn(e){let t=e.getAttribute("role")??void 0,r=e.getAttribute("aria-label")??void 0,n=e.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,i=e.tagName.toLowerCase(),s=ma.has(i)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!s)return;let a={focusable:s};return t!==void 0&&(a.role=t),r!==void 0&&(a.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(a.tabIndex=o),a}function xa(e){let t=e.tagName.toLowerCase(),r=pn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Xe(ye(n,Oe))}`;let o=e.placeholder;if(o)return `${r} ${Xe(ye(o,Oe))}`;let i=e.getAttribute("name");if(i)return `${r}[name="${i}"]`;if(t==="input"){let s=e.type||"text";return `${r}[type=${s}]`}return r}function wa(e){let t=e.alt?.trim();return t?`img ${Xe(ye(t,Oe))}`:"img"}function nt(e){let t=e.tagName.toLowerCase();if(t==="img")return wa(e);if(t==="input"||t==="textarea"||t==="select")return xa(e);let r=pn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Xe(ye(n,Oe))}`;if(t==="a"||t==="button"||un.has(t)||t==="label"){let i=Rt(e);if(i)return `${r} ${Xe(ye(i,Oe))}`;if(t==="a"||t==="button"){let s=e.querySelector("svg");if(s){let l=s.getAttribute("aria-label");return l?`${r} ${Xe(ye(l,Oe))}`:`${r} (icon)`}let a=e.getAttribute("href");if(t==="a"&&a)return `link[href="${ye(a,Oe)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=Le(e);return o.length>0?`${t}.${o[0]}`:t}function gn(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(nt(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,ga)}function fn(e){let t=Rt(e),r=e.parentElement;if(!r)return;let n=Rt(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let i=Rt(o);return !i||i===t?void 0:ye(i,cn)}return ye(n,cn)}}function hn(e){let t=e.parentElement;if(!t)return [];let r=[];for(let n of Array.from(t.children))if(n!==e&&n.tagName.toLowerCase()!=="script"&&(r.push(nt(n)),r.length>=fa))break;return r}var ya=["role","aria-label","name"],ka=10,dn=100;function It(e){let t={};for(let r of ya){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,dn));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=ka)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,dn));}return t}function Nt(e){return ba(e)}function bn(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function Pt(e,t){return e.closest(`[${t}]`)!==null}var Ca=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"]),Aa={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"},Ta={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"},Sa={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 xn(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function Ea(e){return `"${e}"`}function Mt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function vn(e){let t=e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""}function j(e,t){let r=t?.trim();return r?`${e}: ${Ea(xn(r,48))}`:e}function Ra(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function Ia(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Sa[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":Ta[n]??"Area":"Area"}function Na(e){let t=e.getAttribute("aria-label");if(t)return j("Field",t);let r=e.placeholder;if(r)return j("Field",r);let n=e.getAttribute("name");if(n)return j("Field",vn(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return j("Field",vn(o))}return "Field"}function ot(e,t){if(t?.trim())return j("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return j("Button",n??Mt(e));if(r==="a")return j("Link",n??Mt(e));if(r==="input"||r==="textarea"||r==="select")return Na(e);if(r==="img"){let i=e.alt;return j("Image",i)}if(r==="svg")return j("Icon",n);if(/^h[1-6]$/.test(r))return j("Heading",Mt(e));if(Ca.has(r))return j("Text",Mt(e));let o=Aa[r];return j(o||"Area",n)}function _t(e){return e===1?"1 item selected":`${e} items selected`}function Dt(){return "Selected area"}function wn(e){if(e.targetLabel?.trim())return xn(e.targetLabel,120);if(e.selectedText?.trim())return j("Selected text",e.selectedText);let t=e.element?.trim()||e.elementPath?.trim();if(!t)return "Annotation";let r=t.match(/^(\d+)\s+elements?:/i);if(r)return _t(Number(r[1]));if(/^region\b/i.test(t))return Dt();let n=Ra(t.split(">").at(-1)??t);return j(Ia(n.base),n.text)}function An(e){let{clickTarget:t,selection:r}=e,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),i=bn(o.commonAncestorContainer);if(i)return {kind:"element",element:i,rect:i.getBoundingClientRect(),selectedText:n,clickTarget:t}}return {kind:"element",element:t,rect:t.getBoundingClientRect(),clickTarget:t}}var yn=20,Tn=7,kn=10,Pa=.8,Ma=.5,_a=new Set(["html","body","head","script","style","meta","link","title","br","noscript"]),Da=new Set(["section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details","summary"]),Ot=24;function Sn(e){let t=e.tagName.toLowerCase();if(Da.has(t))return true;if(t==="div"||t==="span"){if(e.id)return true;let r=Le(e);if(r.length>0&&r[0]!=="container")return true}return false}var Oa=["a","button","input","select","textarea","img","svg","h1","h2","h3","h4","h5","h6","p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","div","section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details"].join(",");function Cn(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function La(e,t){return !(e.x+e.width<t.x||t.x+t.width<e.x||e.y+e.height<t.y||t.y+t.height<e.y)}function za(e,t,r){if(Pt(e,r))return false;let n=e.tagName.toLowerCase();if(_a.has(n))return false;let o=e.getBoundingClientRect();if(o.width<kn||o.height<kn||o.width>t.width*Pa||o.height>t.height*Ma)return false;if(n==="div"||n==="span"){let i=Array.from(e.childNodes).some(l=>l.nodeType===3&&(l.textContent??"").trim().length>0),s=e.getAttribute("role"),a=s!==null&&s.length>0;if(!i&&!a&&!Sn(e))return false}return true}function Ha(e){return e.filter(t=>!e.some(r=>r!==t&&t.contains(r)))}function Fa(e,t){let r=[...e].sort((n,o)=>{let i=n.getBoundingClientRect(),s=o.getBoundingClientRect();return i.width*i.height-s.width*s.height});for(let n of r){if(!Sn(n)||!e.every(a=>a===n||n.contains(a)))continue;let i=n.getBoundingClientRect();if(i.left>=t.x-Ot&&i.top>=t.y-Ot&&i.right<=t.x+t.width+Ot&&i.bottom<=t.y+t.height+Ot)return n}return null}function $a(e){let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let i of e)i.x<t&&(t=i.x),i.y<r&&(r=i.y),i.x+i.width>n&&(n=i.x+i.width),i.y+i.height>o&&(o=i.y+i.height);return {x:t,y:r,width:n-t,height:o-r}}function Va(e){let t=e.x+e.width/2,r=e.y+e.height/2,n=e.x+e.width,o=e.y+e.height;return [{x:e.x,y:e.y},{x:t,y:e.y},{x:n,y:e.y},{x:e.x,y:r},{x:t,y:r},{x:n,y:r},{x:e.x,y:o},{x:t,y:o},{x:n,y:o}]}function En(e){let{rect:t,viewport:r,internalAttr:n}=e,o=e.doc??document,i=new Set;for(let c of Va(t)){let p=o.elementsFromPoint(c.x,c.y);for(let g of p)i.add(g);}for(let c of Array.from(o.querySelectorAll(Oa)))La(Cn(c.getBoundingClientRect()),t)&&i.add(c);let s=Array.from(i).filter(c=>za(c,r,n)),a=Fa(s,t),l=a?[a]:Ha(s);if(l.length>0){let c=l.map(p=>Cn(p.getBoundingClientRect()));return {kind:"multi",elements:l,rects:c,union:$a(c)}}return t.width>=yn&&t.height>=yn?{kind:"area",rect:t}:null}var Rn="patch-capture-cursor-style";function Ba(e){let t=`:not([${e}]):not([${e}] *)`,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}${t}`).join(`,
2
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),react$1=require('motion/react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function pe(e){if(e.length<=1||!e.endsWith("/"))return e;try{let t=new URL(e);if(t.pathname==="/"&&e.endsWith("/"))return `${t.origin}${t.search}${t.hash}`}catch{}return e.slice(0,-1)}var rr="patch:locationchange",Dr="__patchHistoryPatched";function Ni(e){let t=e.history;if(t[Dr])return;t[Dr]=true;let r=()=>e.dispatchEvent(new Event(rr)),{pushState:n,replaceState:o}=t;try{t.pushState=function(...i){let a=n.apply(this,i);return r(),a},t.replaceState=function(...i){let a=o.apply(this,i);return r(),a};}catch{}}function Lr(e,t){Ni(e);let r=()=>t();return e.addEventListener("popstate",r),e.addEventListener("hashchange",r),e.addEventListener(rr,r),()=>{e.removeEventListener("popstate",r),e.removeEventListener("hashchange",r),e.removeEventListener(rr,r);}}var ve={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"}},Or=["desktop","tablet","mobile"];function Ve(e){let t=ve[e];return t.width===null||t.height===null?t.label:`${t.label} (${t.width}px \xD7 ${t.height}px)`}function zr(e,t){let r=ve[e];return {width:r.width??t.width,height:r.height??t.height}}var _i=32,Di=32,Li=3e3,Vr="cubic-bezier(0.16, 1, 0.3, 1)",Ct=[.22,.61,.36,1],$r=.3,Br=.5,Oi=.34,zi=.5,Hi=.24,Fi=.22,Wr=.12,Vi=.42,Yr=.2,$i=200,Bi=260,Wi=70,Yi=180,Ui=260,Xi=8,Gi=4,Ki="#d9d9dd",qi=30,ji=["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 At(e,t,r){let n=Math.max(320,e.innerWidth-_i*2),o=Math.max(320,e.innerHeight-Di*2);return Math.min(1,n/t,o/r)}function Zi(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function Ur({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:i}){let a=react$1.useReducedMotion(),s=t.width??r.innerWidth,l=t.height??r.innerHeight,c=t.viewport,p=`${c}:${s}:${l}`,g=!!r.happyDOM?.settings?.disableIframePageLoading,[u,f]=react.useState(()=>({viewport:c,width:s,height:l,scale:At(r,s,l)})),[x,w]=react.useState("stable"),[T,k]=react.useState(false),[m,d]=react.useState(false),v=react.useRef(false),C=react.useRef(null),N=`${u.viewport}:${u.width}:${u.height}`!==p,U=T&&!m&&!(N||x==="cover"||x==="resize"),G=T&&!m&&x==="stable"&&!N,ne=react.useCallback(h=>{C.current=h,n(h);},[n]),b=react.useCallback(()=>{let h=C.current;if(!h||!Zi(h)){v.current=false,k(false),d(true);return}v.current=true,k(true),d(false);},[]),A=react.useCallback(()=>{f(h=>{let R=At(r,h.width,h.height);return h.scale===R?h:{...h,scale:R}});},[r]);react.useEffect(()=>(A(),r.addEventListener("resize",A),()=>r.removeEventListener("resize",A)),[r,A]),react.useEffect(()=>{v.current=false,k(false),d(false);let h=r.setTimeout(()=>{v.current||d(true);},Li);return ()=>r.clearTimeout(h)},[e,r]),react.useEffect(()=>{if(a){N&&f({viewport:c,width:s,height:l,scale:At(r,s,l)}),x!=="stable"&&w("stable");return}switch(x){case "stable":{N&&w("cover");return}case "cover":{let h=r.setTimeout(()=>w("resize"),Wi);return ()=>r.clearTimeout(h)}case "resize":{N&&f({viewport:c,width:s,height:l,scale:At(r,s,l)});let h=r.setTimeout(()=>w("reveal"),Yi);return ()=>r.clearTimeout(h)}case "reveal":{let h=r.setTimeout(()=>w("stable"),Ui);return ()=>r.clearTimeout(h)}}},[x,N,a,r,c,s,l]),react.useEffect(()=>{o(G);},[G,o]),react.useEffect(()=>{i(m);},[m,i]);let M=a?{duration:0}:{duration:Hi,ease:Ct},I=a?{duration:0}:{duration:Fi,ease:Ct,delay:Yr*.5},D=a?{duration:0}:{duration:Yr,ease:Ct},j=a?{duration:0}:{opacity:{duration:Vi,ease:Ct,delay:Wr},scale:{type:"spring",bounce:Oi,duration:zi,delay:Wr},width:{type:"spring",bounce:$r,duration:Br},height:{type:"spring",bounce:$r,duration:Br}},ee=(U?Bi:$i)/1e3,le=a?void 0:`opacity ${ee}s ${Vr}, filter ${ee}s ${Vr}`,ce=u.width*u.scale,Ce=u.height*u.scale;return jsxRuntime.jsx(react$1.motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:M},exit:{opacity:0,transition:I},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxRuntime.jsxs(react$1.motion.div,{initial:a?{opacity:0,width:ce,height:Ce}:{opacity:0,scale:.8,width:ce,height:Ce},animate:{opacity:1,scale:1,width:ce,height:Ce},exit:a?{opacity:0}:{opacity:0,scale:.92,transition:D},transition:j,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${Gi}px solid ${Ki}`,borderRadius:qi,boxShadow:ji,willChange:"width, height"},children:[jsxRuntime.jsx("div",{"aria-hidden":!U,className:"absolute top-0 left-0 origin-top-left",style:{width:u.width,height:u.height,transform:`scale(${u.scale})`,opacity:U?1:0,filter:a||U?"none":`blur(${Xi}px)`,transition:le,pointerEvents:U?"auto":"none",willChange:"opacity, filter"},children:jsxRuntime.jsx("iframe",{ref:ne,"data-patch-preview-frame":"","data-patch-preview-src":e,title:`${t.label} preview`,tabIndex:U?0:-1,src:g?void 0:e,srcDoc:g?"<!doctype html><html><body></body></html>":void 0,onLoad:b,className:"block bg-white",style:{width:u.width,height:u.height,border:0}})}),jsxRuntime.jsx(Ji,{visible:m})]})})}function Ji({visible:e}){return e?jsxRuntime.jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsxRuntime.jsx("div",{className:"max-w-[320px] rounded-[20px] 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 qr=react.createContext(null),jr=react.createContext(null),Zr="__patch_preview";function Jr(){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:()=>pe(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:e=>({...e}),targetRectToOverlay:e=>({...e}),eventTargetElement:e=>e instanceof window.Element?e:null}}function ra(e){let t=new URL(e.location.href);return t.searchParams.set(Zr,"1"),t.toString()}function Qr(e=window){try{return new URL(e.location.href).searchParams.get(Zr)==="1"}catch{return false}}function na(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function i(){return t.getBoundingClientRect()}function a(){let l=i();return r.width>0?l.width/r.width:1}function s(l){if(!l)return null;let c=n.Element;return l instanceof c?l:null}return {targetWindow:n,targetDocument:o,overlayWindow:e.overlayWindow,overlayDocument:e.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:e.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>pe(`${n.location.origin}${n.location.pathname}`),targetPointToOverlay:l=>{let c=i(),p=a();return {viewportX:c.left+l.viewportX*p,viewportY:c.top+l.viewportY*p}},targetRectToOverlay:l=>{let c=i(),p=a();return {x:c.left+l.x*p,y:c.top+l.y*p,width:l.width*p,height:l.height*p}},eventTargetElement:s}}function Tt(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function en({children:e}){let t=react.useMemo(()=>Jr(),[]),[r,n]=react.useState("desktop"),[o,i]=react.useState(null),[a,s]=react.useState(false),[l,c]=react.useState(false),[p,g]=react.useState(false),u=r!=="desktop",f=u||p,x=ve[r],w=x.width&&x.height?{width:x.width,height:x.height}:null;react.useEffect(()=>{s(false),c(false);},[r]);let T=react.useRef(u);react.useEffect(()=>{T.current&&!u?g(true):!T.current&&u&&g(false),T.current=u;},[u]);let k=react.useMemo(()=>t?!u||!a||l||!o||!w?t:na(t,o,w)??t:null,[l,o,a,u,w,t]),m=react.useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:f,previewReady:f?u&&a&&!l:true,previewBlocked:u&&l}),[r,l,a,u,f]),d=react.useMemo(()=>t?ra(t.targetWindow):"",[t]);return !k||!t?null:jsxRuntime.jsx(jr.Provider,{value:m,children:jsxRuntime.jsxs(qr.Provider,{value:k,children:[e,jsxRuntime.jsx(react$1.AnimatePresence,{onExitComplete:()=>g(false),children:u&&w?jsxRuntime.jsx(Ur,{src:d,viewport:x,overlayWindow:t.overlayWindow,onFrameElement:i,onReadyChange:s,onBlockedChange:c}):null})]})})}function se(){let e=react.use(qr),t=react.useMemo(()=>Jr(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function Ye(){let e=react.use(jr),[t,r]=react.useState("desktop"),n=react.useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var ia="X-Patch-Client-Id";function me(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[ia]:e.clientUserId}:{}}}async function xe(e,t){try{let r=await fetch(e,t);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function aa(e,t){try{let r=await fetch(e,t),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 tn(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await xe(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:me(e,false)}))?.annotations??[]},async fetchMe(){return xe(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:me(e,false)})},async postIdentity(t){let r=await xe(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:me(e,true),body:JSON.stringify(t)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(t){return xe(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:me(e,true),body:JSON.stringify(t)})},async reply(t,r){return xe(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:me(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return xe(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:me(e,false)})},async deleteMessage(t,r){return xe(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:me(e,false)})},async kickoff(t,r){return aa(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:me(e,true),body:JSON.stringify(r)})},async resolve(t){return xe(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:me(e,true)})},async reopen(t){return xe(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:me(e,true)})}}}var ar="patch.clientIdentity",rn="patch.clientAvatarSeed";function sr(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(ar);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function nn(e){return sr()[e]??null}function lr(e,t){if(!(typeof window>"u"))try{let r=sr();r[e]=t,window.localStorage.setItem(ar,JSON.stringify(r));}catch{}}function on(e){if(!(typeof window>"u"))try{let t=sr();delete t[e],window.localStorage.setItem(ar,JSON.stringify(t));}catch{}}function sa(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(rn);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function ir(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function an(e){if(typeof window>"u")return ir();try{let t=sa(),r=t[e];if(r)return r;let n=ir();return t[e]=n,window.localStorage.setItem(rn,JSON.stringify(t)),n}catch{return ir()}}var da=2e4,ln=react.createContext(null);function ua(e,t){let r=new Map(e.map(a=>[a.id,a])),n=new Set(t.map(a=>a.id)),o=t.map(a=>{let s=r.get(a.id);if(!s)return a;let l=new Set(a.thread.map(g=>g.id)),c=s.thread.filter(g=>g.deliveryStatus&&!l.has(g.id)),p=c.length>0?{...a,thread:[...a.thread,...c]}:a;if(s.optimisticAction==="resolve-pending"&&a.status!=="resolved"&&(p={...p,status:s.status,resolvedBy:s.resolvedBy,resolvedAt:s.resolvedAt,optimisticAction:s.optimisticAction}),s.optimisticAction==="reopen-pending"&&a.status==="resolved"&&(p={...p,status:s.status,resolvedBy:s.resolvedBy,resolvedAt:s.resolvedAt,optimisticAction:s.optimisticAction}),s.optimisticAction==="run-pending"&&s.latestRun?.id.startsWith("tmp-run")){let g=a.latestRun?Date.parse(a.latestRun.createdAt):Number.NaN,u=Date.parse(s.latestRun.createdAt);a.latestRun!=null&&(Number.isNaN(u)||Number.isNaN(g)||g>=u)||(p={...p,latestRun:s.latestRun,optimisticAction:s.optimisticAction});}return p}),i=e.filter(a=>(a.deliveryStatus||a.optimisticAction)&&!n.has(a.id));return [...o,...i]}function cn({projectToken:e,apiBase:t,children:r}){let n=se(),{activeViewport:o,setActiveViewport:i}=Ye(),[a,s]=react.useState(()=>typeof window>"u"?null:nn(e)),[l]=react.useState(()=>typeof window>"u"?"client-avatar:ssr":an(e)),[c,p]=react.useState(null),[g,u]=react.useState("client"),[f,x]=react.useState(null),[w,T]=react.useState([]),[k,m]=react.useState(null),[d,v]=react.useState([]),[C,S]=react.useState(false),N=react.useRef(o);N.current=o;let H=k===o,U=react.useMemo(()=>tn({apiBase:t,token:e,clientUserId:a?.clientUserId}),[t,e,a?.clientUserId]),G=react.useRef(U);G.current=U;let ne=react.useRef(0),b=react.useCallback(async()=>{let h=o,R=++ne.current,L=await G.current.listAnnotations(h==="desktop"?void 0:h);if(R!==ne.current||h!==N.current)return;let X=n.getPageUrl(),ue=L.filter(ae=>pe(ae.payload.url)===X);T(ae=>ua(ae,ue)),m(h);},[o,n]),A=react.useRef(b);A.current=b,react.useEffect(()=>{let h=false;return (async()=>{let R=await G.current.fetchMe();if(!h){if(R?.studio)p(R.studio),u("studio"),x(R.agentRunReadiness??{ready:true,message:null});else if(p(null),u("client"),x(null),R?.client){let L={clientUserId:R.client.id,name:R.client.name,email:R.client.email,avatarSeed:R.client.avatarSeed};s(L),lr(e,L);}await A.current(),h||S(true);}})(),()=>{h=true;}},[e]),react.useEffect(()=>{C&&b();},[C,b]),react.useEffect(()=>{let{overlayDocument:h,overlayWindow:R}=n,L=R.setInterval(()=>{h.visibilityState==="visible"&&b();},da),X=()=>{h.visibilityState==="visible"&&b();};return h.addEventListener("visibilitychange",X),()=>{R.clearInterval(L),h.removeEventListener("visibilitychange",X);}},[b,n]),react.useEffect(()=>Lr(n.targetWindow,()=>{let h=n.getPageUrl();T(R=>R.filter(L=>pe(L.payload.url)===h)),A.current();}),[n]);let M=react.useCallback(async h=>(lr(e,h),s(h),h),[e]),I=react.useCallback(()=>{s(null),on(e);},[e]),D=react.useCallback(h=>{v(R=>[...R.filter(L=>L.tempId!==h.tempId),h]);},[]),j=react.useCallback(h=>{v(R=>R.filter(L=>L.tempId!==h));},[]),ee=react.useCallback(h=>{T(R=>{let L=R.findIndex(ue=>ue.id===h.id);if(L===-1)return [...R,h];let X=R.slice();return X[L]=h,X});},[]),le=react.useCallback((h,R)=>{T(L=>{let X=false,ue=L.flatMap(ae=>{if(ae.id!==h)return [ae];X=true;let Me=R(ae);return Me?[Me]:[]});return X?ue:L});},[]),ce=react.useCallback((h,R)=>{T(L=>L.map(X=>X.id===h?{...X,id:R,deliveryStatus:"sent"}:X));},[]),Ce=react.useMemo(()=>({apiClient:U,ready:C,viewerKind:g,agentRunReadiness:f,activeViewport:o,clientAvatarSeed:l,identity:a,studio:c,annotations:w,annotationsReady:H,ephemerals:d,refresh:b,setActiveViewport:i,setIdentity:M,signOut:I,addEphemeral:D,removeEphemeral:j,applyAnnotationUpdate:ee,updateAnnotation:le,replaceAnnotationId:ce}),[U,C,g,f,o,l,a,c,w,H,d,b,i,M,I,D,j,ee,le,ce]);return jsxRuntime.jsx(ln.Provider,{value:Ce,children:r})}function ge(){let e=react.use(ln);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var dn=react.createContext(null);function un({children:e}){let[t,r]=react.useState(null),[n,o]=react.useState(""),[i,a]=react.useState(0),[s,l]=react.useState(false),c=react.useCallback(()=>{r(null),o(""),l(false);},[]),p=react.useCallback(w=>{r({kind:"existing",annotationId:w}),o(""),l(false);},[]),g=react.useCallback(w=>{r({kind:"composer",...w}),o(""),l(false);},[]),u=react.useCallback(()=>{if(n.trim().length>0){a(w=>w+1);return}c();},[n,c]),f=react.useCallback(()=>{c();},[c]),x=react.useMemo(()=>({active:t,draftText:n,shakeNonce:i,confirmDiscardOpen:s,openExisting:p,openComposer:g,setDraftText:o,attemptClose:u,forceClose:f,setConfirmDiscardOpen:l}),[t,n,i,s,p,g,u,f]);return jsxRuntime.jsx(dn.Provider,{value:x,children:e})}function fe(){let e=react.use(dn);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var gn=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"]),ba=new Set(["a","button","input","select","textarea"]),fn={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"},Le=40,va=1500,pn=200,xa=5,wa=10;function cr(e){return gn.has(e.tagName.toLowerCase())}function ye(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Ue(e){return `"${e}"`}function ya(e){let t="";for(let r of Array.from(e.childNodes))r.nodeType===3&&(t+=r.textContent??"");return t.replace(/\s+/g," ").trim()}function It(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function ka(e){return !(!e||e.length>40||/__[A-Za-z0-9]{4,}$/.test(e)||/_[a-z0-9]{4,}$/i.test(e)&&/[0-9]/.test(e)||/_[A-Za-z0-9]{5,}_/.test(e)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(e)||/^[a-z]{2,}:[\w-]+$/.test(e)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(e)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(e)||(e.match(/\d/g)?.length??0)/e.length>.4)}function Oe(e){let t=Array.from(e.classList),r=t.filter(ka).slice(0,wa);return r.length>0?r:t.length>0?["container"]:[]}function hn(e){let t=e.getAttribute("role")??void 0,r=e.getAttribute("aria-label")??void 0,n=e.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,i=e.tagName.toLowerCase(),a=ba.has(i)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!a)return;let s={focusable:a};return t!==void 0&&(s.role=t),r!==void 0&&(s.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(s.tabIndex=o),s}function Ca(e){let t=e.tagName.toLowerCase(),r=fn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Ue(ye(n,Le))}`;let o=e.placeholder;if(o)return `${r} ${Ue(ye(o,Le))}`;let i=e.getAttribute("name");if(i)return `${r}[name="${i}"]`;if(t==="input"){let a=e.type||"text";return `${r}[type=${a}]`}return r}function Aa(e){let t=e.alt?.trim();return t?`img ${Ue(ye(t,Le))}`:"img"}function nt(e){let t=e.tagName.toLowerCase();if(t==="img")return Aa(e);if(t==="input"||t==="textarea"||t==="select")return Ca(e);let r=fn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Ue(ye(n,Le))}`;if(t==="a"||t==="button"||gn.has(t)||t==="label"){let i=It(e);if(i)return `${r} ${Ue(ye(i,Le))}`;if(t==="a"||t==="button"){let a=e.querySelector("svg");if(a){let l=a.getAttribute("aria-label");return l?`${r} ${Ue(ye(l,Le))}`:`${r} (icon)`}let s=e.getAttribute("href");if(t==="a"&&s)return `link[href="${ye(s,Le)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=Oe(e);return o.length>0?`${t}.${o[0]}`:t}function bn(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(nt(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,va)}function vn(e){let t=It(e),r=e.parentElement;if(!r)return;let n=It(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let i=It(o);return !i||i===t?void 0:ye(i,pn)}return ye(n,pn)}}function xn(e){let t=e.parentElement;if(!t)return [];let r=[];for(let n of Array.from(t.children))if(n!==e&&n.tagName.toLowerCase()!=="script"&&(r.push(nt(n)),r.length>=xa))break;return r}var Ta=["role","aria-label","name"],Sa=10,mn=100;function Pt(e){let t={};for(let r of Ta){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,mn));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=Sa)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,mn));}return t}function Nt(e){return ya(e)}function wn(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function Mt(e,t){return e.closest(`[${t}]`)!==null}var Ea=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"]),Ra={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"},Ia={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"},Pa={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 kn(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function Na(e){return `"${e}"`}function _t(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function yn(e){let t=e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""}function Z(e,t){let r=t?.trim();return r?`${e}: ${Na(kn(r,48))}`:e}function Ma(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function _a(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Pa[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":Ia[n]??"Area":"Area"}function Da(e){let t=e.getAttribute("aria-label");if(t)return Z("Field",t);let r=e.placeholder;if(r)return Z("Field",r);let n=e.getAttribute("name");if(n)return Z("Field",yn(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return Z("Field",yn(o))}return "Field"}function ot(e,t){if(t?.trim())return Z("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return Z("Button",n??_t(e));if(r==="a")return Z("Link",n??_t(e));if(r==="input"||r==="textarea"||r==="select")return Da(e);if(r==="img"){let i=e.alt;return Z("Image",i)}if(r==="svg")return Z("Icon",n);if(/^h[1-6]$/.test(r))return Z("Heading",_t(e));if(Ea.has(r))return Z("Text",_t(e));let o=Ra[r];return Z(o||"Area",n)}function Dt(e){return e===1?"1 item selected":`${e} items selected`}function Lt(){return "Selected area"}function Cn(e){if(e.targetLabel?.trim())return kn(e.targetLabel,120);if(e.selectedText?.trim())return Z("Selected text",e.selectedText);let t=e.element?.trim()||e.elementPath?.trim();if(!t)return "Annotation";let r=t.match(/^(\d+)\s+elements?:/i);if(r)return Dt(Number(r[1]));if(/^region\b/i.test(t))return Lt();let n=Ma(t.split(">").at(-1)??t);return Z(_a(n.base),n.text)}function En(e){let{clickTarget:t,selection:r}=e,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),i=wn(o.commonAncestorContainer);if(i)return {kind:"element",element:i,rect:i.getBoundingClientRect(),selectedText:n,clickTarget:t}}return {kind:"element",element:t,rect:t.getBoundingClientRect(),clickTarget:t}}var An=20,Rn=7,Tn=10,La=.8,Oa=.5,za=new Set(["html","body","head","script","style","meta","link","title","br","noscript"]),Ha=new Set(["section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details","summary"]),Ot=24;function In(e){let t=e.tagName.toLowerCase();if(Ha.has(t))return true;if(t==="div"||t==="span"){if(e.id)return true;let r=Oe(e);if(r.length>0&&r[0]!=="container")return true}return false}var Fa=["a","button","input","select","textarea","img","svg","h1","h2","h3","h4","h5","h6","p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","div","section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details"].join(",");function Sn(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Va(e,t){return !(e.x+e.width<t.x||t.x+t.width<e.x||e.y+e.height<t.y||t.y+t.height<e.y)}function $a(e,t,r){if(Mt(e,r))return false;let n=e.tagName.toLowerCase();if(za.has(n))return false;let o=e.getBoundingClientRect();if(o.width<Tn||o.height<Tn||o.width>t.width*La||o.height>t.height*Oa)return false;if(n==="div"||n==="span"){let i=Array.from(e.childNodes).some(l=>l.nodeType===3&&(l.textContent??"").trim().length>0),a=e.getAttribute("role"),s=a!==null&&a.length>0;if(!i&&!s&&!In(e))return false}return true}function Ba(e){return e.filter(t=>!e.some(r=>r!==t&&t.contains(r)))}function Wa(e,t){let r=[...e].sort((n,o)=>{let i=n.getBoundingClientRect(),a=o.getBoundingClientRect();return i.width*i.height-a.width*a.height});for(let n of r){if(!In(n)||!e.every(s=>s===n||n.contains(s)))continue;let i=n.getBoundingClientRect();if(i.left>=t.x-Ot&&i.top>=t.y-Ot&&i.right<=t.x+t.width+Ot&&i.bottom<=t.y+t.height+Ot)return n}return null}function Ya(e){let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let i of e)i.x<t&&(t=i.x),i.y<r&&(r=i.y),i.x+i.width>n&&(n=i.x+i.width),i.y+i.height>o&&(o=i.y+i.height);return {x:t,y:r,width:n-t,height:o-r}}function Ua(e){let t=e.x+e.width/2,r=e.y+e.height/2,n=e.x+e.width,o=e.y+e.height;return [{x:e.x,y:e.y},{x:t,y:e.y},{x:n,y:e.y},{x:e.x,y:r},{x:t,y:r},{x:n,y:r},{x:e.x,y:o},{x:t,y:o},{x:n,y:o}]}function Pn(e){let{rect:t,viewport:r,internalAttr:n}=e,o=e.doc??document,i=new Set;for(let c of Ua(t)){let p=o.elementsFromPoint(c.x,c.y);for(let g of p)i.add(g);}for(let c of Array.from(o.querySelectorAll(Fa)))Va(Sn(c.getBoundingClientRect()),t)&&i.add(c);let a=Array.from(i).filter(c=>$a(c,r,n)),s=Wa(a,t),l=s?[s]:Ba(a);if(l.length>0){let c=l.map(p=>Sn(p.getBoundingClientRect()));return {kind:"multi",elements:l,rects:c,union:Ya(c)}}return t.width>=An&&t.height>=An?{kind:"area",rect:t}:null}var Nn="patch-capture-cursor-style";function Xa(e){let t=`:not([${e}]):not([${e}] *)`,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}${t}`).join(`,
3
3
  `);return ["html, body { cursor: crosshair !important; }",`body *${t} { cursor: crosshair !important; }`,`${r} { cursor: text !important; }`].join(`
4
- `)}function Wa(e,t){let r=e.targetDocument,n=r.getElementById(Rn);n&&n.remove();let o=r.createElement("style");return o.id=Rn,o.setAttribute(t,""),o.textContent=Ba(t),r.head.appendChild(o),o}function Lt(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var ze=1.5,Nn="#0287FE",Pn="rgba(2, 135, 254, 0.032)";function Ya(e){let t=e.split(" ")[0]??"",r=Number.parseFloat(t);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Xa(e,t){let r=e.targetDocument,n=r.createElement("div");n.setAttribute(t,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${ze}px solid ${Nn}`,background:Pn,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(t,""),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 i=null;return {update(s){let a=s.getBoundingClientRect();if(a.width===0&&a.height===0){this.hide();return}n.style.display="block",n.style.top=`${a.top-ze}px`,n.style.left=`${a.left-ze}px`,n.style.width=`${a.width+ze*2}px`,n.style.height=`${a.height+ze*2}px`,n.style.borderRadius=`${Ya(e.targetWindow.getComputedStyle(s).borderRadius)+ze}px`,s!==i&&(o.textContent=ot(s),i=s),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),p=e.getTargetViewport().width-8;l+240<=p?(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 Ua(e,t){let r=e.targetDocument.createElement("div");return r.setAttribute(t,""),Object.assign(r.style,{position:"fixed",pointerEvents:"none",border:`${ze}px solid ${Nn}`,background:Pn,boxSizing:"border-box",zIndex:"2147483645",borderRadius:"8px"}),e.targetDocument.body.appendChild(r),{update(n){r.style.left=`${n.x}px`,r.style.top=`${n.y}px`,r.style.width=`${n.width}px`,r.style.height=`${n.height}px`;},destroy(){r.remove();}}}function In(e,t){return {x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function Mn(e){let{internalAttr:t,onClick:r,onDrag:n,surface:o}=e,i=o.targetDocument,s=Wa(o,t),a=Xa(o,t),l=false,c=null,p=null;function g(){c?.rectOverlay&&c.rectOverlay.destroy(),c=null;}function u(){p&&(p.destroy(),p=null);}let f=m=>{let d=m,v=o.eventTargetElement(d.target);Lt(o,d.target,t)||v&&lr(v)||(d.preventDefault(),d.stopPropagation(),!l&&(u(),c={startX:d.clientX,startY:d.clientY,isDragging:false,rectOverlay:null}));},x=m=>{let d=m;if(c?.isDragging){d.preventDefault(),d.stopPropagation();let C=In({x:c.startX,y:c.startY},{x:d.clientX,y:d.clientY});p=c.rectOverlay,c=null,n?.(C,d);return}g();let v=o.eventTargetElement(d.target);Lt(o,d.target,t)||v&&lr(v)||(d.preventDefault(),d.stopPropagation());},w=m=>{let d=m;Lt(o,d.target,t)||(d.preventDefault(),d.stopPropagation(),!l&&r(d));},E=m=>{let d=m;if(c){if(!c.isDragging){let T=d.clientX-c.startX,P=d.clientY-c.startY;if(Math.hypot(T,P)<Tn)return;c.isDragging=true,a.hide(),c.rectOverlay=Ua(o,t);}c.rectOverlay?.update(In({x:c.startX,y:c.startY},{x:d.clientX,y:d.clientY}));return}if(l)return;let v=o.eventTargetElement(d.target);if(!v){a.hide();return}if(Lt(o,v,t)){a.hide();return}let C=v.tagName.toLowerCase();if(C==="html"||C==="body"){a.hide();return}a.update(v);},k=m=>{m.relatedTarget||a.hide();};return i.addEventListener("mousedown",f,true),i.addEventListener("mouseup",x,true),i.addEventListener("click",w,true),i.addEventListener("mousemove",E,true),i.addEventListener("mouseout",k,true),{exit(){s.remove(),a.destroy(),g(),u(),i.removeEventListener("mousedown",f,true),i.removeEventListener("mouseup",x,true),i.removeEventListener("click",w,true),i.removeEventListener("mousemove",E,true),i.removeEventListener("mouseout",k,true);},pause(){l=true,a.hide(),g();},resume(){l=false;},dismissDragOverlay(){u();}}}var _n="data-patch-internal",Ln=react.createContext(null),Dn=0;function On(){return Dn+=1,`tmp-${Date.now().toString(36)}-${Dn}`}function zn({children:e}){let t=ge(),r=me(),n=se(),{isPreviewing:o,previewReady:i}=Ye(),[s,a]=react.useState(false),l=react.useRef(null),c=react.useRef(t),p=react.useRef(r);c.current=t,p.current=r;let g=react.useCallback(m=>{let d=c.current;if(d.active&&d.draftText.trim().length>0){d.attemptClose();return}let v=n.eventTargetElement(m.target)??n.targetDocument.body,C=n.targetWindow.getSelection(),T=An({clickTarget:v,selection:C}),P=On(),z={viewportX:m.clientX,viewportY:m.clientY,documentY:m.clientY+n.getTargetScrollY()};p.current.addEphemeral({tempId:P,viewportX:z.viewportX,viewportY:z.viewportY,documentY:z.documentY}),c.current.openComposer({tempId:P,target:T,anchor:z}),l.current?.pause();},[n]),u=react.useCallback((m,d)=>{let v=c.current;if(v.active&&v.draftText.trim().length>0){v.attemptClose(),l.current?.dismissDragOverlay();return}let C=n.getTargetViewport(),T=En({rect:m,viewport:C,internalAttr:_n,doc:n.targetDocument});if(!T){l.current?.dismissDragOverlay();return}let P=On(),z={viewportX:d.viewportX,viewportY:d.viewportY,documentY:d.viewportY+n.getTargetScrollY()};p.current.addEphemeral({tempId:P,viewportX:z.viewportX,viewportY:z.viewportY,documentY:z.documentY}),c.current.openComposer({tempId:P,target:T,anchor:z}),l.current?.pause();},[n]),f=r.annotationsReady&&(!o||i);react.useEffect(()=>{if(!s||!f){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=Mn({internalAttr:_n,surface:n,onClick:g,onDrag:(m,d)=>u(m,{viewportX:d.clientX,viewportY:d.clientY})}),()=>{l.current?.exit(),l.current=null;}},[s,g,u,n,f]);let x=react.useCallback(()=>{s||a(true);},[s]),w=react.useCallback(()=>{a(false);},[]),E=react.useRef(null);react.useEffect(()=>{let m=E.current,d=t.active;m?.kind==="composer"&&d?.kind!=="composer"&&(p.current.removeEphemeral(m.tempId),l.current?.dismissDragOverlay(),l.current?.resume()),m?.kind==="composer"&&d?.kind==="composer"&&m.tempId!==d.tempId&&p.current.removeEphemeral(m.tempId),E.current=d;},[t.active]),react.useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let k=react.useMemo(()=>({isCapturing:s,enter:x,exit:w}),[s,x,w]);return jsxRuntime.jsx(Ln.Provider,{value:k,children:e})}function Hn(){let e=react.use(Ln);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var $n=react.createContext(null);function Vn({children:e}){let[t,r]=react.useState(false),[n,o]=react.useState(false),i=react.useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsxRuntime.jsx($n.Provider,{value:i,children:e})}function Ft(){let e=react.use($n);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var rs="[Patch] No project token found. 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 Bn(e){let t=e.prop?.trim();if(t)return t;let r=e.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=e.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=e.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();if(o)return o;throw new Error(rs)}function Wn(){try{return typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) })>"u"?void 0:undefined}catch{return}}function Yn(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var ns=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 os(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Xn(e){return e.replace(/\s+/g," ").trim()}function dr(e){return ns.has(Xn(e))}function Un(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Xn(n[1]??"");!o||dr(o)||t[t.length-1]!==o&&t.push(o);}return t.length===0?null:os(t.map(n=>`<${n}>`).join(" "),1e3)}var Gn="seed:";function $t(e){return e?e.startsWith(Gn)?{url:null,seed:e.slice(Gn.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var ur=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],Kn=[{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]}],qn=Math.PI*2;function is(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}function as(e){return ()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function W(e,t,r){return t+e()*(r-t)}function ee(e,t=3){let r=10**t;return Math.round(e*r)/r}function jn(e,t,r){return `hsl(${ee((e%360+360)%360,1)} ${ee(t,1)}% ${ee(r,1)}%)`}function Zn(e){let t=is(e?.trim()||"patch-client"),r=as(t),n=t.toString(36),o=(ur[t%ur.length]??ur[0])+W(r,-10,10),i=r()<.5?-1:1,s=r()<.5?-1:1,a=o+s*W(r,52,116),l=o-s*W(r,26,66),c=o+i*W(r,12,38),p=jn(o+i*W(r,0,14),W(r,80,92),W(r,44,54)),g=W(r,0,qn),u=Kn.map((f,x)=>{let E=(f.hue==="accent"?a:f.hue==="accent2"?l:f.hue==="near"?c:o)+W(r,-11,11),k=g+x/Kn.length*qn+W(r,-0.6,.6),m=W(r,f.reach[0],f.reach[1]),d=ee(.5+Math.cos(k)*m),v=ee(.5+Math.sin(k)*m),C=ee(W(r,0,180),1),T=ee(W(r,.62,1.5),3),P=ee(W(r,.62,1.5),3);return {id:`cav-${n}-${x}`,cx:d,cy:v,r:ee(W(r,f.r[0],f.r[1])),color:jn(E,W(r,f.sat[0],f.sat[1]),W(r,f.light[0],f.light[1])),opacity:ee(W(r,f.opacity[0],f.opacity[1]),2),gradientTransform:`rotate(${C} ${d} ${v}) translate(${d} ${v}) scale(${T} ${P}) translate(${ee(-d)} ${ee(-v)})`}});return {id:n,background:p,spots:u,blur:ee(W(r,3.4,5.4),2),grain:ee(W(r,.09,.15),2)}}function it(e){let t=e.gap??12,r=e.margin??16,n=Math.min(e.popover.width,Math.max(0,e.viewport.width-r*2)),o="right",i=e.anchor.x+e.anchor.width+t;i+n>e.viewport.width-r&&(o="left",i=e.anchor.x-n-t),i<r&&(i=r);let s=e.anchor.y;return s+e.popover.height>e.viewport.height-r&&(s=e.viewport.height-r-e.popover.height),s<r&&(s=r),{x:i,y:s,width:n,placement:o}}function R(...e){return e.filter(Boolean).join(" ")}function Bt({seed:e,className:t,style:r}){let n=Zn(e),o=react.useId().replace(/[^a-zA-Z0-9_-]/g,""),i=`${n.id}-${o}`,s=`cav-blur-${i}`,a=`cav-grain-${i}`;return jsxRuntime.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:R("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:s,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsxRuntime.jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxRuntime.jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsxRuntime.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsxRuntime.jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxRuntime.jsxs("radialGradient",{id:`${i}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsxRuntime.jsx("rect",{width:"64",height:"64",fill:n.background}),jsxRuntime.jsx("g",{filter:`url(#${s})`,children:n.spots.map(l=>jsxRuntime.jsx("rect",{width:"64",height:"64",fill:`url(#${i}-${l.id})`},l.id))}),jsxRuntime.jsx("rect",{width:"64",height:"64",filter:`url(#${a})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Se=28,Jn=[.22,.61,.36,1],Wt=["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 Ue(e){if(!e)return "?";let t=e.trim().split(/\s+/),r=t[0],n=t[t.length-1];if(!r||!n)return "?";if(t.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",i=n[0]??"";return (o+i).toUpperCase()||"?"}function Ge(e){if(!e)return Wt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Wt[Math.abs(t)%Wt.length]??Wt[0]}var cs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},ds={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function Ke(e,t){let{placement:r}=it({anchor:{x:e.viewportX-Se/2,y:e.viewportY-Se/2,width:Se,height:Se},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function Yt(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Se,y:e.viewportY-Se,width:Se,height:Se}}function pr({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?us[t.attention]:null,{url:o,seed:i}=$t(t.avatarSrc),s=i??t.generatedSeed,a=t.orphan?"grayscale(1)":t.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",l=t.orphan?.55:1,c=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsxRuntime.jsx(react$1.motion.button,{ref:e,type:"button",onClick:t.onClick,"aria-label":t.ariaLabel??"Open annotation","data-patch-ephemeral":t.ephemeral?"":void 0,"data-patch-pin-id":t.pinId,className:"patch-pin-button fixed z-[2147483645] size-7 border-0 bg-transparent p-0",initial:t.ephemeral?{opacity:0,scale:.45}:false,animate:t.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:t.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:Jn}}:{opacity:0,scale:.9,transition:{duration:.12,ease:Jn}},children:jsxRuntime.jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:cs[r]},children:[jsxRuntime.jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:ds[r],background:"var(--color-muted-foreground)",filter:t.orphan?"grayscale(1)":"none",opacity:t.orphan?.55:1},children:[s?jsxRuntime.jsx(Bt,{seed:s,style:{borderRadius:0,filter:a||"none",opacity:l}}):null,o?jsxRuntime.jsx("img",{src:o,alt:t.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:a||"none",opacity:l},onError:p=>{p.currentTarget.remove();}}):null]}),t.resolved&&jsxRuntime.jsx("span",{className:`absolute ${c} grid size-[13px] place-items-center rounded-full bg-brand-green text-[8px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsxRuntime.jsx("span",{"data-patch-attention":t.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[9px] rounded-full border-[1.5px] border-white ${n}`})]})})}var us={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};var ps="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",ms={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Ee({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:i="md",className:s,style:a}){let{url:l,seed:c}=$t(r),p=c??n;return jsxRuntime.jsxs("span",{className:R(ps,ms[i],s),style:{background:t,...a},children:[jsxRuntime.jsx("span",{children:e}),!l&&p?jsxRuntime.jsx(Bt,{seed:p}):null,l?jsxRuntime.jsx("img",{src:l,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:g=>{g.currentTarget.remove();}}):null]})}var eo={"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"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],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"}]],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"}]],maximize:[["path",{d:"M16.4999 3.26621C17.3443 3.25421 20.1408 2.67328 20.7337 3.26621C21.3266 3.85913 20.7457 6.65559 20.7337 7.5M20.5059 3.49097L13.5021 10.4961"}],["path",{d:"M3.26636 16.5001C3.25436 17.3445 2.67343 20.141 3.26636 20.7339C3.85928 21.3268 6.65574 20.7459 7.50015 20.7339M10.502 13.4976L3.49824 20.5027"}]],minimize:[["path",{d:"M6.5023 10.7365C7.34671 10.7485 10.1432 11.3294 10.7361 10.7365C11.329 10.1436 10.7481 7.34708 10.7361 6.50267M13.2685 17.5027C13.2565 16.6583 12.6756 13.8618 13.2685 13.2689C13.8614 12.676 16.6579 13.2569 17.5023 13.2689M20.9991 21.001L13.6102 13.6188M10.3691 10.3763L2.99998 2.99902"}]],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"}]],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"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function O({name:e,size:t=16,stroke:r=2,color:n,className:o}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:eo[e].map(([i,s],a)=>react.createElement(i,{key:a,...s}))})}var bs="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 gr({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:o?"none":"currentColor",stroke:o?"currentColor":"none",strokeWidth:o?r:void 0,strokeLinejoin:o?"round":void 0,strokeLinecap:o?"round":void 0,"aria-hidden":"true",focusable:"false",className:n,children:jsxRuntime.jsx("path",{d:bs})})}var fr=false,He=null,Xt=null,de={openDelay:700,isInstant(){return fr},onOpen(e){Xt&&Xt!==e&&Xt(),Xt=e??null,fr=true,He&&(clearTimeout(He),He=null);},onClose(){He&&clearTimeout(He),He=setTimeout(()=>{fr=false,He=null;},300);}};var oo="easeOut";function ke({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[i,s]=react.useState(false),[a,l]=react.useState(false),c=react.useRef(null),p=react.useRef(false);react.useEffect(()=>()=>{c.current&&clearTimeout(c.current),p.current&&de.onClose();},[]);let g=v=>{l(v),s(true),p.current=true,de.onOpen();},u=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),de.isInstant()){g(true);return}c.current=setTimeout(()=>{c.current=null,g(false);},de.openDelay);},f=()=>{c.current&&(clearTimeout(c.current),c.current=null),p.current&&(p.current=false,de.onClose()),s(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",w="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",E=n==="warning"?`relative flex w-[200px] items-start gap-1.5 rounded-[14px] bg-foreground px-3 py-2.5 text-left text-[11px] leading-[1.35] font-medium text-white ${w}`:`relative block whitespace-nowrap rounded-[10px] bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${w}`,k=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",m=o==="bottom"&&n!=="warning"?-3:3,d=o==="bottom"&&n!=="warning"?-2:2;return jsxRuntime.jsxs("span",{className:R("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:f,onMouseDown:f,children:[jsxRuntime.jsx("span",{className:x,children:jsxRuntime.jsx(react$1.AnimatePresence,{children:i&&jsxRuntime.jsxs(react$1.motion.span,{initial:a?false:{opacity:0,y:m,scale:.98},animate:{opacity:1,y:0,scale:1,transition:a?{duration:0}:{duration:.1,ease:oo}},exit:{opacity:0,y:d,scale:.98,transition:{duration:.08,ease:oo}},className:E,children:[n==="warning"?jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsxRuntime.jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsxRuntime.jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsxRuntime.jsx("span",{className:"min-w-0 flex-1",children:e}),jsxRuntime.jsx("span",{className:k})]})})}),t]})}var ys=44,ks=212,he=[.16,1,.3,1],ao="easeOut",Cs=.08,As=60,Ts="calc(100% - 64px) calc(100% + 4px)",ct="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function so(){let e=Hn(),t=ge(),r=me(),{dockOpen:n,hideResolvedAnnotations:o,setDockOpen:i,setHideResolvedAnnotations:s}=Ft(),[a,l]=react.useState(false),[c,p]=react.useState(false),[g,u]=react.useState(false),[f,x]=react.useState(false),[w,E]=react.useState(false),k=react.useRef(null),m=react.useRef(null),d=react.useRef(false),[v,C]=react.useState(false),T=r.studio?r.studio.name:r.identity?.name??null,P=Ue(T),z=r.studio?.image??null,X=r.identity?.avatarSeed??r.clientAvatarSeed,G=r.studio?.userId??X,re=r.studio?"var(--color-foreground)":Ge(X),b=r.studio&&!z?"#FFFFFF":re,A=r.studio&&!z?"text-foreground":"text-white",M=ve[r.activeViewport];function I(){k.current!==null&&(window.clearTimeout(k.current),k.current=null);}function D(){m.current!==null&&(window.clearTimeout(m.current),m.current=null);}let ie=react.useRef(()=>{});ie.current=()=>{!d.current&&k.current===null||(I(),D(),d.current=false,E(true));};let Q=react.useRef(()=>ie.current()).current;react.useEffect(()=>{w&&a&&l(false);},[w,a]);function le($){p(false),u(false),I(),D(),d.current=true,E(false),x($),de.onOpen(Q),l(true);}function ce(){le(false);}function Ce(){if(I(),!(d.current||m.current!==null)){if(de.isInstant()){le(true);return}m.current=window.setTimeout(()=>{m.current=null,le(false);},de.openDelay);}}function h(){D(),I(),d.current&&(d.current=false,de.onClose()),k.current=window.setTimeout(()=>{l(false),k.current=null;},120);}function N(){C(true),i(true);}function H(){p(false),u(false),D(),d.current=false,l(false),e.isCapturing?e.exit():e.enter();}function U(){C(true),i(false),p(false),u(false),D(),d.current=false,l(false),e.exit(),t.active&&t.forceClose();}react.useEffect(()=>()=>{k.current!==null&&window.clearTimeout(k.current),m.current!==null&&window.clearTimeout(m.current);},[]);let ue=()=>{r.signOut(),l(false);};function ae(){u(false),D(),d.current=false,l(false),p($=>!$);}function Me($){p(false),r.activeViewport!==$&&(t.active&&t.forceClose(),r.setActiveViewport($));}function ft(){p(false),D(),d.current=false,l(false),u($=>!$);}function ht(){s(!o);}function bt($){let _e=$.relatedTarget;_e instanceof Node&&$.currentTarget.contains(_e)||h();}return jsxRuntime.jsx("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:jsxRuntime.jsxs(react$1.motion.div,{initial:false,animate:{width:n?ks:ys},transition:{duration:.36,ease:he},onAnimationComplete:()=>C(false),whileHover:n?void 0:{scale:1.03,transition:{duration:.15,ease:he}},whileTap:n?void 0:{scale:.97,transition:{duration:.1,ease:he}},"data-patch-fab-dock":"",className:R("pkey-fab relative h-11 rounded-full",v?"overflow-hidden":"overflow-visible"),children:[jsxRuntime.jsx(react$1.motion.div,{animate:{opacity:n?0:1,scale:n?.7:1},transition:{duration:.18,ease:he},className:R("absolute inset-0",n?"pointer-events-none":"pointer-events-auto"),children:jsxRuntime.jsx("button",{type:"button",onClick:N,"data-patch-fab-dock":"","aria-label":"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsxRuntime.jsx(gr,{variant:"outline",size:18})})}),jsxRuntime.jsxs("div",{"data-patch-fab-dock":"",className:R("absolute inset-0 flex items-center gap-1.5 px-1.5",n?"pointer-events-auto":"pointer-events-none"),children:[jsxRuntime.jsx(dt,{visible:n,index:0,children:jsxRuntime.jsx(ke,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:H,className:R(ct,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(gr,{variant:"outline",size:16})})})}),jsxRuntime.jsx(dt,{visible:n,index:1,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${M.label}`,"aria-expanded":c,onClick:ae,className:R(ct,"transition-colors",r.activeViewport==="desktop"&&!c?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsxRuntime.jsx(O,{name:M.glyph,size:15})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:c?jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:he}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:he}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsxRuntime.jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),_r.map($=>{let _e=ve[$],vt=r.activeViewport===$;return jsxRuntime.jsx(ke,{text:$e($),children:jsxRuntime.jsx("button",{type:"button","data-patch-viewport-option":$,"aria-label":$e($),"aria-pressed":vt,onClick:()=>Me($),className:R("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",vt?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(O,{name:_e.glyph,size:15})})},$)})]}):null})]})}),jsxRuntime.jsx(dt,{visible:n,index:2,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx(ke,{text:"Settings",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":g,onClick:ft,className:R(ct,"transition-colors",g||o?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(O,{name:"settings",size:15})})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:g?jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:he}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:he}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-[18px] p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsxRuntime.jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxRuntime.jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-xl px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:o,"aria-label":"Hide resolved annotations",onChange:ht,className:"peer sr-only"}),jsxRuntime.jsx("span",{"aria-hidden":"true",className:R("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",o?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsxRuntime.jsx(O,{name:"check",size:10,stroke:2.4})}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsxRuntime.jsx(dt,{visible:n,index:3,children:jsxRuntime.jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Ce,onMouseLeave:h,onFocus:ce,onBlur:bt,children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":T?`Account: ${T}`:"Identify",className:R(ct,"text-white"),children:T?jsxRuntime.jsx(Ee,{initials:P,tint:b,src:z,generatedSeed:G,alt:T,size:"sm",className:R("size-[22px] text-[9.5px] ring-1 ring-white/20",A)}):jsxRuntime.jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:a?jsxRuntime.jsxs(react$1.motion.div,{initial:f?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:f?{duration:0}:{duration:.12,delay:Cs,ease:ao}},exit:{opacity:0,y:2,scale:.98,transition:w?{duration:0}:{duration:.08,ease:ao}},"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-2xl 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:Ts},children:[jsxRuntime.jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:As}}),r.studio?jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(Ee,{initials:P,tint:re,src:z,generatedSeed:G,alt:r.studio.name,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(Ee,{initials:P,tint:re,generatedSeed:G,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsxRuntime.jsx("div",{className:"my-3 h-px bg-white/10"}),jsxRuntime.jsx("button",{type:"button",onClick:ue,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsxRuntime.jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsxRuntime.jsx(dt,{visible:n,index:4,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsxRuntime.jsx(ke,{text:"Close",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:U,className:R(ct,"text-white/70"),children:jsxRuntime.jsx(O,{name:"x",size:14})})})]})})]})]})})}function dt({children:e,visible:t,index:r}){return jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:he}}:{opacity:0,x:6,transition:{duration:.12,ease:he}},children:e})}function lo(e,t){return t.width<=0||t.height<=0?{fx:0,fy:0}:{fx:(e.viewportX-t.x)/t.width,fy:(e.viewportY-t.y)/t.height}}function co(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var uo=.6,Ut={text:.4,attrs:.3,classes:.2,bbox:.1},Es=5e3;function Rs(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function Is(e,t){if(!t)return .5;let r=Object.keys(t);if(r.length===0)return .5;let n=0;for(let o of r)e[o]===t[o]&&n++;return n/r.length}function Ns(e,t){let r=new Set(e),n=new Set(t??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let s of r)n.has(s)&&o++;let i=r.size+n.size-o;return i===0?0:o/i}function Ps(e,t,r){if(!t)return .5;let n=e.x+e.width/2,o=e.y+e.height/2,i=t.x+t.width/2,s=t.y+t.height/2,a=(n-i)/Math.max(1,r.width),l=(o-s)/Math.max(1,r.height),c=Math.sqrt(a*a+l*l);return Math.max(0,1-c)}function po(e,t){let r=Nt(e),n=It(e),o=Le(e),i=e.getBoundingClientRect(),s=Rs(r,t.payload.domHints?.textSignature),a=Is(n,t.payload.domHints?.attributeSignature),l=Ns(o,t.payload.cssClasses),c=Ps(i,t.payload.boundingBox,t.viewport);return Ut.text*s+Ut.attrs*a+Ut.classes*l+Ut.bbox*c}function Ms(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function _s(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=lo({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return co(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Ds(e){let t=e.payload.domHints?.cssSelector;if(!t)return null;try{return e.doc.querySelector(t)}catch{return null}}function Os(e){let t=null,r=-1,n=0,o=e.doc.querySelectorAll("*");for(let i of Array.from(o)){if(n>=Es)break;if(n++,Pt(i,e.internalAttr))continue;let s=i.tagName.toLowerCase();if(s==="html"||s==="head"||s==="script"||s==="style")continue;let a=po(i,e);a>r&&(r=a,t=i);}return r>=uo?t:null}function Gt(e){if(!e.payload.domHints)return {tier:3,el:null};let t=Ds(e);if(t&&po(t,e)>=uo)return {tier:1,el:t};let r=Os(e);return r?{tier:2,el:r}:{tier:3,el:null}}function vr(e,t){return e.tier===3||!e.el?Ms(t):_s(e.el,t)}function mo(e){let t=Gt(e);return {tier:t.tier,el:t.el,position:vr(t,e)}}function go(e){if(e.status==="resolved")return null;let t=e.latestRun;return t?t.status==="failed"?"patch-failed":t.status!=="succeeded"?null:t.prClosedUnmerged?"rerun-after-closed":t.prUrl?"review-pr":null:null}var zs="data-patch-internal";function Kt(e,t,r){let n=Ke(r,t.getOverlayViewport()),o=Yt(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function yr(e,t){return {payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:zs}}function vo(e,t,r){let n=yr(e,t);return {tier:r.tier,position:e.targetPointToOverlay(vr(r,n))}}function Hs(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function xo(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:i}=me(),s=ge(),{dockOpen:a,hideResolvedAnnotations:l}=Ft(),c=se(),{isPreviewing:p,previewReady:g}=Ye(),u=react$1.useReducedMotion(),f=s.active,x=s.forceClose,w=t&&(!p||g),E=react.useMemo(()=>a&&t?e.filter(b=>!l||b.status!=="resolved"):[],[a,t,e,l]),k=react.useMemo(()=>a&&t?r:[],[a,t,r]);react.useEffect(()=>{if(!l||f?.kind!=="existing")return;e.find(A=>A.id===f.annotationId)?.status==="resolved"&&x();},[f,e,x,l]);let m=react.useRef(new Map),d=react.useRef(new Map),v=react.useRef(new Map),C=react.useMemo(()=>{let b=v.current,A=new Set,M=new Map;for(let I of E){A.add(I.id);let D=Gt(yr(c,I));b.set(I.id,D),M.set(I.id,vo(c,I,D));}for(let I of b.keys())A.has(I)||b.delete(I);return M},[c,E]),T=react.useCallback(()=>{let b=v.current;for(let A of E){let M=m.current.get(A.id);if(!M)continue;let I=b.get(A.id);(!I||I.el&&!I.el.isConnected)&&(I=Gt(yr(c,A)),b.set(A.id,I)),Kt(M,c,vo(c,A,I).position);}for(let A of k){let M=d.current.get(A.tempId);M&&Kt(M,c,Hs(c,A));}},[c,E,k]);react.useEffect(()=>{let b=null,A=()=>{b===null&&(b=c.overlayWindow.requestAnimationFrame(()=>{b=null,T();}));},M=new Set([c.targetWindow,c.overlayWindow]);for(let D of M)D.addEventListener("resize",A),D.addEventListener("scroll",A,{passive:true});let I=Tt(c.targetWindow,A);return I.observe(c.targetDocument.body),A(),()=>{b!==null&&c.overlayWindow.cancelAnimationFrame(b);for(let D of M)D.removeEventListener("resize",A),D.removeEventListener("scroll",A);I.disconnect();}},[T,c]);let P=react.useCallback(b=>{if(s.active&&s.draftText.trim().length>0){s.attemptClose();return}s.openExisting(b);},[s]),z=o?o.name:n?.name??null,X=o?.image??null,G=n?.avatarSeed??i,re=o?.userId??G;return jsxRuntime.jsxs("div",{"data-patch-pin-layer":"",style:{opacity:w?1:0,transition:u||!w?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:w?void 0:"none"},children:[jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:E.map(b=>{let A=C.get(b.id),M=Fs(b),I=!o&&!!n?.clientUserId&&b.payload.authorRole==="client"&&b.payload.authorId===n.clientUserId,D=o?go(b):null,ie=A?Ke(A.position,c.getOverlayViewport()):"right";return jsxRuntime.jsx(pr,{ref:Q=>{Q?(m.current.set(b.id,Q),A&&Kt(Q,c,A.position)):m.current.delete(b.id);},avatarSrc:M.image,generatedSeed:I?G:M.generatedSeed,avatarAlt:M.name??"",resolved:b.status==="resolved",attention:D,orphan:A?.tier===3,pointSide:ie,ariaLabel:`Annotation by ${b.authorName??"someone"}`,onClick:()=>P(b.id),pinId:b.id},b.id)})}),jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:k.map(b=>{let A=c.targetPointToOverlay({viewportX:b.viewportX,viewportY:b.viewportY});return jsxRuntime.jsx(pr,{ref:M=>{M?(d.current.set(b.tempId,M),Kt(M,c,A)):d.current.delete(b.tempId);},avatarSrc:X,generatedSeed:re,avatarAlt:z??"",resolved:false,pointSide:Ke(A,c.getOverlayViewport()),ephemeral:true},b.tempId)})})]})}function Fs(e){let t=e.authorAvatarSeed??e.payload.authorId??(e.authorName?`annotation-author:${e.authorName}`:null);if(e.authorImage||t||e.authorName)return {name:e.authorName,image:e.authorImage??null,generatedSeed:t??e.id,key:e.payload.authorId??e.authorName??e.id};let r=e.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??e.id,key:r.authorId??r.authorName??e.id}}return {name:e.authorName,image:e.authorImage??null,generatedSeed:e.id,key:e.id}}var wo=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
4
+ `)}function Ga(e,t){let r=e.targetDocument,n=r.getElementById(Nn);n&&n.remove();let o=r.createElement("style");return o.id=Nn,o.setAttribute(t,""),o.textContent=Xa(t),r.head.appendChild(o),o}function zt(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var ze=1.5,_n="#0287FE",Dn="rgba(2, 135, 254, 0.032)";function Ka(e){let t=e.split(" ")[0]??"",r=Number.parseFloat(t);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function qa(e,t){let r=e.targetDocument,n=r.createElement("div");n.setAttribute(t,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${ze}px solid ${_n}`,background:Dn,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(t,""),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 i=null;return {update(a){let s=a.getBoundingClientRect();if(s.width===0&&s.height===0){this.hide();return}n.style.display="block",n.style.top=`${s.top-ze}px`,n.style.left=`${s.left-ze}px`,n.style.width=`${s.width+ze*2}px`,n.style.height=`${s.height+ze*2}px`,n.style.borderRadius=`${Ka(e.targetWindow.getComputedStyle(a).borderRadius)+ze}px`,a!==i&&(o.textContent=ot(a),i=a),o.style.display="block";let l=s.right+8,c=Math.max(8,s.top),p=e.getTargetViewport().width-8;l+240<=p?(o.style.left=`${l}px`,o.style.top=`${c}px`):(o.style.left=`${Math.max(8,s.right-240)}px`,o.style.top=`${Math.max(8,s.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function ja(e,t){let r=e.targetDocument.createElement("div");return r.setAttribute(t,""),Object.assign(r.style,{position:"fixed",pointerEvents:"none",border:`${ze}px solid ${_n}`,background:Dn,boxSizing:"border-box",zIndex:"2147483645",borderRadius:"8px"}),e.targetDocument.body.appendChild(r),{update(n){r.style.left=`${n.x}px`,r.style.top=`${n.y}px`,r.style.width=`${n.width}px`,r.style.height=`${n.height}px`;},destroy(){r.remove();}}}function Mn(e,t){return {x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function Ln(e){let{internalAttr:t,onClick:r,onDrag:n,surface:o}=e,i=o.targetDocument,a=Ga(o,t),s=qa(o,t),l=false,c=null,p=null;function g(){c?.rectOverlay&&c.rectOverlay.destroy(),c=null;}function u(){p&&(p.destroy(),p=null);}let f=m=>{let d=m,v=o.eventTargetElement(d.target);zt(o,d.target,t)||v&&cr(v)||(d.preventDefault(),d.stopPropagation(),!l&&(u(),c={startX:d.clientX,startY:d.clientY,isDragging:false,rectOverlay:null}));},x=m=>{let d=m;if(c?.isDragging){d.preventDefault(),d.stopPropagation();let C=Mn({x:c.startX,y:c.startY},{x:d.clientX,y:d.clientY});p=c.rectOverlay,c=null,n?.(C,d);return}g();let v=o.eventTargetElement(d.target);zt(o,d.target,t)||v&&cr(v)||(d.preventDefault(),d.stopPropagation());},w=m=>{let d=m;zt(o,d.target,t)||(d.preventDefault(),d.stopPropagation(),!l&&r(d));},T=m=>{let d=m;if(c){if(!c.isDragging){let S=d.clientX-c.startX,N=d.clientY-c.startY;if(Math.hypot(S,N)<Rn)return;c.isDragging=true,s.hide(),c.rectOverlay=ja(o,t);}c.rectOverlay?.update(Mn({x:c.startX,y:c.startY},{x:d.clientX,y:d.clientY}));return}if(l)return;let v=o.eventTargetElement(d.target);if(!v){s.hide();return}if(zt(o,v,t)){s.hide();return}let C=v.tagName.toLowerCase();if(C==="html"||C==="body"){s.hide();return}s.update(v);},k=m=>{m.relatedTarget||s.hide();};return i.addEventListener("mousedown",f,true),i.addEventListener("mouseup",x,true),i.addEventListener("click",w,true),i.addEventListener("mousemove",T,true),i.addEventListener("mouseout",k,true),{exit(){a.remove(),s.destroy(),g(),u(),i.removeEventListener("mousedown",f,true),i.removeEventListener("mouseup",x,true),i.removeEventListener("click",w,true),i.removeEventListener("mousemove",T,true),i.removeEventListener("mouseout",k,true);},pause(){l=true,s.hide(),g();},resume(){l=false;},dismissDragOverlay(){u();}}}var On="data-patch-internal",Fn=react.createContext(null),zn=0;function Hn(){return zn+=1,`tmp-${Date.now().toString(36)}-${zn}`}function Vn({children:e}){let t=fe(),r=ge(),n=se(),{isPreviewing:o,previewReady:i}=Ye(),[a,s]=react.useState(false),l=react.useRef(null),c=react.useRef(t),p=react.useRef(r);c.current=t,p.current=r;let g=react.useCallback(m=>{let d=c.current;if(d.active&&d.draftText.trim().length>0){d.attemptClose();return}let v=n.eventTargetElement(m.target)??n.targetDocument.body,C=n.targetWindow.getSelection(),S=En({clickTarget:v,selection:C}),N=Hn(),H={viewportX:m.clientX,viewportY:m.clientY,documentY:m.clientY+n.getTargetScrollY()};p.current.addEphemeral({tempId:N,viewportX:H.viewportX,viewportY:H.viewportY,documentY:H.documentY}),c.current.openComposer({tempId:N,target:S,anchor:H}),l.current?.pause();},[n]),u=react.useCallback((m,d)=>{let v=c.current;if(v.active&&v.draftText.trim().length>0){v.attemptClose(),l.current?.dismissDragOverlay();return}let C=n.getTargetViewport(),S=Pn({rect:m,viewport:C,internalAttr:On,doc:n.targetDocument});if(!S){l.current?.dismissDragOverlay();return}let N=Hn(),H={viewportX:d.viewportX,viewportY:d.viewportY,documentY:d.viewportY+n.getTargetScrollY()};p.current.addEphemeral({tempId:N,viewportX:H.viewportX,viewportY:H.viewportY,documentY:H.documentY}),c.current.openComposer({tempId:N,target:S,anchor:H}),l.current?.pause();},[n]),f=r.annotationsReady&&(!o||i);react.useEffect(()=>{if(!a||!f){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=Ln({internalAttr:On,surface:n,onClick:g,onDrag:(m,d)=>u(m,{viewportX:d.clientX,viewportY:d.clientY})}),()=>{l.current?.exit(),l.current=null;}},[a,g,u,n,f]);let x=react.useCallback(()=>{a||s(true);},[a]),w=react.useCallback(()=>{s(false);},[]),T=react.useRef(null);react.useEffect(()=>{let m=T.current,d=t.active;m?.kind==="composer"&&d?.kind!=="composer"&&(p.current.removeEphemeral(m.tempId),l.current?.dismissDragOverlay(),l.current?.resume()),m?.kind==="composer"&&d?.kind==="composer"&&m.tempId!==d.tempId&&p.current.removeEphemeral(m.tempId),T.current=d;},[t.active]),react.useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let k=react.useMemo(()=>({isCapturing:a,enter:x,exit:w}),[a,x,w]);return jsxRuntime.jsx(Fn.Provider,{value:k,children:e})}function $n(){let e=react.use(Fn);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var Wn=react.createContext(null);function Yn({children:e}){let[t,r]=react.useState(false),[n,o]=react.useState(false),i=react.useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsxRuntime.jsx(Wn.Provider,{value:i,children:e})}function Vt(){let e=react.use(Wn);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var as="[Patch] No project token found. 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 Un(e){let t=e.prop?.trim();if(t)return t;let r=e.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=e.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=e.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();if(o)return o;throw new Error(as)}function Xn(){try{return typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) })>"u"?void 0:undefined}catch{return}}function Gn(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var ss=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 ls(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Kn(e){return e.replace(/\s+/g," ").trim()}function ur(e){return ss.has(Kn(e))}function qn(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Kn(n[1]??"");!o||ur(o)||t[t.length-1]!==o&&t.push(o);}return t.length===0?null:ls(t.map(n=>`<${n}>`).join(" "),1e3)}var jn="seed:";function $t(e){return e?e.startsWith(jn)?{url:null,seed:e.slice(jn.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var pr=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],Zn=[{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]}],Jn=Math.PI*2;function cs(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}function ds(e){return ()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function W(e,t,r){return t+e()*(r-t)}function te(e,t=3){let r=10**t;return Math.round(e*r)/r}function Qn(e,t,r){return `hsl(${te((e%360+360)%360,1)} ${te(t,1)}% ${te(r,1)}%)`}function eo(e){let t=cs(e?.trim()||"patch-client"),r=ds(t),n=t.toString(36),o=(pr[t%pr.length]??pr[0])+W(r,-10,10),i=r()<.5?-1:1,a=r()<.5?-1:1,s=o+a*W(r,52,116),l=o-a*W(r,26,66),c=o+i*W(r,12,38),p=Qn(o+i*W(r,0,14),W(r,80,92),W(r,44,54)),g=W(r,0,Jn),u=Zn.map((f,x)=>{let T=(f.hue==="accent"?s:f.hue==="accent2"?l:f.hue==="near"?c:o)+W(r,-11,11),k=g+x/Zn.length*Jn+W(r,-0.6,.6),m=W(r,f.reach[0],f.reach[1]),d=te(.5+Math.cos(k)*m),v=te(.5+Math.sin(k)*m),C=te(W(r,0,180),1),S=te(W(r,.62,1.5),3),N=te(W(r,.62,1.5),3);return {id:`cav-${n}-${x}`,cx:d,cy:v,r:te(W(r,f.r[0],f.r[1])),color:Qn(T,W(r,f.sat[0],f.sat[1]),W(r,f.light[0],f.light[1])),opacity:te(W(r,f.opacity[0],f.opacity[1]),2),gradientTransform:`rotate(${C} ${d} ${v}) translate(${d} ${v}) scale(${S} ${N}) translate(${te(-d)} ${te(-v)})`}});return {id:n,background:p,spots:u,blur:te(W(r,3.4,5.4),2),grain:te(W(r,.09,.15),2)}}function it(e){let t=e.gap??12,r=e.margin??16,n=Math.min(e.popover.width,Math.max(0,e.viewport.width-r*2)),o="right",i=e.anchor.x+e.anchor.width+t;i+n>e.viewport.width-r&&(o="left",i=e.anchor.x-n-t),i<r&&(i=r);let a=e.anchor.y;return a+e.popover.height>e.viewport.height-r&&(a=e.viewport.height-r-e.popover.height),a<r&&(a=r),{x:i,y:a,width:n,placement:o}}function P(...e){return e.filter(Boolean).join(" ")}function Wt({seed:e,className:t,style:r}){let n=eo(e),o=react.useId().replace(/[^a-zA-Z0-9_-]/g,""),i=`${n.id}-${o}`,a=`cav-blur-${i}`,s=`cav-grain-${i}`;return jsxRuntime.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:P("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:a,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsxRuntime.jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxRuntime.jsxs("filter",{id:s,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsxRuntime.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsxRuntime.jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxRuntime.jsxs("radialGradient",{id:`${i}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsxRuntime.jsx("rect",{width:"64",height:"64",fill:n.background}),jsxRuntime.jsx("g",{filter:`url(#${a})`,children:n.spots.map(l=>jsxRuntime.jsx("rect",{width:"64",height:"64",fill:`url(#${i}-${l.id})`},l.id))}),jsxRuntime.jsx("rect",{width:"64",height:"64",filter:`url(#${s})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Se=28,to=[.22,.61,.36,1],Yt=["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 Xe(e){if(!e)return "?";let t=e.trim().split(/\s+/),r=t[0],n=t[t.length-1];if(!r||!n)return "?";if(t.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",i=n[0]??"";return (o+i).toUpperCase()||"?"}function Ge(e){if(!e)return Yt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Yt[Math.abs(t)%Yt.length]??Yt[0]}var ms={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},gs={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function Ke(e,t){let{placement:r}=it({anchor:{x:e.viewportX-Se/2,y:e.viewportY-Se/2,width:Se,height:Se},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function Ut(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Se,y:e.viewportY-Se,width:Se,height:Se}}function mr({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?fs[t.attention]:null,{url:o,seed:i}=$t(t.avatarSrc),a=i??t.generatedSeed,s=t.orphan?"grayscale(1)":t.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",l=t.orphan?.55:1,c=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsxRuntime.jsx(react$1.motion.button,{ref:e,type:"button",onClick:t.onClick,"aria-label":t.ariaLabel??"Open annotation","data-patch-ephemeral":t.ephemeral?"":void 0,"data-patch-pin-id":t.pinId,className:"patch-pin-button fixed z-[2147483645] size-7 border-0 bg-transparent p-0",initial:t.ephemeral?{opacity:0,scale:.45}:false,animate:t.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:t.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:to}}:{opacity:0,scale:.9,transition:{duration:.12,ease:to}},children:jsxRuntime.jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:ms[r]},children:[jsxRuntime.jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:gs[r],background:"var(--color-muted-foreground)",filter:t.orphan?"grayscale(1)":"none",opacity:t.orphan?.55:1},children:[a?jsxRuntime.jsx(Wt,{seed:a,style:{borderRadius:0,filter:s||"none",opacity:l}}):null,o?jsxRuntime.jsx("img",{src:o,alt:t.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:s||"none",opacity:l},onError:p=>{p.currentTarget.remove();}}):null]}),t.resolved&&jsxRuntime.jsx("span",{className:`absolute ${c} grid size-[13px] place-items-center rounded-full bg-brand-green text-[8px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsxRuntime.jsx("span",{"data-patch-attention":t.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[9px] rounded-full border-[1.5px] border-white ${n}`})]})})}var fs={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};var hs="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",bs={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Ee({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:i="md",className:a,style:s}){let{url:l,seed:c}=$t(r),p=c??n;return jsxRuntime.jsxs("span",{className:P(hs,bs[i],a),style:{background:t,...s},children:[jsxRuntime.jsx("span",{children:e}),!l&&p?jsxRuntime.jsx(Wt,{seed:p}):null,l?jsxRuntime.jsx("img",{src:l,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:g=>{g.currentTarget.remove();}}):null]})}var no={"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"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],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"}]],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"}]],maximize:[["path",{d:"M16.4999 3.26621C17.3443 3.25421 20.1408 2.67328 20.7337 3.26621C21.3266 3.85913 20.7457 6.65559 20.7337 7.5M20.5059 3.49097L13.5021 10.4961"}],["path",{d:"M3.26636 16.5001C3.25436 17.3445 2.67343 20.141 3.26636 20.7339C3.85928 21.3268 6.65574 20.7459 7.50015 20.7339M10.502 13.4976L3.49824 20.5027"}]],minimize:[["path",{d:"M6.5023 10.7365C7.34671 10.7485 10.1432 11.3294 10.7361 10.7365C11.329 10.1436 10.7481 7.34708 10.7361 6.50267M13.2685 17.5027C13.2565 16.6583 12.6756 13.8618 13.2685 13.2689C13.8614 12.676 16.6579 13.2569 17.5023 13.2689M20.9991 21.001L13.6102 13.6188M10.3691 10.3763L2.99998 2.99902"}]],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"}]],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"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function O({name:e,size:t=16,stroke:r=2,color:n,className:o}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:no[e].map(([i,a],s)=>react.createElement(i,{key:s,...a}))})}var ys="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 fr({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:o?"none":"currentColor",stroke:o?"currentColor":"none",strokeWidth:o?r:void 0,strokeLinejoin:o?"round":void 0,strokeLinecap:o?"round":void 0,"aria-hidden":"true",focusable:"false",className:n,children:jsxRuntime.jsx("path",{d:ys})})}var hr=false,He=null,Xt=null,de={openDelay:700,isInstant(){return hr},onOpen(e){Xt&&Xt!==e&&Xt(),Xt=e??null,hr=true,He&&(clearTimeout(He),He=null);},onClose(){He&&clearTimeout(He),He=setTimeout(()=>{hr=false,He=null;},300);}};var so="easeOut";function ke({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[i,a]=react.useState(false),[s,l]=react.useState(false),c=react.useRef(null),p=react.useRef(false);react.useEffect(()=>()=>{c.current&&clearTimeout(c.current),p.current&&de.onClose();},[]);let g=v=>{l(v),a(true),p.current=true,de.onOpen();},u=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),de.isInstant()){g(true);return}c.current=setTimeout(()=>{c.current=null,g(false);},de.openDelay);},f=()=>{c.current&&(clearTimeout(c.current),c.current=null),p.current&&(p.current=false,de.onClose()),a(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",w="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",T=n==="warning"?`relative flex w-[200px] items-start gap-1.5 rounded-[14px] bg-foreground px-3 py-2.5 text-left text-[11px] leading-[1.35] font-medium text-white ${w}`:`relative block whitespace-nowrap rounded-[10px] bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${w}`,k=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",m=o==="bottom"&&n!=="warning"?-3:3,d=o==="bottom"&&n!=="warning"?-2:2;return jsxRuntime.jsxs("span",{className:P("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:f,onMouseDown:f,children:[jsxRuntime.jsx("span",{className:x,children:jsxRuntime.jsx(react$1.AnimatePresence,{children:i&&jsxRuntime.jsxs(react$1.motion.span,{initial:s?false:{opacity:0,y:m,scale:.98},animate:{opacity:1,y:0,scale:1,transition:s?{duration:0}:{duration:.1,ease:so}},exit:{opacity:0,y:d,scale:.98,transition:{duration:.08,ease:so}},className:T,children:[n==="warning"?jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsxRuntime.jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsxRuntime.jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsxRuntime.jsx("span",{className:"min-w-0 flex-1",children:e}),jsxRuntime.jsx("span",{className:k})]})})}),t]})}var Ts=44,Ss=212,be=[.16,1,.3,1],co="easeOut",Es=.08,Rs=60,Is="calc(100% - 64px) calc(100% + 4px)",ct="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function uo(){let e=$n(),t=fe(),r=ge(),{dockOpen:n,hideResolvedAnnotations:o,setDockOpen:i,setHideResolvedAnnotations:a}=Vt(),[s,l]=react.useState(false),[c,p]=react.useState(false),[g,u]=react.useState(false),[f,x]=react.useState(false),[w,T]=react.useState(false),k=react.useRef(null),m=react.useRef(null),d=react.useRef(false),[v,C]=react.useState(false),S=r.studio?r.studio.name:r.identity?.name??null,N=Xe(S),H=r.studio?.image??null,U=r.identity?.avatarSeed??r.clientAvatarSeed,G=r.studio?.userId??U,ne=r.studio?"var(--color-foreground)":Ge(U),b=r.studio&&!H?"#FFFFFF":ne,A=r.studio&&!H?"text-foreground":"text-white",M=ve[r.activeViewport];function I(){k.current!==null&&(window.clearTimeout(k.current),k.current=null);}function D(){m.current!==null&&(window.clearTimeout(m.current),m.current=null);}let j=react.useRef(()=>{});j.current=()=>{!d.current&&k.current===null||(I(),D(),d.current=false,T(true));};let ee=react.useRef(()=>j.current()).current;react.useEffect(()=>{w&&s&&l(false);},[w,s]);function le(V){p(false),u(false),I(),D(),d.current=true,T(false),x(V),de.onOpen(ee),l(true);}function ce(){le(false);}function Ce(){if(I(),!(d.current||m.current!==null)){if(de.isInstant()){le(true);return}m.current=window.setTimeout(()=>{m.current=null,le(false);},de.openDelay);}}function h(){D(),I(),d.current&&(d.current=false,de.onClose()),k.current=window.setTimeout(()=>{l(false),k.current=null;},120);}function R(){C(true),i(true);}function L(){p(false),u(false),D(),d.current=false,l(false),e.isCapturing?e.exit():e.enter();}function X(){C(true),i(false),p(false),u(false),D(),d.current=false,l(false),e.exit(),t.active&&t.forceClose();}react.useEffect(()=>()=>{k.current!==null&&window.clearTimeout(k.current),m.current!==null&&window.clearTimeout(m.current);},[]);let ue=()=>{r.signOut(),l(false);};function ae(){u(false),D(),d.current=false,l(false),p(V=>!V);}function Me(V){p(false),r.activeViewport!==V&&(t.active&&t.forceClose(),r.setActiveViewport(V));}function ft(){p(false),D(),d.current=false,l(false),u(V=>!V);}function ht(){a(!o);}function bt(V){let _e=V.relatedTarget;_e instanceof Node&&V.currentTarget.contains(_e)||h();}return jsxRuntime.jsx("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:jsxRuntime.jsxs(react$1.motion.div,{initial:false,animate:{width:n?Ss:Ts},transition:{duration:.36,ease:be},onAnimationComplete:()=>C(false),whileHover:n?void 0:{scale:1.03,transition:{duration:.15,ease:be}},whileTap:n?void 0:{scale:.97,transition:{duration:.1,ease:be}},"data-patch-fab-dock":"",className:P("pkey-fab relative h-11 rounded-full",v?"overflow-hidden":"overflow-visible"),children:[jsxRuntime.jsx(react$1.motion.div,{animate:{opacity:n?0:1,scale:n?.7:1},transition:{duration:.18,ease:be},className:P("absolute inset-0",n?"pointer-events-none":"pointer-events-auto"),children:jsxRuntime.jsx("button",{type:"button",onClick:R,"data-patch-fab-dock":"","aria-label":"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsxRuntime.jsx(fr,{variant:"outline",size:18})})}),jsxRuntime.jsxs("div",{"data-patch-fab-dock":"",className:P("absolute inset-0 flex items-center gap-1.5 px-1.5",n?"pointer-events-auto":"pointer-events-none"),children:[jsxRuntime.jsx(dt,{visible:n,index:0,children:jsxRuntime.jsx(ke,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:L,className:P(ct,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(fr,{variant:"outline",size:16})})})}),jsxRuntime.jsx(dt,{visible:n,index:1,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${M.label}`,"aria-expanded":c,onClick:ae,className:P(ct,"transition-colors",r.activeViewport==="desktop"&&!c?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsxRuntime.jsx(O,{name:M.glyph,size:15})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:c?jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:be}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:be}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsxRuntime.jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),Or.map(V=>{let _e=ve[V],vt=r.activeViewport===V;return jsxRuntime.jsx(ke,{text:Ve(V),children:jsxRuntime.jsx("button",{type:"button","data-patch-viewport-option":V,"aria-label":Ve(V),"aria-pressed":vt,onClick:()=>Me(V),className:P("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",vt?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(O,{name:_e.glyph,size:15})})},V)})]}):null})]})}),jsxRuntime.jsx(dt,{visible:n,index:2,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx(ke,{text:"Settings",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":g,onClick:ft,className:P(ct,"transition-colors",g||o?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(O,{name:"settings",size:15})})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:g?jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:be}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:be}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-[18px] p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsxRuntime.jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxRuntime.jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-xl px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:o,"aria-label":"Hide resolved annotations",onChange:ht,className:"peer sr-only"}),jsxRuntime.jsx("span",{"aria-hidden":"true",className:P("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",o?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsxRuntime.jsx(O,{name:"check",size:10,stroke:2.4})}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsxRuntime.jsx(dt,{visible:n,index:3,children:jsxRuntime.jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Ce,onMouseLeave:h,onFocus:ce,onBlur:bt,children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":S?`Account: ${S}`:"Identify",className:P(ct,"text-white"),children:S?jsxRuntime.jsx(Ee,{initials:N,tint:b,src:H,generatedSeed:G,alt:S,size:"sm",className:P("size-[22px] text-[9.5px] ring-1 ring-white/20",A)}):jsxRuntime.jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:s?jsxRuntime.jsxs(react$1.motion.div,{initial:f?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:f?{duration:0}:{duration:.12,delay:Es,ease:co}},exit:{opacity:0,y:2,scale:.98,transition:w?{duration:0}:{duration:.08,ease:co}},"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-2xl 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:Is},children:[jsxRuntime.jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:Rs}}),r.studio?jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(Ee,{initials:N,tint:ne,src:H,generatedSeed:G,alt:r.studio.name,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(Ee,{initials:N,tint:ne,generatedSeed:G,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsxRuntime.jsx("div",{className:"my-3 h-px bg-white/10"}),jsxRuntime.jsx("button",{type:"button",onClick:ue,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsxRuntime.jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsxRuntime.jsx(dt,{visible:n,index:4,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsxRuntime.jsx(ke,{text:"Close",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:X,className:P(ct,"text-white/70"),children:jsxRuntime.jsx(O,{name:"x",size:14})})})]})})]})]})})}function dt({children:e,visible:t,index:r}){return jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:be}}:{opacity:0,x:6,transition:{duration:.12,ease:be}},children:e})}function po(e,t){return t.width<=0||t.height<=0?{fx:0,fy:0}:{fx:(e.viewportX-t.x)/t.width,fy:(e.viewportY-t.y)/t.height}}function mo(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var go=.6,Gt={text:.4,attrs:.3,classes:.2,bbox:.1},Ns=5e3;function Ms(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function _s(e,t){if(!t)return .5;let r=Object.keys(t);if(r.length===0)return .5;let n=0;for(let o of r)e[o]===t[o]&&n++;return n/r.length}function Ds(e,t){let r=new Set(e),n=new Set(t??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let a of r)n.has(a)&&o++;let i=r.size+n.size-o;return i===0?0:o/i}function Ls(e,t,r){if(!t)return .5;let n=e.x+e.width/2,o=e.y+e.height/2,i=t.x+t.width/2,a=t.y+t.height/2,s=(n-i)/Math.max(1,r.width),l=(o-a)/Math.max(1,r.height),c=Math.sqrt(s*s+l*l);return Math.max(0,1-c)}function fo(e,t){let r=Nt(e),n=Pt(e),o=Oe(e),i=e.getBoundingClientRect(),a=Ms(r,t.payload.domHints?.textSignature),s=_s(n,t.payload.domHints?.attributeSignature),l=Ds(o,t.payload.cssClasses),c=Ls(i,t.payload.boundingBox,t.viewport);return Gt.text*a+Gt.attrs*s+Gt.classes*l+Gt.bbox*c}function Os(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function zs(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=po({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return mo(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Hs(e){let t=e.payload.domHints?.cssSelector;if(!t)return null;try{return e.doc.querySelector(t)}catch{return null}}function Fs(e){let t=null,r=-1,n=0,o=e.doc.querySelectorAll("*");for(let i of Array.from(o)){if(n>=Ns)break;if(n++,Mt(i,e.internalAttr))continue;let a=i.tagName.toLowerCase();if(a==="html"||a==="head"||a==="script"||a==="style")continue;let s=fo(i,e);s>r&&(r=s,t=i);}return r>=go?t:null}function Kt(e){if(!e.payload.domHints)return {tier:3,el:null};let t=Hs(e);if(t&&fo(t,e)>=go)return {tier:1,el:t};let r=Fs(e);return r?{tier:2,el:r}:{tier:3,el:null}}function xr(e,t){return e.tier===3||!e.el?Os(t):zs(e.el,t)}function ho(e){let t=Kt(e);return {tier:t.tier,el:t.el,position:xr(t,e)}}function bo(e){if(e.status==="resolved")return null;let t=e.latestRun;return t?t.status==="failed"?"patch-failed":t.status!=="succeeded"?null:t.prClosedUnmerged?"rerun-after-closed":t.prUrl?"review-pr":null:null}var $s="data-patch-internal";function qt(e,t,r){let n=Ke(r,t.getOverlayViewport()),o=Ut(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function kr(e,t){return {payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:$s}}function yo(e,t,r){let n=kr(e,t);return {tier:r.tier,position:e.targetPointToOverlay(xr(r,n))}}function Bs(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function ko(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:i}=ge(),a=fe(),{dockOpen:s,hideResolvedAnnotations:l}=Vt(),c=se(),{isPreviewing:p,previewReady:g}=Ye(),u=react$1.useReducedMotion(),f=a.active,x=a.forceClose,w=t&&(!p||g),T=react.useMemo(()=>s&&t?e.filter(b=>!l||b.status!=="resolved"):[],[s,t,e,l]),k=react.useMemo(()=>s&&t?r:[],[s,t,r]);react.useEffect(()=>{if(!l||f?.kind!=="existing")return;e.find(A=>A.id===f.annotationId)?.status==="resolved"&&x();},[f,e,x,l]);let m=react.useRef(new Map),d=react.useRef(new Map),v=react.useRef(new Map),C=react.useMemo(()=>{let b=v.current,A=new Set,M=new Map;for(let I of T){A.add(I.id);let D=b.get(I.id),j=D?.el?.isConnected?D:Kt(kr(c,I));b.set(I.id,j),M.set(I.id,yo(c,I,j));}for(let I of b.keys())A.has(I)||b.delete(I);return M},[c,T]),S=react.useCallback(()=>{let b=v.current;for(let A of T){let M=m.current.get(A.id);if(!M)continue;let I=b.get(A.id);(!I||I.el&&!I.el.isConnected)&&(I=Kt(kr(c,A)),b.set(A.id,I)),qt(M,c,yo(c,A,I).position);}for(let A of k){let M=d.current.get(A.tempId);M&&qt(M,c,Bs(c,A));}},[c,T,k]);react.useEffect(()=>{let b=null,A=()=>{b===null&&(b=c.overlayWindow.requestAnimationFrame(()=>{b=null,S();}));},M=new Set([c.targetWindow,c.overlayWindow]);for(let D of M)D.addEventListener("resize",A),D.addEventListener("scroll",A,{passive:true});let I=Tt(c.targetWindow,A);return I.observe(c.targetDocument.body),A(),()=>{b!==null&&c.overlayWindow.cancelAnimationFrame(b);for(let D of M)D.removeEventListener("resize",A),D.removeEventListener("scroll",A);I.disconnect();}},[S,c]);let N=react.useCallback(b=>{if(a.active&&a.draftText.trim().length>0){a.attemptClose();return}a.openExisting(b);},[a]),H=o?o.name:n?.name??null,U=o?.image??null,G=n?.avatarSeed??i,ne=o?.userId??G;return jsxRuntime.jsxs("div",{"data-patch-pin-layer":"",style:{opacity:w?1:0,transition:u||!w?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:w?void 0:"none"},children:[jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:T.map(b=>{let A=C.get(b.id),M=Ws(b),I=!o&&!!n?.clientUserId&&b.payload.authorRole==="client"&&b.payload.authorId===n.clientUserId,D=o?bo(b):null,j=A?Ke(A.position,c.getOverlayViewport()):"right";return jsxRuntime.jsx(mr,{ref:ee=>{ee?(m.current.set(b.id,ee),A&&qt(ee,c,A.position)):m.current.delete(b.id);},avatarSrc:M.image,generatedSeed:I?G:M.generatedSeed,avatarAlt:M.name??"",resolved:b.status==="resolved",attention:D,orphan:A?.tier===3,pointSide:j,ariaLabel:`Annotation by ${b.authorName??"someone"}`,onClick:()=>N(b.id),pinId:b.id},b.id)})}),jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:k.map(b=>{let A=c.targetPointToOverlay({viewportX:b.viewportX,viewportY:b.viewportY});return jsxRuntime.jsx(mr,{ref:M=>{M?(d.current.set(b.tempId,M),qt(M,c,A)):d.current.delete(b.tempId);},avatarSrc:U,generatedSeed:ne,avatarAlt:H??"",resolved:false,pointSide:Ke(A,c.getOverlayViewport()),ephemeral:true},b.tempId)})})]})}function Ws(e){let t=e.authorAvatarSeed??e.payload.authorId??(e.authorName?`annotation-author:${e.authorName}`:null);if(e.authorImage||t||e.authorName)return {name:e.authorName,image:e.authorImage??null,generatedSeed:t??e.id,key:e.payload.authorId??e.authorName??e.id};let r=e.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??e.id,key:r.authorId??r.authorName??e.id}}return {name:e.authorName,image:e.authorImage??null,generatedSeed:e.id,key:e.id}}var Co=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
5
5
  @layer properties;
6
6
  @layer theme, base, components, utilities;
7
7
  @layer theme {
@@ -1884,5 +1884,5 @@ button:not(:disabled):not(.pkey):active {
1884
1884
  }
1885
1885
  }
1886
1886
  }
1887
- `;var yo="patch-widget-root";function ko({children:e}){let[t,r]=react.useState(null),n=react.useRef(null);return react.useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(yo);o||(o=document.createElement(yo),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let i=o.shadowRoot??o.attachShadow({mode:"open"});if(!i.querySelector("style[data-patch-css]")){let a=document.createElement("style");a.setAttribute("data-patch-css",""),a.textContent=wo,i.appendChild(a);}let s=i.querySelector("div[data-patch-mount]");return s||(s=document.createElement("div"),s.setAttribute("data-patch-mount",""),i.appendChild(s)),r(s),()=>{}},[]),t?reactDom.createPortal(e,t):null}var Xs=/[\s#.:[\]()>+~,\\]/;function Co(e){return !(!e||Xs.test(e)||/^\d/.test(e))}function Us(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Ao(e){if(!e.tagName)return "";if(e.id&&Co(e.id))return `#${e.id}`;let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<4;){let o=r.tagName.toLowerCase();if(r.id&&Co(r.id))return t.unshift(`#${r.id}`),t.join(" > ");t.unshift(`${o}:nth-of-type(${Us(r)})`),r=r.parentElement,n++;}return t.join(" > ")}var Gs=80,Ks=500;function So(e){return e!==null&&typeof e=="object"}function qs(e){return So(e)?"return"in e||"type"in e||"elementType"in e||"_debugOwner"in e:false}function jt(e){if(typeof e=="function")return e.displayName||e.name||null;if(!So(e))return null;let t=e.displayName;if(typeof t=="string"&&t)return t;let r=jt(e.render);if(r)return r;let n=jt(e.type);return n||null}function Eo(e){return e.replace(/\s+/g," ").trim()}function Ro(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function js(e){let t=Eo(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:Ro(t,Gs)}function Zs(e){let t=jt(e.elementType)??jt(e.type);return t?js(t):null}function To(e){return Ro(Eo(e),Ks)}function Js(e){let t=e.replace(/\\/g,"/");return t.includes("/.next/")||t.includes("/node_modules/next/")||t.includes("/node_modules/react/")||t.includes("/node_modules/react-dom/")||t.includes("/node_modules/react-router/")||t.includes("/node_modules/react-router-dom/")||t.includes("/node_modules/@remix-run/")||t.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(t)}function Qs(e){let t=e.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=t.lastIndexOf(n);if(o>=0)return To(t.slice(o+1))}let r=t.split("/").filter(Boolean);return To(r.slice(-3).join("/"))}function el(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||Js(t)?null:Qs(t)}function tl(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(qs(n))return n}return null}function kr(e){let t=tl(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let a=Zs(t),l=a?dr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=el(t)),t=t.return??t._debugOwner??null,o+=1;}let i=r.length>0?Un(r.reverse().map(a=>`<${a}>`).join(" ")):null,s={};return i&&(s.reactComponents=i),n&&(s.sourceFile=n),Object.keys(s).length>0?s:null}var Io=500,No=3;function rl(e){return e.length<=Io?e:e.slice(0,Io)}function Cr(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function Zt(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Po(e){let t={cssSelector:Ao(e)},r=Nt(e);r&&(t.textSignature=r);let n=It(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function Mo(e){return e.kind==="element"?ot(e.element,e.selectedText):e.kind==="multi"?_t(e.elements.length):Dt()}function _o(e){let{target:t,click:r,comment:n,url:o}=e,i=t.element,s=t.rect,a=mn(i),l=fn(i),c=Le(i),p=hn(i),g=kr(i),u={comment:n,element:nt(i),elementPath:gn(i),targetLabel:ot(i,t.selectedText),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:Cr(r),boundingBox:Zt(s),domHints:Po(i)};return t.selectedText&&(u.selectedText=rl(t.selectedText)),l&&(u.nearbyText=l),c.length>0&&(u.cssClasses=c),p.length>0&&(u.nearbyElements=p),a&&(u.accessibility=a),g?.reactComponents&&(u.reactComponents=g.reactComponents),g?.sourceFile&&(u.sourceFile=g.sourceFile),u}function Do(e){let{target:t,click:r,comment:n,url:o}=e,i=t.elements.slice(0,No).map(p=>nt(p)),s=t.elements.length>No?"\u2026":"",a=`${t.elements.length} elements: ${i.join(", ")}${s}`,l=t.elements[0],c=l?kr(l):null;return {comment:n,element:a,elementPath:a,targetLabel:_t(t.elements.length),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:Cr(r),boundingBox:Zt(t.union),isMultiSelect:true,elementBoundingBoxes:t.rects.map(Zt),...c?.reactComponents?{reactComponents:c.reactComponents}:{},...c?.sourceFile?{sourceFile:c.sourceFile}:{},...l?{domHints:Po(l)}:{}}}function Oo(e){let{target:t,click:r,comment:n,url:o}=e,i=Math.round(t.rect.width),s=Math.round(t.rect.height),a=Math.round(t.rect.x),l=Math.round(t.rect.y);return {comment:n,element:`region ${i}\xD7${s}`,elementPath:`region at (${a}, ${l}) ${i}\xD7${s}`,targetLabel:Dt(),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:Cr(r),boundingBox:Zt(t.rect)}}async function ut(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function Lo(e,t){return t.resolve(e)}async function zo(e,t){return t.deleteAnnotation(e)}async function Ho(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function Fo(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function $o(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function Vo(e,t){return t.postIdentity(e)}var Yo=react.createContext(null),Wo=0;function Tr(e){return Wo+=1,`${e}-${Date.now().toString(36)}-${Wo}`}function Sr(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function Xo({annotation:e,draftTargetLabel:t,children:r}){let n=me(),o=ge(),i=se(),[s,a]=react.useState(false),[l,c]=react.useState(null),[p,g]=react.useState(null),u=react.useRef(false),f=e?.thread??[],x=e?.latestRun??null,w=e?.status==="resolved",E=e?Sr(e):false,k=n.viewerKind,m=react.useCallback(()=>k==="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,k]),d=react.useMemo(()=>m(),[m]),v=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!d.authorId&&e.payload.authorRole===d.role&&e.payload.authorId===d.authorId,C=react.useCallback(S=>{let _=m();return {id:Tr("tmp-msg"),role:_.role,authorId:_.authorId,authorName:_.authorName,authorImage:_.authorImage,content:S,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[m]),T=react.useCallback(async S=>{if(u.current)return Promise.reject(new Error("busy"));u.current=true,a(true);try{return await S()}finally{u.current=false,a(false);}},[]),P=react.useCallback(async()=>{let S=o.draftText.trim();if(!S)return;if(e){if(w||Sr(e))return;let et=C(S);o.setDraftText(""),n.updateAnnotation(e.id,Ae=>({...Ae,thread:[...Ae.thread,et]}));let Mr=await ut({kind:"reply",annotationId:e.id,content:S},n.apiClient);if(Mr){n.updateAnnotation(e.id,Ae=>({...Ae,thread:Ae.thread.map(De=>De.id===et.id?{...De,id:Mr.id,deliveryStatus:"sent"}:De)})),n.refresh();return}n.updateAnnotation(e.id,Ae=>({...Ae,thread:Ae.thread.map(De=>De.id===et.id?{...De,deliveryStatus:"failed"}:De)}));return}let _=o.active;if(!_||_.kind!=="composer")return;let F=_.target,V={viewportX:_.anchor.viewportX,viewportY:_.anchor.viewportY,scrollY:_.anchor.documentY-_.anchor.viewportY},B=i.getPageUrl(),Ei=Dr(n.activeViewport,i.getTargetViewport()),xt=F.kind==="element"?_o({target:F,click:V,comment:S,url:B}):F.kind==="multi"?Do({target:F,click:V,comment:S,url:B}):Oo({target:F,click:V,comment:S,url:B});xt.viewport=n.activeViewport,xt.viewportSize=Ei;let wt=m(),yt=Tr("tmp-ann");n.applyAnnotationUpdate({id:yt,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:wt.authorName,authorImage:wt.authorImage,payload:{...xt,authorRole:wt.role,authorId:wt.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(yt);let er=await ut({kind:"composer",payload:xt},n.apiClient);if(er){n.replaceAnnotationId(yt,er.id),o.openExisting(er.id),n.refresh();return}n.updateAnnotation(yt,et=>({...et,deliveryStatus:"failed"}));},[e,m,w,C,n,o,i]),z=react.useCallback(async S=>{if(!e||Sr(e))return;let _=e.thread.find(V=>V.id===S);if(!_||_.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"sending"}:B)}));let F=await ut({kind:"reply",annotationId:e.id,content:_.content},n.apiClient);if(F){n.updateAnnotation(e.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,id:F.id,deliveryStatus:"sent"}:B)})),n.refresh();return}n.updateAnnotation(e.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"failed"}:B)}));},[e,n]),X=react.useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let S=e.id;n.updateAnnotation(S,F=>({...F,deliveryStatus:"sending"}));let _=await ut({kind:"composer",payload:e.payload},n.apiClient);if(_){n.replaceAnnotationId(S,_.id),o.openExisting(_.id),n.refresh();return}n.updateAnnotation(S,F=>({...F,deliveryStatus:"failed"}));},[e,n,o]),G=react.useCallback(S=>!d.authorId||S.deliveryStatus&&S.deliveryStatus!=="sent"?false:S.role===d.role&&S.authorId===d.authorId,[d]),re=react.useCallback(()=>{v&&(c(null),g({kind:"annotation"}));},[v]),b=react.useCallback(S=>{G(S)&&(c(null),g({kind:"message",messageId:S.id}));},[G]),A=react.useCallback(()=>{c(null),g(null);},[]),M=react.useCallback(async S=>{if(!e)return false;let _=e.thread;return T(async()=>(c(null),n.updateAnnotation(e.id,V=>({...V,thread:V.thread.filter(B=>B.id!==S)})),await Ho({annotationId:e.id,messageId:S},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,V=>({...V,thread:_})),c("Couldn't delete message. Try again."),false)))},[e,n,T]),I=react.useCallback(async()=>!e||!v?false:T(async()=>(c(null),await zo(e.id,n.apiClient)?(n.updateAnnotation(e.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[e,v,n,o,T]),D=react.useCallback(async()=>{if(p)try{(p.kind==="annotation"?await I():await M(p.messageId))&&g(null);}catch{c("Couldn't delete. Try again.");}},[p,I,M]),ie=react.useCallback(async()=>{e&&await T(async()=>{c(null);let S={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,F=>({...F,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await Lo(e.id,n.apiClient)){n.updateAnnotation(e.id,F=>({...F,...S})),c("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,T]),Q=react.useCallback(async()=>{e&&await T(async()=>{c(null);let S={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,F=>({...F,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await Fo({annotationId:e.id,viewerKind:k},n.apiClient)){n.updateAnnotation(e.id,F=>({...F,...S})),c("Couldn't reopen. Try again.");return}n.refresh();});},[e,k,n,T]),le=react.useCallback(async S=>{e&&await T(async()=>{c(null);let _=e.latestRun,F=e.optimisticAction;n.updateAnnotation(e.id,B=>({...B,latestRun:{id:Tr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let V=await $o({annotationId:e.id,viewerKind:k,guidance:S},n.apiClient);if(!V?.ok){n.updateAnnotation(e.id,B=>({...B,latestRun:_,optimisticAction:F})),c(V?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,k,n,T]),ce=react.useCallback(async S=>{let _=await Vo({...S,avatarSeed:n.clientAvatarSeed},n.apiClient);return _&&await n.setIdentity(_),_},[n]),h=k==="client"&&!n.identity&&f.length===0,N=!!e||f.length>0,H=n.agentRunReadiness?.ready??true,U=n.agentRunReadiness?.message??null,ue=react.useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),ae=e?wn(e.payload):t||"annotation",Me=e?.payload.viewport??n.activeViewport,ft=n.studio?n.studio.name:n.identity?.name??null,ht=n.identity?.avatarSeed??n.clientAvatarSeed,bt=n.studio?.userId??ht,$=n.studio?.image??null,_e=n.studio?.userId??ht,vt=react.useMemo(()=>({state:{annotation:e,messages:f,runState:x,draftText:o.draftText,busy:s,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:p,showDevFooter:k==="studio",agentRunReady:H,agentRunSetupMessage:U,needsIdentity:h,isResolved:w,initialMessageLocked:E,threadVisible:N,canDeleteAnnotation:v},actions:{setDraftText:o.setDraftText,submit:P,retryMessage:z,retryInitialMessage:X,requestDeleteAnnotation:re,requestDeleteMessage:b,canDeleteMessage:G,cancelDelete:A,confirmDelete:D,markResolved:ie,reopen:Q,runPatch:le,setIdentity:ce,attemptClose:o.attemptClose,requestClose:ue,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:ae,viewport:Me,shakeNonce:o.shakeNonce,viewer:{kind:k,authorId:d.authorId,name:ft,avatarKey:bt,avatarSrc:$,generatedSeed:_e}}}),[e,f,x,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,s,l,p,P,z,X,re,b,G,A,D,ie,Q,le,ce,k,H,U,h,w,E,N,v,ue,ae,Me,d.authorId,ft,bt,$,_e]);return jsxRuntime.jsx(Yo.Provider,{value:vt,children:r})}function Y(){let e=react.use(Yo);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var ll="inline-flex shrink-0 items-center justify-center gap-1.5 h-8 px-3.5 rounded-full whitespace-nowrap text-[13px] font-semibold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",cl={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 Er(e="brand",t){return R(ll,cl[e],t)}function ne({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsxRuntime.jsx("button",{ref:n,type:r,className:Er(e,t),...o})}function Go(){let{state:e,actions:t}=Y(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",i=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",s=n?"Delete annotation":"Delete message";return jsxRuntime.jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:i}),e.actionError?jsxRuntime.jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(ne,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsxRuntime.jsx(ne,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":s})]})]})})}function qo(){let{state:e,actions:t}=Y();return e.confirmDiscardOpen?jsxRuntime.jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(ne,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsxRuntime.jsx(ne,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var ul="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",pl={sm:"size-7",md:"size-8"},ml={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Re({size:e="sm",tone:t="default",className:r,type:n="button",ref:o,...i}){return jsxRuntime.jsx("button",{ref:o,type:n,className:R(ul,pl[e],ml[t],r),...i})}function jo(e){let t=new Date(e).getTime(),r=Date.now()-t,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 Zo(e){let t=e.composedPath();for(let r of t)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function Jo(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}function Qo(){let{state:e}=Y();return !e.showDevFooter||!e.annotation?null:jsxRuntime.jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsx(fl,{}),jsxRuntime.jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsxRuntime.jsx(bl,{})})]}),e.actionError?jsxRuntime.jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function fl(){let{state:e,actions:t}=Y(),[r,n]=react.useState(false),[o,i]=react.useState(""),[s,a]=react.useState(false),l=e.runState,c=l?.status;if(e.annotation?.status==="resolved")return jsxRuntime.jsx("div",{className:"min-w-0 flex-1"});let g=c==="queued"||c==="running",u=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,f=c==="succeeded"&&l?.prClosedUnmerged,x=l?"Run Patch again":"Run Patch",w=c==="failed"?"destructiveTint":f?"warnTint":"brand",E=!e.agentRunReady,k=async()=>{try{a(!0),await t.runPatch(o.trim()||void 0),i(""),n(!1);}finally{a(false);}};if(g)return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs(ne,{variant:"brandTint",disabled:true,children:[jsxRuntime.jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let d=Jo(l.prUrl);return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Er("brand","no-underline"),children:[jsxRuntime.jsx(O,{name:"pr",size:12}),d==="PR"?"View PR":`View PR ${d}`]})})}let m=jsxRuntime.jsxs(ne,{variant:w,disabled:e.busy||E,className:E?"opacity-60":void 0,onClick:()=>n(true),children:[jsxRuntime.jsx(O,{name:c==="failed"?"play":"robot",size:12})," ",x]});return jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[E&&e.agentRunSetupMessage?jsxRuntime.jsx(ke,{text:e.agentRunSetupMessage,tone:"warning",children:m}):m,r?jsxRuntime.jsx(hl,{title:x,guidance:o,submitting:s||e.busy,onGuidanceChange:i,onCancel:()=>n(false),onSubmit:k}):null]})}function hl({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:i}){return jsxRuntime.jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsxRuntime.jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxRuntime.jsxs("form",{role:"dialog","aria-label":e,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-[20px] bg-popover p-4 shadow-dialog",onSubmit:s=>{s.preventDefault(),i();},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-xl bg-brand text-white",children:jsxRuntime.jsx(O,{name:"robot",size:13})}),jsxRuntime.jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsxRuntime.jsx(Re,{size:"sm",title:"Close",onClick:o,children:jsxRuntime.jsx(O,{name:"x",size:12})})]}),jsxRuntime.jsxs("label",{className:"flex flex-col gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsxRuntime.jsx("textarea",{value:t,onChange:s=>n(s.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-[16px] border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(ne,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsxRuntime.jsx(ne,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function bl(){let{state:e,actions:t}=Y();return e.annotation?e.annotation.status==="resolved"?jsxRuntime.jsxs(ne,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsxRuntime.jsx(O,{name:"refresh",size:12}),"Reopen"]}):jsxRuntime.jsxs(ne,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsxRuntime.jsx(O,{name:"check",size:12}),"Resolve"]}):null}var Ir=react.createContext({expanded:false,onToggleExpand:()=>{}});function ei(){return react.use(Ir)}function ti(){let{state:e,meta:t}=Y(),{expanded:r,onToggleExpand:n}=ei(),o=e.annotation,i=ve[t.viewport],s=o?.payload.selectedText;return jsxRuntime.jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{title:t.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:t.targetLabel}),jsxRuntime.jsx(ke,{text:$e(t.viewport),placement:"bottom",children:jsxRuntime.jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":$e(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsxRuntime.jsx(O,{name:i.glyph,size:15,stroke:1.8})})})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsxRuntime.jsx(O,{name:"check",size:10})," Resolved"]}):null,jsxRuntime.jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[jsxRuntime.jsx(kl,{}),jsxRuntime.jsx(Re,{onClick:n,title:r?"Collapse":"Expand",children:jsxRuntime.jsx(O,{name:r?"minimize":"maximize",size:13})}),jsxRuntime.jsx(yl,{})]})]})]}),s?jsxRuntime.jsx("div",{className:"rounded-xl bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsxRuntime.jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:s.length>200?`${s.slice(0,199).trim()}\u2026`:s})}):null]})}function yl(){let{actions:e}=Y();return jsxRuntime.jsx(Re,{onClick:e.requestClose,title:"Close",children:jsxRuntime.jsx(O,{name:"x",size:14})})}function kl(){let{state:e,actions:t}=Y(),[r,n]=react.useState(false);return e.canDeleteAnnotation?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Re,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsxRuntime.jsx(O,{name:"more",size:14})}),r?jsxRuntime.jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxRuntime.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),t.requestDeleteAnnotation();},children:[jsxRuntime.jsx(O,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function ai(){let{state:e,actions:t,meta:r}=Y(),n=react.useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,i=r.viewer.kind==="client"?r.viewer.authorId:null;return react.useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),e.threadVisible?jsxRuntime.jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:R("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",e.showDevFooter&&e.isResolved&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[e.annotation?jsxRuntime.jsx(oi,{name:e.annotation.authorName??"Someone",createdAt:e.annotation.createdAt,content:e.annotation.payload.comment,authorKey:e.annotation.payload.authorId??e.annotation.authorName??e.annotation.id,avatarSrc:e.annotation.authorImage,generatedSeed:e.annotation.payload.authorRole==="client"&&e.annotation.payload.authorId===i?o:e.annotation.authorAvatarSeed??e.annotation.payload.authorId??null,deliveryStatus:e.annotation.deliveryStatus,onRetry:e.annotation.deliveryStatus==="failed"?t.retryInitialMessage:void 0}):null,e.messages.map(a=>jsxRuntime.jsx(oi,{name:a.authorName??a.role,createdAt:a.createdAt,content:a.content,authorKey:a.authorId??a.authorName??a.role,avatarSrc:a.authorImage,generatedSeed:a.role==="client"&&a.authorId===i?o:a.authorAvatarSeed??a.authorId,deliveryStatus:a.deliveryStatus,canDelete:t.canDeleteMessage(a),onDelete:()=>t.requestDeleteMessage(a),onRetry:a.deliveryStatus==="failed"?()=>{t.retryMessage(a.id);}:void 0},a.id))]}):null}function oi(e){let t=Ue(e.name),r=Ge(e.authorKey),n=e.deliveryStatus==="failed";return jsxRuntime.jsxs("div",{className:"group/message flex gap-2.5",children:[jsxRuntime.jsx(Ee,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsxRuntime.jsx("span",{className:"text-[11px] text-muted-foreground",children:jo(e.createdAt)})]}),e.canDelete&&e.onDelete?jsxRuntime.jsx(Sl,{onDelete:e.onDelete}):null,jsxRuntime.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsxRuntime.jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?jsxRuntime.jsx("button",{type:"button",onClick:e.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 Al=44,Tl=8;function Sl({onDelete:e}){let[t,r]=react.useState(false),[n,o]=react.useState("down"),i=react.useRef(null),s=react.useCallback(()=>{let l=i.current,c=l?.closest("[data-patch-thread-scroller]");if(!l||!c){o("down");return}let p=l.getBoundingClientRect(),g=c.getBoundingClientRect(),u=g.bottom-p.bottom,f=p.top-g.top;o(u<Al+Tl&&f>u?"up":"down");},[]),a=react.useCallback(()=>{r(l=>{let c=!l;return c&&s(),c});},[s]);return jsxRuntime.jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsxRuntime.jsx(Re,{ref:i,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:a,children:jsxRuntime.jsx(O,{name:"more",size:14})}),t?jsxRuntime.jsx("div",{role:"menu",className:R("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxRuntime.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),e();},children:[jsxRuntime.jsx(O,{name:"trash",size:13}),"Delete"]})}):null]})}var El={default:"w-full min-h-[60px] resize-y rounded-2xl 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 si({variant:e="default",className:t,ref:r,...n}){return jsxRuntime.jsx("textarea",{ref:r,className:R(El[e],t),...n})}var Pl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,li="w-full rounded-[10px] border border-border bg-popover px-2 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function ci(){let{actions:e}=Y(),[t,r]=react.useState(""),[n,o]=react.useState(""),[i,s]=react.useState(null),[a,l]=react.useState(false),c=react.useRef(null);return react.useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxRuntime.jsxs("form",{onSubmit:async g=>{g.preventDefault();let u=t.trim(),f=n.trim();if(!u){s("Name is required.");return}if(!Pl.test(f)){s("Enter a valid email.");return}s(null),l(true);let x=await e.setIdentity({name:u,email:f});l(false),x||s("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsxRuntime.jsx("input",{ref:c,type:"text",placeholder:"Name",value:t,onChange:g=>r(g.target.value),className:li}),jsxRuntime.jsx("input",{type:"email",placeholder:"Email",value:n,onChange:g=>o(g.target.value),className:li}),i?jsxRuntime.jsx("div",{className:"text-xs text-destructive",children:i}):null,jsxRuntime.jsx("button",{type:"submit",disabled:a,className:R("self-end rounded-[10px] bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}function ui(){let{state:e,actions:t,meta:r}=Y(),n=react.useRef(null),[o,i]=react.useState(false);if(react.useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),react.useEffect(()=>{let u=n.current;if(!u)return;u.style.height="0px";let f=Math.min(u.scrollHeight,140);u.style.height=`${f}px`,i(f>28);},[e.draftText]),e.isResolved||e.initialMessageLocked)return null;if(e.needsIdentity)return jsxRuntime.jsx("div",{className:R("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsxRuntime.jsx(ci,{})});let s=e.draftText.trim().length>0,a=r.viewer.name,l=Ue(a),c=r.viewer.kind==="studio"?"var(--color-foreground)":Ge(r.viewer.avatarKey),p=u=>{u.preventDefault(),t.submit();},g=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),t.submit());};return jsxRuntime.jsx("form",{onSubmit:p,className:R("bg-white p-3",e.threadVisible&&"border-t border-black/6",e.showDevFooter&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxRuntime.jsxs("div",{className:R("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-[18px]":"rounded-full"),children:[jsxRuntime.jsx(Ee,{initials:l,tint:c,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:a??"",className:"self-start"}),jsxRuntime.jsx(si,{ref:n,variant:"bare",value:e.draftText,onChange:u=>t.setDraftText(u.target.value),onKeyDown:g,rows:1,placeholder:e.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsxRuntime.jsx(Ol,{enabled:s})]})})}function Ol({enabled:e}){return jsxRuntime.jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:R("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsxRuntime.jsx(O,{name:"arrow-up",size:13})})}var $l=440,gi=88,Qt=16,Vl=[.22,.61,.36,1],Bl=[.4,0,.2,1],Wl={x:-8,y:-8,origin:"top left"},fi=200;function hi(e,t,r){return Math.max(t,Math.min(r,e))}function vi(e,t,r){let n={x:e.x+e.width/2,y:e.y+e.height/2},o={x:t.x+t.width/2,y:t.y+r/2};return {x:hi((n.x-o.x)*.08,-12,12),y:hi((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Yl(e,t){if(!t)return Wl;let r=it({anchor:t,popover:{width:332,height:fi},viewport:e.getOverlayViewport()});return vi(t,r,fi)}function Xl(e,t){return e.x===t.x&&e.y===t.y&&e.origin===t.origin}function xi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n=0,onToggleExpand:o,children:i}){let{actions:{attemptClose:s},meta:{shakeNonce:a}}=Y(),l=se(),c=react.useRef(null),[p,g]=react.useState(600),[u,f]=react.useState(()=>Yl(l,t??e())),x=react.useCallback(()=>{let m=c.current;if(!m||r)return;let d=e();if(!d)return;let v=m.offsetHeight||200,C=it({anchor:d,popover:{width:332,height:v},viewport:l.getOverlayViewport()});m.style.left=`${C.x}px`,m.style.top=`${C.y}px`,m.style.right="auto";let T=vi(d,C,v);f(P=>Xl(P,T)?P:T);},[e,r,l]);react.useLayoutEffect(()=>{r||x(),g(l.getOverlayViewport().height-Qt-gi);}),react.useEffect(()=>{let m=null,d=()=>{m===null&&(m=l.overlayWindow.requestAnimationFrame(()=>{m=null,r||x(),g(l.getOverlayViewport().height-Qt-gi);}));},v=new Set([l.targetWindow,l.overlayWindow]);for(let T of v)T.addEventListener("resize",d),T.addEventListener("scroll",d,{passive:true});let C=Tt(l.overlayWindow,d);return C.observe(l.overlayDocument.body),l.targetDocument.body!==l.overlayDocument.body&&C.observe(l.targetDocument.body),c.current&&C.observe(c.current),()=>{m!==null&&l.overlayWindow.cancelAnimationFrame(m);for(let T of v)T.removeEventListener("resize",d),T.removeEventListener("scroll",d);C.disconnect();}},[x,r,l]),react.useEffect(()=>{let m=C=>{Zo(C)||s();},d=C=>{C.key==="Escape"&&s();},v=new Set([l.targetDocument,l.overlayDocument]);for(let C of v)C.addEventListener("mousedown",m,true),C.addEventListener("keydown",d);return ()=>{for(let C of v)C.removeEventListener("mousedown",m,true),C.removeEventListener("keydown",d);}},[s,l]);let w=react.useRef(a);react.useEffect(()=>{if(a===w.current)return;w.current=a;let m=c.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[a]);let E={left:"auto",right:`${Qt}px`,top:`${Qt}px`,width:`${$l}px`,height:`${p}px`},k={width:`${332}px`,height:"auto",transformOrigin:u.origin};return jsxRuntime.jsx(react$1.motion.div,{ref:c,layout:true,initial:{opacity:0,x:u.x,y:u.y,scale:.985},animate:{opacity:1,x:0,y:0,scale:1,transition:{type:"spring",stiffness:560,damping:34,mass:.7,delay:n}},exit:{opacity:0,x:u.x,y:u.y,scale:.985,transition:{duration:.16,ease:Bl}},transition:{layout:{duration:.42,ease:Vl}},onLayoutAnimationComplete:x,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-[22px] 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:r?E:k,children:jsxRuntime.jsx(Ir.Provider,{value:{expanded:r,onToggleExpand:o},children:i})})}var J={Root:xi,Header:ti,Messages:ai,Reply:ui,DevFooter:Qo,ConfirmDiscard:qo,ConfirmDelete:Go};function wi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxRuntime.jsxs(J.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsxRuntime.jsx(J.Header,{}),jsxRuntime.jsx(J.Messages,{}),jsxRuntime.jsx(J.Reply,{}),jsxRuntime.jsx(J.ConfirmDiscard,{}),jsxRuntime.jsx(J.ConfirmDelete,{})]})}function yi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxRuntime.jsxs(J.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsxRuntime.jsx(J.Header,{}),jsxRuntime.jsx(J.Messages,{}),jsxRuntime.jsx(J.Reply,{}),jsxRuntime.jsx(J.DevFooter,{}),jsxRuntime.jsx(J.ConfirmDiscard,{}),jsxRuntime.jsx(J.ConfirmDelete,{})]})}var Jl="data-patch-internal";function Ai(e,t,r){let n={viewportX:t,viewportY:r},o=Ke(n,e.getOverlayViewport());return Yt(n,o)}function Ql(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function ec(e,t){let r=Ql(e,`[data-patch-pin-id="${t}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function tc(e,t){if(!t)return null;let r=mo({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:Jl}),n=e.targetPointToOverlay(r.position);return Ai(e,n.viewportX,n.viewportY)}function Ci(e,t,r){if(!t)return null;if(t.kind==="existing")return ec(e,t.annotationId)??tc(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return Ai(e,n.viewportX,n.viewportY)}function Ti(){let e=ge(),t=me(),r=se(),n=e.active,o=react.useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(x=>x.id===n.annotationId)??null,[n,t.annotations]),i=react.useCallback(()=>Ci(r,n,o),[n,o,r]),[s,a]=react.useState(false),l=e.active?e.active.kind==="existing"?e.active.annotationId:"composer":null;react.useEffect(()=>{a(false);},[l]);let c=t.viewerKind==="studio"?yi:wi,p=n&&(n.kind==="composer"||!!o),g=n?.kind==="composer"?.04:0,u=n?.kind==="composer"?Mo(n.target):null,f=react.useMemo(()=>Ci(r,n,o),[n,o,r]);return jsxRuntime.jsx(react$1.AnimatePresence,{children:p?jsxRuntime.jsx(Xo,{annotation:o,draftTargetLabel:u,children:jsxRuntime.jsx(c,{getAnchorRect:i,initialAnchorRect:f,expanded:s,entryDelay:g,onToggleExpand:()=>a(x=>!x)})},"active-popover"):null})}var nc="https://app.usepatch.dev";function Si(e){let t=typeof window<"u"&&jr(window),r=react.useMemo(()=>Bn({prop:e.projectToken,processEnv:Yn(),importMetaEnv:Wn()}),[e.projectToken]),n=e.apiBase??nc;return t?null:jsxRuntime.jsx(ko,{children:jsxRuntime.jsx(Zr,{children:jsxRuntime.jsx(an,{projectToken:r,apiBase:n,children:jsxRuntime.jsx(ln,{children:jsxRuntime.jsx(Vn,{children:jsxRuntime.jsxs(zn,{children:[jsxRuntime.jsx(xo,{}),jsxRuntime.jsx(Ti,{}),jsxRuntime.jsx(so,{})]})})})})})})}var oc=Si;
1888
- exports.Patch=Si;exports.default=oc;
1887
+ `;var Ao="patch-widget-root";function To({children:e}){let[t,r]=react.useState(null),n=react.useRef(null);return react.useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(Ao);o||(o=document.createElement(Ao),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let i=o.shadowRoot??o.attachShadow({mode:"open"});if(!i.querySelector("style[data-patch-css]")){let s=document.createElement("style");s.setAttribute("data-patch-css",""),s.textContent=Co,i.appendChild(s);}let a=i.querySelector("div[data-patch-mount]");return a||(a=document.createElement("div"),a.setAttribute("data-patch-mount",""),i.appendChild(a)),r(a),()=>{}},[]),t?reactDom.createPortal(e,t):null}var qs=/[\s#.:[\]()>+~,\\]/;function So(e){return !(!e||qs.test(e)||/^\d/.test(e))}function js(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Eo(e){if(!e.tagName)return "";if(e.id&&So(e.id))return `#${e.id}`;let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<4;){let o=r.tagName.toLowerCase();if(r.id&&So(r.id))return t.unshift(`#${r.id}`),t.join(" > ");t.unshift(`${o}:nth-of-type(${js(r)})`),r=r.parentElement,n++;}return t.join(" > ")}var Zs=80,Js=500;function Io(e){return e!==null&&typeof e=="object"}function Qs(e){return Io(e)?"return"in e||"type"in e||"elementType"in e||"_debugOwner"in e:false}function Zt(e){if(typeof e=="function")return e.displayName||e.name||null;if(!Io(e))return null;let t=e.displayName;if(typeof t=="string"&&t)return t;let r=Zt(e.render);if(r)return r;let n=Zt(e.type);return n||null}function Po(e){return e.replace(/\s+/g," ").trim()}function No(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function el(e){let t=Po(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:No(t,Zs)}function tl(e){let t=Zt(e.elementType)??Zt(e.type);return t?el(t):null}function Ro(e){return No(Po(e),Js)}function rl(e){let t=e.replace(/\\/g,"/");return t.includes("/.next/")||t.includes("/node_modules/next/")||t.includes("/node_modules/react/")||t.includes("/node_modules/react-dom/")||t.includes("/node_modules/react-router/")||t.includes("/node_modules/react-router-dom/")||t.includes("/node_modules/@remix-run/")||t.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(t)}function nl(e){let t=e.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=t.lastIndexOf(n);if(o>=0)return Ro(t.slice(o+1))}let r=t.split("/").filter(Boolean);return Ro(r.slice(-3).join("/"))}function ol(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||rl(t)?null:nl(t)}function il(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(Qs(n))return n}return null}function Cr(e){let t=il(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let s=tl(t),l=s?ur(s):false;s&&!l&&r[r.length-1]!==s&&r.push(s),l||(n??=ol(t)),t=t.return??t._debugOwner??null,o+=1;}let i=r.length>0?qn(r.reverse().map(s=>`<${s}>`).join(" ")):null,a={};return i&&(a.reactComponents=i),n&&(a.sourceFile=n),Object.keys(a).length>0?a:null}var Mo=500,_o=3;function al(e){return e.length<=Mo?e:e.slice(0,Mo)}function Ar(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function Jt(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Do(e){let t={cssSelector:Eo(e)},r=Nt(e);r&&(t.textSignature=r);let n=Pt(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function Lo(e){return e.kind==="element"?ot(e.element,e.selectedText):e.kind==="multi"?Dt(e.elements.length):Lt()}function Oo(e){let{target:t,click:r,comment:n,url:o}=e,i=t.element,a=t.rect,s=hn(i),l=vn(i),c=Oe(i),p=xn(i),g=Cr(i),u={comment:n,element:nt(i),elementPath:bn(i),targetLabel:ot(i,t.selectedText),timestamp:Date.now(),url:pe(o),kind:"feedback",coordinates:Ar(r),boundingBox:Jt(a),domHints:Do(i)};return t.selectedText&&(u.selectedText=al(t.selectedText)),l&&(u.nearbyText=l),c.length>0&&(u.cssClasses=c),p.length>0&&(u.nearbyElements=p),s&&(u.accessibility=s),g?.reactComponents&&(u.reactComponents=g.reactComponents),g?.sourceFile&&(u.sourceFile=g.sourceFile),u}function zo(e){let{target:t,click:r,comment:n,url:o}=e,i=t.elements.slice(0,_o).map(p=>nt(p)),a=t.elements.length>_o?"\u2026":"",s=`${t.elements.length} elements: ${i.join(", ")}${a}`,l=t.elements[0],c=l?Cr(l):null;return {comment:n,element:s,elementPath:s,targetLabel:Dt(t.elements.length),timestamp:Date.now(),url:pe(o),kind:"feedback",coordinates:Ar(r),boundingBox:Jt(t.union),isMultiSelect:true,elementBoundingBoxes:t.rects.map(Jt),...c?.reactComponents?{reactComponents:c.reactComponents}:{},...c?.sourceFile?{sourceFile:c.sourceFile}:{},...l?{domHints:Do(l)}:{}}}function Ho(e){let{target:t,click:r,comment:n,url:o}=e,i=Math.round(t.rect.width),a=Math.round(t.rect.height),s=Math.round(t.rect.x),l=Math.round(t.rect.y);return {comment:n,element:`region ${i}\xD7${a}`,elementPath:`region at (${s}, ${l}) ${i}\xD7${a}`,targetLabel:Lt(),timestamp:Date.now(),url:pe(o),kind:"feedback",coordinates:Ar(r),boundingBox:Jt(t.rect)}}async function ut(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function Fo(e,t){return t.resolve(e)}async function Vo(e,t){return t.deleteAnnotation(e)}async function $o(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function Bo(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function Wo(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function Yo(e,t){return t.postIdentity(e)}var Go=react.createContext(null),Xo=0;function Sr(e){return Xo+=1,`${e}-${Date.now().toString(36)}-${Xo}`}function Er(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function Ko({annotation:e,draftTargetLabel:t,children:r}){let n=ge(),o=fe(),i=se(),[a,s]=react.useState(false),[l,c]=react.useState(null),[p,g]=react.useState(null),u=react.useRef(false),f=e?.thread??[],x=e?.latestRun??null,w=e?.status==="resolved",T=e?Er(e):false,k=n.viewerKind,m=react.useCallback(()=>k==="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,k]),d=react.useMemo(()=>m(),[m]),v=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!d.authorId&&e.payload.authorRole===d.role&&e.payload.authorId===d.authorId,C=react.useCallback(E=>{let _=m();return {id:Sr("tmp-msg"),role:_.role,authorId:_.authorId,authorName:_.authorName,authorImage:_.authorImage,content:E,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[m]),S=react.useCallback(async E=>{if(u.current)return Promise.reject(new Error("busy"));u.current=true,s(true);try{return await E()}finally{u.current=false,s(false);}},[]),N=react.useCallback(async()=>{let E=o.draftText.trim();if(!E)return;if(e){if(w||Er(e))return;let et=C(E);o.setDraftText(""),n.updateAnnotation(e.id,Ae=>({...Ae,thread:[...Ae.thread,et]}));let _r=await ut({kind:"reply",annotationId:e.id,content:E},n.apiClient);if(_r){n.updateAnnotation(e.id,Ae=>({...Ae,thread:Ae.thread.map(De=>De.id===et.id?{...De,id:_r.id,deliveryStatus:"sent"}:De)})),n.refresh();return}n.updateAnnotation(e.id,Ae=>({...Ae,thread:Ae.thread.map(De=>De.id===et.id?{...De,deliveryStatus:"failed"}:De)}));return}let _=o.active;if(!_||_.kind!=="composer")return;let F=_.target,$={viewportX:_.anchor.viewportX,viewportY:_.anchor.viewportY,scrollY:_.anchor.documentY-_.anchor.viewportY},B=i.getPageUrl(),Pi=zr(n.activeViewport,i.getTargetViewport()),xt=F.kind==="element"?Oo({target:F,click:$,comment:E,url:B}):F.kind==="multi"?zo({target:F,click:$,comment:E,url:B}):Ho({target:F,click:$,comment:E,url:B});xt.viewport=n.activeViewport,xt.viewportSize=Pi;let wt=m(),yt=Sr("tmp-ann");n.applyAnnotationUpdate({id:yt,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:wt.authorName,authorImage:wt.authorImage,payload:{...xt,authorRole:wt.role,authorId:wt.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(yt);let tr=await ut({kind:"composer",payload:xt},n.apiClient);if(tr){n.replaceAnnotationId(yt,tr.id),o.openExisting(tr.id),n.refresh();return}n.updateAnnotation(yt,et=>({...et,deliveryStatus:"failed"}));},[e,m,w,C,n,o,i]),H=react.useCallback(async E=>{if(!e||Er(e))return;let _=e.thread.find($=>$.id===E);if(!_||_.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,$=>({...$,thread:$.thread.map(B=>B.id===E?{...B,deliveryStatus:"sending"}:B)}));let F=await ut({kind:"reply",annotationId:e.id,content:_.content},n.apiClient);if(F){n.updateAnnotation(e.id,$=>({...$,thread:$.thread.map(B=>B.id===E?{...B,id:F.id,deliveryStatus:"sent"}:B)})),n.refresh();return}n.updateAnnotation(e.id,$=>({...$,thread:$.thread.map(B=>B.id===E?{...B,deliveryStatus:"failed"}:B)}));},[e,n]),U=react.useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let E=e.id;n.updateAnnotation(E,F=>({...F,deliveryStatus:"sending"}));let _=await ut({kind:"composer",payload:e.payload},n.apiClient);if(_){n.replaceAnnotationId(E,_.id),o.openExisting(_.id),n.refresh();return}n.updateAnnotation(E,F=>({...F,deliveryStatus:"failed"}));},[e,n,o]),G=react.useCallback(E=>!d.authorId||E.deliveryStatus&&E.deliveryStatus!=="sent"?false:E.role===d.role&&E.authorId===d.authorId,[d]),ne=react.useCallback(()=>{v&&(c(null),g({kind:"annotation"}));},[v]),b=react.useCallback(E=>{G(E)&&(c(null),g({kind:"message",messageId:E.id}));},[G]),A=react.useCallback(()=>{c(null),g(null);},[]),M=react.useCallback(async E=>{if(!e)return false;let _=e.thread;return S(async()=>(c(null),n.updateAnnotation(e.id,$=>({...$,thread:$.thread.filter(B=>B.id!==E)})),await $o({annotationId:e.id,messageId:E},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,$=>({...$,thread:_})),c("Couldn't delete message. Try again."),false)))},[e,n,S]),I=react.useCallback(async()=>!e||!v?false:S(async()=>(c(null),await Vo(e.id,n.apiClient)?(n.updateAnnotation(e.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[e,v,n,o,S]),D=react.useCallback(async()=>{if(p)try{(p.kind==="annotation"?await I():await M(p.messageId))&&g(null);}catch{c("Couldn't delete. Try again.");}},[p,I,M]),j=react.useCallback(async()=>{e&&await S(async()=>{c(null);let E={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,F=>({...F,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await Fo(e.id,n.apiClient)){n.updateAnnotation(e.id,F=>({...F,...E})),c("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,S]),ee=react.useCallback(async()=>{e&&await S(async()=>{c(null);let E={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,F=>({...F,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await Bo({annotationId:e.id,viewerKind:k},n.apiClient)){n.updateAnnotation(e.id,F=>({...F,...E})),c("Couldn't reopen. Try again.");return}n.refresh();});},[e,k,n,S]),le=react.useCallback(async E=>{e&&await S(async()=>{c(null);let _=e.latestRun,F=e.optimisticAction;n.updateAnnotation(e.id,B=>({...B,latestRun:{id:Sr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let $=await Wo({annotationId:e.id,viewerKind:k,guidance:E},n.apiClient);if(!$?.ok){n.updateAnnotation(e.id,B=>({...B,latestRun:_,optimisticAction:F})),c($?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,k,n,S]),ce=react.useCallback(async E=>{let _=await Yo({...E,avatarSeed:n.clientAvatarSeed},n.apiClient);return _&&await n.setIdentity(_),_},[n]),h=k==="client"&&!n.identity&&f.length===0,R=!!e||f.length>0,L=n.agentRunReadiness?.ready??true,X=n.agentRunReadiness?.message??null,ue=react.useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),ae=e?Cn(e.payload):t||"annotation",Me=e?.payload.viewport??n.activeViewport,ft=n.studio?n.studio.name:n.identity?.name??null,ht=n.identity?.avatarSeed??n.clientAvatarSeed,bt=n.studio?.userId??ht,V=n.studio?.image??null,_e=n.studio?.userId??ht,vt=react.useMemo(()=>({state:{annotation:e,messages:f,runState:x,draftText:o.draftText,busy:a,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:p,showDevFooter:k==="studio",agentRunReady:L,agentRunSetupMessage:X,needsIdentity:h,isResolved:w,initialMessageLocked:T,threadVisible:R,canDeleteAnnotation:v},actions:{setDraftText:o.setDraftText,submit:N,retryMessage:H,retryInitialMessage:U,requestDeleteAnnotation:ne,requestDeleteMessage:b,canDeleteMessage:G,cancelDelete:A,confirmDelete:D,markResolved:j,reopen:ee,runPatch:le,setIdentity:ce,attemptClose:o.attemptClose,requestClose:ue,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:ae,viewport:Me,shakeNonce:o.shakeNonce,viewer:{kind:k,authorId:d.authorId,name:ft,avatarKey:bt,avatarSrc:V,generatedSeed:_e}}}),[e,f,x,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,a,l,p,N,H,U,ne,b,G,A,D,j,ee,le,ce,k,L,X,h,w,T,R,v,ue,ae,Me,d.authorId,ft,bt,V,_e]);return jsxRuntime.jsx(Go.Provider,{value:vt,children:r})}function Y(){let e=react.use(Go);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var pl="inline-flex shrink-0 items-center justify-center gap-1.5 h-8 px-3.5 rounded-full whitespace-nowrap text-[13px] font-semibold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",ml={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 Rr(e="brand",t){return P(pl,ml[e],t)}function oe({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsxRuntime.jsx("button",{ref:n,type:r,className:Rr(e,t),...o})}function jo(){let{state:e,actions:t}=Y(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",i=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",a=n?"Delete annotation":"Delete message";return jsxRuntime.jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:i}),e.actionError?jsxRuntime.jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(oe,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsxRuntime.jsx(oe,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":a})]})]})})}function Jo(){let{state:e,actions:t}=Y();return e.confirmDiscardOpen?jsxRuntime.jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(oe,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsxRuntime.jsx(oe,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var fl="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",hl={sm:"size-7",md:"size-8"},bl={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Re({size:e="sm",tone:t="default",className:r,type:n="button",ref:o,...i}){return jsxRuntime.jsx("button",{ref:o,type:n,className:P(fl,hl[e],bl[t],r),...i})}function Qo(e){let t=new Date(e).getTime(),r=Date.now()-t,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 ei(e){let t=e.composedPath();for(let r of t)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function ti(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}function ri(){let{state:e}=Y();return !e.showDevFooter||!e.annotation?null:jsxRuntime.jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsx(xl,{}),jsxRuntime.jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsxRuntime.jsx(yl,{})})]}),e.actionError?jsxRuntime.jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function xl(){let{state:e,actions:t}=Y(),[r,n]=react.useState(false),[o,i]=react.useState(""),[a,s]=react.useState(false),l=e.runState,c=l?.status;if(e.annotation?.status==="resolved")return jsxRuntime.jsx("div",{className:"min-w-0 flex-1"});let g=c==="queued"||c==="running",u=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,f=c==="succeeded"&&l?.prClosedUnmerged,x=l?"Run Patch again":"Run Patch",w=c==="failed"?"destructiveTint":f?"warnTint":"brand",T=!e.agentRunReady,k=async()=>{try{s(!0),await t.runPatch(o.trim()||void 0),i(""),n(!1);}finally{s(false);}};if(g)return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs(oe,{variant:"brandTint",disabled:true,children:[jsxRuntime.jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let d=ti(l.prUrl);return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Rr("brand","no-underline"),children:[jsxRuntime.jsx(O,{name:"pr",size:12}),d==="PR"?"View PR":`View PR ${d}`]})})}let m=jsxRuntime.jsxs(oe,{variant:w,disabled:e.busy||T,className:T?"opacity-60":void 0,onClick:()=>n(true),children:[jsxRuntime.jsx(O,{name:c==="failed"?"play":"robot",size:12})," ",x]});return jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[T&&e.agentRunSetupMessage?jsxRuntime.jsx(ke,{text:e.agentRunSetupMessage,tone:"warning",children:m}):m,r?jsxRuntime.jsx(wl,{title:x,guidance:o,submitting:a||e.busy,onGuidanceChange:i,onCancel:()=>n(false),onSubmit:k}):null]})}function wl({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:i}){return jsxRuntime.jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsxRuntime.jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxRuntime.jsxs("form",{role:"dialog","aria-label":e,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-[20px] bg-popover p-4 shadow-dialog",onSubmit:a=>{a.preventDefault(),i();},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-xl bg-brand text-white",children:jsxRuntime.jsx(O,{name:"robot",size:13})}),jsxRuntime.jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsxRuntime.jsx(Re,{size:"sm",title:"Close",onClick:o,children:jsxRuntime.jsx(O,{name:"x",size:12})})]}),jsxRuntime.jsxs("label",{className:"flex flex-col gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsxRuntime.jsx("textarea",{value:t,onChange:a=>n(a.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-[16px] border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(oe,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsxRuntime.jsx(oe,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function yl(){let{state:e,actions:t}=Y();return e.annotation?e.annotation.status==="resolved"?jsxRuntime.jsxs(oe,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsxRuntime.jsx(O,{name:"refresh",size:12}),"Reopen"]}):jsxRuntime.jsxs(oe,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsxRuntime.jsx(O,{name:"check",size:12}),"Resolve"]}):null}var Pr=react.createContext({expanded:false,onToggleExpand:()=>{}});function ni(){return react.use(Pr)}function oi(){let{state:e,meta:t}=Y(),{expanded:r,onToggleExpand:n}=ni(),o=e.annotation,i=ve[t.viewport],a=o?.payload.selectedText;return jsxRuntime.jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{title:t.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:t.targetLabel}),jsxRuntime.jsx(ke,{text:Ve(t.viewport),placement:"bottom",children:jsxRuntime.jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":Ve(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsxRuntime.jsx(O,{name:i.glyph,size:15,stroke:1.8})})})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsxRuntime.jsx(O,{name:"check",size:10})," Resolved"]}):null,jsxRuntime.jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[jsxRuntime.jsx(Sl,{}),jsxRuntime.jsx(Re,{onClick:n,title:r?"Collapse":"Expand",children:jsxRuntime.jsx(O,{name:r?"minimize":"maximize",size:13})}),jsxRuntime.jsx(Tl,{})]})]})]}),a?jsxRuntime.jsx("div",{className:"rounded-xl bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsxRuntime.jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:a.length>200?`${a.slice(0,199).trim()}\u2026`:a})}):null]})}function Tl(){let{actions:e}=Y();return jsxRuntime.jsx(Re,{onClick:e.requestClose,title:"Close",children:jsxRuntime.jsx(O,{name:"x",size:14})})}function Sl(){let{state:e,actions:t}=Y(),[r,n]=react.useState(false);return e.canDeleteAnnotation?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Re,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsxRuntime.jsx(O,{name:"more",size:14})}),r?jsxRuntime.jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxRuntime.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),t.requestDeleteAnnotation();},children:[jsxRuntime.jsx(O,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function ci(){let{state:e,actions:t,meta:r}=Y(),n=react.useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,i=r.viewer.kind==="client"?r.viewer.authorId:null;return react.useEffect(()=>{let s=n.current;s&&(s.scrollTop=s.scrollHeight);}),e.threadVisible?jsxRuntime.jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:P("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",e.showDevFooter&&e.isResolved&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[e.annotation?jsxRuntime.jsx(si,{name:e.annotation.authorName??"Someone",createdAt:e.annotation.createdAt,content:e.annotation.payload.comment,authorKey:e.annotation.payload.authorId??e.annotation.authorName??e.annotation.id,avatarSrc:e.annotation.authorImage,generatedSeed:e.annotation.payload.authorRole==="client"&&e.annotation.payload.authorId===i?o:e.annotation.authorAvatarSeed??e.annotation.payload.authorId??null,deliveryStatus:e.annotation.deliveryStatus,onRetry:e.annotation.deliveryStatus==="failed"?t.retryInitialMessage:void 0}):null,e.messages.map(s=>jsxRuntime.jsx(si,{name:s.authorName??s.role,createdAt:s.createdAt,content:s.content,authorKey:s.authorId??s.authorName??s.role,avatarSrc:s.authorImage,generatedSeed:s.role==="client"&&s.authorId===i?o:s.authorAvatarSeed??s.authorId,deliveryStatus:s.deliveryStatus,canDelete:t.canDeleteMessage(s),onDelete:()=>t.requestDeleteMessage(s),onRetry:s.deliveryStatus==="failed"?()=>{t.retryMessage(s.id);}:void 0},s.id))]}):null}function si(e){let t=Xe(e.name),r=Ge(e.authorKey),n=e.deliveryStatus==="failed";return jsxRuntime.jsxs("div",{className:"group/message flex gap-2.5",children:[jsxRuntime.jsx(Ee,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsxRuntime.jsx("span",{className:"text-[11px] text-muted-foreground",children:Qo(e.createdAt)})]}),e.canDelete&&e.onDelete?jsxRuntime.jsx(Pl,{onDelete:e.onDelete}):null,jsxRuntime.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsxRuntime.jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?jsxRuntime.jsx("button",{type:"button",onClick:e.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 Rl=44,Il=8;function Pl({onDelete:e}){let[t,r]=react.useState(false),[n,o]=react.useState("down"),i=react.useRef(null),a=react.useCallback(()=>{let l=i.current,c=l?.closest("[data-patch-thread-scroller]");if(!l||!c){o("down");return}let p=l.getBoundingClientRect(),g=c.getBoundingClientRect(),u=g.bottom-p.bottom,f=p.top-g.top;o(u<Rl+Il&&f>u?"up":"down");},[]),s=react.useCallback(()=>{r(l=>{let c=!l;return c&&a(),c});},[a]);return jsxRuntime.jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsxRuntime.jsx(Re,{ref:i,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:s,children:jsxRuntime.jsx(O,{name:"more",size:14})}),t?jsxRuntime.jsx("div",{role:"menu",className:P("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxRuntime.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),e();},children:[jsxRuntime.jsx(O,{name:"trash",size:13}),"Delete"]})}):null]})}var Nl={default:"w-full min-h-[60px] resize-y rounded-2xl 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 di({variant:e="default",className:t,ref:r,...n}){return jsxRuntime.jsx("textarea",{ref:r,className:P(Nl[e],t),...n})}var Ll=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ui="w-full rounded-[10px] border border-border bg-popover px-2 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function pi(){let{actions:e}=Y(),[t,r]=react.useState(""),[n,o]=react.useState(""),[i,a]=react.useState(null),[s,l]=react.useState(false),c=react.useRef(null);return react.useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxRuntime.jsxs("form",{onSubmit:async g=>{g.preventDefault();let u=t.trim(),f=n.trim();if(!u){a("Name is required.");return}if(!Ll.test(f)){a("Enter a valid email.");return}a(null),l(true);let x=await e.setIdentity({name:u,email:f});l(false),x||a("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsxRuntime.jsx("input",{ref:c,type:"text",placeholder:"Name",value:t,onChange:g=>r(g.target.value),className:ui}),jsxRuntime.jsx("input",{type:"email",placeholder:"Email",value:n,onChange:g=>o(g.target.value),className:ui}),i?jsxRuntime.jsx("div",{className:"text-xs text-destructive",children:i}):null,jsxRuntime.jsx("button",{type:"submit",disabled:s,className:P("self-end rounded-[10px] bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",s&&"cursor-not-allowed opacity-60"),children:s?"Saving\u2026":"Continue"})]})}function gi(){let{state:e,actions:t,meta:r}=Y(),n=react.useRef(null),[o,i]=react.useState(false);if(react.useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),react.useEffect(()=>{let u=n.current;if(!u)return;u.style.height="0px";let f=Math.min(u.scrollHeight,140);u.style.height=`${f}px`,i(f>28);},[e.draftText]),e.isResolved||e.initialMessageLocked)return null;if(e.needsIdentity)return jsxRuntime.jsx("div",{className:P("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsxRuntime.jsx(pi,{})});let a=e.draftText.trim().length>0,s=r.viewer.name,l=Xe(s),c=r.viewer.kind==="studio"?"var(--color-foreground)":Ge(r.viewer.avatarKey),p=u=>{u.preventDefault(),t.submit();},g=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),t.submit());};return jsxRuntime.jsx("form",{onSubmit:p,className:P("bg-white p-3",e.threadVisible&&"border-t border-black/6",e.showDevFooter&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxRuntime.jsxs("div",{className:P("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-[18px]":"rounded-full"),children:[jsxRuntime.jsx(Ee,{initials:l,tint:c,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:s??"",className:"self-start"}),jsxRuntime.jsx(di,{ref:n,variant:"bare",value:e.draftText,onChange:u=>t.setDraftText(u.target.value),onKeyDown:g,rows:1,placeholder:e.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsxRuntime.jsx(Fl,{enabled:a})]})})}function Fl({enabled:e}){return jsxRuntime.jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:P("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsxRuntime.jsx(O,{name:"arrow-up",size:13})})}var Yl=440,bi=88,er=16,Ul=[.22,.61,.36,1],Xl=[.4,0,.2,1],Gl={x:-8,y:-8,origin:"top left"},vi=200;function xi(e,t,r){return Math.max(t,Math.min(r,e))}function yi(e,t,r){let n={x:e.x+e.width/2,y:e.y+e.height/2},o={x:t.x+t.width/2,y:t.y+r/2};return {x:xi((n.x-o.x)*.08,-12,12),y:xi((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Kl(e,t){if(!t)return Gl;let r=it({anchor:t,popover:{width:332,height:vi},viewport:e.getOverlayViewport()});return yi(t,r,vi)}function ql(e,t){return e.x===t.x&&e.y===t.y&&e.origin===t.origin}function ki({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n=0,onToggleExpand:o,children:i}){let{actions:{attemptClose:a},meta:{shakeNonce:s}}=Y(),l=se(),c=react.useRef(null),[p,g]=react.useState(600),[u,f]=react.useState(()=>Kl(l,t??e())),x=react.useCallback(()=>{let m=c.current;if(!m||r)return;let d=e();if(!d)return;let v=m.offsetHeight||200,C=it({anchor:d,popover:{width:332,height:v},viewport:l.getOverlayViewport()});m.style.left=`${C.x}px`,m.style.top=`${C.y}px`,m.style.right="auto";let S=yi(d,C,v);f(N=>ql(N,S)?N:S);},[e,r,l]);react.useLayoutEffect(()=>{r||x(),g(l.getOverlayViewport().height-er-bi);}),react.useEffect(()=>{let m=null,d=()=>{m===null&&(m=l.overlayWindow.requestAnimationFrame(()=>{m=null,r||x(),g(l.getOverlayViewport().height-er-bi);}));},v=new Set([l.targetWindow,l.overlayWindow]);for(let S of v)S.addEventListener("resize",d),S.addEventListener("scroll",d,{passive:true});let C=Tt(l.overlayWindow,d);return C.observe(l.overlayDocument.body),l.targetDocument.body!==l.overlayDocument.body&&C.observe(l.targetDocument.body),c.current&&C.observe(c.current),()=>{m!==null&&l.overlayWindow.cancelAnimationFrame(m);for(let S of v)S.removeEventListener("resize",d),S.removeEventListener("scroll",d);C.disconnect();}},[x,r,l]),react.useEffect(()=>{let m=C=>{ei(C)||a();},d=C=>{C.key==="Escape"&&a();},v=new Set([l.targetDocument,l.overlayDocument]);for(let C of v)C.addEventListener("mousedown",m,true),C.addEventListener("keydown",d);return ()=>{for(let C of v)C.removeEventListener("mousedown",m,true),C.removeEventListener("keydown",d);}},[a,l]);let w=react.useRef(s);react.useEffect(()=>{if(s===w.current)return;w.current=s;let m=c.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[s]);let T={left:"auto",right:`${er}px`,top:`${er}px`,width:`${Yl}px`,height:`${p}px`},k={width:`${332}px`,height:"auto",transformOrigin:u.origin};return jsxRuntime.jsx(react$1.motion.div,{ref:c,layout:true,initial:{opacity:0,x:u.x,y:u.y,scale:.985},animate:{opacity:1,x:0,y:0,scale:1,transition:{type:"spring",stiffness:560,damping:34,mass:.7,delay:n}},exit:{opacity:0,x:u.x,y:u.y,scale:.985,transition:{duration:.16,ease:Xl}},transition:{layout:{duration:.42,ease:Ul}},onLayoutAnimationComplete:x,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-[22px] 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:r?T:k,children:jsxRuntime.jsx(Pr.Provider,{value:{expanded:r,onToggleExpand:o},children:i})})}var Q={Root:ki,Header:oi,Messages:ci,Reply:gi,DevFooter:ri,ConfirmDiscard:Jo,ConfirmDelete:jo};function Ci({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxRuntime.jsxs(Q.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsxRuntime.jsx(Q.Header,{}),jsxRuntime.jsx(Q.Messages,{}),jsxRuntime.jsx(Q.Reply,{}),jsxRuntime.jsx(Q.ConfirmDiscard,{}),jsxRuntime.jsx(Q.ConfirmDelete,{})]})}function Ai({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxRuntime.jsxs(Q.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsxRuntime.jsx(Q.Header,{}),jsxRuntime.jsx(Q.Messages,{}),jsxRuntime.jsx(Q.Reply,{}),jsxRuntime.jsx(Q.DevFooter,{}),jsxRuntime.jsx(Q.ConfirmDiscard,{}),jsxRuntime.jsx(Q.ConfirmDelete,{})]})}var rc="data-patch-internal";function Ei(e,t,r){let n={viewportX:t,viewportY:r},o=Ke(n,e.getOverlayViewport());return Ut(n,o)}function nc(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function oc(e,t){let r=nc(e,`[data-patch-pin-id="${t}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function ic(e,t){if(!t)return null;let r=ho({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:rc}),n=e.targetPointToOverlay(r.position);return Ei(e,n.viewportX,n.viewportY)}function Si(e,t,r){if(!t)return null;if(t.kind==="existing")return oc(e,t.annotationId)??ic(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return Ei(e,n.viewportX,n.viewportY)}function Ri(){let e=fe(),t=ge(),r=se(),n=e.active,o=react.useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(x=>x.id===n.annotationId)??null,[n,t.annotations]),i=react.useCallback(()=>Si(r,n,o),[n,o,r]),[a,s]=react.useState(false),l=e.active?e.active.kind==="existing"?e.active.annotationId:"composer":null;react.useEffect(()=>{s(false);},[l]);let c=t.viewerKind==="studio"?Ai:Ci,p=n&&(n.kind==="composer"||!!o),g=n?.kind==="composer"?.04:0,u=n?.kind==="composer"?Lo(n.target):null,f=react.useMemo(()=>Si(r,n,o),[n,o,r]);return jsxRuntime.jsx(react$1.AnimatePresence,{children:p?jsxRuntime.jsx(Ko,{annotation:o,draftTargetLabel:u,children:jsxRuntime.jsx(c,{getAnchorRect:i,initialAnchorRect:f,expanded:a,entryDelay:g,onToggleExpand:()=>s(x=>!x)})},"active-popover"):null})}var sc="https://app.usepatch.dev";function Ii(e){let t=typeof window<"u"&&Qr(window),r=react.useMemo(()=>Un({prop:e.projectToken,processEnv:Gn(),importMetaEnv:Xn()}),[e.projectToken]),n=e.apiBase??sc;return t?null:jsxRuntime.jsx(To,{children:jsxRuntime.jsx(en,{children:jsxRuntime.jsx(cn,{projectToken:r,apiBase:n,children:jsxRuntime.jsx(un,{children:jsxRuntime.jsx(Yn,{children:jsxRuntime.jsxs(Vn,{children:[jsxRuntime.jsx(ko,{}),jsxRuntime.jsx(Ri,{}),jsxRuntime.jsx(uo,{})]})})})})})})}var lc=Ii;
1888
+ exports.Patch=Ii;exports.default=lc;