PageSourceSearch

https://thetool.company/_next/static/chunks/06l7h7ognjmtl.js

js thetool.company collected 2026-10-02 01:53:05 UTC 26,730 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,712686,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(373375),a=e.i(664659),r=e.i(643531),i=e.i(329006),l=e.i(788699),o=e.i(341256),d=e.i(844700),u=e.i(167881),c=e.i(647163),m=e.i(340024),p=e.i(245092),h=e.i(194976),g=e.i(419829),x=e.i(59377),f=e.i(728231),b=e.i(456174),v=e.i(414318),w=e.i(800126),y=e.i(444256),j=e.i(158061),T=e.i(572377),N=e.i(969878),S=e.i(138108),_=e.i(564138),C=e.i(713152),k=e.i(264648),E=e.i(809868),M=e.i(197031),P=e.i(904889),R=e.i(343820),I=e.i(357440),O=e.i(920755),D=e.i(923508),B=e.i(724057),L=e.i(369680);let U=new Map,A=new Map;function $({peer:e,conversationId:t,channel:s}){return`${e}|${t??""}|${s??""}`}function G(e){return U.get(e)?.data??null}var H=e.i(464430),F=e.i(869407),V=e.i(625458),q=e.i(602944),z=e.i(201),J=e.i(861782),K=e.i(691551),W=e.i(515168),Q=e.i(771060),Y=e.i(534344);function X(e){return"imessage"!==(e??"").toLowerCase()}function Z(e){return e?e.friendly_name?.trim()||function(e){if(!e)return null;let t=e.replace(/[^\d+]/g,""),s=/^\+1(\d{3})(\d{3})(\d{4})$/.exec(t);return s?`+1 ${s[1]} ${s[2]} ${s[3]}`:e}(e.phone_number):null}let ee=[{value:"auto",label:"Automatic",hint:"iMessage when we can, text when we cannot"},{value:"imessage",label:"iMessage",hint:"Blue, sent through your Mac"},{value:"mac_text",label:"Text from my iPhone",hint:"Green, from your personal number"},{value:"twilio",label:"Text from the workspace number",hint:"Green, shared and logged for the team"}];function et({capability:e,preferred:n,options:a,onPick:i,saving:l,pinnable:o,children:d}){let[u,m]=(0,s.useState)(!1);return(0,t.jsxs)(x.Popover,{open:u,onOpenChange:m,children:[(0,t.jsx)(x.PopoverTrigger,{asChild:!0,children:d}),(0,t.jsxs)(x.PopoverContent,{align:"start",side:"top",className:"w-[280px] p-1",children:[a.map(e=>{let s=n===e.value;return(0,t.jsxs)("button",{type:"button",disabled:e.disabled||l||!o,onClick:()=>{e.disabled||(i(e.value),m(!1))},className:(0,c.cn)("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors duration-150",e.disabled?"cursor-not-allowed opacity-50":"hover:bg-muted"),children:[(0,t.jsx)("span",{className:"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:s&&(0,t.jsx)(r.Check,{className:"h-3.5 w-3.5 text-foreground"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-[13px] leading-snug text-foreground",children:e.label}),(0,t.jsx)("span",{className:"block text-[11px] leading-snug text-muted-foreground",children:e.disabled?e.reason:e.hint})]})]},e.value)}),!o&&(0,t.jsx)("p",{className:"border-t border-border px-2 pb-1 pt-1.5 text-[11px] leading-snug text-muted-foreground",children:"Send one message first, then you can pin this thread to a route."}),e?.reason&&(0,t.jsx)("p",{className:"border-t border-border px-2 pb-1 pt-1.5 text-[11px] leading-snug text-muted-foreground",children:e.reason})]})]})}function es({routeLabel:e,className:s,...n}){let r=(n.capability?.transport??"auto")==="imessage",i=r&&!n.capability?.warnings?.length;return(0,t.jsxs)("div",{className:(0,c.cn)("flex min-w-0 items-center gap-1",s),children:[(0,t.jsx)(f.TooltipProvider,{children:(0,t.jsxs)(f.Tooltip,{children:[(0,t.jsx)(f.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:r?F.BLUE:F.GREEN}}),!i&&(0,t.jsx)("span",{className:"truncate",children:e})]})}),(0,t.jsx)(f.TooltipContent,{side:"top",children:n.capability?.reason||e})]})}),(0,t.jsx)(et,{...n,children:(0,t.jsx)("button",{type:"button","aria-label":"Change how this thread sends",className:"shrink-0 rounded-full p-0.5 text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground",children:(0,t.jsx)(a.ChevronDown,{className:"h-3 w-3"})})})]})}function en({routeLabel:e,route:s,...n}){return(0,t.jsx)(et,{...n,children:(0,t.jsx)("button",{type:"button","aria-label":"Change how this thread sends",title:e,className:"flex h-7 w-7 items-center justify-center rounded-lg [corner-shape:squircle] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:(0,t.jsx)("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:"imessage"===s?F.BLUE:F.GREEN}})})})}function ea({msg:e,contactName:n,isGroup:a,canSendTapbacks:r,canEditUnsend:d,reactions:u,onReact:m,onReply:p,onEdit:h,onUnsend:g,viaLabel:x,isLastOutbound:f,isRunEnd:b,replyRun:v}){let w=e.is_outbound,y=X(e.transport),j="sending"===e.delivery,T="failed"===e.delivery,[N,M]=(0,s.use
1State)(!1),[P,R]=(0,s.useState)(null),[I,O]=(0,s.useState)(null),[D,B]=(0,s.useState)(!1),[L,U]=(0,s.useState)(e.content??""),A=(0,s.useRef)(null),$=(0,K.useMessageActionPill)(A,w),G=!e.id.startsWith("temp-")&&!j&&!T,H="imessage"===e.source&&G,J="imessage"===e.source&&G&&!!e.message_guid,Q=(0,s.useMemo)(()=>{if(e.attachments?.length)return e.attachments;if(e.media_url){var t,s;return[(t=e.id,{id:`${t}-media`,filename:(s=e.media_url).split("?")[0].split("/").pop()||"Attachment",mime_type:null,byte_size:null,url:s})]}},[e.attachments,e.media_url,e.id]),Y=(0,k.describeBalloon)(e.balloon),Z=!Y&&!!(e.content??"").trim(),ee=(0,C.isBareBalloonKind)(Y)||(0,E.isMediaOnly)(Q,e.content),et=Z&&(0,E.isVisualMediaOnly)(Q),es=!Z||Y||Q?.length?null:(0,S.extractFirstUrl)(e.content??""),en=(0,_.useLinkPreview)(es),er=!!es&&(e.content??"").trim()===es&&(en.loading||!!en.data),ei=!w||!f||y||j||T?null:(0,F.receiptLabel)(e.delivered_at,e.read_at),el=(0,s.useCallback)(async(t,s)=>{if(!1===r)return;let n=await m(e.id,t,s);n?R(n):(R(null),M(!1))},[r,m,e.id]),eo=(0,s.useCallback)(async()=>{let t=L.trim();if(!t||t===(e.content??""))return void B(!1);let s=await h(e.id,t);s?O(s):(O(null),B(!1))},[L,e.content,e.id,h]),ed=(0,s.useCallback)(async()=>{$.dismiss(),O(await g(e.id))},[g,e.id,$]),eu=w&&G&&"imessage"===e.source&&!y&&!e.retracted_at,ec=eu&&(0,W.withinEditWindow)(e.sent_at),em=eu&&(0,W.withinUnsendWindow)(e.sent_at),ep=!1===d;return e.retracted_at?(0,t.jsx)("div",{className:(0,c.cn)("flex flex-col",w?"items-end":"items-start"),"data-message-id":e.id,children:(0,t.jsx)(F.UnsentBubble,{title:(0,F.bubbleTimeTitle)(e.sent_at)})}):(0,t.jsxs)("div",{className:(0,c.cn)("relative flex flex-col",w?"items-end":"items-start",u.length>0&&"mt-2.5"),"data-message-id":e.id,children:[e.reply_to&&(0,q.showsReplyQuote)(v)&&(0,t.jsx)(V.ReplyRunBracket,{side:w?"right":"left"}),e.reply_to&&(0,q.showsReplyQuote)(v)&&(0,t.jsx)(F.QuotedReplyBubble,{quote:e.reply_to,isOut:w,text:y,contactName:n,isGroup:a}),(0,t.jsx)("div",{className:(0,c.cn)("group flex max-w-[85%] items-center gap-1",w&&"flex-row-reverse"),"data-reply-run-end":"end"===v||"solo"===v?"":void 0,children:D?(0,t.jsx)(F.InlineMessageEditor,{value:L,onChange:U,onSave:()=>void eo(),onCancel:()=>{B(!1),U(e.content??"")}}):(0,t.jsxs)("div",{ref:A,className:"relative min-w-0",onTouchStart:$.touchProps.onTouchStart,onTouchMove:$.touchProps.onTouchMove,onTouchEnd:$.touchProps.onTouchEnd,onContextMenu:$.touchProps.onContextMenu,children:[(0,t.jsxs)("div",{title:(0,F.bubbleTimeTitle)(e.sent_at),className:(0,c.cn)("relative min-w-0 rounded-2xl text-sm",ee?"bg-transparent p-0":(0,c.cn)("message-bubble px-3 py-2",w?(0,c.cn)("text-white",b&&"rounded-br-md"):(0,c.cn)("oat-surface bg-[#F0EFED] text-foreground dark:bg-black",b&&"rounded-bl-md")),T&&"opacity-80 ring-1 ring-destructive/50"),...w&&!ee&&!y?F.BUBBLE_BLUE_ATTR:{},style:w&&!ee?{backgroundColor:y?F.GREEN:F.BUBBLE_BLUE_VAR}:void 0,children:[(0,t.jsx)(F.TapbackChips,{reactions:u,isOut:w,contactName:n,isGroup:a}),Q&&Q.length>0&&(0,t.jsx)(E.MessageAttachments,{attachments:Q,bare:ee,flush:et,flushTop:et,onColor:w&&!ee,className:(0,c.cn)(Z&&"mb-1.5")}),Y&&(0,t.jsx)(C.MessageBalloon,{balloon:Y,onColor:w&&!ee}),Z&&!er&&(0,t.jsxs)("p",{className:"whitespace-pre-wrap [word-break:break-word] text-[13px] leading-relaxed [overflow-wrap:anywhere]",children:[(0,t.jsx)(S.MessageText,{text:e.content??""}),e.edited_at&&(0,t.jsx)(F.EditedMarker,{isOut:w})]}),es&&(en.loading||en.data)&&(0,t.jsx)("div",{className:(0,c.cn)("-mx-3 w-[240px] max-w-[calc(100%+1.5rem)]",er?"-mt-2":"mt-1.5"),children:en.data?(0,t.jsx)(_.MessageLinkPreview,{url:es,data:en.data,onColor:w}):er&&(0,t.jsx)(_.LinkPreviewSkeleton,{})})]}),w&&(0,t.jsx)(F.SendProgressPill,{status:T?"failed":j?"sending":"sent",tone:y?"green":"blue"}),(H||J||Z||ec||em)&&(0,t.jsxs)(K.MessageActionPill,{revealed:$.revealed,onDismiss:$.dismiss,orientation:$.orientation,isOutbound:w,forceVisible:N,hoverGroup:"group",notice:ep&&(ec||em)?W.EDIT_UNSEND_UNSUPPORTED_NOTICE:null,children:[(0,t.jsx)(K.MessageStarButton,{channel:e.source,messageId:e.id}),H&&(0,t.jsx)(z.TapbackPicker,{open:N,onOpenChange:e=>{M(e),e||R(null)},align:w?"end":"start",reactions:u,canSendTapbacks:r,notice:P,onPick:(e,t)=>void el(e,t)}),J&&(0,t.jsx)(K.MessageActionButton,{label:"Reply",onClick:()=>{$.dismiss(),p(e)}
1,children:(0,t.jsx)(i.Reply,{className:"h-3.5 w-3.5"})}),Z&&(0,t.jsx)(K.MessageCopyButton,{text:e.content??""}),ec&&(0,t.jsx)(K.MessageActionButton,{label:"Edit",disabled:ep,disabledReason:W.EDIT_UNSEND_UNSUPPORTED_NOTICE,onClick:()=>{$.dismiss(),U(e.content??""),B(!0)},children:(0,t.jsx)(l.Pencil,{className:"h-3.5 w-3.5"})}),em&&(0,t.jsx)(K.MessageActionButton,{label:"Unsend",disabled:ep,disabledReason:W.EDIT_UNSEND_UNSUPPORTED_NOTICE,destructive:!0,onClick:()=>void ed(),children:(0,t.jsx)(o.TrashIcon,{className:"h-3.5 w-3.5"})})]})]})}),I&&(0,t.jsx)("p",{className:"mt-0.5 max-w-[85%] break-words px-1 text-[11px] leading-snug text-muted-foreground",children:I}),w&&x&&(0,t.jsxs)("p",{className:"mt-0.5 max-w-[85%] truncate px-1 text-[10px] text-muted-foreground",children:["via ",x]}),T&&(0,t.jsx)("p",{className:"mt-0.5 max-w-[85%] break-words px-1 text-[11px] text-destructive",children:e.delivery_error||"Failed to send"}),(0,t.jsx)(F.ReceiptLine,{label:ei})]})}e.s(["MessagesThreadPanel",0,function({peer:e,contactId:a,contactName:r,conversationId:i,channel:l,hideHeader:o,externalSearchQuery:x,autoFocusComposer:f,onBack:S,embedded:_}){let C=(0,b.useMergeVars)(a??null),{configured:k,isLoading:E}=(0,H.useMessagingTransportStatus)(),V=(0,P.getCachedMessagesThread)({contactId:a,conversationId:i,peer:e??null}),[q,z]=(0,s.useState)(V??[]),[K,et]=(0,s.useState)(!V),[er,ei]=(0,s.useState)(""),[el,eo]=(0,s.useState)(!1),[ed,eu]=(0,s.useState)(null),ec=(0,s.useRef)(null),em=(0,s.useRef)(null),[ep,eh]=(0,s.use
1State)({}),[eg,ex]=(0,s.useState)("inline"),[ef,eb]=(0,s.useState)(""),[ev,ew]=(0,s.useState)(Q.UNKNOWN_IMESSAGE_CAPABILITIES),{canSendTapbacks:ey,canEditUnsend:ej,canReplyThreaded:eT}=ev,[eN,eS]=(0,s.useState)({}),[e_,eC]=(0,s.useState)(()=>e?G($({peer:e,conversationId:i,channel:l})):null),[ek,eE]=(0,s.useState)("auto"),[eM,eP]=(0,s.useState)(!1),[eR,eI]=(0,s.useState)([]),[eO,eD]=(0,s.useState)(null),[eB,eL]=(0,s.useState)(null),[eU,eA]=(0,s.useState)(!1),e$=(0,M.useComposerAttachments)({onError:eL}),{addFiles:eG,addFromClipboard:eH,clear:eF}=e$,{peerTyping:eV,notifyTyping:eq,stopTyping:ez}=(0,D.useTypingIndicator)({channel:(0,L.resolveTypingChannel)("messages",l),conversationId:i}),[eJ,eK]=(0,s.useState)(0),{actions:eW,collectDurations:eQ}=(0,R.useComposerMediaNotes)({attachments:e$.attachments,addFiles:eG,onNotice:eL,disabled:el}),[eY,eX]=(0,s.useState)(null),[eZ,e0]=(0,s.useState)(!1),e1=e??eY;(0,s.useEffect)(()=>{if(!i||!l)return;let t=!1,s=(0,O.createClient)();return("imessage"===l?s.from("imessage_conversations").select("chat_identifier, preferred_transport, is_group, service").eq("id",i).maybeSingle():s.from("sms_conversations").select("phone_number, preferred_transport").eq("id",i).maybeSingle()).then(({data:s})=>{var n;let a;if(t||!s)return;e||eX(s.chat_identifier??s.phone_number??null),s.preferred_transport&&eE(s.preferred_transport);let r=(n=s.service,"imessage"===(a=(n??"").toLowerCase())?{transport:"imessage",optimistic:!0}:"sms"===a||"rcs"===a||"sms"===l?{transport:"twilio",optimistic:!0}:null);r&&eC(e=>e??r),e0(!!s.is_group)}),()=>{t=!0}},[e,i,l]),(0,s.useEffect)(()=>{let e=!1;return(0,O.createClient)().from("twilio_phone_numbers").select("id, phone_number, friendly_name, is_default").then(({data:t})=>{!e&&t&&eI(t)}),()=>{e=!0}},[]),(0,s.useEffect)(()=>{let e=!1;return fetch("/api/imessage/pair").then(e=>e.ok?e.json():null).then(t=>{if(e)return;let s=t?.devices;s&&0!==s.length&&ew((0,Q.deriveIMessageCapabilities)(s))}).catch(()=>{}),()=>{e=!0}},[]);let e5=(0,s.useCallback)(async()=>{if(!e1&&!a)return void et(!1);let e=new URLSearchParams({limit:"200"});e1&&e.set("peer",e1),a&&e.set("contactId",a);try{let t=await (0,w.fetchJsonShared)(`/api/messages/thread?${e.toString()}`);if(!t)return;let s=(t.messages??[]).slice().sort((e,t)=>new Date(e.sent_at).getTime()-new Date(t.sent_at).getTime());z(e=>{let t=new Set(s.map(e=>e.id)),n=e.filter(e=>e.id.startsWith("temp-")&&!(e._serverId&&t.has(e._serverId)));return[...s,...n]}),(0,P.setCachedMessagesThread)({contactId:a,conversationId:i,peer:e1},s)}catch{}finally{et(!1)}},[e1,a,i]);(0,s.useEffect)(()=>{(0,P.getCachedMessagesThread)({contactId:a,conversationId:i,peer:e??null})||et(!0),e5()},[e5,a,i,e]),(0,w.useConversationPoll)(e1||a?`messages:${e1??""}:${a??""}`:null,ec,e5);let e2=(0,s.useCallback)(async()=>{if(!e1)return;let e={peer:e1,conversationId:i,channel:l},t=$(e),s=G(t);if(s){let e;if(eC(s),s.preferredTransport&&eE(s.preferredTransport),(e=U.get(t))&&Date.now()-e.at<6e4)return}let n=await function(e,t){let s=A.get(e);if(s)return s;let n=new URLSearchParams({peer:t.peer});t.conversationId&&n.set("conversationId",t.conversationId),t.channel&&n.set("channel",t.channel);let a=(async()=>{try{let t=await fetch(`/api/messages/capability?${n.toString()}`);if(!t.ok)return null;let s=await t.json();return U.set(e,{data:s,at:Date.now()}),s}catch{return null}finally{A.delete(e)}})();return A.set(e,a),a}(t,e);n&&(eC(n),n.preferredTransport&&eE(n.preferredTransport))},[e1,i,l]);(0,s.useEffect)(()=>{e2()},[e2]);let e3=(0,s.useRef)(!0),e4=K&&0===q.length?null:e1??i??"messages",e8=(0,N.useScrollPinBottom)(ec,em,e3,e4);(0,F.useBubbleViewportGradient)(ec,em,q);let e6=(0,s.useCallback)(()=>{let e=ec.current;e&&(e3.current=e.scrollHeight-e.scrollTop-e.clientHeight<200)},[]),e7=(0,s.useRef)(null),e9=(0,s.useRef)(0),te=(0,s.useRef)(!1);(0,s.useEffect)(()=>{let e=ec.current;if(!e)return;let t=q.length>0?q[q.length-1].id:null,s=e7.current,n=e9.current;if(e7.current=t,e9.current=e.scrollHeight,!te.current&&q.length>0){e.scrollTop=e.scrollHeight,te.current=!0;return}if(t===s){let t=e.scrollHeight-n;t>0&&(e.scrollTop+=t);return}e3.current&&(e.scrollTop=e.scrollHeight)},[q]);let tt=(0,s.useCallback)(async(e,t,s)=>{let n={kind:t,remove:s,at:new Date().toISOString()};eS(s=>({...s,[e]:[...(s[e]??[]).filter(e=>e.kind!==t),n]}));let a=()=>eS(t=>({...t,[e]:(t[e]??[]).filter(e=>e!==n)}));try{let n=await fetch("/api/imessage/react",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:e,kind:t,...s?{remove:!0}:{}})});if(n.ok)return null;a();let r=await n.json().catch(()=>null);if(r?.error==="tapbacks_unsupported")return ew(e=>
1({...e,canSendTapbacks:!1})),J.TAPBACKS_UNSUPPORTED_NOTICE;return r?.error||"Failed to send tapback"}catch{return a(),"Failed to send tapback"}},[]),ts=(0,s.useCallback)(e=>{e.message_guid&&(eD({messageId:e.id,guid:e.message_guid,content:e.content,isOutbound:e.is_outbound,senderHandle:e.sender_handle,attachments:e.attachments}),eL(null))},[]),tn=(0,s.useCallback)(async(e,t)=>{try{let s=await fetch(`/api/imessage/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.ok)return e5(),null;let n=await s.json().catch(()=>null);if(n?.error==="edit_unsupported")return ew(e=>({...e,canEditUnsend:!1})),n.detail??W.EDIT_UNSEND_UNSUPPORTED_NOTICE;return n?.detail||n?.error||`Could not ${e} that message.`}catch{return`Could not ${e} that message.`}},[e5]),ta=(0,s.useCallback)((e,t)=>tn("edit",{messageId:e,text:t}),[tn]),tr=(0,s.useCallback)(e=>tn("unsend",{messageId:e}),[tn]),ti=(0,s.useCallback)(e=>{eH(e)&&e.preventDefault()},[eH]),tl=(0,s.useCallback)(e=>{eA(!1),e.dataTransfer?.files?.length&&(e.preventDefault(),eG(e.dataTransfer.files))},[eG]),to=(0,s.useCallback)(e=>{Array.from(e.dataTransfer?.types??[]).includes("Files")&&(e.preventDefault(),eA(!0))},[]),td=(0,s.useCallback)(async e=>{if(i){eE(e),eP(!0);try{if(!(await fetch("/api/messages/preferences",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferredTransport:e,conversationId:i,...l?{channel:l}:{}})})).ok)return void eE(ek);eu(null),await e2()}catch{eE(ek)}finally{eP(!1)}}},[ek,i,l,e2]),tu=(0,s.useCallback)(async()=>{let e=e$.paths,t=!!er.trim();if(!t&&0===e.length||el||!e1&&!a&&!i)return;if(ez(),e$.uploading)return void eL("Still uploading. Send again once the attachment finishes.");let s=t?(0,y.resolveTemplateVarsLenient)(er.trim(),C):"",n=eQ();ei(""),eD(null),eL(null),eo(!0),eu(null);let r=e_?.transport??"auto",o="imessage"===ek||"auto"===ek&&"imessage"===r?"iMessage":"twilio"===ek||"auto"===ek&&"twilio"===r?"twilio":"SMS",d=`temp-${Date.now()}`,u={id:d,source:"iMessage"===o?"imessage":"sms",transport:o,content:s,is_outbound:!0,sent_at:new Date().toISOString(),sender_handle:null,sender_user_id:null,delivery:"sending",attachments:e$.attachments.filter(e=>e.storagePath).map(e=>({id:e.id,filename:e.file.name,mime_type:e.file.type||null,byte_size:e.file.size,url:e.preview??null})),...eO?{reply_to:{id:eO.messageId,content:eO.content,is_outbound:eO.isOutbound,sender_handle:eO.senderHandle,attachments:eO.attachments}}:{}};z(e=>[...e,u]),eF();let c=e=>z(t=>t.map(t=>t.id===d?{...t,delivery:"failed",delivery_error:e}:t));try{let t=await fetch("/api/messages/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s,transport:ek,...e1?{peer:e1}:{},...a?{contactId:a}:{},...i?{conversationId:i}:{},...l?{channel:l}:{},...e.length>0?{attachmentPaths:e,attachmentDurations:n}:{},...eO?{replyToGuid:eO.guid}:{}})}),r=await t.json().catch(()=>null);if(409===t.status&&r?.error==="no_transport"){let e=r.reason||"There is no way to send to this person right now.";eu(e),c(e);return}if(!t.ok)return void c(r?.reason||r?.error||"Failed to send message");r?.warnings?.length&&eL(r.warnings.join(" ")),r?.replyMode==="quoted"&&ew(e=>({...e,canReplyThreaded:!1}));let o=r?.messageId;o&&eh(e=>({...e,[o]:d})),z(e=>e.map(e=>e.id===d?{...e,_serverId:r?.messageId,transport:r?.transport==="imessage"?"iMessage":r?.transport==="twilio"?"twilio":e.transport}:e)),(0,v.dispatchInboxRefresh)(),e2()}catch{c("Failed to send message")}finally{eo(!1)}},[er,el,e1,a,i,l,C,e_,ek,e2,e$,eF,eQ,eO,ez]),tc=(0,s.useCallback)(async e=>{let t=e$.paths,s=!!er.trim();if(!s&&0===t.length||!e1&&!a&&!i)return;if(e$.uploading)return void eL("Still uploading. Schedule again once the attachment finishes.");let n=s?(0,y.resolveTemplateVarsLenient)(er.trim(),C):"",r=eQ();eo(!0),eL(null),eu(null);try{let s=await fetch("/api/messages/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:n,transport:ek,scheduledAt:e.toISOString(),...e1?{peer:e1}:{},...a?{contactId:a}:{},...i?{conversationId:i}:{},...l?{channel:l}:{},...t.length>0?{attachmentPaths:t,attachmentDurations:r}:{},...eO?{replyToGuid:eO.guid}:{}})}),o=await s.json().catch(()=>null);if(409===s.status&&o?.error==="no_transport")return void eu(o.reason||"There is no way to send to this person right now.");
1if(!s.ok)return void eL(o?.reason||o?.error||"Could not schedule that message.");ei(""),eD(null),eF(),o?.warnings?.length&&eL(o.warnings.join(" ")),eK(e=>e+1)}catch{eL("Could not schedule that message.")}finally{eo(!1)}},[er,e1,a,i,l,C,ek,e$,eF,eQ,eO]),tm=(x??"").trim()||ef,tp=(0,s.useMemo)(()=>{if(!tm.trim())return q;let e=tm.toLowerCase().trim();return q.filter(t=>t.content?.toLowerCase().includes(e))},[q,tm]),th=(0,s.useMemo)(()=>{let e=new Map,t=null;for(let s of tp){let n=null!==t&&X(t)!==X(s.transport),a=null!==t&&!n&&X(s.transport)&&(t??"").toLowerCase()!==(s.transport??"").toLowerCase();(n||a)&&e.set(s.id,`Switched to ${function(e){switch((e??"").toLowerCase()){case"imessage":return"iMessage";case"rcs":return"RCS";case"twilio":return"text from the workspace number";default:return"text"}}(s.transport)}`),t=s.transport}return e},[tp]),tg=(0,s.useMemo)(()=>new Map(eR.map(e=>[e.id,e])),[eR]),tx=(0,s.useMemo)(()=>{let e=e_?.fromNumberId?tg.get(e_.fromNumberId):null;return e||(eR.find(e=>e.is_default)??(1===eR.length?eR[0]:null))},[e_,tg,eR]),tf=Z(tx)??"your workspace number",tb=(0,s.useMemo)(()=>{if(e_?.optimistic)return"imessage"===e_.transport?"iMessage":"Text";switch(e_?.transport){case"imessage":return"iMessage · via your Mac";case"mac_text":return"Text · from your iPhone";case"twilio":return`Text \xb7 from ${tf}`;default:return e_?"No way to send yet":"Checking how this sends…"}},[e_,tf]),tv=(0,s.useMemo)(()=>{let e=e_?.availableTransports;return ee.map(t=>{var s,n;let a;if("auto"===t.value){let s=!!e&&0===e.filter(e=>"auto"!==e).length;return{...t,disabled:s,reason:s?e_?.reason||"No transport is available for this person":null}}let r=!!e&&!e.includes(t.value),i=r?e_?.unavailable?.[t.value]||(s=t.value,a=(n=e??[]).includes("imessage")||n.includes("mac_text"),"twilio"===s?"No workspace number is set up to text from. Add one in Settings.":a?"mac_text"===s?"Texts need a phone number. This contact is only reachable by Apple ID.":"iMessage is not available for this contact.":"Your Mac is offline. Open Everything Helper on your Mac."):null,l="twilio"===t.value&&tx?`Text from ${Z(tx)}`:t.label;return{...t,label:l,disabled:r,reason:i}})},[e_,tx]),tw=(0,s.useMemo)(()=>{let e="auto"===ek?e_?.transport??"auto":ek;return"twilio"===e||"mac_text"===e?"A text cannot reply to one message, so this will send as a plain message.":!1===eT?F.REPLY_QUOTED_NOTICE:null},[ek,e_,eT]),ty=eO?{messageId:eO.messageId,name:eO.isOutbound?"You":(0,F.inboundSenderName)({senderHandle:eO.senderHandle,contactName:r,isGroup:eZ,unknown:"Them"}),...(0,F.replyStripMedia)(eO),...tw?{note:tw}:{}}:null,tj={capability:e_,preferred:ek,options:tv,onPick:td,saving:eM,pinnable:!!i},tT=(0,t.jsx)(es,{routeLabel:tb,...tj}),tN="auto"===ek?e_?.transport??"imessage":ek,tS=(0,s.useMemo)(()=>(0,F.newestOutboundId)(q),[q]),t_=(0,F.threadRowMeta)(tp),tC=(0,t.jsxs)(t.Fragment,{children:[!o&&(0,t.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b bg-muted/30 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[S&&(0,t.jsx)(u.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 shrink-0 rounded-3xl p-0",onClick:S,"aria-label":"Back",children:(0,t.jsx)(n.ChevronLeft,{className:"h-4 w-4"})}),(0,t.jsx)(T.IMessageSquircle,{}),tT]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2","data-channel-actions":!0,children:[(0,t.jsx)(p.MessageSearchPill,{value:ef,onChange:eb}),(0,t.jsx)(h.ChatExpandButtons,{expansion:eg,onChange:ex})]})]}),(0,t.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",onDragOver:to,onDragLeave:()=>eA(!1),onDrop:tl,children:[K&&0===q.length||!e8&&q.length>0?(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col overflow-hidden bg-card",children:(0,t.jsx)(j.MessageListSkeleton,{})}):null,eU&&(0,t.jsx)("div",{className:"pointer-events-none absolute inset-2 z-20 flex items-center justify-center rounded-2xl border-2 border-dashed border-border bg-card",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Drop to attach"})}),(0,t.jsx)("div",{ref:ec,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overflow-x-hidden",onScroll:e6,children:(0,t.jsx)("div",{ref:em,className:(0,
1c.cn)(m.THREAD_GUTTER_X,"py-3"),"data-reply-run-scope":!0,children:K||0!==tp.length?tp.map(e=>{let s=th.get(e.id),n=t_.get(e.id);return(0,t.jsxs)("div",{className:(0,c.cn)(!n?.separator&&!s&&(n?.isRunStart?"mt-2":"mt-[2px]")),children:[n?.separator&&(0,t.jsx)(F.ThreadTimeSeparator,{...n.separator}),s&&(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1","aria-label":s,children:[(0,t.jsx)("span",{className:"h-px flex-1 bg-border"}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[(0,t.jsx)("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:X(e.transport)?F.GREEN:F.BLUE}}),s]}),(0,t.jsx)("span",{className:"h-px flex-1 bg-border"})]}),(0,t.jsx)(ea,{msg:e,contactName:r,isGroup:eZ,canSendTapbacks:ey,canEditUnsend:ej,reactions:(0,F.applyReactionOverlays)(e.reactions,eN[e.id]),onReact:tt,onReply:ts,onEdit:ta,onUnsend:tr,viaLabel:e.is_outbound&&"twilio"===e.transport?tf:null,isLastOutbound:e.id===tS,isRunEnd:n?.isRunEnd??!0,replyRun:n?.replyRun??null})]},ep[e.id]??e.id)}):(0,t.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[(0,t.jsx)(d.ChatBubbleIcon,{className:"h-8 w-8 text-muted-foreground/30"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:tm.trim()?"No messages match your search":"No messages yet. Say hello."})]})})})]}),ed&&(E||k?(0,t.jsx)("div",{className:"shrink-0 border-t bg-amber-500/10 px-3 py-2",children:(0,t.jsx)("p",{className:"text-xs text-amber-900 dark:text-amber-200",children:ed})}):(0,t.jsx)("div",{className:"shrink-0 border-t px-3 py-2",children:(0,t.jsx)(H.HelperSetupCta,{variant:"compact"})})),eV&&(0,t.jsx)("div",{className:(0,c.cn)(m.THREAD_GUTTER_X,"shrink-0"),children:(0,t.jsx)(B.TypingIndicator,{name:r})}),(0,t.jsxs)("div",{className:"shrink-0 border-t bg-card py-2 px-2",onPaste:ti,children:[eB&&(0,t.jsx)("p",{className:"px-1.5 pb-1 text-[11px] leading-snug text-muted-foreground",children:eB}),(0,t.jsx)(I.ScheduledSendsStrip,{conversationId:i??null,peer:e1??null,refreshToken:eJ,onError:eL}),(0,t.jsx)(g.ChatInputBox,{placeholder:"imessage"===tN?"iMessage":"Text Message",text:er,onTextChange:ei,draftKey:`messages:${i??a??""}`,onTyping:eq,mergeVars:C,onSubmit:tu,sending:el,autoFocus:f,attachments:e$.attachments,onRemoveAttachment:e$.remove,onDropFiles:eG,replyTo:ty,onCancelReply:()=>eD(null),extraActions:(0,t.jsx)(en,{routeLabel:tb,route:tN,...tj}),trailingActions:eW,onScheduleSend:e=>void tc(e)})]})]});return"inline"!==eg?(0,t.jsx)(h.ChatExpandedSurface,{expansion:eg,title:Y.MESSAGES_CHANNEL_LABEL,onCollapse:()=>ex("inline"),children:tC}):(0,t.jsx)("div",{className:`flex min-h-0 flex-1 flex-col overflow-hidden ${o||_?"":"rounded-2xl border bg-card"}`,"data-channel-panel":!0,children:tC})}],712686)}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.