@usepatch/widget 0.2.10 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +150 -82
  2. package/dist/index.js +150 -82
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createElement,useId,useLayoutEffect}from'react';import {AnimatePresence,useReducedMotion,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';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 or="patch:locationchange",Lr="__patchHistoryPatched";function Oi(e){let t=e.history;if(t[Lr])return;t[Lr]=true;let r=()=>e.dispatchEvent(new Event(or)),{pushState:n,replaceState:o}=t;try{t.pushState=function(...a){let s=n.apply(this,a);return r(),s},t.replaceState=function(...a){let s=o.apply(this,a);return r(),s};}catch{}}function zr(e,t){Oi(e);let r=()=>t();return e.addEventListener("popstate",r),e.addEventListener("hashchange",r),e.addEventListener(or,r),()=>{e.removeEventListener("popstate",r),e.removeEventListener("hashchange",r),e.removeEventListener(or,r);}}var Ce={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"}},Hr=["desktop","tablet","mobile"];function We(e){let t=Ce[e];return t.width===null||t.height===null?t.label:`${t.label} (${t.width}px \xD7 ${t.height}px)`}function Fr(e,t){let r=Ce[e];return {width:r.width??t.width,height:r.height??t.height}}var zi=32,Hi=32,Fi=3e3,Br="cubic-bezier(0.16, 1, 0.3, 1)",St=[.22,.61,.36,1],Wr=.3,Yr=.5,Vi=.34,$i=.5,Bi=.24,Wi=.22,Xr=.12,Yi=.42,Ur=.2,Xi=200,Ui=260,Gi=70,Ki=180,qi=260,Zi=8,ji=4,Ji="#d9d9dd",Qi=30,ea=["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 Et(e,t,r){let n=Math.max(320,e.innerWidth-zi*2),o=Math.max(320,e.innerHeight-Hi*2);return Math.min(1,n/t,o/r)}function ta(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function Gr({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:a}){let s=useReducedMotion(),i=t.width??r.innerWidth,l=t.height??r.innerHeight,c=t.viewport,d=`${c}:${i}:${l}`,g=!!r.happyDOM?.settings?.disableIframePageLoading,[p,f]=useState(()=>({viewport:c,width:i,height:l,scale:Et(r,i,l)})),[x,w]=useState("stable"),[P,b]=useState(false),[m,u]=useState(false),v=useRef(false),k=useRef(null),S=`${p.viewport}:${p.width}:${p.height}`!==d,Z=P&&!m&&!(S||x==="cover"||x==="resize"),j=P&&!m&&x==="stable"&&!S,ie=useCallback(A=>{k.current=A,n(A);},[n]),ae=useCallback(()=>{let A=k.current;if(!A||!ta(A)){v.current=false,b(false),u(true);return}v.current=true,b(true),u(false);},[]),Q=useCallback(()=>{f(A=>{let le=Et(r,A.width,A.height);return A.scale===le?A:{...A,scale:le}});},[r]);useEffect(()=>(Q(),r.addEventListener("resize",Q),()=>r.removeEventListener("resize",Q)),[r,Q]),useEffect(()=>{v.current=false,b(false),u(false);let A=r.setTimeout(()=>{v.current||u(true);},Fi);return ()=>r.clearTimeout(A)},[e,r]),useEffect(()=>{if(s){S&&f({viewport:c,width:i,height:l,scale:Et(r,i,l)}),x!=="stable"&&w("stable");return}switch(x){case "stable":{S&&w("cover");return}case "cover":{let A=r.setTimeout(()=>w("resize"),Gi);return ()=>r.clearTimeout(A)}case "resize":{S&&f({viewport:c,width:i,height:l,scale:Et(r,i,l)});let A=r.setTimeout(()=>w("reveal"),Ki);return ()=>r.clearTimeout(A)}case "reveal":{let A=r.setTimeout(()=>w("stable"),qi);return ()=>r.clearTimeout(A)}}},[x,S,s,r,c,i,l]),useEffect(()=>{o(j);},[j,o]),useEffect(()=>{a(m);},[m,a]);let se=s?{duration:0}:{duration:Bi,ease:St},Y=s?{duration:0}:{duration:Wi,ease:St,delay:Ur*.5},h=s?{duration:0}:{duration:Ur,ease:St},R=s?{duration:0}:{opacity:{duration:Yi,ease:St,delay:Xr},scale:{type:"spring",bounce:Vi,duration:$i,delay:Xr},width:{type:"spring",bounce:Wr,duration:Yr},height:{type:"spring",bounce:Wr,duration:Yr}},_=(Z?Ui:Xi)/1e3,C=s?void 0:`opacity ${_}s ${Br}, filter ${_}s ${Br}`,D=p.width*p.scale,L=p.height*p.scale;return jsx(motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:se},exit:{opacity:0,transition:Y},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxs(motion.div,{initial:s?{opacity:0,width:D,height:L}:{opacity:0,scale:.8,width:D,height:L},animate:{opacity:1,scale:1,width:D,height:L},exit:s?{opacity:0}:{opacity:0,scale:.92,transition:h},transition:R,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${ji}px solid ${Ji}`,borderRadius:Qi,boxShadow:ea,willChange:"width, height"},children:[jsx("div",{"aria-hidden":!Z,className:"absolute top-0 left-0 origin-top-left",style:{width:p.width,height:p.height,transform:`scale(${p.scale})`,opacity:Z?1:0,filter:s||Z?"none":`blur(${Zi}px)`,transition:C,pointerEvents:Z?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:ie,"data-patch-preview-frame":"","data-patch-preview-src":e,title:`${t.label} preview`,tabIndex:Z?0:-1,src:g?void 0:e,srcDoc:g?"<!doctype html><html><body></body></html>":void 0,onLoad:ae,className:"block bg-white",style:{width:p.width,height:p.height,border:0}})}),jsx(ra,{visible:m})]})})}function ra({visible:e}){return e?jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children: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 jr=createContext(null),Jr=createContext(null),Qr="__patch_preview";function en(){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 aa(e){let t=new URL(e.location.href);return t.searchParams.set(Qr,"1"),t.toString()}function tn(e=window){try{return new URL(e.location.href).searchParams.get(Qr)==="1"}catch{return false}}function sa(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function a(){return t.getBoundingClientRect()}function s(){let l=a();return r.width>0?l.width/r.width:1}function i(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=a(),d=s();return {viewportX:c.left+l.viewportX*d,viewportY:c.top+l.viewportY*d}},targetRectToOverlay:l=>{let c=a(),d=s();return {x:c.left+l.x*d,y:c.top+l.y*d,width:l.width*d,height:l.height*d}},eventTargetElement:i}}function rn(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function nn({children:e}){let t=useMemo(()=>en(),[]),[r,n]=useState("desktop"),[o,a]=useState(null),[s,i]=useState(false),[l,c]=useState(false),[d,g]=useState(false),p=r!=="desktop",f=p||d,x=Ce[r],w=x.width&&x.height?{width:x.width,height:x.height}:null;useEffect(()=>{i(false),c(false);},[r]);let P=useRef(p);useEffect(()=>{P.current&&!p?g(true):!P.current&&p&&g(false),P.current=p;},[p]);let b=useMemo(()=>t?!p||!s||l||!o||!w?t:sa(t,o,w)??t:null,[l,o,s,p,w,t]),m=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:f,previewReady:f?p&&s&&!l:true,previewBlocked:p&&l}),[r,l,s,p,f]),u=useMemo(()=>t?aa(t.targetWindow):"",[t]);return !b||!t?null:jsx(Jr.Provider,{value:m,children:jsxs(jr.Provider,{value:b,children:[e,jsx(AnimatePresence,{onExitComplete:()=>g(false),children:p&&w?jsx(Gr,{src:u,viewport:x,overlayWindow:t.overlayWindow,onFrameElement:a,onReadyChange:i,onBlockedChange:c}):null})]})})}function pe(){let e=use(jr),t=useMemo(()=>en(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function Ge(){let e=use(Jr),[t,r]=useState("desktop"),n=useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var ca="X-Patch-Client-Id";function ge(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[ca]:e.clientUserId}:{}}}async function ve(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 da(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 on(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await ve(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:ge(e,false)}))?.annotations??[]},async fetchMe(){return ve(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:ge(e,false)})},async postIdentity(t){let r=await ve(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:ge(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 ve(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:ge(e,true),body:JSON.stringify(t)})},async reply(t,r){return ve(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:ge(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return ve(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:ge(e,false)})},async deleteMessage(t,r){return ve(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:ge(e,false)})},async kickoff(t,r){return da(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:ge(e,true),body:JSON.stringify(r)})},async resolve(t){return ve(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:ge(e,true)})},async reopen(t){return ve(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:ge(e,true)})},async reportAnchorStatuses(t){t.length!==0&&await ve(`${e.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:ge(e,true),body:JSON.stringify({reports:t})});}}}var lr="patch.clientIdentity",an="patch.clientAvatarSeed";function cr(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(lr);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function sn(e){return cr()[e]??null}function dr(e,t){if(!(typeof window>"u"))try{let r=cr();r[e]=t,window.localStorage.setItem(lr,JSON.stringify(r));}catch{}}function ln(e){if(!(typeof window>"u"))try{let t=cr();delete t[e],window.localStorage.setItem(lr,JSON.stringify(t));}catch{}}function ua(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(an);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function sr(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function cn(e){if(typeof window>"u")return sr();try{let t=ua(),r=t[e];if(r)return r;let n=sr();return t[e]=n,window.localStorage.setItem(an,JSON.stringify(t)),n}catch{return sr()}}var ga=2e4,un=createContext(null);function fa(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 i=r.get(s.id);if(!i)return s;let l=new Set(s.thread.map(g=>g.id)),c=i.thread.filter(g=>g.deliveryStatus&&!l.has(g.id)),d=c.length>0?{...s,thread:[...s.thread,...c]}:s;if(i.optimisticAction==="resolve-pending"&&s.status!=="resolved"&&(d={...d,status:i.status,resolvedBy:i.resolvedBy,resolvedAt:i.resolvedAt,optimisticAction:i.optimisticAction}),i.optimisticAction==="reopen-pending"&&s.status==="resolved"&&(d={...d,status:i.status,resolvedBy:i.resolvedBy,resolvedAt:i.resolvedAt,optimisticAction:i.optimisticAction}),i.optimisticAction==="run-pending"&&i.latestRun?.id.startsWith("tmp-run")){let g=s.latestRun?Date.parse(s.latestRun.createdAt):Number.NaN,p=Date.parse(i.latestRun.createdAt);s.latestRun!=null&&(Number.isNaN(p)||Number.isNaN(g)||g>=p)||(d={...d,latestRun:i.latestRun,optimisticAction:i.optimisticAction});}return d}),a=e.filter(s=>(s.deliveryStatus||s.optimisticAction)&&!n.has(s.id));return [...o,...a]}function pn({projectToken:e,apiBase:t,children:r}){let n=pe(),{activeViewport:o,setActiveViewport:a}=Ge(),[s,i]=useState(()=>typeof window>"u"?null:sn(e)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":cn(e)),[c,d]=useState(null),[g,p]=useState("client"),[f,x]=useState(null),[w,P]=useState([]),[b,m]=useState(null),[u,v]=useState([]),[k,T]=useState(false),[S,H]=useState(null),Z=useRef(S);Z.current=S;let j=useRef(o);j.current=o;let ie=b===o,ae=useMemo(()=>on({apiBase:t,token:e,clientUserId:s?.clientUserId}),[t,e,s?.clientUserId]),Q=useRef(ae);Q.current=ae;let se=useRef(0),Y=useCallback(async()=>{let I=o,M=++se.current,z=await Q.current.listAnnotations(I==="desktop"?void 0:I);if(M!==se.current||I!==j.current)return;let K=n.getPageUrl(),he=z.filter(ue=>be(ue.payload.url)===K);P(ue=>fa(ue,he)),m(I);},[o,n]),h=useRef(Y);h.current=Y,useEffect(()=>{let I=false;return (async()=>{let M=await Q.current.fetchMe();if(!I){if(M?.active===false){H(false),T(true);return}if(H(true),M?.studio)d(M.studio),p("studio"),x(M.agentRunReadiness??{ready:true,message:null});else if(d(null),p("client"),x(null),M?.client){let z={clientUserId:M.client.id,name:M.client.name,email:M.client.email,avatarSeed:M.client.avatarSeed};i(z),dr(e,z);}await h.current(),I||T(true);}})(),()=>{I=true;}},[e]),useEffect(()=>{!k||!S||Y();},[k,S,Y]),useEffect(()=>{if(!S)return;let{overlayDocument:I,overlayWindow:M}=n,z=M.setInterval(()=>{I.visibilityState==="visible"&&Y();},ga),K=()=>{I.visibilityState==="visible"&&Y();};return I.addEventListener("visibilitychange",K),()=>{M.clearInterval(z),I.removeEventListener("visibilitychange",K);}},[S,Y,n]),useEffect(()=>{if(S)return zr(n.targetWindow,()=>{let I=n.getPageUrl();P(M=>M.filter(z=>be(z.payload.url)===I)),h.current();})},[S,n]);let R=useCallback(async I=>(dr(e,I),i(I),I),[e]),_=useCallback(()=>{i(null),ln(e);},[e]),C=useCallback(I=>{v(M=>[...M.filter(z=>z.tempId!==I.tempId),I]);},[]),D=useCallback(I=>{v(M=>M.filter(z=>z.tempId!==I));},[]),L=useCallback(I=>{P(M=>{let z=M.findIndex(he=>he.id===I.id);if(z===-1)return [...M,I];let K=M.slice();return K[z]=I,K});},[]),A=useCallback((I,M)=>{P(z=>{let K=false,he=z.flatMap(ue=>{if(ue.id!==I)return [ue];K=true;let De=M(ue);return De?[De]:[]});return K?he:z});},[]),le=useCallback((I,M)=>{P(z=>z.map(K=>K.id===I?{...K,id:M,deliveryStatus:"sent"}:K));},[]),Be=useMemo(()=>({apiClient:ae,active:S,ready:k,viewerKind:g,agentRunReadiness:f,activeViewport:o,clientAvatarSeed:l,identity:s,studio:c,annotations:w,annotationsReady:ie,ephemerals:u,refresh:Y,setActiveViewport:a,setIdentity:R,signOut:_,addEphemeral:C,removeEphemeral:D,applyAnnotationUpdate:L,updateAnnotation:A,replaceAnnotationId:le}),[ae,S,k,g,f,o,l,s,c,w,ie,u,Y,a,R,_,C,D,L,A,le]);return jsx(un.Provider,{value:Be,children:r})}function me(){let e=use(un);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var mn=createContext(null);function gn({children:e}){let[t,r]=useState(null),[n,o]=useState(""),[a,s]=useState(0),[i,l]=useState(false),c=useCallback(()=>{r(null),o(""),l(false);},[]),d=useCallback(w=>{r({kind:"existing",annotationId:w}),o(""),l(false);},[]),g=useCallback(w=>{r({kind:"composer",...w}),o(""),l(false);},[]),p=useCallback(()=>{if(n.trim().length>0){s(w=>w+1);return}c();},[n,c]),f=useCallback(()=>{c();},[c]),x=useMemo(()=>({active:t,draftText:n,shakeNonce:a,confirmDiscardOpen:i,openExisting:d,openComposer:g,setDraftText:o,attemptClose:p,forceClose:f,setConfirmDiscardOpen:l}),[t,n,a,i,d,g,p,f]);return jsx(mn.Provider,{value:x,children:e})}function we(){let e=use(mn);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var bn=new Set(["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),ya=new Set(["a","button","input","select","textarea"]),vn={a:"link",button:"button",input:"input",select:"select",textarea:"textarea",img:"img",svg:"icon",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"paragraph",li:"list item",td:"cell",th:"header cell",label:"label",blockquote:"quote",figcaption:"caption",code:"code",pre:"code block"},ze=40,ka=1500,fn=200,Ca=5,Aa=10;function ur(e){return bn.has(e.tagName.toLowerCase())}function Ae(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Ke(e){return `"${e}"`}function Ta(e){let t="";for(let r of Array.from(e.childNodes))r.nodeType===3&&(t+=r.textContent??"");return t.replace(/\s+/g," ").trim()}function Pt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Sa(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 He(e){let t=Array.from(e.classList),r=t.filter(Sa).slice(0,Aa);return r.length>0?r:t.length>0?["container"]:[]}function xn(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,a=e.tagName.toLowerCase(),s=ya.has(a)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!s)return;let i={focusable:s};return t!==void 0&&(i.role=t),r!==void 0&&(i.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(i.tabIndex=o),i}function Ea(e){let t=e.tagName.toLowerCase(),r=vn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Ke(Ae(n,ze))}`;let o=e.placeholder;if(o)return `${r} ${Ke(Ae(o,ze))}`;let a=e.getAttribute("name");if(a)return `${r}[name="${a}"]`;if(t==="input"){let s=e.type||"text";return `${r}[type=${s}]`}return r}function Ra(e){let t=e.alt?.trim();return t?`img ${Ke(Ae(t,ze))}`:"img"}function st(e){let t=e.tagName.toLowerCase();if(t==="img")return Ra(e);if(t==="input"||t==="textarea"||t==="select")return Ea(e);let r=vn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Ke(Ae(n,ze))}`;if(t==="a"||t==="button"||bn.has(t)||t==="label"){let a=Pt(e);if(a)return `${r} ${Ke(Ae(a,ze))}`;if(t==="a"||t==="button"){let s=e.querySelector("svg");if(s){let l=s.getAttribute("aria-label");return l?`${r} ${Ke(Ae(l,ze))}`:`${r} (icon)`}let i=e.getAttribute("href");if(t==="a"&&i)return `link[href="${Ae(i,ze)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=He(e);return o.length>0?`${t}.${o[0]}`:t}function wn(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(st(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,ka)}function yn(e){let t=Pt(e),r=e.parentElement;if(!r)return;let n=Pt(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let a=Pt(o);return !a||a===t?void 0:Ae(a,fn)}return Ae(n,fn)}}function kn(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(st(n)),r.length>=Ca))break;return r}var Ia=["role","aria-label","name"],Pa=10,hn=100;function Nt(e){let t={};for(let r of Ia){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,hn));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=Pa)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,hn));}return t}function Mt(e){return Ta(e)}function Cn(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function _t(e,t){return e.closest(`[${t}]`)!==null}var Na=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"]),Ma={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"},_a={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"},Da={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 Tn(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function Oa(e){return `"${e}"`}function Dt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function An(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 ee(e,t){let r=t?.trim();return r?`${e}: ${Oa(Tn(r,48))}`:e}function La(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function za(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Da[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":_a[n]??"Area":"Area"}function Ha(e){let t=e.getAttribute("aria-label");if(t)return ee("Field",t);let r=e.placeholder;if(r)return ee("Field",r);let n=e.getAttribute("name");if(n)return ee("Field",An(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return ee("Field",An(o))}return "Field"}function lt(e,t){if(t?.trim())return ee("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return ee("Button",n??Dt(e));if(r==="a")return ee("Link",n??Dt(e));if(r==="input"||r==="textarea"||r==="select")return Ha(e);if(r==="img"){let a=e.alt;return ee("Image",a)}if(r==="svg")return ee("Icon",n);if(/^h[1-6]$/.test(r))return ee("Heading",Dt(e));if(Na.has(r))return ee("Text",Dt(e));let o=Ma[r];return ee(o||"Area",n)}function Ot(e){return e===1?"1 item selected":`${e} items selected`}function Lt(){return "Selected area"}function Sn(e){if(e.targetLabel?.trim())return Tn(e.targetLabel,120);if(e.selectedText?.trim())return ee("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 Ot(Number(r[1]));if(/^region\b/i.test(t))return Lt();let n=La(t.split(">").at(-1)??t);return ee(za(n.base),n.text)}function Pn(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),a=Cn(o.commonAncestorContainer);if(a)return {kind:"element",element:a,rect:a.getBoundingClientRect(),selectedText:n,clickTarget:t}}return {kind:"element",element:t,rect:t.getBoundingClientRect(),clickTarget:t}}var En=20,Nn=7,Rn=10,Fa=.8,Va=.5,$a=new Set(["html","body","head","script","style","meta","link","title","br","noscript"]),Ba=new Set(["section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details","summary"]),zt=24;function Mn(e){let t=e.tagName.toLowerCase();if(Ba.has(t))return true;if(t==="div"||t==="span"){if(e.id)return true;let r=He(e);if(r.length>0&&r[0]!=="container")return true}return false}var Wa=["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 In(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Ya(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 Xa(e,t,r){if(_t(e,r))return false;let n=e.tagName.toLowerCase();if($a.has(n))return false;let o=e.getBoundingClientRect();if(o.width<Rn||o.height<Rn||o.width>t.width*Fa||o.height>t.height*Va)return false;if(n==="div"||n==="span"){let a=Array.from(e.childNodes).some(l=>l.nodeType===3&&(l.textContent??"").trim().length>0),s=e.getAttribute("role"),i=s!==null&&s.length>0;if(!a&&!i&&!Mn(e))return false}return true}function Ua(e){return e.filter(t=>!e.some(r=>r!==t&&t.contains(r)))}function Ga(e,t){let r=[...e].sort((n,o)=>{let a=n.getBoundingClientRect(),s=o.getBoundingClientRect();return a.width*a.height-s.width*s.height});for(let n of r){if(!Mn(n)||!e.every(i=>i===n||n.contains(i)))continue;let a=n.getBoundingClientRect();if(a.left>=t.x-zt&&a.top>=t.y-zt&&a.right<=t.x+t.width+zt&&a.bottom<=t.y+t.height+zt)return n}return null}function Ka(e){let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of e)a.x<t&&(t=a.x),a.y<r&&(r=a.y),a.x+a.width>n&&(n=a.x+a.width),a.y+a.height>o&&(o=a.y+a.height);return {x:t,y:r,width:n-t,height:o-r}}function qa(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 _n(e){let{rect:t,viewport:r,internalAttr:n}=e,o=e.doc??document,a=new Set;for(let c of qa(t)){let d=o.elementsFromPoint(c.x,c.y);for(let g of d)a.add(g);}for(let c of Array.from(o.querySelectorAll(Wa)))Ya(In(c.getBoundingClientRect()),t)&&a.add(c);let s=Array.from(a).filter(c=>Xa(c,r,n)),i=Ga(s,t),l=i?[i]:Ua(s);if(l.length>0){let c=l.map(d=>In(d.getBoundingClientRect()));return {kind:"multi",elements:l,rects:c,union:Ka(c)}}return t.width>=En&&t.height>=En?{kind:"area",rect:t}:null}var Dn="patch-capture-cursor-style";function Za(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
+ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEffect,use,createElement,useId}from'react';import {AnimatePresence,useReducedMotion,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';function 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)}function ae(e){try{let t=new URL(e);return Pe(`${t.origin}${t.pathname}`)}catch{return Pe(e)}}var gr="patch:locationchange",Gr="__patchHistoryPatched";function ea(e){let t=e.history;if(t[Gr])return;t[Gr]=true;let r=()=>e.dispatchEvent(new Event(gr)),{pushState:n,replaceState:o}=t;try{t.pushState=function(...s){let i=n.apply(this,s);return r(),i},t.replaceState=function(...s){let i=o.apply(this,s);return r(),i};}catch{}}function Kr(e,t){ea(e);let r=()=>t();return e.addEventListener("popstate",r),e.addEventListener("hashchange",r),e.addEventListener(gr,r),()=>{e.removeEventListener("popstate",r),e.removeEventListener("hashchange",r),e.removeEventListener(gr,r);}}var we={desktop:{viewport:"desktop",label:"Desktop",width:null,height:null,glyph:"desktop"},tablet:{viewport:"tablet",label:"Tablet",width:834,height:1194,glyph:"tablet"},mobile:{viewport:"mobile",label:"Mobile",width:390,height:844,glyph:"mobile"}},qr=["desktop","tablet","mobile"];function Ke(e){let t=we[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=we[e];return {width:r.width??t.width,height:r.height??t.height}}var ra=32,na=32,oa=3e3,Qr="cubic-bezier(0.16, 1, 0.3, 1)",Mt=[.22,.61,.36,1],en=.3,tn=.5,ia=.34,aa=.5,sa=.24,la=.22,rn=.12,ca=.42,nn=.2,da=200,ua=260,pa=70,ma=180,ga=260,fa=8,ha=4,ba="#d9d9dd",va=30,xa=["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 _t(e,t,r){let n=Math.max(320,e.innerWidth-ra*2),o=Math.max(320,e.innerHeight-na*2);return Math.min(1,n/t,o/r)}function wa(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function on({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:s}){let i=useReducedMotion(),a=t.width??r.innerWidth,l=t.height??r.innerHeight,c=t.viewport,d=`${c}:${a}:${l}`,m=!!r.happyDOM?.settings?.disableIframePageLoading,[u,h]=useState(()=>({viewport:c,width:a,height:l,scale:_t(r,a,l)})),[v,x]=useState("stable"),[T,w]=useState(false),[g,p]=useState(false),b=useRef(false),C=useRef(null),f=`${u.viewport}:${u.width}:${u.height}`!==d,Q=T&&!g&&!(f||v==="cover"||v==="resize"),Z=T&&!g&&v==="stable"&&!f,be=useCallback(E=>{C.current=E,n(E);},[n]),pe=useCallback(()=>{let E=C.current;if(!E||!wa(E)){b.current=false,w(false),p(true);return}b.current=true,w(true),p(false);},[]),oe=useCallback(()=>{h(E=>{let te=_t(r,E.width,E.height);return E.scale===te?E:{...E,scale:te}});},[r]);useEffect(()=>(oe(),r.addEventListener("resize",oe),()=>r.removeEventListener("resize",oe)),[r,oe]),useEffect(()=>{b.current=false,w(false),p(false);let E=r.setTimeout(()=>{b.current||p(true);},oa);return ()=>r.clearTimeout(E)},[e,r]),useEffect(()=>{if(i){f&&h({viewport:c,width:a,height:l,scale:_t(r,a,l)}),v!=="stable"&&x("stable");return}switch(v){case "stable":{f&&x("cover");return}case "cover":{let E=r.setTimeout(()=>x("resize"),pa);return ()=>r.clearTimeout(E)}case "resize":{f&&h({viewport:c,width:a,height:l,scale:_t(r,a,l)});let E=r.setTimeout(()=>x("reveal"),ma);return ()=>r.clearTimeout(E)}case "reveal":{let E=r.setTimeout(()=>x("stable"),ga);return ()=>r.clearTimeout(E)}}},[v,f,i,r,c,a,l]),useEffect(()=>{o(Z);},[Z,o]),useEffect(()=>{s(g);},[g,s]);let ee=i?{duration:0}:{duration:sa,ease:Mt},U=i?{duration:0}:{duration:la,ease:Mt,delay:nn*.5},k=i?{duration:0}:{duration:nn,ease:Mt},N=i?{duration:0}:{opacity:{duration:ca,ease:Mt,delay:rn},scale:{type:"spring",bounce:ia,duration:aa,delay:rn},width:{type:"spring",bounce:en,duration:tn},height:{type:"spring",bounce:en,duration:tn}},_=(Q?ua:da)/1e3,S=i?void 0:`opacity ${_}s ${Qr}, filter ${_}s ${Qr}`,L=u.width*u.scale,H=u.height*u.scale;return jsx(motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:ee},exit:{opacity:0,transition:U},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxs(motion.div,{initial:i?{opacity:0,width:L,height:H}:{opacity:0,scale:.8,width:L,height:H},animate:{opacity:1,scale:1,width:L,height:H},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:k},transition:N,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${ha}px solid ${ba}`,borderRadius:va,boxShadow:xa,willChange:"width, height"},children:[jsx("div",{"aria-hidden":!Q,className:"absolute top-0 left-0 origin-top-left",style:{width:u.width,height:u.height,transform:`scale(${u.scale})`,opacity:Q?1:0,filter:i||Q?"none":`blur(${fa}px)`,transition:S,pointerEvents:Q?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:be,"data-patch-preview-frame":"","data-patch-preview-src":e,title:`${t.label} preview`,tabIndex:Q?0:-1,src:m?void 0:e,srcDoc:m?"<!doctype html><html><body></body></html>":void 0,onLoad:pe,className:"block bg-white",style:{width:u.width,height:u.height,border:0}})}),jsx(ya,{visible:g})]})})}function ya({visible:e}){return e?jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsx("div",{className:"max-w-[320px] rounded-xl bg-white px-5 py-4 text-center text-[13px] leading-[1.45] text-foreground shadow-[0_18px_44px_-18px_rgba(0,0,0,0.28)]",children:"This site blocks embedding. Add X-Frame-Options: SAMEORIGIN or frame-ancestors 'self' to enable viewport previews."})}):null}var cn=createContext(null),dn=createContext(null),un="__patch_preview";function pn(){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 Sa(e){let t=new URL(e.location.href);return t.searchParams.set(un,"1"),t.toString()}function mn(e=window){try{return new URL(e.location.href).searchParams.get(un)==="1"}catch{return false}}function Ta(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function s(){return t.getBoundingClientRect()}function i(){let l=s();return r.width>0?l.width/r.width:1}function a(l){if(!l)return null;let c=n.Element;return l instanceof c?l:null}return {targetWindow:n,targetDocument:o,overlayWindow: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=s(),d=i();return {viewportX:c.left+l.viewportX*d,viewportY:c.top+l.viewportY*d}},targetRectToOverlay:l=>{let c=s(),d=i();return {x:c.left+l.x*d,y:c.top+l.y*d,width:l.width*d,height:l.height*d}},eventTargetElement:a}}function gn(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function fn({children:e}){let t=useMemo(()=>pn(),[]),[r,n]=useState("desktop"),[o,s]=useState(null),[i,a]=useState(false),[l,c]=useState(false),[d,m]=useState(false),u=r!=="desktop",h=u||d,v=we[r],x=v.width&&v.height?{width:v.width,height:v.height}:null;useEffect(()=>{a(false),c(false);},[r]);let T=useRef(u);useEffect(()=>{T.current&&!u?m(true):!T.current&&u&&m(false),T.current=u;},[u]);let w=useMemo(()=>t?!u||!i||l||!o||!x?t:Ta(t,o,x)??t:null,[l,o,i,u,x,t]),g=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:h,previewReady:h?u&&i&&!l:true,previewBlocked:u&&l}),[r,l,i,u,h]),p=useMemo(()=>t?Sa(t.targetWindow):"",[t]);return !w||!t?null:jsx(dn.Provider,{value:g,children:jsxs(cn.Provider,{value:w,children:[e,jsx(AnimatePresence,{onExitComplete:()=>m(false),children:u&&x?jsx(on,{src:p,viewport:v,overlayWindow:t.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function ce(){let e=use(cn),t=useMemo(()=>pn(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function Je(){let e=use(dn),[t,r]=useState("desktop"),n=useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var Ra="X-Patch-Client-Id";function ve(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[Ra]:e.clientUserId}:{}}}async function ye(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 Ia(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 hn(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await ye(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.annotations??[]},async listRoster(){return (await ye(`${e.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.entries??[]},async fetchMe(){return ye(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:ve(e,false)})},async postIdentity(t){let r=await ye(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:ve(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 ye(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(t)})},async reply(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return ye(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async deleteMessage(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async kickoff(t,r){return Ia(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async resolve(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reopen(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reportAnchorStatuses(t){t.length!==0&&await ye(`${e.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify({reports:t})});}}}var vr="patch.clientIdentity",bn="patch.clientAvatarSeed";function xr(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(vr);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function vn(e){return xr()[e]??null}function wr(e,t){if(!(typeof window>"u"))try{let r=xr();r[e]=t,window.localStorage.setItem(vr,JSON.stringify(r));}catch{}}function xn(e){if(!(typeof window>"u"))try{let t=xr();delete t[e],window.localStorage.setItem(vr,JSON.stringify(t));}catch{}}function Na(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(bn);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function br(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function wn(e){if(typeof window>"u")return br();try{let t=Na(),r=t[e];if(r)return r;let n=br();return t[e]=n,window.localStorage.setItem(bn,JSON.stringify(t)),n}catch{return br()}}var _a=2e4,kn=createContext(null);function Da(e,t){let r=new Map(e.map(i=>[i.id,i])),n=new Set(t.map(i=>i.id)),o=t.map(i=>{let a=r.get(i.id);if(!a)return i;let l=new Set(i.thread.map(m=>m.id)),c=a.thread.filter(m=>m.deliveryStatus&&!l.has(m.id)),d=c.length>0?{...i,thread:[...i.thread,...c]}:i;if(a.optimisticAction==="resolve-pending"&&i.status!=="resolved"&&(d={...d,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="reopen-pending"&&i.status==="resolved"&&(d={...d,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="run-pending"&&a.latestRun?.id.startsWith("tmp-run")){let m=i.latestRun?Date.parse(i.latestRun.createdAt):Number.NaN,u=Date.parse(a.latestRun.createdAt);i.latestRun!=null&&(Number.isNaN(u)||Number.isNaN(m)||m>=u)||(d={...d,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return d}),s=e.filter(i=>(i.deliveryStatus||i.optimisticAction)&&!n.has(i.id));return [...o,...s]}function Cn({projectToken:e,apiBase:t,children:r}){let n=ce(),{activeViewport:o,setActiveViewport:s}=Je(),[i,a]=useState(()=>typeof window>"u"?null:vn(e)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":wn(e)),[c,d]=useState(null),[m,u]=useState("client"),[h,v]=useState(null),[x,T]=useState([]),[w,g]=useState(null),[p,b]=useState([]),[C,A]=useState(false),[f,I]=useState(null),Q=useRef(f);Q.current=f;let Z=useRef(o);Z.current=o;let be=w===o,pe=useMemo(()=>hn({apiBase:t,token:e,clientUserId:i?.clientUserId}),[t,e,i?.clientUserId]),oe=useRef(pe);oe.current=pe;let ee=useRef(0),U=useCallback(async()=>{let P=o,D=++ee.current,$=await oe.current.listAnnotations(P==="desktop"?void 0:P);if(D!==ee.current||P!==Z.current)return;let K=n.getPageUrl(),Ae=$.filter(ge=>ae(ge.payload.url)===K);T(ge=>Da(ge,Ae)),g(P);},[o,n]),k=useRef(U);k.current=U,useEffect(()=>{let P=false;return (async()=>{let D=await oe.current.fetchMe();if(!P){if(D?.active===false){I(false),A(true);return}if(I(true),D?.studio)d(D.studio),u("studio"),v(D.agentRunReadiness??{ready:true,message:null});else if(d(null),u("client"),v(null),D?.client){let $={clientUserId:D.client.id,name:D.client.name,email:D.client.email,avatarSeed:D.client.avatarSeed};a($),wr(e,$);}await k.current(),P||A(true);}})(),()=>{P=true;}},[e]),useEffect(()=>{!C||!f||U();},[C,f,U]),useEffect(()=>{if(!f)return;let{overlayDocument:P,overlayWindow:D}=n,$=D.setInterval(()=>{P.visibilityState==="visible"&&U();},_a),K=()=>{P.visibilityState==="visible"&&U();};return P.addEventListener("visibilitychange",K),()=>{D.clearInterval($),P.removeEventListener("visibilitychange",K);}},[f,U,n]),useEffect(()=>{if(f)return Kr(n.targetWindow,()=>{let P=n.getPageUrl();T(D=>D.filter($=>ae($.payload.url)===P)),k.current();})},[f,n]);let N=useCallback(async P=>(wr(e,P),a(P),P),[e]),_=useCallback(()=>{a(null),xn(e);},[e]),S=useCallback(P=>{b(D=>[...D.filter($=>$.tempId!==P.tempId),P]);},[]),L=useCallback(P=>{b(D=>D.filter($=>$.tempId!==P));},[]),H=useCallback(P=>{T(D=>{let $=D.findIndex(Ae=>Ae.id===P.id);if($===-1)return [...D,P];let K=D.slice();return K[$]=P,K});},[]),E=useCallback((P,D)=>{T($=>{let K=false,Ae=$.flatMap(ge=>{if(ge.id!==P)return [ge];K=true;let Ve=D(ge);return Ve?[Ve]:[]});return K?Ae:$});},[]),te=useCallback((P,D)=>{T($=>$.map(K=>K.id===P?{...K,id:D,deliveryStatus:"sent"}:K));},[]),me=useMemo(()=>({apiClient:pe,active:f,ready:C,viewerKind:m,agentRunReadiness:h,activeViewport:o,clientAvatarSeed:l,identity:i,studio:c,annotations:x,annotationsReady:be,ephemerals:p,refresh:U,setActiveViewport:s,setIdentity:N,signOut:_,addEphemeral:S,removeEphemeral:L,applyAnnotationUpdate:H,updateAnnotation:E,replaceAnnotationId:te}),[pe,f,C,m,h,o,l,i,c,x,be,p,U,s,N,_,S,L,H,E,te]);return jsx(kn.Provider,{value:me,children:r})}function re(){let e=use(kn);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var An=createContext(null);function Sn({children:e}){let[t,r]=useState(null),[n,o]=useState(""),[s,i]=useState(0),[a,l]=useState(false),c=useCallback(()=>{r(null),o(""),l(false);},[]),d=useCallback(x=>{r({kind:"existing",annotationId:x}),o(""),l(false);},[]),m=useCallback(x=>{r({kind:"composer",...x}),o(""),l(false);},[]),u=useCallback(()=>{if(n.trim().length>0){i(x=>x+1);return}c();},[n,c]),h=useCallback(()=>{c();},[c]),v=useMemo(()=>({active:t,draftText:n,shakeNonce:s,confirmDiscardOpen:a,openExisting:d,openComposer:m,setDraftText:o,attemptClose:u,forceClose:h,setConfirmDiscardOpen:l}),[t,n,s,a,d,m,u,h]);return jsx(An.Provider,{value:v,children:e})}function xe(){let e=use(An);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var Rn=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"]),$a=new Set(["a","button","input","select","textarea"]),In={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"},We=40,Va=1500,Tn=200,Ba=5,Wa=10;function yr(e){return Rn.has(e.tagName.toLowerCase())}function Me(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Qe(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 Ot(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Ua(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 Ye(e){let t=Array.from(e.classList),r=t.filter(Ua).slice(0,Wa);return r.length>0?r:t.length>0?["container"]:[]}function Nn(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,s=e.tagName.toLowerCase(),i=$a.has(s)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!i)return;let a={focusable:i};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=In[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Qe(Me(n,We))}`;let o=e.placeholder;if(o)return `${r} ${Qe(Me(o,We))}`;let s=e.getAttribute("name");if(s)return `${r}[name="${s}"]`;if(t==="input"){let i=e.type||"text";return `${r}[type=${i}]`}return r}function Ga(e){let t=e.alt?.trim();return t?`img ${Qe(Me(t,We))}`:"img"}function ht(e){let t=e.tagName.toLowerCase();if(t==="img")return Ga(e);if(t==="input"||t==="textarea"||t==="select")return Xa(e);let r=In[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Qe(Me(n,We))}`;if(t==="a"||t==="button"||Rn.has(t)||t==="label"){let s=Ot(e);if(s)return `${r} ${Qe(Me(s,We))}`;if(t==="a"||t==="button"){let i=e.querySelector("svg");if(i){let l=i.getAttribute("aria-label");return l?`${r} ${Qe(Me(l,We))}`:`${r} (icon)`}let a=e.getAttribute("href");if(t==="a"&&a)return `link[href="${Me(a,We)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=Ye(e);return o.length>0?`${t}.${o[0]}`:t}function Pn(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(ht(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,Va)}function Mn(e){let t=Ot(e),r=e.parentElement;if(!r)return;let n=Ot(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let s=Ot(o);return !s||s===t?void 0:Me(s,Tn)}return Me(n,Tn)}}function _n(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(ht(n)),r.length>=Ba))break;return r}var Ka=["role","aria-label","name"],qa=10,En=100;function zt(e){let t={};for(let r of Ka){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,En));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=qa)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,En));}return t}function Ht(e){return Ya(e)}function Dn(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function Ft(e,t){return e.closest(`[${t}]`)!==null}var Za=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"]),ja={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"},Ja={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"},Qa={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 On(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function es(e){return `"${e}"`}function $t(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Ln(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 se(e,t){let r=t?.trim();return r?`${e}: ${es(On(r,48))}`:e}function ts(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function rs(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Qa[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":Ja[n]??"Area":"Area"}function ns(e){let t=e.getAttribute("aria-label");if(t)return se("Field",t);let r=e.placeholder;if(r)return se("Field",r);let n=e.getAttribute("name");if(n)return se("Field",Ln(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return se("Field",Ln(o))}return "Field"}function bt(e,t){if(t?.trim())return se("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return se("Button",n??$t(e));if(r==="a")return se("Link",n??$t(e));if(r==="input"||r==="textarea"||r==="select")return ns(e);if(r==="img"){let s=e.alt;return se("Image",s)}if(r==="svg")return se("Icon",n);if(/^h[1-6]$/.test(r))return se("Heading",$t(e));if(Za.has(r))return se("Text",$t(e));let o=ja[r];return se(o||"Area",n)}function Vt(e){return e===1?"1 item selected":`${e} items selected`}function Bt(){return "Selected area"}function zn(e){if(e.targetLabel?.trim())return On(e.targetLabel,120);if(e.selectedText?.trim())return se("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 Vt(Number(r[1]));if(/^region\b/i.test(t))return Bt();let n=ts(t.split(">").at(-1)??t);return se(rs(n.base),n.text)}function Vn(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),s=Dn(o.commonAncestorContainer);if(s)return {kind:"element",element:s,rect:s.getBoundingClientRect(),selectedText:n,clickTarget:t}}return {kind:"element",element:t,rect:t.getBoundingClientRect(),clickTarget:t}}var Hn=20,Bn=7,Fn=10,os=.8,is=.5,as=new Set(["html","body","head","script","style","meta","link","title","br","noscript"]),ss=new Set(["section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details","summary"]),Wt=24;function Wn(e){let t=e.tagName.toLowerCase();if(ss.has(t))return true;if(t==="div"||t==="span"){if(e.id)return true;let r=Ye(e);if(r.length>0&&r[0]!=="container")return true}return false}var ls=["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 $n(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function cs(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 ds(e,t,r){if(Ft(e,r))return false;let n=e.tagName.toLowerCase();if(as.has(n))return false;let o=e.getBoundingClientRect();if(o.width<Fn||o.height<Fn||o.width>t.width*os||o.height>t.height*is)return false;if(n==="div"||n==="span"){let s=Array.from(e.childNodes).some(l=>l.nodeType===3&&(l.textContent??"").trim().length>0),i=e.getAttribute("role"),a=i!==null&&i.length>0;if(!s&&!a&&!Wn(e))return false}return true}function us(e){return e.filter(t=>!e.some(r=>r!==t&&t.contains(r)))}function ps(e,t){let r=[...e].sort((n,o)=>{let s=n.getBoundingClientRect(),i=o.getBoundingClientRect();return s.width*s.height-i.width*i.height});for(let n of r){if(!Wn(n)||!e.every(a=>a===n||n.contains(a)))continue;let s=n.getBoundingClientRect();if(s.left>=t.x-Wt&&s.top>=t.y-Wt&&s.right<=t.x+t.width+Wt&&s.bottom<=t.y+t.height+Wt)return n}return null}function ms(e){let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let s of e)s.x<t&&(t=s.x),s.y<r&&(r=s.y),s.x+s.width>n&&(n=s.x+s.width),s.y+s.height>o&&(o=s.y+s.height);return {x:t,y:r,width:n-t,height:o-r}}function gs(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 Yn(e){let{rect:t,viewport:r,internalAttr:n}=e,o=e.doc??document,s=new Set;for(let c of gs(t)){let d=o.elementsFromPoint(c.x,c.y);for(let m of d)s.add(m);}for(let c of Array.from(o.querySelectorAll(ls)))cs($n(c.getBoundingClientRect()),t)&&s.add(c);let i=Array.from(s).filter(c=>ds(c,r,n)),a=ps(i,t),l=a?[a]:us(i);if(l.length>0){let c=l.map(d=>$n(d.getBoundingClientRect()));return {kind:"multi",elements:l,rects:c,union:ms(c)}}return t.width>=Hn&&t.height>=Hn?{kind:"area",rect:t}:null}var Un="patch-capture-cursor-style";function fs(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 ja(e,t){let r=e.targetDocument,n=r.getElementById(Dn);n&&n.remove();let o=r.createElement("style");return o.id=Dn,o.setAttribute(t,""),o.textContent=Za(t),r.head.appendChild(o),o}function Ht(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var Fe=1.5,Ln="#0287FE",zn="rgba(2, 135, 254, 0.032)";function Ja(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:`${Fe}px solid ${Ln}`,background:zn,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 a=null;return {update(s){let i=s.getBoundingClientRect();if(i.width===0&&i.height===0){this.hide();return}n.style.display="block",n.style.top=`${i.top-Fe}px`,n.style.left=`${i.left-Fe}px`,n.style.width=`${i.width+Fe*2}px`,n.style.height=`${i.height+Fe*2}px`,n.style.borderRadius=`${Ja(e.targetWindow.getComputedStyle(s).borderRadius)+Fe}px`,s!==a&&(o.textContent=lt(s),a=s),o.style.display="block";let l=i.right+8,c=Math.max(8,i.top),d=e.getTargetViewport().width-8;l+240<=d?(o.style.left=`${l}px`,o.style.top=`${c}px`):(o.style.left=`${Math.max(8,i.right-240)}px`,o.style.top=`${Math.max(8,i.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function es(e,t){let r=e.targetDocument.createElement("div");return r.setAttribute(t,""),Object.assign(r.style,{position:"fixed",pointerEvents:"none",border:`${Fe}px solid ${Ln}`,background:zn,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 On(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 Hn(e){let{internalAttr:t,onClick:r,onDrag:n,surface:o}=e,a=o.targetDocument,s=ja(o,t),i=Qa(o,t),l=false,c=null,d=null;function g(){c?.rectOverlay&&c.rectOverlay.destroy(),c=null;}function p(){d&&(d.destroy(),d=null);}let f=m=>{let u=m,v=o.eventTargetElement(u.target);Ht(o,u.target,t)||v&&ur(v)||(u.preventDefault(),u.stopPropagation(),!l&&(p(),c={startX:u.clientX,startY:u.clientY,isDragging:false,rectOverlay:null}));},x=m=>{let u=m;if(c?.isDragging){u.preventDefault(),u.stopPropagation();let k=On({x:c.startX,y:c.startY},{x:u.clientX,y:u.clientY});d=c.rectOverlay,c=null,n?.(k,u);return}g();let v=o.eventTargetElement(u.target);Ht(o,u.target,t)||v&&ur(v)||(u.preventDefault(),u.stopPropagation());},w=m=>{let u=m;Ht(o,u.target,t)||(u.preventDefault(),u.stopPropagation(),!l&&r(u));},P=m=>{let u=m;if(c){if(!c.isDragging){let T=u.clientX-c.startX,S=u.clientY-c.startY;if(Math.hypot(T,S)<Nn)return;c.isDragging=true,i.hide(),c.rectOverlay=es(o,t);}c.rectOverlay?.update(On({x:c.startX,y:c.startY},{x:u.clientX,y:u.clientY}));return}if(l)return;let v=o.eventTargetElement(u.target);if(!v){i.hide();return}if(Ht(o,v,t)){i.hide();return}let k=v.tagName.toLowerCase();if(k==="html"||k==="body"){i.hide();return}i.update(v);},b=m=>{m.relatedTarget||i.hide();};return a.addEventListener("mousedown",f,true),a.addEventListener("mouseup",x,true),a.addEventListener("click",w,true),a.addEventListener("mousemove",P,true),a.addEventListener("mouseout",b,true),{exit(){s.remove(),i.destroy(),g(),p(),a.removeEventListener("mousedown",f,true),a.removeEventListener("mouseup",x,true),a.removeEventListener("click",w,true),a.removeEventListener("mousemove",P,true),a.removeEventListener("mouseout",b,true);},pause(){l=true,i.hide(),g();},resume(){l=false;},dismissDragOverlay(){p();}}}var Fn="data-patch-internal",Bn=createContext(null),Vn=0;function $n(){return Vn+=1,`tmp-${Date.now().toString(36)}-${Vn}`}function Wn({children:e}){let t=we(),r=me(),n=pe(),{isPreviewing:o,previewReady:a}=Ge(),[s,i]=useState(false),l=useRef(null),c=useRef(t),d=useRef(r);c.current=t,d.current=r;let g=useCallback(m=>{let u=c.current;if(u.active&&u.draftText.trim().length>0){u.attemptClose();return}let v=n.eventTargetElement(m.target)??n.targetDocument.body,k=n.targetWindow.getSelection(),T=Pn({clickTarget:v,selection:k}),S=$n(),H={viewportX:m.clientX,viewportY:m.clientY,documentY:m.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:S,viewportX:H.viewportX,viewportY:H.viewportY,documentY:H.documentY}),c.current.openComposer({tempId:S,target:T,anchor:H}),l.current?.pause();},[n]),p=useCallback((m,u)=>{let v=c.current;if(v.active&&v.draftText.trim().length>0){v.attemptClose(),l.current?.dismissDragOverlay();return}let k=n.getTargetViewport(),T=_n({rect:m,viewport:k,internalAttr:Fn,doc:n.targetDocument});if(!T){l.current?.dismissDragOverlay();return}let S=$n(),H={viewportX:u.viewportX,viewportY:u.viewportY,documentY:u.viewportY+n.getTargetScrollY()};d.current.addEphemeral({tempId:S,viewportX:H.viewportX,viewportY:H.viewportY,documentY:H.documentY}),c.current.openComposer({tempId:S,target:T,anchor:H}),l.current?.pause();},[n]),f=r.annotationsReady&&(!o||a);useEffect(()=>{if(!s||!f){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=Hn({internalAttr:Fn,surface:n,onClick:g,onDrag:(m,u)=>p(m,{viewportX:u.clientX,viewportY:u.clientY})}),()=>{l.current?.exit(),l.current=null;}},[s,g,p,n,f]);let x=useCallback(()=>{s||i(true);},[s]),w=useCallback(()=>{i(false);},[]),P=useRef(null);useEffect(()=>{let m=P.current,u=t.active;m?.kind==="composer"&&u?.kind!=="composer"&&(d.current.removeEphemeral(m.tempId),l.current?.dismissDragOverlay(),l.current?.resume()),m?.kind==="composer"&&u?.kind==="composer"&&m.tempId!==u.tempId&&d.current.removeEphemeral(m.tempId),P.current=u;},[t.active]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let b=useMemo(()=>({isCapturing:s,enter:x,exit:w}),[s,x,w]);return jsx(Bn.Provider,{value:b,children:e})}function Yn(){let e=use(Bn);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var Un=createContext(null);function Gn({children:e}){let[t,r]=useState(false),[n,o]=useState(false),a=useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsx(Un.Provider,{value:a,children:e})}function $t(){let e=use(Un);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var Kn="[Patch] No project token found, widget disabled. Pass `projectToken` as a prop, or set NEXT_PUBLIC_PATCH_TOKEN (Next.js), VITE_PATCH_TOKEN (Vite / React Router), or PUBLIC_PATCH_TOKEN (Astro) in your env.";function qn(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();return o||null}function Zn(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function jn(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var ds=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 us(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Jn(e){return e.replace(/\s+/g," ").trim()}function mr(e){return ds.has(Jn(e))}function Qn(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Jn(n[1]??"");!o||mr(o)||t[t.length-1]!==o&&t.push(o);}return t.length===0?null:us(t.map(n=>`<${n}>`).join(" "),1e3)}var eo="seed:";function Bt(e){return e?e.startsWith(eo)?{url:null,seed:e.slice(eo.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var gr=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],to=[{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]}],ro=Math.PI*2;function ps(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 ms(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 U(e,t,r){return t+e()*(r-t)}function ne(e,t=3){let r=10**t;return Math.round(e*r)/r}function no(e,t,r){return `hsl(${ne((e%360+360)%360,1)} ${ne(t,1)}% ${ne(r,1)}%)`}function oo(e){let t=ps(e?.trim()||"patch-client"),r=ms(t),n=t.toString(36),o=(gr[t%gr.length]??gr[0])+U(r,-10,10),a=r()<.5?-1:1,s=r()<.5?-1:1,i=o+s*U(r,52,116),l=o-s*U(r,26,66),c=o+a*U(r,12,38),d=no(o+a*U(r,0,14),U(r,80,92),U(r,44,54)),g=U(r,0,ro),p=to.map((f,x)=>{let P=(f.hue==="accent"?i:f.hue==="accent2"?l:f.hue==="near"?c:o)+U(r,-11,11),b=g+x/to.length*ro+U(r,-0.6,.6),m=U(r,f.reach[0],f.reach[1]),u=ne(.5+Math.cos(b)*m),v=ne(.5+Math.sin(b)*m),k=ne(U(r,0,180),1),T=ne(U(r,.62,1.5),3),S=ne(U(r,.62,1.5),3);return {id:`cav-${n}-${x}`,cx:u,cy:v,r:ne(U(r,f.r[0],f.r[1])),color:no(P,U(r,f.sat[0],f.sat[1]),U(r,f.light[0],f.light[1])),opacity:ne(U(r,f.opacity[0],f.opacity[1]),2),gradientTransform:`rotate(${k} ${u} ${v}) translate(${u} ${v}) scale(${T} ${S}) translate(${ne(-u)} ${ne(-v)})`}});return {id:n,background:d,spots:p,blur:ne(U(r,3.4,5.4),2),grain:ne(U(r,.09,.15),2)}}function ct(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",a=e.anchor.x+e.anchor.width+t;a+n>e.viewport.width-r&&(o="left",a=e.anchor.x-n-t),a<r&&(a=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:a,y:s,width:n,placement:o}}function N(...e){return e.filter(Boolean).join(" ")}function Yt({seed:e,className:t,style:r}){let n=oo(e),o=useId().replace(/[^a-zA-Z0-9_-]/g,""),a=`${n.id}-${o}`,s=`cav-blur-${a}`,i=`cav-grain-${a}`;return jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:N("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxs("defs",{children:[jsx("filter",{id:s,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxs("filter",{id:i,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxs("radialGradient",{id:`${a}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsx("rect",{width:"64",height:"64",fill:n.background}),jsx("g",{filter:`url(#${s})`,children:n.spots.map(l=>jsx("rect",{width:"64",height:"64",fill:`url(#${a}-${l.id})`},l.id))}),jsx("rect",{width:"64",height:"64",filter:`url(#${i})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Ie=28,io=[.22,.61,.36,1],Xt=["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 qe(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]??"",a=n[0]??"";return (o+a).toUpperCase()||"?"}function Ze(e){if(!e)return Xt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Xt[Math.abs(t)%Xt.length]??Xt[0]}var hs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},bs={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function je(e,t){let{placement:r}=ct({anchor:{x:e.viewportX-Ie/2,y:e.viewportY-Ie/2,width:Ie,height:Ie},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function Ut(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Ie,y:e.viewportY-Ie,width:Ie,height:Ie}}function fr({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?vs[t.attention]:null,{url:o,seed:a}=Bt(t.avatarSrc),s=a??t.generatedSeed,i=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 jsx(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:io}}:{opacity:0,scale:.9,transition:{duration:.12,ease:io}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:hs[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:bs[r],background:"var(--color-muted-foreground)",filter:t.orphan?"grayscale(1)":"none",opacity:t.orphan?.55:1},children:[s?jsx(Yt,{seed:s,style:{borderRadius:0,filter:i||"none",opacity:l}}):null,o?jsx("img",{src:o,alt:t.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:i||"none",opacity:l},onError:d=>{d.currentTarget.remove();}}):null]}),t.resolved&&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&&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 vs={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};var xs="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",ws={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Pe({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:a="md",className:s,style:i}){let{url:l,seed:c}=Bt(r),d=c??n;return jsxs("span",{className:N(xs,ws[a],s),style:{background:t,...i},children:[jsx("span",{children:e}),!l&&d?jsx(Yt,{seed:d}):null,l?jsx("img",{src:l,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:g=>{g.currentTarget.remove();}}):null]})}var so={"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 $({name:e,size:t=16,stroke:r=2,color:n,className:o}){return 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:so[e].map(([a,s],i)=>createElement(a,{key:i,...s}))})}var As="M48 0C67.8823 0 84 16.1178 84 36V63C84 67.9706 79.9706 72 75 72H48C42.2522 72 36.8201 70.6505 32 68.2549V87C32 91.9706 27.9706 96 23 96H14C12.8954 96 12 95.1046 12 94V36C12 16.1178 28.1178 0 48 0ZM48 18C38.0589 18 30 26.0589 30 36C30 45.9411 38.0589 54 48 54C57.9411 54 66 45.9411 66 36C66 26.0589 57.9411 18 48 18Z",Ts="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 pt({size:e=16,className:t}){return jsx("svg",{width:e,height:e,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:t,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:As})})}function lo({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return 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:jsx("path",{d:Ts})})}var br=false,Ve=null,Kt=null,fe={openDelay:700,isInstant(){return br},onOpen(e){Kt&&Kt!==e&&Kt(),Kt=e??null,br=true,Ve&&(clearTimeout(Ve),Ve=null);},onClose(){Ve&&clearTimeout(Ve),Ve=setTimeout(()=>{br=false,Ve=null;},300);}};var po="easeOut";function Te({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[a,s]=useState(false),[i,l]=useState(false),c=useRef(null),d=useRef(false);useEffect(()=>()=>{c.current&&clearTimeout(c.current),d.current&&fe.onClose();},[]);let g=v=>{l(v),s(true),d.current=true,fe.onOpen();},p=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),fe.isInstant()){g(true);return}c.current=setTimeout(()=>{c.current=null,g(false);},fe.openDelay);},f=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,fe.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",P=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}`,b=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,u=o==="bottom"&&n!=="warning"?-2:2;return jsxs("span",{className:N("relative inline-flex items-center justify-center",r),onMouseEnter:p,onMouseLeave:f,onMouseDown:f,children:[jsx("span",{className:x,children:jsx(AnimatePresence,{children:a&&jsxs(motion.span,{initial:i?false:{opacity:0,y:m,scale:.98},animate:{opacity:1,y:0,scale:1,transition:i?{duration:0}:{duration:.1,ease:po}},exit:{opacity:0,y:u,scale:.98,transition:{duration:.08,ease:po}},className:P,children:[n==="warning"?jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsx("span",{className:"min-w-0 flex-1",children:e}),jsx("span",{className:b})]})})}),t]})}var Is=44,Ps=212,ke=[.16,1,.3,1],go="easeOut",Ns=.08,Ms=60,_s="calc(100% - 64px) calc(100% + 4px)",gt="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function fo(){let e=Yn(),t=we(),r=me(),{dockOpen:n,hideResolvedAnnotations:o,setDockOpen:a,setHideResolvedAnnotations:s}=$t(),[i,l]=useState(false),[c,d]=useState(false),[g,p]=useState(false),[f,x]=useState(false),[w,P]=useState(false),b=useRef(null),m=useRef(null),u=useRef(false),[v,k]=useState(false),T=r.studio?r.studio.name:r.identity?.name??null,S=qe(T),H=r.studio?.image??null,Z=r.identity?.avatarSeed??r.clientAvatarSeed,j=r.studio?.userId??Z,ie=r.studio?"var(--color-foreground)":Ze(Z),ae=r.studio&&!H?"#FFFFFF":ie,Q=r.studio&&!H?"text-foreground":"text-white",se=Ce[r.activeViewport];function Y(){b.current!==null&&(window.clearTimeout(b.current),b.current=null);}function h(){m.current!==null&&(window.clearTimeout(m.current),m.current=null);}let R=useRef(()=>{});R.current=()=>{!u.current&&b.current===null||(Y(),h(),u.current=false,P(true));};let _=useRef(()=>R.current()).current;useEffect(()=>{w&&i&&l(false);},[w,i]);function C(B){d(false),p(false),Y(),h(),u.current=true,P(false),x(B),fe.onOpen(_),l(true);}function D(){C(false);}function L(){if(Y(),!(u.current||m.current!==null)){if(fe.isInstant()){C(true);return}m.current=window.setTimeout(()=>{m.current=null,C(false);},fe.openDelay);}}function A(){h(),Y(),u.current&&(u.current=false,fe.onClose()),b.current=window.setTimeout(()=>{l(false),b.current=null;},120);}function le(){k(true),a(true);}function Be(){d(false),p(false),h(),u.current=false,l(false),e.isCapturing?e.exit():e.enter();}function I(){k(true),a(false),d(false),p(false),h(),u.current=false,l(false),e.exit(),t.active&&t.forceClose();}useEffect(()=>()=>{b.current!==null&&window.clearTimeout(b.current),m.current!==null&&window.clearTimeout(m.current);},[]);let M=()=>{r.signOut(),l(false);};function z(){p(false),h(),u.current=false,l(false),d(B=>!B);}function K(B){d(false),r.activeViewport!==B&&(t.active&&t.forceClose(),r.setActiveViewport(B));}function he(){d(false),h(),u.current=false,l(false),p(B=>!B);}function ue(){s(!o);}function De(B){let Oe=B.relatedTarget;Oe instanceof Node&&B.currentTarget.contains(Oe)||A();}return jsx("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:jsxs(motion.div,{initial:false,animate:{width:n?Ps:Is},transition:{duration:.36,ease:ke},onAnimationComplete:()=>k(false),whileHover:n?void 0:{scale:1.03,transition:{duration:.15,ease:ke}},whileTap:n?void 0:{scale:.97,transition:{duration:.1,ease:ke}},"data-patch-fab-dock":"",className:N("pkey-fab relative h-11 rounded-full",v?"overflow-hidden":"overflow-visible"),children:[jsx(motion.div,{animate:{opacity:n?0:1,scale:n?.7:1},transition:{duration:.18,ease:ke},className:N("absolute inset-0",n?"pointer-events-none":"pointer-events-auto"),children:jsx("button",{type:"button",onClick:le,"data-patch-fab-dock":"","aria-label":"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsx(pt,{size:18})})}),jsxs("div",{"data-patch-fab-dock":"",className:N("absolute inset-0 flex items-center gap-1.5 px-1.5",n?"pointer-events-auto":"pointer-events-none"),children:[jsx(ft,{visible:n,index:0,children:jsx(Te,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:Be,className:N(gt,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(lo,{variant:"outline",size:16})})})}),jsx(ft,{visible:n,index:1,children:jsxs("div",{className:"relative flex items-center",children:[jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${se.label}`,"aria-expanded":c,onClick:z,className:N(gt,"transition-colors",r.activeViewport==="desktop"&&!c?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx($,{name:se.glyph,size:15})}),jsx(AnimatePresence,{children:c?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:ke}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:ke}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),Hr.map(B=>{let Oe=Ce[B],yt=r.activeViewport===B;return jsx(Te,{text:We(B),children:jsx("button",{type:"button","data-patch-viewport-option":B,"aria-label":We(B),"aria-pressed":yt,onClick:()=>K(B),className:N("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",yt?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx($,{name:Oe.glyph,size:15})})},B)})]}):null})]})}),jsx(ft,{visible:n,index:2,children:jsxs("div",{className:"relative flex items-center",children:[jsx(Te,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":g,onClick:he,className:N(gt,"transition-colors",g||o?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx($,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:g?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:ke}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:ke}},"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:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-xl px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsx("input",{type:"checkbox",checked:o,"aria-label":"Hide resolved annotations",onChange:ue,className:"peer sr-only"}),jsx("span",{"aria-hidden":"true",className:N("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:jsx($,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(ft,{visible:n,index:3,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:L,onMouseLeave:A,onFocus:D,onBlur:De,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":T?`Account: ${T}`:"Identify",className:N(gt,"text-white"),children:T?jsx(Pe,{initials:S,tint:ae,src:H,generatedSeed:j,alt:T,size:"sm",className:N("size-[22px] text-[9.5px] ring-1 ring-white/20",Q)}):jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsx(AnimatePresence,{children:i?jsxs(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:Ns,ease:go}},exit:{opacity:0,y:2,scale:.98,transition:w?{duration:0}:{duration:.08,ease:go}},"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:_s},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:Ms}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Pe,{initials:S,tint:ie,src:H,generatedSeed:j,alt:r.studio.name,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Pe,{initials:S,tint:ie,generatedSeed:j,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsx("div",{className:"my-3 h-px bg-white/10"}),jsx("button",{type:"button",onClick:M,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsx(ft,{visible:n,index:4,children:jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsx(Te,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:I,className:N(gt,"text-white/70"),children:jsx($,{name:"x",size:14})})})]})})]})]})})}function ft({children:e,visible:t,index:r}){return jsx(motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:ke}}:{opacity:0,x:6,transition:{duration:.12,ease:ke}},children:e})}function ho(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 bo(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var Os=.6,Ls=.5,qt={text:.4,attrs:.3,classes:.2,position:.1},zs=5e3,Hs=.08,Fs=.12;function Vs(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 Bs(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 a=r.size+n.size-o;return a===0?0:o/a}function xo(e){let t=e.payload.boundingBox;if(!t)return null;let r=e.payload.coordinates.documentY-e.payload.coordinates.viewportY;return {x:t.x+t.width/2,y:t.y+t.height/2+r}}function wr(e,t,r){if(!t)return .5;let n=e.left+e.width/2,o=e.top+r.scrollY+e.height/2,a=(n-t.x)/Math.max(1,r.viewport.width),s=(o-t.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(a*a+s*s))}function Ws(e,t){let r=Mt(e),n=Nt(e),o=He(e),a=e.getBoundingClientRect(),s=Vs(r,t.payload.domHints?.textSignature),i=$s(n,t.payload.domHints?.attributeSignature),l=Bs(o,t.payload.cssClasses),c=wr(a,xo(t),t);return qt.text*s+qt.attrs*i+qt.classes*l+qt.position*c}function Ys(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function vo(e,t,r){let n=null,o=null,a=0;for(let s=0;s<e.length&&!(a>=zs);s++){let i=e[s];if(!i||(a++,_t(i,t.internalAttr)))continue;let l=i.tagName.toLowerCase();if(l==="html"||l==="head"||l==="script"||l==="style"||Ys(i))continue;let c=Ws(i,t);!n||c>n.score?(o=n,n={el:i,score:c}):(!o||c>o.score)&&(o={el:i,score:c});}if(!n||n.score<r)return null;if(o&&n.score-o.score<Hs){let s=xo(t),i=wr(n.el.getBoundingClientRect(),s,t),l=wr(o.el.getBoundingClientRect(),s,t);if(i-l<Fs)return null}return n.el}function Xs(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function Us(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=ho({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return bo(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Gs(e){let t=e.payload.domHints?.cssSelector;if(!t)return [];try{return Array.from(e.doc.querySelectorAll(t))}catch{return []}}function Zt(e){if(!e.payload.domHints)return {kind:"positional",el:null};let t=Gs(e);if(t.length>0){let n=vo(t,e,Ls);if(n)return {kind:"anchored",tier:1,el:n}}let r=vo(e.doc.querySelectorAll("*"),e,Os);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function yr(e,t){return e.kind==="anchored"&&e.el?Us(e.el,t):Xs(t)}function wo(e){let t=Zt(e);return {kind:t.kind,tier:t.tier,el:t.el,position:yr(t,e)}}function yo(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 qs="data-patch-internal";function jt(e,t,r){let n=je(r,t.getOverlayViewport()),o=Ut(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function Ao(e,t){return Math.abs(e.viewportX-t.viewportX)<.5&&Math.abs(e.viewportY-t.viewportY)<.5}function Zs(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function Ar(e,t){return {payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:qs}}function To(e,t,r){let n=Ar(e,t);return {kind:r.kind,position:e.targetPointToOverlay(yr(r,n))}}function js(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function So(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:a,apiClient:s}=me(),i=we(),{dockOpen:l,hideResolvedAnnotations:c}=$t(),d=pe(),{isPreviewing:g,previewReady:p}=Ge(),f=useReducedMotion(),x=i.active,w=i.forceClose,P=t&&(!g||p),b=useMemo(()=>l&&t?e.filter(h=>!c||h.status!=="resolved"):[],[l,t,e,c]),m=useMemo(()=>l&&t?r:[],[l,t,r]);useEffect(()=>{if(!c||x?.kind!=="existing")return;e.find(R=>R.id===x.annotationId)?.status==="resolved"&&w();},[x,e,w,c]);let u=useRef(new Map),v=useRef(new Map),k=useRef(new Map),T=useRef(new Map),S=useMemo(()=>{let h=T.current,R=new Set,_=new Map;for(let C of b){R.add(C.id);let D=h.get(C.id),A=D?.kind==="positional"||D?.kind==="anchored"&&D.el?.isConnected?D:Zt(Ar(d,C));h.set(C.id,A),_.set(C.id,To(d,C,A));}for(let C of h.keys())R.has(C)||h.delete(C);return _},[d,b]),H=useCallback(()=>{let h=T.current,R=k.current,_=new Set;for(let C of b){let D=u.current.get(C.id);if(!D)continue;_.add(C.id);let L=h.get(C.id);if((!L||L.kind==="anchored"&&L.el&&!L.el.isConnected)&&(L=Zt(Ar(d,C)),h.set(C.id,L)),L.kind==="detached"||L.kind==="anchored"&&L.el&&Zs(L.el)){D.style.visibility!=="hidden"&&(D.style.visibility="hidden"),R.delete(C.id);continue}D.style.visibility==="hidden"&&(D.style.visibility="");let A=To(d,C,L).position,le=R.get(C.id);le&&Ao(le,A)||(R.set(C.id,A),jt(D,d,A));}for(let C of m){let D=v.current.get(C.tempId);if(!D)continue;_.add(C.tempId);let L=js(d,C),A=R.get(C.tempId);A&&Ao(A,L)||(R.set(C.tempId,L),jt(D,d,L));}for(let C of R.keys())_.has(C)||R.delete(C);},[d,b,m]),Z=b.length>0||m.length>0;useEffect(()=>{if(!Z)return;let h=d.overlayWindow,R=h.requestAnimationFrame(function _(){H(),R=h.requestAnimationFrame(_);});return ()=>h.cancelAnimationFrame(R)},[Z,H,d]);let j=useRef(new Map);useEffect(()=>{if(!t||b.length===0)return;let h=setTimeout(()=>{let R=[];for(let _ of b){let C=S.get(_.id);if(!C)continue;let D=C.kind!=="detached";j.current.get(_.id)!==D&&(j.current.set(_.id,D),R.push({id:_.id,present:D}));}s.reportAnchorStatuses(R);},1500);return ()=>clearTimeout(h)},[S,b,t,s]);let ie=useCallback(h=>{if(i.active&&i.draftText.trim().length>0){i.attemptClose();return}i.openExisting(h);},[i]),ae=o?o.name:n?.name??null,Q=o?.image??null,se=n?.avatarSeed??a,Y=o?.userId??se;return jsxs("div",{"data-patch-pin-layer":"",style:{opacity:P?1:0,transition:f||!P?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:P?void 0:"none"},children:[jsx(AnimatePresence,{initial:false,children:b.map(h=>{let R=S.get(h.id);if(R?.kind==="detached")return null;let _=Js(h),C=!o&&!!n?.clientUserId&&h.payload.authorRole==="client"&&h.payload.authorId===n.clientUserId,D=o?yo(h):null,L=R?je(R.position,d.getOverlayViewport()):"right";return jsx(fr,{ref:A=>{A?(u.current.set(h.id,A),R&&jt(A,d,R.position)):u.current.delete(h.id);},avatarSrc:_.image,generatedSeed:C?se:_.generatedSeed,avatarAlt:_.name??"",resolved:h.status==="resolved",attention:D,orphan:R?.kind==="positional",pointSide:L,ariaLabel:`Annotation by ${h.authorName??"someone"}`,onClick:()=>ie(h.id),pinId:h.id},h.id)})}),jsx(AnimatePresence,{initial:false,children:m.map(h=>{let R=d.targetPointToOverlay({viewportX:h.viewportX,viewportY:h.viewportY});return jsx(fr,{ref:_=>{_?(v.current.set(h.tempId,_),jt(_,d,R)):v.current.delete(h.tempId);},avatarSrc:Q,generatedSeed:Y,avatarAlt:ae??"",resolved:false,pointSide:je(R,d.getOverlayViewport()),ephemeral:true},h.tempId)})})]})}function Js(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 Eo=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
4
+ `)}function hs(e,t){let r=e.targetDocument,n=r.getElementById(Un);n&&n.remove();let o=r.createElement("style");return o.id=Un,o.setAttribute(t,""),o.textContent=fs(t),r.head.appendChild(o),o}function Yt(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var Ue=1.5,Gn="#0287FE",Kn="rgba(2, 135, 254, 0.032)";function bs(e){let t=e.split(" ")[0]??"",r=Number.parseFloat(t);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function vs(e,t){let r=e.targetDocument,n=r.createElement("div");n.setAttribute(t,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${Ue}px solid ${Gn}`,background:Kn,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 s=null;return {update(i){let a=i.getBoundingClientRect();if(a.width===0&&a.height===0){this.hide();return}n.style.display="block",n.style.top=`${a.top-Ue}px`,n.style.left=`${a.left-Ue}px`,n.style.width=`${a.width+Ue*2}px`,n.style.height=`${a.height+Ue*2}px`,n.style.borderRadius=`${bs(e.targetWindow.getComputedStyle(i).borderRadius)+Ue}px`,i!==s&&(o.textContent=bt(i),s=i),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),d=e.getTargetViewport().width-8;l+240<=d?(o.style.left=`${l}px`,o.style.top=`${c}px`):(o.style.left=`${Math.max(8,a.right-240)}px`,o.style.top=`${Math.max(8,a.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function xs(e,t){let r=e.targetDocument.createElement("div");return r.setAttribute(t,""),Object.assign(r.style,{position:"fixed",pointerEvents:"none",border:`${Ue}px solid ${Gn}`,background:Kn,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 Xn(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 qn(e){let{internalAttr:t,onClick:r,onDrag:n,surface:o}=e,s=o.targetDocument,i=hs(o,t),a=vs(o,t),l=false,c=null,d=null;function m(){c?.rectOverlay&&c.rectOverlay.destroy(),c=null;}function u(){d&&(d.destroy(),d=null);}let h=g=>{let p=g,b=o.eventTargetElement(p.target);Yt(o,p.target,t)||b&&yr(b)||(p.preventDefault(),p.stopPropagation(),!l&&(u(),c={startX:p.clientX,startY:p.clientY,isDragging:false,rectOverlay:null}));},v=g=>{let p=g;if(c?.isDragging){p.preventDefault(),p.stopPropagation();let C=Xn({x:c.startX,y:c.startY},{x:p.clientX,y:p.clientY});d=c.rectOverlay,c=null,n?.(C,p);return}m();let b=o.eventTargetElement(p.target);Yt(o,p.target,t)||b&&yr(b)||(p.preventDefault(),p.stopPropagation());},x=g=>{let p=g;Yt(o,p.target,t)||(p.preventDefault(),p.stopPropagation(),!l&&r(p));},T=g=>{let p=g;if(c){if(!c.isDragging){let A=p.clientX-c.startX,f=p.clientY-c.startY;if(Math.hypot(A,f)<Bn)return;c.isDragging=true,a.hide(),c.rectOverlay=xs(o,t);}c.rectOverlay?.update(Xn({x:c.startX,y:c.startY},{x:p.clientX,y:p.clientY}));return}if(l)return;let b=o.eventTargetElement(p.target);if(!b){a.hide();return}if(Yt(o,b,t)){a.hide();return}let C=b.tagName.toLowerCase();if(C==="html"||C==="body"){a.hide();return}a.update(b);},w=g=>{g.relatedTarget||a.hide();};return s.addEventListener("mousedown",h,true),s.addEventListener("mouseup",v,true),s.addEventListener("click",x,true),s.addEventListener("mousemove",T,true),s.addEventListener("mouseout",w,true),{exit(){i.remove(),a.destroy(),m(),u(),s.removeEventListener("mousedown",h,true),s.removeEventListener("mouseup",v,true),s.removeEventListener("click",x,true),s.removeEventListener("mousemove",T,true),s.removeEventListener("mouseout",w,true);},pause(){l=true,a.hide(),m();},resume(){l=false;},dismissDragOverlay(){u();}}}var Zn="data-patch-internal",Qn=createContext(null),jn=0;function Jn(){return jn+=1,`tmp-${Date.now().toString(36)}-${jn}`}function eo({children:e}){let t=xe(),r=re(),n=ce(),{isPreviewing:o,previewReady:s}=Je(),[i,a]=useState(false),l=useRef(null),c=useRef(t),d=useRef(r);c.current=t,d.current=r;let m=useCallback(g=>{let p=c.current;if(p.active&&p.draftText.trim().length>0){p.attemptClose();return}let b=n.eventTargetElement(g.target)??n.targetDocument.body,C=n.targetWindow.getSelection(),A=Vn({clickTarget:b,selection:C}),f=Jn(),I={viewportX:g.clientX,viewportY:g.clientY,documentY:g.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:f,viewportX:I.viewportX,viewportY:I.viewportY,documentY:I.documentY}),c.current.openComposer({tempId:f,target:A,anchor:I}),l.current?.pause();},[n]),u=useCallback((g,p)=>{let b=c.current;if(b.active&&b.draftText.trim().length>0){b.attemptClose(),l.current?.dismissDragOverlay();return}let C=n.getTargetViewport(),A=Yn({rect:g,viewport:C,internalAttr:Zn,doc:n.targetDocument});if(!A){l.current?.dismissDragOverlay();return}let f=Jn(),I={viewportX:p.viewportX,viewportY:p.viewportY,documentY:p.viewportY+n.getTargetScrollY()};d.current.addEphemeral({tempId:f,viewportX:I.viewportX,viewportY:I.viewportY,documentY:I.documentY}),c.current.openComposer({tempId:f,target:A,anchor:I}),l.current?.pause();},[n]),h=r.annotationsReady&&(!o||s);useEffect(()=>{if(!i||!h){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=qn({internalAttr:Zn,surface:n,onClick:m,onDrag:(g,p)=>u(g,{viewportX:p.clientX,viewportY:p.clientY})}),()=>{l.current?.exit(),l.current=null;}},[i,m,u,n,h]);let v=useCallback(()=>{i||a(true);},[i]),x=useCallback(()=>{a(false);},[]),T=useRef(null);useEffect(()=>{let g=T.current,p=t.active;g?.kind==="composer"&&p?.kind!=="composer"&&(d.current.removeEphemeral(g.tempId),l.current?.dismissDragOverlay(),l.current?.resume()),g?.kind==="composer"&&p?.kind==="composer"&&g.tempId!==p.tempId&&d.current.removeEphemeral(g.tempId),T.current=p;},[t.active]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let w=useMemo(()=>({isCapturing:i,enter:v,exit:x}),[i,v,x]);return jsx(Qn.Provider,{value:w,children:e})}function to(){let e=use(Qn);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var Es="patch:focus-intent";function Sr(e){return `${Es}:${e}`}function Rs(e){try{let t=window.sessionStorage.getItem(Sr(e));if(!t)return null;window.sessionStorage.removeItem(Sr(e));let r=JSON.parse(t);return typeof r.id!="string"||typeof r.url!="string"?null:{id:r.id,url:r.url,viewport:r.viewport??"desktop"}}catch{return null}}function Is(e,t){try{window.sessionStorage.setItem(Sr(e),JSON.stringify(t));}catch{}}var oo=createContext(null);function Ns(e){return e==="pending"||e==="acknowledged"}function io({projectToken:e,children:t}){let{apiClient:r,active:n,viewerKind:o,annotations:s}=re(),i=o==="studio",[a,l]=useState([]),[c,d]=useState(false),[m,u]=useState(null),h=useRef(r);h.current=r;let v=useCallback(async()=>{if(!i){l([]),d(true);return}let f=await h.current.listRoster();l(f),d(true);},[i]);useEffect(()=>{if(!n||!i)return;let f=Rs(e);f&&ae(f.url)===ae(window.location.href)&&u(f),v();},[n,i,e,v]);let x=useMemo(()=>s.map(f=>`${f.id}:${f.status}`).sort().join(","),[s]),T=useRef(null);useEffect(()=>{if(!(!n||!i)){if(T.current===null){T.current=x;return}T.current!==x&&(T.current=x,v());}},[x,n,i,v]);let w=useCallback(f=>{let I={id:f.id,url:f.url,viewport:f.viewport};if(ae(f.url)===ae(window.location.href)){u(I);return}Is(e,I),window.location.assign(f.url);},[e]),g=useCallback(()=>u(null),[]),p=useMemo(()=>{let f=new Map;for(let I of s)f.set(I.id,I.status);return f},[s]),b=useMemo(()=>a.map(f=>{let I=p.get(f.id);return I&&I!==f.status?{...f,status:I}:f}),[a,p]),C=useMemo(()=>b.filter(f=>Ns(f.status)).length,[b]),A=useMemo(()=>({entries:b,ready:c,unresolvedCount:C,refresh:v,focusPin:w,pendingFocus:m,clearFocus:g}),[b,c,C,v,w,m,g]);return jsx(oo.Provider,{value:A,children:t})}function et(){let e=use(oo);if(!e)throw new Error("useRosterStore must be used inside <RosterProvider>");return e}var so=createContext(null);function lo({children:e}){let[t,r]=useState(false),[n,o]=useState(false),s=useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsx(so.Provider,{value:s,children:e})}function Le(){let e=use(so);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var co="[Patch] No project token found, widget disabled. Pass `projectToken` as a prop, or set NEXT_PUBLIC_PATCH_TOKEN (Next.js), VITE_PATCH_TOKEN (Vite / React Router), or PUBLIC_PATCH_TOKEN (Astro) in your env.";function uo(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();return o||null}function po(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function mo(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var Os=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 zs(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function go(e){return e.replace(/\s+/g," ").trim()}function Tr(e){return Os.has(go(e))}function fo(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=go(n[1]??"");!o||Tr(o)||t[t.length-1]!==o&&t.push(o);}return t.length===0?null:zs(t.map(n=>`<${n}>`).join(" "),1e3)}var ho="seed:";function Gt(e){return e?e.startsWith(ho)?{url:null,seed:e.slice(ho.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var Er=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],bo=[{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]}],vo=Math.PI*2;function Hs(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 Fs(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 X(e,t,r){return t+e()*(r-t)}function de(e,t=3){let r=10**t;return Math.round(e*r)/r}function xo(e,t,r){return `hsl(${de((e%360+360)%360,1)} ${de(t,1)}% ${de(r,1)}%)`}function wo(e){let t=Hs(e?.trim()||"patch-client"),r=Fs(t),n=t.toString(36),o=(Er[t%Er.length]??Er[0])+X(r,-10,10),s=r()<.5?-1:1,i=r()<.5?-1:1,a=o+i*X(r,52,116),l=o-i*X(r,26,66),c=o+s*X(r,12,38),d=xo(o+s*X(r,0,14),X(r,80,92),X(r,44,54)),m=X(r,0,vo),u=bo.map((h,v)=>{let T=(h.hue==="accent"?a:h.hue==="accent2"?l:h.hue==="near"?c:o)+X(r,-11,11),w=m+v/bo.length*vo+X(r,-0.6,.6),g=X(r,h.reach[0],h.reach[1]),p=de(.5+Math.cos(w)*g),b=de(.5+Math.sin(w)*g),C=de(X(r,0,180),1),A=de(X(r,.62,1.5),3),f=de(X(r,.62,1.5),3);return {id:`cav-${n}-${v}`,cx:p,cy:b,r:de(X(r,h.r[0],h.r[1])),color:xo(T,X(r,h.sat[0],h.sat[1]),X(r,h.light[0],h.light[1])),opacity:de(X(r,h.opacity[0],h.opacity[1]),2),gradientTransform:`rotate(${C} ${p} ${b}) translate(${p} ${b}) scale(${A} ${f}) translate(${de(-p)} ${de(-b)})`}});return {id:n,background:d,spots:u,blur:de(X(r,3.4,5.4),2),grain:de(X(r,.09,.15),2)}}function xt(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",s=e.anchor.x+e.anchor.width+t;s+n>e.viewport.width-r&&(o="left",s=e.anchor.x-n-t),s<r&&(s=r);let i=e.anchor.y;return i+e.popover.height>e.viewport.height-r&&(i=e.viewport.height-r-e.popover.height),i<r&&(i=r),{x:s,y:i,width:n,placement:o}}function M(...e){return e.filter(Boolean).join(" ")}function qt({seed:e,className:t,style:r}){let n=wo(e),o=useId().replace(/[^a-zA-Z0-9_-]/g,""),s=`${n.id}-${o}`,i=`cav-blur-${s}`,a=`cav-grain-${s}`;return jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:M("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxs("defs",{children:[jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxs("radialGradient",{id:`${s}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsx("rect",{width:"64",height:"64",fill:n.background}),jsx("g",{filter:`url(#${i})`,children:n.spots.map(l=>jsx("rect",{width:"64",height:"64",fill:`url(#${s}-${l.id})`},l.id))}),jsx("rect",{width:"64",height:"64",filter:`url(#${a})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Re=32,yo=[.22,.61,.36,1],Zt=["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 tt(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]??"",s=n[0]??"";return (o+s).toUpperCase()||"?"}function rt(e){if(!e)return Zt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Zt[Math.abs(t)%Zt.length]??Zt[0]}var Bs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},Ws={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function nt(e,t){let{placement:r}=xt({anchor:{x:e.viewportX-Re/2,y:e.viewportY-Re/2,width:Re,height:Re},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function jt(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Re,y:e.viewportY-Re,width:Re,height:Re}}function Rr({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?Ys[t.attention]:null,{url:o,seed:s}=Gt(t.avatarSrc),i=s??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 jsx(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] border-0 bg-transparent p-0",style:{width:Re,height:Re},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:yo}}:{opacity:0,scale:.9,transition:{duration:.12,ease:yo}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:Bs[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:Ws[r],background:"var(--color-muted-foreground)",filter:t.orphan?"grayscale(1)":"none",opacity:t.orphan?.55:1},children:[i?jsx(qt,{seed:i,style:{borderRadius:0,filter:a||"none",opacity:l}}):null,o?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:d=>{d.currentTarget.remove();}}):null]}),t.resolved&&jsx("span",{className:`absolute ${c} grid size-[14px] place-items-center rounded-full bg-brand-green text-[9px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsx("span",{"data-patch-attention":t.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[10px] rounded-full border-[1.5px] border-white ${n}`})]})})}var Ys={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function Jt(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 Co(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 Ao(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}var So={"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"}]],list:[["path",{d:"M8 5.5L20 5.5"}],["path",{d:"M8 12.5L20 12.5"}],["path",{d:"M8 19.5L20 19.5"}],["path",{d:"M4.375 5.5H4.25M4.5 5.5C4.5 5.63807 4.38807 5.75 4.25 5.75C4.11193 5.75 4 5.63807 4 5.5C4 5.36193 4.11193 5.25 4.25 5.25C4.38807 5.25 4.5 5.36193 4.5 5.5Z"}],["path",{d:"M4.375 12.5H4.25M4.5 12.5C4.5 12.6381 4.38807 12.75 4.25 12.75C4.11193 12.75 4 12.6381 4 12.5C4 12.3619 4.11193 12.25 4.25 12.25C4.38807 12.25 4.5 12.3619 4.5 12.5Z"}],["path",{d:"M4.375 19.5H4.25M4.5 19.5C4.5 19.6381 4.38807 19.75 4.25 19.75C4.11193 19.75 4 19.6381 4 19.5C4 19.3619 4.11193 19.25 4.25 19.25C4.38807 19.25 4.5 19.3619 4.5 19.5Z"}]],lock:[["path",{d:"M4.26781 18.8447C4.49269 20.515 5.87613 21.8235 7.55966 21.9009C8.97627 21.966 10.4153 22 12 22C13.5847 22 15.0237 21.966 16.4403 21.9009C18.1239 21.8235 19.5073 20.515 19.7322 18.8447C19.879 17.7547 20 16.6376 20 15.5C20 14.3624 19.879 13.2453 19.7322 12.1553C19.5073 10.485 18.1239 9.17649 16.4403 9.09909C15.0237 9.03397 13.5847 9 12 9C10.4153 9 8.97627 9.03397 7.55966 9.09909C5.87613 9.17649 4.49269 10.485 4.26781 12.1553C4.12104 13.2453 4 14.3624 4 15.5C4 16.6376 4.12104 17.7547 4.26781 18.8447Z"}],["path",{d:"M7.5 9V6.5C7.5 4.01472 9.51472 2 12 2C14.4853 2 16.5 4.01472 16.5 6.5V9"}],["path",{d:"M12.125 15.5H12M12.25 15.5C12.25 15.6381 12.1381 15.75 12 15.75C11.8619 15.75 11.75 15.6381 11.75 15.5C11.75 15.3619 11.8619 15.25 12 15.25C12.1381 15.25 12.25 15.3619 12.25 15.5Z"}]],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"}]],unlink:[["path",{d:"M12.1434 10.691L12.3503 10.4841C14.329 8.50532 17.5372 8.50532 19.5159 10.4841C21.4947 12.4628 21.4947 15.671 19.5159 17.6497L16.6497 20.5159C14.671 22.4947 11.4628 22.4947 9.48405 20.5159C7.50532 18.5372 7.50532 15.329 9.48405 13.3503L9.9484 12.886"}],["path",{d:"M20.0516 11.114L20.5159 10.6497C22.4947 8.67095 22.4947 5.46279 20.5159 3.48405C18.5372 1.50532 15.329 1.50532 13.3503 3.48405L10.4841 6.35031C8.50532 8.32904 8.50532 11.5372 10.4841 13.5159C12.4628 15.4947 15.671 15.4947 17.6497 13.5159L17.8566 13.309"}],["path",{d:"M4.5 4L6 6M2 8L5 9M3 13.5L5 12"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function F({name:e,size:t=16,stroke:r=2,color:n,className:o}){return 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:So[e].map(([s,i],a)=>createElement(s,{key:a,...i}))})}var Eo=[.16,1,.3,1];function Ks(e){try{let r=new URL(e).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return e}}function Qt(e){return e==="pending"||e==="acknowledged"}function Ro({onClose:e}){let t=et(),{hideResolvedAnnotations:r}=Le(),n=t.focusPin,o=typeof window>"u"?"":ae(window.location.href),s=useMemo(()=>[...r?t.entries.filter(d=>d.status!=="resolved"):t.entries].sort((d,m)=>(Qt(d.status)?0:1)-(Qt(m.status)?0:1)),[t.entries,r]),i=useMemo(()=>{let c=t.entries.filter(m=>Qt(m.status)&&ae(m.url)===o).length,d=t.entries.filter(m=>Qt(m.status)).length;return {here:c,elsewhere:d-c,total:d}},[t.entries,o]);function a(){if(i.total===0)return "No open feedback";let c=[`${i.total} open`];return i.here>0&&c.push(`${i.here} here`),i.elsewhere>0&&c.push(`${i.elsewhere} elsewhere`),c.join(" \xB7 ")}function l(c){e(),n(c);}return jsxs(motion.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease:Eo}},exit:{opacity:0,y:4,scale:.985,transition:{duration:.12,ease:Eo}},"data-patch-fab-dock":"","data-patch-roster-panel":"",className:"absolute right-0 bottom-[54px] z-[2147483647] flex max-h-[min(480px,calc(100vh-120px))] w-[min(360px,calc(100vw-40px))] flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:{transformOrigin:"100% 100%"},children:[jsxs("div",{className:"flex items-baseline justify-between gap-2 px-4 pt-3.5 pb-2.5",children:[jsx("span",{className:"text-[13px] font-semibold",children:"Feedback"}),jsx("span",{className:"text-[11.5px] font-medium text-popover-foreground/50",children:a()})]}),s.length===0?jsx("div",{className:"px-4 pt-2 pb-6 text-center text-[12.5px] text-popover-foreground/50",children:"No feedback yet."}):jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-2",children:s.map(c=>jsx(qs,{entry:c,onCurrentPage:ae(c.url)===o,onClick:()=>l(c)},c.id))})]})}function qs({entry:e,onCurrentPage:t,onClick:r}){let n=e.status==="resolved",o=e.anchorStatus==="detached";return jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-row":e.id,onClick:r,className:"flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-black/[0.04]",children:[jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsx(F,{name:"check",size:10,stroke:2.6})}):e.status==="dismissed"?jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxs("span",{className:"min-w-0 flex-1",children:[jsx("span",{className:M("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:e.label}),jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsx(F,{name:we[e.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsx("span",{className:"truncate",children:t?"This page":Ks(e.url)}),jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsx("span",{className:"shrink-0",children:Jt(e.createdAt)}),o?jsxs("span",{className:"ml-0.5 inline-flex shrink-0 items-center gap-1 rounded-full bg-black/[0.05] px-1.5 py-px text-[10px] font-medium text-popover-foreground/55",children:[jsx(F,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var Zs="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",js={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Oe({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:s="md",className:i,style:a}){let{url:l,seed:c}=Gt(r),d=c??n;return jsxs("span",{className:M(Zs,js[s],i),style:{background:t,...a},children:[jsx("span",{children:e}),!l&&d?jsx(qt,{seed:d}):null,l?jsx("img",{src:l,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:m=>{m.currentTarget.remove();}}):null]})}var Qs="M48 0C67.8823 0 84 16.1178 84 36V63C84 67.9706 79.9706 72 75 72H48C42.2522 72 36.8201 70.6505 32 68.2549V87C32 91.9706 27.9706 96 23 96H14C12.8954 96 12 95.1046 12 94V36C12 16.1178 28.1178 0 48 0ZM48 18C38.0589 18 30 26.0589 30 36C30 45.9411 38.0589 54 48 54C57.9411 54 66 45.9411 66 36C66 26.0589 57.9411 18 48 18Z",el="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 kt({size:e=16,className:t}){return jsx("svg",{width:e,height:e,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:t,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:Qs})})}function Io({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return 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:jsx("path",{d:el})})}var Nr=false,Xe=null,tr=null,ke={openDelay:700,isInstant(){return Nr},onOpen(e){tr&&tr!==e&&tr(),tr=e??null,Nr=true,Xe&&(clearTimeout(Xe),Xe=null);},onClose(){Xe&&clearTimeout(Xe),Xe=setTimeout(()=>{Nr=false,Xe=null;},300);}};var Mo="easeOut";function Ie({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[s,i]=useState(false),[a,l]=useState(false),c=useRef(null),d=useRef(false);useEffect(()=>()=>{c.current&&clearTimeout(c.current),d.current&&ke.onClose();},[]);let m=b=>{l(b),i(true),d.current=true,ke.onOpen();},u=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),ke.isInstant()){m(true);return}c.current=setTimeout(()=>{c.current=null,m(false);},ke.openDelay);},h=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,ke.onClose()),i(false);},v=n==="warning"?"pointer-events-none absolute bottom-[calc(100%+8px)] left-0 z-[1]":o==="bottom"?"pointer-events-none absolute top-[calc(100%+8px)] left-1/2 z-[1] -translate-x-1/2":"pointer-events-none absolute -top-[38px] left-1/2 z-[1] -translate-x-1/2",x="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-lg bg-foreground px-3 py-2.5 text-left text-[11px] leading-[1.35] font-medium text-white ${x}`:`relative block whitespace-nowrap rounded-md bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${x}`,w=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",g=o==="bottom"&&n!=="warning"?-3:3,p=o==="bottom"&&n!=="warning"?-2:2;return jsxs("span",{className:M("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:h,onMouseDown:h,children:[jsx("span",{className:v,children:jsx(AnimatePresence,{children:s&&jsxs(motion.span,{initial:a?false:{opacity:0,y:g,scale:.98},animate:{opacity:1,y:0,scale:1,transition:a?{duration:0}:{duration:.1,ease:Mo}},exit:{opacity:0,y:p,scale:.98,transition:{duration:.08,ease:Mo}},className:T,children:[n==="warning"?jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsx("span",{className:"min-w-0 flex-1",children:e}),jsx("span",{className:w})]})})}),t]})}var Do=44,Ne=[.16,1,.3,1],Lo="easeOut",il=.08,al=60,sl="calc(100% - 64px) calc(100% + 4px)",st="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function Oo(){let e=to(),t=xe(),r=re(),n=et(),{dockOpen:o,hideResolvedAnnotations:s,setDockOpen:i,setHideResolvedAnnotations:a}=Le(),l=!!r.studio,c=n.unresolvedCount,[d,m]=useState(false),[u,h]=useState(false),[v,x]=useState(false),[T,w]=useState(false),[g,p]=useState(false),[b,C]=useState(false),A=useRef(null),f=useRef(null),I=useRef(false),[Q,Z]=useState(false),be=useRef(null),[pe,oe]=useState(Do);useLayoutEffect(()=>{let z=be.current;if(!z)return;let ie=()=>oe(z.offsetWidth);ie();let Se=new ResizeObserver(ie);return Se.observe(z),()=>Se.disconnect()},[]);let ee=r.studio?r.studio.name:r.identity?.name??null,U=tt(ee),k=r.studio?.image??null,N=r.identity?.avatarSeed??r.clientAvatarSeed,_=r.studio?.userId??N,S=r.studio?"var(--color-foreground)":rt(N),L=r.studio&&!k?"#FFFFFF":S,H=r.studio&&!k?"text-foreground":"text-white",E=we[r.activeViewport];function te(){A.current!==null&&(window.clearTimeout(A.current),A.current=null);}function me(){f.current!==null&&(window.clearTimeout(f.current),f.current=null);}let P=useRef(()=>{});P.current=()=>{!I.current&&A.current===null||(te(),me(),I.current=false,C(true));};let D=useRef(()=>P.current()).current;useEffect(()=>{b&&d&&m(false);},[b,d]);function $(z){h(false),x(false),w(false),te(),me(),I.current=true,C(false),p(z),ke.onOpen(D),m(true);}function K(){$(false);}function Ae(){if(te(),!(I.current||f.current!==null)){if(ke.isInstant()){$(true);return}f.current=window.setTimeout(()=>{f.current=null,$(false);},ke.openDelay);}}function ge(){me(),te(),I.current&&(I.current=false,ke.onClose()),A.current=window.setTimeout(()=>{m(false),A.current=null;},120);}function Ve(){Z(true),i(true);}function It(){h(false),x(false),w(false),me(),I.current=false,m(false),e.isCapturing?e.exit():e.enter();}function Nt(){h(false),x(false),me(),I.current=false,m(false),w(z=>{let ie=!z;return ie&&n.refresh(),ie});}function ur(){Z(true),i(false),h(false),x(false),w(false),me(),I.current=false,m(false),e.exit(),t.active&&t.forceClose();}useEffect(()=>()=>{A.current!==null&&window.clearTimeout(A.current),f.current!==null&&window.clearTimeout(f.current);},[]);let R=()=>{r.signOut(),m(false);};function O(){x(false),w(false),me(),I.current=false,m(false),h(z=>!z);}function V(z){h(false),r.activeViewport!==z&&(t.active&&t.forceClose(),r.setActiveViewport(z));}function B(){h(false),w(false),me(),I.current=false,m(false),x(z=>!z);}function Y(){a(!s);}function pr(z){let ie=z.relatedTarget;ie instanceof Node&&z.currentTarget.contains(ie)||ge();}return jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxs(motion.div,{initial:false,animate:{width:o?pe:Do},transition:{duration:.36,ease:Ne},onAnimationComplete:()=>Z(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Ne}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Ne}},"data-patch-fab-dock":"",className:M("pkey-fab relative h-11 rounded-full",Q?"overflow-hidden":"overflow-visible"),children:[jsx(motion.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Ne},className:M("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsx("button",{type:"button",onClick:Ve,"data-patch-fab-dock":"","aria-label":l&&c>0?`Leave feedback \u2014 ${c} open`:"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsx(kt,{size:18})})}),jsxs("div",{ref:be,"data-patch-fab-dock":"",className:M("absolute inset-y-0 left-0 flex w-max items-center gap-1.5 px-1.5",o?"pointer-events-auto":"pointer-events-none"),children:[jsx(lt,{visible:o,index:0,children:jsx(Ie,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:It,className:M(st,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(Io,{variant:"outline",size:16})})})}),l?jsx(lt,{visible:o,index:1,children:jsx(Ie,{text:"Feedback",children:jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-btn":"","aria-label":c>0?`Feedback \u2014 ${c} open`:"Feedback","aria-expanded":T,onClick:Nt,className:M(st,"relative transition-colors",T||c>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsx(F,{name:"list",size:15}),c>0?jsx("span",{className:"pointer-events-none absolute -top-0.5 -right-0.5 grid h-[15px] min-w-[15px] place-items-center rounded-full bg-brand px-1 text-[9px] font-semibold text-white",children:c>99?"99+":c}):null]})})}):null,jsx(lt,{visible:o,index:2,children:jsxs("div",{className:"relative flex items-center",children:[jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${E.label}`,"aria-expanded":u,onClick:O,className:M(st,"transition-colors",r.activeViewport==="desktop"&&!u?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx(F,{name:E.glyph,size:15})}),jsx(AnimatePresence,{children:u?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Ne}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Ne}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),qr.map(z=>{let ie=we[z],Se=r.activeViewport===z;return jsx(Ie,{text:Ke(z),children:jsx("button",{type:"button","data-patch-viewport-option":z,"aria-label":Ke(z),"aria-pressed":Se,onClick:()=>V(z),className:M("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",Se?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(F,{name:ie.glyph,size:15})})},z)})]}):null})]})}),jsx(lt,{visible:o,index:3,children:jsxs("div",{className:"relative flex items-center",children:[jsx(Ie,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":v,onClick:B,className:M(st,"transition-colors",v||s?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(F,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:v?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Ne}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Ne}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-xl p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsx("input",{type:"checkbox",checked:s,"aria-label":"Hide resolved annotations",onChange:Y,className:"peer sr-only"}),jsx("span",{"aria-hidden":"true",className:M("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",s?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsx(F,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(lt,{visible:o,index:4,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Ae,onMouseLeave:ge,onFocus:K,onBlur:pr,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":ee?`Account: ${ee}`:"Identify",className:M(st,"text-white"),children:ee?jsx(Oe,{initials:U,tint:L,src:k,generatedSeed:_,alt:ee,size:"sm",className:M("size-[22px] text-[9.5px] ring-1 ring-white/20",H)}):jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsx(AnimatePresence,{children:d?jsxs(motion.div,{initial:g?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:g?{duration:0}:{duration:.12,delay:il,ease:Lo}},exit:{opacity:0,y:2,scale:.98,transition:b?{duration:0}:{duration:.08,ease:Lo}},"data-patch-fab-dock":"","data-patch-identity-popover":"",className:"fixed right-8 bottom-[72px] z-[2147483647] w-[min(272px,calc(100vw-40px))] min-w-[220px] rounded-xl bg-foreground p-3.5 font-sans text-[13px] text-white shadow-[0_18px_44px_-14px_rgba(0,0,0,0.5),0_6px_14px_-6px_rgba(0,0,0,0.45)] ring-1 ring-white/10",style:{transformOrigin:sl},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:al}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Oe,{initials:U,tint:S,src:k,generatedSeed:_,alt:r.studio.name,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Oe,{initials:U,tint:S,generatedSeed:_,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsx("div",{className:"my-3 h-px bg-white/10"}),jsx("button",{type:"button",onClick:R,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsx(lt,{visible:o,index:5,children:jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsx(Ie,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:ur,className:M(st,"text-white/70"),children:jsx(F,{name:"x",size:14})})})]})})]})]}),l&&!o&&c>0?jsx("span",{"data-patch-fab-dock":"","data-patch-roster-badge":"","aria-hidden":"true",className:"pointer-events-none absolute -top-1 -right-1 grid h-[18px] min-w-[18px] place-items-center rounded-full bg-brand px-1 text-[10.5px] font-semibold text-white shadow-[0_1px_3px_rgba(0,0,0,0.3)]",children:c>99?"99+":c}):null,jsx(AnimatePresence,{children:T?jsx(Ro,{onClose:()=>w(false)}):null})]})}function lt({children:e,visible:t,index:r}){return jsx(motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Ne}}:{opacity:0,x:6,transition:{duration:.12,ease:Ne}},children:e})}function zo(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 Ho(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var cl=.6,dl=.5,nr={text:.4,attrs:.3,classes:.2,position:.1},ul=5e3,pl=.08,ml=.12;function gl(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function fl(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 hl(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 i of r)n.has(i)&&o++;let s=r.size+n.size-o;return s===0?0:o/s}function $o(e){let t=e.payload.boundingBox;if(!t)return null;let r=e.payload.coordinates.documentY-e.payload.coordinates.viewportY;return {x:t.x+t.width/2,y:t.y+t.height/2+r}}function Mr(e,t,r){if(!t)return .5;let n=e.left+e.width/2,o=e.top+r.scrollY+e.height/2,s=(n-t.x)/Math.max(1,r.viewport.width),i=(o-t.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(s*s+i*i))}function bl(e,t){let r=Ht(e),n=zt(e),o=Ye(e),s=e.getBoundingClientRect(),i=gl(r,t.payload.domHints?.textSignature),a=fl(n,t.payload.domHints?.attributeSignature),l=hl(o,t.payload.cssClasses),c=Mr(s,$o(t),t);return nr.text*i+nr.attrs*a+nr.classes*l+nr.position*c}function vl(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function Fo(e,t,r){let n=null,o=null,s=0;for(let i=0;i<e.length&&!(s>=ul);i++){let a=e[i];if(!a||(s++,Ft(a,t.internalAttr)))continue;let l=a.tagName.toLowerCase();if(l==="html"||l==="head"||l==="script"||l==="style"||vl(a))continue;let c=bl(a,t);!n||c>n.score?(o=n,n={el:a,score:c}):(!o||c>o.score)&&(o={el:a,score:c});}if(!n||n.score<r)return null;if(o&&n.score-o.score<pl){let i=$o(t),a=Mr(n.el.getBoundingClientRect(),i,t),l=Mr(o.el.getBoundingClientRect(),i,t);if(a-l<ml)return null}return n.el}function xl(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function wl(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=zo({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return Ho(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function yl(e){let t=e.payload.domHints?.cssSelector;if(!t)return [];try{return Array.from(e.doc.querySelectorAll(t))}catch{return []}}function or(e){if(!e.payload.domHints)return {kind:"positional",el:null};let t=yl(e);if(t.length>0){let n=Fo(t,e,dl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Fo(e.doc.querySelectorAll("*"),e,cl);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function _r(e,t){return e.kind==="anchored"&&e.el?wl(e.el,t):xl(t)}function Vo(e){let t=or(e);return {kind:t.kind,tier:t.tier,el:t.el,position:_r(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 Cl="data-patch-internal";function ir(e,t,r){let n=nt(r,t.getOverlayViewport()),o=jt(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function Uo(e,t){return Math.abs(e.viewportX-t.viewportX)<.5&&Math.abs(e.viewportY-t.viewportY)<.5}function Al(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function Or(e,t){return {payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:Cl}}function Xo(e,t,r){let n=Or(e,t);return {kind:r.kind,position:e.targetPointToOverlay(_r(r,n))}}function Sl(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function Go(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:s,apiClient:i}=re(),a=xe(),{dockOpen:l,hideResolvedAnnotations:c}=Le(),d=ce(),{isPreviewing:m,previewReady:u}=Je(),h=useReducedMotion(),v=a.active,x=a.forceClose,T=t&&(!m||u),w=useMemo(()=>l&&t?e.filter(k=>!c||k.status!=="resolved"):[],[l,t,e,c]),g=useMemo(()=>l&&t?r:[],[l,t,r]);useEffect(()=>{if(!c||v?.kind!=="existing")return;e.find(N=>N.id===v.annotationId)?.status==="resolved"&&x();},[v,e,x,c]);let p=useRef(new Map),b=useRef(new Map),C=useRef(new Map),A=useRef(new Map),f=useMemo(()=>{let k=A.current,N=new Set,_=new Map;for(let S of w){N.add(S.id);let L=k.get(S.id),E=L?.kind==="positional"||L?.kind==="anchored"&&L.el?.isConnected?L:or(Or(d,S));k.set(S.id,E),_.set(S.id,Xo(d,S,E));}for(let S of k.keys())N.has(S)||k.delete(S);return _},[d,w]),I=useCallback(()=>{let k=A.current,N=C.current,_=new Set;for(let S of w){let L=p.current.get(S.id);if(!L)continue;_.add(S.id);let H=k.get(S.id);if((!H||H.kind==="anchored"&&H.el&&!H.el.isConnected)&&(H=or(Or(d,S)),k.set(S.id,H)),H.kind==="detached"||H.kind==="anchored"&&H.el&&Al(H.el)){L.style.visibility!=="hidden"&&(L.style.visibility="hidden"),N.delete(S.id);continue}L.style.visibility==="hidden"&&(L.style.visibility="");let E=Xo(d,S,H).position,te=N.get(S.id);te&&Uo(te,E)||(N.set(S.id,E),ir(L,d,E));}for(let S of g){let L=b.current.get(S.tempId);if(!L)continue;_.add(S.tempId);let H=Sl(d,S),E=N.get(S.tempId);E&&Uo(E,H)||(N.set(S.tempId,H),ir(L,d,H));}for(let S of N.keys())_.has(S)||N.delete(S);},[d,w,g]),Q=w.length>0||g.length>0;useEffect(()=>{if(!Q)return;let k=d.overlayWindow,N=k.requestAnimationFrame(function _(){I(),N=k.requestAnimationFrame(_);});return ()=>k.cancelAnimationFrame(N)},[Q,I,d]);let Z=useRef(new Map);useEffect(()=>{if(!t||w.length===0)return;let k=setTimeout(()=>{let N=[];for(let _ of w){let S=f.get(_.id);if(!S)continue;let L=S.kind!=="detached";Z.current.get(_.id)!==L&&(Z.current.set(_.id,L),N.push({id:_.id,present:L}));}i.reportAnchorStatuses(N);},1500);return ()=>clearTimeout(k)},[f,w,t,i]);let be=useCallback(k=>{if(a.active&&a.draftText.trim().length>0){a.attemptClose();return}a.openExisting(k);},[a]),pe=o?o.name:n?.name??null,oe=o?.image??null,ee=n?.avatarSeed??s,U=o?.userId??ee;return jsxs("div",{"data-patch-pin-layer":"",style:{opacity:T?1:0,transition:h||!T?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:T?void 0:"none"},children:[jsx(AnimatePresence,{initial:false,children:w.map(k=>{let N=f.get(k.id);if(N?.kind==="detached")return null;let _=Tl(k),S=!o&&!!n?.clientUserId&&k.payload.authorRole==="client"&&k.payload.authorId===n.clientUserId,L=o?Bo(k):null,H=N?nt(N.position,d.getOverlayViewport()):"right";return jsx(Rr,{ref:E=>{E?(p.current.set(k.id,E),N&&ir(E,d,N.position)):p.current.delete(k.id);},avatarSrc:_.image,generatedSeed:S?ee:_.generatedSeed,avatarAlt:_.name??"",resolved:k.status==="resolved",attention:L,orphan:N?.kind==="positional",pointSide:H,ariaLabel:`Annotation by ${k.authorName??"someone"}`,onClick:()=>be(k.id),pinId:k.id},k.id)})}),jsx(AnimatePresence,{initial:false,children:g.map(k=>{let N=d.targetPointToOverlay({viewportX:k.viewportX,viewportY:k.viewportY});return jsx(Rr,{ref:_=>{_?(b.current.set(k.tempId,_),ir(_,d,N)):b.current.delete(k.tempId);},avatarSrc:oe,generatedSeed:U,avatarAlt:pe??"",resolved:false,pointSide:nt(N,d.getOverlayViewport()),ephemeral:true},k.tempId)})})]})}function Tl(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 Pl=5e3;function qo(){let e=et(),t=re(),r=xe(),n=Le(),o=ce(),s=useReducedMotion(),i=e.pendingFocus,a=useRef(null),l=useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return useEffect(()=>{if(!i)return;if(ae(window.location.href)!==ae(i.url)){e.clearFocus();return}if(n.dockOpen||n.setDockOpen(true),t.activeViewport!==i.viewport){t.setActiveViewport(i.viewport);return}if(!t.annotationsReady)return;let c=t.annotations.find(m=>m.id===i.id);if(!c){a.current===null&&(a.current=window.setTimeout(()=>{a.current=null,e.clearFocus();},Pl));return}l();let d=c.payload.coordinates?.documentY;if(typeof d=="number"){let m=o.getTargetViewport().height;o.targetWindow.scrollTo({top:Math.max(0,d-m/3),behavior:s?"auto":"smooth"});}r.openExisting(i.id),e.clearFocus();},[i,t,n,o,s,r,e,l]),useEffect(()=>()=>l(),[l]),null}var Zo=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
5
5
  @layer properties;
6
6
  @layer theme, base, components, utilities;
7
7
  @layer theme {
@@ -21,10 +21,11 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
21
21
  --font-weight-medium: 500;
22
22
  --font-weight-semibold: 600;
23
23
  --font-weight-bold: 700;
24
+ --leading-snug: 1.375;
24
25
  --leading-normal: 1.5;
25
- --radius-lg: 1.25rem;
26
- --radius-xl: 0.75rem;
27
- --radius-2xl: 1rem;
26
+ --radius-md: 0.5rem;
27
+ --radius-lg: 0.75rem;
28
+ --radius-xl: 1rem;
28
29
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
29
30
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
30
31
  --default-transition-duration: 150ms;
@@ -32,14 +33,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
32
33
  --default-font-family: var(--font-sans);
33
34
  --default-mono-font-family: var(--font-mono);
34
35
  --radius: var(--radius-lg);
35
- --color-foreground: oklch(0.18 0 0);
36
- --color-popover: oklch(1 0 0);
37
- --color-popover-foreground: oklch(0.18 0 0);
38
- --color-primary: oklch(0.18 0 0);
39
- --color-primary-foreground: oklch(1 0 0);
40
- --color-muted-foreground: oklch(0.62 0 0);
36
+ --color-foreground: oklch(0.19 0.005 265);
37
+ --color-popover: oklch(0.998 0.0015 265);
38
+ --color-popover-foreground: oklch(0.19 0.005 265);
39
+ --color-muted-foreground: oklch(0.6 0.008 265);
41
40
  --color-destructive: oklch(0.55 0.2 27);
42
- --color-border: oklch(0.92 0 0);
41
+ --color-border: oklch(0.925 0.005 265);
43
42
  --color-ring: oklch(0.60 0.21 250 / 0.40);
44
43
  --color-brand: #0287FE;
45
44
  --color-brand-tint: rgba(2, 135, 254, 0.10);
@@ -242,6 +241,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
242
241
  .inset-\\[2px\\] {
243
242
  inset: 2px;
244
243
  }
244
+ .inset-y-0 {
245
+ inset-block: calc(var(--spacing) * 0);
246
+ }
245
247
  .start {
246
248
  inset-inline-start: var(--spacing);
247
249
  }
@@ -269,6 +271,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
269
271
  .-right-0\\.5 {
270
272
  right: calc(var(--spacing) * -0.5);
271
273
  }
274
+ .-right-1 {
275
+ right: calc(var(--spacing) * -1);
276
+ }
272
277
  .right-0 {
273
278
  right: calc(var(--spacing) * 0);
274
279
  }
@@ -293,6 +298,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
293
298
  .bottom-\\[46px\\] {
294
299
  bottom: 46px;
295
300
  }
301
+ .bottom-\\[54px\\] {
302
+ bottom: 54px;
303
+ }
296
304
  .bottom-\\[72px\\] {
297
305
  bottom: 72px;
298
306
  }
@@ -413,13 +421,13 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
413
421
  width: 7px;
414
422
  height: 7px;
415
423
  }
416
- .size-\\[9px\\] {
417
- width: 9px;
418
- height: 9px;
424
+ .size-\\[10px\\] {
425
+ width: 10px;
426
+ height: 10px;
419
427
  }
420
- .size-\\[13px\\] {
421
- width: 13px;
422
- height: 13px;
428
+ .size-\\[14px\\] {
429
+ width: 14px;
430
+ height: 14px;
423
431
  }
424
432
  .size-\\[22px\\] {
425
433
  width: 22px;
@@ -445,9 +453,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
445
453
  .h-11 {
446
454
  height: calc(var(--spacing) * 11);
447
455
  }
456
+ .h-\\[15px\\] {
457
+ height: 15px;
458
+ }
459
+ .h-\\[18px\\] {
460
+ height: 18px;
461
+ }
448
462
  .h-px {
449
463
  height: 1px;
450
464
  }
465
+ .max-h-\\[min\\(480px\\,calc\\(100vh-120px\\)\\)\\] {
466
+ max-height: min(480px, calc(100vh - 120px));
467
+ }
451
468
  .min-h-0 {
452
469
  min-height: calc(var(--spacing) * 0);
453
470
  }
@@ -463,9 +480,15 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
463
480
  .w-\\[min\\(272px\\,calc\\(100vw-40px\\)\\)\\] {
464
481
  width: min(272px, calc(100vw - 40px));
465
482
  }
483
+ .w-\\[min\\(360px\\,calc\\(100vw-40px\\)\\)\\] {
484
+ width: min(360px, calc(100vw - 40px));
485
+ }
466
486
  .w-full {
467
487
  width: 100%;
468
488
  }
489
+ .w-max {
490
+ width: max-content;
491
+ }
469
492
  .w-px {
470
493
  width: 1px;
471
494
  }
@@ -487,6 +510,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
487
510
  .min-w-40 {
488
511
  min-width: calc(var(--spacing) * 40);
489
512
  }
513
+ .min-w-\\[15px\\] {
514
+ min-width: 15px;
515
+ }
516
+ .min-w-\\[18px\\] {
517
+ min-width: 18px;
518
+ }
490
519
  .min-w-\\[220px\\] {
491
520
  min-width: 220px;
492
521
  }
@@ -601,45 +630,27 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
601
630
  .rounded {
602
631
  border-radius: var(--radius);
603
632
  }
604
- .rounded-2xl {
605
- border-radius: var(--radius-2xl);
606
- }
607
633
  .rounded-\\[2px\\] {
608
634
  border-radius: 2px;
609
635
  }
610
636
  .rounded-\\[5px\\] {
611
637
  border-radius: 5px;
612
638
  }
613
- .rounded-\\[10px\\] {
614
- border-radius: 10px;
615
- }
616
- .rounded-\\[14px\\] {
617
- border-radius: 14px;
618
- }
619
- .rounded-\\[16px\\] {
620
- border-radius: 16px;
621
- }
622
- .rounded-\\[18px\\] {
623
- border-radius: 18px;
624
- }
625
- .rounded-\\[20px\\] {
626
- border-radius: 20px;
627
- }
628
- .rounded-\\[22px\\] {
629
- border-radius: 22px;
630
- }
631
639
  .rounded-full {
632
640
  border-radius: calc(infinity * 1px);
633
641
  }
634
642
  .rounded-lg {
635
643
  border-radius: var(--radius-lg);
636
644
  }
645
+ .rounded-md {
646
+ border-radius: var(--radius-md);
647
+ }
637
648
  .rounded-xl {
638
649
  border-radius: var(--radius-xl);
639
650
  }
640
- .rounded-b-\\[22px\\] {
641
- border-bottom-right-radius: 22px;
642
- border-bottom-left-radius: 22px;
651
+ .rounded-b-xl {
652
+ border-bottom-right-radius: var(--radius-xl);
653
+ border-bottom-left-radius: var(--radius-xl);
643
654
  }
644
655
  .border {
645
656
  border-style: var(--tw-border-style);
@@ -691,6 +702,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
691
702
  border-color: color-mix(in oklab, var(--color-black) 16%, transparent);
692
703
  }
693
704
  }
705
+ .border-black\\/20 {
706
+ border-color: color-mix(in srgb, #000 20%, transparent);
707
+ @supports (color: color-mix(in lab, red, red)) {
708
+ border-color: color-mix(in oklab, var(--color-black) 20%, transparent);
709
+ }
710
+ }
694
711
  .border-black\\/\\[0\\.07\\] {
695
712
  border-color: color-mix(in srgb, #000 7.000000000000001%, transparent);
696
713
  @supports (color: color-mix(in lab, red, red)) {
@@ -760,6 +777,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
760
777
  background-color: color-mix(in oklab, var(--color-black) 3%, transparent);
761
778
  }
762
779
  }
780
+ .bg-black\\/\\[0\\.05\\] {
781
+ background-color: color-mix(in srgb, #000 5%, transparent);
782
+ @supports (color: color-mix(in lab, red, red)) {
783
+ background-color: color-mix(in oklab, var(--color-black) 5%, transparent);
784
+ }
785
+ }
763
786
  .bg-brand {
764
787
  background-color: var(--color-brand);
765
788
  }
@@ -817,9 +840,6 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
817
840
  .bg-popover {
818
841
  background-color: var(--color-popover);
819
842
  }
820
- .bg-primary {
821
- background-color: var(--color-primary);
822
- }
823
843
  .bg-transparent {
824
844
  background-color: transparent;
825
845
  }
@@ -901,9 +921,6 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
901
921
  .py-1 {
902
922
  padding-block: calc(var(--spacing) * 1);
903
923
  }
904
- .py-1\\.5 {
905
- padding-block: calc(var(--spacing) * 1.5);
906
- }
907
924
  .py-2 {
908
925
  padding-block: calc(var(--spacing) * 2);
909
926
  }
@@ -925,6 +942,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
925
942
  .py-\\[7px\\] {
926
943
  padding-block: 7px;
927
944
  }
945
+ .py-px {
946
+ padding-block: 1px;
947
+ }
948
+ .pt-2 {
949
+ padding-top: calc(var(--spacing) * 2);
950
+ }
928
951
  .pt-3\\.5 {
929
952
  padding-top: calc(var(--spacing) * 3.5);
930
953
  }
@@ -934,9 +957,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
934
957
  .pr-8 {
935
958
  padding-right: calc(var(--spacing) * 8);
936
959
  }
960
+ .pb-2 {
961
+ padding-bottom: calc(var(--spacing) * 2);
962
+ }
963
+ .pb-2\\.5 {
964
+ padding-bottom: calc(var(--spacing) * 2.5);
965
+ }
937
966
  .pb-3 {
938
967
  padding-bottom: calc(var(--spacing) * 3);
939
968
  }
969
+ .pb-6 {
970
+ padding-bottom: calc(var(--spacing) * 6);
971
+ }
940
972
  .pl-2\\.5 {
941
973
  padding-left: calc(var(--spacing) * 2.5);
942
974
  }
@@ -953,15 +985,21 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
953
985
  font-size: var(--text-xs);
954
986
  line-height: var(--tw-leading, var(--text-xs--line-height));
955
987
  }
956
- .text-\\[8px\\] {
957
- font-size: 8px;
958
- }
959
988
  .text-\\[9\\.5px\\] {
960
989
  font-size: 9.5px;
961
990
  }
991
+ .text-\\[9px\\] {
992
+ font-size: 9px;
993
+ }
962
994
  .text-\\[10\\.5px\\] {
963
995
  font-size: 10.5px;
964
996
  }
997
+ .text-\\[10px\\] {
998
+ font-size: 10px;
999
+ }
1000
+ .text-\\[11\\.5px\\] {
1001
+ font-size: 11.5px;
1002
+ }
965
1003
  .text-\\[11px\\] {
966
1004
  font-size: 11px;
967
1005
  }
@@ -997,6 +1035,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
997
1035
  --tw-leading: var(--leading-normal);
998
1036
  line-height: var(--leading-normal);
999
1037
  }
1038
+ .leading-snug {
1039
+ --tw-leading: var(--leading-snug);
1040
+ line-height: var(--leading-snug);
1041
+ }
1000
1042
  .font-bold {
1001
1043
  --tw-font-weight: var(--font-weight-bold);
1002
1044
  font-weight: var(--font-weight-bold);
@@ -1050,8 +1092,23 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
1050
1092
  .text-popover-foreground {
1051
1093
  color: var(--color-popover-foreground);
1052
1094
  }
1053
- .text-primary-foreground {
1054
- color: var(--color-primary-foreground);
1095
+ .text-popover-foreground\\/45 {
1096
+ color: color-mix(in srgb, oklch(0.19 0.005 265) 45%, transparent);
1097
+ @supports (color: color-mix(in lab, red, red)) {
1098
+ color: color-mix(in oklab, var(--color-popover-foreground) 45%, transparent);
1099
+ }
1100
+ }
1101
+ .text-popover-foreground\\/50 {
1102
+ color: color-mix(in srgb, oklch(0.19 0.005 265) 50%, transparent);
1103
+ @supports (color: color-mix(in lab, red, red)) {
1104
+ color: color-mix(in oklab, var(--color-popover-foreground) 50%, transparent);
1105
+ }
1106
+ }
1107
+ .text-popover-foreground\\/55 {
1108
+ color: color-mix(in srgb, oklch(0.19 0.005 265) 55%, transparent);
1109
+ @supports (color: color-mix(in lab, red, red)) {
1110
+ color: color-mix(in oklab, var(--color-popover-foreground) 55%, transparent);
1111
+ }
1055
1112
  }
1056
1113
  .text-transparent {
1057
1114
  color: transparent;
@@ -1080,6 +1137,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
1080
1137
  .lowercase {
1081
1138
  text-transform: lowercase;
1082
1139
  }
1140
+ .line-through {
1141
+ text-decoration-line: line-through;
1142
+ }
1083
1143
  .no-underline {
1084
1144
  text-decoration-line: none;
1085
1145
  }
@@ -1089,6 +1149,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
1089
1149
  .opacity-60 {
1090
1150
  opacity: 60%;
1091
1151
  }
1152
+ .opacity-80 {
1153
+ opacity: 80%;
1154
+ }
1092
1155
  .shadow {
1093
1156
  --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
1094
1157
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
@@ -1097,6 +1160,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
1097
1160
  --tw-shadow: 0 0 0 1px var(--tw-shadow-color, rgba(0,0,0,0.06));
1098
1161
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1099
1162
  }
1163
+ .shadow-\\[0_1px_3px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\] {
1164
+ --tw-shadow: 0 1px 3px var(--tw-shadow-color, rgba(0,0,0,0.3));
1165
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1166
+ }
1100
1167
  .shadow-\\[0_6px_12px_-5px_rgba\\(0\\,0\\,0\\,0\\.16\\)\\] {
1101
1168
  --tw-shadow: 0 6px 12px -5px var(--tw-shadow-color, rgba(0,0,0,0.16));
1102
1169
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
@@ -1215,6 +1282,16 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
1215
1282
  }
1216
1283
  }
1217
1284
  }
1285
+ .hover\\:bg-black\\/\\[0\\.04\\] {
1286
+ &:hover {
1287
+ @media (hover: hover) {
1288
+ background-color: color-mix(in srgb, #000 4%, transparent);
1289
+ @supports (color: color-mix(in lab, red, red)) {
1290
+ background-color: color-mix(in oklab, var(--color-black) 4%, transparent);
1291
+ }
1292
+ }
1293
+ }
1294
+ }
1218
1295
  .hover\\:bg-brand-green\\/15 {
1219
1296
  &:hover {
1220
1297
  @media (hover: hover) {
@@ -1265,16 +1342,6 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
1265
1342
  }
1266
1343
  }
1267
1344
  }
1268
- .hover\\:bg-primary\\/90 {
1269
- &:hover {
1270
- @media (hover: hover) {
1271
- background-color: color-mix(in srgb, oklch(0.18 0 0) 90%, transparent);
1272
- @supports (color: color-mix(in lab, red, red)) {
1273
- background-color: color-mix(in oklab, var(--color-primary) 90%, transparent);
1274
- }
1275
- }
1276
- }
1277
- }
1278
1345
  .hover\\:bg-white\\/\\[0\\.08\\] {
1279
1346
  &:hover {
1280
1347
  @media (hover: hover) {
@@ -1381,23 +1448,23 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
1381
1448
  font-feature-settings: "cv11", "ss01";
1382
1449
  letter-spacing: -0.011em;
1383
1450
  cursor: auto;
1384
- --color-background: oklch(0.985 0 0);
1385
- --color-foreground: oklch(0.18 0 0);
1386
- --color-card: oklch(1 0 0);
1387
- --color-card-foreground: oklch(0.18 0 0);
1388
- --color-popover: oklch(1 0 0);
1389
- --color-popover-foreground: oklch(0.18 0 0);
1390
- --color-primary: oklch(0.18 0 0);
1391
- --color-primary-foreground: oklch(1 0 0);
1392
- --color-secondary: oklch(0.945 0 0);
1393
- --color-secondary-foreground: oklch(0.18 0 0);
1394
- --color-muted: oklch(0.945 0 0);
1395
- --color-muted-foreground: oklch(0.62 0 0);
1451
+ --color-background: oklch(0.985 0.003 265);
1452
+ --color-foreground: oklch(0.19 0.005 265);
1453
+ --color-card: oklch(0.998 0.0015 265);
1454
+ --color-card-foreground: oklch(0.19 0.005 265);
1455
+ --color-popover: oklch(0.998 0.0015 265);
1456
+ --color-popover-foreground: oklch(0.19 0.005 265);
1457
+ --color-primary: oklch(0.19 0.005 265);
1458
+ --color-primary-foreground: oklch(0.99 0.0015 265);
1459
+ --color-secondary: oklch(0.948 0.004 265);
1460
+ --color-secondary-foreground: oklch(0.19 0.005 265);
1461
+ --color-muted: oklch(0.948 0.004 265);
1462
+ --color-muted-foreground: oklch(0.6 0.008 265);
1396
1463
  --color-accent: oklch(0.60 0.21 250);
1397
1464
  --color-accent-foreground: oklch(1 0 0);
1398
1465
  --color-destructive: oklch(0.55 0.2 27);
1399
- --color-border: oklch(0.92 0 0);
1400
- --color-input: oklch(0.92 0 0);
1466
+ --color-border: oklch(0.925 0.005 265);
1467
+ --color-input: oklch(0.905 0.006 265);
1401
1468
  --color-ring: oklch(0.60 0.21 250 / 0.40);
1402
1469
  --color-brand: #0287FE;
1403
1470
  --color-brand-hover: #0173D6;
@@ -1410,9 +1477,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,use,createEl
1410
1477
  --color-avatar-tint-4: #525252;
1411
1478
  --color-avatar-tint-5: #3D3D3D;
1412
1479
  --radius-pill: 9999px;
1413
- --radius-sm: 0.625rem;
1414
- --radius-md: 1rem;
1415
- --radius-lg: 1.25rem;
1480
+ --radius-sm: 0.375rem;
1481
+ --radius-md: 0.5rem;
1482
+ --radius-lg: 0.75rem;
1483
+ --radius-xl: 1rem;
1416
1484
  --radius: var(--radius-lg);
1417
1485
  --shadow-subtle: 0 1px 2px 0 oklch(0 0 0 / 0.04);
1418
1486
  --shadow-card: 0 2px 8px -2px oklch(0 0 0 / 0.06), 0 4px 12px -4px oklch(0 0 0 / 0.04);
@@ -1887,5 +1955,5 @@ button:not(:disabled):not(.pkey):active {
1887
1955
  }
1888
1956
  }
1889
1957
  }
1890
- `;var Ro="patch-widget-root";function Io({children:e}){let[t,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(Ro);o||(o=document.createElement(Ro),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let a=o.shadowRoot??o.attachShadow({mode:"open"});if(!a.querySelector("style[data-patch-css]")){let i=document.createElement("style");i.setAttribute("data-patch-css",""),i.textContent=Eo,a.appendChild(i);}let s=a.querySelector("div[data-patch-mount]");return s||(s=document.createElement("div"),s.setAttribute("data-patch-mount",""),a.appendChild(s)),r(s),()=>{}},[]),t?createPortal(e,t):null}var ol=/[\s#.:[\]()>+~,\\]/;function il(e){return !(!e||ol.test(e)||/^\d/.test(e))}function al(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Po(e,t,r){try{let n=e.querySelectorAll(t);return n.length===1&&n[0]===r}catch{return false}}function sl(e,t){return e.id&&il(e.id)&&(!t||Po(t,`#${e.id}`,e))?`#${e.id}`:`${e.tagName.toLowerCase()}:nth-of-type(${al(e)})`}function No(e,t){if(!e.tagName)return "";let r=e.ownerDocument??null,n=[],o=e,a=0;for(;o&&a<12;){let s=sl(o,r);if(n.unshift(s),s.startsWith("#"))break;let i=n.join(" > ");if(r&&Po(r,i,e))return i;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,a++;}return n.join(" > ")}var ll=80,cl=500;function _o(e){return e!==null&&typeof e=="object"}function dl(e){return _o(e)?"return"in e||"type"in e||"elementType"in e||"_debugOwner"in e:false}function Qt(e){if(typeof e=="function")return e.displayName||e.name||null;if(!_o(e))return null;let t=e.displayName;if(typeof t=="string"&&t)return t;let r=Qt(e.render);if(r)return r;let n=Qt(e.type);return n||null}function Do(e){return e.replace(/\s+/g," ").trim()}function Oo(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function ul(e){let t=Do(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:Oo(t,ll)}function pl(e){let t=Qt(e.elementType)??Qt(e.type);return t?ul(t):null}function Mo(e){return Oo(Do(e),cl)}function ml(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 gl(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 Mo(t.slice(o+1))}let r=t.split("/").filter(Boolean);return Mo(r.slice(-3).join("/"))}function fl(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||ml(t)?null:gl(t)}function hl(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(dl(n))return n}return null}function Tr(e){let t=hl(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let i=pl(t),l=i?mr(i):false;i&&!l&&r[r.length-1]!==i&&r.push(i),l||(n??=fl(t)),t=t.return??t._debugOwner??null,o+=1;}let a=r.length>0?Qn(r.reverse().map(i=>`<${i}>`).join(" ")):null,s={};return a&&(s.reactComponents=a),n&&(s.sourceFile=n),Object.keys(s).length>0?s:null}var Lo=500,zo=3;function bl(e){return e.length<=Lo?e:e.slice(0,Lo)}function Sr(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function er(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Ho(e){let t={cssSelector:No(e)},r=Mt(e);r&&(t.textSignature=r);let n=Nt(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function Fo(e){return e.kind==="element"?lt(e.element,e.selectedText):e.kind==="multi"?Ot(e.elements.length):Lt()}function Vo(e){let{target:t,click:r,comment:n,url:o}=e,a=t.element,s=t.rect,i=xn(a),l=yn(a),c=He(a),d=kn(a),g=Tr(a),p={comment:n,element:st(a),elementPath:wn(a),targetLabel:lt(a,t.selectedText),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:Sr(r),boundingBox:er(s),domHints:Ho(a)};return t.selectedText&&(p.selectedText=bl(t.selectedText)),l&&(p.nearbyText=l),c.length>0&&(p.cssClasses=c),d.length>0&&(p.nearbyElements=d),i&&(p.accessibility=i),g?.reactComponents&&(p.reactComponents=g.reactComponents),g?.sourceFile&&(p.sourceFile=g.sourceFile),p}function $o(e){let{target:t,click:r,comment:n,url:o}=e,a=t.elements.slice(0,zo).map(d=>st(d)),s=t.elements.length>zo?"\u2026":"",i=`${t.elements.length} elements: ${a.join(", ")}${s}`,l=t.elements[0],c=l?Tr(l):null;return {comment:n,element:i,elementPath:i,targetLabel:Ot(t.elements.length),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:Sr(r),boundingBox:er(t.union),isMultiSelect:true,elementBoundingBoxes:t.rects.map(er),...c?.reactComponents?{reactComponents:c.reactComponents}:{},...c?.sourceFile?{sourceFile:c.sourceFile}:{},...l?{domHints:Ho(l)}:{}}}function Bo(e){let{target:t,click:r,comment:n,url:o}=e,a=Math.round(t.rect.width),s=Math.round(t.rect.height),i=Math.round(t.rect.x),l=Math.round(t.rect.y);return {comment:n,element:`region ${a}\xD7${s}`,elementPath:`region at (${i}, ${l}) ${a}\xD7${s}`,targetLabel:Lt(),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:Sr(r),boundingBox:er(t.rect)}}async function bt(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function Wo(e,t){return t.resolve(e)}async function Yo(e,t){return t.deleteAnnotation(e)}async function Xo(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function Uo(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function Go(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function Ko(e,t){return t.postIdentity(e)}var jo=createContext(null),Zo=0;function Rr(e){return Zo+=1,`${e}-${Date.now().toString(36)}-${Zo}`}function Ir(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function Jo({annotation:e,draftTargetLabel:t,children:r}){let n=me(),o=we(),a=pe(),[s,i]=useState(false),[l,c]=useState(null),[d,g]=useState(null),p=useRef(false),f=e?.thread??[],x=e?.latestRun??null,w=e?.status==="resolved",P=e?Ir(e):false,b=n.viewerKind,m=useCallback(()=>b==="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,b]),u=useMemo(()=>m(),[m]),v=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!u.authorId&&e.payload.authorRole===u.role&&e.payload.authorId===u.authorId,k=useCallback(E=>{let O=m();return {id:Rr("tmp-msg"),role:O.role,authorId:O.authorId,authorName:O.authorName,authorImage:O.authorImage,content:E,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[m]),T=useCallback(async E=>{if(p.current)return Promise.reject(new Error("busy"));p.current=true,i(true);try{return await E()}finally{p.current=false,i(false);}},[]),S=useCallback(async()=>{let E=o.draftText.trim();if(!E)return;if(e){if(w||Ir(e))return;let nt=k(E);o.setDraftText(""),n.updateAnnotation(e.id,Ee=>({...Ee,thread:[...Ee.thread,nt]}));let Or=await bt({kind:"reply",annotationId:e.id,content:E},n.apiClient);if(Or){n.updateAnnotation(e.id,Ee=>({...Ee,thread:Ee.thread.map(Le=>Le.id===nt.id?{...Le,id:Or.id,deliveryStatus:"sent"}:Le)})),n.refresh();return}n.updateAnnotation(e.id,Ee=>({...Ee,thread:Ee.thread.map(Le=>Le.id===nt.id?{...Le,deliveryStatus:"failed"}:Le)}));return}let O=o.active;if(!O||O.kind!=="composer")return;let V=O.target,W={viewportX:O.anchor.viewportX,viewportY:O.anchor.viewportY,scrollY:O.anchor.documentY-O.anchor.viewportY},X=a.getPageUrl(),Di=Fr(n.activeViewport,a.getTargetViewport()),kt=V.kind==="element"?Vo({target:V,click:W,comment:E,url:X}):V.kind==="multi"?$o({target:V,click:W,comment:E,url:X}):Bo({target:V,click:W,comment:E,url:X});kt.viewport=n.activeViewport,kt.viewportSize=Di;let Ct=m(),At=Rr("tmp-ann");n.applyAnnotationUpdate({id:At,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:Ct.authorName,authorImage:Ct.authorImage,payload:{...kt,authorRole:Ct.role,authorId:Ct.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(At);let nr=await bt({kind:"composer",payload:kt},n.apiClient);if(nr){n.replaceAnnotationId(At,nr.id),o.openExisting(nr.id),n.refresh();return}n.updateAnnotation(At,nt=>({...nt,deliveryStatus:"failed"}));},[e,m,w,k,n,o,a]),H=useCallback(async E=>{if(!e||Ir(e))return;let O=e.thread.find(W=>W.id===E);if(!O||O.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,W=>({...W,thread:W.thread.map(X=>X.id===E?{...X,deliveryStatus:"sending"}:X)}));let V=await bt({kind:"reply",annotationId:e.id,content:O.content},n.apiClient);if(V){n.updateAnnotation(e.id,W=>({...W,thread:W.thread.map(X=>X.id===E?{...X,id:V.id,deliveryStatus:"sent"}:X)})),n.refresh();return}n.updateAnnotation(e.id,W=>({...W,thread:W.thread.map(X=>X.id===E?{...X,deliveryStatus:"failed"}:X)}));},[e,n]),Z=useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let E=e.id;n.updateAnnotation(E,V=>({...V,deliveryStatus:"sending"}));let O=await bt({kind:"composer",payload:e.payload},n.apiClient);if(O){n.replaceAnnotationId(E,O.id),o.openExisting(O.id),n.refresh();return}n.updateAnnotation(E,V=>({...V,deliveryStatus:"failed"}));},[e,n,o]),j=useCallback(E=>!u.authorId||E.deliveryStatus&&E.deliveryStatus!=="sent"?false:E.role===u.role&&E.authorId===u.authorId,[u]),ie=useCallback(()=>{v&&(c(null),g({kind:"annotation"}));},[v]),ae=useCallback(E=>{j(E)&&(c(null),g({kind:"message",messageId:E.id}));},[j]),Q=useCallback(()=>{c(null),g(null);},[]),se=useCallback(async E=>{if(!e)return false;let O=e.thread;return T(async()=>(c(null),n.updateAnnotation(e.id,W=>({...W,thread:W.thread.filter(X=>X.id!==E)})),await Xo({annotationId:e.id,messageId:E},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,W=>({...W,thread:O})),c("Couldn't delete message. Try again."),false)))},[e,n,T]),Y=useCallback(async()=>!e||!v?false:T(async()=>(c(null),await Yo(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]),h=useCallback(async()=>{if(d)try{(d.kind==="annotation"?await Y():await se(d.messageId))&&g(null);}catch{c("Couldn't delete. Try again.");}},[d,Y,se]),R=useCallback(async()=>{e&&await T(async()=>{c(null);let E={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await Wo(e.id,n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...E})),c("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,T]),_=useCallback(async()=>{e&&await T(async()=>{c(null);let E={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await Uo({annotationId:e.id,viewerKind:b},n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...E})),c("Couldn't reopen. Try again.");return}n.refresh();});},[e,b,n,T]),C=useCallback(async E=>{e&&await T(async()=>{c(null);let O=e.latestRun,V=e.optimisticAction;n.updateAnnotation(e.id,X=>({...X,latestRun:{id:Rr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let W=await Go({annotationId:e.id,viewerKind:b,guidance:E},n.apiClient);if(!W?.ok){n.updateAnnotation(e.id,X=>({...X,latestRun:O,optimisticAction:V})),c(W?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,b,n,T]),D=useCallback(async E=>{let O=await Ko({...E,avatarSeed:n.clientAvatarSeed},n.apiClient);return O&&await n.setIdentity(O),O},[n]),A=b==="client"&&!n.identity&&f.length===0,le=!!e||f.length>0,Be=n.agentRunReadiness?.ready??true,I=n.agentRunReadiness?.message??null,M=useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),z=e?Sn(e.payload):t||"annotation",K=e?.payload.viewport??n.activeViewport,he=n.studio?n.studio.name:n.identity?.name??null,ue=n.identity?.avatarSeed??n.clientAvatarSeed,De=n.studio?.userId??ue,B=n.studio?.image??null,Oe=n.studio?.userId??ue,yt=useMemo(()=>({state:{annotation:e,messages:f,runState:x,draftText:o.draftText,busy:s,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:b==="studio",agentRunReady:Be,agentRunSetupMessage:I,needsIdentity:A,isResolved:w,initialMessageLocked:P,threadVisible:le,canDeleteAnnotation:v},actions:{setDraftText:o.setDraftText,submit:S,retryMessage:H,retryInitialMessage:Z,requestDeleteAnnotation:ie,requestDeleteMessage:ae,canDeleteMessage:j,cancelDelete:Q,confirmDelete:h,markResolved:R,reopen:_,runPatch:C,setIdentity:D,attemptClose:o.attemptClose,requestClose:M,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:z,viewport:K,shakeNonce:o.shakeNonce,viewer:{kind:b,authorId:u.authorId,name:he,avatarKey:De,avatarSrc:B,generatedSeed:Oe}}}),[e,f,x,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,s,l,d,S,H,Z,ie,ae,j,Q,h,R,_,C,D,b,Be,I,A,w,P,le,v,M,z,K,u.authorId,he,De,B,Oe]);return jsx(jo.Provider,{value:yt,children:r})}function G(){let e=use(jo);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var Cl="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",Al={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 Pr(e="brand",t){return N(Cl,Al[e],t)}function ce({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:Pr(e,t),...o})}function ei(){let{state:e,actions:t}=G(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",a=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",s=n?"Delete annotation":"Delete message";return jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsx("div",{className:"text-xs text-muted-foreground",children:a}),e.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(ce,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsx(ce,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":s})]})]})})}function ri(){let{state:e,actions:t}=G();return e.confirmDiscardOpen?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(ce,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(ce,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var Sl="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",El={sm:"size-7",md:"size-8"},Rl={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Ne({size:e="sm",tone:t="default",className:r,type:n="button",ref:o,...a}){return jsx("button",{ref:o,type:n,className:N(Sl,El[e],Rl[t],r),...a})}function ni(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 oi(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 ii(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}function ai(){let{state:e}=G();return !e.showDevFooter||!e.annotation?null:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx(Pl,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(Ml,{})})]}),e.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function Pl(){let{state:e,actions:t}=G(),[r,n]=useState(false),[o,a]=useState(""),[s,i]=useState(false),l=e.runState,c=l?.status;if(e.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let g=c==="queued"||c==="running",p=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,f=l?"Run Patch again":"Run Patch",x=c==="failed"?"destructiveTint":"brand",w=!e.agentRunReady,P=async()=>{try{i(!0),await t.runPatch(o.trim()||void 0),a(""),n(!1);}finally{i(false);}};if(g)return jsx("div",{className:"min-w-0 flex-1",children:jsxs(ce,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(p){let m=ii(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Pr("brand","no-underline"),children:[jsx($,{name:"pr",size:12}),m==="PR"?"View PR":`View PR ${m}`]})})}let b=jsxs(ce,{variant:x,disabled:e.busy||w,className:w?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(pt,{size:12})," ",f]});return jsxs("div",{className:"min-w-0 flex-1",children:[w&&e.agentRunSetupMessage?jsx(Te,{text:e.agentRunSetupMessage,tone:"warning",children:b}):b,r?jsx(Nl,{title:f,guidance:o,submitting:s||e.busy,onGuidanceChange:a,onCancel:()=>n(false),onSubmit:P}):null]})}function Nl({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:a}){return jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxs("form",{role:"dialog","aria-label":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(),a();},children:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-xl bg-brand text-white",children:jsx(pt,{size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsx(Ne,{size:"sm",title:"Close",onClick:o,children:jsx($,{name:"x",size:12})})]}),jsxs("label",{className:"flex flex-col gap-1.5",children:[jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsx("textarea",{value: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"})]}),jsxs("div",{className:"flex justify-end gap-2",children:[jsx(ce,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(ce,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function Ml(){let{state:e,actions:t}=G();return e.annotation?e.annotation.status==="resolved"?jsxs(ce,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsx($,{name:"refresh",size:12}),"Reopen"]}):jsxs(ce,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsx($,{name:"check",size:12}),"Resolve"]}):null}var Mr=createContext({expanded:false,onToggleExpand:()=>{}});function si(){return use(Mr)}function li(){let{state:e,meta:t}=G(),{expanded:r,onToggleExpand:n}=si(),o=e.annotation,a=Ce[t.viewport],s=o?.payload.selectedText;return jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{title:t.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:t.targetLabel}),jsx(Te,{text:We(t.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":We(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx($,{name:a.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsx($,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[jsx(zl,{}),jsx(Ne,{onClick:n,title:r?"Collapse":"Expand",children:jsx($,{name:r?"minimize":"maximize",size:13})}),jsx(Ll,{})]})]})]}),s?jsx("div",{className:"rounded-xl bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:s.length>200?`${s.slice(0,199).trim()}\u2026`:s})}):null]})}function Ll(){let{actions:e}=G();return jsx(Ne,{onClick:e.requestClose,title:"Close",children:jsx($,{name:"x",size:14})})}function zl(){let{state:e,actions:t}=G(),[r,n]=useState(false);return e.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(Ne,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx($,{name:"more",size:14})}),r?jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),t.requestDeleteAnnotation();},children:[jsx($,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function mi(){let{state:e,actions:t,meta:r}=G(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,a=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let i=n.current;i&&(i.scrollTop=i.scrollHeight);}),e.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:N("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?jsx(ui,{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===a?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(i=>jsx(ui,{name:i.authorName??i.role,createdAt:i.createdAt,content:i.content,authorKey:i.authorId??i.authorName??i.role,avatarSrc:i.authorImage,generatedSeed:i.role==="client"&&i.authorId===a?o:i.authorAvatarSeed??i.authorId,deliveryStatus:i.deliveryStatus,canDelete:t.canDeleteMessage(i),onDelete:()=>t.requestDeleteMessage(i),onRetry:i.deliveryStatus==="failed"?()=>{t.retryMessage(i.id);}:void 0},i.id))]}):null}function ui(e){let t=qe(e.name),r=Ze(e.authorKey),n=e.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(Pe,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:ni(e.createdAt)})]}),e.canDelete&&e.onDelete?jsx($l,{onDelete:e.onDelete}):null,jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?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 Fl=44,Vl=8;function $l({onDelete:e}){let[t,r]=useState(false),[n,o]=useState("down"),a=useRef(null),s=useCallback(()=>{let l=a.current,c=l?.closest("[data-patch-thread-scroller]");if(!l||!c){o("down");return}let d=l.getBoundingClientRect(),g=c.getBoundingClientRect(),p=g.bottom-d.bottom,f=d.top-g.top;o(p<Fl+Vl&&f>p?"up":"down");},[]),i=useCallback(()=>{r(l=>{let c=!l;return c&&s(),c});},[s]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx(Ne,{ref:a,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:i,children:jsx($,{name:"more",size:14})}),t?jsx("div",{role:"menu",className:N("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),e();},children:[jsx($,{name:"trash",size:13}),"Delete"]})}):null]})}var Bl={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 gi({variant:e="default",className:t,ref:r,...n}){return jsx("textarea",{ref:r,className:N(Bl[e],t),...n})}var Ul=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,fi="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 hi(){let{actions:e}=G(),[t,r]=useState(""),[n,o]=useState(""),[a,s]=useState(null),[i,l]=useState(false),c=useRef(null);return useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxs("form",{onSubmit:async g=>{g.preventDefault();let p=t.trim(),f=n.trim();if(!p){s("Name is required.");return}if(!Ul.test(f)){s("Enter a valid email.");return}s(null),l(true);let x=await e.setIdentity({name:p,email:f});l(false),x||s("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsx("input",{ref:c,type:"text",placeholder:"Name",value:t,onChange:g=>r(g.target.value),className:fi}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:g=>o(g.target.value),className:fi}),a?jsx("div",{className:"text-xs text-destructive",children:a}):null,jsx("button",{type:"submit",disabled:i,className:N("self-end rounded-[10px] bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",i&&"cursor-not-allowed opacity-60"),children:i?"Saving\u2026":"Continue"})]})}function vi(){let{state:e,actions:t,meta:r}=G(),n=useRef(null),[o,a]=useState(false);if(useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),useEffect(()=>{let p=n.current;if(!p)return;p.style.height="0px";let f=Math.min(p.scrollHeight,140);p.style.height=`${f}px`,a(f>28);},[e.draftText]),e.isResolved||e.initialMessageLocked)return null;if(e.needsIdentity)return jsx("div",{className:N("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsx(hi,{})});let s=e.draftText.trim().length>0,i=r.viewer.name,l=qe(i),c=r.viewer.kind==="studio"?"var(--color-foreground)":Ze(r.viewer.avatarKey),d=p=>{p.preventDefault(),t.submit();},g=p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),t.submit());};return jsx("form",{onSubmit:d,className:N("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:jsxs("div",{className:N("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-[18px]":"rounded-full"),children:[jsx(Pe,{initials:l,tint:c,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:i??"",className:"self-start"}),jsx(gi,{ref:n,variant:"bare",value:e.draftText,onChange:p=>t.setDraftText(p.target.value),onKeyDown:g,rows:1,placeholder:e.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsx(Zl,{enabled:s})]})})}function Zl({enabled:e}){return jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:N("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsx($,{name:"arrow-up",size:13})})}var tc=440,yi=88,rr=16,rc=[.22,.61,.36,1],nc=[.4,0,.2,1],oc={x:-8,y:-8,origin:"top left"},ki=200;function Ci(e,t,r){return Math.max(t,Math.min(r,e))}function Ti(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:Ci((n.x-o.x)*.08,-12,12),y:Ci((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function ic(e,t){if(!t)return oc;let r=ct({anchor:t,popover:{width:332,height:ki},viewport:e.getOverlayViewport()});return Ti(t,r,ki)}function ac(e,t){return e.x===t.x&&e.y===t.y&&e.origin===t.origin}function Si({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n=0,onToggleExpand:o,children:a}){let{actions:{attemptClose:s},meta:{shakeNonce:i}}=G(),l=pe(),c=useRef(null),[d,g]=useState(600),[p,f]=useState(()=>ic(l,t??e())),x=useCallback(()=>{let m=c.current;if(!m||r)return;let u=e();if(!u)return;let v=m.offsetHeight||200,k=ct({anchor:u,popover:{width:332,height:v},viewport:l.getOverlayViewport()});m.style.left=`${k.x}px`,m.style.top=`${k.y}px`,m.style.right="auto";let T=Ti(u,k,v);f(S=>ac(S,T)?S:T);},[e,r,l]);useLayoutEffect(()=>{r||x(),g(l.getOverlayViewport().height-rr-yi);}),useEffect(()=>{let m=null,u=()=>{m===null&&(m=l.overlayWindow.requestAnimationFrame(()=>{m=null,r||x(),g(l.getOverlayViewport().height-rr-yi);}));},v=new Set([l.targetWindow,l.overlayWindow]);for(let T of v)T.addEventListener("resize",u),T.addEventListener("scroll",u,{passive:true});let k=rn(l.overlayWindow,u);return k.observe(l.overlayDocument.body),l.targetDocument.body!==l.overlayDocument.body&&k.observe(l.targetDocument.body),c.current&&k.observe(c.current),()=>{m!==null&&l.overlayWindow.cancelAnimationFrame(m);for(let T of v)T.removeEventListener("resize",u),T.removeEventListener("scroll",u);k.disconnect();}},[x,r,l]),useEffect(()=>{let m=k=>{oi(k)||s();},u=k=>{k.key==="Escape"&&s();},v=new Set([l.targetDocument,l.overlayDocument]);for(let k of v)k.addEventListener("mousedown",m,true),k.addEventListener("keydown",u);return ()=>{for(let k of v)k.removeEventListener("mousedown",m,true),k.removeEventListener("keydown",u);}},[s,l]);let w=useRef(i);useEffect(()=>{if(i===w.current)return;w.current=i;let m=c.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[i]);let P={left:"auto",right:`${rr}px`,top:`${rr}px`,width:`${tc}px`,height:`${d}px`},b={width:`${332}px`,height:"auto",transformOrigin:p.origin};return jsx(motion.div,{ref:c,layout:true,initial:{opacity:0,x:p.x,y:p.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:p.x,y:p.y,scale:.985,transition:{duration:.16,ease:nc}},transition:{layout:{duration:.42,ease:rc}},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?P:b,children:jsx(Mr.Provider,{value:{expanded:r,onToggleExpand:o},children:a})})}var re={Root:Si,Header:li,Messages:mi,Reply:vi,DevFooter:ai,ConfirmDiscard:ri,ConfirmDelete:ei};function Ei({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(re.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(re.Header,{}),jsx(re.Messages,{}),jsx(re.Reply,{}),jsx(re.ConfirmDiscard,{}),jsx(re.ConfirmDelete,{})]})}function Ri({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(re.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(re.Header,{}),jsx(re.Messages,{}),jsx(re.Reply,{}),jsx(re.DevFooter,{}),jsx(re.ConfirmDiscard,{}),jsx(re.ConfirmDelete,{})]})}var mc="data-patch-internal";function Ni(e,t,r){let n={viewportX:t,viewportY:r},o=je(n,e.getOverlayViewport());return Ut(n,o)}function gc(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function fc(e,t){let r=gc(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 hc(e,t){if(!t)return null;let r=wo({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:mc}),n=e.targetPointToOverlay(r.position);return Ni(e,n.viewportX,n.viewportY)}function Pi(e,t,r){if(!t)return null;if(t.kind==="existing")return fc(e,t.annotationId)??hc(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return Ni(e,n.viewportX,n.viewportY)}function Mi(){let e=we(),t=me(),r=pe(),n=e.active,o=useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(x=>x.id===n.annotationId)??null,[n,t.annotations]),a=useCallback(()=>Pi(r,n,o),[n,o,r]),[s,i]=useState(false),l=e.active?e.active.kind==="existing"?e.active.annotationId:"composer":null;useEffect(()=>{i(false);},[l]);let c=t.viewerKind==="studio"?Ri:Ei,d=n&&(n.kind==="composer"||!!o),g=n?.kind==="composer"?.04:0,p=n?.kind==="composer"?Fo(n.target):null,f=useMemo(()=>Pi(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:d?jsx(Jo,{annotation:o,draftTargetLabel:p,children:jsx(c,{getAnchorRect:a,initialAnchorRect:f,expanded:s,entryDelay:g,onToggleExpand:()=>i(x=>!x)})},"active-popover"):null})}var xc="https://app.usepatch.dev";function wc({children:e}){let{active:t}=me();return t?e:null}function _i(e){let t=typeof window<"u"&&tn(window),r=useMemo(()=>qn({prop:e.projectToken,processEnv:jn(),importMetaEnv:Zn()}),[e.projectToken]),n=e.apiBase??xc;return useEffect(()=>{r||console.warn(Kn);},[r]),t||!r?null:jsx(Io,{children:jsx(nn,{children:jsx(pn,{projectToken:r,apiBase:n,children:jsx(wc,{children:jsx(gn,{children:jsx(Gn,{children:jsxs(Wn,{children:[jsx(So,{}),jsx(Mi,{}),jsx(fo,{})]})})})})})})})}var yc=_i;
1891
- export{_i as Patch,yc as default};
1958
+ `;var jo="patch-widget-root";function Jo({children:e}){let[t,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(jo);o||(o=document.createElement(jo),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let s=o.shadowRoot??o.attachShadow({mode:"open"});if(!s.querySelector("style[data-patch-css]")){let a=document.createElement("style");a.setAttribute("data-patch-css",""),a.textContent=Zo,s.appendChild(a);}let i=s.querySelector("div[data-patch-mount]");return i||(i=document.createElement("div"),i.setAttribute("data-patch-mount",""),s.appendChild(i)),r(i),()=>{}},[]),t?createPortal(e,t):null}var Ol=/[\s#.:[\]()>+~,\\]/;function zl(e){return !(!e||Ol.test(e)||/^\d/.test(e))}function Hl(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Qo(e,t,r){try{let n=e.querySelectorAll(t);return n.length===1&&n[0]===r}catch{return false}}function Fl(e,t){return e.id&&zl(e.id)&&(!t||Qo(t,`#${e.id}`,e))?`#${e.id}`:`${e.tagName.toLowerCase()}:nth-of-type(${Hl(e)})`}function ei(e,t){if(!e.tagName)return "";let r=e.ownerDocument??null,n=[],o=e,s=0;for(;o&&s<12;){let i=Fl(o,r);if(n.unshift(i),i.startsWith("#"))break;let a=n.join(" > ");if(r&&Qo(r,a,e))return a;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,s++;}return n.join(" > ")}var $l=80,Vl=500;function ri(e){return e!==null&&typeof e=="object"}function Bl(e){return ri(e)?"return"in e||"type"in e||"elementType"in e||"_debugOwner"in e:false}function sr(e){if(typeof e=="function")return e.displayName||e.name||null;if(!ri(e))return null;let t=e.displayName;if(typeof t=="string"&&t)return t;let r=sr(e.render);if(r)return r;let n=sr(e.type);return n||null}function ni(e){return e.replace(/\s+/g," ").trim()}function oi(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Wl(e){let t=ni(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:oi(t,$l)}function Yl(e){let t=sr(e.elementType)??sr(e.type);return t?Wl(t):null}function ti(e){return oi(ni(e),Vl)}function Ul(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 Xl(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 ti(t.slice(o+1))}let r=t.split("/").filter(Boolean);return ti(r.slice(-3).join("/"))}function Gl(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||Ul(t)?null:Xl(t)}function Kl(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(Bl(n))return n}return null}function zr(e){let t=Kl(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let a=Yl(t),l=a?Tr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=Gl(t)),t=t.return??t._debugOwner??null,o+=1;}let s=r.length>0?fo(r.reverse().map(a=>`<${a}>`).join(" ")):null,i={};return s&&(i.reactComponents=s),n&&(i.sourceFile=n),Object.keys(i).length>0?i:null}var ii=500,ai=3;function ql(e){return e.length<=ii?e:e.slice(0,ii)}function Hr(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function lr(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function si(e){let t={cssSelector:ei(e)},r=Ht(e);r&&(t.textSignature=r);let n=zt(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function li(e){return e.kind==="element"?bt(e.element,e.selectedText):e.kind==="multi"?Vt(e.elements.length):Bt()}function ci(e){let{target:t,click:r,comment:n,url:o}=e,s=t.element,i=t.rect,a=Nn(s),l=Mn(s),c=Ye(s),d=_n(s),m=zr(s),u={comment:n,element:ht(s),elementPath:Pn(s),targetLabel:bt(s,t.selectedText),timestamp:Date.now(),url:Pe(o),kind:"feedback",coordinates:Hr(r),boundingBox:lr(i),domHints:si(s)};return t.selectedText&&(u.selectedText=ql(t.selectedText)),l&&(u.nearbyText=l),c.length>0&&(u.cssClasses=c),d.length>0&&(u.nearbyElements=d),a&&(u.accessibility=a),m?.reactComponents&&(u.reactComponents=m.reactComponents),m?.sourceFile&&(u.sourceFile=m.sourceFile),u}function di(e){let{target:t,click:r,comment:n,url:o}=e,s=t.elements.slice(0,ai).map(d=>ht(d)),i=t.elements.length>ai?"\u2026":"",a=`${t.elements.length} elements: ${s.join(", ")}${i}`,l=t.elements[0],c=l?zr(l):null;return {comment:n,element:a,elementPath:a,targetLabel:Vt(t.elements.length),timestamp:Date.now(),url:Pe(o),kind:"feedback",coordinates:Hr(r),boundingBox:lr(t.union),isMultiSelect:true,elementBoundingBoxes:t.rects.map(lr),...c?.reactComponents?{reactComponents:c.reactComponents}:{},...c?.sourceFile?{sourceFile:c.sourceFile}:{},...l?{domHints:si(l)}:{}}}function ui(e){let{target:t,click:r,comment:n,url:o}=e,s=Math.round(t.rect.width),i=Math.round(t.rect.height),a=Math.round(t.rect.x),l=Math.round(t.rect.y);return {comment:n,element:`region ${s}\xD7${i}`,elementPath:`region at (${a}, ${l}) ${s}\xD7${i}`,targetLabel:Bt(),timestamp:Date.now(),url:Pe(o),kind:"feedback",coordinates:Hr(r),boundingBox:lr(t.rect)}}async function At(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function pi(e,t){return t.resolve(e)}async function mi(e,t){return t.deleteAnnotation(e)}async function gi(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function fi(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function hi(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function bi(e,t){return t.postIdentity(e)}var wi=createContext(null),xi=0;function $r(e){return xi+=1,`${e}-${Date.now().toString(36)}-${xi}`}function Vr(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function yi({annotation:e,draftTargetLabel:t,children:r}){let n=re(),o=xe(),s=ce(),[i,a]=useState(false),[l,c]=useState(null),[d,m]=useState(null),u=useRef(false),h=e?.thread??[],v=e?.latestRun??null,x=e?.status==="resolved",T=e?Vr(e):false,w=n.viewerKind,g=useCallback(()=>w==="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,w]),p=useMemo(()=>g(),[g]),b=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!p.authorId&&e.payload.authorRole===p.role&&e.payload.authorId===p.authorId,C=useCallback(R=>{let O=g();return {id:$r("tmp-msg"),role:O.role,authorId:O.authorId,authorName:O.authorName,authorImage:O.authorImage,content:R,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[g]),A=useCallback(async R=>{if(u.current)return Promise.reject(new Error("busy"));u.current=true,a(true);try{return await R()}finally{u.current=false,a(false);}},[]),f=useCallback(async()=>{let R=o.draftText.trim();if(!R)return;if(e){if(x||Vr(e))return;let pt=C(R);o.setDraftText(""),n.updateAnnotation(e.id,_e=>({..._e,thread:[..._e.thread,pt]}));let Xr=await At({kind:"reply",annotationId:e.id,content:R},n.apiClient);if(Xr){n.updateAnnotation(e.id,_e=>({..._e,thread:_e.thread.map(Be=>Be.id===pt.id?{...Be,id:Xr.id,deliveryStatus:"sent"}:Be)})),n.refresh();return}n.updateAnnotation(e.id,_e=>({..._e,thread:_e.thread.map(Be=>Be.id===pt.id?{...Be,deliveryStatus:"failed"}:Be)}));return}let O=o.active;if(!O||O.kind!=="composer")return;let V=O.target,B={viewportX:O.anchor.viewportX,viewportY:O.anchor.viewportY,scrollY:O.anchor.documentY-O.anchor.viewportY},Y=s.getPageUrl(),pr=Zr(n.activeViewport,s.getTargetViewport()),z=V.kind==="element"?ci({target:V,click:B,comment:R,url:Y}):V.kind==="multi"?di({target:V,click:B,comment:R,url:Y}):ui({target:V,click:B,comment:R,url:Y});z.viewport=n.activeViewport,z.viewportSize=pr;let ie=g(),Se=$r("tmp-ann");n.applyAnnotationUpdate({id:Se,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:ie.authorName,authorImage:ie.authorImage,payload:{...z,authorRole:ie.role,authorId:ie.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(Se);let mr=await At({kind:"composer",payload:z},n.apiClient);if(mr){n.replaceAnnotationId(Se,mr.id),o.openExisting(mr.id),n.refresh();return}n.updateAnnotation(Se,pt=>({...pt,deliveryStatus:"failed"}));},[e,g,x,C,n,o,s]),I=useCallback(async R=>{if(!e||Vr(e))return;let O=e.thread.find(B=>B.id===R);if(!O||O.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===R?{...Y,deliveryStatus:"sending"}:Y)}));let V=await At({kind:"reply",annotationId:e.id,content:O.content},n.apiClient);if(V){n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===R?{...Y,id:V.id,deliveryStatus:"sent"}:Y)})),n.refresh();return}n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===R?{...Y,deliveryStatus:"failed"}:Y)}));},[e,n]),Q=useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let R=e.id;n.updateAnnotation(R,V=>({...V,deliveryStatus:"sending"}));let O=await At({kind:"composer",payload:e.payload},n.apiClient);if(O){n.replaceAnnotationId(R,O.id),o.openExisting(O.id),n.refresh();return}n.updateAnnotation(R,V=>({...V,deliveryStatus:"failed"}));},[e,n,o]),Z=useCallback(R=>!p.authorId||R.deliveryStatus&&R.deliveryStatus!=="sent"?false:R.role===p.role&&R.authorId===p.authorId,[p]),be=useCallback(()=>{b&&(c(null),m({kind:"annotation"}));},[b]),pe=useCallback(R=>{Z(R)&&(c(null),m({kind:"message",messageId:R.id}));},[Z]),oe=useCallback(()=>{c(null),m(null);},[]),ee=useCallback(async R=>{if(!e)return false;let O=e.thread;return A(async()=>(c(null),n.updateAnnotation(e.id,B=>({...B,thread:B.thread.filter(Y=>Y.id!==R)})),await gi({annotationId:e.id,messageId:R},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,B=>({...B,thread:O})),c("Couldn't delete message. Try again."),false)))},[e,n,A]),U=useCallback(async()=>!e||!b?false:A(async()=>(c(null),await mi(e.id,n.apiClient)?(n.updateAnnotation(e.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[e,b,n,o,A]),k=useCallback(async()=>{if(d)try{(d.kind==="annotation"?await U():await ee(d.messageId))&&m(null);}catch{c("Couldn't delete. Try again.");}},[d,U,ee]),N=useCallback(async()=>{e&&await A(async()=>{c(null);let R={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await pi(e.id,n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...R})),c("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,A]),_=useCallback(async()=>{e&&await A(async()=>{c(null);let R={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await fi({annotationId:e.id,viewerKind:w},n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...R})),c("Couldn't reopen. Try again.");return}n.refresh();});},[e,w,n,A]),S=useCallback(async R=>{e&&await A(async()=>{c(null);let O=e.latestRun,V=e.optimisticAction;n.updateAnnotation(e.id,Y=>({...Y,latestRun:{id:$r("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let B=await hi({annotationId:e.id,viewerKind:w,guidance:R},n.apiClient);if(!B?.ok){n.updateAnnotation(e.id,Y=>({...Y,latestRun:O,optimisticAction:V})),c(B?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,w,n,A]),L=useCallback(async R=>{let O=await bi({...R,avatarSeed:n.clientAvatarSeed},n.apiClient);return O&&await n.setIdentity(O),O},[n]),E=w==="client"&&!n.identity&&h.length===0,te=!!e||h.length>0,me=n.agentRunReadiness?.ready??true,P=n.agentRunReadiness?.message??null,D=useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),$=e?zn(e.payload):t||"annotation",K=e?.payload.viewport??n.activeViewport,Ae=n.studio?n.studio.name:n.identity?.name??null,ge=n.identity?.avatarSeed??n.clientAvatarSeed,Ve=n.studio?.userId??ge,It=n.studio?.image??null,Nt=n.studio?.userId??ge,ur=useMemo(()=>({state:{annotation:e,messages:h,runState:v,draftText:o.draftText,busy:i,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:w==="studio",agentRunReady:me,agentRunSetupMessage:P,needsIdentity:E,isResolved:x,initialMessageLocked:T,threadVisible:te,canDeleteAnnotation:b},actions:{setDraftText:o.setDraftText,submit:f,retryMessage:I,retryInitialMessage:Q,requestDeleteAnnotation:be,requestDeleteMessage:pe,canDeleteMessage:Z,cancelDelete:oe,confirmDelete:k,markResolved:N,reopen:_,runPatch:S,setIdentity:L,attemptClose:o.attemptClose,requestClose:D,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:$,viewport:K,shakeNonce:o.shakeNonce,viewer:{kind:w,authorId:p.authorId,name:Ae,avatarKey:Ve,avatarSrc:It,generatedSeed:Nt}}}),[e,h,v,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,l,d,f,I,Q,be,pe,Z,oe,k,N,_,S,L,w,me,P,E,x,T,te,b,D,$,K,p.authorId,Ae,Ve,It,Nt]);return jsx(wi.Provider,{value:ur,children:r})}function G(){let e=use(wi);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var tc="inline-flex shrink-0 items-center justify-center gap-1.5 h-8 px-3.5 rounded-lg whitespace-nowrap text-[13px] font-semibold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",rc={brand:"pkey pkey-brand text-white",brandTint:"bg-brand-tint text-brand hover:bg-brand-tint/70",destructive:"pkey pkey-destructive text-white",destructiveTint:"bg-destructive/10 text-destructive hover:bg-destructive/15",successTint:"bg-brand-green/10 text-brand-green hover:bg-brand-green/15",warn:"pkey pkey-warn text-white",warnTint:"bg-brand-orange/10 text-brand-orange hover:bg-brand-orange/15",neutral:"pkey pkey-outline text-foreground",subtle:"bg-black/8 text-muted-foreground"};function St(e="brand",t){return M(tc,rc[e],t)}function fe({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:St(e,t),...o})}function Ci(){let{state:e,actions:t}=G(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",s=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",i=n?"Delete annotation":"Delete message";return jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsx("div",{className:"text-xs text-muted-foreground",children:s}),e.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(fe,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsx(fe,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":i})]})]})})}function Si(){let{state:e,actions:t}=G();return e.confirmDiscardOpen?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(fe,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(fe,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var oc="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",ic={sm:"size-7",md:"size-8"},ac={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function He({size:e="sm",tone:t="default",className:r,type:n="button",ref:o,...s}){return jsx("button",{ref:o,type:n,className:M(oc,ic[e],ac[t],r),...s})}function Ti(){let{state:e}=G();return !e.showDevFooter||!e.annotation?null:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx(lc,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(dc,{})})]}),e.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function lc(){let{state:e,actions:t}=G(),[r,n]=useState(false),[o,s]=useState(""),[i,a]=useState(false),l=e.runState,c=l?.status;if(e.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let m=c==="queued"||c==="running",u=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,h=l?"Run Patch again":"Run Patch",v=c==="failed"?"destructiveTint":"brand",x=!e.agentRunReady,T=async()=>{try{a(!0),await t.runPatch(o.trim()||void 0),s(""),n(!1);}finally{a(false);}};if(m)return jsx("div",{className:"min-w-0 flex-1",children:jsxs(fe,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let g=Ao(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:St("brand","no-underline"),children:[jsx(F,{name:"pr",size:12}),g==="PR"?"View PR":`View PR ${g}`]})})}let w=jsxs(fe,{variant:v,disabled:e.busy||x,className:x?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(kt,{size:12})," ",h]});return jsxs("div",{className:"min-w-0 flex-1",children:[x&&e.agentRunSetupMessage?jsx(Ie,{text:e.agentRunSetupMessage,tone:"warning",children:w}):w,r?jsx(cc,{title:h,guidance:o,submitting:i||e.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:T}):null]})}function cc({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:s}){return jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxs("form",{role:"dialog","aria-label":e,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-xl bg-popover p-4 shadow-dialog",onSubmit:i=>{i.preventDefault(),s();},children:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg bg-brand text-white",children:jsx(kt,{size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsx(He,{size:"sm",title:"Close",onClick:o,children:jsx(F,{name:"x",size:12})})]}),jsxs("label",{className:"flex flex-col gap-1.5",children:[jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsx("textarea",{value:t,onChange:i=>n(i.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-md border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxs("div",{className:"flex justify-end gap-2",children:[jsx(fe,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(fe,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function dc(){let{state:e,actions:t}=G();return e.annotation?e.annotation.status==="resolved"?jsxs(fe,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsx(F,{name:"refresh",size:12}),"Reopen"]}):jsxs(fe,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsx(F,{name:"check",size:12}),"Resolve"]}):null}var Wr=createContext({expanded:false,onToggleExpand:()=>{}});function Ei(){return use(Wr)}function Ri(){let{state:e,meta:t}=G(),{expanded:r,onToggleExpand:n}=Ei(),o=e.annotation,s=we[t.viewport],i=o?.payload.selectedText;return jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{title:t.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:t.targetLabel}),jsx(Ie,{text:Ke(t.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":Ke(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx(F,{name:s.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsx(F,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[jsx(fc,{}),jsx(He,{onClick:n,title:r?"Collapse":"Expand",children:jsx(F,{name:r?"minimize":"maximize",size:13})}),jsx(gc,{})]})]})]}),i?jsx("div",{className:"rounded-lg bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:i.length>200?`${i.slice(0,199).trim()}\u2026`:i})}):null]})}function gc(){let{actions:e}=G();return jsx(He,{onClick:e.requestClose,title:"Close",children:jsx(F,{name:"x",size:14})})}function fc(){let{state:e,actions:t}=G(),[r,n]=useState(false);return e.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(He,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(F,{name:"more",size:14})}),r?jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),t.requestDeleteAnnotation();},children:[jsx(F,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function _i(){let{state:e,actions:t,meta:r}=G(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,s=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),e.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:M("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-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[e.annotation?jsx(Pi,{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===s?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=>jsx(Pi,{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===s?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 Pi(e){let t=tt(e.name),r=rt(e.authorKey),n=e.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(Oe,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:Jt(e.createdAt)})]}),e.canDelete&&e.onDelete?jsx(xc,{onDelete:e.onDelete}):null,jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?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 bc=44,vc=8;function xc({onDelete:e}){let[t,r]=useState(false),[n,o]=useState("down"),s=useRef(null),i=useCallback(()=>{let l=s.current,c=l?.closest("[data-patch-thread-scroller]");if(!l||!c){o("down");return}let d=l.getBoundingClientRect(),m=c.getBoundingClientRect(),u=m.bottom-d.bottom,h=d.top-m.top;o(u<bc+vc&&h>u?"up":"down");},[]),a=useCallback(()=>{r(l=>{let c=!l;return c&&i(),c});},[i]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx(He,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:a,children:jsx(F,{name:"more",size:14})}),t?jsx("div",{role:"menu",className:M("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),e();},children:[jsx(F,{name:"trash",size:13}),"Delete"]})}):null]})}var wc={default:"w-full min-h-[60px] resize-y rounded-md border border-border bg-popover px-3 py-2 text-[13px] leading-[1.45] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",bare:"w-full resize-none self-center overflow-y-auto bg-transparent border-0 outline-none text-[13px] leading-normal text-foreground placeholder:text-muted-foreground"};function Di({variant:e="default",className:t,ref:r,...n}){return jsx("textarea",{ref:r,className:M(wc[e],t),...n})}var Ac=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Li="w-full rounded-md border border-border bg-popover px-2.5 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function Oi(){let{actions:e}=G(),[t,r]=useState(""),[n,o]=useState(""),[s,i]=useState(null),[a,l]=useState(false),c=useRef(null);return useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxs("form",{onSubmit:async m=>{m.preventDefault();let u=t.trim(),h=n.trim();if(!u){i("Name is required.");return}if(!Ac.test(h)){i("Enter a valid email.");return}i(null),l(true);let v=await e.setIdentity({name:u,email:h});l(false),v||i("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsx("input",{ref:c,type:"text",placeholder:"Name",value:t,onChange:m=>r(m.target.value),className:Li}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:m=>o(m.target.value),className:Li}),s?jsx("div",{className:"text-xs text-destructive",children:s}):null,jsx("button",{type:"submit",disabled:a,className:M(St("brand"),"self-end",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}function Hi(){let{state:e,actions:t,meta:r}=G(),n=useRef(null),[o,s]=useState(false);if(useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),useEffect(()=>{let u=n.current;if(!u)return;u.style.height="0px";let h=Math.min(u.scrollHeight,140);u.style.height=`${h}px`,s(h>28);},[e.draftText]),e.isResolved||e.initialMessageLocked)return null;if(e.needsIdentity)return jsx("div",{className:M("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsx(Oi,{})});let i=e.draftText.trim().length>0,a=r.viewer.name,l=tt(a),c=r.viewer.kind==="studio"?"var(--color-foreground)":rt(r.viewer.avatarKey),d=u=>{u.preventDefault(),t.submit();},m=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),t.submit());};return jsx("form",{onSubmit:d,className:M("bg-white p-3",e.threadVisible&&"border-t border-black/6",e.showDevFooter&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxs("div",{className:M("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-xl":"rounded-full"),children:[jsx(Oe,{initials:l,tint:c,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:a??"",className:"self-start"}),jsx(Di,{ref:n,variant:"bare",value:e.draftText,onChange:u=>t.setDraftText(u.target.value),onKeyDown:m,rows:1,placeholder:e.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsx(Rc,{enabled:i})]})})}function Rc({enabled:e}){return jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:M("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsx(F,{name:"arrow-up",size:13})})}var _c=440,Vi=88,dr=16,Dc=[.22,.61,.36,1],Lc=[.4,0,.2,1],Oc={x:-8,y:-8,origin:"top left"},Bi=200;function Wi(e,t,r){return Math.max(t,Math.min(r,e))}function Ui(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:Wi((n.x-o.x)*.08,-12,12),y:Wi((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function zc(e,t){if(!t)return Oc;let r=xt({anchor:t,popover:{width:332,height:Bi},viewport:e.getOverlayViewport()});return Ui(t,r,Bi)}function Hc(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:s}){let{actions:{attemptClose:i},meta:{shakeNonce:a}}=G(),l=ce(),c=useRef(null),[d,m]=useState(600),[u,h]=useState(()=>zc(l,t??e())),v=useCallback(()=>{let g=c.current;if(!g||r)return;let p=e();if(!p)return;let b=g.offsetHeight||200,C=xt({anchor:p,popover:{width:332,height:b},viewport:l.getOverlayViewport()});g.style.left=`${C.x}px`,g.style.top=`${C.y}px`,g.style.right="auto";let A=Ui(p,C,b);h(f=>Hc(f,A)?f:A);},[e,r,l]);useLayoutEffect(()=>{r||v(),m(l.getOverlayViewport().height-dr-Vi);}),useEffect(()=>{let g=null,p=()=>{g===null&&(g=l.overlayWindow.requestAnimationFrame(()=>{g=null,r||v(),m(l.getOverlayViewport().height-dr-Vi);}));},b=new Set([l.targetWindow,l.overlayWindow]);for(let A of b)A.addEventListener("resize",p),A.addEventListener("scroll",p,{passive:true});let C=gn(l.overlayWindow,p);return C.observe(l.overlayDocument.body),l.targetDocument.body!==l.overlayDocument.body&&C.observe(l.targetDocument.body),c.current&&C.observe(c.current),()=>{g!==null&&l.overlayWindow.cancelAnimationFrame(g);for(let A of b)A.removeEventListener("resize",p),A.removeEventListener("scroll",p);C.disconnect();}},[v,r,l]),useEffect(()=>{let g=C=>{Co(C)||i();},p=C=>{C.key==="Escape"&&i();},b=new Set([l.targetDocument,l.overlayDocument]);for(let C of b)C.addEventListener("mousedown",g,true),C.addEventListener("keydown",p);return ()=>{for(let C of b)C.removeEventListener("mousedown",g,true),C.removeEventListener("keydown",p);}},[i,l]);let x=useRef(a);useEffect(()=>{if(a===x.current)return;x.current=a;let g=c.current;g&&(g.classList.remove("patch-shake"),g.offsetWidth,g.classList.add("patch-shake"));},[a]);let T={left:"auto",right:`${dr}px`,top:`${dr}px`,width:`${_c}px`,height:`${d}px`},w={width:`${332}px`,height:"auto",transformOrigin:u.origin};return jsx(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:Lc}},transition:{layout:{duration:.42,ease:Dc}},onLayoutAnimationComplete:v,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:r?T:w,children:jsx(Wr.Provider,{value:{expanded:r,onToggleExpand:o},children:s})})}var le={Root:Xi,Header:Ri,Messages:_i,Reply:Hi,DevFooter:Ti,ConfirmDiscard:Si,ConfirmDelete:Ci};function Gi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(le.Header,{}),jsx(le.Messages,{}),jsx(le.Reply,{}),jsx(le.ConfirmDiscard,{}),jsx(le.ConfirmDelete,{})]})}function Ki({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(le.Header,{}),jsx(le.Messages,{}),jsx(le.Reply,{}),jsx(le.DevFooter,{}),jsx(le.ConfirmDiscard,{}),jsx(le.ConfirmDelete,{})]})}var Uc="data-patch-internal";function ji(e,t,r){let n={viewportX:t,viewportY:r},o=nt(n,e.getOverlayViewport());return jt(n,o)}function Xc(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function Gc(e,t){let r=Xc(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 Kc(e,t){if(!t)return null;let r=Vo({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:Uc}),n=e.targetPointToOverlay(r.position);return ji(e,n.viewportX,n.viewportY)}function Zi(e,t,r){if(!t)return null;if(t.kind==="existing")return Gc(e,t.annotationId)??Kc(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return ji(e,n.viewportX,n.viewportY)}function Ji(){let e=xe(),t=re(),r=ce(),n=e.active,o=useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(v=>v.id===n.annotationId)??null,[n,t.annotations]),s=useCallback(()=>Zi(r,n,o),[n,o,r]),[i,a]=useState(false),l=e.active?e.active.kind==="existing"?e.active.annotationId:"composer":null;useEffect(()=>{a(false);},[l]);let c=t.viewerKind==="studio"?Ki:Gi,d=n&&(n.kind==="composer"||!!o),m=n?.kind==="composer"?.04:0,u=n?.kind==="composer"?li(n.target):null,h=useMemo(()=>Zi(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:d?jsx(yi,{annotation:o,draftTargetLabel:u,children:jsx(c,{getAnchorRect:s,initialAnchorRect:h,expanded:i,entryDelay:m,onToggleExpand:()=>a(v=>!v)})},"active-popover"):null})}var jc="https://app.usepatch.dev";function Jc({children:e}){let{active:t}=re();return t?e:null}function Qi(e){let t=typeof window<"u"&&mn(window),r=useMemo(()=>uo({prop:e.projectToken,processEnv:mo(),importMetaEnv:po()}),[e.projectToken]),n=e.apiBase??jc;return useEffect(()=>{r||console.warn(co);},[r]),t||!r?null:jsx(Jo,{children:jsx(fn,{children:jsx(Cn,{projectToken:r,apiBase:n,children:jsx(Jc,{children:jsx(Sn,{children:jsx(lo,{children:jsx(io,{projectToken:r,children:jsxs(eo,{children:[jsx(Go,{}),jsx(Ji,{}),jsx(qo,{}),jsx(Oo,{})]})})})})})})})})}var Qc=Qi;
1959
+ export{Qi as Patch,Qc as default};