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