javascript:(async()=>{var it="MESSAGE_VISIBILITY_EXTERNAL",Ct="MESSAGE_SOURCE_AGENT",ne="MESSAGE_SOURCE_INAPPSUPPORT",re=t=>/client|rider|eater/i.test(t.userType??""),oe=t=>/driver|partner|courier/i.test(t.userType??""),se=t=>t.closureKind==="bliss-closed",ie=t=>t.closureKind!=null,ae=t=>t.messages.some(e=>e.source===ne&&e.visibility===it),le=t=>t.messages.some(e=>e.source===Ct&&e.visibility===it),ce="addPhoneMetadataV2",ue="we attempted to call you";function de(t){let e=t.messages.flatMap((r,o)=>r.actionType===ce?[o]:[]);return e.length?!e.every(r=>t.messages.slice(r+1).find(n=>n.actionType==="addMessageV1"&&n.source===Ct&&n.visibility===it)?.text.toLowerCase().includes(ue)):!1}var pe=t=>ae(t)||de(t);function Tt(t){let e=[];if(t.length){let n=t.every(se),i=t.every(ie);e.push(n?{label:"Investigation Closed",tone:"ok",title:"Every linked contact is solved in Bliss."}:i?{label:"Investigation Closed (72hrs+ elapsed)",tone:"ok",title:"Every linked contact is solved or has been closed after 72 hours without a rider response."}:{label:"Investigation Ongoing",tone:"warn",title:"At least one selected contact is not closed."})}let r=t.filter(re);if(r.length){let n=r.some(pe);e.push(n?{label:"Rider inbound made",tone:"ok",title:"The rider wrote in or a call follow-up confirms the rider was reached."}:{label:"No rider inbound",tone:"warn",title:"The rider never wrote in and no rider call was confirmed or left unclear."})}let o=t.filter(oe);if(o.length){let n=o.some(le);e.push(n?{label:"Driver outreach made",tone:"ok",title:"We sent the driver an external message or a successful call to the driver was found."}:{label:"No driver outreach",tone:"warn",title:"We never sent the driver an external message and no successful call to the driver was found."})}return e}function B(t){return t!=null&&Number.isFinite(t)&&t>0}function ge(t,e){let r=F(t),o=F(e),n=B(r),i=B(o);return n&&i&&r!==o?r-o:n!==i?n?-1:1:t.uuid.localeCompare(e.uuid)}function me(t){return[...t].sort(ge)}function at(t){return t.recipientId??`contact:${t.uuid}`}function fe(t){return t.find(e=>e.recipientName?.trim())?.recipientName?.trim()||"Unknown recipient"}function F(t){return B(t.openedAt)?t.openedAt:B(t.firstMessageAt)?t.firstMessageAt:B(t.lastMessageAt)?t.lastMessageAt:null}function vt(t){return B(t.closedAt)?t.closedAt:B(t.lastMessageAt)?t.lastMessageAt:F(t)}function he(t,e,r){return Array.from({length:5},(n,i)=>{let l=t+(e-t)*i/4;return{timestamp:l,x:r(l)}})}function wt(t){let e=me(t),r=[...new Set(e.map(at))].sort((p,b)=>p.localeCompare(b)),n=e.filter(p=>F(p)!=null).flatMap(p=>[F(p),vt(p)]),i=n.length?Math.min(...n):0,l=n.length?Math.max(...n):0,d=792,u=Math.max(l-i,1),m=p=>220+(p-i)/u*d,v=Math.max(1,Math.floor(d/18)),h=220,c=new Map,A=new Map,x=new Map(r.map(p=>[p,[]]));for(let p of e)x.get(at(p)).push(p);let T=new Map;for(let p of r){let b=[],S=0;for(let M of x.get(p)){let N=F(M),_=vt(M);if(N==null||_==null){let L=S%25v,z=b.length+Math.floor(S/v);S++,T.set(M.uuid,{x:h+L*18,endX:h+L*18+16,hasTime:!1,row:z,startAt:null,endAt:null});continue}let q=m(N),J=Math.max(q+16,m(Math.max(N,_))),P=b.findIndex(L=>L{let b=A.get(p),S=x.get(p),M={key:p,label:fe(S),y:C+28/2};return C+=Math.max(96,b*48+16),M}),w=new Map(y.map(p=>[p.key,p]));for(let p of e){let b=T.get(p.uuid),S=w.get(at(p));c.set(p.uuid,{uuid:p.uuid,x:b.x,endX:b.endX,y:S.y+b.row*48,hasTime:b.hasTime,startAt:b.startAt,endAt:b.endAt})}return{nodes:c,lanes:y,ticks:n.length?he(i,l,m):[],height:C+38,width:1040}}function Et(t,e,r){let o=(t.x+t.endX)/2,n=t.y,i=(e.x+e.endX)/2,l=e.y,d=i-o,u=l-n,m=Math.hypot(d,u)||1,v=20+r*14,h=(o+i)/2-u/m*v,c=(n+l)/2+d/m*v;return`M${o},${n} Q${h},${c} ${i},${l}`}function At(t,e){return e.map(r=>t!=null&&(r.from===t||r.to===t))}var ye=new Set(["createContactMessage","addInternalNoteV1","addMessageV1","addPhoneMetadataV2"]);function _t(t){return ye.has(t.actionType)}function kt(t){return`${t.actionType.replace(/^ACTION_TYPE_/,"").replaceAll("_"," ")||"Event"} %5CxB7 ${new Date(t.createdAt).toLocaleString()}`}function St(t,e,r){let n=(Math.max(e.x,Math.min(r.x,t))-e.x)/Math.max(r.x-e.x,1);return e.timestamp+n*(r.timestamp-e.timestamp)}function It(t,e=24){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}%5Cu2026`}var xe="__AUTO_DRAFTER_URL__";function be(t){let e=new TextEncoder().encode(t),r="";for(let o=0;o"']+/g;var Ce="https://blissnxt.uberinternal.com/hydrator/graphql";async function H(t,e,r={}){let n=await(r.fetch??globalThis.fetch)(`${Ce}?opName=${t.opName}`,{method:"POST",credentials:"include",signal:r.signal,headers:{"content-type":"application/json","x-csrf-token":"x","rpc-procedure":t.rpcProcedure,...r.headers},body:JSON.stringify({operationName:t.opName,variables:e,query:t.query})});if(!n.ok)throw new Error(`Bliss ${t.opName} HTTP ${n.status} ${n.statusText}`);let i=await n.json();if(!i.data){if(i.errors?.length){let l=i.errors.map(d=>d.message).join("; ");throw new Error(`Bliss ${t.opName} GraphQL error: ${l}`)}throw new Error(`Bliss ${t.opName} returned no data`)}return i.data}var Mt=`query getContactContext($contactId: String) {%0A hydrationGetContactContext(%0A in: {%0A contactCustomRequest: {%0A contactId: {value: $contactId}%0A filters: {action: {inclusions: {inclusions: {event: {outcomeType: {outcomeType: [ACTION_OUTCOME_TYPE_SUCCEEDED]}}}}, exclusions: {exclusions: {type: {type: ["recordAgentViewStartV1", "recordAgentViewEndV1"]}}}}}%0A includeInlineAttachmentUrl: true%0A }%0A contactNestedParams: {%0A requesterRequest: {%0A fieldsToSelectV2: {%0A fieldMask: {%0A paths: [%0A "id.uuid.value",%0A "user_info.name.first_name.value",%0A "user_info.name.last_name.value",%0A "user_info.role",%0A "user_info.signup_info.city_id.value",%0A "user_info.signup_info.country_id.value"%0A ]%0A }%0A }%0A }%0A tripRequest: {options: {includeAgora: true, includePaymentProfile: true}}%0A territoryRequest: {request: {options: {includeCountry: true}}}%0A }%0A }%0A ) {%0A contact {%0A id { value }%0A userType%0A modality%0A status%0A createdAt { value }%0A updatedAt { value }%0A cityId%0A countryId { value }%0A territory {%0A name%0A country { name }%0A }%0A requester {%0A id { uuid { value } }%0A userInfo {%0A name { firstName lastName }%0A role%0A signupInfo { cityId countryId }%0A }%0A }%0A trip {%0A uuid { value }%0A driverUuid { value }%0A clientUuid { value }%0A partnerUuid { value }%0A cityId%0A countryId%0A }%0A actions {%0A actions {%0A id { value }%0A actionType%0A arguments { arguments { name value } }%0A message {%0A source%0A visibility%0A text%0A createdAt { value }%0A }%0A }%0A }%0A }%0A }%0A}%0A`;var Y={opName:"getContactContext",rpcProcedure:"bliss_hydrator.get_contact_context.__no_postfix__",query:Mt};var Nt=`query getRelatedContacts($contactId: String!, $tenancy: String!) {%0A hydrationGetContactContext(%0A in: {contactCustomRequest: {contactId: {value: $contactId}}, contactDownstreamHeaders: {entries: [{key: "x-uber-tenancy", value: $tenancy}]}}%0A ) {%0A relatedContacts {%0A isSafetyContact%0A relatedContacts {%0A contactId%0A isContactOfRecord%0A }%0A }%0A }%0A}%0A`;var ct={opName:"getRelatedContacts",rpcProcedure:"bliss_hydrator.get_related_contacts.__no_postfix__",query:Nt};var Rt=`query getUserContext($requesterID: String!) {%0A hydrationGetUserContext(%0A in: {%0A userCustomRequest: {%0A criteria: {userId: {uuid: {value: $requesterID}}}%0A fieldsToSelectV2: {%0A fieldMask: {%0A paths: [%0A "user_info.name.first_name.value",%0A "user_info.name.last_name.value",%0A "user_info.role",%0A "user_info.user_types",%0A "user_info.signup_info.city_id.value",%0A "user_info.signup_info.country_id.value",%0A "user_info.signup_info.country_iso2_code.value",%0A "extensions[driver].proto.onboarding.city_id",%0A "extensions[driver].proto.onboarding.driver_business_city_id",%0A "extensions[driver].proto.onboarding.current_status",%0A "extensions[driver].proto.onboarding.flow_type"%0A ]%0A }%0A }%0A }%0A }%0A ) {%0A user {%0A id { uuid { value } }%0A userInfo {%0A name { firstName lastName }%0A role%0A signupInfo {%0A cityId%0A countryId%0A countryIso2Code%0A territory {%0A name%0A slug%0A country { name }%0A }%0A }%0A userTypes%0A }%0A driverInfo {%0A onboarding {%0A driverBusinessCityId%0A cityId%0A currentStatus%0A flowType%0A territory {%0A name%0A country { name }%0A }%0A }%0A }%0A }%0A }%0A}%0A`;var ut={opName:"getUserContext",rpcProcedure:"bliss_hydrator.get_user_context.__no_postfix__",query:Rt};var Dt=45e3,dt=8,pt=120,Ee=new Set(["recordAgentViewStartV1","recordAgentViewEndV1"]),X=null;function I(t,...e){Ie(t)}function Ae(){I("Reading Bliss auth info...");let t=document.getElementById("__AUTH_INFO__");if(!t?.content)throw new Error("Could not find __AUTH_INFO__ meta tag on the page");let e=JSON.parse(`"${t.content.replace(/"/g,'%5C%5C"')}"`),r=JSON.parse(e),o=r.uuid,n=r.agentInfo?.agentId;if(!o)throw new Error("uuid missing from __AUTH_INFO__");if(!n)throw new Error("agentInfo.agentId missing from __AUTH_INFO__");return I("Found Bliss auth info",{uuidPrefix:o.slice(0,8),agentId:n}),{uuid:o,agentId:n}}function _e(){let e=[...(new URL(location.href).searchParams.get("tabs")??"").matchAll(j)].map(r=>r[1].toLowerCase());return I("Read contact tabs from Bliss URL",e),e}function ke(t){return`https://blissnxt.uberinternal.com/tabs?tabs=${t.map(r=>`contact:${r}`).join(",")}`}function Se(){if(X&&document.body.contains(X))return X;let t=document.createElement("div");return t.id="launch-autodrafter-overlay",t.style.cssText=["position:fixed","top:12px","right:12px","z-index:2147483647","background:%23111827","color:%23fff","font-family:system-ui,sans-serif","font-size:12px","padding:8px 12px","border-radius:6px","box-shadow:0 4px 12px rgba(0,0,0,0.3)","max-width:340px","line-height:1.4"].join(";"),document.body.appendChild(t),X=t,t}function Ie(t){Se().textContent=t}function Ut(){X?.remove(),X=null}function Lt(t,e){let r=new AbortController,o=setTimeout(()=>r.abort(),Dt);return t(r.signal).catch(n=>{throw n instanceof DOMException&&n.name==="AbortError"?new Error(`${e} timed out after ${Dt}ms`):n}).finally(()=>clearTimeout(o))}async function Ge(t){return I(`Fetching contact ${t.slice(0,8)}...`,{contactId:t}),Lt(e=>H(Y,{contactId:t},{signal:e}),`getContactContext(${t})`)}async function Me(t){return I(`Fetching user ${t.slice(0,8)}...`,{requesterID:t}),Lt(e=>H(ut,{requesterID:t},{signal:e}),`getUserContext(${t})`)}function Ne(t){return[t?.firstName,t?.lastName].filter(Boolean).join(" ")||null}function et(t){let e=t.hydrationGetContactContext?.contact;if(!e)throw new Error("GraphQL response did not include contact data");return e}function Re(t){let r=et(t).requester,o=r?.userInfo?.name;return{id:r?.id?.uuid?.value??null,name:Ne(o),firstName:o?.firstName??null,lastName:o?.lastName??null}}function De(t){return et(t).userType??null}function Ue(t){let e=et(t).trip;return e?{uuid:e.uuid?.value??null,driverUuid:e.driverUuid?.value??null,clientUuid:e.clientUuid?.value??null,partnerUuid:e.partnerUuid?.value??null,cityId:e.cityId??null,countryId:e.countryId??null}:null}function Le(t){return(et(t).actions?.actions??[]).filter(o=>!Ee.has(o.actionType??"")).map(o=>{let n=o.message,i={};for(let l of o.arguments?.arguments??[])i[l.name]=l.value;return{text:n?.text??"",createdAt:new Date(n?.createdAt?.value??0),source:n?.source??"",visibility:n?.visibility??"",actionType:o.actionType??"",arguments:i}}).sort((o,n)=>o.createdAt.getTime()-n.createdAt.getTime())}function $e(t){let e=new Set;for(let r of t)for(let o of r.text.match(tt)??[])for(let[,n]of o.matchAll(j))e.add(n.toLowerCase());return[...e]}function Oe(t){return!t||t.name==null&&t.country?.name==null?null:{name:t.name??null,country:t.country?.name??null}}function Pe(t,e){let o=e.hydrationGetUserContext?.user?.driverInfo?.onboarding;return{uuid:t,driverTerritory:Oe(o?.territory),driverCityId:o?.driverBusinessCityId??o?.cityId??null}}async function Be(t){let e=await Promise.allSettled(t.map(Ge)),r=[],o=[];for(let n=0;nc.createdAt.getTime()),u=$e(l),m=Re(i.value),v=De(i.value),h=Ue(i.value);I(`Parsed contact ${t[n].slice(0,8)}`,{uuid:t[n],messages:l.length,mentionedUuids:u,requester:m,userType:v,tripDriverUuid:h?.driverUuid??null}),r.push({uuid:t[n],messages:l,firstAt:d.length?Math.min(...d):1/0,mentionedUuids:u,requester:m,userType:v,trip:h})}return{results:r,errors:o}}async function He(t){let e=await Promise.allSettled(t.map(Me)),r=[],o=[];for(let n=0;n&view=0 first.`),null;let e=new Map,r=new Map,o=[],n=[...new Set(t)],i=0;for(;n.length;){if(i++,i>dt){o.push(...n.map(C=>({uuid:C,reason:`Stopped at max sweep depth ${dt}`}))),I("Stopped recursive fetch at max depth",{maxDepth:dt,skipped:n});break}I(i===1?`Fetching ${n.length} tab contact(s)...`:`Depth ${i}: fetching ${n.length} linked contact(s)...`,{pending:n,depth:i});let{results:c,errors:A}=await Be(n);o.push(...A);for(let C of c)e.set(C.uuid,C),r.set(C.uuid,C.mentionedUuids);let x=new Set(e.keys()),T=new Set;n=c.flatMap(C=>C.mentionedUuids.filter(y=>x.has(y)||T.has(y)||e.size+T.size>=pt?!1:(T.add(y),!0))),e.size>=pt&&(I("Stopped recursive fetch at max contact count",{maxContacts:pt,fetched:e.size}),n=[]),I(`Depth ${i} complete`,{totalFetched:e.size,nextPending:n,errors:o.length})}let l=Ve(e.values());I(`Hydrating ${l.length} unique person(s)...`,{personUuids:l});let{users:d,errors:u}=l.length?await He(l):{users:[],errors:[]};o.push(...u);let m=[...e.values()].sort((c,A)=>c.firstAt-A.firstAt),v=m.map(c=>c.uuid),h={sortedUuids:v,combinedUrl:ke(v),contacts:Object.fromEntries(m.map(c=>[c.uuid,{uuid:c.uuid,firstAt:c.firstAt===1/0?null:c.firstAt,messages:c.messages,requester:c.requester,userType:c.userType,trip:c.trip}])),users:Object.fromEntries(d.map(c=>[c.uuid,c])),errors:o.map(c=>({uuid:c.uuid,reason:c.reason instanceof Error?c.reason.message:String(c.reason)}))};return I("Sweep complete",{contacts:v.length,users:Object.keys(h.users).length,messages:Object.values(h.contacts).reduce((c,A)=>c+A.messages.length,0),errors:h.errors,payloadBytes:JSON.stringify(h).length}),h}var Ot="blissnxt.uberinternal.com";function qe(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"&%2339;")}function ze(t){t.document.open(),t.document.write(`%0A%0A %0A Launch Auto Drafter%0A %0A %0A
%0A

Preparing Auto Drafter

%0A

Gathering the selected Bliss contacts. This tab will open Auto Drafter automatically.

%0A
%0A %0A`),t.document.close()}function Fe(t,e){t.document.open(),t.document.write(`%0A%0A %0A Auto Drafter needs attention%0A %0A %0A
%0A

Auto Drafter could not start

%0A

${qe(e)}

%0A
%0A %0A`),t.document.close()}async function Pt(){if(location.hostname!==Ot){alert(`Launch Auto Drafter must be clicked from a Bliss page on ${Ot}.`);return}let t=`launch-autodrafter-${Date.now()}`,e=window.open("about:blank",t);e&&ze(e);try{let r=await $t();r&&(Gt(r,e?t:"_blank",e),window.location.href=r.combinedUrl)}catch(r){let o=r instanceof Error?r.message:String(r);e&&!e.closed&&Fe(e,o),Ut(),alert(`Auto Drafter failed: ${o}`)}}function Bt(t,e){return t.reduce((r,o,n)=>r+o+(e[n]??""),"").replace(/>%5Cs+<").replace(/%5Cs+/g," ").trim()}var gt=(t,...e)=>Bt(t,e),V=(t,...e)=>Bt(t,e);var Xe="http://www.w3.org/2000/svg",K=28,Ke=7,Ht=3,We=5,je=11,Vt=["%232563eb","%23dc2626","%2316a34a","%23d97706","%237c3aed","%230891b2","%23db2777","%2365a30d","%23ea580c","%234f46e5","%230d9488","%23b45309"],mt="%2394a3b8",Ye={starting:"Starting point",primary:"Primary mention",secondary:"Secondary mention",deeper:"Deeper mention"},nt={mention:"%23475569",related:"%23f97316"};function qt(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"&%2339;")}function E(t,e){let r=document.createElementNS(Xe,t);for(let o in e)r.setAttribute(o,String(e[o]));return r}function Je(t){if(t.recipientName){let e=t.recipientName.trim().split(/%5Cs+/);return(e[0][0]+(e[1]?.[0]??"")).toUpperCase()}return t.uuid.slice(0,2).toUpperCase()}function ft(t){return t.recipientId??`contact:${t.uuid}`}function Qe(t){let e=new Map,r=0;for(let o of t){let n=ft(o);e.has(n)||e.set(n,o.recipientId?Vt[r++%25Vt.length]:mt)}return e}function zt(t,e=1){return`https://blissnxt.uberinternal.com/tabs?tabs=${t.map(o=>`contact:${o}`).join(",")}&view=${e}`}function Ze(t,e,r){document.getElementById("bg-context-menu")?.remove();let o=document.createElement("div");o.id="bg-context-menu",o.style.cssText=V` position: fixed; z-index: 2147483647; background: %23fff; border: 1px solid %23e2e8f0; border-radius: 8px; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25); padding: 4px; min-width: 210px; font-family: system-ui, sans-serif; `;for(let u of r){let m=document.createElement("button");m.textContent=u.label,m.style.cssText=V` display: block; width: 100%25; text-align: left; border: none; background: none; padding: 8px 12px; font-size: 13px; color: %230f172a; cursor: pointer; border-radius: 6px; `,m.addEventListener("mouseenter",()=>m.style.background="%23f1f5f9"),m.addEventListener("mouseleave",()=>m.style.background="none"),m.addEventListener("click",()=>{o.remove(),u.onClick()}),o.appendChild(m)}document.body.appendChild(o);let n=o.getBoundingClientRect(),i=Math.min(t,window.innerWidth-n.width-8),l=Math.min(e,window.innerHeight-n.height-8);o.style.left=`${Math.max(8,i)}px`,o.style.top=`${Math.max(8,l)}px`;let d=u=>{o.contains(u.target)||(o.remove(),document.removeEventListener("mousedown",d))};setTimeout(()=>document.addEventListener("mousedown",d),0)}function tn(t){let e=Tt(t);return e.length?e.map(r=>{let o=r.tone==="ok"?"background:%23dcfce7;color:%23166534;border:1px solid %23bbf7d0":"background:%23fef2f2;color:%23991b1b;border:1px solid %23fecaca";return gt` ${qt(r.label)} `}).join(""):'No rider or driver contacts selected.'}function Ft(t){document.getElementById("bliss-graph-overlay")?.remove(),document.getElementById("bliss-graph-restore")?.remove();let{contacts:e,edges:r}=t,o=Qe(e),n=wt(e),i=n.nodes,l=new Set(e.filter(s=>s.source.kind!=="secondary").map(s=>s.uuid)),d=document.createElement("div");d.id="bliss-graph-overlay",d.style.cssText=V` position: fixed; inset: 0; z-index: 2147483647; background: rgba(15, 23, 42, 0.55); display: flex; align-items: center; justify-content: center; font-family: system-ui, sans-serif; `,d.innerHTML=gt` `,document.body.appendChild(d);let u=E("svg",{viewBox:`0 0 ${n.width} ${n.height}`,width:String(n.width),style:"display:block"});u.setAttribute("height",String(n.height));let m=E("defs",{});for(let s of["mention","related"]){let a=E("marker",{id:`bg-arrow-${s}`,viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse"});a.appendChild(E("path",{d:"M0,0 L10,5 L0,10 z",fill:nt[s]})),m.appendChild(a)}u.appendChild(m);for(let s of n.lanes){u.appendChild(E("line",{x1:0,x2:n.width,y1:s.y,y2:s.y,stroke:"%23e2e8f0","stroke-width":"1"}));let a=o.get(s.key)??mt,f=E("g",{class:"bg-recipient","data-recipient-key":s.key,role:"button",tabindex:"0","aria-label":`Toggle ${s.label}'s contacts`,style:"cursor:pointer;user-select:none"}),g=E("rect",{x:8,y:s.y-16,width:200,height:32,rx:8,fill:"%23fff",stroke:"%23e2e8f0"});f.appendChild(g),f.appendChild(E("circle",{cx:23,cy:s.y,r:6,fill:a}));let k=E("text",{x:36,y:s.y+4,"font-size":"12","font-weight":"700",fill:"%23475569"});k.textContent=It(s.label),f.appendChild(k);let G=E("title",{});G.textContent=`Toggle ${s.label}'s contacts`,f.appendChild(G),u.appendChild(f)}for(let s of n.ticks){u.appendChild(E("line",{x1:s.x,x2:s.x,y1:26,y2:n.height-18,stroke:"%23cbd5e1","stroke-width":"1","stroke-dasharray":"3 4"}));let a=E("text",{x:s.x,y:18,"text-anchor":"middle","font-size":"10",fill:"%2364748b"});a.textContent=new Date(s.timestamp).toLocaleString(),u.appendChild(a)}let v=n.ticks[0],h=n.ticks[n.ticks.length-1],c=E("g",{style:"display:none;pointer-events:none","aria-hidden":"true"}),A=E("line",{y1:26,y2:n.height-18,stroke:"%230f172a","stroke-width":"1.5","stroke-dasharray":"4 3"}),x=E("rect",{y:27,width:144,height:20,rx:5,fill:"%230f172a"}),T=E("text",{y:41,"text-anchor":"middle","font-size":"10","font-weight":"700",fill:"%23fff"});c.append(A,x,T);let C=new Map,y=null,w=r.map(s=>{let a=i.get(s.from),f=i.get(s.to);if(!a||!f)return null;let g=`${s.from}>${s.to}`,k=C.get(g)??0;C.set(g,k+1);let G=Et(a,f,k),R=E("path",{d:G,fill:"none",stroke:nt[s.kind],"stroke-width":"4","marker-end":`url(%23bg-arrow-${s.kind})`,...s.mentionRole==="secondary"?{"stroke-dasharray":"8 5"}:{}});if(s.note){let O=E("title",{});O.textContent=s.note,R.appendChild(O)}return R.setAttribute("pointer-events","none"),{el:R,edge:s}}).filter(s=>s!=null),p=new Map;for(let s of e){let a=i.get(s.uuid),f=o.get(ft(s))??mt,g=E("g",{style:"cursor:pointer"}),k=E("title",{}),G=a.hasTime?`${s.openedAt?`Opened: ${new Date(s.openedAt).toLocaleString()}%0A`:""}${s.closedAt?`Closed: ${new Date(s.closedAt).toLocaleString()}`:s.lastMessageAt?`Last event: ${new Date(s.lastMessageAt).toLocaleString()}`:""}`:"No valid timeline timestamps";k.textContent=`${Ye[s.source.kind]}${s.source.kind==="deeper"?` %5CxB7 level ${s.source.level}`:""}%0A${s.recipientName??"Unknown"} %5CxB7 ${s.userType??"?"}%0A${G}%0A${s.uuid}`,g.appendChild(k);let R=E("rect",{x:a.x,y:a.y-K/2,width:a.endX-a.x,height:K,rx:Ke,fill:f,stroke:s.source.kind==="starting"?"%23ca8a04":"%230f172a","stroke-width":s.source.kind==="starting"?"3":"2"}),O=E("text",{x:a.x+7,y:a.y+4,"font-size":"11","font-weight":"700",fill:"%23fff",style:"pointer-events:none;user-select:none"});O.textContent=Je(s),g.appendChild(R);for(let D of s.messages){if(!_t(D)||!Number.isFinite(D.createdAt)||D.createdAt<=0||!a.hasTime||a.startAt==null||a.endAt==null)continue;let Q=Math.max(a.x+3,Math.min(a.endX-3,a.x+(D.createdAt-a.startAt)/Math.max(a.endAt-a.startAt,1)*(a.endX-a.x))),Z=E("line",{x1:Q,x2:Q,y1:a.y-K/2+3,y2:a.y+K/2-3,stroke:"transparent","stroke-width":je,"stroke-linecap":"round",style:"cursor:help"}),W=E("line",{x1:Q,x2:Q,y1:a.y-K/2+3,y2:a.y+K/2-3,stroke:"%23fff","stroke-width":Ht,"stroke-linecap":"round",style:"pointer-events:none;transition:stroke .12s ease,stroke-width .12s ease"}),bt=E("title",{});bt.textContent=kt(D),Z.appendChild(bt),Z.addEventListener("pointerenter",()=>{W.setAttribute("stroke","%23facc15"),W.setAttribute("stroke-width",String(We))}),Z.addEventListener("pointerleave",()=>{W.setAttribute("stroke","%23fff"),W.setAttribute("stroke-width",String(Ht))}),g.append(Z,W)}g.appendChild(O),g.addEventListener("pointerenter",()=>{y=s.uuid,_()}),g.addEventListener("pointerleave",()=>{y===s.uuid&&(y=null,_())}),g.addEventListener("focusin",()=>{y=s.uuid,_()}),g.addEventListener("focusout",()=>{y===s.uuid&&(y=null,_())}),g.addEventListener("click",()=>q(s.uuid)),g.addEventListener("contextmenu",D=>{D.preventDefault(),Ze(D.clientX,D.clientY,[{label:l.has(s.uuid)?"De-select contact":"Select contact",onClick:()=>q(s.uuid)},{label:"Open contact in new tab",onClick:()=>J(s.uuid)}])}),u.appendChild(g),p.set(s.uuid,{bar:R,label:O})}for(let{el:s}of w)u.appendChild(s);u.appendChild(c),v&&h&&(u.addEventListener("pointermove",s=>{let a=u.getScreenCTM();if(!a)return;let f=new DOMPoint(s.clientX,s.clientY).matrixTransform(a.inverse()),g=Math.max(v.x,Math.min(h.x,f.x)),k=St(g,v,h),G=Math.max(72,Math.min(n.width-72,g));c.style.display="block",A.setAttribute("x1",String(g)),A.setAttribute("x2",String(g)),x.setAttribute("x",String(G-72)),T.setAttribute("x",String(G)),T.textContent=new Date(k).toLocaleString()}),u.addEventListener("pointerleave",()=>{c.style.display="none"})),d.querySelector("%23bg-graph").appendChild(u);let b=d.querySelector("%23bg-link"),S=d.querySelector("%23bg-badges"),M=[...u.querySelectorAll(".bg-recipient")];function N(s){return e.filter(a=>ft(a)===s).map(a=>a.uuid)}function _(){let s=e.filter(f=>l.has(f.uuid)).map(f=>f.uuid);s.length?(b.href=zt(s),b.textContent=`Open ${s.length}-in-1 Bliss`,b.style.pointerEvents="auto",b.style.opacity="1"):(b.removeAttribute("href"),b.textContent="Select at least one contact",b.style.pointerEvents="none",b.style.opacity="0.5"),S.innerHTML=tn(e.filter(f=>l.has(f.uuid)));for(let[f,g]of p){let k=l.has(f);g.bar.setAttribute("opacity",k?"1":"0.25"),g.bar.setAttribute("stroke-dasharray",k?"0":"4 3"),g.label.setAttribute("opacity",k?"1":"0.4")}let a=At(y,w.map(({edge:f})=>f));for(let[{el:f},g]of w.map((k,G)=>[k,a[G]]))f.setAttribute("opacity",g?"1":"0");for(let f of M){let g=f.dataset.recipientKey??"",k=N(g),G=k.filter(O=>l.has(O)).length,R=G===0?"false":G===k.length?"true":"mixed";f.setAttribute("aria-pressed",R),f.style.opacity=R==="false"?"0.4":R==="mixed"?"0.7":"1"}}function q(s){l.has(s)?l.delete(s):l.add(s),_()}function J(s){let a=e.filter(g=>l.has(g.uuid)||g.uuid===s).map(g=>g.uuid),f=Math.max(0,a.indexOf(s));window.open(zt(a,f),"_blank")}function P(s){let a=N(s.dataset.recipientKey??""),f=a.some(g=>l.has(g));for(let g of a)f?l.delete(g):l.add(g);_()}for(let s of M)s.addEventListener("click",()=>P(s)),s.addEventListener("keydown",a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),P(s))});let L=d.querySelector("%23bg-dialog"),z=d.querySelector("%23bg-hide"),$=document.createElement("button");$.id="bliss-graph-restore",$.textContent="Show contact graph",$.style.cssText=V` position: fixed; bottom: 16px; right: 16px; z-index: 2147483647; display: none; cursor: pointer; border: none; background: %230f172a; color: %23fff; border-radius: 999px; padding: 10px 16px; font-family: system-ui, sans-serif; font-size: 13px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35); `;let ot=z;function te(){return[...L.querySelectorAll('a[href],button:not([disabled]),[tabindex]:not([tabindex="-1"])')]}function st(){L.contains(document.activeElement)&&(ot=document.activeElement),d.style.display="none",$.style.display="block",$.focus()}function ee(){d.style.display="flex",$.style.display="none",(ot.isConnected?ot:z).focus()}$.addEventListener("click",ee),document.body.appendChild($),z.addEventListener("click",st),d.querySelector("%23bg-autodrafter").addEventListener("click",()=>{Pt()}),d.addEventListener("click",s=>{s.target===d&&st()}),d.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),st();return}if(s.key!=="Tab")return;let a=te();if(!a.length){s.preventDefault(),L.focus();return}let f=a[0],g=a[a.length-1];s.shiftKey&&document.activeElement===f?(s.preventDefault(),g.focus()):!s.shiftKey&&document.activeElement===g&&(s.preventDefault(),f.focus())}),_(),z.focus()}var Xt=45e3,Kt=8,ht=120,en="uber/production",Wt=4320*60*1e3,nn="MESSAGE_VISIBILITY_EXTERNAL",rn="MESSAGE_SOURCE_AGENT",on="addPhoneMetadataV2";function Yt(t,e){let r=new AbortController,o=setTimeout(()=>r.abort(),Xt);return t(r.signal).catch(n=>{throw n instanceof DOMException&&n.name==="AbortError"?new Error(`${e} timed out after ${Xt}ms`):n}).finally(()=>clearTimeout(o))}function Jt(t){return[...t.matchAll(j)].map(e=>e[1].toLowerCase())}function sn(){let t=new URL(location.href).searchParams.get("tabs")??"";return Jt(t)}function an(t){let e;try{e=new URL(t.replace(/&/g,"&"))}catch{return[]}if(e.hostname.toLowerCase()!=="blissnxt.uberinternal.com")return[];let r=Jt(e.searchParams.get("tabs")??""),o=e.searchParams.get("view"),n=o==null?0:Number(o),i=Number.isInteger(n)&&n>=0&&n({uuid:d,source:u}))}var rt={starting:0,primary:1,deeper:2,secondary:3};function yt(t,e){return!t||rt[e.kind]rt[t.kind]?t:e.level280?`${r.slice(0,279)}%5Cu2026`:r}function dn(t){return/client|rider|eater/i.test(t??"")}function pn(t){return t.source===rn&&t.visibility===nn||t.actionType===on}function gn(t,e,r,o){let n=r.at(-1);return/solved|closed|resolved|archived/i.test(t??"")?{kind:"bliss-closed",closedAt:n&&Number.isFinite(n.createdAt)&&n.createdAt>0?n.createdAt:null}:dn(e)&&n&&Number.isFinite(n.createdAt)&&n.createdAt>0&&pn(n)&&o-n.createdAt>=Wt?{kind:"bliss-closed-72hrs",closedAt:n.createdAt+Wt}:{kind:null,closedAt:null}}function mn(t,e,r){let o=cn(r),i=(o.actions?.actions??[]).map(h=>{let c=h.message,A=new Date(c?.createdAt?.value??0).getTime();return{text:c?.text??"",createdAt:A,source:c?.source??"",visibility:c?.visibility??"",actionType:h.actionType??""}});i.sort((h,c)=>h.createdAt-c.createdAt);let l=new Map;for(let h of i)for(let c of h.text.match(tt)??[])for(let A of an(c))A.uuid!==t&&!l.has(A.uuid)&&l.set(A.uuid,{...A,note:un(h.text)});let d=o.requester,u=i.map(h=>h.createdAt).filter(h=>Number.isFinite(h)&&h>0),m=new Date(o.createdAt?.value??"").getTime(),v=gn(o.status,o.userType,i,Date.now());return{contact:{uuid:t,source:e,recipientId:d?.id?.uuid?.value??null,recipientName:ln(d?.userInfo?.name),userType:o.userType??null,modality:o.modality??null,status:o.status??null,messages:i,openedAt:Number.isFinite(m)&&m>0?m:null,firstMessageAt:u.length?Math.min(...u):null,lastMessageAt:u.length?Math.max(...u):null,closureKind:v.kind,closedAt:v.closedAt},firstAt:u.length?Math.min(...u):1/0,mentions:[...l.values()]}}async function fn(t,e){return((await Yt(n=>H(ct,{contactId:t,tenancy:e},{signal:n}),`getRelatedContacts(${t})`)).hydrationGetContactContext?.relatedContacts?.relatedContacts??[]).map(n=>n.contactId?.toLowerCase()).filter(n=>!!n&&n!==t)}async function hn(t){return Yt(e=>H(Y,{contactId:t},{signal:e}),`getContactContext(${t})`)}async function Qt(t=()=>{}){let e=[...new Set(sn())];if(!e.length)return alert(`Bliss Graph: no contact tabs found in the current URL.%0AOpen a Bliss page like /tabs?tabs=contact: first.`),null;let r=[],o=new Set,n=[],i=(x,T,C,y,w)=>{if(x===T)return;let p=`${x}|${T}|${C}`;o.has(p)||(o.add(p),n.push({from:x,to:T,kind:C,...y?{note:y}:{},...w?{mentionRole:w}:{}}))};t(`Finding related contacts for ${e.length} tab(s)...`);let l=await Promise.allSettled(e.map(x=>fn(x,en))),d=new Map(e.map(x=>[x,{kind:"starting",level:0}]));l.forEach((x,T)=>{if(x.status==="rejected"){r.push({uuid:e[T],reason:xt(x.reason)});return}for(let C of x.value)!d.has(C)&&d.size>=ht||(i(e[T],C,"related"),d.set(C,yt(d.get(C),{kind:"deeper",level:1})))});let u=new Map,m=[...d.entries()].map(([x,T])=>({uuid:x,source:T})),v=0;for(;m.length;){if(v++,v>Kt){r.push(...m.map(({uuid:y})=>({uuid:y,reason:`Stopped at max sweep depth ${Kt}`})));break}t(v===1?`Fetching ${m.length} contact(s)...`:`Depth ${v}: fetching ${m.length} linked contact(s)...`);let x=await Promise.allSettled(m.map(({uuid:y})=>hn(y))),T=[];x.forEach((y,w)=>{let{uuid:p,source:b}=m[w];if(y.status==="rejected"){r.push({uuid:p,reason:xt(y.reason)});return}try{let S=mn(p,b,y.value);u.set(p,S),T.push(S)}catch(S){r.push({uuid:p,reason:xt(S)})}});let C=new Map;for(let y of T)if(jt(y.contact.source))for(let w of y.mentions){i(y.contact.uuid,w.uuid,"mention",w.note,w.source);let p=w.source==="secondary"?{kind:"secondary",level:y.contact.source.level+1}:y.contact.source.kind==="starting"?{kind:"primary",level:1}:{kind:"deeper",level:y.contact.source.level+1},b=u.get(w.uuid),S=T.find(_=>_.contact.uuid===w.uuid);if(b){let _=yt(b.contact.source,p);_!==b.contact.source&&(b.contact.source=_,S&&(S.contact.source=_),jt(_)&&C.set(w.uuid,_));continue}let M=C.get(w.uuid)??d.get(w.uuid),N=M?yt(M,p):p;!C.has(w.uuid)&&u.size+C.size>=ht||(d.set(w.uuid,N),C.set(w.uuid,N))}m=[...C.entries()].map(([y,w])=>({uuid:y,source:w})),u.size>=ht&&(m=[])}let h=[...u.values()].sort((x,T)=>x.firstAt-T.firstAt).map(x=>x.contact),c=new Set(h.map(x=>x.uuid)),A=n.filter(x=>c.has(x.from)&&c.has(x.to));return t(`Sweep complete: ${h.length} contact(s).`),{contacts:h,edges:A,errors:r}}var Zt="blissnxt.uberinternal.com",U=null;function yn(t){U||(U=document.createElement("div"),U.style.cssText=V` position: fixed; top: 12px; right: 12px; z-index: 2147483647; background: %23111827; color: %23fff; font-family: system-ui, sans-serif; font-size: 12px; padding: 8px 12px; border-radius: 6px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); max-width: 340px; line-height: 1.4; `,document.body.appendChild(U)),U.textContent=t}async function xn(){if(location.hostname!==Zt){alert(`Bliss Graph must be clicked from a Bliss page on ${Zt}.`);return}let t=await Qt(yn);U?.remove(),U=null,t&&Ft(t)}xn().catch(t=>{U?.remove(),U=null;let e=t instanceof Error?t.message:String(t);alert(`Bliss Graph failed: ${e}`)});})()