@usepatch/widget 0.2.1 → 0.2.2
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 +4 -4
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {createContext,useMemo,useState,useRef,useEffect,useCallback,use,createElement,useId,useLayoutEffect}from'react';import {AnimatePresence,useReducedMotion,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';function be(e){if(e.length<=1||!e.endsWith("/"))return e;try{let t=new URL(e);if(t.pathname==="/"&&e.endsWith("/"))return `${t.origin}${t.search}${t.hash}`}catch{}return e.slice(0,-1)}var ve={desktop:{viewport:"desktop",label:"Desktop",width:null,height:null,glyph:"desktop"},tablet:{viewport:"tablet",label:"Tablet",width:834,height:1194,glyph:"tablet"},mobile:{viewport:"mobile",label:"Mobile",width:390,height:844,glyph:"mobile"}},Nr=["desktop","tablet","mobile"];function Fe(e){let t=ve[e];return t.width===null||t.height===null?t.label:`${t.label} (${t.width}px \xD7 ${t.height}px)`}function Pr(e,t){let r=ve[e];return {width:r.width??t.width,height:r.height??t.height}}var Ri=32,Ii=32,Ni=3e3,Dr="cubic-bezier(0.16, 1, 0.3, 1)",Ct=[.22,.61,.36,1],Or=.3,Lr=.5,Pi=.34,Mi=.5,_i=.24,Di=.22,zr=.12,Oi=.42,Hr=.2,Li=200,zi=260,Hi=70,$i=180,Fi=260,Vi=8,Bi=4,Wi="#d9d9dd",Yi=30,Xi=["0 2px 8px rgba(0,0,0,0.20)","0 30px 60px -18px rgba(0,0,0,0.55)","0 70px 130px -52px rgba(0,0,0,0.55)"].join(", ");function At(e,t,r){let n=Math.max(320,e.innerWidth-Ri*2),o=Math.max(320,e.innerHeight-Ii*2);return Math.min(1,n/t,o/r)}function Ui(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function $r({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:i}){let s=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]=useState(()=>({viewport:c,width:a,height:l,scale:At(r,a,l)})),[v,w]=useState("stable"),[S,C]=useState(false),[m,d]=useState(false),b=useRef(false),y=useRef(null),N=`${u.viewport}:${u.width}:${u.height}`!==p,V=S&&!m&&!(N||v==="cover"||v==="resize"),G=S&&!m&&v==="stable"&&!N,x=useCallback(h=>{y.current=h,n(h);},[n]),A=useCallback(()=>{let h=y.current;if(!h||!Ui(h)){b.current=false,C(false),d(true);return}b.current=true,C(true),d(false);},[]),O=useCallback(()=>{f(h=>{let I=At(r,h.width,h.height);return h.scale===I?h:{...h,scale:I}});},[r]);useEffect(()=>(O(),r.addEventListener("resize",O),()=>r.removeEventListener("resize",O)),[r,O]),useEffect(()=>{b.current=false,C(false),d(false);let h=r.setTimeout(()=>{b.current||d(true);},Ni);return ()=>r.clearTimeout(h)},[e,r]),useEffect(()=>{if(s){N&&f({viewport:c,width:a,height:l,scale:At(r,a,l)}),v!=="stable"&&w("stable");return}switch(v){case "stable":{N&&w("cover");return}case "cover":{let h=r.setTimeout(()=>w("resize"),Hi);return ()=>r.clearTimeout(h)}case "resize":{N&&f({viewport:c,width:a,height:l,scale:At(r,a,l)});let h=r.setTimeout(()=>w("reveal"),$i);return ()=>r.clearTimeout(h)}case "reveal":{let h=r.setTimeout(()=>w("stable"),Fi);return ()=>r.clearTimeout(h)}}},[v,N,s,r,c,a,l]),useEffect(()=>{o(G);},[G,o]),useEffect(()=>{i(m);},[m,i]);let j=s?{duration:0}:{duration:_i,ease:Ct},B=s?{duration:0}:{duration:Di,ease:Ct,delay:Hr*.5},K=s?{duration:0}:{duration:Hr,ease:Ct},ee=s?{duration:0}:{opacity:{duration:Oi,ease:Ct,delay:zr},scale:{type:"spring",bounce:Pi,duration:Mi,delay:zr},width:{type:"spring",bounce:Or,duration:Lr},height:{type:"spring",bounce:Or,duration:Lr}},de=(V?zi:Li)/1e3,se=s?void 0:`opacity ${de}s ${Dr}, filter ${de}s ${Dr}`,le=u.width*u.scale,Ce=u.height*u.scale;return jsx(motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:j},exit:{opacity:0,transition:B},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxs(motion.div,{initial:s?{opacity:0,width:le,height:Ce}:{opacity:0,scale:.8,width:le,height:Ce},animate:{opacity:1,scale:1,width:le,height:Ce},exit:s?{opacity:0}:{opacity:0,scale:.92,transition:K},transition:ee,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${Bi}px solid ${Wi}`,borderRadius:Yi,boxShadow:Xi,willChange:"width, height"},children:[jsx("div",{"aria-hidden":!V,className:"absolute top-0 left-0 origin-top-left",style:{width:u.width,height:u.height,transform:`scale(${u.scale})`,opacity:V?1:0,filter:s||V?"none":`blur(${Vi}px)`,transition:se,pointerEvents:V?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:x,"data-patch-preview-frame":"","data-patch-preview-src":e,title:`${t.label} preview`,tabIndex:V?0:-1,src:g?void 0:e,srcDoc:g?"<!doctype html><html><body></body></html>":void 0,onLoad:A,className:"block bg-white",style:{width:u.width,height:u.height,border:0}})}),jsx(Gi,{visible:m})]})})}function Gi({visible:e}){return e?jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsx("div",{className:"max-w-[320px] rounded-[20px] bg-white px-5 py-4 text-center text-[13px] leading-[1.45] text-foreground shadow-[0_18px_44px_-18px_rgba(0,0,0,0.28)]",children:"This site blocks embedding. Add X-Frame-Options: SAMEORIGIN or frame-ancestors 'self' to enable viewport previews."})}):null}var Wr=createContext(null),Yr=createContext(null),Xr="__patch_preview";function Ur(){return typeof window>"u"||typeof document>"u"?null:{targetWindow:window,targetDocument:document,overlayWindow:window,overlayDocument:document,getTargetViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getOverlayViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getTargetScrollY:()=>window.scrollY,getPageUrl:()=>be(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:e=>({...e}),targetRectToOverlay:e=>({...e}),eventTargetElement:e=>e instanceof window.Element?e:null}}function Zi(e){let t=new URL(e.location.href);return t.searchParams.set(Xr,"1"),t.toString()}function Gr(e=window){try{return new URL(e.location.href).searchParams.get(Xr)==="1"}catch{return false}}function Ji(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function i(){return t.getBoundingClientRect()}function s(){let l=i();return r.width>0?l.width/r.width:1}function a(l){if(!l)return null;let c=n.Element;return l instanceof c?l:null}return {targetWindow:n,targetDocument:o,overlayWindow:e.overlayWindow,overlayDocument:e.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:e.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>be(`${n.location.origin}${n.location.pathname}`),targetPointToOverlay:l=>{let c=i(),p=s();return {viewportX:c.left+l.viewportX*p,viewportY:c.top+l.viewportY*p}},targetRectToOverlay:l=>{let c=i(),p=s();return {x:c.left+l.x*p,y:c.top+l.y*p,width:l.width*p,height:l.height*p}},eventTargetElement:a}}function Tt(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function Kr({children:e}){let t=useMemo(()=>Ur(),[]),[r,n]=useState("desktop"),[o,i]=useState(null),[s,a]=useState(false),[l,c]=useState(false),[p,g]=useState(false),u=r!=="desktop",f=u||p,v=ve[r],w=v.width&&v.height?{width:v.width,height:v.height}:null;useEffect(()=>{a(false),c(false);},[r]);let S=useRef(u);useEffect(()=>{S.current&&!u?g(true):!S.current&&u&&g(false),S.current=u;},[u]);let C=useMemo(()=>t?!u||!s||l||!o||!w?t:Ji(t,o,w)??t:null,[l,o,s,u,w,t]),m=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:f,previewReady:f?u&&s&&!l:true,previewBlocked:u&&l}),[r,l,s,u,f]),d=useMemo(()=>t?Zi(t.targetWindow):"",[t]);return !C||!t?null:jsx(Yr.Provider,{value:m,children:jsxs(Wr.Provider,{value:C,children:[e,jsx(AnimatePresence,{onExitComplete:()=>g(false),children:u&&w?jsx($r,{src:d,viewport:v,overlayWindow:t.overlayWindow,onFrameElement:i,onReadyChange:a,onBlockedChange:c}):null})]})})}function ae(){let e=use(Wr),t=useMemo(()=>Ur(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function Ye(){let e=use(Yr),[t,r]=useState("desktop"),n=useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var ea="X-Patch-Client-Id";function pe(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[ea]:e.clientUserId}:{}}}async function xe(e,t){try{let r=await fetch(e,t);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function ta(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 qr(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await xe(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:pe(e,false)}))?.annotations??[]},async fetchMe(){return xe(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:pe(e,false)})},async postIdentity(t){let r=await xe(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(t)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(t){return xe(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(t)})},async reply(t,r){return xe(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return xe(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:pe(e,false)})},async deleteMessage(t,r){return xe(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:pe(e,false)})},async kickoff(t,r){return ta(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(r)})},async resolve(t){return xe(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:pe(e,true)})},async reopen(t){return xe(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:pe(e,true)})}}}var or="patch.clientIdentity",jr="patch.clientAvatarSeed";function ir(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(or);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function Zr(e){return ir()[e]??null}function ar(e,t){if(!(typeof window>"u"))try{let r=ir();r[e]=t,window.localStorage.setItem(or,JSON.stringify(r));}catch{}}function Jr(e){if(!(typeof window>"u"))try{let t=ir();delete t[e],window.localStorage.setItem(or,JSON.stringify(t));}catch{}}function ra(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(jr);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function nr(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function Qr(e){if(typeof window>"u")return nr();try{let t=ra(),r=t[e];if(r)return r;let n=nr();return t[e]=n,window.localStorage.setItem(jr,JSON.stringify(t)),n}catch{return nr()}}var ia=2e4,tn=createContext(null);function aa(e,t){let r=new Map(e.map(s=>[s.id,s])),n=new Set(t.map(s=>s.id)),o=t.map(s=>{let a=r.get(s.id);if(!a)return s;let l=new Set(s.thread.map(g=>g.id)),c=a.thread.filter(g=>g.deliveryStatus&&!l.has(g.id)),p=c.length>0?{...s,thread:[...s.thread,...c]}:s;if(a.optimisticAction==="resolve-pending"&&s.status!=="resolved"&&(p={...p,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="reopen-pending"&&s.status==="resolved"&&(p={...p,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="run-pending"&&a.latestRun?.id.startsWith("tmp-run")){let g=s.latestRun?Date.parse(s.latestRun.createdAt):Number.NaN,u=Date.parse(a.latestRun.createdAt);s.latestRun!=null&&(Number.isNaN(u)||Number.isNaN(g)||g>=u)||(p={...p,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return p}),i=e.filter(s=>(s.deliveryStatus||s.optimisticAction)&&!n.has(s.id));return [...o,...i]}function rn({projectToken:e,apiBase:t,children:r}){let n=ae(),{activeViewport:o,setActiveViewport:i}=Ye(),[s,a]=useState(()=>typeof window>"u"?null:Zr(e)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":Qr(e)),[c,p]=useState(null),[g,u]=useState("client"),[f,v]=useState(null),[w,S]=useState([]),[C,m]=useState(null),[d,b]=useState([]),[y,E]=useState(false),N=useRef(o);N.current=o;let D=C===o,V=useMemo(()=>qr({apiBase:t,token:e,clientUserId:s?.clientUserId}),[t,e,s?.clientUserId]),G=useRef(V);G.current=V;let x=useRef(0),A=useCallback(async()=>{let h=o,I=++x.current,L=await G.current.listAnnotations(h==="desktop"?void 0:h);if(I!==x.current||h!==N.current)return;let X=n.getPageUrl(),ue=L.filter(ie=>be(ie.payload.url)===X);S(ie=>aa(ie,ue)),m(h);},[o,n]),O=useRef(A);O.current=A,useEffect(()=>{let h=false;return (async()=>{let I=await G.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};a(L),ar(e,L);}await O.current(),h||E(true);}})(),()=>{h=true;}},[e]),useEffect(()=>{y&&A();},[y,A]),useEffect(()=>{let{overlayDocument:h,overlayWindow:I}=n,L=I.setInterval(()=>{h.visibilityState==="visible"&&A();},ia),X=()=>{h.visibilityState==="visible"&&A();};return h.addEventListener("visibilitychange",X),()=>{I.clearInterval(L),h.removeEventListener("visibilitychange",X);}},[A,n]);let j=useCallback(async h=>(ar(e,h),a(h),h),[e]),B=useCallback(()=>{a(null),Jr(e);},[e]),K=useCallback(h=>{b(I=>[...I.filter(L=>L.tempId!==h.tempId),h]);},[]),ee=useCallback(h=>{b(I=>I.filter(L=>L.tempId!==h));},[]),de=useCallback(h=>{S(I=>{let L=I.findIndex(ue=>ue.id===h.id);if(L===-1)return [...I,h];let X=I.slice();return X[L]=h,X});},[]),se=useCallback((h,I)=>{S(L=>{let X=false,ue=L.flatMap(ie=>{if(ie.id!==h)return [ie];X=true;let Me=I(ie);return Me?[Me]:[]});return X?ue:L});},[]),le=useCallback((h,I)=>{S(L=>L.map(X=>X.id===h?{...X,id:I,deliveryStatus:"sent"}:X));},[]),Ce=useMemo(()=>({apiClient:V,ready:y,viewerKind:g,agentRunReadiness:f,activeViewport:o,clientAvatarSeed:l,identity:s,studio:c,annotations:w,annotationsReady:D,ephemerals:d,refresh:A,setActiveViewport:i,setIdentity:j,signOut:B,addEphemeral:K,removeEphemeral:ee,applyAnnotationUpdate:de,updateAnnotation:se,replaceAnnotationId:le}),[V,y,g,f,o,l,s,c,w,D,d,A,i,j,B,K,ee,de,se,le]);return jsx(tn.Provider,{value:Ce,children:r})}function me(){let e=use(tn);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var nn=createContext(null);function on({children:e}){let[t,r]=useState(null),[n,o]=useState(""),[i,s]=useState(0),[a,l]=useState(false),c=useCallback(()=>{r(null),o(""),l(false);},[]),p=useCallback(w=>{r({kind:"existing",annotationId:w}),o(""),l(false);},[]),g=useCallback(w=>{r({kind:"composer",...w}),o(""),l(false);},[]),u=useCallback(()=>{if(n.trim().length>0){s(w=>w+1);return}c();},[n,c]),f=useCallback(()=>{c();},[c]),v=useMemo(()=>({active:t,draftText:n,shakeNonce:i,confirmDiscardOpen:a,openExisting:p,openComposer:g,setDraftText:o,attemptClose:u,forceClose:f,setConfirmDiscardOpen:l}),[t,n,i,a,p,g,u,f]);return jsx(nn.Provider,{value:v,children:e})}function ge(){let e=use(nn);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var ln=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"]),pa=new Set(["a","button","input","select","textarea"]),cn={a:"link",button:"button",input:"input",select:"select",textarea:"textarea",img:"img",svg:"icon",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"paragraph",li:"list item",td:"cell",th:"header cell",label:"label",blockquote:"quote",figcaption:"caption",code:"code",pre:"code block"},Oe=40,ma=1500,an=200,ga=5,fa=10;function lr(e){return ln.has(e.tagName.toLowerCase())}function ye(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Xe(e){return `"${e}"`}function ha(e){let t="";for(let r of Array.from(e.childNodes))r.nodeType===3&&(t+=r.textContent??"");return t.replace(/\s+/g," ").trim()}function Rt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function ba(e){return !(!e||e.length>40||/__[A-Za-z0-9]{4,}$/.test(e)||/_[a-z0-9]{4,}$/i.test(e)&&/[0-9]/.test(e)||/_[A-Za-z0-9]{5,}_/.test(e)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(e)||/^[a-z]{2,}:[\w-]+$/.test(e)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(e)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(e)||(e.match(/\d/g)?.length??0)/e.length>.4)}function Le(e){let t=Array.from(e.classList),r=t.filter(ba).slice(0,fa);return r.length>0?r:t.length>0?["container"]:[]}function dn(e){let t=e.getAttribute("role")??void 0,r=e.getAttribute("aria-label")??void 0,n=e.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,i=e.tagName.toLowerCase(),s=pa.has(i)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!s)return;let a={focusable:s};return t!==void 0&&(a.role=t),r!==void 0&&(a.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(a.tabIndex=o),a}function va(e){let t=e.tagName.toLowerCase(),r=cn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Xe(ye(n,Oe))}`;let o=e.placeholder;if(o)return `${r} ${Xe(ye(o,Oe))}`;let i=e.getAttribute("name");if(i)return `${r}[name="${i}"]`;if(t==="input"){let s=e.type||"text";return `${r}[type=${s}]`}return r}function xa(e){let t=e.alt?.trim();return t?`img ${Xe(ye(t,Oe))}`:"img"}function nt(e){let t=e.tagName.toLowerCase();if(t==="img")return xa(e);if(t==="input"||t==="textarea"||t==="select")return va(e);let r=cn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Xe(ye(n,Oe))}`;if(t==="a"||t==="button"||ln.has(t)||t==="label"){let i=Rt(e);if(i)return `${r} ${Xe(ye(i,Oe))}`;if(t==="a"||t==="button"){let s=e.querySelector("svg");if(s){let l=s.getAttribute("aria-label");return l?`${r} ${Xe(ye(l,Oe))}`:`${r} (icon)`}let a=e.getAttribute("href");if(t==="a"&&a)return `link[href="${ye(a,Oe)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=Le(e);return o.length>0?`${t}.${o[0]}`:t}function un(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(nt(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,ma)}function pn(e){let t=Rt(e),r=e.parentElement;if(!r)return;let n=Rt(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let i=Rt(o);return !i||i===t?void 0:ye(i,an)}return ye(n,an)}}function mn(e){let t=e.parentElement;if(!t)return [];let r=[];for(let n of Array.from(t.children))if(n!==e&&n.tagName.toLowerCase()!=="script"&&(r.push(nt(n)),r.length>=ga))break;return r}var wa=["role","aria-label","name"],ya=10,sn=100;function It(e){let t={};for(let r of wa){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,sn));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=ya)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,sn));}return t}function Nt(e){return ha(e)}function gn(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function Pt(e,t){return e.closest(`[${t}]`)!==null}var ka=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"]),Ca={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"},Aa={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"},Ta={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 hn(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function Sa(e){return `"${e}"`}function Mt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function fn(e){let t=e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""}function Z(e,t){let r=t?.trim();return r?`${e}: ${Sa(hn(r,48))}`:e}function Ea(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function Ra(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Ta[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":Aa[n]??"Area":"Area"}function Ia(e){let t=e.getAttribute("aria-label");if(t)return Z("Field",t);let r=e.placeholder;if(r)return Z("Field",r);let n=e.getAttribute("name");if(n)return Z("Field",fn(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return Z("Field",fn(o))}return "Field"}function ot(e,t){if(t?.trim())return Z("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return Z("Button",n??Mt(e));if(r==="a")return Z("Link",n??Mt(e));if(r==="input"||r==="textarea"||r==="select")return Ia(e);if(r==="img"){let i=e.alt;return Z("Image",i)}if(r==="svg")return Z("Icon",n);if(/^h[1-6]$/.test(r))return Z("Heading",Mt(e));if(ka.has(r))return Z("Text",Mt(e));let o=Ca[r];return Z(o||"Area",n)}function _t(e){return e===1?"1 item selected":`${e} items selected`}function Dt(){return "Selected area"}function bn(e){if(e.targetLabel?.trim())return hn(e.targetLabel,120);if(e.selectedText?.trim())return Z("Selected text",e.selectedText);let t=e.element?.trim()||e.elementPath?.trim();if(!t)return "Annotation";let r=t.match(/^(\d+)\s+elements?:/i);if(r)return _t(Number(r[1]));if(/^region\b/i.test(t))return Dt();let n=Ea(t.split(">").at(-1)??t);return Z(Ra(n.base),n.text)}function yn(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=gn(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 vn=20,kn=7,xn=10,Na=.8,Pa=.5,Ma=new Set(["html","body","head","script","style","meta","link","title","br","noscript"]),_a=new Set(["section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details","summary"]),Ot=24;function Cn(e){let t=e.tagName.toLowerCase();if(_a.has(t))return true;if(t==="div"||t==="span"){if(e.id)return true;let r=Le(e);if(r.length>0&&r[0]!=="container")return true}return false}var Da=["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 wn(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Oa(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 La(e,t,r){if(Pt(e,r))return false;let n=e.tagName.toLowerCase();if(Ma.has(n))return false;let o=e.getBoundingClientRect();if(o.width<xn||o.height<xn||o.width>t.width*Na||o.height>t.height*Pa)return false;if(n==="div"||n==="span"){let i=Array.from(e.childNodes).some(l=>l.nodeType===3&&(l.textContent??"").trim().length>0),s=e.getAttribute("role"),a=s!==null&&s.length>0;if(!i&&!a&&!Cn(e))return false}return true}function za(e){return e.filter(t=>!e.some(r=>r!==t&&t.contains(r)))}function Ha(e,t){let r=[...e].sort((n,o)=>{let i=n.getBoundingClientRect(),s=o.getBoundingClientRect();return i.width*i.height-s.width*s.height});for(let n of r){if(!Cn(n)||!e.every(a=>a===n||n.contains(a)))continue;let i=n.getBoundingClientRect();if(i.left>=t.x-Ot&&i.top>=t.y-Ot&&i.right<=t.x+t.width+Ot&&i.bottom<=t.y+t.height+Ot)return n}return null}function $a(e){let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let i of e)i.x<t&&(t=i.x),i.y<r&&(r=i.y),i.x+i.width>n&&(n=i.x+i.width),i.y+i.height>o&&(o=i.y+i.height);return {x:t,y:r,width:n-t,height:o-r}}function Fa(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 An(e){let{rect:t,viewport:r,internalAttr:n}=e,o=e.doc??document,i=new Set;for(let c of Fa(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(Da)))Oa(wn(c.getBoundingClientRect()),t)&&i.add(c);let s=Array.from(i).filter(c=>La(c,r,n)),a=Ha(s,t),l=a?[a]:za(s);if(l.length>0){let c=l.map(p=>wn(p.getBoundingClientRect()));return {kind:"multi",elements:l,rects:c,union:$a(c)}}return t.width>=vn&&t.height>=vn?{kind:"area",rect:t}:null}var Tn="patch-capture-cursor-style";function Va(e){let t=`:not([${e}]):not([${e}] *)`,r=["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"].map(n=>`body ${n}${t}`).join(`,
|
|
2
|
+
import {createContext,useMemo,useState,useRef,useEffect,useCallback,use,createElement,useId,useLayoutEffect}from'react';import {AnimatePresence,useReducedMotion,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';function be(e){if(e.length<=1||!e.endsWith("/"))return e;try{let t=new URL(e);if(t.pathname==="/"&&e.endsWith("/"))return `${t.origin}${t.search}${t.hash}`}catch{}return e.slice(0,-1)}var ve={desktop:{viewport:"desktop",label:"Desktop",width:null,height:null,glyph:"desktop"},tablet:{viewport:"tablet",label:"Tablet",width:834,height:1194,glyph:"tablet"},mobile:{viewport:"mobile",label:"Mobile",width:390,height:844,glyph:"mobile"}},_r=["desktop","tablet","mobile"];function $e(e){let t=ve[e];return t.width===null||t.height===null?t.label:`${t.label} (${t.width}px \xD7 ${t.height}px)`}function Dr(e,t){let r=ve[e];return {width:r.width??t.width,height:r.height??t.height}}var Ii=32,Ni=32,Pi=3e3,zr="cubic-bezier(0.16, 1, 0.3, 1)",Ct=[.22,.61,.36,1],Hr=.3,Fr=.5,Mi=.34,_i=.5,Di=.24,Oi=.22,$r=.12,Li=.42,Vr=.2,zi=200,Hi=260,Fi=70,$i=180,Vi=260,Bi=8,Wi=4,Yi="#d9d9dd",Xi=30,Ui=["0 2px 8px rgba(0,0,0,0.20)","0 30px 60px -18px rgba(0,0,0,0.55)","0 70px 130px -52px rgba(0,0,0,0.55)"].join(", ");function At(e,t,r){let n=Math.max(320,e.innerWidth-Ii*2),o=Math.max(320,e.innerHeight-Ni*2);return Math.min(1,n/t,o/r)}function Gi(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function Br({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:i}){let s=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]=useState(()=>({viewport:c,width:a,height:l,scale:At(r,a,l)})),[x,w]=useState("stable"),[E,k]=useState(false),[m,d]=useState(false),v=useRef(false),C=useRef(null),P=`${u.viewport}:${u.width}:${u.height}`!==p,X=E&&!m&&!(P||x==="cover"||x==="resize"),G=E&&!m&&x==="stable"&&!P,re=useCallback(h=>{C.current=h,n(h);},[n]),b=useCallback(()=>{let h=C.current;if(!h||!Gi(h)){v.current=false,k(false),d(true);return}v.current=true,k(true),d(false);},[]),A=useCallback(()=>{f(h=>{let N=At(r,h.width,h.height);return h.scale===N?h:{...h,scale:N}});},[r]);useEffect(()=>(A(),r.addEventListener("resize",A),()=>r.removeEventListener("resize",A)),[r,A]),useEffect(()=>{v.current=false,k(false),d(false);let h=r.setTimeout(()=>{v.current||d(true);},Pi);return ()=>r.clearTimeout(h)},[e,r]),useEffect(()=>{if(s){P&&f({viewport:c,width:a,height:l,scale:At(r,a,l)}),x!=="stable"&&w("stable");return}switch(x){case "stable":{P&&w("cover");return}case "cover":{let h=r.setTimeout(()=>w("resize"),Fi);return ()=>r.clearTimeout(h)}case "resize":{P&&f({viewport:c,width:a,height:l,scale:At(r,a,l)});let h=r.setTimeout(()=>w("reveal"),$i);return ()=>r.clearTimeout(h)}case "reveal":{let h=r.setTimeout(()=>w("stable"),Vi);return ()=>r.clearTimeout(h)}}},[x,P,s,r,c,a,l]),useEffect(()=>{o(G);},[G,o]),useEffect(()=>{i(m);},[m,i]);let M=s?{duration:0}:{duration:Di,ease:Ct},I=s?{duration:0}:{duration:Oi,ease:Ct,delay:Vr*.5},D=s?{duration:0}:{duration:Vr,ease:Ct},ie=s?{duration:0}:{opacity:{duration:Li,ease:Ct,delay:$r},scale:{type:"spring",bounce:Mi,duration:_i,delay:$r},width:{type:"spring",bounce:Hr,duration:Fr},height:{type:"spring",bounce:Hr,duration:Fr}},Q=(X?Hi:zi)/1e3,le=s?void 0:`opacity ${Q}s ${zr}, filter ${Q}s ${zr}`,ce=u.width*u.scale,Ce=u.height*u.scale;return jsx(motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:M},exit:{opacity:0,transition:I},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxs(motion.div,{initial:s?{opacity:0,width:ce,height:Ce}:{opacity:0,scale:.8,width:ce,height:Ce},animate:{opacity:1,scale:1,width:ce,height:Ce},exit:s?{opacity:0}:{opacity:0,scale:.92,transition:D},transition:ie,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${Wi}px solid ${Yi}`,borderRadius:Xi,boxShadow:Ui,willChange:"width, height"},children:[jsx("div",{"aria-hidden":!X,className:"absolute top-0 left-0 origin-top-left",style:{width:u.width,height:u.height,transform:`scale(${u.scale})`,opacity:X?1:0,filter:s||X?"none":`blur(${Bi}px)`,transition:le,pointerEvents:X?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:re,"data-patch-preview-frame":"","data-patch-preview-src":e,title:`${t.label} preview`,tabIndex:X?0:-1,src:g?void 0:e,srcDoc:g?"<!doctype html><html><body></body></html>":void 0,onLoad:b,className:"block bg-white",style:{width:u.width,height:u.height,border:0}})}),jsx(Ki,{visible:m})]})})}function Ki({visible:e}){return e?jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsx("div",{className:"max-w-[320px] rounded-[20px] bg-white px-5 py-4 text-center text-[13px] leading-[1.45] text-foreground shadow-[0_18px_44px_-18px_rgba(0,0,0,0.28)]",children:"This site blocks embedding. Add X-Frame-Options: SAMEORIGIN or frame-ancestors 'self' to enable viewport previews."})}):null}var Ur=createContext(null),Gr=createContext(null),Kr="__patch_preview";function qr(){return typeof window>"u"||typeof document>"u"?null:{targetWindow:window,targetDocument:document,overlayWindow:window,overlayDocument:document,getTargetViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getOverlayViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getTargetScrollY:()=>window.scrollY,getPageUrl:()=>be(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:e=>({...e}),targetRectToOverlay:e=>({...e}),eventTargetElement:e=>e instanceof window.Element?e:null}}function Ji(e){let t=new URL(e.location.href);return t.searchParams.set(Kr,"1"),t.toString()}function jr(e=window){try{return new URL(e.location.href).searchParams.get(Kr)==="1"}catch{return false}}function Qi(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function i(){return t.getBoundingClientRect()}function s(){let l=i();return r.width>0?l.width/r.width:1}function a(l){if(!l)return null;let c=n.Element;return l instanceof c?l:null}return {targetWindow:n,targetDocument:o,overlayWindow:e.overlayWindow,overlayDocument:e.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:e.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>be(`${n.location.origin}${n.location.pathname}`),targetPointToOverlay:l=>{let c=i(),p=s();return {viewportX:c.left+l.viewportX*p,viewportY:c.top+l.viewportY*p}},targetRectToOverlay:l=>{let c=i(),p=s();return {x:c.left+l.x*p,y:c.top+l.y*p,width:l.width*p,height:l.height*p}},eventTargetElement:a}}function Tt(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function Zr({children:e}){let t=useMemo(()=>qr(),[]),[r,n]=useState("desktop"),[o,i]=useState(null),[s,a]=useState(false),[l,c]=useState(false),[p,g]=useState(false),u=r!=="desktop",f=u||p,x=ve[r],w=x.width&&x.height?{width:x.width,height:x.height}:null;useEffect(()=>{a(false),c(false);},[r]);let E=useRef(u);useEffect(()=>{E.current&&!u?g(true):!E.current&&u&&g(false),E.current=u;},[u]);let k=useMemo(()=>t?!u||!s||l||!o||!w?t:Qi(t,o,w)??t:null,[l,o,s,u,w,t]),m=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:f,previewReady:f?u&&s&&!l:true,previewBlocked:u&&l}),[r,l,s,u,f]),d=useMemo(()=>t?Ji(t.targetWindow):"",[t]);return !k||!t?null:jsx(Gr.Provider,{value:m,children:jsxs(Ur.Provider,{value:k,children:[e,jsx(AnimatePresence,{onExitComplete:()=>g(false),children:u&&w?jsx(Br,{src:d,viewport:x,overlayWindow:t.overlayWindow,onFrameElement:i,onReadyChange:a,onBlockedChange:c}):null})]})})}function se(){let e=use(Ur),t=useMemo(()=>qr(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function Ye(){let e=use(Gr),[t,r]=useState("desktop"),n=useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var ta="X-Patch-Client-Id";function pe(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[ta]:e.clientUserId}:{}}}async function xe(e,t){try{let r=await fetch(e,t);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function ra(e,t){try{let r=await fetch(e,t),n=await r.text(),o=n?JSON.parse(n):null;return r.ok?o??{ok:!0}:{ok:!1,error:o&&typeof o=="object"&&typeof o.error=="string"?o.error:"Request failed."}}catch{return null}}function Jr(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await xe(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:pe(e,false)}))?.annotations??[]},async fetchMe(){return xe(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:pe(e,false)})},async postIdentity(t){let r=await xe(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(t)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(t){return xe(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(t)})},async reply(t,r){return xe(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return xe(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:pe(e,false)})},async deleteMessage(t,r){return xe(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:pe(e,false)})},async kickoff(t,r){return ra(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:pe(e,true),body:JSON.stringify(r)})},async resolve(t){return xe(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:pe(e,true)})},async reopen(t){return xe(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:pe(e,true)})}}}var or="patch.clientIdentity",Qr="patch.clientAvatarSeed";function ir(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(or);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function en(e){return ir()[e]??null}function ar(e,t){if(!(typeof window>"u"))try{let r=ir();r[e]=t,window.localStorage.setItem(or,JSON.stringify(r));}catch{}}function tn(e){if(!(typeof window>"u"))try{let t=ir();delete t[e],window.localStorage.setItem(or,JSON.stringify(t));}catch{}}function na(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(Qr);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function nr(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function rn(e){if(typeof window>"u")return nr();try{let t=na(),r=t[e];if(r)return r;let n=nr();return t[e]=n,window.localStorage.setItem(Qr,JSON.stringify(t)),n}catch{return nr()}}var aa=2e4,on=createContext(null);function sa(e,t){let r=new Map(e.map(s=>[s.id,s])),n=new Set(t.map(s=>s.id)),o=t.map(s=>{let a=r.get(s.id);if(!a)return s;let l=new Set(s.thread.map(g=>g.id)),c=a.thread.filter(g=>g.deliveryStatus&&!l.has(g.id)),p=c.length>0?{...s,thread:[...s.thread,...c]}:s;if(a.optimisticAction==="resolve-pending"&&s.status!=="resolved"&&(p={...p,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="reopen-pending"&&s.status==="resolved"&&(p={...p,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="run-pending"&&a.latestRun?.id.startsWith("tmp-run")){let g=s.latestRun?Date.parse(s.latestRun.createdAt):Number.NaN,u=Date.parse(a.latestRun.createdAt);s.latestRun!=null&&(Number.isNaN(u)||Number.isNaN(g)||g>=u)||(p={...p,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return p}),i=e.filter(s=>(s.deliveryStatus||s.optimisticAction)&&!n.has(s.id));return [...o,...i]}function an({projectToken:e,apiBase:t,children:r}){let n=se(),{activeViewport:o,setActiveViewport:i}=Ye(),[s,a]=useState(()=>typeof window>"u"?null:en(e)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":rn(e)),[c,p]=useState(null),[g,u]=useState("client"),[f,x]=useState(null),[w,E]=useState([]),[k,m]=useState(null),[d,v]=useState([]),[C,T]=useState(false),P=useRef(o);P.current=o;let z=k===o,X=useMemo(()=>Jr({apiBase:t,token:e,clientUserId:s?.clientUserId}),[t,e,s?.clientUserId]),G=useRef(X);G.current=X;let re=useRef(0),b=useCallback(async()=>{let h=o,N=++re.current,H=await G.current.listAnnotations(h==="desktop"?void 0:h);if(N!==re.current||h!==P.current)return;let U=n.getPageUrl(),ue=H.filter(ae=>be(ae.payload.url)===U);E(ae=>sa(ae,ue)),m(h);},[o,n]),A=useRef(b);A.current=b,useEffect(()=>{let h=false;return (async()=>{let N=await G.current.fetchMe();if(!h){if(N?.studio)p(N.studio),u("studio"),x(N.agentRunReadiness??{ready:true,message:null});else if(p(null),u("client"),x(null),N?.client){let H={clientUserId:N.client.id,name:N.client.name,email:N.client.email,avatarSeed:N.client.avatarSeed};a(H),ar(e,H);}await A.current(),h||T(true);}})(),()=>{h=true;}},[e]),useEffect(()=>{C&&b();},[C,b]),useEffect(()=>{let{overlayDocument:h,overlayWindow:N}=n,H=N.setInterval(()=>{h.visibilityState==="visible"&&b();},aa),U=()=>{h.visibilityState==="visible"&&b();};return h.addEventListener("visibilitychange",U),()=>{N.clearInterval(H),h.removeEventListener("visibilitychange",U);}},[b,n]);let M=useCallback(async h=>(ar(e,h),a(h),h),[e]),I=useCallback(()=>{a(null),tn(e);},[e]),D=useCallback(h=>{v(N=>[...N.filter(H=>H.tempId!==h.tempId),h]);},[]),ie=useCallback(h=>{v(N=>N.filter(H=>H.tempId!==h));},[]),Q=useCallback(h=>{E(N=>{let H=N.findIndex(ue=>ue.id===h.id);if(H===-1)return [...N,h];let U=N.slice();return U[H]=h,U});},[]),le=useCallback((h,N)=>{E(H=>{let U=false,ue=H.flatMap(ae=>{if(ae.id!==h)return [ae];U=true;let Me=N(ae);return Me?[Me]:[]});return U?ue:H});},[]),ce=useCallback((h,N)=>{E(H=>H.map(U=>U.id===h?{...U,id:N,deliveryStatus:"sent"}:U));},[]),Ce=useMemo(()=>({apiClient:X,ready:C,viewerKind:g,agentRunReadiness:f,activeViewport:o,clientAvatarSeed:l,identity:s,studio:c,annotations:w,annotationsReady:z,ephemerals:d,refresh:b,setActiveViewport:i,setIdentity:M,signOut:I,addEphemeral:D,removeEphemeral:ie,applyAnnotationUpdate:Q,updateAnnotation:le,replaceAnnotationId:ce}),[X,C,g,f,o,l,s,c,w,z,d,b,i,M,I,D,ie,Q,le,ce]);return jsx(on.Provider,{value:Ce,children:r})}function me(){let e=use(on);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var sn=createContext(null);function ln({children:e}){let[t,r]=useState(null),[n,o]=useState(""),[i,s]=useState(0),[a,l]=useState(false),c=useCallback(()=>{r(null),o(""),l(false);},[]),p=useCallback(w=>{r({kind:"existing",annotationId:w}),o(""),l(false);},[]),g=useCallback(w=>{r({kind:"composer",...w}),o(""),l(false);},[]),u=useCallback(()=>{if(n.trim().length>0){s(w=>w+1);return}c();},[n,c]),f=useCallback(()=>{c();},[c]),x=useMemo(()=>({active:t,draftText:n,shakeNonce:i,confirmDiscardOpen:a,openExisting:p,openComposer:g,setDraftText:o,attemptClose:u,forceClose:f,setConfirmDiscardOpen:l}),[t,n,i,a,p,g,u,f]);return jsx(sn.Provider,{value:x,children:e})}function ge(){let e=use(sn);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var un=new Set(["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),ma=new Set(["a","button","input","select","textarea"]),pn={a:"link",button:"button",input:"input",select:"select",textarea:"textarea",img:"img",svg:"icon",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"paragraph",li:"list item",td:"cell",th:"header cell",label:"label",blockquote:"quote",figcaption:"caption",code:"code",pre:"code block"},Oe=40,ga=1500,cn=200,fa=5,ha=10;function lr(e){return un.has(e.tagName.toLowerCase())}function ye(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Xe(e){return `"${e}"`}function ba(e){let t="";for(let r of Array.from(e.childNodes))r.nodeType===3&&(t+=r.textContent??"");return t.replace(/\s+/g," ").trim()}function Rt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function va(e){return !(!e||e.length>40||/__[A-Za-z0-9]{4,}$/.test(e)||/_[a-z0-9]{4,}$/i.test(e)&&/[0-9]/.test(e)||/_[A-Za-z0-9]{5,}_/.test(e)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(e)||/^[a-z]{2,}:[\w-]+$/.test(e)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(e)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(e)||(e.match(/\d/g)?.length??0)/e.length>.4)}function Le(e){let t=Array.from(e.classList),r=t.filter(va).slice(0,ha);return r.length>0?r:t.length>0?["container"]:[]}function mn(e){let t=e.getAttribute("role")??void 0,r=e.getAttribute("aria-label")??void 0,n=e.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,i=e.tagName.toLowerCase(),s=ma.has(i)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!s)return;let a={focusable:s};return t!==void 0&&(a.role=t),r!==void 0&&(a.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(a.tabIndex=o),a}function xa(e){let t=e.tagName.toLowerCase(),r=pn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Xe(ye(n,Oe))}`;let o=e.placeholder;if(o)return `${r} ${Xe(ye(o,Oe))}`;let i=e.getAttribute("name");if(i)return `${r}[name="${i}"]`;if(t==="input"){let s=e.type||"text";return `${r}[type=${s}]`}return r}function wa(e){let t=e.alt?.trim();return t?`img ${Xe(ye(t,Oe))}`:"img"}function nt(e){let t=e.tagName.toLowerCase();if(t==="img")return wa(e);if(t==="input"||t==="textarea"||t==="select")return xa(e);let r=pn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Xe(ye(n,Oe))}`;if(t==="a"||t==="button"||un.has(t)||t==="label"){let i=Rt(e);if(i)return `${r} ${Xe(ye(i,Oe))}`;if(t==="a"||t==="button"){let s=e.querySelector("svg");if(s){let l=s.getAttribute("aria-label");return l?`${r} ${Xe(ye(l,Oe))}`:`${r} (icon)`}let a=e.getAttribute("href");if(t==="a"&&a)return `link[href="${ye(a,Oe)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=Le(e);return o.length>0?`${t}.${o[0]}`:t}function gn(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(nt(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,ga)}function fn(e){let t=Rt(e),r=e.parentElement;if(!r)return;let n=Rt(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let i=Rt(o);return !i||i===t?void 0:ye(i,cn)}return ye(n,cn)}}function hn(e){let t=e.parentElement;if(!t)return [];let r=[];for(let n of Array.from(t.children))if(n!==e&&n.tagName.toLowerCase()!=="script"&&(r.push(nt(n)),r.length>=fa))break;return r}var ya=["role","aria-label","name"],ka=10,dn=100;function It(e){let t={};for(let r of ya){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,dn));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=ka)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,dn));}return t}function Nt(e){return ba(e)}function bn(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function Pt(e,t){return e.closest(`[${t}]`)!==null}var Ca=new Set(["p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),Aa={article:"Article",aside:"Sidebar",dialog:"Dialog",fieldset:"Form section",figure:"Image",footer:"Footer",form:"Form",header:"Header",main:"Main content",nav:"Navigation",section:"Section",summary:"Summary"},Ta={a:"Link",article:"Article",aside:"Sidebar",blockquote:"Text",button:"Button",code:"Text",div:"Area",figcaption:"Text",figure:"Image",footer:"Footer",form:"Form",header:"Header",img:"Image",input:"Field",label:"Text",li:"Text",main:"Main content",nav:"Navigation",p:"Text",pre:"Text",section:"Section",select:"Field",span:"Text",svg:"Icon",textarea:"Field"},Sa={caption:"Text",cell:"Text","code block":"Text",icon:"Icon",input:"Field",label:"Text",link:"Link","list item":"Text",paragraph:"Text",quote:"Text",select:"Field",textarea:"Field"};function xn(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function Ea(e){return `"${e}"`}function Mt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function vn(e){let t=e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""}function j(e,t){let r=t?.trim();return r?`${e}: ${Ea(xn(r,48))}`:e}function Ra(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function Ia(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Sa[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":Ta[n]??"Area":"Area"}function Na(e){let t=e.getAttribute("aria-label");if(t)return j("Field",t);let r=e.placeholder;if(r)return j("Field",r);let n=e.getAttribute("name");if(n)return j("Field",vn(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return j("Field",vn(o))}return "Field"}function ot(e,t){if(t?.trim())return j("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return j("Button",n??Mt(e));if(r==="a")return j("Link",n??Mt(e));if(r==="input"||r==="textarea"||r==="select")return Na(e);if(r==="img"){let i=e.alt;return j("Image",i)}if(r==="svg")return j("Icon",n);if(/^h[1-6]$/.test(r))return j("Heading",Mt(e));if(Ca.has(r))return j("Text",Mt(e));let o=Aa[r];return j(o||"Area",n)}function _t(e){return e===1?"1 item selected":`${e} items selected`}function Dt(){return "Selected area"}function wn(e){if(e.targetLabel?.trim())return xn(e.targetLabel,120);if(e.selectedText?.trim())return j("Selected text",e.selectedText);let t=e.element?.trim()||e.elementPath?.trim();if(!t)return "Annotation";let r=t.match(/^(\d+)\s+elements?:/i);if(r)return _t(Number(r[1]));if(/^region\b/i.test(t))return Dt();let n=Ra(t.split(">").at(-1)??t);return j(Ia(n.base),n.text)}function An(e){let{clickTarget:t,selection:r}=e,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),i=bn(o.commonAncestorContainer);if(i)return {kind:"element",element:i,rect:i.getBoundingClientRect(),selectedText:n,clickTarget:t}}return {kind:"element",element:t,rect:t.getBoundingClientRect(),clickTarget:t}}var yn=20,Tn=7,kn=10,Pa=.8,Ma=.5,_a=new Set(["html","body","head","script","style","meta","link","title","br","noscript"]),Da=new Set(["section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details","summary"]),Ot=24;function Sn(e){let t=e.tagName.toLowerCase();if(Da.has(t))return true;if(t==="div"||t==="span"){if(e.id)return true;let r=Le(e);if(r.length>0&&r[0]!=="container")return true}return false}var Oa=["a","button","input","select","textarea","img","svg","h1","h2","h3","h4","h5","h6","p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","div","section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details"].join(",");function Cn(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function La(e,t){return !(e.x+e.width<t.x||t.x+t.width<e.x||e.y+e.height<t.y||t.y+t.height<e.y)}function za(e,t,r){if(Pt(e,r))return false;let n=e.tagName.toLowerCase();if(_a.has(n))return false;let o=e.getBoundingClientRect();if(o.width<kn||o.height<kn||o.width>t.width*Pa||o.height>t.height*Ma)return false;if(n==="div"||n==="span"){let i=Array.from(e.childNodes).some(l=>l.nodeType===3&&(l.textContent??"").trim().length>0),s=e.getAttribute("role"),a=s!==null&&s.length>0;if(!i&&!a&&!Sn(e))return false}return true}function Ha(e){return e.filter(t=>!e.some(r=>r!==t&&t.contains(r)))}function Fa(e,t){let r=[...e].sort((n,o)=>{let i=n.getBoundingClientRect(),s=o.getBoundingClientRect();return i.width*i.height-s.width*s.height});for(let n of r){if(!Sn(n)||!e.every(a=>a===n||n.contains(a)))continue;let i=n.getBoundingClientRect();if(i.left>=t.x-Ot&&i.top>=t.y-Ot&&i.right<=t.x+t.width+Ot&&i.bottom<=t.y+t.height+Ot)return n}return null}function $a(e){let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let i of e)i.x<t&&(t=i.x),i.y<r&&(r=i.y),i.x+i.width>n&&(n=i.x+i.width),i.y+i.height>o&&(o=i.y+i.height);return {x:t,y:r,width:n-t,height:o-r}}function Va(e){let t=e.x+e.width/2,r=e.y+e.height/2,n=e.x+e.width,o=e.y+e.height;return [{x:e.x,y:e.y},{x:t,y:e.y},{x:n,y:e.y},{x:e.x,y:r},{x:t,y:r},{x:n,y:r},{x:e.x,y:o},{x:t,y:o},{x:n,y:o}]}function En(e){let{rect:t,viewport:r,internalAttr:n}=e,o=e.doc??document,i=new Set;for(let c of Va(t)){let p=o.elementsFromPoint(c.x,c.y);for(let g of p)i.add(g);}for(let c of Array.from(o.querySelectorAll(Oa)))La(Cn(c.getBoundingClientRect()),t)&&i.add(c);let s=Array.from(i).filter(c=>za(c,r,n)),a=Fa(s,t),l=a?[a]:Ha(s);if(l.length>0){let c=l.map(p=>Cn(p.getBoundingClientRect()));return {kind:"multi",elements:l,rects:c,union:$a(c)}}return t.width>=yn&&t.height>=yn?{kind:"area",rect:t}:null}var Rn="patch-capture-cursor-style";function Ba(e){let t=`:not([${e}]):not([${e}] *)`,r=["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"].map(n=>`body ${n}${t}`).join(`,
|
|
3
3
|
`);return ["html, body { cursor: crosshair !important; }",`body *${t} { cursor: crosshair !important; }`,`${r} { cursor: text !important; }`].join(`
|
|
4
|
-
`)}function Ba(e,t){let r=e.targetDocument,n=r.getElementById(Tn);n&&n.remove();let o=r.createElement("style");return o.id=Tn,o.setAttribute(t,""),o.textContent=Va(t),r.head.appendChild(o),o}function Lt(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var ze=1.5,En="#0287FE",Rn="rgba(2, 135, 254, 0.032)";function Wa(e){let t=e.split(" ")[0]??"",r=Number.parseFloat(t);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Ya(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 ${En}`,background:Rn,boxSizing:"border-box",zIndex:"2147483645",display:"none",borderRadius:"6px",transition:"top 80ms ease-out, left 80ms ease-out, width 80ms ease-out, height 80ms ease-out, border-radius 80ms ease-out"});let o=r.createElement("div");o.setAttribute(t,""),Object.assign(o.style,{position:"fixed",pointerEvents:"none",background:"#111",color:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"12px",fontWeight:"500",padding:"6px 10px",borderRadius:"6px",zIndex:"2147483646",maxWidth:"240px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"none",boxShadow:"0 10px 24px -12px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.08)"}),r.body.appendChild(n),r.body.appendChild(o);let i=null;return {update(s){let a=s.getBoundingClientRect();if(a.width===0&&a.height===0){this.hide();return}n.style.display="block",n.style.top=`${a.top-ze}px`,n.style.left=`${a.left-ze}px`,n.style.width=`${a.width+ze*2}px`,n.style.height=`${a.height+ze*2}px`,n.style.borderRadius=`${Wa(e.targetWindow.getComputedStyle(s).borderRadius)+ze}px`,s!==i&&(o.textContent=ot(s),i=s),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),p=e.getTargetViewport().width-8;l+240<=p?(o.style.left=`${l}px`,o.style.top=`${c}px`):(o.style.left=`${Math.max(8,a.right-240)}px`,o.style.top=`${Math.max(8,a.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function Xa(e,t){let r=e.targetDocument.createElement("div");return r.setAttribute(t,""),Object.assign(r.style,{position:"fixed",pointerEvents:"none",border:`${ze}px solid ${En}`,background:Rn,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 Sn(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 In(e){let{internalAttr:t,onClick:r,onDrag:n,surface:o}=e,i=o.targetDocument,s=Ba(o,t),a=Ya(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);Lt(o,d.target,t)||b&&lr(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=Sn({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);Lt(o,d.target,t)||b&&lr(b)||(d.preventDefault(),d.stopPropagation());},w=m=>{let d=m;Lt(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)<kn)return;c.isDragging=true,a.hide(),c.rectOverlay=Xa(o,t);}c.rectOverlay?.update(Sn({x:c.startX,y:c.startY},{x:d.clientX,y:d.clientY}));return}if(l)return;let b=o.eventTargetElement(d.target);if(!b){a.hide();return}if(Lt(o,b,t)){a.hide();return}let y=b.tagName.toLowerCase();if(y==="html"||y==="body"){a.hide();return}a.update(b);},C=m=>{m.relatedTarget||a.hide();};return i.addEventListener("mousedown",f,true),i.addEventListener("mouseup",v,true),i.addEventListener("click",w,true),i.addEventListener("mousemove",S,true),i.addEventListener("mouseout",C,true),{exit(){s.remove(),a.destroy(),g(),u(),i.removeEventListener("mousedown",f,true),i.removeEventListener("mouseup",v,true),i.removeEventListener("click",w,true),i.removeEventListener("mousemove",S,true),i.removeEventListener("mouseout",C,true);},pause(){l=true,a.hide(),g();},resume(){l=false;},dismissDragOverlay(){u();}}}var Nn="data-patch-internal",_n=createContext(null),Pn=0;function Mn(){return Pn+=1,`tmp-${Date.now().toString(36)}-${Pn}`}function Dn({children:e}){let t=ge(),r=me(),n=ae(),{isPreviewing:o,previewReady:i}=Ye(),[s,a]=useState(false),l=useRef(null),c=useRef(t),p=useRef(r);c.current=t,p.current=r;let g=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=yn({clickTarget:b,selection:y}),N=Mn(),D={viewportX:m.clientX,viewportY:m.clientY,documentY:m.clientY+n.getTargetScrollY()};p.current.addEphemeral({tempId:N,viewportX:D.viewportX,viewportY:D.viewportY,documentY:D.documentY}),c.current.openComposer({tempId:N,target:E,anchor:D}),l.current?.pause();},[n]),u=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=An({rect:m,viewport:y,internalAttr:Nn,doc:n.targetDocument});if(!E){l.current?.dismissDragOverlay();return}let N=Mn(),D={viewportX:d.viewportX,viewportY:d.viewportY,documentY:d.viewportY+n.getTargetScrollY()};p.current.addEphemeral({tempId:N,viewportX:D.viewportX,viewportY:D.viewportY,documentY:D.documentY}),c.current.openComposer({tempId:N,target:E,anchor:D}),l.current?.pause();},[n]),f=r.annotationsReady&&(!o||i);useEffect(()=>{if(!s||!f){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=In({internalAttr:Nn,surface:n,onClick:g,onDrag:(m,d)=>u(m,{viewportX:d.clientX,viewportY:d.clientY})}),()=>{l.current?.exit(),l.current=null;}},[s,g,u,n,f]);let v=useCallback(()=>{s||a(true);},[s]),w=useCallback(()=>{a(false);},[]),S=useRef(null);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]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let C=useMemo(()=>({isCapturing:s,enter:v,exit:w}),[s,v,w]);return jsx(_n.Provider,{value:C,children:e})}function On(){let e=use(_n);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var zn=createContext(null);function Hn({children:e}){let[t,r]=useState(false),[n,o]=useState(false),i=useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsx(zn.Provider,{value:i,children:e})}function $t(){let e=use(zn);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var ts="[Patch] No project token found. Pass `projectToken` as a prop, or set NEXT_PUBLIC_PATCH_TOKEN (Next.js), VITE_PATCH_TOKEN (Vite / React Router), or PUBLIC_PATCH_TOKEN (Astro) in your env.";function $n(e){let t=e.prop?.trim();if(t)return t;let r=e.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=e.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=e.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();if(o)return o;throw new Error(ts)}function Fn(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function Vn(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var rs=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 ns(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Bn(e){return e.replace(/\s+/g," ").trim()}function dr(e){return rs.has(Bn(e))}function Wn(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Bn(n[1]??"");!o||dr(o)||t[t.length-1]!==o&&t.push(o);}return t.length===0?null:ns(t.map(n=>`<${n}>`).join(" "),1e3)}var Yn="seed:";function Ft(e){return e?e.startsWith(Yn)?{url:null,seed:e.slice(Yn.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var ur=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],Xn=[{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]}],Un=Math.PI*2;function os(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 is(e){return ()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function W(e,t,r){return t+e()*(r-t)}function te(e,t=3){let r=10**t;return Math.round(e*r)/r}function Gn(e,t,r){return `hsl(${te((e%360+360)%360,1)} ${te(t,1)}% ${te(r,1)}%)`}function Kn(e){let t=os(e?.trim()||"patch-client"),r=is(t),n=t.toString(36),o=(ur[t%ur.length]??ur[0])+W(r,-10,10),i=r()<.5?-1:1,s=r()<.5?-1:1,a=o+s*W(r,52,116),l=o-s*W(r,26,66),c=o+i*W(r,12,38),p=Gn(o+i*W(r,0,14),W(r,80,92),W(r,44,54)),g=W(r,0,Un),u=Xn.map((f,v)=>{let S=(f.hue==="accent"?a:f.hue==="accent2"?l:f.hue==="near"?c:o)+W(r,-11,11),C=g+v/Xn.length*Un+W(r,-0.6,.6),m=W(r,f.reach[0],f.reach[1]),d=te(.5+Math.cos(C)*m),b=te(.5+Math.sin(C)*m),y=te(W(r,0,180),1),E=te(W(r,.62,1.5),3),N=te(W(r,.62,1.5),3);return {id:`cav-${n}-${v}`,cx:d,cy:b,r:te(W(r,f.r[0],f.r[1])),color:Gn(S,W(r,f.sat[0],f.sat[1]),W(r,f.light[0],f.light[1])),opacity:te(W(r,f.opacity[0],f.opacity[1]),2),gradientTransform:`rotate(${y} ${d} ${b}) translate(${d} ${b}) scale(${E} ${N}) translate(${te(-d)} ${te(-b)})`}});return {id:n,background:p,spots:u,blur:te(W(r,3.4,5.4),2),grain:te(W(r,.09,.15),2)}}function it(e){let t=e.gap??12,r=e.margin??16,n=Math.min(e.popover.width,Math.max(0,e.viewport.width-r*2)),o="right",i=e.anchor.x+e.anchor.width+t;i+n>e.viewport.width-r&&(o="left",i=e.anchor.x-n-t),i<r&&(i=r);let s=e.anchor.y;return s+e.popover.height>e.viewport.height-r&&(s=e.viewport.height-r-e.popover.height),s<r&&(s=r),{x:i,y:s,width:n,placement:o}}function R(...e){return e.filter(Boolean).join(" ")}function Bt({seed:e,className:t,style:r}){let n=Kn(e),o=useId().replace(/[^a-zA-Z0-9_-]/g,""),i=`${n.id}-${o}`,s=`cav-blur-${i}`,a=`cav-grain-${i}`;return jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:R("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxs("defs",{children:[jsx("filter",{id:s,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxs("radialGradient",{id:`${i}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsx("rect",{width:"64",height:"64",fill:n.background}),jsx("g",{filter:`url(#${s})`,children:n.spots.map(l=>jsx("rect",{width:"64",height:"64",fill:`url(#${i}-${l.id})`},l.id))}),jsx("rect",{width:"64",height:"64",filter:`url(#${a})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Se=28,qn=[.22,.61,.36,1],Wt=["var(--color-avatar-tint-1)","var(--color-avatar-tint-2)","var(--color-avatar-tint-3)","var(--color-avatar-tint-4)","var(--color-avatar-tint-5)"];function Ue(e){if(!e)return "?";let t=e.trim().split(/\s+/),r=t[0],n=t[t.length-1];if(!r||!n)return "?";if(t.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",i=n[0]??"";return (o+i).toUpperCase()||"?"}function Ge(e){if(!e)return Wt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Wt[Math.abs(t)%Wt.length]??Wt[0]}var ls={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},cs={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function Ke(e,t){let{placement:r}=it({anchor:{x:e.viewportX-Se/2,y:e.viewportY-Se/2,width:Se,height:Se},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function Yt(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Se,y:e.viewportY-Se,width:Se,height:Se}}function pr({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?ds[t.attention]:null,{url:o,seed:i}=Ft(t.avatarSrc),s=i??t.generatedSeed,a=t.orphan?"grayscale(1)":t.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",l=t.orphan?.55:1,c=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsx(motion.button,{ref:e,type:"button",onClick:t.onClick,"aria-label":t.ariaLabel??"Open annotation","data-patch-ephemeral":t.ephemeral?"":void 0,"data-patch-pin-id":t.pinId,className:"patch-pin-button fixed z-[2147483645] size-7 border-0 bg-transparent p-0",initial:t.ephemeral?{opacity:0,scale:.45}:false,animate:t.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:t.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:qn}}:{opacity:0,scale:.9,transition:{duration:.12,ease:qn}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:ls[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:cs[r],background:"var(--color-muted-foreground)",filter:t.orphan?"grayscale(1)":"none",opacity:t.orphan?.55:1},children:[s?jsx(Bt,{seed:s,style:{borderRadius:0,filter:a||"none",opacity:l}}):null,o?jsx("img",{src:o,alt:t.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:a||"none",opacity:l},onError:p=>{p.currentTarget.remove();}}):null]}),t.resolved&&jsx("span",{className:`absolute ${c} grid size-[13px] place-items-center rounded-full bg-brand-green text-[8px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsx("span",{"data-patch-attention":t.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[9px] rounded-full border-[1.5px] border-white ${n}`})]})})}var ds={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};var us="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",ps={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Ee({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:i="md",className:s,style:a}){let{url:l,seed:c}=Ft(r),p=c??n;return jsxs("span",{className:R(us,ps[i],s),style:{background:t,...a},children:[jsx("span",{children:e}),!l&&p?jsx(Bt,{seed:p}):null,l?jsx("img",{src:l,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:g=>{g.currentTarget.remove();}}):null]})}var Zn={"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 M({name:e,size:t=16,stroke:r=2,color:n,className:o}){return jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:Zn[e].map(([i,s],a)=>createElement(i,{key:a,...s}))})}var hs="M12 2A10 10 0 0 1 22 12V20.6A1.4 1.4 0 0 1 20.6 22H12A10 10 0 0 1 2 12A10 10 0 0 1 12 2Z";function gr({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:o?"none":"currentColor",stroke:o?"currentColor":"none",strokeWidth:o?r:void 0,strokeLinejoin:o?"round":void 0,strokeLinecap:o?"round":void 0,"aria-hidden":"true",focusable:"false",className:n,children:jsx("path",{d:hs})})}var fr=false,He=null,Xt=null,ce={openDelay:700,isInstant(){return fr},onOpen(e){Xt&&Xt!==e&&Xt(),Xt=e??null,fr=true,He&&(clearTimeout(He),He=null);},onClose(){He&&clearTimeout(He),He=setTimeout(()=>{fr=false,He=null;},300);}};var to="easeOut";function ke({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[i,s]=useState(false),[a,l]=useState(false),c=useRef(null),p=useRef(false);useEffect(()=>()=>{c.current&&clearTimeout(c.current),p.current&&ce.onClose();},[]);let g=b=>{l(b),s(true),p.current=true,ce.onOpen();},u=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),ce.isInstant()){g(true);return}c.current=setTimeout(()=>{c.current=null,g(false);},ce.openDelay);},f=()=>{c.current&&(clearTimeout(c.current),c.current=null),p.current&&(p.current=false,ce.onClose()),s(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",w="shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45),0_3px_8px_-3px_rgba(0,0,0,0.3)] ring-1 ring-white/10",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 ${w}`:`relative block whitespace-nowrap rounded-[10px] bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${w}`,C=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 jsxs("span",{className:R("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:f,onMouseDown:f,children:[jsx("span",{className:v,children:jsx(AnimatePresence,{children:i&&jsxs(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:to}},exit:{opacity:0,y:d,scale:.98,transition:{duration:.08,ease:to}},className:S,children:[n==="warning"?jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsx("span",{className:"min-w-0 flex-1",children:e}),jsx("span",{className:C})]})})}),t]})}var ws=44,ys=212,he=[.16,1,.3,1],no="easeOut",ks=.08,Cs=60,As="calc(100% - 64px) calc(100% + 4px)",ct="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function oo(){let e=On(),t=ge(),r=me(),{dockOpen:n,hideResolvedAnnotations:o,setDockOpen:i,setHideResolvedAnnotations:s}=$t(),[a,l]=useState(false),[c,p]=useState(false),[g,u]=useState(false),[f,v]=useState(false),[w,S]=useState(false),C=useRef(null),m=useRef(null),d=useRef(false),[b,y]=useState(false),E=r.studio?r.studio.name:r.identity?.name??null,N=Ue(E),D=r.studio?.image??null,V=r.identity?.avatarSeed??r.clientAvatarSeed,G=r.studio?.userId??V,x=r.studio?"var(--color-foreground)":Ge(V),A=r.studio&&!D?"#FFFFFF":x,O=r.studio&&!D?"text-foreground":"text-white",j=ve[r.activeViewport];function B(){C.current!==null&&(window.clearTimeout(C.current),C.current=null);}function K(){m.current!==null&&(window.clearTimeout(m.current),m.current=null);}let ee=useRef(()=>{});ee.current=()=>{!d.current&&C.current===null||(B(),K(),d.current=false,S(true));};let de=useRef(()=>ee.current()).current;useEffect(()=>{w&&a&&l(false);},[w,a]);function se(H){p(false),u(false),B(),K(),d.current=true,S(false),v(H),ce.onOpen(de),l(true);}function le(){se(false);}function Ce(){if(B(),!(d.current||m.current!==null)){if(ce.isInstant()){se(true);return}m.current=window.setTimeout(()=>{m.current=null,se(false);},ce.openDelay);}}function h(){K(),B(),d.current&&(d.current=false,ce.onClose()),C.current=window.setTimeout(()=>{l(false),C.current=null;},120);}function I(){y(true),i(true);}function L(){p(false),u(false),K(),d.current=false,l(false),e.isCapturing?e.exit():e.enter();}function X(){y(true),i(false),p(false),u(false),K(),d.current=false,l(false),e.exit(),t.active&&t.forceClose();}useEffect(()=>()=>{C.current!==null&&window.clearTimeout(C.current),m.current!==null&&window.clearTimeout(m.current);},[]);let ue=()=>{r.signOut(),l(false);};function ie(){u(false),K(),d.current=false,l(false),p(H=>!H);}function Me(H){p(false),r.activeViewport!==H&&(t.active&&t.forceClose(),r.setActiveViewport(H));}function ft(){p(false),K(),d.current=false,l(false),u(H=>!H);}function ht(){s(!o);}function bt(H){let _e=H.relatedTarget;_e instanceof Node&&H.currentTarget.contains(_e)||h();}return jsx("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:jsxs(motion.div,{initial:false,animate:{width:n?ys:ws},transition:{duration:.36,ease:he},onAnimationComplete:()=>y(false),whileHover:n?void 0:{scale:1.03,transition:{duration:.15,ease:he}},whileTap:n?void 0:{scale:.97,transition:{duration:.1,ease:he}},"data-patch-fab-dock":"",className:R("pkey-fab relative h-11 rounded-full",b?"overflow-hidden":"overflow-visible"),children:[jsx(motion.div,{animate:{opacity:n?0:1,scale:n?.7:1},transition:{duration:.18,ease:he},className:R("absolute inset-0",n?"pointer-events-none":"pointer-events-auto"),children: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:jsx(gr,{variant:"outline",size:18})})}),jsxs("div",{"data-patch-fab-dock":"",className:R("absolute inset-0 flex items-center gap-1.5 px-1.5",n?"pointer-events-auto":"pointer-events-none"),children:[jsx(dt,{visible:n,index:0,children:jsx(ke,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:L,className:R(ct,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(gr,{variant:"outline",size:16})})})}),jsx(dt,{visible:n,index:1,children:jsxs("div",{className:"relative flex items-center",children:[jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${j.label}`,"aria-expanded":c,onClick:ie,className:R(ct,"transition-colors",r.activeViewport==="desktop"&&!c?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx(M,{name:j.glyph,size:15})}),jsx(AnimatePresence,{children:c?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:he}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:he}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[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"}),Nr.map(H=>{let _e=ve[H],vt=r.activeViewport===H;return jsx(ke,{text:Fe(H),children:jsx("button",{type:"button","data-patch-viewport-option":H,"aria-label":Fe(H),"aria-pressed":vt,onClick:()=>Me(H),className:R("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",vt?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(M,{name:_e.glyph,size:15})})},H)})]}):null})]})}),jsx(dt,{visible:n,index:2,children:jsxs("div",{className:"relative flex items-center",children:[jsx(ke,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":g,onClick:ft,className:R(ct,"transition-colors",g||o?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(M,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:g?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:he}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:he}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-[18px] p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-xl px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsx("input",{type:"checkbox",checked:o,"aria-label":"Hide resolved annotations",onChange:ht,className:"peer sr-only"}),jsx("span",{"aria-hidden":"true",className:R("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",o?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsx(M,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(dt,{visible:n,index:3,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Ce,onMouseLeave:h,onFocus:le,onBlur:bt,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":E?`Account: ${E}`:"Identify",className:R(ct,"text-white"),children:E?jsx(Ee,{initials:N,tint:A,src:D,generatedSeed:G,alt:E,size:"sm",className:R("size-[22px] text-[9.5px] ring-1 ring-white/20",O)}):jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsx(AnimatePresence,{children:a?jsxs(motion.div,{initial:f?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:f?{duration:0}:{duration:.12,delay:ks,ease:no}},exit:{opacity:0,y:2,scale:.98,transition:w?{duration:0}:{duration:.08,ease:no}},"data-patch-fab-dock":"","data-patch-identity-popover":"",className:"fixed right-8 bottom-[72px] z-[2147483647] w-[min(272px,calc(100vw-40px))] min-w-[220px] rounded-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:As},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:Cs}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Ee,{initials:N,tint:x,src:D,generatedSeed:G,alt:r.studio.name,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Ee,{initials:N,tint:x,generatedSeed:G,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsx("div",{className:"my-3 h-px bg-white/10"}),jsx("button",{type:"button",onClick:ue,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsx(dt,{visible:n,index:4,children:jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsx(ke,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:X,className:R(ct,"text-white/70"),children:jsx(M,{name:"x",size:14})})})]})})]})]})})}function dt({children:e,visible:t,index:r}){return jsx(motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:he}}:{opacity:0,x:6,transition:{duration:.12,ease:he}},children:e})}function io(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 ao(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var co=.6,Ut={text:.4,attrs:.3,classes:.2,bbox:.1},Ss=5e3;function Es(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function Rs(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 Is(e,t){let r=new Set(e),n=new Set(t??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let s of r)n.has(s)&&o++;let i=r.size+n.size-o;return i===0?0:o/i}function Ns(e,t,r){if(!t)return .5;let n=e.x+e.width/2,o=e.y+e.height/2,i=t.x+t.width/2,s=t.y+t.height/2,a=(n-i)/Math.max(1,r.width),l=(o-s)/Math.max(1,r.height),c=Math.sqrt(a*a+l*l);return Math.max(0,1-c)}function uo(e,t){let r=Nt(e),n=It(e),o=Le(e),i=e.getBoundingClientRect(),s=Es(r,t.payload.domHints?.textSignature),a=Rs(n,t.payload.domHints?.attributeSignature),l=Is(o,t.payload.cssClasses),c=Ns(i,t.payload.boundingBox,t.viewport);return Ut.text*s+Ut.attrs*a+Ut.classes*l+Ut.bbox*c}function so(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function lo(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=io({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return ao(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Ps(e){let t=e.payload.domHints?.cssSelector;if(!t)return null;try{return e.doc.querySelector(t)}catch{return null}}function Ms(e){let t=null,r=-1,n=0,o=e.doc.querySelectorAll("*");for(let i of Array.from(o)){if(n>=Ss)break;if(n++,Pt(i,e.internalAttr))continue;let s=i.tagName.toLowerCase();if(s==="html"||s==="head"||s==="script"||s==="style")continue;let a=uo(i,e);a>r&&(r=a,t=i);}return r>=co?t:null}function Gt(e){if(!e.payload.domHints)return {tier:3,el:null,position:so(e)};let t=Ps(e);if(t&&uo(t,e)>=co)return {tier:1,el:t,position:lo(t,e)};let r=Ms(e);return r?{tier:2,el:r,position:lo(r,e)}:{tier:3,el:null,position:so(e)}}function po(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 Ds="data-patch-internal";function Kt(e,t,r){let n=Ke(r,t.getOverlayViewport()),o=Yt(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function bo(e,t){let r=Gt({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:Ds});return {tier:r.tier,position:e.targetPointToOverlay(r.position)}}function Os(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function vo(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:i}=me(),s=ge(),{dockOpen:a,hideResolvedAnnotations:l}=$t(),c=ae(),{isPreviewing:p,previewReady:g}=Ye(),u=useReducedMotion(),f=s.active,v=s.forceClose,w=t&&(!p||g),S=useMemo(()=>a&&t?e.filter(x=>!l||x.status!=="resolved"):[],[a,t,e,l]),C=useMemo(()=>a&&t?r:[],[a,t,r]);useEffect(()=>{if(!l||f?.kind!=="existing")return;e.find(A=>A.id===f.annotationId)?.status==="resolved"&&v();},[f,e,v,l]);let m=useRef(new Map),d=useRef(new Map),b=useMemo(()=>{let x=new Map;for(let A of S)x.set(A.id,bo(c,A));return x},[c,S]),y=useCallback(()=>{for(let x of S){let A=m.current.get(x.id);A&&Kt(A,c,bo(c,x).position);}for(let x of C){let A=d.current.get(x.tempId);A&&Kt(A,c,Os(c,x));}},[c,S,C]);useEffect(()=>{let x=null,A=()=>{x===null&&(x=c.overlayWindow.requestAnimationFrame(()=>{x=null,y();}));},O=new Set([c.targetWindow,c.overlayWindow]);for(let B of O)B.addEventListener("resize",A),B.addEventListener("scroll",A,{passive:true});let j=Tt(c.targetWindow,A);return j.observe(c.targetDocument.body),A(),()=>{x!==null&&c.overlayWindow.cancelAnimationFrame(x);for(let B of O)B.removeEventListener("resize",A),B.removeEventListener("scroll",A);j.disconnect();}},[y,c]);let E=useCallback(x=>{if(s.active&&s.draftText.trim().length>0){s.attemptClose();return}s.openExisting(x);},[s]),N=o?o.name:n?.name??null,D=o?.image??null,V=n?.avatarSeed??i,G=o?.userId??V;return jsxs("div",{"data-patch-pin-layer":"",style:{opacity:w?1:0,transition:u||!w?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:w?void 0:"none"},children:[jsx(AnimatePresence,{initial:false,children:S.map(x=>{let A=b.get(x.id),O=Ls(x),j=!o&&!!n?.clientUserId&&x.payload.authorRole==="client"&&x.payload.authorId===n.clientUserId,B=o?po(x):null,K=A?Ke(A.position,c.getOverlayViewport()):"right";return jsx(pr,{ref:ee=>{ee?(m.current.set(x.id,ee),A&&Kt(ee,c,A.position)):m.current.delete(x.id);},avatarSrc:O.image,generatedSeed:j?V:O.generatedSeed,avatarAlt:O.name??"",resolved:x.status==="resolved",attention:B,orphan:A?.tier===3,pointSide:K,ariaLabel:`Annotation by ${x.authorName??"someone"}`,onClick:()=>E(x.id),pinId:x.id},x.id)})}),jsx(AnimatePresence,{initial:false,children:C.map(x=>{let A=c.targetPointToOverlay({viewportX:x.viewportX,viewportY:x.viewportY});return jsx(pr,{ref:O=>{O?(d.current.set(x.tempId,O),Kt(O,c,A)):d.current.delete(x.tempId);},avatarSrc:D,generatedSeed:G,avatarAlt:N??"",resolved:false,pointSide:Ke(A,c.getOverlayViewport()),ephemeral:true},x.tempId)})})]})}function Ls(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 xo=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
|
|
4
|
+
`)}function Wa(e,t){let r=e.targetDocument,n=r.getElementById(Rn);n&&n.remove();let o=r.createElement("style");return o.id=Rn,o.setAttribute(t,""),o.textContent=Ba(t),r.head.appendChild(o),o}function Lt(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var ze=1.5,Nn="#0287FE",Pn="rgba(2, 135, 254, 0.032)";function Ya(e){let t=e.split(" ")[0]??"",r=Number.parseFloat(t);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Xa(e,t){let r=e.targetDocument,n=r.createElement("div");n.setAttribute(t,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${ze}px solid ${Nn}`,background:Pn,boxSizing:"border-box",zIndex:"2147483645",display:"none",borderRadius:"6px",transition:"top 80ms ease-out, left 80ms ease-out, width 80ms ease-out, height 80ms ease-out, border-radius 80ms ease-out"});let o=r.createElement("div");o.setAttribute(t,""),Object.assign(o.style,{position:"fixed",pointerEvents:"none",background:"#111",color:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"12px",fontWeight:"500",padding:"6px 10px",borderRadius:"6px",zIndex:"2147483646",maxWidth:"240px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"none",boxShadow:"0 10px 24px -12px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.08)"}),r.body.appendChild(n),r.body.appendChild(o);let i=null;return {update(s){let a=s.getBoundingClientRect();if(a.width===0&&a.height===0){this.hide();return}n.style.display="block",n.style.top=`${a.top-ze}px`,n.style.left=`${a.left-ze}px`,n.style.width=`${a.width+ze*2}px`,n.style.height=`${a.height+ze*2}px`,n.style.borderRadius=`${Ya(e.targetWindow.getComputedStyle(s).borderRadius)+ze}px`,s!==i&&(o.textContent=ot(s),i=s),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),p=e.getTargetViewport().width-8;l+240<=p?(o.style.left=`${l}px`,o.style.top=`${c}px`):(o.style.left=`${Math.max(8,a.right-240)}px`,o.style.top=`${Math.max(8,a.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function Ua(e,t){let r=e.targetDocument.createElement("div");return r.setAttribute(t,""),Object.assign(r.style,{position:"fixed",pointerEvents:"none",border:`${ze}px solid ${Nn}`,background:Pn,boxSizing:"border-box",zIndex:"2147483645",borderRadius:"8px"}),e.targetDocument.body.appendChild(r),{update(n){r.style.left=`${n.x}px`,r.style.top=`${n.y}px`,r.style.width=`${n.width}px`,r.style.height=`${n.height}px`;},destroy(){r.remove();}}}function In(e,t){return {x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function Mn(e){let{internalAttr:t,onClick:r,onDrag:n,surface:o}=e,i=o.targetDocument,s=Wa(o,t),a=Xa(o,t),l=false,c=null,p=null;function g(){c?.rectOverlay&&c.rectOverlay.destroy(),c=null;}function u(){p&&(p.destroy(),p=null);}let f=m=>{let d=m,v=o.eventTargetElement(d.target);Lt(o,d.target,t)||v&&lr(v)||(d.preventDefault(),d.stopPropagation(),!l&&(u(),c={startX:d.clientX,startY:d.clientY,isDragging:false,rectOverlay:null}));},x=m=>{let d=m;if(c?.isDragging){d.preventDefault(),d.stopPropagation();let C=In({x:c.startX,y:c.startY},{x:d.clientX,y:d.clientY});p=c.rectOverlay,c=null,n?.(C,d);return}g();let v=o.eventTargetElement(d.target);Lt(o,d.target,t)||v&&lr(v)||(d.preventDefault(),d.stopPropagation());},w=m=>{let d=m;Lt(o,d.target,t)||(d.preventDefault(),d.stopPropagation(),!l&&r(d));},E=m=>{let d=m;if(c){if(!c.isDragging){let T=d.clientX-c.startX,P=d.clientY-c.startY;if(Math.hypot(T,P)<Tn)return;c.isDragging=true,a.hide(),c.rectOverlay=Ua(o,t);}c.rectOverlay?.update(In({x:c.startX,y:c.startY},{x:d.clientX,y:d.clientY}));return}if(l)return;let v=o.eventTargetElement(d.target);if(!v){a.hide();return}if(Lt(o,v,t)){a.hide();return}let C=v.tagName.toLowerCase();if(C==="html"||C==="body"){a.hide();return}a.update(v);},k=m=>{m.relatedTarget||a.hide();};return i.addEventListener("mousedown",f,true),i.addEventListener("mouseup",x,true),i.addEventListener("click",w,true),i.addEventListener("mousemove",E,true),i.addEventListener("mouseout",k,true),{exit(){s.remove(),a.destroy(),g(),u(),i.removeEventListener("mousedown",f,true),i.removeEventListener("mouseup",x,true),i.removeEventListener("click",w,true),i.removeEventListener("mousemove",E,true),i.removeEventListener("mouseout",k,true);},pause(){l=true,a.hide(),g();},resume(){l=false;},dismissDragOverlay(){u();}}}var _n="data-patch-internal",Ln=createContext(null),Dn=0;function On(){return Dn+=1,`tmp-${Date.now().toString(36)}-${Dn}`}function zn({children:e}){let t=ge(),r=me(),n=se(),{isPreviewing:o,previewReady:i}=Ye(),[s,a]=useState(false),l=useRef(null),c=useRef(t),p=useRef(r);c.current=t,p.current=r;let g=useCallback(m=>{let d=c.current;if(d.active&&d.draftText.trim().length>0){d.attemptClose();return}let v=n.eventTargetElement(m.target)??n.targetDocument.body,C=n.targetWindow.getSelection(),T=An({clickTarget:v,selection:C}),P=On(),z={viewportX:m.clientX,viewportY:m.clientY,documentY:m.clientY+n.getTargetScrollY()};p.current.addEphemeral({tempId:P,viewportX:z.viewportX,viewportY:z.viewportY,documentY:z.documentY}),c.current.openComposer({tempId:P,target:T,anchor:z}),l.current?.pause();},[n]),u=useCallback((m,d)=>{let v=c.current;if(v.active&&v.draftText.trim().length>0){v.attemptClose(),l.current?.dismissDragOverlay();return}let C=n.getTargetViewport(),T=En({rect:m,viewport:C,internalAttr:_n,doc:n.targetDocument});if(!T){l.current?.dismissDragOverlay();return}let P=On(),z={viewportX:d.viewportX,viewportY:d.viewportY,documentY:d.viewportY+n.getTargetScrollY()};p.current.addEphemeral({tempId:P,viewportX:z.viewportX,viewportY:z.viewportY,documentY:z.documentY}),c.current.openComposer({tempId:P,target:T,anchor:z}),l.current?.pause();},[n]),f=r.annotationsReady&&(!o||i);useEffect(()=>{if(!s||!f){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=Mn({internalAttr:_n,surface:n,onClick:g,onDrag:(m,d)=>u(m,{viewportX:d.clientX,viewportY:d.clientY})}),()=>{l.current?.exit(),l.current=null;}},[s,g,u,n,f]);let x=useCallback(()=>{s||a(true);},[s]),w=useCallback(()=>{a(false);},[]),E=useRef(null);useEffect(()=>{let m=E.current,d=t.active;m?.kind==="composer"&&d?.kind!=="composer"&&(p.current.removeEphemeral(m.tempId),l.current?.dismissDragOverlay(),l.current?.resume()),m?.kind==="composer"&&d?.kind==="composer"&&m.tempId!==d.tempId&&p.current.removeEphemeral(m.tempId),E.current=d;},[t.active]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let k=useMemo(()=>({isCapturing:s,enter:x,exit:w}),[s,x,w]);return jsx(Ln.Provider,{value:k,children:e})}function Hn(){let e=use(Ln);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var $n=createContext(null);function Vn({children:e}){let[t,r]=useState(false),[n,o]=useState(false),i=useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsx($n.Provider,{value:i,children:e})}function Ft(){let e=use($n);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var rs="[Patch] No project token found. Pass `projectToken` as a prop, or set NEXT_PUBLIC_PATCH_TOKEN (Next.js), VITE_PATCH_TOKEN (Vite / React Router), or PUBLIC_PATCH_TOKEN (Astro) in your env.";function Bn(e){let t=e.prop?.trim();if(t)return t;let r=e.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=e.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=e.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();if(o)return o;throw new Error(rs)}function Wn(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function Yn(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var ns=new Set(["AmpStateContext","AppRouter","AppRouterContext","ClientPageRoot","ClientSegmentRoot","ErrorBoundary","ForbiddenBoundary","GlobalLayoutRouterContext","HTTPAccessFallbackBoundary","HTTPAccessFallbackErrorBoundary","HeadManagerContext","HotReload","ImageConfigContext","InnerLayoutRouter","InnerScrollAndFocusHandler","InnerScrollAndFocusHandlerOld","LayoutRouterContext","LoadingBoundary","NavigationPromisesContext","NotFoundBoundary","OuterLayoutRouter","PathParamsContext","PathnameContext","ReactDevOverlay","RedirectBoundary","RedirectErrorBoundary","RenderFromTemplateContext","RouterContext","ScrollAndMaybeFocusHandler","SearchParamsContext","SegmentStateProvider","SegmentViewNode","ServerInsertedHTMLContext","Suspense","TemplateContext","UnauthorizedBoundary","AwaitContext","BrowserRouter","DataRouterContext","DataRouterStateContext","DataRoutes","FetchersContext","HashRouter","LocationContext","MemoryRouter","NavigationContext","Outlet","RenderErrorBoundary","RenderedRoute","Route","RouteContext","RouteErrorContext","Router","RouterProvider","Routes","StaticRouter","StaticRouterProvider","ViewTransitionContext"]);function os(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Xn(e){return e.replace(/\s+/g," ").trim()}function dr(e){return ns.has(Xn(e))}function Un(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Xn(n[1]??"");!o||dr(o)||t[t.length-1]!==o&&t.push(o);}return t.length===0?null:os(t.map(n=>`<${n}>`).join(" "),1e3)}var Gn="seed:";function $t(e){return e?e.startsWith(Gn)?{url:null,seed:e.slice(Gn.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var ur=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],Kn=[{hue:"near",sat:[88,98],light:[68,82],r:[.44,.62],opacity:[.9,1],reach:[.14,.32]},{hue:"base",sat:[85,96],light:[44,56],r:[.5,.74],opacity:[.85,1],reach:[.2,.42]},{hue:"accent",sat:[84,97],light:[50,66],r:[.42,.64],opacity:[.8,.98],reach:[.26,.48]},{hue:"accent2",sat:[82,95],light:[30,46],r:[.44,.66],opacity:[.72,.94],reach:[.24,.46]}],qn=Math.PI*2;function is(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}function as(e){return ()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function W(e,t,r){return t+e()*(r-t)}function ee(e,t=3){let r=10**t;return Math.round(e*r)/r}function jn(e,t,r){return `hsl(${ee((e%360+360)%360,1)} ${ee(t,1)}% ${ee(r,1)}%)`}function Zn(e){let t=is(e?.trim()||"patch-client"),r=as(t),n=t.toString(36),o=(ur[t%ur.length]??ur[0])+W(r,-10,10),i=r()<.5?-1:1,s=r()<.5?-1:1,a=o+s*W(r,52,116),l=o-s*W(r,26,66),c=o+i*W(r,12,38),p=jn(o+i*W(r,0,14),W(r,80,92),W(r,44,54)),g=W(r,0,qn),u=Kn.map((f,x)=>{let E=(f.hue==="accent"?a:f.hue==="accent2"?l:f.hue==="near"?c:o)+W(r,-11,11),k=g+x/Kn.length*qn+W(r,-0.6,.6),m=W(r,f.reach[0],f.reach[1]),d=ee(.5+Math.cos(k)*m),v=ee(.5+Math.sin(k)*m),C=ee(W(r,0,180),1),T=ee(W(r,.62,1.5),3),P=ee(W(r,.62,1.5),3);return {id:`cav-${n}-${x}`,cx:d,cy:v,r:ee(W(r,f.r[0],f.r[1])),color:jn(E,W(r,f.sat[0],f.sat[1]),W(r,f.light[0],f.light[1])),opacity:ee(W(r,f.opacity[0],f.opacity[1]),2),gradientTransform:`rotate(${C} ${d} ${v}) translate(${d} ${v}) scale(${T} ${P}) translate(${ee(-d)} ${ee(-v)})`}});return {id:n,background:p,spots:u,blur:ee(W(r,3.4,5.4),2),grain:ee(W(r,.09,.15),2)}}function it(e){let t=e.gap??12,r=e.margin??16,n=Math.min(e.popover.width,Math.max(0,e.viewport.width-r*2)),o="right",i=e.anchor.x+e.anchor.width+t;i+n>e.viewport.width-r&&(o="left",i=e.anchor.x-n-t),i<r&&(i=r);let s=e.anchor.y;return s+e.popover.height>e.viewport.height-r&&(s=e.viewport.height-r-e.popover.height),s<r&&(s=r),{x:i,y:s,width:n,placement:o}}function R(...e){return e.filter(Boolean).join(" ")}function Bt({seed:e,className:t,style:r}){let n=Zn(e),o=useId().replace(/[^a-zA-Z0-9_-]/g,""),i=`${n.id}-${o}`,s=`cav-blur-${i}`,a=`cav-grain-${i}`;return jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:R("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxs("defs",{children:[jsx("filter",{id:s,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxs("radialGradient",{id:`${i}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsx("rect",{width:"64",height:"64",fill:n.background}),jsx("g",{filter:`url(#${s})`,children:n.spots.map(l=>jsx("rect",{width:"64",height:"64",fill:`url(#${i}-${l.id})`},l.id))}),jsx("rect",{width:"64",height:"64",filter:`url(#${a})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Se=28,Jn=[.22,.61,.36,1],Wt=["var(--color-avatar-tint-1)","var(--color-avatar-tint-2)","var(--color-avatar-tint-3)","var(--color-avatar-tint-4)","var(--color-avatar-tint-5)"];function Ue(e){if(!e)return "?";let t=e.trim().split(/\s+/),r=t[0],n=t[t.length-1];if(!r||!n)return "?";if(t.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",i=n[0]??"";return (o+i).toUpperCase()||"?"}function Ge(e){if(!e)return Wt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Wt[Math.abs(t)%Wt.length]??Wt[0]}var cs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},ds={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function Ke(e,t){let{placement:r}=it({anchor:{x:e.viewportX-Se/2,y:e.viewportY-Se/2,width:Se,height:Se},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function Yt(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Se,y:e.viewportY-Se,width:Se,height:Se}}function pr({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?us[t.attention]:null,{url:o,seed:i}=$t(t.avatarSrc),s=i??t.generatedSeed,a=t.orphan?"grayscale(1)":t.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",l=t.orphan?.55:1,c=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsx(motion.button,{ref:e,type:"button",onClick:t.onClick,"aria-label":t.ariaLabel??"Open annotation","data-patch-ephemeral":t.ephemeral?"":void 0,"data-patch-pin-id":t.pinId,className:"patch-pin-button fixed z-[2147483645] size-7 border-0 bg-transparent p-0",initial:t.ephemeral?{opacity:0,scale:.45}:false,animate:t.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:t.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:Jn}}:{opacity:0,scale:.9,transition:{duration:.12,ease:Jn}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:cs[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:ds[r],background:"var(--color-muted-foreground)",filter:t.orphan?"grayscale(1)":"none",opacity:t.orphan?.55:1},children:[s?jsx(Bt,{seed:s,style:{borderRadius:0,filter:a||"none",opacity:l}}):null,o?jsx("img",{src:o,alt:t.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:a||"none",opacity:l},onError:p=>{p.currentTarget.remove();}}):null]}),t.resolved&&jsx("span",{className:`absolute ${c} grid size-[13px] place-items-center rounded-full bg-brand-green text-[8px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsx("span",{"data-patch-attention":t.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[9px] rounded-full border-[1.5px] border-white ${n}`})]})})}var us={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};var ps="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",ms={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Ee({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:i="md",className:s,style:a}){let{url:l,seed:c}=$t(r),p=c??n;return jsxs("span",{className:R(ps,ms[i],s),style:{background:t,...a},children:[jsx("span",{children:e}),!l&&p?jsx(Bt,{seed:p}):null,l?jsx("img",{src:l,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:g=>{g.currentTarget.remove();}}):null]})}var eo={"arrow-up":[["path",{d:"M12 5.5V19"}],["path",{d:"M18 11C18 11 13.5811 5.00001 12 5C10.4188 4.99999 6 11 6 11"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],cursor:[["path",{d:"M12.669 8.35811L17.6969 10.3256C20.5969 11.4604 22.0469 12.0277 21.9988 12.9278C21.9508 13.8278 20.4375 14.2405 17.4111 15.0659C16.5099 15.3117 16.0593 15.4346 15.7469 15.7469C15.4346 16.0593 15.3117 16.5099 15.0659 17.4111C14.2405 20.4375 13.8278 21.9508 12.9278 21.9988C12.0277 22.0469 11.4604 20.5969 10.3256 17.6969L8.35811 12.669C7.17004 9.63279 6.57601 8.1147 7.34535 7.34535C8.1147 6.57601 9.63279 7.17004 12.669 8.35811Z"}],["path",{d:"M9 4V2M5 5L3.5 3.5M4 9H2M5 13L3.5 14.5M14.5 3.5L13 5"}]],desktop:[["path",{d:"M14 21H16M14 21C13.1716 21 12.5 20.3284 12.5 19.5V17L12 17M14 21H10M10 21H8M10 21C10.8284 21 11.5 20.3284 11.5 19.5V17L12 17M12 17V21"}],["path",{d:"M16 3H8C5.17157 3 3.75736 3 2.87868 3.87868C2 4.75736 2 6.17157 2 9V11C2 13.8284 2 15.2426 2.87868 16.1213C3.75736 17 5.17157 17 8 17H16C18.8284 17 20.2426 17 21.1213 16.1213C22 15.2426 22 13.8284 22 11V9C22 6.17157 22 4.75736 21.1213 3.87868C20.2426 3 18.8284 3 16 3Z"}]],globe:[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12C8 18 12 22 12 22C12 22 16 18 16 12C16 6 12 2 12 2C12 2 8 6 8 12Z"}],["path",{d:"M21 15H3"}],["path",{d:"M21 9H3"}]],lock:[["path",{d:"M4.26781 18.8447C4.49269 20.515 5.87613 21.8235 7.55966 21.9009C8.97627 21.966 10.4153 22 12 22C13.5847 22 15.0237 21.966 16.4403 21.9009C18.1239 21.8235 19.5073 20.515 19.7322 18.8447C19.879 17.7547 20 16.6376 20 15.5C20 14.3624 19.879 13.2453 19.7322 12.1553C19.5073 10.485 18.1239 9.17649 16.4403 9.09909C15.0237 9.03397 13.5847 9 12 9C10.4153 9 8.97627 9.03397 7.55966 9.09909C5.87613 9.17649 4.49269 10.485 4.26781 12.1553C4.12104 13.2453 4 14.3624 4 15.5C4 16.6376 4.12104 17.7547 4.26781 18.8447Z"}],["path",{d:"M7.5 9V6.5C7.5 4.01472 9.51472 2 12 2C14.4853 2 16.5 4.01472 16.5 6.5V9"}],["path",{d:"M12.125 15.5H12M12.25 15.5C12.25 15.6381 12.1381 15.75 12 15.75C11.8619 15.75 11.75 15.6381 11.75 15.5C11.75 15.3619 11.8619 15.25 12 15.25C12.1381 15.25 12.25 15.3619 12.25 15.5Z"}]],maximize:[["path",{d:"M16.4999 3.26621C17.3443 3.25421 20.1408 2.67328 20.7337 3.26621C21.3266 3.85913 20.7457 6.65559 20.7337 7.5M20.5059 3.49097L13.5021 10.4961"}],["path",{d:"M3.26636 16.5001C3.25436 17.3445 2.67343 20.141 3.26636 20.7339C3.85928 21.3268 6.65574 20.7459 7.50015 20.7339M10.502 13.4976L3.49824 20.5027"}]],minimize:[["path",{d:"M6.5023 10.7365C7.34671 10.7485 10.1432 11.3294 10.7361 10.7365C11.329 10.1436 10.7481 7.34708 10.7361 6.50267M13.2685 17.5027C13.2565 16.6583 12.6756 13.8618 13.2685 13.2689C13.8614 12.676 16.6579 13.2569 17.5023 13.2689M20.9991 21.001L13.6102 13.6188M10.3691 10.3763L2.99998 2.99902"}]],mobile:[["path",{d:"M13.5 2H10.5C8.14298 2 6.96447 2 6.23223 2.73223C5.5 3.46447 5.5 4.64298 5.5 7V17C5.5 19.357 5.5 20.5355 6.23223 21.2678C6.96447 22 8.14298 22 10.5 22H13.5C15.857 22 17.0355 22 17.7678 21.2678C18.5 20.5355 18.5 19.357 18.5 17V7C18.5 4.64298 18.5 3.46447 17.7678 2.73223C17.0355 2 15.857 2 13.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],more:[["path",{d:"M12 12.002H12.5M19 12.002H19.5M5 12.002H5.5M12 13.002C12.5523 13.002 13 12.5542 13 12.002C13 11.4497 12.5523 11.002 12 11.002C11.4477 11.002 11 11.4497 11 12.002C11 12.5542 11.4477 13.002 12 13.002ZM19 13.002C19.5523 13.002 20 12.5542 20 12.002C20 11.4497 19.5523 11.002 19 11.002C18.4477 11.002 18 11.4497 18 12.002C18 12.5542 18.4477 13.002 19 13.002ZM5 13.002C5.55228 13.002 6 12.5542 6 12.002C6 11.4497 5.55228 11.002 5 11.002C4.44772 11.002 4 11.4497 4 12.002C4 12.5542 4.44772 13.002 5 13.002Z"}]],play:[["path",{d:"M18.8906 12.846C18.5371 14.189 16.8667 15.138 13.5257 17.0361C10.296 18.8709 8.6812 19.7884 7.37983 19.4196C6.8418 19.2671 6.35159 18.9776 5.95624 18.5787C5 17.6139 5 15.7426 5 12C5 8.2574 5 6.3861 5.95624 5.42132C6.35159 5.02245 6.8418 4.73288 7.37983 4.58042C8.6812 4.21165 10.296 5.12907 13.5257 6.96393C16.8667 8.86197 18.5371 9.811 18.8906 11.154C19.0365 11.7084 19.0365 12.2916 18.8906 12.846Z"}]],pr:[["path",{d:"M6 8L6 16"}],["path",{d:"M18 16V12C18 9.17156 18 7.75735 17.1213 6.87867C16.2426 5.99999 14.8284 5.99999 12 5.99999L11 5.99999M11 5.99999C11 5.29976 12.9943 3.99152 13.5 3.49999M11 5.99999C11 6.70022 12.9943 8.00846 13.5 8.49999"}],["circle",{cx:"6",cy:"18",r:"2"}],["circle",{cx:"6",cy:"6",r:"2"}],["circle",{cx:"18",cy:"18",r:"2"}]],refresh:[["path",{d:"M20.0092 2V5.13219C20.0092 5.42605 19.6418 5.55908 19.4537 5.33333C17.6226 3.2875 14.9617 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12"}]],robot:[["path",{d:"M19 16V14C19 11.1716 19 9.75736 18.1213 8.87868C17.2426 8 15.8284 8 13 8H11C8.17157 8 6.75736 8 5.87868 8.87868C5 9.75736 5 11.1716 5 14V16C5 18.8284 5 20.2426 5.87868 21.1213C6.75736 22 8.17157 22 11 22H13C15.8284 22 17.2426 22 18.1213 21.1213C19 20.2426 19 18.8284 19 16Z"}],["path",{d:"M19 18C20.4142 18 21.1213 18 21.5607 17.5607C22 17.1213 22 16.4142 22 15C22 13.5858 22 12.8787 21.5607 12.4393C21.1213 12 20.4142 12 19 12"}],["path",{d:"M5 18C3.58579 18 2.87868 18 2.43934 17.5607C2 17.1213 2 16.4142 2 15C2 13.5858 2 12.8787 2.43934 12.4393C2.87868 12 3.58579 12 5 12"}],["path",{d:"M13.5 3.5C13.5 4.32843 12.8284 5 12 5C11.1716 5 10.5 4.32843 10.5 3.5C10.5 2.67157 11.1716 2 12 2C12.8284 2 13.5 2.67157 13.5 3.5Z"}],["path",{d:"M12 5V8"}],["path",{d:"M9 13V14"}],["path",{d:"M15 13V14"}],["path",{d:"M10 17.5C10 17.5 10.6667 18 12 18C13.3333 18 14 17.5 14 17.5"}]],settings:[["path",{d:"M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z"}],["path",{d:"M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z"}]],tablet:[["path",{d:"M14.5 2H9.5C6.67157 2 5.25736 2 4.37868 2.87868C3.5 3.75736 3.5 5.17157 3.5 8V16C3.5 18.8284 3.5 20.2426 4.37868 21.1213C5.25736 22 6.67157 22 9.5 22H14.5C17.3284 22 18.7426 22 19.6213 21.1213C20.5 20.2426 20.5 18.8284 20.5 16V8C20.5 5.17157 20.5 3.75736 19.6213 2.87868C18.7426 2 17.3284 2 14.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],trash:[["path",{d:"M19.5 5.5L18.8803 15.5251C18.7219 18.0864 18.6428 19.3671 18.0008 20.2879C17.6833 20.7431 17.2747 21.1273 16.8007 21.416C15.8421 22 14.559 22 11.9927 22C9.42312 22 8.1383 22 7.17905 21.4149C6.7048 21.1257 6.296 20.7408 5.97868 20.2848C5.33688 19.3626 5.25945 18.0801 5.10461 15.5152L4.5 5.5"}],["path",{d:"M3 5.5H21M16.0557 5.5L15.3731 4.09173C14.9196 3.15626 14.6928 2.68852 14.3017 2.39681C14.215 2.3321 14.1231 2.27454 14.027 2.2247C13.5939 2 13.0741 2 12.0345 2C10.9688 2 10.436 2 9.99568 2.23412C9.8981 2.28601 9.80498 2.3459 9.71729 2.41317C9.32164 2.7167 9.10063 3.20155 8.65861 4.17126L8.05292 5.5"}],["path",{d:"M9.5 16.5L9.5 10.5"}],["path",{d:"M14.5 16.5L14.5 10.5"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function O({name:e,size:t=16,stroke:r=2,color:n,className:o}){return jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:eo[e].map(([i,s],a)=>createElement(i,{key:a,...s}))})}var bs="M12 2A10 10 0 0 1 22 12V20.6A1.4 1.4 0 0 1 20.6 22H12A10 10 0 0 1 2 12A10 10 0 0 1 12 2Z";function gr({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:o?"none":"currentColor",stroke:o?"currentColor":"none",strokeWidth:o?r:void 0,strokeLinejoin:o?"round":void 0,strokeLinecap:o?"round":void 0,"aria-hidden":"true",focusable:"false",className:n,children:jsx("path",{d:bs})})}var fr=false,He=null,Xt=null,de={openDelay:700,isInstant(){return fr},onOpen(e){Xt&&Xt!==e&&Xt(),Xt=e??null,fr=true,He&&(clearTimeout(He),He=null);},onClose(){He&&clearTimeout(He),He=setTimeout(()=>{fr=false,He=null;},300);}};var oo="easeOut";function ke({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[i,s]=useState(false),[a,l]=useState(false),c=useRef(null),p=useRef(false);useEffect(()=>()=>{c.current&&clearTimeout(c.current),p.current&&de.onClose();},[]);let g=v=>{l(v),s(true),p.current=true,de.onOpen();},u=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),de.isInstant()){g(true);return}c.current=setTimeout(()=>{c.current=null,g(false);},de.openDelay);},f=()=>{c.current&&(clearTimeout(c.current),c.current=null),p.current&&(p.current=false,de.onClose()),s(false);},x=n==="warning"?"pointer-events-none absolute bottom-[calc(100%+8px)] left-0 z-[1]":o==="bottom"?"pointer-events-none absolute top-[calc(100%+8px)] left-1/2 z-[1] -translate-x-1/2":"pointer-events-none absolute -top-[38px] left-1/2 z-[1] -translate-x-1/2",w="shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45),0_3px_8px_-3px_rgba(0,0,0,0.3)] ring-1 ring-white/10",E=n==="warning"?`relative flex w-[200px] items-start gap-1.5 rounded-[14px] bg-foreground px-3 py-2.5 text-left text-[11px] leading-[1.35] font-medium text-white ${w}`:`relative block whitespace-nowrap rounded-[10px] bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${w}`,k=n==="warning"?"absolute -bottom-1 left-6 size-2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground":o==="bottom"?"absolute -top-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-l border-t border-white/10 bg-foreground":"absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground",m=o==="bottom"&&n!=="warning"?-3:3,d=o==="bottom"&&n!=="warning"?-2:2;return jsxs("span",{className:R("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:f,onMouseDown:f,children:[jsx("span",{className:x,children:jsx(AnimatePresence,{children:i&&jsxs(motion.span,{initial:a?false:{opacity:0,y:m,scale:.98},animate:{opacity:1,y:0,scale:1,transition:a?{duration:0}:{duration:.1,ease:oo}},exit:{opacity:0,y:d,scale:.98,transition:{duration:.08,ease:oo}},className:E,children:[n==="warning"?jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsx("span",{className:"min-w-0 flex-1",children:e}),jsx("span",{className:k})]})})}),t]})}var ys=44,ks=212,he=[.16,1,.3,1],ao="easeOut",Cs=.08,As=60,Ts="calc(100% - 64px) calc(100% + 4px)",ct="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function so(){let e=Hn(),t=ge(),r=me(),{dockOpen:n,hideResolvedAnnotations:o,setDockOpen:i,setHideResolvedAnnotations:s}=Ft(),[a,l]=useState(false),[c,p]=useState(false),[g,u]=useState(false),[f,x]=useState(false),[w,E]=useState(false),k=useRef(null),m=useRef(null),d=useRef(false),[v,C]=useState(false),T=r.studio?r.studio.name:r.identity?.name??null,P=Ue(T),z=r.studio?.image??null,X=r.identity?.avatarSeed??r.clientAvatarSeed,G=r.studio?.userId??X,re=r.studio?"var(--color-foreground)":Ge(X),b=r.studio&&!z?"#FFFFFF":re,A=r.studio&&!z?"text-foreground":"text-white",M=ve[r.activeViewport];function I(){k.current!==null&&(window.clearTimeout(k.current),k.current=null);}function D(){m.current!==null&&(window.clearTimeout(m.current),m.current=null);}let ie=useRef(()=>{});ie.current=()=>{!d.current&&k.current===null||(I(),D(),d.current=false,E(true));};let Q=useRef(()=>ie.current()).current;useEffect(()=>{w&&a&&l(false);},[w,a]);function le($){p(false),u(false),I(),D(),d.current=true,E(false),x($),de.onOpen(Q),l(true);}function ce(){le(false);}function Ce(){if(I(),!(d.current||m.current!==null)){if(de.isInstant()){le(true);return}m.current=window.setTimeout(()=>{m.current=null,le(false);},de.openDelay);}}function h(){D(),I(),d.current&&(d.current=false,de.onClose()),k.current=window.setTimeout(()=>{l(false),k.current=null;},120);}function N(){C(true),i(true);}function H(){p(false),u(false),D(),d.current=false,l(false),e.isCapturing?e.exit():e.enter();}function U(){C(true),i(false),p(false),u(false),D(),d.current=false,l(false),e.exit(),t.active&&t.forceClose();}useEffect(()=>()=>{k.current!==null&&window.clearTimeout(k.current),m.current!==null&&window.clearTimeout(m.current);},[]);let ue=()=>{r.signOut(),l(false);};function ae(){u(false),D(),d.current=false,l(false),p($=>!$);}function Me($){p(false),r.activeViewport!==$&&(t.active&&t.forceClose(),r.setActiveViewport($));}function ft(){p(false),D(),d.current=false,l(false),u($=>!$);}function ht(){s(!o);}function bt($){let _e=$.relatedTarget;_e instanceof Node&&$.currentTarget.contains(_e)||h();}return jsx("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:jsxs(motion.div,{initial:false,animate:{width:n?ks:ys},transition:{duration:.36,ease:he},onAnimationComplete:()=>C(false),whileHover:n?void 0:{scale:1.03,transition:{duration:.15,ease:he}},whileTap:n?void 0:{scale:.97,transition:{duration:.1,ease:he}},"data-patch-fab-dock":"",className:R("pkey-fab relative h-11 rounded-full",v?"overflow-hidden":"overflow-visible"),children:[jsx(motion.div,{animate:{opacity:n?0:1,scale:n?.7:1},transition:{duration:.18,ease:he},className:R("absolute inset-0",n?"pointer-events-none":"pointer-events-auto"),children:jsx("button",{type:"button",onClick:N,"data-patch-fab-dock":"","aria-label":"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsx(gr,{variant:"outline",size:18})})}),jsxs("div",{"data-patch-fab-dock":"",className:R("absolute inset-0 flex items-center gap-1.5 px-1.5",n?"pointer-events-auto":"pointer-events-none"),children:[jsx(dt,{visible:n,index:0,children:jsx(ke,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:H,className:R(ct,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(gr,{variant:"outline",size:16})})})}),jsx(dt,{visible:n,index:1,children:jsxs("div",{className:"relative flex items-center",children:[jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${M.label}`,"aria-expanded":c,onClick:ae,className:R(ct,"transition-colors",r.activeViewport==="desktop"&&!c?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx(O,{name:M.glyph,size:15})}),jsx(AnimatePresence,{children:c?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:he}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:he}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),_r.map($=>{let _e=ve[$],vt=r.activeViewport===$;return jsx(ke,{text:$e($),children:jsx("button",{type:"button","data-patch-viewport-option":$,"aria-label":$e($),"aria-pressed":vt,onClick:()=>Me($),className:R("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",vt?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(O,{name:_e.glyph,size:15})})},$)})]}):null})]})}),jsx(dt,{visible:n,index:2,children:jsxs("div",{className:"relative flex items-center",children:[jsx(ke,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":g,onClick:ft,className:R(ct,"transition-colors",g||o?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(O,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:g?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:he}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:he}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-[18px] p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-xl px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsx("input",{type:"checkbox",checked:o,"aria-label":"Hide resolved annotations",onChange:ht,className:"peer sr-only"}),jsx("span",{"aria-hidden":"true",className:R("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",o?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsx(O,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(dt,{visible:n,index:3,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Ce,onMouseLeave:h,onFocus:ce,onBlur:bt,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":T?`Account: ${T}`:"Identify",className:R(ct,"text-white"),children:T?jsx(Ee,{initials:P,tint:b,src:z,generatedSeed:G,alt:T,size:"sm",className:R("size-[22px] text-[9.5px] ring-1 ring-white/20",A)}):jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsx(AnimatePresence,{children:a?jsxs(motion.div,{initial:f?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:f?{duration:0}:{duration:.12,delay:Cs,ease:ao}},exit:{opacity:0,y:2,scale:.98,transition:w?{duration:0}:{duration:.08,ease:ao}},"data-patch-fab-dock":"","data-patch-identity-popover":"",className:"fixed right-8 bottom-[72px] z-[2147483647] w-[min(272px,calc(100vw-40px))] min-w-[220px] rounded-2xl bg-foreground p-3.5 font-sans text-[13px] text-white shadow-[0_18px_44px_-14px_rgba(0,0,0,0.5),0_6px_14px_-6px_rgba(0,0,0,0.45)] ring-1 ring-white/10",style:{transformOrigin:Ts},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:As}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Ee,{initials:P,tint:re,src:z,generatedSeed:G,alt:r.studio.name,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Ee,{initials:P,tint:re,generatedSeed:G,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsx("div",{className:"my-3 h-px bg-white/10"}),jsx("button",{type:"button",onClick:ue,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsx(dt,{visible:n,index:4,children:jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsx(ke,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:U,className:R(ct,"text-white/70"),children:jsx(O,{name:"x",size:14})})})]})})]})]})})}function dt({children:e,visible:t,index:r}){return jsx(motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:he}}:{opacity:0,x:6,transition:{duration:.12,ease:he}},children:e})}function lo(e,t){return t.width<=0||t.height<=0?{fx:0,fy:0}:{fx:(e.viewportX-t.x)/t.width,fy:(e.viewportY-t.y)/t.height}}function co(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var uo=.6,Ut={text:.4,attrs:.3,classes:.2,bbox:.1},Es=5e3;function Rs(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function Is(e,t){if(!t)return .5;let r=Object.keys(t);if(r.length===0)return .5;let n=0;for(let o of r)e[o]===t[o]&&n++;return n/r.length}function Ns(e,t){let r=new Set(e),n=new Set(t??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let s of r)n.has(s)&&o++;let i=r.size+n.size-o;return i===0?0:o/i}function Ps(e,t,r){if(!t)return .5;let n=e.x+e.width/2,o=e.y+e.height/2,i=t.x+t.width/2,s=t.y+t.height/2,a=(n-i)/Math.max(1,r.width),l=(o-s)/Math.max(1,r.height),c=Math.sqrt(a*a+l*l);return Math.max(0,1-c)}function po(e,t){let r=Nt(e),n=It(e),o=Le(e),i=e.getBoundingClientRect(),s=Rs(r,t.payload.domHints?.textSignature),a=Is(n,t.payload.domHints?.attributeSignature),l=Ns(o,t.payload.cssClasses),c=Ps(i,t.payload.boundingBox,t.viewport);return Ut.text*s+Ut.attrs*a+Ut.classes*l+Ut.bbox*c}function Ms(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function _s(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=lo({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return co(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Ds(e){let t=e.payload.domHints?.cssSelector;if(!t)return null;try{return e.doc.querySelector(t)}catch{return null}}function Os(e){let t=null,r=-1,n=0,o=e.doc.querySelectorAll("*");for(let i of Array.from(o)){if(n>=Es)break;if(n++,Pt(i,e.internalAttr))continue;let s=i.tagName.toLowerCase();if(s==="html"||s==="head"||s==="script"||s==="style")continue;let a=po(i,e);a>r&&(r=a,t=i);}return r>=uo?t:null}function Gt(e){if(!e.payload.domHints)return {tier:3,el:null};let t=Ds(e);if(t&&po(t,e)>=uo)return {tier:1,el:t};let r=Os(e);return r?{tier:2,el:r}:{tier:3,el:null}}function vr(e,t){return e.tier===3||!e.el?Ms(t):_s(e.el,t)}function mo(e){let t=Gt(e);return {tier:t.tier,el:t.el,position:vr(t,e)}}function go(e){if(e.status==="resolved")return null;let t=e.latestRun;return t?t.status==="failed"?"patch-failed":t.status!=="succeeded"?null:t.prClosedUnmerged?"rerun-after-closed":t.prUrl?"review-pr":null:null}var zs="data-patch-internal";function Kt(e,t,r){let n=Ke(r,t.getOverlayViewport()),o=Yt(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function yr(e,t){return {payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:zs}}function vo(e,t,r){let n=yr(e,t);return {tier:r.tier,position:e.targetPointToOverlay(vr(r,n))}}function Hs(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function xo(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:i}=me(),s=ge(),{dockOpen:a,hideResolvedAnnotations:l}=Ft(),c=se(),{isPreviewing:p,previewReady:g}=Ye(),u=useReducedMotion(),f=s.active,x=s.forceClose,w=t&&(!p||g),E=useMemo(()=>a&&t?e.filter(b=>!l||b.status!=="resolved"):[],[a,t,e,l]),k=useMemo(()=>a&&t?r:[],[a,t,r]);useEffect(()=>{if(!l||f?.kind!=="existing")return;e.find(A=>A.id===f.annotationId)?.status==="resolved"&&x();},[f,e,x,l]);let m=useRef(new Map),d=useRef(new Map),v=useRef(new Map),C=useMemo(()=>{let b=v.current,A=new Set,M=new Map;for(let I of E){A.add(I.id);let D=Gt(yr(c,I));b.set(I.id,D),M.set(I.id,vo(c,I,D));}for(let I of b.keys())A.has(I)||b.delete(I);return M},[c,E]),T=useCallback(()=>{let b=v.current;for(let A of E){let M=m.current.get(A.id);if(!M)continue;let I=b.get(A.id);(!I||I.el&&!I.el.isConnected)&&(I=Gt(yr(c,A)),b.set(A.id,I)),Kt(M,c,vo(c,A,I).position);}for(let A of k){let M=d.current.get(A.tempId);M&&Kt(M,c,Hs(c,A));}},[c,E,k]);useEffect(()=>{let b=null,A=()=>{b===null&&(b=c.overlayWindow.requestAnimationFrame(()=>{b=null,T();}));},M=new Set([c.targetWindow,c.overlayWindow]);for(let D of M)D.addEventListener("resize",A),D.addEventListener("scroll",A,{passive:true});let I=Tt(c.targetWindow,A);return I.observe(c.targetDocument.body),A(),()=>{b!==null&&c.overlayWindow.cancelAnimationFrame(b);for(let D of M)D.removeEventListener("resize",A),D.removeEventListener("scroll",A);I.disconnect();}},[T,c]);let P=useCallback(b=>{if(s.active&&s.draftText.trim().length>0){s.attemptClose();return}s.openExisting(b);},[s]),z=o?o.name:n?.name??null,X=o?.image??null,G=n?.avatarSeed??i,re=o?.userId??G;return jsxs("div",{"data-patch-pin-layer":"",style:{opacity:w?1:0,transition:u||!w?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:w?void 0:"none"},children:[jsx(AnimatePresence,{initial:false,children:E.map(b=>{let A=C.get(b.id),M=Fs(b),I=!o&&!!n?.clientUserId&&b.payload.authorRole==="client"&&b.payload.authorId===n.clientUserId,D=o?go(b):null,ie=A?Ke(A.position,c.getOverlayViewport()):"right";return jsx(pr,{ref:Q=>{Q?(m.current.set(b.id,Q),A&&Kt(Q,c,A.position)):m.current.delete(b.id);},avatarSrc:M.image,generatedSeed:I?G:M.generatedSeed,avatarAlt:M.name??"",resolved:b.status==="resolved",attention:D,orphan:A?.tier===3,pointSide:ie,ariaLabel:`Annotation by ${b.authorName??"someone"}`,onClick:()=>P(b.id),pinId:b.id},b.id)})}),jsx(AnimatePresence,{initial:false,children:k.map(b=>{let A=c.targetPointToOverlay({viewportX:b.viewportX,viewportY:b.viewportY});return jsx(pr,{ref:M=>{M?(d.current.set(b.tempId,M),Kt(M,c,A)):d.current.delete(b.tempId);},avatarSrc:X,generatedSeed:re,avatarAlt:z??"",resolved:false,pointSide:Ke(A,c.getOverlayViewport()),ephemeral:true},b.tempId)})})]})}function Fs(e){let t=e.authorAvatarSeed??e.payload.authorId??(e.authorName?`annotation-author:${e.authorName}`:null);if(e.authorImage||t||e.authorName)return {name:e.authorName,image:e.authorImage??null,generatedSeed:t??e.id,key:e.payload.authorId??e.authorName??e.id};let r=e.thread.find(n=>n.authorImage||n.authorId||n.authorName);if(r){let n=r.authorAvatarSeed??r.authorId??(r.authorName?`thread-author:${r.authorName}`:null);return {name:r.authorName,image:r.authorImage??null,generatedSeed:n??e.id,key:r.authorId??r.authorName??e.id}}return {name:e.authorName,image:e.authorImage??null,generatedSeed:e.id,key:e.id}}var wo=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
|
|
5
5
|
@layer properties;
|
|
6
6
|
@layer theme, base, components, utilities;
|
|
7
7
|
@layer theme {
|
|
@@ -1884,5 +1884,5 @@ button:not(:disabled):not(.pkey):active {
|
|
|
1884
1884
|
}
|
|
1885
1885
|
}
|
|
1886
1886
|
}
|
|
1887
|
-
`;var wo="patch-widget-root";function yo({children:e}){let[t,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(wo);o||(o=document.createElement(wo),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let i=o.shadowRoot??o.attachShadow({mode:"open"});if(!i.querySelector("style[data-patch-css]")){let a=document.createElement("style");a.setAttribute("data-patch-css",""),a.textContent=xo,i.appendChild(a);}let s=i.querySelector("div[data-patch-mount]");return s||(s=document.createElement("div"),s.setAttribute("data-patch-mount",""),i.appendChild(s)),r(s),()=>{}},[]),t?createPortal(e,t):null}var Bs=/[\s#.:[\]()>+~,\\]/;function ko(e){return !(!e||Bs.test(e)||/^\d/.test(e))}function Ws(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Co(e){if(!e.tagName)return "";if(e.id&&ko(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&&ko(r.id))return t.unshift(`#${r.id}`),t.join(" > ");t.unshift(`${o}:nth-of-type(${Ws(r)})`),r=r.parentElement,n++;}return t.join(" > ")}var Ys=80,Xs=500;function To(e){return e!==null&&typeof e=="object"}function Us(e){return To(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(!To(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 So(e){return e.replace(/\s+/g," ").trim()}function Eo(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Gs(e){let t=So(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:Eo(t,Ys)}function Ks(e){let t=jt(e.elementType)??jt(e.type);return t?Gs(t):null}function Ao(e){return Eo(So(e),Xs)}function qs(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 js(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 Ao(t.slice(o+1))}let r=t.split("/").filter(Boolean);return Ao(r.slice(-3).join("/"))}function Zs(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||qs(t)?null:js(t)}function Js(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(Us(n))return n}return null}function xr(e){let t=Js(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let a=Ks(t),l=a?dr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=Zs(t)),t=t.return??t._debugOwner??null,o+=1;}let i=r.length>0?Wn(r.reverse().map(a=>`<${a}>`).join(" ")):null,s={};return i&&(s.reactComponents=i),n&&(s.sourceFile=n),Object.keys(s).length>0?s:null}var Ro=500,Io=3;function Qs(e){return e.length<=Ro?e:e.slice(0,Ro)}function wr(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function Zt(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function No(e){let t={cssSelector:Co(e)},r=Nt(e);r&&(t.textSignature=r);let n=It(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function Po(e){return e.kind==="element"?ot(e.element,e.selectedText):e.kind==="multi"?_t(e.elements.length):Dt()}function Mo(e){let{target:t,click:r,comment:n,url:o}=e,i=t.element,s=t.rect,a=dn(i),l=pn(i),c=Le(i),p=mn(i),g=xr(i),u={comment:n,element:nt(i),elementPath:un(i),targetLabel:ot(i,t.selectedText),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:wr(r),boundingBox:Zt(s),domHints:No(i)};return t.selectedText&&(u.selectedText=Qs(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,i=t.elements.slice(0,Io).map(p=>nt(p)),s=t.elements.length>Io?"\u2026":"",a=`${t.elements.length} elements: ${i.join(", ")}${s}`,l=t.elements[0],c=l?xr(l):null;return {comment:n,element:a,elementPath:a,targetLabel:_t(t.elements.length),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:wr(r),boundingBox:Zt(t.union),isMultiSelect:true,elementBoundingBoxes:t.rects.map(Zt),...c?.reactComponents?{reactComponents:c.reactComponents}:{},...c?.sourceFile?{sourceFile:c.sourceFile}:{},...l?{domHints:No(l)}:{}}}function Do(e){let{target:t,click:r,comment:n,url:o}=e,i=Math.round(t.rect.width),s=Math.round(t.rect.height),a=Math.round(t.rect.x),l=Math.round(t.rect.y);return {comment:n,element:`region ${i}\xD7${s}`,elementPath:`region at (${a}, ${l}) ${i}\xD7${s}`,targetLabel:Dt(),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:wr(r),boundingBox:Zt(t.rect)}}async function ut(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function Oo(e,t){return t.resolve(e)}async function Lo(e,t){return t.deleteAnnotation(e)}async function zo(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function Ho(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function $o(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function Fo(e,t){return t.postIdentity(e)}var Wo=createContext(null),Bo=0;function kr(e){return Bo+=1,`${e}-${Date.now().toString(36)}-${Bo}`}function Cr(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function Yo({annotation:e,draftTargetLabel:t,children:r}){let n=me(),o=ge(),i=ae(),[s,a]=useState(false),[l,c]=useState(null),[p,g]=useState(null),u=useRef(false),f=e?.thread??[],v=e?.latestRun??null,w=e?.status==="resolved",S=e?Cr(e):false,C=n.viewerKind,m=useCallback(()=>C==="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,C]),d=useMemo(()=>m(),[m]),b=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!d.authorId&&e.payload.authorRole===d.role&&e.payload.authorId===d.authorId,y=useCallback(T=>{let P=m();return {id:kr("tmp-msg"),role:P.role,authorId:P.authorId,authorName:P.authorName,authorImage:P.authorImage,content:T,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[m]),E=useCallback(async T=>{if(u.current)return Promise.reject(new Error("busy"));u.current=true,a(true);try{return await T()}finally{u.current=false,a(false);}},[]),N=useCallback(async()=>{let T=o.draftText.trim();if(!T)return;if(e){if(w||Cr(e))return;let et=y(T);o.setDraftText(""),n.updateAnnotation(e.id,Ae=>({...Ae,thread:[...Ae.thread,et]}));let Ir=await ut({kind:"reply",annotationId:e.id,content:T},n.apiClient);if(Ir){n.updateAnnotation(e.id,Ae=>({...Ae,thread:Ae.thread.map(De=>De.id===et.id?{...De,id:Ir.id,deliveryStatus:"sent"}:De)})),n.refresh();return}n.updateAnnotation(e.id,Ae=>({...Ae,thread:Ae.thread.map(De=>De.id===et.id?{...De,deliveryStatus:"failed"}:De)}));return}let P=o.active;if(!P||P.kind!=="composer")return;let z=P.target,$={viewportX:P.anchor.viewportX,viewportY:P.anchor.viewportY,scrollY:P.anchor.documentY-P.anchor.viewportY},F=i.getPageUrl(),Si=Pr(n.activeViewport,i.getTargetViewport()),xt=z.kind==="element"?Mo({target:z,click:$,comment:T,url:F}):z.kind==="multi"?_o({target:z,click:$,comment:T,url:F}):Do({target:z,click:$,comment:T,url:F});xt.viewport=n.activeViewport,xt.viewportSize=Si;let wt=m(),yt=kr("tmp-ann");n.applyAnnotationUpdate({id:yt,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:wt.authorName,authorImage:wt.authorImage,payload:{...xt,authorRole:wt.role,authorId:wt.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(yt);let er=await ut({kind:"composer",payload:xt},n.apiClient);if(er){n.replaceAnnotationId(yt,er.id),o.openExisting(er.id),n.refresh();return}n.updateAnnotation(yt,et=>({...et,deliveryStatus:"failed"}));},[e,m,w,y,n,o,i]),D=useCallback(async T=>{if(!e||Cr(e))return;let P=e.thread.find($=>$.id===T);if(!P||P.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,$=>({...$,thread:$.thread.map(F=>F.id===T?{...F,deliveryStatus:"sending"}:F)}));let z=await ut({kind:"reply",annotationId:e.id,content:P.content},n.apiClient);if(z){n.updateAnnotation(e.id,$=>({...$,thread:$.thread.map(F=>F.id===T?{...F,id:z.id,deliveryStatus:"sent"}:F)})),n.refresh();return}n.updateAnnotation(e.id,$=>({...$,thread:$.thread.map(F=>F.id===T?{...F,deliveryStatus:"failed"}:F)}));},[e,n]),V=useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let T=e.id;n.updateAnnotation(T,z=>({...z,deliveryStatus:"sending"}));let P=await ut({kind:"composer",payload:e.payload},n.apiClient);if(P){n.replaceAnnotationId(T,P.id),o.openExisting(P.id),n.refresh();return}n.updateAnnotation(T,z=>({...z,deliveryStatus:"failed"}));},[e,n,o]),G=useCallback(T=>!d.authorId||T.deliveryStatus&&T.deliveryStatus!=="sent"?false:T.role===d.role&&T.authorId===d.authorId,[d]),x=useCallback(()=>{b&&(c(null),g({kind:"annotation"}));},[b]),A=useCallback(T=>{G(T)&&(c(null),g({kind:"message",messageId:T.id}));},[G]),O=useCallback(()=>{c(null),g(null);},[]),j=useCallback(async T=>{if(!e)return false;let P=e.thread;return E(async()=>(c(null),n.updateAnnotation(e.id,$=>({...$,thread:$.thread.filter(F=>F.id!==T)})),await zo({annotationId:e.id,messageId:T},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,$=>({...$,thread:P})),c("Couldn't delete message. Try again."),false)))},[e,n,E]),B=useCallback(async()=>!e||!b?false:E(async()=>(c(null),await Lo(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]),K=useCallback(async()=>{if(p)try{(p.kind==="annotation"?await B():await j(p.messageId))&&g(null);}catch{c("Couldn't delete. Try again.");}},[p,B,j]),ee=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,z=>({...z,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await Oo(e.id,n.apiClient)){n.updateAnnotation(e.id,z=>({...z,...T})),c("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,E]),de=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,z=>({...z,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await Ho({annotationId:e.id,viewerKind:C},n.apiClient)){n.updateAnnotation(e.id,z=>({...z,...T})),c("Couldn't reopen. Try again.");return}n.refresh();});},[e,C,n,E]),se=useCallback(async T=>{e&&await E(async()=>{c(null);let P=e.latestRun,z=e.optimisticAction;n.updateAnnotation(e.id,F=>({...F,latestRun:{id:kr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let $=await $o({annotationId:e.id,viewerKind:C,guidance:T},n.apiClient);if(!$?.ok){n.updateAnnotation(e.id,F=>({...F,latestRun:P,optimisticAction:z})),c($?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,C,n,E]),le=useCallback(async T=>{let P=await Fo({...T,avatarSeed:n.clientAvatarSeed},n.apiClient);return P&&await n.setIdentity(P),P},[n]),h=C==="client"&&!n.identity&&f.length===0,I=!!e||f.length>0,L=n.agentRunReadiness?.ready??true,X=n.agentRunReadiness?.message??null,ue=useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),ie=e?bn(e.payload):t||"annotation",Me=e?.payload.viewport??n.activeViewport,ft=n.studio?n.studio.name:n.identity?.name??null,ht=n.identity?.avatarSeed??n.clientAvatarSeed,bt=n.studio?.userId??ht,H=n.studio?.image??null,_e=n.studio?.userId??ht,vt=useMemo(()=>({state:{annotation:e,messages:f,runState:v,draftText:o.draftText,busy:s,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:p,showDevFooter:C==="studio",agentRunReady:L,agentRunSetupMessage:X,needsIdentity:h,isResolved:w,initialMessageLocked:S,threadVisible:I,canDeleteAnnotation:b},actions:{setDraftText:o.setDraftText,submit:N,retryMessage:D,retryInitialMessage:V,requestDeleteAnnotation:x,requestDeleteMessage:A,canDeleteMessage:G,cancelDelete:O,confirmDelete:K,markResolved:ee,reopen:de,runPatch:se,setIdentity:le,attemptClose:o.attemptClose,requestClose:ue,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:ie,viewport:Me,shakeNonce:o.shakeNonce,viewer:{kind:C,authorId:d.authorId,name:ft,avatarKey:bt,avatarSrc:H,generatedSeed:_e}}}),[e,f,v,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,s,l,p,N,D,V,x,A,G,O,K,ee,de,se,le,C,L,X,h,w,S,I,b,ue,ie,Me,d.authorId,ft,bt,H,_e]);return jsx(Wo.Provider,{value:vt,children:r})}function Y(){let e=use(Wo);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var il="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 Ar(e="brand",t){return R(il,al[e],t)}function ne({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:Ar(e,t),...o})}function Uo(){let{state:e,actions:t}=Y(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",i=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",s=n?"Delete annotation":"Delete message";return jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsx("div",{className:"text-xs text-muted-foreground",children:i}),e.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(ne,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsx(ne,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":s})]})]})})}function Ko(){let{state:e,actions:t}=Y();return e.confirmDiscardOpen?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(ne,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(ne,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var ll="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",cl={sm:"size-7",md:"size-8"},dl={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 jsx("button",{ref:o,type:n,className:R(ll,cl[e],dl[t],r),...i})}function qo(e){let t=new Date(e).getTime(),r=Date.now()-t,n=Math.round(r/6e4);if(Number.isNaN(n))return "";if(n<1)return "just now";if(n<60)return `${n}m ago`;let o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function jo(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 Zo(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}function Jo(){let{state:e}=Y();return !e.showDevFooter||!e.annotation?null:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx(pl,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(gl,{})})]}),e.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function pl(){let{state:e,actions:t}=Y(),[r,n]=useState(false),[o,i]=useState(""),[s,a]=useState(false),l=e.runState,c=l?.status;if(e.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let g=c==="queued"||c==="running",u=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,f=c==="succeeded"&&l?.prClosedUnmerged,v=l?"Run Patch again":"Run Patch",w=c==="failed"?"destructiveTint":f?"warnTint":"brand",S=!e.agentRunReady,C=async()=>{try{a(!0),await t.runPatch(o.trim()||void 0),i(""),n(!1);}finally{a(false);}};if(g)return jsx("div",{className:"min-w-0 flex-1",children:jsxs(ne,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let d=Zo(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Ar("brand","no-underline"),children:[jsx(M,{name:"pr",size:12}),d==="PR"?"View PR":`View PR ${d}`]})})}let m=jsxs(ne,{variant:w,disabled:e.busy||S,className:S?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(M,{name:c==="failed"?"play":"robot",size:12})," ",v]});return jsxs("div",{className:"min-w-0 flex-1",children:[S&&e.agentRunSetupMessage?jsx(ke,{text:e.agentRunSetupMessage,tone:"warning",children:m}):m,r?jsx(ml,{title:v,guidance:o,submitting:s||e.busy,onGuidanceChange:i,onCancel:()=>n(false),onSubmit:C}):null]})}function ml({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:i}){return jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxs("form",{role:"dialog","aria-label":e,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-[20px] bg-popover p-4 shadow-dialog",onSubmit:s=>{s.preventDefault(),i();},children:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-xl bg-brand text-white",children:jsx(M,{name:"robot",size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsx(Re,{size:"sm",title:"Close",onClick:o,children:jsx(M,{name:"x",size:12})})]}),jsxs("label",{className:"flex flex-col gap-1.5",children:[jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsx("textarea",{value:t,onChange:s=>n(s.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-[16px] border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxs("div",{className:"flex justify-end gap-2",children:[jsx(ne,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(ne,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function gl(){let{state:e,actions:t}=Y();return e.annotation?e.annotation.status==="resolved"?jsxs(ne,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsx(M,{name:"refresh",size:12}),"Reopen"]}):jsxs(ne,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsx(M,{name:"check",size:12}),"Resolve"]}):null}var Sr=createContext({expanded:false,onToggleExpand:()=>{}});function Qo(){return use(Sr)}function ei(){let{state:e,meta:t}=Y(),{expanded:r,onToggleExpand:n}=Qo(),o=e.annotation,i=ve[t.viewport],s=o?.payload.selectedText;return jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{title:t.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:t.targetLabel}),jsx(ke,{text:Fe(t.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":Fe(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx(M,{name:i.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsx(M,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[jsx(xl,{}),jsx(Re,{onClick:n,title:r?"Collapse":"Expand",children:jsx(M,{name:r?"minimize":"maximize",size:13})}),jsx(vl,{})]})]})]}),s?jsx("div",{className:"rounded-xl bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:s.length>200?`${s.slice(0,199).trim()}\u2026`:s})}):null]})}function vl(){let{actions:e}=Y();return jsx(Re,{onClick:e.requestClose,title:"Close",children:jsx(M,{name:"x",size:14})})}function xl(){let{state:e,actions:t}=Y(),[r,n]=useState(false);return e.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(Re,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(M,{name:"more",size:14})}),r?jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),t.requestDeleteAnnotation();},children:[jsx(M,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function ii(){let{state:e,actions:t,meta:r}=Y(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,i=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),e.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:R("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",e.showDevFooter&&e.isResolved&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[e.annotation?jsx(ni,{name:e.annotation.authorName??"Someone",createdAt:e.annotation.createdAt,content:e.annotation.payload.comment,authorKey:e.annotation.payload.authorId??e.annotation.authorName??e.annotation.id,avatarSrc:e.annotation.authorImage,generatedSeed:e.annotation.payload.authorRole==="client"&&e.annotation.payload.authorId===i?o:e.annotation.authorAvatarSeed??e.annotation.payload.authorId??null,deliveryStatus:e.annotation.deliveryStatus,onRetry:e.annotation.deliveryStatus==="failed"?t.retryInitialMessage:void 0}):null,e.messages.map(a=>jsx(ni,{name:a.authorName??a.role,createdAt:a.createdAt,content:a.content,authorKey:a.authorId??a.authorName??a.role,avatarSrc:a.authorImage,generatedSeed:a.role==="client"&&a.authorId===i?o:a.authorAvatarSeed??a.authorId,deliveryStatus:a.deliveryStatus,canDelete:t.canDeleteMessage(a),onDelete:()=>t.requestDeleteMessage(a),onRetry:a.deliveryStatus==="failed"?()=>{t.retryMessage(a.id);}:void 0},a.id))]}):null}function ni(e){let t=Ue(e.name),r=Ge(e.authorKey),n=e.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(Ee,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:qo(e.createdAt)})]}),e.canDelete&&e.onDelete?jsx(Cl,{onDelete:e.onDelete}):null,jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?jsx("button",{type:"button",onClick:e.onRetry,className:"rounded-full bg-black/8 px-2 py-1 font-medium text-foreground transition-colors hover:bg-black/12",children:"Retry"}):null]}):null]})]})}var yl=44,kl=8;function Cl({onDelete:e}){let[t,r]=useState(false),[n,o]=useState("down"),i=useRef(null),s=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<yl+kl&&f>u?"up":"down");},[]),a=useCallback(()=>{r(l=>{let c=!l;return c&&s(),c});},[s]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx(Re,{ref:i,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:a,children:jsx(M,{name:"more",size:14})}),t?jsx("div",{role:"menu",className:R("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),e();},children:[jsx(M,{name:"trash",size:13}),"Delete"]})}):null]})}var Al={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 ai({variant:e="default",className:t,ref:r,...n}){return jsx("textarea",{ref:r,className:R(Al[e],t),...n})}var Rl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,si="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 li(){let{actions:e}=Y(),[t,r]=useState(""),[n,o]=useState(""),[i,s]=useState(null),[a,l]=useState(false),c=useRef(null);return useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxs("form",{onSubmit:async g=>{g.preventDefault();let u=t.trim(),f=n.trim();if(!u){s("Name is required.");return}if(!Rl.test(f)){s("Enter a valid email.");return}s(null),l(true);let v=await e.setIdentity({name:u,email:f});l(false),v||s("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsx("input",{ref:c,type:"text",placeholder:"Name",value:t,onChange:g=>r(g.target.value),className:si}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:g=>o(g.target.value),className:si}),i?jsx("div",{className:"text-xs text-destructive",children:i}):null,jsx("button",{type:"submit",disabled:a,className:R("self-end rounded-[10px] bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}function di(){let{state:e,actions:t,meta:r}=Y(),n=useRef(null),[o,i]=useState(false);if(useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),useEffect(()=>{let u=n.current;if(!u)return;u.style.height="0px";let 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 jsx("div",{className:R("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsx(li,{})});let s=e.draftText.trim().length>0,a=r.viewer.name,l=Ue(a),c=r.viewer.kind==="studio"?"var(--color-foreground)":Ge(r.viewer.avatarKey),p=u=>{u.preventDefault(),t.submit();},g=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),t.submit());};return jsx("form",{onSubmit:p,className:R("bg-white p-3",e.threadVisible&&"border-t border-black/6",e.showDevFooter&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxs("div",{className:R("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-[18px]":"rounded-full"),children:[jsx(Ee,{initials:l,tint:c,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:a??"",className:"self-start"}),jsx(ai,{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"}}),jsx(Ml,{enabled:s})]})})}function Ml({enabled:e}){return jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:R("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsx(M,{name:"arrow-up",size:13})})}var zl=440,mi=88,Qt=16,Hl=[.22,.61,.36,1],$l=[.4,0,.2,1],Fl={x:-8,y:-8,origin:"top left"},gi=200;function fi(e,t,r){return Math.max(t,Math.min(r,e))}function bi(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:fi((n.x-o.x)*.08,-12,12),y:fi((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Vl(e,t){if(!t)return Fl;let r=it({anchor:t,popover:{width:332,height:gi},viewport:e.getOverlayViewport()});return bi(t,r,gi)}function Bl(e,t){return e.x===t.x&&e.y===t.y&&e.origin===t.origin}function vi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n=0,onToggleExpand:o,children:i}){let{actions:{attemptClose:s},meta:{shakeNonce:a}}=Y(),l=ae(),c=useRef(null),[p,g]=useState(600),[u,f]=useState(()=>Vl(l,t??e())),v=useCallback(()=>{let m=c.current;if(!m||r)return;let d=e();if(!d)return;let b=m.offsetHeight||200,y=it({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=bi(d,y,b);f(N=>Bl(N,E)?N:E);},[e,r,l]);useLayoutEffect(()=>{r||v(),g(l.getOverlayViewport().height-Qt-mi);}),useEffect(()=>{let m=null,d=()=>{m===null&&(m=l.overlayWindow.requestAnimationFrame(()=>{m=null,r||v(),g(l.getOverlayViewport().height-Qt-mi);}));},b=new Set([l.targetWindow,l.overlayWindow]);for(let E of b)E.addEventListener("resize",d),E.addEventListener("scroll",d,{passive:true});let y=Tt(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]),useEffect(()=>{let m=y=>{jo(y)||s();},d=y=>{y.key==="Escape"&&s();},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);}},[s,l]);let w=useRef(a);useEffect(()=>{if(a===w.current)return;w.current=a;let m=c.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[a]);let S={left:"auto",right:`${Qt}px`,top:`${Qt}px`,width:`${zl}px`,height:`${p}px`},C={width:`${332}px`,height:"auto",transformOrigin:u.origin};return jsx(motion.div,{ref:c,layout:true,initial:{opacity:0,x:u.x,y:u.y,scale:.985},animate:{opacity:1,x:0,y:0,scale:1,transition:{type:"spring",stiffness:560,damping:34,mass:.7,delay:n}},exit:{opacity:0,x:u.x,y:u.y,scale:.985,transition:{duration:.16,ease:$l}},transition:{layout:{duration:.42,ease:Hl}},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:C,children:jsx(Sr.Provider,{value:{expanded:r,onToggleExpand:o},children:i})})}var Q={Root:vi,Header:ei,Messages:ii,Reply:di,DevFooter:Jo,ConfirmDiscard:Ko,ConfirmDelete:Uo};function xi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(Q.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(Q.Header,{}),jsx(Q.Messages,{}),jsx(Q.Reply,{}),jsx(Q.ConfirmDiscard,{}),jsx(Q.ConfirmDelete,{})]})}function wi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(Q.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(Q.Header,{}),jsx(Q.Messages,{}),jsx(Q.Reply,{}),jsx(Q.DevFooter,{}),jsx(Q.ConfirmDiscard,{}),jsx(Q.ConfirmDelete,{})]})}var ql="data-patch-internal";function Ci(e,t,r){let n={viewportX:t,viewportY:r},o=Ke(n,e.getOverlayViewport());return Yt(n,o)}function jl(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function Zl(e,t){let r=jl(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 Jl(e,t){if(!t)return null;let r=Gt({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:ql}),n=e.targetPointToOverlay(r.position);return Ci(e,n.viewportX,n.viewportY)}function ki(e,t,r){if(!t)return null;if(t.kind==="existing")return Zl(e,t.annotationId)??Jl(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return Ci(e,n.viewportX,n.viewportY)}function Ai(){let e=ge(),t=me(),r=ae(),n=e.active,o=useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(v=>v.id===n.annotationId)??null,[n,t.annotations]),i=useCallback(()=>ki(r,n,o),[n,o,r]),[s,a]=useState(false),l=e.active?e.active.kind==="existing"?e.active.annotationId:"composer":null;useEffect(()=>{a(false);},[l]);let c=t.viewerKind==="studio"?wi:xi,p=n&&(n.kind==="composer"||!!o),g=n?.kind==="composer"?.04:0,u=n?.kind==="composer"?Po(n.target):null,f=useMemo(()=>ki(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:p?jsx(Yo,{annotation:o,draftTargetLabel:u,children:jsx(c,{getAnchorRect:i,initialAnchorRect:f,expanded:s,entryDelay:g,onToggleExpand:()=>a(v=>!v)})},"active-popover"):null})}var ec="https://app.usepatch.dev";function Ti(e){let t=typeof window<"u"&&Gr(window),r=useMemo(()=>$n({prop:e.projectToken,processEnv:Vn(),importMetaEnv:Fn()}),[e.projectToken]),n=e.apiBase??ec;return t?null:jsx(yo,{children:jsx(Kr,{children:jsx(rn,{projectToken:r,apiBase:n,children:jsx(on,{children:jsx(Hn,{children:jsxs(Dn,{children:[jsx(vo,{}),jsx(Ai,{}),jsx(oo,{})]})})})})})})}var tc=Ti;
|
|
1888
|
-
export{
|
|
1887
|
+
`;var yo="patch-widget-root";function ko({children:e}){let[t,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(yo);o||(o=document.createElement(yo),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let i=o.shadowRoot??o.attachShadow({mode:"open"});if(!i.querySelector("style[data-patch-css]")){let a=document.createElement("style");a.setAttribute("data-patch-css",""),a.textContent=wo,i.appendChild(a);}let s=i.querySelector("div[data-patch-mount]");return s||(s=document.createElement("div"),s.setAttribute("data-patch-mount",""),i.appendChild(s)),r(s),()=>{}},[]),t?createPortal(e,t):null}var Xs=/[\s#.:[\]()>+~,\\]/;function Co(e){return !(!e||Xs.test(e)||/^\d/.test(e))}function Us(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Ao(e){if(!e.tagName)return "";if(e.id&&Co(e.id))return `#${e.id}`;let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<4;){let o=r.tagName.toLowerCase();if(r.id&&Co(r.id))return t.unshift(`#${r.id}`),t.join(" > ");t.unshift(`${o}:nth-of-type(${Us(r)})`),r=r.parentElement,n++;}return t.join(" > ")}var Gs=80,Ks=500;function So(e){return e!==null&&typeof e=="object"}function qs(e){return So(e)?"return"in e||"type"in e||"elementType"in e||"_debugOwner"in e:false}function jt(e){if(typeof e=="function")return e.displayName||e.name||null;if(!So(e))return null;let t=e.displayName;if(typeof t=="string"&&t)return t;let r=jt(e.render);if(r)return r;let n=jt(e.type);return n||null}function Eo(e){return e.replace(/\s+/g," ").trim()}function Ro(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function js(e){let t=Eo(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:Ro(t,Gs)}function Zs(e){let t=jt(e.elementType)??jt(e.type);return t?js(t):null}function To(e){return Ro(Eo(e),Ks)}function Js(e){let t=e.replace(/\\/g,"/");return t.includes("/.next/")||t.includes("/node_modules/next/")||t.includes("/node_modules/react/")||t.includes("/node_modules/react-dom/")||t.includes("/node_modules/react-router/")||t.includes("/node_modules/react-router-dom/")||t.includes("/node_modules/@remix-run/")||t.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(t)}function Qs(e){let t=e.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=t.lastIndexOf(n);if(o>=0)return To(t.slice(o+1))}let r=t.split("/").filter(Boolean);return To(r.slice(-3).join("/"))}function el(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||Js(t)?null:Qs(t)}function tl(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(qs(n))return n}return null}function kr(e){let t=tl(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let a=Zs(t),l=a?dr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=el(t)),t=t.return??t._debugOwner??null,o+=1;}let i=r.length>0?Un(r.reverse().map(a=>`<${a}>`).join(" ")):null,s={};return i&&(s.reactComponents=i),n&&(s.sourceFile=n),Object.keys(s).length>0?s:null}var Io=500,No=3;function rl(e){return e.length<=Io?e:e.slice(0,Io)}function Cr(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function Zt(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Po(e){let t={cssSelector:Ao(e)},r=Nt(e);r&&(t.textSignature=r);let n=It(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function Mo(e){return e.kind==="element"?ot(e.element,e.selectedText):e.kind==="multi"?_t(e.elements.length):Dt()}function _o(e){let{target:t,click:r,comment:n,url:o}=e,i=t.element,s=t.rect,a=mn(i),l=fn(i),c=Le(i),p=hn(i),g=kr(i),u={comment:n,element:nt(i),elementPath:gn(i),targetLabel:ot(i,t.selectedText),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:Cr(r),boundingBox:Zt(s),domHints:Po(i)};return t.selectedText&&(u.selectedText=rl(t.selectedText)),l&&(u.nearbyText=l),c.length>0&&(u.cssClasses=c),p.length>0&&(u.nearbyElements=p),a&&(u.accessibility=a),g?.reactComponents&&(u.reactComponents=g.reactComponents),g?.sourceFile&&(u.sourceFile=g.sourceFile),u}function Do(e){let{target:t,click:r,comment:n,url:o}=e,i=t.elements.slice(0,No).map(p=>nt(p)),s=t.elements.length>No?"\u2026":"",a=`${t.elements.length} elements: ${i.join(", ")}${s}`,l=t.elements[0],c=l?kr(l):null;return {comment:n,element:a,elementPath:a,targetLabel:_t(t.elements.length),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:Cr(r),boundingBox:Zt(t.union),isMultiSelect:true,elementBoundingBoxes:t.rects.map(Zt),...c?.reactComponents?{reactComponents:c.reactComponents}:{},...c?.sourceFile?{sourceFile:c.sourceFile}:{},...l?{domHints:Po(l)}:{}}}function Oo(e){let{target:t,click:r,comment:n,url:o}=e,i=Math.round(t.rect.width),s=Math.round(t.rect.height),a=Math.round(t.rect.x),l=Math.round(t.rect.y);return {comment:n,element:`region ${i}\xD7${s}`,elementPath:`region at (${a}, ${l}) ${i}\xD7${s}`,targetLabel:Dt(),timestamp:Date.now(),url:be(o),kind:"feedback",coordinates:Cr(r),boundingBox:Zt(t.rect)}}async function ut(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function Lo(e,t){return t.resolve(e)}async function zo(e,t){return t.deleteAnnotation(e)}async function Ho(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function Fo(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function $o(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function Vo(e,t){return t.postIdentity(e)}var Yo=createContext(null),Wo=0;function Tr(e){return Wo+=1,`${e}-${Date.now().toString(36)}-${Wo}`}function Sr(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function Xo({annotation:e,draftTargetLabel:t,children:r}){let n=me(),o=ge(),i=se(),[s,a]=useState(false),[l,c]=useState(null),[p,g]=useState(null),u=useRef(false),f=e?.thread??[],x=e?.latestRun??null,w=e?.status==="resolved",E=e?Sr(e):false,k=n.viewerKind,m=useCallback(()=>k==="studio"?{role:"studio",authorId:n.studio?.userId??null,authorName:n.studio?.name??null,authorImage:n.studio?.image??null}:{role:"client",authorId:n.identity?.clientUserId??null,authorName:n.identity?.name??null,authorImage:null},[n.identity,n.studio,k]),d=useMemo(()=>m(),[m]),v=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!d.authorId&&e.payload.authorRole===d.role&&e.payload.authorId===d.authorId,C=useCallback(S=>{let _=m();return {id:Tr("tmp-msg"),role:_.role,authorId:_.authorId,authorName:_.authorName,authorImage:_.authorImage,content:S,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[m]),T=useCallback(async S=>{if(u.current)return Promise.reject(new Error("busy"));u.current=true,a(true);try{return await S()}finally{u.current=false,a(false);}},[]),P=useCallback(async()=>{let S=o.draftText.trim();if(!S)return;if(e){if(w||Sr(e))return;let et=C(S);o.setDraftText(""),n.updateAnnotation(e.id,Ae=>({...Ae,thread:[...Ae.thread,et]}));let Mr=await ut({kind:"reply",annotationId:e.id,content:S},n.apiClient);if(Mr){n.updateAnnotation(e.id,Ae=>({...Ae,thread:Ae.thread.map(De=>De.id===et.id?{...De,id:Mr.id,deliveryStatus:"sent"}:De)})),n.refresh();return}n.updateAnnotation(e.id,Ae=>({...Ae,thread:Ae.thread.map(De=>De.id===et.id?{...De,deliveryStatus:"failed"}:De)}));return}let _=o.active;if(!_||_.kind!=="composer")return;let F=_.target,V={viewportX:_.anchor.viewportX,viewportY:_.anchor.viewportY,scrollY:_.anchor.documentY-_.anchor.viewportY},B=i.getPageUrl(),Ei=Dr(n.activeViewport,i.getTargetViewport()),xt=F.kind==="element"?_o({target:F,click:V,comment:S,url:B}):F.kind==="multi"?Do({target:F,click:V,comment:S,url:B}):Oo({target:F,click:V,comment:S,url:B});xt.viewport=n.activeViewport,xt.viewportSize=Ei;let wt=m(),yt=Tr("tmp-ann");n.applyAnnotationUpdate({id:yt,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:wt.authorName,authorImage:wt.authorImage,payload:{...xt,authorRole:wt.role,authorId:wt.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(yt);let er=await ut({kind:"composer",payload:xt},n.apiClient);if(er){n.replaceAnnotationId(yt,er.id),o.openExisting(er.id),n.refresh();return}n.updateAnnotation(yt,et=>({...et,deliveryStatus:"failed"}));},[e,m,w,C,n,o,i]),z=useCallback(async S=>{if(!e||Sr(e))return;let _=e.thread.find(V=>V.id===S);if(!_||_.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"sending"}:B)}));let F=await ut({kind:"reply",annotationId:e.id,content:_.content},n.apiClient);if(F){n.updateAnnotation(e.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,id:F.id,deliveryStatus:"sent"}:B)})),n.refresh();return}n.updateAnnotation(e.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"failed"}:B)}));},[e,n]),X=useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let S=e.id;n.updateAnnotation(S,F=>({...F,deliveryStatus:"sending"}));let _=await ut({kind:"composer",payload:e.payload},n.apiClient);if(_){n.replaceAnnotationId(S,_.id),o.openExisting(_.id),n.refresh();return}n.updateAnnotation(S,F=>({...F,deliveryStatus:"failed"}));},[e,n,o]),G=useCallback(S=>!d.authorId||S.deliveryStatus&&S.deliveryStatus!=="sent"?false:S.role===d.role&&S.authorId===d.authorId,[d]),re=useCallback(()=>{v&&(c(null),g({kind:"annotation"}));},[v]),b=useCallback(S=>{G(S)&&(c(null),g({kind:"message",messageId:S.id}));},[G]),A=useCallback(()=>{c(null),g(null);},[]),M=useCallback(async S=>{if(!e)return false;let _=e.thread;return T(async()=>(c(null),n.updateAnnotation(e.id,V=>({...V,thread:V.thread.filter(B=>B.id!==S)})),await Ho({annotationId:e.id,messageId:S},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,V=>({...V,thread:_})),c("Couldn't delete message. Try again."),false)))},[e,n,T]),I=useCallback(async()=>!e||!v?false:T(async()=>(c(null),await zo(e.id,n.apiClient)?(n.updateAnnotation(e.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[e,v,n,o,T]),D=useCallback(async()=>{if(p)try{(p.kind==="annotation"?await I():await M(p.messageId))&&g(null);}catch{c("Couldn't delete. Try again.");}},[p,I,M]),ie=useCallback(async()=>{e&&await T(async()=>{c(null);let S={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,F=>({...F,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await Lo(e.id,n.apiClient)){n.updateAnnotation(e.id,F=>({...F,...S})),c("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,T]),Q=useCallback(async()=>{e&&await T(async()=>{c(null);let S={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,F=>({...F,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await Fo({annotationId:e.id,viewerKind:k},n.apiClient)){n.updateAnnotation(e.id,F=>({...F,...S})),c("Couldn't reopen. Try again.");return}n.refresh();});},[e,k,n,T]),le=useCallback(async S=>{e&&await T(async()=>{c(null);let _=e.latestRun,F=e.optimisticAction;n.updateAnnotation(e.id,B=>({...B,latestRun:{id:Tr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let V=await $o({annotationId:e.id,viewerKind:k,guidance:S},n.apiClient);if(!V?.ok){n.updateAnnotation(e.id,B=>({...B,latestRun:_,optimisticAction:F})),c(V?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,k,n,T]),ce=useCallback(async S=>{let _=await Vo({...S,avatarSeed:n.clientAvatarSeed},n.apiClient);return _&&await n.setIdentity(_),_},[n]),h=k==="client"&&!n.identity&&f.length===0,N=!!e||f.length>0,H=n.agentRunReadiness?.ready??true,U=n.agentRunReadiness?.message??null,ue=useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),ae=e?wn(e.payload):t||"annotation",Me=e?.payload.viewport??n.activeViewport,ft=n.studio?n.studio.name:n.identity?.name??null,ht=n.identity?.avatarSeed??n.clientAvatarSeed,bt=n.studio?.userId??ht,$=n.studio?.image??null,_e=n.studio?.userId??ht,vt=useMemo(()=>({state:{annotation:e,messages:f,runState:x,draftText:o.draftText,busy:s,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:p,showDevFooter:k==="studio",agentRunReady:H,agentRunSetupMessage:U,needsIdentity:h,isResolved:w,initialMessageLocked:E,threadVisible:N,canDeleteAnnotation:v},actions:{setDraftText:o.setDraftText,submit:P,retryMessage:z,retryInitialMessage:X,requestDeleteAnnotation:re,requestDeleteMessage:b,canDeleteMessage:G,cancelDelete:A,confirmDelete:D,markResolved:ie,reopen:Q,runPatch:le,setIdentity:ce,attemptClose:o.attemptClose,requestClose:ue,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:ae,viewport:Me,shakeNonce:o.shakeNonce,viewer:{kind:k,authorId:d.authorId,name:ft,avatarKey:bt,avatarSrc:$,generatedSeed:_e}}}),[e,f,x,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,s,l,p,P,z,X,re,b,G,A,D,ie,Q,le,ce,k,H,U,h,w,E,N,v,ue,ae,Me,d.authorId,ft,bt,$,_e]);return jsx(Yo.Provider,{value:vt,children:r})}function Y(){let e=use(Yo);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var ll="inline-flex shrink-0 items-center justify-center gap-1.5 h-8 px-3.5 rounded-full whitespace-nowrap text-[13px] font-semibold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",cl={brand:"pkey pkey-brand text-white",brandTint:"bg-brand-tint text-brand hover:bg-brand-tint/70",destructive:"pkey pkey-destructive text-white",destructiveTint:"bg-destructive/10 text-destructive hover:bg-destructive/15",successTint:"bg-brand-green/10 text-brand-green hover:bg-brand-green/15",warn:"pkey pkey-warn text-white",warnTint:"bg-brand-orange/10 text-brand-orange hover:bg-brand-orange/15",neutral:"pkey pkey-outline text-foreground",subtle:"bg-black/8 text-muted-foreground"};function Er(e="brand",t){return R(ll,cl[e],t)}function ne({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:Er(e,t),...o})}function Go(){let{state:e,actions:t}=Y(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",i=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",s=n?"Delete annotation":"Delete message";return jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsx("div",{className:"text-xs text-muted-foreground",children:i}),e.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(ne,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsx(ne,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":s})]})]})})}function qo(){let{state:e,actions:t}=Y();return e.confirmDiscardOpen?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(ne,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(ne,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var ul="inline-grid place-items-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",pl={sm:"size-7",md:"size-8"},ml={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Re({size:e="sm",tone:t="default",className:r,type:n="button",ref:o,...i}){return jsx("button",{ref:o,type:n,className:R(ul,pl[e],ml[t],r),...i})}function jo(e){let t=new Date(e).getTime(),r=Date.now()-t,n=Math.round(r/6e4);if(Number.isNaN(n))return "";if(n<1)return "just now";if(n<60)return `${n}m ago`;let o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function Zo(e){let t=e.composedPath();for(let r of t)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function Jo(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}function Qo(){let{state:e}=Y();return !e.showDevFooter||!e.annotation?null:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx(fl,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(bl,{})})]}),e.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function fl(){let{state:e,actions:t}=Y(),[r,n]=useState(false),[o,i]=useState(""),[s,a]=useState(false),l=e.runState,c=l?.status;if(e.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let g=c==="queued"||c==="running",u=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,f=c==="succeeded"&&l?.prClosedUnmerged,x=l?"Run Patch again":"Run Patch",w=c==="failed"?"destructiveTint":f?"warnTint":"brand",E=!e.agentRunReady,k=async()=>{try{a(!0),await t.runPatch(o.trim()||void 0),i(""),n(!1);}finally{a(false);}};if(g)return jsx("div",{className:"min-w-0 flex-1",children:jsxs(ne,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let d=Jo(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Er("brand","no-underline"),children:[jsx(O,{name:"pr",size:12}),d==="PR"?"View PR":`View PR ${d}`]})})}let m=jsxs(ne,{variant:w,disabled:e.busy||E,className:E?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(O,{name:c==="failed"?"play":"robot",size:12})," ",x]});return jsxs("div",{className:"min-w-0 flex-1",children:[E&&e.agentRunSetupMessage?jsx(ke,{text:e.agentRunSetupMessage,tone:"warning",children:m}):m,r?jsx(hl,{title:x,guidance:o,submitting:s||e.busy,onGuidanceChange:i,onCancel:()=>n(false),onSubmit:k}):null]})}function hl({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:i}){return jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxs("form",{role:"dialog","aria-label":e,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-[20px] bg-popover p-4 shadow-dialog",onSubmit:s=>{s.preventDefault(),i();},children:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-xl bg-brand text-white",children:jsx(O,{name:"robot",size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsx(Re,{size:"sm",title:"Close",onClick:o,children:jsx(O,{name:"x",size:12})})]}),jsxs("label",{className:"flex flex-col gap-1.5",children:[jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsx("textarea",{value:t,onChange:s=>n(s.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-[16px] border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxs("div",{className:"flex justify-end gap-2",children:[jsx(ne,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(ne,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function bl(){let{state:e,actions:t}=Y();return e.annotation?e.annotation.status==="resolved"?jsxs(ne,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsx(O,{name:"refresh",size:12}),"Reopen"]}):jsxs(ne,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsx(O,{name:"check",size:12}),"Resolve"]}):null}var Ir=createContext({expanded:false,onToggleExpand:()=>{}});function ei(){return use(Ir)}function ti(){let{state:e,meta:t}=Y(),{expanded:r,onToggleExpand:n}=ei(),o=e.annotation,i=ve[t.viewport],s=o?.payload.selectedText;return jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{title:t.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:t.targetLabel}),jsx(ke,{text:$e(t.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":$e(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx(O,{name:i.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsx(O,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[jsx(kl,{}),jsx(Re,{onClick:n,title:r?"Collapse":"Expand",children:jsx(O,{name:r?"minimize":"maximize",size:13})}),jsx(yl,{})]})]})]}),s?jsx("div",{className:"rounded-xl bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:s.length>200?`${s.slice(0,199).trim()}\u2026`:s})}):null]})}function yl(){let{actions:e}=Y();return jsx(Re,{onClick:e.requestClose,title:"Close",children:jsx(O,{name:"x",size:14})})}function kl(){let{state:e,actions:t}=Y(),[r,n]=useState(false);return e.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(Re,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(O,{name:"more",size:14})}),r?jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),t.requestDeleteAnnotation();},children:[jsx(O,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function ai(){let{state:e,actions:t,meta:r}=Y(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,i=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),e.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:R("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",e.showDevFooter&&e.isResolved&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[e.annotation?jsx(oi,{name:e.annotation.authorName??"Someone",createdAt:e.annotation.createdAt,content:e.annotation.payload.comment,authorKey:e.annotation.payload.authorId??e.annotation.authorName??e.annotation.id,avatarSrc:e.annotation.authorImage,generatedSeed:e.annotation.payload.authorRole==="client"&&e.annotation.payload.authorId===i?o:e.annotation.authorAvatarSeed??e.annotation.payload.authorId??null,deliveryStatus:e.annotation.deliveryStatus,onRetry:e.annotation.deliveryStatus==="failed"?t.retryInitialMessage:void 0}):null,e.messages.map(a=>jsx(oi,{name:a.authorName??a.role,createdAt:a.createdAt,content:a.content,authorKey:a.authorId??a.authorName??a.role,avatarSrc:a.authorImage,generatedSeed:a.role==="client"&&a.authorId===i?o:a.authorAvatarSeed??a.authorId,deliveryStatus:a.deliveryStatus,canDelete:t.canDeleteMessage(a),onDelete:()=>t.requestDeleteMessage(a),onRetry:a.deliveryStatus==="failed"?()=>{t.retryMessage(a.id);}:void 0},a.id))]}):null}function oi(e){let t=Ue(e.name),r=Ge(e.authorKey),n=e.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(Ee,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:jo(e.createdAt)})]}),e.canDelete&&e.onDelete?jsx(Sl,{onDelete:e.onDelete}):null,jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?jsx("button",{type:"button",onClick:e.onRetry,className:"rounded-full bg-black/8 px-2 py-1 font-medium text-foreground transition-colors hover:bg-black/12",children:"Retry"}):null]}):null]})]})}var Al=44,Tl=8;function Sl({onDelete:e}){let[t,r]=useState(false),[n,o]=useState("down"),i=useRef(null),s=useCallback(()=>{let l=i.current,c=l?.closest("[data-patch-thread-scroller]");if(!l||!c){o("down");return}let p=l.getBoundingClientRect(),g=c.getBoundingClientRect(),u=g.bottom-p.bottom,f=p.top-g.top;o(u<Al+Tl&&f>u?"up":"down");},[]),a=useCallback(()=>{r(l=>{let c=!l;return c&&s(),c});},[s]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx(Re,{ref:i,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:a,children:jsx(O,{name:"more",size:14})}),t?jsx("div",{role:"menu",className:R("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),e();},children:[jsx(O,{name:"trash",size:13}),"Delete"]})}):null]})}var El={default:"w-full min-h-[60px] resize-y rounded-2xl border border-border bg-popover px-3 py-2 text-[13px] leading-[1.45] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",bare:"w-full resize-none self-center overflow-y-auto bg-transparent border-0 outline-none text-[13px] leading-normal text-foreground placeholder:text-muted-foreground"};function si({variant:e="default",className:t,ref:r,...n}){return jsx("textarea",{ref:r,className:R(El[e],t),...n})}var Pl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,li="w-full rounded-[10px] border border-border bg-popover px-2 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function ci(){let{actions:e}=Y(),[t,r]=useState(""),[n,o]=useState(""),[i,s]=useState(null),[a,l]=useState(false),c=useRef(null);return useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxs("form",{onSubmit:async g=>{g.preventDefault();let u=t.trim(),f=n.trim();if(!u){s("Name is required.");return}if(!Pl.test(f)){s("Enter a valid email.");return}s(null),l(true);let x=await e.setIdentity({name:u,email:f});l(false),x||s("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsx("input",{ref:c,type:"text",placeholder:"Name",value:t,onChange:g=>r(g.target.value),className:li}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:g=>o(g.target.value),className:li}),i?jsx("div",{className:"text-xs text-destructive",children:i}):null,jsx("button",{type:"submit",disabled:a,className:R("self-end rounded-[10px] bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}function ui(){let{state:e,actions:t,meta:r}=Y(),n=useRef(null),[o,i]=useState(false);if(useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),useEffect(()=>{let u=n.current;if(!u)return;u.style.height="0px";let 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 jsx("div",{className:R("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsx(ci,{})});let s=e.draftText.trim().length>0,a=r.viewer.name,l=Ue(a),c=r.viewer.kind==="studio"?"var(--color-foreground)":Ge(r.viewer.avatarKey),p=u=>{u.preventDefault(),t.submit();},g=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),t.submit());};return jsx("form",{onSubmit:p,className:R("bg-white p-3",e.threadVisible&&"border-t border-black/6",e.showDevFooter&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxs("div",{className:R("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-[18px]":"rounded-full"),children:[jsx(Ee,{initials:l,tint:c,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:a??"",className:"self-start"}),jsx(si,{ref:n,variant:"bare",value:e.draftText,onChange:u=>t.setDraftText(u.target.value),onKeyDown:g,rows:1,placeholder:e.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsx(Ol,{enabled:s})]})})}function Ol({enabled:e}){return jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:R("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsx(O,{name:"arrow-up",size:13})})}var $l=440,gi=88,Qt=16,Vl=[.22,.61,.36,1],Bl=[.4,0,.2,1],Wl={x:-8,y:-8,origin:"top left"},fi=200;function hi(e,t,r){return Math.max(t,Math.min(r,e))}function vi(e,t,r){let n={x:e.x+e.width/2,y:e.y+e.height/2},o={x:t.x+t.width/2,y:t.y+r/2};return {x:hi((n.x-o.x)*.08,-12,12),y:hi((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Yl(e,t){if(!t)return Wl;let r=it({anchor:t,popover:{width:332,height:fi},viewport:e.getOverlayViewport()});return vi(t,r,fi)}function Xl(e,t){return e.x===t.x&&e.y===t.y&&e.origin===t.origin}function xi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n=0,onToggleExpand:o,children:i}){let{actions:{attemptClose:s},meta:{shakeNonce:a}}=Y(),l=se(),c=useRef(null),[p,g]=useState(600),[u,f]=useState(()=>Yl(l,t??e())),x=useCallback(()=>{let m=c.current;if(!m||r)return;let d=e();if(!d)return;let v=m.offsetHeight||200,C=it({anchor:d,popover:{width:332,height:v},viewport:l.getOverlayViewport()});m.style.left=`${C.x}px`,m.style.top=`${C.y}px`,m.style.right="auto";let T=vi(d,C,v);f(P=>Xl(P,T)?P:T);},[e,r,l]);useLayoutEffect(()=>{r||x(),g(l.getOverlayViewport().height-Qt-gi);}),useEffect(()=>{let m=null,d=()=>{m===null&&(m=l.overlayWindow.requestAnimationFrame(()=>{m=null,r||x(),g(l.getOverlayViewport().height-Qt-gi);}));},v=new Set([l.targetWindow,l.overlayWindow]);for(let T of v)T.addEventListener("resize",d),T.addEventListener("scroll",d,{passive:true});let C=Tt(l.overlayWindow,d);return C.observe(l.overlayDocument.body),l.targetDocument.body!==l.overlayDocument.body&&C.observe(l.targetDocument.body),c.current&&C.observe(c.current),()=>{m!==null&&l.overlayWindow.cancelAnimationFrame(m);for(let T of v)T.removeEventListener("resize",d),T.removeEventListener("scroll",d);C.disconnect();}},[x,r,l]),useEffect(()=>{let m=C=>{Zo(C)||s();},d=C=>{C.key==="Escape"&&s();},v=new Set([l.targetDocument,l.overlayDocument]);for(let C of v)C.addEventListener("mousedown",m,true),C.addEventListener("keydown",d);return ()=>{for(let C of v)C.removeEventListener("mousedown",m,true),C.removeEventListener("keydown",d);}},[s,l]);let w=useRef(a);useEffect(()=>{if(a===w.current)return;w.current=a;let m=c.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[a]);let E={left:"auto",right:`${Qt}px`,top:`${Qt}px`,width:`${$l}px`,height:`${p}px`},k={width:`${332}px`,height:"auto",transformOrigin:u.origin};return jsx(motion.div,{ref:c,layout:true,initial:{opacity:0,x:u.x,y:u.y,scale:.985},animate:{opacity:1,x:0,y:0,scale:1,transition:{type:"spring",stiffness:560,damping:34,mass:.7,delay:n}},exit:{opacity:0,x:u.x,y:u.y,scale:.985,transition:{duration:.16,ease:Bl}},transition:{layout:{duration:.42,ease:Vl}},onLayoutAnimationComplete:x,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-[22px] border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:r?E:k,children:jsx(Ir.Provider,{value:{expanded:r,onToggleExpand:o},children:i})})}var J={Root:xi,Header:ti,Messages:ai,Reply:ui,DevFooter:Qo,ConfirmDiscard:qo,ConfirmDelete:Go};function wi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(J.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(J.Header,{}),jsx(J.Messages,{}),jsx(J.Reply,{}),jsx(J.ConfirmDiscard,{}),jsx(J.ConfirmDelete,{})]})}function yi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(J.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(J.Header,{}),jsx(J.Messages,{}),jsx(J.Reply,{}),jsx(J.DevFooter,{}),jsx(J.ConfirmDiscard,{}),jsx(J.ConfirmDelete,{})]})}var Jl="data-patch-internal";function Ai(e,t,r){let n={viewportX:t,viewportY:r},o=Ke(n,e.getOverlayViewport());return Yt(n,o)}function Ql(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function ec(e,t){let r=Ql(e,`[data-patch-pin-id="${t}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function tc(e,t){if(!t)return null;let r=mo({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:Jl}),n=e.targetPointToOverlay(r.position);return Ai(e,n.viewportX,n.viewportY)}function Ci(e,t,r){if(!t)return null;if(t.kind==="existing")return ec(e,t.annotationId)??tc(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return Ai(e,n.viewportX,n.viewportY)}function Ti(){let e=ge(),t=me(),r=se(),n=e.active,o=useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(x=>x.id===n.annotationId)??null,[n,t.annotations]),i=useCallback(()=>Ci(r,n,o),[n,o,r]),[s,a]=useState(false),l=e.active?e.active.kind==="existing"?e.active.annotationId:"composer":null;useEffect(()=>{a(false);},[l]);let c=t.viewerKind==="studio"?yi:wi,p=n&&(n.kind==="composer"||!!o),g=n?.kind==="composer"?.04:0,u=n?.kind==="composer"?Mo(n.target):null,f=useMemo(()=>Ci(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:p?jsx(Xo,{annotation:o,draftTargetLabel:u,children:jsx(c,{getAnchorRect:i,initialAnchorRect:f,expanded:s,entryDelay:g,onToggleExpand:()=>a(x=>!x)})},"active-popover"):null})}var nc="https://app.usepatch.dev";function Si(e){let t=typeof window<"u"&&jr(window),r=useMemo(()=>Bn({prop:e.projectToken,processEnv:Yn(),importMetaEnv:Wn()}),[e.projectToken]),n=e.apiBase??nc;return t?null:jsx(ko,{children:jsx(Zr,{children:jsx(an,{projectToken:r,apiBase:n,children:jsx(ln,{children:jsx(Vn,{children:jsxs(zn,{children:[jsx(xo,{}),jsx(Ti,{}),jsx(so,{})]})})})})})})}var oc=Si;
|
|
1888
|
+
export{Si as Patch,oc as default};
|