PageSourceSearch

https://thetool.company/_next/static/chunks/39o69c1th8zea.js

js thetool.company collected 2026-09-24 15:00:46 UTC 75,998 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,869407,197031,343820,357440,861782,201,e=>{"use strict";var t=e.i(843476),n=e.i(271645),r=e.i(373375),a=e.i(329006),s=e.i(788699),l=e.i(37727),i=e.i(643531),o=e.i(178583),d=e.i(493886),c=e.i(653339),u=e.i(341256),m=e.i(844700),h=e.i(167881),p=e.i(647163),f=e.i(340024),x=e.i(245092),g=e.i(194976),b=e.i(419829),v=e.i(728231),y=e.i(456174),j=e.i(620043),w=e.i(414318),N=e.i(800126),k=e.i(444256),C=e.i(158061),S=e.i(572377),T=e.i(969878),E=e.i(138108),M=e.i(564138),R=e.i(809868),_=e.i(625458),P=e.i(602944),D=e.i(713152),A=e.i(264648),L=e.i(247167);function I(e){let[t,r]=(0,n.useState)([]),a=e?.onError,s=(0,n.useRef)([]);(0,n.useEffect)(()=>{s.current=t},[t]),(0,n.useEffect)(()=>()=>{for(let e of s.current)e.preview&&URL.revokeObjectURL(e.preview)},[]);let l=(0,n.useCallback)(e=>{let t=Array.from(e);if(0===t.length)return;let n=[];for(let e of t){if(e.size>0x6400000){a?.(`"${e.name}" is larger than 100 MB.`);continue}n.push({id:`att-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,file:e,preview:e.type.startsWith("image/")?URL.createObjectURL(e):void 0,progress:0})}if(0!==n.length)for(let e of(r(e=>[...e,...n]),n))(function(e,t){return new Promise((n,r)=>{if(e.size>0x6400000)return void r(Error(`"${e.name}" is larger than 100 MB.`));let a=new FormData;a.append("file",e),a.append("filename",e.name);let s=new XMLHttpRequest;if(s.open("POST","/api/messages/attachments"),s.upload.onprogress=e=>{e.lengthComputable&&t?.onProgress?.(e.loaded/e.total)},s.onload=()=>{let a=null;try{a=JSON.parse(s.responseText)}catch{a=null}s.status<200||s.status>=300?r(Error(a?.error||`Upload failed (${s.status})`)):(t?.onProgress?.(1),n({storagePath:a?.storagePath,signedUrl:a?.signedUrl??null,mimeType:a?.mimeType||e.type||"application/octet-stream",byteSize:a?.byteSize??e.size,filename:a?.filename||e.name}))},s.onerror=()=>r(Error("Upload failed")),s.onabort=()=>r(Error("Upload canceled")),t?.signal){if(t.signal.aborted)return void s.abort();t.signal.addEventListener("abort",()=>s.abort(),{once:!0})}s.send(a)})})(e.file,{onProgress:t=>r(n=>n.map(n=>n.id===e.id?{...n,progress:t}:n))}).then(t=>r(n=>n.map(n=>n.id===e.id?{...n,progress:1,storagePath:t.storagePath,error:void 0}:n))).catch(t=>{let n=t instanceof Error?t.message:"Upload failed";a?.(n),r(t=>{let n=t.find(t=>t.id===e.id);return n?.preview&&URL.revokeObjectURL(n.preview),t.filter(t=>t.id!==e.id)})})},[a]),i=(0,n.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return!1;let n=[];for(let e of Array.from(t)){if("file"!==e.kind)continue;let t=e.getAsFile();t&&n.push(t)}return 0!==n.length&&(l(n),!0)},[l]),o=(0,n.useCallback)(e=>{r(t=>{let n=t.find(t=>t.id===e);return n?.preview&&URL.revokeObjectURL(n.preview),t.filter(t=>t.id!==e)})},[]),d=(0,n.useCallback)(()=>{r(e=>{for(let t of e)t.preview&&URL.revokeObjectURL(t.preview);return[]})},[]),c=t.map(e=>e.storagePath).filter(e=>"string"==typeof e),u=t.some(e=>!e.storagePath);return{attachments:t,addFiles:l,addFromClipboard:i,remove:o,clear:d,paths:c,uploading:u}}L.default.env.B2_KEY_ID,L.default.env.B2_APP_KEY,L.default.env.B2_BUCKET_NAME,L.default.env.B2_REGION,L.default.env.B2_ENDPOINT,L.default.env.B2_CDN_URL,e.s(["useComposerAttachments",0,I],197031);var U=e.i(387951),O=e.i(752044),B=e.i(403568);function F({onRecorded:e,onError:r,disabled:a}){let[s,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(!1),[c,u]=(0,n.use
1State)(0),[m,h]=(0,n.useState)(()=>Array(14).fill(.12)),p=(0,n.useRef)(null),f=(0,n.useRef)([]),x=(0,n.useRef)(null),g=(0,n.useRef)(null),b=(0,n.useRef)(null),y=(0,n.useRef)(null),j=(0,n.useRef)(null),w=(0,n.useRef)(0),N=(0,n.useRef)(!1);(0,n.useEffect)(()=>{i((0,B.voiceNoteSupported)())},[]);let k=(0,n.useCallback)(()=>{y.current&&(clearInterval(y.current),y.current=null),j.current&&(clearInterval(j.current),j.current=null),b.current=null;let e=g.current;g.current=null,e&&"closed"!==e.state&&e.close().catch(()=>{});let t=x.current;x.current=null,t?.getTracks().forEach(e=>e.stop()),p.current=null},[]);(0,n.useEffect)(()=>()=>k(),[k]);let C=(0,n.useCallback)(()=>{let e=p.current;e&&"inactive"!==e.state?e.stop():k(),d(!1)},[k]),S=(0,n.useCallback)(()=>{N.current=!0,C()},[C]),T=(0,n.useCallback)(async()=>{let t,n;if(a||o)return;let s=(0,B.pickVoiceNoteFormat)();if(!s)return void r?.("This browser cannot record audio. Try Safari or Chrome.");try{t=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(t){let e=t instanceof Error?t.name:"";r?.("NotAllowedError"===e||"SecurityError"===e?"Microphone access is blocked. Allow it for this site in your browser settings, then try again.":"NotFoundError"===e?"No microphone found.":"Could not start recording.");return}x.current=t,N.current=!1,f.current=[];try{n=new MediaRecorder(t,{mimeType:s.mimeType})}catch{k(),r?.("Could not start recording.");return}n.ondataavailable=e=>{e.data.size>0&&f.current.push(e.data)},n.onstop=()=>{let t=f.current;f.current=[];let n=(Date.now()-w.current)/1e3,r=N.current;if(N.current=!1,k(),d(!1),r||0===t.length)return;let a=new Blob(t,{type:s.mimeType});0!==a.size&&(0,B.readAudioDuration)(a,n).then(t=>{e(new File([a],s.filename,{type:s.mimeType}),Math.max(t,.1))})};try{let e=window.AudioContext??window.webkitAudioContext;if(e){let n=new e,r=n.createAnalyser();r.fftSize=512,n.createMediaStreamSource(t).connect(r),g.current=n,b.current=r}}catch{}n.start(250),p.current=n,w.current=Date.now(),u(0),h(Array(14).fill(.12)),d(!0),j.current=setInterval(()=>{let e=Date.now()-w.current;u(e),e>=3e5&&C()},200);let l=new Uint8Array(b.current?.fftSize??512);y.current=setInterval(()=>{let e=b.current;if(!e)return;e.getByteTimeDomainData(l);let t=0;for(let e=0;e<l.length;e++){let n=(l[e]-128)/128;t+=n*n}let n=Math.min(1,Math.max(.12,3.2*Math.sqrt(t/l.length)));h(e=>[...e.slice(1),n])},80)},[a,o,r,e,C,k]);return s?o?(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-lg [corner-shape:squircle] bg-muted px-2 py-1",children:[(0,t.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-destructive","aria-hidden":!0}),(0,t.jsx)("span",{className:"shrink-0 text-[11px] font-medium tabular-nums text-foreground",children:(0,B.formatVoiceNoteDuration)(c/1e3)}),(0,t.jsx)("span",{className:"flex h-4 shrink-0 items-center gap-[2px]","aria-hidden":!0,children:m.map((e,n)=>(0,t.jsx)("span",{className:"w-[2px] rounded-full bg-foreground",style:{height:`${Math.round(100*e)}%`}},n))}),(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:S,"aria-label":"Discard recording",className:"flex h-6 w-6 items-center justify-center rounded-full text-muted-foreground transition-colors duration-150 hover:bg-destructive/10 hover:text-destructive",children:(0,t.jsx)(l.X,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Discard"})]}),(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:C,"aria-label":"Stop recording",className:"flex h-6 w-6 items-center justify-center rounded-full bg-destructive text-destructive-foreground transition-colors duration-150 hover:bg-destructive/90",children:(0,t.jsx)(O.Square,{className:"h-2.5 w-2.5 fill-current"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Stop"})]})]}):(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:()=>void T(),disabled:a,"aria-label":"Record a voice note",className:"flex h-7 w-7 items-center justify-center rounded-lg [corner-shape:squircle] text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground disabled:opacity-50",children:(0,t.jsx)(U.Mic,{className:"h-4 w-4"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Voice note"})]}):null}var $=e.i(476819),z=e.i(174080),q=e.i(278716),H=e.i(367240);let V=[{mimeType:"video/mp4;codecs=avc1,mp4a.40.2",extension:"mp4"},{mimeType:"video/mp4",extension:"mp4"},{mimeType:"video/webm;codecs=vp9",extension:"webm"},{mimeType:"video/webm",extension:"webm"}];function X(){if("u"<typeof MediaRecorder||"function"!=typeof MediaRecorder.isTypeSupp
1orted)return null;for(let e of V)if(MediaRecorder.isTypeSupported(e.mimeType))return{...e,filename:`video-note.${e.extension}`,needsCaveat:"webm"===e.extension};return null}let G={video:{width:{ideal:1280},height:{ideal:720},facingMode:"user"},audio:!0};var W=e.i(609216);function K({onRecorded:e,onError:r,disabled:a}){let[s,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)("idle"),[u,m]=(0,n.useState)(0),[h,p]=(0,n.useState)(null),[f,x]=(0,n.useState)(null),[g,b]=(0,n.useState)(null),y=(0,n.useRef)(null),j=(0,n.useRef)(null),w=(0,n.useRef)(null),N=(0,n.useRef)(null),k=(0,n.useRef)([]),C=(0,n.useRef)(null),S=(0,n.useRef)(0),T=(0,n.useRef)(null),E=(0,n.useRef)(!1),M=(0,n.useRef)(!1);(0,n.useEffect)(()=>{o(!("u"<typeof navigator)&&!!navigator.mediaDevices?.getUserMedia&&null!==X())},[]);let R=(0,n.useCallback)(()=>{C.current&&(clearInterval(C.current),C.current=null);let e=j.current;e&&(e.srcObject=null);let t=N.current;N.current=null,t?.getTracks().forEach(e=>e.stop()),w.current=null,M.current=!1},[]),_=(0,n.useCallback)(()=>{let e=T.current;T.current=null,e&&URL.revokeObjectURL(e.url),x(null)},[]);(0,n.useEffect)(()=>()=>{let e=w.current;if(e&&"inactive"!==e.state){E.current=!0;try{e.stop()}catch{}}R();let t=T.current;T.current=null,t&&URL.revokeObjectURL(t.url)},[R]),(0,n.useLayoutEffect)(()=>{if("idle"===d)return void b(null);let e=()=>{let e=y.current;if(!e)return;let t=e.getBoundingClientRect();b({left:t.left,top:t.top,viewportHeight:window.innerHeight})};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[d]);let P=(0,n.useCallback)(e=>{if(j.current=e,!e)return;let t=N.current;t&&(e.srcObject=t,e.play().catch(()=>{}))},[]),D=(0,n.useCallback)(()=>{let e=w.current;e&&"inactive"!==e.state?e.stop():(R(),c("idle"))},[R]),A=(0,n.useCallback)(()=>{E.current=!0,D()},[D]),L=(0,n.useCallback)(async()=>{let e,t;if(a||M.current||N.current||w.current)return;M.current=!0;let n=X();if(!n){M.current=!1,r?.("This browser cannot record video. Try Safari or Chrome.");return}try{e=await navigator.mediaDevices.getUserMedia(G)}catch(t){M.current=!1;let e=t instanceof Error?t.name:"";r?.("NotAllowedError"===e||"SecurityError"===e?"Camera access is blocked. Allow camera and microphone for this site in your browser settings, then try again.":"NotFoundError"===e||"OverconstrainedError"===e?"No camera found.":"NotReadableError"===e?"The camera is already in use by another app.":"Could not start recording.");return}N.current=e,E.current=!1,k.current=[];try{t=new MediaRecorder(e,{mimeType:n.mimeType})}catch{M.current=!1,R(),r?.("Could not start recording.");return}t.ondataavailable=e=>{e.data.size>0&&k.current.push(e.data)},t.onerror=()=>{k.current=[],R(),c("idle"),r?.("Recording stopped unexpectedly.")},t.onstop=()=>{let e=k.current;k.current=[];let t=(Date.now()-S.current)/1e3,r=E.current;if(E.current=!1,R(),r||0===e.length)return void c("idle");let a=new Blob(e,{type:n.mimeType});0===a.size?c("idle"):new Promise(e=>{if("u"<typeof document)return void e(t);let n=URL.createObjectURL(a),r=document.createElement("video"),s=!1,l=a=>{s||(s=!0,URL.revokeObjectURL(n),r.removeAttribute("src"),e(Number.isFinite(a)&&a>0?a:t))};r.preload="metadata",r.muted=!0,r.onloadedmetadata=()=>l(r.duration),r.onerror=()=>l(t),setTimeout(()=>l(t),1500),r.src=n}).then(e=>{let t=URL.createObjectURL(a);T.current={file:new File([a],n.filename,{type:n.mimeType}),durationSeconds:Math.max(e,.1),url:t},x(t),c("review")})},t.start(250),M.current=!1,w.current=t,S.current=Date.now(),m(0),p(n.needsCaveat?"This browser can only record WebM, which may not play for the recipient. Chrome or Safari will record MP4.":null),c("recording"),C.current=setInterval(()=>{let e=Date.now()-S.current;m(e),e>=6e4&&D()},200)},[a,r,R,D]),I=(0,n.useCallback)(()=>{_(),c("idle")},[_]),U=(0,n.useCallback)(()=>{let t=T.current;t?(T.current=null,URL.revokeObjectURL(t.url),x(null),c("idle"),e(t.file,t.durationSeconds)):c("idle")},[e]),F=(0,n.useCallback)(()=>{_(),c("idle"),L()},[_,L]);if(!s)return null;let V="idle"!==d,Y=V&&g&&"u">typeof document?(0,z.createPortal)((0,t.jsxs)("div",{role:"dialog","aria-label":"recording"===d?"Recording a video note":"Review video note",style:{position:"fixed",left:Math.max(8,Math.min(g.left,window.innerWidth-160*(0,$.currentUiScale)()-24)),bottom:Math.max(8,g.viewportHe
1ight-g.top+8),width:(0,$.designPx)(176),zIndex:210,boxShadow:"0 10px 30px rgba(0, 0, 0, 0.18)"},className:"rounded-2xl [corner-shape:squircle] border border-border bg-card p-2",children:["recording"===d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("video",{ref:P,muted:!0,autoPlay:!0,playsInline:!0,style:{width:(0,$.designPx)(160),height:(0,$.designPx)(160),transform:"scaleX(-1)"},className:"block rounded-xl [corner-shape:squircle] bg-muted object-cover"}),(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-destructive","aria-hidden":!0}),(0,t.jsx)("span",{className:"flex-1 text-[11px] font-medium tabular-nums text-foreground",children:(0,B.formatVoiceNoteDuration)(u/1e3)}),(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:A,"aria-label":"Discard recording",className:"flex h-6 w-6 items-center justify-center rounded-full text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-destructive",children:(0,t.jsx)(l.X,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Discard"})]}),(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:D,"aria-label":"Stop recording",className:"flex h-6 w-6 items-center justify-center rounded-full bg-destructive text-destructive-foreground transition-colors duration-150 hover:opacity-90",children:(0,t.jsx)(O.Square,{className:"h-2.5 w-2.5 fill-current"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Stop"})]})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(W.VideoPlayer,{src:f??void 0,style:{width:(0,$.designPx)(160)},className:"block rounded-xl [corner-shape:squircle]",videoClassName:"w-full max-h-[240px]"}),(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-1",children:[(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:I,"aria-label":"Discard video note",className:"flex h-7 w-7 items-center justify-center rounded-lg [corner-shape:squircle] text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-destructive",children:(0,t.jsx)(l.X,{className:"h-4 w-4"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Discard"})]}),(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:F,"aria-label":"Record again",className:"flex h-7 w-7 items-center justify-center rounded-lg [corner-shape:squircle] text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground",children:(0,t.jsx)(H.RotateCcw,{className:"h-4 w-4"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Record again"})]}),(0,t.jsxs)("button",{type:"button",onClick:U,className:"ml-auto flex h-7 items-center gap-1 rounded-lg [corner-shape:squircle] bg-primary px-2 text-[11px] font-medium text-primary-foreground transition-opacity duration-150 hover:opacity-90",children:[(0,t.jsx)(i.Check,{className:"h-3.5 w-3.5"}),"Attach"]})]})]}),h&&(0,t.jsx)("p",{className:"mt-1.5 text-[10px] leading-snug text-muted-foreground",children:h})]}),document.body):null;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{ref:y,type:"button",onClick:()=>V?void 0:void L(),disabled:a||V,"aria-label":"Record a video note",className:V?"flex h-7 w-7 items-center justify-center rounded-lg [corner-shape:squircle] bg-accent text-destructive transition-colors duration-150":"flex h-7 w-7 items-center justify-center rounded-lg [corner-shape:squircle] text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground disabled:opacity-50",children:(0,t.jsx)(q.Video,{className:"h-4 w-4"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Video note"})]}),Y]})}function Y({attachments:e,addFiles:r,onNotice:a,disabled:s}){let l=(0,n.useRef)(new Map),i=(0,n.useCallback)((e,t)=>{l.current.set(e,t),a(null),r([e])},[r,a]),o=(0,n.useCallback)(()=>{let t={};for(let n of e){let e=l.current.get(n.file);n.storagePath&&"number"==typeof e&&(t[n.storagePath]=e)}return t},[e]);return{actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(F,{onRecorded:i,onError:a,disabled:s}),(0,t.jsx)(K,{onRecorded:i,onError:a,disabled:s})]}),collectDurations:o}}e.s(["useComposerMediaNotes",0,Y],343820);var J=e.i(503116),Q=e.i(82735),Z=e.i(401851),ee=e.i(980797),et=e.i(611316),en=e.i(926925);function er(e){let t=new Date(e);return Number.isNaN(t.getTime())?"later":(0,ee.isToday)(t)?`today at ${(0,Z.format)(t,"h:mm a")}`:(0,et.isTomorrow)(t)?`tomorrow at ${(0,Z.format)(t,"h:mm a")}`:`${(0,Z.format)(t,"EEE, d MMM")} at ${(0,Z.format)(t,"h:mm a")}`}function ea({conversationId:e,peer:r,refreshToken:a=0,onError:i}
1){let[o,d]=(0,n.useState)([]),[c,u]=(0,n.useState)(null),[m,p]=(0,n.useState)(""),[f,x]=(0,n.useState)(null),[g,b]=(0,n.useState)(null),y=(0,n.useMemo)(()=>{let t=new URLSearchParams;return e&&t.set("conversationId",e),r&&t.set("peer",r),t.toString()},[e,r]),j=(0,n.useCallback)(async()=>{if(!y)return void d([]);try{let e=await fetch(`/api/messages/scheduled?${y}`);if(!e.ok)return;let t=await e.json();d(t.scheduled??[])}catch{}},[y]);(0,n.useEffect)(()=>{j()},[j,a]),(0,n.useEffect)(()=>{if(!y)return;let e=setInterval(()=>void j(),3e4);return()=>clearInterval(e)},[y,j]);let w=(0,n.useCallback)(async e=>{b(e.id);try{let t=await fetch("/api/messages/scheduled",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboxId:e.id})});if(!t.ok){let e=await t.json().catch(()=>null);i?.(e?.error||"Could not cancel that message.")}}catch{i?.("Could not cancel that message.")}finally{b(null),j()}},[i,j]),N=(0,n.useCallback)(e=>{u(e.id),p(e.text),x(null)},[]),k=(0,n.useCallback)(async e=>{let t=m.trim();if(!t&&0===e.attachmentCount)return void i?.("Message cannot be empty. Cancel it instead.");b(e.id);try{let n=await fetch("/api/messages/scheduled",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboxId:e.id,...t!==e.text?{text:t}:{},...f?{scheduledAt:f}:{}})});if(!n.ok){let e=await n.json().catch(()=>null);i?.(e?.error||"Could not update that message.");return}u(null),x(null)}catch{i?.("Could not update that message.")}finally{b(null),j()}},[m,f,i,j]);if(0===o.length)return null;let C=o.some(e=>"mac_helper"===e.transport);return(0,t.jsxs)("div",{className:"mb-1.5 space-y-1 px-1.5",children:[o.map(e=>{let n=c===e.id,r=g===e.id;return(0,t.jsx)("div",{className:"rounded-xl border border-border bg-card px-2.5 py-1.5","data-scheduled-send":!0,children:n?(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("textarea",{value:m,onChange:e=>p(e.target.value),rows:2,"aria-label":"Scheduled message",className:"w-full resize-none rounded-lg border border-border bg-card px-2 py-1.5 text-[12px] text-foreground outline-none placeholder:text-muted-foreground",placeholder:"Message"}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,t.jsx)(J.Clock,{className:"h-3 w-3"}),er(f??e.scheduledAt)]}),(0,t.jsx)(en.SendLaterPopover,{variant:"compact",disabled:r,onSchedule:e=>x(e.toISOString())}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(h.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[11px]",onClick:()=>{u(null),x(null)},disabled:r,children:"Cancel"}),(0,t.jsx)(h.Button,{size:"sm",className:"h-6 px-2 text-[11px]",onClick:()=>void k(e),disabled:r,children:"Save"})]})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(J.Clock,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"truncate text-[12px] text-foreground",children:e.text||(e.attachmentCount>0?"Attachment":"Message")}),(0,t.jsxs)("p",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,t.jsxs)("span",{children:["Scheduled for ",er(e.scheduledAt)]}),e.attachmentCount>0&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5",children:[(0,t.jsx)(Q.Paperclip,{className:"h-2.5 w-2.5"}),e.attachmentCount]})]})]}),(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:()=>N(e),disabled:r,"aria-label":"Edit scheduled message",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground disabled:opacity-50",children:(0,t.jsx)(s.Pencil,{className:"h-3 w-3"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Edit"})]}),(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",onClick:()=>void w(e),disabled:r,"aria-label":"Cancel scheduled message",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors duration-150 hover:bg-destructive/10 hover:text-destructive disabled:opacity-50",children:(0,t.jsx)(l.X,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(v.TooltipContent,{side:"top",children:"Cancel"})]})]})},e.id)}),C&&(0,t.jsx)("p",{className:"px-1 text-[10px] leading-snug text-muted-foreground",children:"Sends fire when your Mac is online. If it's asleep at that time, it goes out when it wakes."})]})}e.s(["ScheduledSendsStrip",0,ea],357440);var es=e.i(777845),el=e.i(923508),ei=e.i(724057),eo=e.i(920755),ed=e.i(691551),ec=e.i(515168),eu=e.i(771060),em=e.i(903659),eh=e.i(941388),ep=e.i(59377);let ef="emoji:",ex=[{kind:"loved",glyph:"❤️",label:"Love"},{kind:"liked",glyph:"👍",label:"Like"},{kind:"disliked",glyph:"👎",label:"Dislike"},{kind:"laughed",glyph:"😂",label:"Laugh"},{kind:"emphasized",glyph:"‼️",label:"Emphasize"},{kind:"questioned",glyph:"❓",label:"Question"}],eg=Object.fromEntries(ex.map(e=>[e.kind,e.glyph])),eb="💬",ev="Sending tapbacks needs Accessibility permission for Everything Helper on your Mac. Receiving tapbacks always works.";function ey(e){return e.startsWith(ef)}function ej(e){return`${ef}${e}`}function ew(e){return ey(e)?e.slice(ef.length):null}function eN(e){return ey(e)?e.slice(ef.length):eg[e]}function ek(e){let t=ew(e);return t?`React with ${t}`:ex.find(t=>t.kind===e)?.label??e}function eC(e){return"emoji"===e.kind||"other"===e.kind?e.emoji||eb:eg[e.kind]??eb}function eS(e){return"emoji"===e.kind||"other"===e.kind?`${e.kind}:${e.emoji??""}`:e.kind}function eT(e,t){let n=ew(t);return null===n?e.kind===t:"emoji"===e.kind&&e.emoji===n}function eE(e,t){return ey(e)?{kind:"emoji",emoji:e.slice(ef.length),sender_handle:null,is_from_me:!0,at:t}:{kind:e,sender_handle:null,is_from_me:!0,at:t}}e.s(["STANDARD_TAPBACKS",0,ex,"TAPBACKS_UNSUPPORTED_NOTICE",0,ev,"customEmojiTapback",0,ej,"isCustomEmojiTapback",0,ey,"reactionForTapback",0,eE,"reactionGlyph",0,eC,"reactionKey",0,eS,"reactionMatchesTapback",0,eT,"tapbackGlyph",0,eN,"tapbackLabel",0,ek],861782);let eM=(0,n.lazy)(()=>e.A(238121).then(e=>({default:e.EmojiPicker})));function eR(){return(0,t.jsxs)("div",{className:"flex h-[330px] flex-col gap-2 p-3",children:[(0,t.jsx)("div",{className:"h-9 w-full animate-pulse rounded-full bg-muted"}),(0,t.jsx)("div",{className:"flex gap-1",children:Array.from({length:4}).map((e,n)=>(0,t.jsx)("div",{className:"h-6 w-16 animate-pulse rounded-full bg-muted"},n))}),(0,t.jsx)("div",{className:"grid flex-1 grid-cols-4 content-start gap-1 pt-1",children:Array.from({length:20}).map((e,n)=>(0,t.jsx)("div",{className:"h-8 w-8 animate-pulse rounded-lg bg-muted"},n))})]})}function e_({open:e,onOpenChange:a,align:s,reactions:l,canSendTapbacks:i,notice:o,onPick:d}
1){let[c,u]=(0,n.useState)(!1),m=!1===i,h=(0,n.useMemo)(()=>{let e=new Set,t=[];for(let n of l)!n.is_from_me||"emoji"!==n.kind||!n.emoji||e.has(n.emoji)||(e.add(n.emoji),t.push(ej(n.emoji)));return t},[l]),f=(0,n.useMemo)(()=>[...ex.map(e=>e.kind),...h],[h]);return(0,t.jsxs)(ep.Popover,{open:e,onOpenChange:e=>{e&&u(!1),a(e)},children:[(0,t.jsx)(ep.PopoverTrigger,{asChild:!0,children:(0,t.jsx)(ed.MessageActionButton,{label:"React with a tapback",children:(0,t.jsx)(em.SmilePlus,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(ep.PopoverContent,{side:"top",align:s,className:(0,p.cn)("overflow-hidden",c?"w-[280px] p-0":"w-auto p-1.5"),children:c?(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>u(!1),className:"flex items-center gap-1 border-b border-border px-2.5 py-2 text-left text-[11px] text-muted-foreground hover:text-foreground",children:[(0,t.jsx)(r.ChevronLeft,{className:"h-3 w-3"}),"Tapbacks"]}),(0,t.jsx)(n.Suspense,{fallback:(0,t.jsx)(eR,{}),children:(0,t.jsx)(eM,{embedded:!0,onSelect:e=>{let t=ej(e);d(t,l.some(e=>e.is_from_me&&eT(e,t)))},onClose:()=>u(!1)})}),o&&(0,t.jsx)("p",{className:"border-t border-border px-2.5 py-2 text-[11px] leading-snug text-muted-foreground",children:o})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[f.map((e,n)=>{let r=l.some(t=>t.is_from_me&&eT(t,e)),a=ey(e)&&n===ex.length;return(0,t.jsxs)("div",{className:"flex items-center",children:[a&&(0,t.jsx)("span",{className:"mx-1 h-5 w-px bg-border","aria-hidden":!0}),(0,t.jsx)("button",{type:"button",disabled:m,title:ek(e),className:(0,p.cn)("flex h-8 w-8 items-center justify-center rounded-full text-base leading-none transition-colors duration-150",r&&"bg-muted",m?"cursor-not-allowed opacity-40":"hover:bg-muted"),onClick:()=>d(e,r),children:eN(e)})]},e)}),(0,t.jsx)("button",{type:"button",disabled:m,title:"Any emoji","aria-label":"React with any emoji",className:(0,p.cn)("ml-0.5 flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors duration-150",m?"cursor-not-allowed opacity-40":"hover:bg-muted hover:text-foreground"),onClick:()=>u(!0),children:(0,t.jsx)(eh.Plus,{className:"h-4 w-4"})})]}),(m||o)&&(0,t.jsx)("p",{className:"mt-1.5 max-w-[228px] px-1 pb-0.5 text-[11px] leading-snug text-muted-foreground",children:o??ev})]})})]})}e.s(["TapbackPicker",0,e_],201);let eP="Your Mac helper is offline. Open Everything Helper on your Mac.",eD="Sends as a normal message, so they will not see it as a reply. Threaded replies need Accessibility permission for Everything Helper.";function eA(e){let t=(e??"").toLowerCase();return"sms"===t||"rcs"===t}function eL(e,t){let n=e??[];if(!t?.length)return n;for(let e of t)e.remove?n=n.filter(t=>!(t.is_from_me&&eT(t,e.kind))):n.some(t=>t.is_from_me&&eT(t,e.kind))||(n=[...n,eE(e.kind,e.at)]);return n}function eI(e){return new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"})}function eU(e){let t=new Date(e),n=new Date,r=eI(e);if(t.toDateString()===n.toDateString())return{day:"Today",time:r};let a=new Date(n);if(a.setDate(a.getDate()-1),t.toDateString()===a.toDateString())return{day:"Yesterday",time:r};let s=(n.getTime()-t.getTime())/864e5;return s>=0&&s<7?{day:t.toLocaleDateString([],{weekday:"short"}),time:r}:{day:t.toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),time:r}}function eO(e){return new Date(e).toLocaleString("en-US")}function eB(e){let t=e.map((t,n)=>{if(0===n)return!0;let r=new Date(e[n-1].sent_at),a=new Date(t.sent_at);return r.toDateString()!==a.toDateString()||a.getTime()-r.getTime()>36e5}),n=(0,P.replyRunPositions)(e,{target:e=>e.reply_to?.id,sender:e=>`${e.is_outbound?"out":"in"}:${e.sender_handle??""}`,breakBefore:(e,n)=>t[n]}),r=new Map;return e.forEach((a,s)=>{let l=t[s];r.set(a.id,{separator:l?eU(a.sent_at):null,isRunStart:l||e[s-1].is_outbound!==a.is_outbound,isRunEnd:s===e.length-1||t[s+1]||e[s+1].is_outbound!==a.is_outbound,replyRun:n[s]})}),r}function eF({day:e,time:n}){return(0,t.jsx)("div",{className:"flex items-center justify-center py-2.5",children:(0,t.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-semibold",children:e})," ",n]})})}let e$="#34C759",ez="#1E99FF",eq="#4DBEFB";function eH(e,t,n){let r=Math.min(1,Math.max(0,n)),a=e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)],[s,l,i]=a(e),[o,d,c]=a(t),u=(e,t)=>
1Math.round(e+(t-e)*r);return`#${[u(s,o),u(l,d),u(i,c)].map(e=>e.toString(16).padStart(2,"0")).join("")}`}let eV=`var(--bubble-blue, ${ez})`,eX={"data-bubble-blue":""};function eG(e,t,r){(0,n.useEffect)(()=>{let n=e.current;if(!n)return;let r=0,a=()=>{r=0;let e=n.getBoundingClientRect(),t=e.height||1,a=[];for(let[r,s]of(n.querySelectorAll("[data-bubble-blue]").forEach(n=>{let r=n.getBoundingClientRect();if(r.bottom<e.top||r.top>e.bottom)return;let s=r.top+r.height/2,l=Math.min(1,Math.max(0,(e.bottom-s)/t));a.push([n,eH(ez,eq,l)])}),a))r.style.setProperty("--bubble-blue",s)},s=()=>{r||(r=requestAnimationFrame(a))};a(),n.addEventListener("scroll",s,{passive:!0});let l=new ResizeObserver(s);return l.observe(n),t.current&&l.observe(t.current),()=>{r&&cancelAnimationFrame(r),n.removeEventListener("scroll",s),l.disconnect()}},[e,t,r])}let eW="Read receipts only appear when the person you are messaging has them turned on.";function eK(e,t){return t?{word:"Read",time:eI(t)}:e?{word:"Delivered",time:null}:null}function eY(e){for(let t=e.length-1;t>=0;t--)if(e[t].is_outbound)return e[t].id;return null}function eJ({label:e}){return e?(0,t.jsx)(v.TooltipProvider,{delayDuration:200,children:(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("span",{tabIndex:0,className:"mt-1 px-1 text-[10px] text-muted-foreground outline-none",children:[(0,t.jsx)("span",{className:"font-medium",children:e.word}),e.time?` ${e.time}`:""]})}),(0,t.jsx)(v.TooltipContent,{side:"left",className:"max-w-[220px]",children:eW})]})}):null}function eQ({status:e,tone:r="blue"}){let a=(0,n.useRef)(null),s=(0,n.useRef)(null),l=(0,n.useRef)(null),[i,o]=(0,n.useState)("sending"!==e);return((0,n.useEffect)(()=>{if(i)return;let t=s.current,n=a.current;if(!t||!n)return;let r=!0,d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;if("sending"===e){if(d){t.style.transform="scaleX(0.9)";return}return l.current=t.animate([{transform:"scaleX(0.04)"},{transform:"scaleX(0.9)"}],{duration:3200,easing:"cubic-bezier(0.16, 1, 0.3, 1)",fill:"forwards"}),()=>{r=!1}}let c=l.current;if(l.current=null,c){c.pause();try{c.commitStyles()}catch{}c.cancel()}if(d){"sent"===e&&(t.style.transform="scaleX(1)");let n=setTimeout(()=>{r&&o(!0)},420);return()=>{r=!1,clearTimeout(n)}}let u=getComputedStyle(t).transform;return"sent"===e&&t.animate([{transform:u},{transform:"scaleX(1)"}],{duration:220,easing:"ease-out",fill:"forwards"}),n.animate([{opacity:1},{opacity:0}],{duration:200,delay:220*("sent"===e),easing:"ease-out",fill:"forwards"}).finished.then(()=>{r&&o(!0)}).catch(()=>{}),()=>{r=!1}},[e,i]),i)?null:(0,t.jsx)("div",{ref:a,role:"progressbar","aria-label":"Sending",className:"mt-1 ml-auto h-[3px] w-1/2 overflow-hidden rounded-full bg-border",children:(0,t.jsx)("div",{ref:s,..."blue"===r?eX:{},className:"h-full w-full origin-left rounded-full",style:{backgroundColor:"green"===r?e$:eV,transform:"scaleX(0.04)"}})})}function eZ({senderHandle:e,contactName:t,isGroup:n,unknown:r}){let a=t?.trim();return!n&&a?a:e?.trim()||r}function e0({reactions:e,isOut:r,contactName:a,isGroup:s}){let l=(0,n.useMemo)(()=>{let t=new Map;for(let n of e){let e=eS(n),r=n.is_from_me?"You":eZ({senderHandle:n.sender_handle,contactName:a,isGroup:s,unknown:"Unknown"}),l=t.get(e);l?(l.senders.push(r),n.is_from_me&&(l.byMe=!0)):t.set(e,{glyph:eC(n),senders:[r],byMe:n.is_from_me})}return Array.from(t.entries())},[e,a,s]);return 0===l.length?null:(0,t.jsx)(v.TooltipProvider,{delayDuration:200,children:(0,t.jsx)("div",{className:(0,p.cn)("absolute -top-3 z-10 flex -space-x-1.5",r?"left-0 -translate-x-1.5":"right-0 translate-x-1.5"),children:l.map(([e,n])=>(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("span",{className:(0,p.cn)("inline-flex h-[22px] min-w-[22px] items-center justify-center gap-0.5 rounded-full border px-1 text-[11px] leading-none shadow-sm cursor-default",n.byMe?"border-transparent text-white":"border-border bg-card text-foreground"),style:n.byMe?{backgroundColor:ez}:void 0,children:[(0,t.jsx)("span",{className:"text-[12px] leading-none",children:n.glyph}),n.senders.length>1&&(0,t.jsx)("span",{className:(0,p.cn)("text-[10px] font-medium",n.b
1yMe?"text-white":"text-muted-foreground"),children:n.senders.length})]})}),(0,t.jsx)(v.TooltipContent,{side:"top",className:"max-w-[220px]",children:n.senders.join(", ")})]},e))})})}function e1(e){let t=(0,R.quotedAttachmentSummary)(e.attachments,!0),n=e.attachments?.[0],r="image"===t.kind?"image/gif"===(n?.mime_type??"").toLowerCase()?"gif":"image":"video"===t.kind?"video":null;return{text:e.content||t.label,...r&&n?.url?{mediaUrl:n.url,mediaType:r}:{}}}function e2({quote:e,isOut:n,text:r,contactName:a,isGroup:s}){let l=e.is_outbound?"You":eZ({senderHandle:e.sender_handle,contactName:a,isGroup:s,unknown:"Them"}),i=(0,R.quotedAttachmentSummary)(e.attachments,e.has_attachments),u=e.content||i.label||"Message",m=!e.content&&null!==i.kind,h="video"===i.kind?d.Film:"audio"===i.kind?c.Music:o.FileText;return(0,t.jsx)("div",{className:(0,p.cn)("flex",n?"justify-end":"justify-start"),children:(0,t.jsxs)("button",{type:"button","data-reply-quote":!0,"aria-label":`Go to the quoted message from ${l}: ${u}`,onClick:()=>(0,es.jumpToThreadMessage)(e.id),className:(0,p.cn)("mb-0.5 flex max-w-[200px] items-center gap-2 rounded-2xl border bg-transparent text-left text-[11px] leading-snug",m?"py-1 pl-1 pr-2.5":"px-2.5 py-1","text-foreground opacity-80 transition-opacity duration-150 hover:opacity-100",n?"mr-2":"ml-2",e.is_outbound?"":"border-[#DAD8D4] dark:border-white/25"),style:e.is_outbound?{borderColor:r?e$:ez}:void 0,children:[m&&(i.thumbUrl?(0,t.jsx)("img",{src:i.thumbUrl,alt:"",className:"h-8 w-8 shrink-0 rounded-[10px] object-cover",loading:"lazy",draggable:!1}):(0,t.jsx)("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-[10px] bg-muted text-muted-foreground",children:(0,t.jsx)(h,{className:"h-3.5 w-3.5"})})),(0,t.jsxs)("span",{className:"block min-w-0 truncate",children:[(0,t.jsxs)("span",{className:"font-medium",children:[l,": "]}),u]})]})})}function e5({isOut:e}){return(0,t.jsx)("span",{className:(0,p.cn)("ml-1 text-[10px]",e?"text-white/70":"text-muted-foreground"),children:"Edited"})}function e3({title:e}){return(0,t.jsx)("div",{title:e,className:"max-w-[85%] rounded-2xl border border-dashed border-border bg-muted px-3 py-2 text-[13px] italic leading-relaxed text-muted-foreground",children:"Message unsent"})}function e4({value:e,onChange:r,onSave:a,onCancel:s}){let o=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let e=o.current;e&&(e.focus(),e.style.height="auto",e.style.height=`${e.scrollHeight}px`)},[]),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("textarea",{ref:o,value:e,onChange:e=>{r(e.target.value),e.target.style.height="auto",e.target.style.height=`${e.target.scrollHeight}px`},onKeyDown:e=>{let t=window.matchMedia("(max-width: 767px)").matches;"Enter"!==e.key||e.shiftKey||t||(e.preventDefault(),a()),"Escape"===e.key&&s()},rows:1,className:"w-full min-w-[200px] resize-none rounded-2xl border border-border bg-card px-3 py-2 pb-8 text-[13px] leading-relaxed outline-none"}),(0,t.jsxs)("div",{className:"absolute bottom-1.5 right-1.5 flex items-center gap-0.5",children:[(0,t.jsx)("button",{type:"button","aria-label":"Cancel edit",onClick:s,className:"flex h-5 w-5 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,t.jsx)(l.X,{className:"h-3 w-3"})}),(0,t.jsx)("button",{type:"button","aria-label":"Save edit",onClick:a,className:"flex h-5 w-5 items-center justify-center rounded text-foreground transition-colors hover:bg-muted",children:(0,t.jsx)(i.Check,{className:"h-3 w-3"})})]})]})}function e6({msg:e,showSender:r,contactName:l,convoService:i,isGroup:o,isLastOutbound:d,isRunEnd:c,replyRun:m,canSendTapbacks:h,canEditUnsend:f,reactions:x,onReact:g,onReply:b,onEdit:v,onUnsend:y}){let j=e.is_outbound,w=eA(e.service??i),[N,k]=(0,n.useState)(!1),[C,S]=(0,n.useState)(null),[T,L]=(0,n.useState)(null),[I,U]=(0,n.useState)(!1),[O,B]=(0,n.useState)(e.content??""),F=(0,n.useRef)(null),$=(0,ed.useMessageActionPill)(F,j),z=!e.id.startsWith("temp-")&&!e.sending&&!e.failed,q=z&&!!e.message_guid,H=(0,A.describeBalloon)(e.balloon),V=!H&&!!(e.content??"").trim(),X=(0,D.isBareBalloonKind)(H)||(0,R.isMediaOnly)(e.attachments,e.content),G=V&&(0,R.isVisualMediaOnly)(e.attachments),W=!V||H||e.attachments?.length?null:(0,E.extractFirstUrl)(e.content??""),K=(0,M.useLinkPreview)(W),Y=!!W&&(e.content??"").trim()===W&&(K.loading||!!K.data),J=!j||!d||w||e.sending||e.failed?null:eK(e.delivered_at,e.read_at),Q=j&&z&&!w&&!e.retracted_at,Z=Q&&(0,ec.withinEditWindow)(e.sent_at),ee=Q&&(0,ec.withinUnsendWindow)(e.sent_at),et=!1===f,en=(0,n.useCallback)(async(t,n)=>{if(!1===h)return;let r=await g(e.id,t,n);r?S(r):(S(null),k(!1))},[h,g,e.id]),er=(0,n.useCallback)(async()=>{let t=O.trim();if(!t||t===(e.content??""))return void U(!1);let n=await v(e.id,t);n?L(n):(L(null),U(!1))},[O,e.content,e.id,v]),ea=(0,n.useCallback)(async()=>{$.dismiss(),L(await y(e.id))},[y,e.id,$]);return e.retracted_at?(0,t.jsx)("div",{className:(0,p.cn)("flex flex-col",j?"items-end":"items-start"),"data-message-id":e.id,children:(0,t.jsx)(e3,{title:eO(e.sent_at)})}):(0,t.jsxs)("div",{className:(0,p.cn)("relative flex flex-col",j?"items-end":"items-start",x.length>0&&"mt-2.5"),"data-message-id":e.id,children:[e.reply_to&&(0,P.showsReplyQuote)(m)&&(0,t.jsx)(_.ReplyRunBracket,{side:j?"right":"left"}),r&&!j&&e.sender_handle&&(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground mb-0.5 px-1",children:e.sender_handle}),e.reply_to&&(0,P.showsReplyQuote)(m)&&(0,t.jsx)(e2,{quote:e.reply_to,isOut:j,text:w,contactName:l,isGroup:o}),(0,t.jsx)("div",{className:(0,p.cn)("group flex max-w-[85%] items-center gap-1",j&&"flex-row-reverse"),"data-reply-run-end":"end"===m||"solo"===m?"":void 0,children:I?(0,t.jsx)(e4,{value:O,onChange:B,onSave:()=>void er(),onCancel:()=>{U(!1),B(e.content??"")}}):(0,t.jsxs)("div",{ref:F,className:"relative min-w-0",onTouchStart:$.touchProps.onTouchStart,onTouchMove:$.touchProps.onTouchMove,onTouchEnd:$.touchProps.onTouchEnd,onContextMenu:$.touchProps.onContextMenu,children:[(0,t.jsxs)("div",{title:eO(e.sent_at),className:(0,p.cn)("relative min-w-0 rounded-2xl text-sm",X?"bg-transparent p-0":(0,p.cn)("px-3 py-2",j?(0,p.cn)("text-white",c&&"rounded-br-md"):(0,p.cn)("oat-surface bg-[#F0EFED] dark:bg-black text-foreground",c&&"rounded-bl-md")),e.failed&&"opacity-80 ring-1 ring-destructive/50"),...j&&!X&&!w?eX:{},style:j&&!X?{backgroundColor:w?e$:eV}:void 0,children:[(0,t.jsx)(e0,{reactions:x,isOut:j,contactName:l,isGroup:o}),e.attachments&&e.attachments.length>0&&(0,t.jsx)(R.MessageAttachments,{attachments:e.attachments,bare:X,flush:G,flushTop:G,onColor:j&&!X,className:(0,p.cn)(V&&"mb-1.5")}),H&&(0,t.jsx)(D.MessageBalloon,{balloon:H,onColor:j&&!X}),V&&!Y&&(0,t.jsxs)("p",{className:"whitespace-pre-wrap [word-break:break-word] text-[13px] leading-relaxed [overflow-wrap:anywhere]",children:[(0,t.jsx)(E.MessageText,{text:e.content??""}),e.edited_at&&(0,t.jsx)(e5,{isOut:j})]}),W&&(K.loading||K.data)&&(0,t.jsx)("div",{className:(0,p.cn)("-mx-3 w-[240px] max-w-[calc(100%+1.5rem)]",Y?"-mt-2":"mt-1.5"),children:K.data?(0,t.jsx)(M.MessageLinkPreview,{url:W,data:K.data,onColor:j}):Y&&(0,t.jsx)(M.LinkPreviewSkeleton,{})}),e.has_attachments&&!e.attachments?.length&&(0,t.jsx)("p",{className:(0,p.cn)("text-[10px] mt-0.5",j?"text-white/70":"text-muted-foreground"),children:"Attachment"})]}),j&&(0,t.jsx)(eQ,{status:e.failed?"failed":e.sending?"sending":"sent",tone:w?"green":"blue"}),(z||q||V||Z||ee)&&(0,t.jsxs)(ed.MessageActionPill,{revealed:$.revealed,onDismiss:$.dismiss,orientation:$.orientation,isOutbound:j,forceVisible:N,hoverGroup:"group",notice:et&&(Z||ee)?ec.EDIT_UNSEND_UNSUPPORTED_NOTICE:null,children:[(0,t.jsx)(ed.MessageStarButton,{channel:"imessage",messageId:e.id}),z&&(0,t.jsx)(e_,{open:N,onOpenChange:e=>{k(e),e||S(null)}
1,align:j?"end":"start",reactions:x,canSendTapbacks:h,notice:C,onPick:(e,t)=>void en(e,t)}),q&&(0,t.jsx)(ed.MessageActionButton,{label:"Reply",onClick:()=>{$.dismiss(),b(e)},children:(0,t.jsx)(a.Reply,{className:"h-3.5 w-3.5"})}),V&&(0,t.jsx)(ed.MessageCopyButton,{text:e.content??""}),Z&&(0,t.jsx)(ed.MessageActionButton,{label:"Edit",disabled:et,disabledReason:ec.EDIT_UNSEND_UNSUPPORTED_NOTICE,onClick:()=>{$.dismiss(),B(e.content??""),U(!0)},children:(0,t.jsx)(s.Pencil,{className:"h-3.5 w-3.5"})}),ee&&(0,t.jsx)(ed.MessageActionButton,{label:"Unsend",disabled:et,disabledReason:ec.EDIT_UNSEND_UNSUPPORTED_NOTICE,destructive:!0,onClick:()=>void ea(),children:(0,t.jsx)(u.TrashIcon,{className:"h-3.5 w-3.5"})})]})]})}),T&&(0,t.jsx)("p",{className:"mt-0.5 max-w-[85%] break-words px-1 text-[11px] leading-snug text-muted-foreground",children:T}),e.failed&&(0,t.jsx)("p",{className:"text-[11px] text-destructive mt-0.5 px-1 max-w-[85%] break-words",children:e.error||"Failed to send"}),(0,t.jsx)(eJ,{label:J})]})}e.s(["BLUE",0,"#0A84FF","BLUE_NEWEST",0,ez,"BLUE_OLDEST",0,eq,"BUBBLE_BLUE_ATTR",0,eX,"BUBBLE_BLUE_VAR",0,eV,"EditedMarker",0,e5,"GREEN",0,e$,"IMessageChatPanel",0,function({conversationId:e,contactName:a,contactId:s,hideHeader:l,externalSearchQuery:i,autoFocusComposer:o,onBack:d}){let c=(0,y.useMergeVars)(s??null),u=(0,j.getCachedImessageThread)(e),[v,E]=(0,n.useState)(u??[]),[M,R]=(0,n.useState)(!!e&&!u),[_,P]=(0,n.useState)(""),[D,A]=(0,n.use
1State)(!1),[L,U]=(0,n.useState)(!1),O=(0,n.useRef)(null),B=(0,n.useRef)(null),[F,$]=(0,n.useState)({}),[z,q]=(0,n.useState)("inline"),[H,V]=(0,n.useState)(""),[X,G]=(0,n.useState)(null),[W,K]=(0,n.useState)(!1),[J,Q]=(0,n.useState)(eu.UNKNOWN_IMESSAGE_CAPABILITIES),{canSendTapbacks:Z,canEditUnsend:ee,canReplyThreaded:et}=J,[en,er]=(0,n.useState)({}),[es,ed]=(0,n.useState)(null),[em,eh]=(0,n.useState)(null),[ep,ef]=(0,n.useState)(!1),ex=I({onError:eh}),{addFiles:eg,addFromClipboard:eb,clear:ey}=ex,{peerTyping:ej,notifyTyping:ew,stopTyping:eN}=(0,el.useTypingIndicator)({channel:"imessage",conversationId:e}),[ek,eC]=(0,n.useState)(0),[eS,eT]=(0,n.useState)(null),{actions:eE,collectDurations:eM}=Y({attachments:ex.attachments,addFiles:eg,onNotice:eh,disabled:D}),eR=(i??"").trim()||H,e_=(0,n.useMemo)(()=>{if(!eR.trim())return v;let e=eR.toLowerCase().trim();return v.filter(t=>t.content?.toLowerCase().includes(e))},[v,eR]);(0,n.useEffect)(()=>{if(!e)return;let t=!1;return(0,eo.createClient)().from("imessage_conversations").select("service, handle, chat_identifier, is_group").eq("id",e).maybeSingle().then(({data:e})=>{if(t)return;let n=e??null;G(n?.service??null),eT(n?.handle??n?.chat_identifier??null),K(!!n?.is_group)}),()=>{t=!0}},[e]),(0,n.useEffect)(()=>{let e=!1;return fetch("/api/imessage/pair").then(e=>e.ok?e.json():null).then(t=>{if(e)return;let n=t?.devices;n&&0!==n.length&&Q((0,eu.deriveIMessageCapabilities)(n))}).catch(()=>{}),()=>{e=!0}},[]);let eI=(0,n.useCallback)(async()=>{if(e)try{let t=await (0,N.fetchJsonShared)(`/api/imessage/messages?conversationId=${encodeURIComponent(e)}&limit=200`);if(!t)return;let n=(t.messages??[]).slice().sort((e,t)=>new Date(e.sent_at).getTime()-new Date(t.sent_at).getTime());E(e=>{let t=new Set(n.map(e=>e.id)),r=e.filter(e=>e.id.startsWith("temp-")&&!(e._serverId&&t.has(e._serverId)));return[...n,...r]}),(0,j.setCachedImessageThread)(e,n)}catch{}finally{R(!1)}},[e]);(0,n.useEffect)(()=>{if(!e)return void R(!1);let t=!1,n=(0,j.getCachedImessageThread)(e),r=n?void 0:(0,j.getImessageThreadInflight)(e);return n||r||R(!0),(async()=>{if(r){let e=await Promise.race([r,new Promise(e=>setTimeout(()=>e(null),1500))]);if(t)return;e?.messages.length&&(E(e.messages),R(!1))}t||await eI()})(),()=>{t=!0}},[e,eI]),(0,N.useConversationPoll)(e?`imessage:${e}`:null,O,eI);let eU=(0,n.useRef)(!0),eO=M&&0===v.length?null:e,e$=(0,T.useScrollPinBottom)(O,B,eU,eO);eG(O,B,v);let ez=(0,n.useCallback)(()=>{let e=O.current;e&&(eU.current=e.scrollHeight-e.scrollTop-e.clientHeight<200)},[]),eq=(0,n.useRef)(null),eH=(0,n.useRef)(0),eV=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let e=O.current;if(!e)return;let t=v.length>0?v[v.length-1].id:null,n=eq.current,r=eH.current;if(eq.current=t,eH.current=e.scrollHeight,!eV.current&&v.length>0){e.scrollTop=e.scrollHeight,eV.current=!0;return}if(t===n){let t=e.scrollHeight-r;t>0&&(e.scrollTop+=t);return}eU.current&&(e.scrollTop=e.scrollHeight)},[v]);let eX=(0,n.useCallback)(async(e,t,n)=>{let r={kind:t,remove:n,at:new Date().toISOString()};er(n=>({...n,[e]:[...(n[e]??[]).filter(e=>e.kind!==t),r]}));let a=()=>er(t=>({...t,[e]:(t[e]??[]).filter(e=>e!==r)}));try{let r=await fetch("/api/imessage/react",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:e,kind:t,...n?{remove:!0}:{}})});if(r.ok)return null;if(a(),409===r.status){let e=await r.json().catch(()=>null);if(e?.error==="tapbacks_unsupported")return Q(e=>({...e,canSendTapbacks:!1})),ev;if(e?.error==="helper offline")return U(!0),eP;return e?.error||"Failed to send tapback"}return"Failed to send tapback"}catch{return a(),"Failed to send tapback"}},[]),eW=(0,n.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}),eh(null))},[]),eK=(0,n.useCallback)(async(e,t)=>{try{let n=await fetch(`/api/imessage/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(n.ok)return eI(),null;let r=await n.json().catch(()=>null);if(r?.error==="edit_unsupported")return Q(e=>({...e,canEditUnsend:!1})),r.detail??ec.EDIT_UNSEND_UNSUPPORTED_NOTICE;if(r?.error==="helper offline")return U(!0),eP;return r?.detail||r?.error||`Could not ${e} that message.`}catch{return`Could not ${e} that message.`}},[eI]),eJ=(0,n.useCallback)((e,t)=>eK("edit",{messageId:e,text:t}),[eK]),eQ=(0,n.useCallback)(e=>eK("unsend",{messageId:e}),[eK]),e0=(0,n.useCallback)(e=>{eb(e)&&e.preventDefault()},[eb]),e2=(0,n.useCallback)(e=>{ef(!1),e.dataTransfer?.files?.length&&(e.preventDefault(),eg(e.dataTransfer.files))},[eg]),e5=(0,n.useCallback)(e=>{Array.from(e.dataTransfer?.types??[]).includes("Files")&&(e.preventDefault(),ef(!0))},[]),e3=(0,n.useCallback)(async()=>{let t=ex.paths,n=!!_.trim();if(!n&&0===t.length||!e||D)return;if(eN(),ex.uploading)return void eh("Still uploading. Send again once the attachment finishes.");let r=n?(0,k.resolveTemplateVarsLenient)(_.trim(),c):"";P(""),ed(null),eh(null),A(!0);let a=`temp-${Date.now()}`,s=new Date().toISOString(),l={id:a,content:r,is_outbound:!0,sender_handle:null,sender_user_id:null,
1service:null,has_attachments:t.length>0,attachments:ex.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})),sent_at:s,created_at:s,sending:!0,...es?{reply_to:{id:es.messageId,content:es.content,is_outbound:es.isOutbound,sender_handle:es.senderHandle,attachments:es.attachments}}:{}};E(e=>[...e,l]),ey();try{let n=await fetch("/api/imessage/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversationId:e,message:r,...t.length>0?{attachmentPaths:t,attachmentDurations:eM()}:{},...es?{replyToGuid:es.guid}:{}})});if(409===n.status){U(!0),E(e=>e.map(e=>e.id===a?{...e,sending:!1,failed:!0,error:eP}:e));return}if(!n.ok){let e="Failed to send message";try{let t=await n.json();t?.error&&(e=t.error)}catch{}E(t=>t.map(t=>t.id===a?{...t,sending:!1,failed:!0,error:e}:t));return}let s=await n.json();U(!1),"quoted"===s.replyMode&&Q(e=>({...e,canReplyThreaded:!1}));let l=s.messageId;l&&$(e=>({...e,[l]:a})),E(e=>e.map(e=>e.id===a?{...e,_serverId:s.messageId}:e)),(0,w.dispatchInboxRefresh)()}catch{E(e=>e.map(e=>e.id===a?{...e,sending:!1,failed:!0,error:"Failed to send message"}:e))}finally{A(!1)}},[_,e,D,c,ex,ey,eM,es,eN]),e4=(0,n.useCallback)(async t=>{let n=ex.paths,r=!!_.trim();if(!r&&0===n.length||!e||D)return;if(ex.uploading)return void eh("Still uploading. Schedule again once the attachment finishes.");let a=r?(0,k.resolveTemplateVarsLenient)(_.trim(),c):"",s=eM();A(!0),eh(null);try{let r=await fetch("/api/messages/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:a,conversationId:e,channel:"imessage",scheduledAt:t.toISOString(),...n.length>0?{attachmentPaths:n,attachmentDurations:s}:{},...es?{replyToGuid:es.guid}:{}})}),l=await r.json().catch(()=>null);if(!r.ok)return void eh(l?.reason||l?.error||"Could not schedule that message.");P(""),ed(null),ey(),l?.warnings?.length&&eh(l.warnings.join(" ")),eC(e=>e+1)}catch{eh("Could not schedule that message.")}finally{A(!1)}},[_,e,D,c,ex,ey,eM,es]);if(!e)return(0,t.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${l?"":"border rounded-2xl bg-card"}`,"data-channel-panel":!0,children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b bg-muted/30 shrink-0",children:[d&&(0,t.jsx)(h.Button,{variant:"ghost",size:"sm",className:"rounded-3xl h-7 w-7 p-0 shrink-0",onClick:d,"aria-label":"Back",children:(0,t.jsx)(r.ChevronLeft,{className:"h-4 w-4"})}),(0,t.jsx)(S.IMessageSquircle,{}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"iMessage"})]}),(0,t.jsxs)("div",{className:"rounded-lg border border-dashed m-4 p-8 text-center space-y-2",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No iMessage conversation yet."}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Conversations sync from your paired Mac. Pair one in Settings, then message this person from Messages."})]})]});let e8=eB(e_),e7=eY(v),e9=es?{messageId:es.messageId,name:es.isOutbound?"You":eZ({senderHandle:es.senderHandle,contactName:a,isGroup:W,unknown:"Them"}),...e1(es),...!1===et?{note:eD}:{}}:null,te=(0,t.jsxs)(t.Fragment,{children:[!l&&(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted/30 shrink-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 overflow-hidden",children:[d&&(0,t.jsx)(h.Button,{variant:"ghost",size:"sm",className:"rounded-3xl h-7 w-7 p-0 shrink-0",onClick:d,"aria-label":"Back",children:(0,t.jsx)(r.ChevronLeft,{className:"h-4 w-4"})}),(0,t.jsx)(S.IMessageSquircle,{})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0","data-channel-actions":!0,children:[(0,t.jsx)(x.MessageSearchPill,{value:H,onChange:V}),(0,t.jsx)(g.ChatExpandButtons,{expansion:z,onChange:q})]})]}),(0,t.jsxs)("div",{className:"flex-1 min-h-0 relative flex flex-col",onDragOver:e5,onDragLeave:()=>ef(!1),onDrop:e2,children:[M&&0===v.length||!e$&&v.length>0?(0,t.jsx)("div",{className:"absolute inset-0 z-10 bg-card pointer-events-none flex flex-col overflow-hidden",children:(0,t.jsx)(C.MessageListSkeleton,{})}):null,ep&&(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/90",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Drop to attach"})}),(0,t.jsx)("div",{ref:O,className:"flex-1 min-h-0 min-w-0 overflow-y-auto overflow-x-hidden",onScroll:ez,children:(0,t.jsx)("div",{ref:B,className:(0,p.cn)(f.THREAD_GUTTER_X,"py-3"),"data-reply-run-scope":!0,children:M||0!==e_.length?e_.map(e=>{let n=e8.get(e.id);return(0,t.jsxs)("div",{className:(0,p.cn)(!n?.separator&&(n?.isRunStart?"mt-2":"mt-[2px]")),children:[n?.separator&&(0,t.jsx)(eF,{...n.separator}),(0,t.jsx)(e6,{msg:e,showSender:!1,contactName:a,convoService:X,isGroup:W,isLastOutbound:e.id===e7,isRunEnd:n?.isRunEnd??!0,replyRun:n?.replyRun??null,canSendTapbacks:Z,canEditUnsend:ee,reactions:eL(e.reactions,en[e.id]),onReact:eX,onReply:eW,onEdit:eJ,onUnsend:eQ})]},F[e.id]??e.id)}):(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-2",children:[(0,t.jsx)(m.ChatBubbleIcon,{className:"h-8 w-8 text-muted-foreground
1/30"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:eR.trim()?"No messages match your search":"No messages yet. Send the first iMessage."})]})})})]}),L&&(0,t.jsx)("div",{className:"px-3 py-2 border-t bg-amber-500/10 shrink-0",children:(0,t.jsx)("p",{className:"text-xs text-amber-900 dark:text-amber-200",children:eP})}),ej&&(0,t.jsx)("div",{className:(0,p.cn)(f.THREAD_GUTTER_X,"shrink-0"),children:(0,t.jsx)(ei.TypingIndicator,{name:a})}),(0,t.jsxs)("div",{className:"border-t py-2 shrink-0 bg-card px-2",onPaste:e0,children:[em&&(0,t.jsx)("p",{className:"px-1.5 pb-1 text-[11px] leading-snug text-muted-foreground",children:em}),(0,t.jsx)(ea,{conversationId:e??null,peer:eS,refreshToken:ek,onError:eh}),(0,t.jsx)(b.ChatInputBox,{placeholder:!W&&a?.trim()?`Message ${a.trim()}...`:eA(X)?"Text Message":"iMessage",text:_,onTextChange:P,draftKey:e?`imessage:${e}`:void 0,onTyping:eA(X)?void 0:ew,mergeVars:c,onSubmit:e3,sending:D,autoFocus:o,attachments:ex.attachments,onRemoveAttachment:ex.remove,onDropFiles:eg,replyTo:e9,onCancelReply:()=>ed(null),trailingActions:eE,onScheduleSend:e=>void e4(e)})]})]});return"inline"!==z?(0,t.jsx)(g.ChatExpandedSurface,{expansion:z,title:"iMessage",onCollapse:()=>q("inline"),children:te}):(0,t.jsx)("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${l?"":"border rounded-2xl bg-card"}`,"data-channel-panel":!0,children:te})},"InlineMessageEditor",0,e4,"QuotedReplyBubble",0,e2,"RECEIPT_CAVEAT",0,eW,"REPLY_QUOTED_NOTICE",0,eD,"ReceiptLine",0,eJ,"SEPARATOR_GAP_MS",0,36e5,"SendProgressPill",0,eQ,"TapbackChips",0,e0,"ThreadTimeSeparator",0,eF,"UnsentBubble",0,e3,"applyReactionOverlays",0,eL,"bubbleTimeTitle",0,eO,"inboundSenderName",0,eZ,"lerpHex",0,eH,"newestOutboundId",0,eY,"receiptLabel",0,eK,"replyStripMedia",0,e1,"separatorParts",0,eU,"threadRowMeta",0,eB,"useBubbleViewportGradient",0,eG],869407)},809868,e=>{"use strict";var t=e.i(843476),n=e.i(476819),r=e.i(271645),a=e.i(174080),s=e.i(178583),l=e.i(493886),i=e.i(653339),o=e.i(836192),o=o,d=e.i(431343),c=e.i(495242),u=e.i(611423),m=e.i(761691),h=e.i(403986),p=e.i(9692),f=e.i(403568),x=e.i(647163),g=e.i(609216);function b(e){let t=(e.mime_type??"").toLowerCase();if(t.startsWith("image/"))return"image";if(t.startsWith("video/"))return"video";if(t.startsWith("audio/"))return"audio";let n=(e.filename??"").split(".").pop()?.toLowerCase()??"";return["png","jpg","jpeg","gif","webp","heic","heif","bmp"].includes(n)?"image":["mp4","mov","m4v","webm","avi"].includes(n)?"video":["mp3","m4a","aac","wav","caf","amr","ogg"].includes(n)?"audio":"file"}function v(e){let t=b(e);return"image"===t||"video"===t}function y(e){return!!e?.length&&e.every(v)}let j="rgba(255, 255, 255, 0.35)",w="#ffffff";function N(e,t){let n=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let r=n.current;r?.complete&&(r.naturalWidth>0?e(r):t())}),n}function k({att:e,onOpen:a,plain:s,tile:l,radius:i}){let[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)(!1),h=N((0,r.useCallback)(()=>d(!0),[]),(0,r.useCallback)(()=>m(!0),[])),p=e.width&&e.height?`${e.width} / ${e.height}`:"4 / 3";return c||!e.url?(0,t.jsx)(P,{att:e}):(0,t.jsxs)("button",{type:"button",onClick:a,className:(0,x.cn)("relative block w-full overflow-hidden",i,l&&"aspect-square",s?"bg-transparent":"bg-card"),"aria-label":`Open ${e.filename||"image"}`,children:[!o&&(l?(0,t.jsx)(u.Skeleton,{className:(0,x.cn)("absolute inset-0 h-full w-full",i)}):(0,t.jsx)("div",{style:{aspectRatio:p,maxHeight:(0,n.designPx)(320)},className:"w-full",children:(0,t.jsx)(u.Skeleton,{className:(0,x.cn)("h-full w-full",i)})})),(0,t.jsx)("img",{ref:h,src:e.url,alt:e.filename||"",loading:"lazy",onLoad:()=>d(!0),onError:()=>m(!0),className:(0,x.cn)("block",i,l?"h-full w-full object-cover":"h-auto max-h-[320px] w-full object-contain",o?"opacity-100":"absolute inset-0 opacity-0")})]})}let C="cubic-bezier(.2,.8,.25,1)",S=3/4;function T(e,t=0){let n=Math.max(0,e-t);return`translateX(${8*n}px) translateY(${6*n}px) scale(${1-.025*n}) rotate(${1.5*n}deg)`}function E(e,t=0){let n=Math.max(0,e-t);return`translateX(${-(8*n)}px) translateY(${6*n}px) scale(${1-.025*n}) rotate(${-(1.5*n)}deg)`}function M(e,t=0){return Math.max(0,1-.15*Math.max(0,e-t))}
1function R({items:e,radius:n,onOpen:a}){let[s,l]=(0,r.useState)(0),[i,o]=(0,r.useState)(S),d=(0,r.useRef)(null),c=(0,r.useRef)(null),u=(0,r.useRef)(null),m=(0,r.useRef)(0),h=(0,r.useRef)(!1),p=(0,r.useCallback)(()=>d.current?.querySelectorAll("[data-deck-card]")??[],[]),f=(0,r.useCallback)((e,t)=>{let n=d.current?.clientWidth||260,r=t?`transform 300ms ${C}, opacity 300ms ease-out`:"none",a=Math.min(1,Math.abs(e)/120),s=0===e?null:e<0?"right":"left";for(let t of p()){let l=Number(t.dataset.deckCard);if(t.style.transition=r,0===l){let r=1-Math.min(.08,Math.abs(e)/n*.12);t.style.transform=e?`translateX(${e}px) scale(${r}) rotate(${e/n*6}deg)`:"none",t.style.opacity=e?String(1-Math.min(.3,Math.abs(e)/n*.4)):"1";continue}let i=l<0?"left":"right",o=Math.abs(l),d=s===i,c=d?a:0;t.style.transform="right"===i?T(o,c):E(o,c);let u=s&&!d?1-Math.min(1,1.3*a):1;t.style.opacity=String(M(o,c)*u),t.style.zIndex=String((20-o)*2+ +!!d)}},[p]),g=(0,r.useCallback)(e=>{let t=d.current?.clientWidth||260;h.current=!0;let n=1===e?-(.35*t):.35*t,r=1===e?"right":"left",a=`transform 300ms ${C}, opacity 300ms ease-out`;for(let e of p()){let s=Number(e.dataset.deckCard);if(e.style.transition=a,0===s){e.style.transform=`translateX(${n}px) scale(0.88) rotate(${n/t*5}deg)`,e.style.opacity="0";continue}let l=s<0?"left":"right";if(l!==r)continue;let i=Math.abs(s);e.style.transform="right"===l?T(i-1):E(i-1),e.style.opacity=String(M(i-1))}window.setTimeout(()=>{l(t=>t+e),h.current=!1,requestAnimationFrame(()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{c.current||f(0,!1)})))},300)},[p,f]),b=(0,r.useRef)(!1),v=(0,r.useRef)(null),y=(0,r.useCallback)((t,n)=>{let r=c.current;if(!r||h.current)return;let a=t-r.x,l=n-r.y;if(!u.current){if(8>Math.abs(a)&&8>Math.abs(l))return;u.current=Math.abs(a)>1.2*Math.abs(l)?"h":"v"}if("h"!==u.current)return;let i=0===s&&a>0,o=s===e.length-1&&a<0;m.current=i||o?.18*a:a,b.current=!0,f(m.current,!1)},[s,e.length,f]),j=(0,r.useCallback)(()=>{let t=c.current;if(c.current=null,!t||"h"!==u.current||h.current)return;let n=m.current;m.current=0;let r=Math.abs(n)>=48||Date.now()-t.t<200&&Math.abs(n)>24;return r&&n<0&&s<e.length-1?g(1):r&&n>0&&s>0?g(-1):void f(0,!0)},[g,s,e.length,f]),w=(0,r.useCallback)(e=>{if(h.current)return;v.current?.(),c.current={x:e.clientX,y:e.clientY,t:Date.now()},u.current=null,m.current=0,b.current=!1;let t=e.pointerId,n=e=>{e.pointerId===t&&y(e.clientX,e.clientY)},r=e=>{e.pointerId===t&&(a(),j())},a=()=>{window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",r),v.current=null};v.current=a,window.addEventListener("pointermove",n),window.addEventListener("pointerup",r),window.addEventListener("pointercancel",r)},[j,y]);(0,r.useEffect)(()=>()=>v.current?.(),[]);let N=[];for(let t=-2;t<=3;t++){let n=s+t;n>=0&&n<e.length&&N.push({att:e[n],depth:t})}let k=16*(s>0),P=24*(s<e.length-1);return(0,t.jsx)("div",{className:"min-w-0",style:{paddingLeft:k,paddingRight:P,paddingBottom:18},children:(0,t.jsxs)("div",{ref:d,"data-owns-horizontal-swipe":"",className:"relative w-full touch-pan-y select-none",style:{aspectRatio:String(i)},onPointerDown:w,children:[N.map(({att:r,depth:l})=>{let i=0===l;return(0,t.jsx)("button",{type:"button","data-deck-card":l,onClick:i?()=>{if(b.current){b.current=!1;return}a(r)}:void 0,onKeyDown:i?t=>{"ArrowRight"===t.key&&s<e.length-1?(t.preventDefault(),g(1)):"ArrowLeft"===t.key&&s>0&&(t.preventDefault(),g(-1))}:void 0,tabIndex:i?0:-1,"aria-hidden":!i,"aria-label":i?`Open ${r.filename||"photo"}`:void 0,className:(0,x.cn)("absolute inset-0 block overflow-hidden bg-card",n,!i&&"pointer-events-none"),style:{transform:i?"none":l<0?E(-l):T(l),opacity:i?1:M(Math.abs(l)),zIndex:(20-Math.abs(l))*2,transformOrigin:"center center",willChange:"transform, opacity"},children:(0,t.jsx)(_,{att:r,radius:n,onRatio:i&&0===l?o:void 0})},r.id)}),(0,t.jsxs)("span",{className:"pointer-events-none absolute right-2 top-2 z-[50] rounded-full px-2 py-0.5 text-[10px] font-medium tabular-nums text-white",style:{backgroundColor:"rgba(0, 0, 0, 0.45)",backdropFilter:"blur(4px)"},children:[s+1," / ",e.length]})]})})}function _({att:e,radius:n,onRatio:a}){let[s,l]=(0,r.useState)(!1),[i,d]=(0,r.useState)(!1),c=(0,r.useCallback)(e=>{l(!0);
1let{naturalWidth:t,naturalHeight:n}=e;t>0&&n>0&&a?.(Math.min(1.4,Math.max(.62,t/n)))},[a]),m=N(c,(0,r.useCallback)(()=>d(!0),[]));return i||!e.url?(0,t.jsx)("span",{className:"flex h-full w-full items-center justify-center bg-muted",children:(0,t.jsx)(o.default,{className:"h-5 w-5 text-muted-foreground"})}):(0,t.jsxs)(t.Fragment,{children:[!s&&(0,t.jsx)(u.Skeleton,{className:(0,x.cn)("absolute inset-0 h-full w-full",n)}),(0,t.jsx)("img",{ref:m,src:e.url,alt:e.filename||"",loading:"lazy",draggable:!1,onLoad:e=>c(e.currentTarget),onError:()=>d(!0),className:(0,x.cn)("h-full w-full object-cover",n,s?"opacity-100":"opacity-0")})]})}function P({att:e}){return(0,t.jsxs)("span",{className:"flex items-center gap-2 rounded-xl border border-border bg-card px-3 py-2",children:[(0,t.jsx)(o.default,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"block truncate text-[12px] text-foreground",children:e.filename||"Attachment"}),(0,t.jsx)("span",{className:"block text-[10px] text-muted-foreground",children:"Not available yet"})]})]})}function D({att:e}){let n=b(e),r="file"===n&&(0,m.isPdfFile)(e.mime_type??void 0,e.filename??void 0),a="video"===n?l.Film:"audio"===n?i.Music:s.FileText,o=e.byte_size?(0,p.formatFileSize)(e.byte_size):"";return e.url?(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 rounded-xl border border-border bg-card px-3 py-2 transition-colors duration-150 hover:bg-muted",children:[r?(0,t.jsx)(m.PdfIcon,{className:"h-4 w-4 shrink-0"}):(0,t.jsx)(a,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"block truncate text-[12px] text-foreground",children:e.filename||"Attachment"}),o&&(0,t.jsx)("span",{className:"block text-[10px] text-muted-foreground",children:o})]})]}):(0,t.jsx)(P,{att:e})}function A(e){return"audio"===b(e)&&(!!(0,f.isVoiceNoteFilename)(e.filename)||!e.is_sticker&&!!e.duration_seconds&&e.duration_seconds>0)}function L({att:e,onColor:n}){let a=(0,r.useRef)(null),[s,l]=(0,r.useState)(!1),[i,o]=(0,r.useState)(e.duration_seconds??null),[u,m]=(0,r.useState)(0),h=A(e),p=(0,r.useMemo)(()=>h?(0,f.voiceNoteBars)(e.id):[],[h,e.id]),g=(0,r.useCallback)(()=>{let e=a.current;e&&(e.paused?e.play().catch(()=>l(!1)):e.pause())},[]);if(!e.url)return(0,t.jsx)(P,{att:e});let b=i&&i>0?Math.min(1,u/i):0,v=Math.round(b*p.length),y=h?"voice note":e.filename||"audio";return(0,t.jsxs)("span",{className:"flex w-full max-w-[260px] items-center gap-2.5",children:[(0,t.jsx)("button",{type:"button",onClick:g,"aria-label":`${s?"Pause":"Play"} ${y}`,className:(0,x.cn)("flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-opacity duration-150 hover:opacity-80",n?"text-white":"bg-muted text-foreground"),style:n?{backgroundColor:"rgba(255, 255, 255, 0.22)"}:void 0,children:s?(0,t.jsx)(c.Pause,{className:"h-3.5 w-3.5"}):(0,t.jsx)(d.Play,{className:"ml-0.5 h-3.5 w-3.5"})}),h?(0,t.jsx)("span",{className:"flex h-6 min-w-0 flex-1 items-center gap-[2px]","aria-hidden":!0,children:p.map((e,r)=>(0,t.jsx)("span",{className:(0,x.cn)("w-[2px] flex-1 rounded-full",!n&&(r<v?"bg-foreground":"bg-muted-foreground")),style:{height:`${Math.round(100*e)}%`,opacity:n||r<v?1:.35,backgroundColor:n?r<v?w:j:void 0}},r))}):(0,t.jsx)("span",{className:(0,x.cn)("h-[3px] min-w-0 flex-1 overflow-hidden rounded-full",!n&&"bg-muted"),style:n?{backgroundColor:j}:void 0,"aria-hidden":!0,children:(0,t.jsx)("span",{className:(0,x.cn)("block h-full rounded-full",!n&&"bg-foreground"),style:{width:`${Math.round(100*b)}%`,backgroundColor:n?w:void 0}})}),(0,t.jsx)("span",{className:(0,x.cn)("shrink-0 text-[11px] tabular-nums",!n&&"text-muted-foreground"),style:n?{color:"rgba(255, 255, 255, 0.85)"}:void 0,children:(0,f.formatVoiceNoteDuration)(s||u>0?u:i)}),(0,t.jsx)("audio",{ref:a,src:e.url,preload:"metadata",onPlay:()=>l(!0),onPause:()=>l(!1),onLoadedMetadata:e=>{let t=e.currentTarget.duration;Number.isFinite(t)&&t>0&&o(t)},onTimeUpdate:e=>m(e.currentTarget.currentTime),onEnded:()=>{l(!1),m(0)},className:"hidden"})]})}e.s(["MessageAttachments",0,function({attachments:e,className:n,bare:s=!1,flush:l=!1,flushTop:i=!1,onColor:o=!1}){let[d,c]=(0,r.useState)(null),u=(0,r.useMemo)(()=>(e??[]).filter(e=>"image"===b(e)&&!!e.url).map(e=>({url:e.url,mediaType:e.mime_type||"image/jpeg",filename:e.filename||"Image",size:e.byte_size??0})),[e]),m=(0,r.useCallback)(e=>{let t=u.findIndex(t=>t.url===e.url);c(t>=0?t:0)},[u]);if(!e?.length)return null;let p=e.length>1,f=p&&e.every(e=>"image"===b(e)&&!!e.url&&!e.is_sticker),v=s||l?"rounded-2xl":"rounded-xl",y=s||l;return f?(0,t.jsxs)("div",{className:(0,x.cn)("min-w-0",s?"w-[260px] max-w-full":"w-[240px] max-w-full",n),children:[(0,t.jsx)(R,{items:e,radiu
1s:v,onOpen:m}),null!==d&&u.length>0&&"u">typeof document&&(0,a.createPortal)((0,t.jsx)(h.MediaPreviewModal,{media:u,initialIndex:d,onClose:()=>c(null)}),document.body)]}):(0,t.jsxs)("div",{className:(0,x.cn)("min-w-0",p?"grid grid-cols-2 gap-1.5":"flex flex-col gap-1.5",s&&"w-[260px] max-w-full",!s&&!l&&"w-[240px] max-w-full",l&&"-mx-3",l&&i&&"-mt-2",n),children:[e.map(e=>{let n=b(e);return"image"===n?(0,t.jsx)(k,{att:e,plain:y||!!e.is_sticker,tile:p,radius:v,onOpen:()=>m(e)},e.id):"video"===n&&e.url?(0,t.jsx)(g.VideoPlayer,{src:e.url,className:(0,x.cn)("block w-full",v),videoClassName:(0,x.cn)("w-full",p?"aspect-square object-cover":"h-auto max-h-[320px] object-contain")},e.id):"audio"===n&&e.url?(0,t.jsx)(L,{att:e,onColor:o},e.id):(0,t.jsx)(D,{att:e},e.id)}),null!==d&&u.length>0&&"u">typeof document&&(0,a.createPortal)((0,t.jsx)(h.MediaPreviewModal,{media:u,initialIndex:d,onClose:()=>c(null)}),document.body)]})},"isMediaOnly",0,function(e,t){return!(t??"").trim()&&y(e)},"isVisualMediaOnly",0,y,"quotedAttachmentSummary",0,function(e,t){let n=e?.[0];if(!n)return{label:t?"Attachment":"",thumbUrl:null,kind:null};let r=b(n),a=e?.length??1;return{label:"image"===r?n.is_sticker?"Sticker":"image/gif"===(n.mime_type??"").toLowerCase()?"GIF":a>1?`${a} Photos`:"Photo":"video"===r?a>1?`${a} Videos`:"Video":"audio"===r?A(n)?"Audio message":"Audio":n.filename||"File",thumbUrl:"image"===r?n.url:null,kind:r}}],809868)},713152,264648,e=>{"use strict";var t=e.i(843476),n=e.i(271645);function r(e){return(e??"").replace(/ /g," ").trim()}function a(e){let t=/(\p{Sc}\s?[\d][\d.,]*|[\d][\d.,]*\s?\p{Sc})/u.exec(e);if(!t)return{amount:null,label:e||null};let n=(e.slice(0,t.index)+e.slice(t.index+t[0].length)).replace(/\s+/g," ").trim();return{amount:t[0].replace(/\s+/g,""),label:n||null}}e.s(["describeBalloon",0,function(e){if(!e||!e.bundle_id)return null;let t=r(e.app)||r(e.caption)||"iMessage app",n=r(e.summary)||null,s=r(e.subcaption);if(e.bundle_id.includes("PeerPaymentMessagesExtension")){let{amount:e,label:r}=a(s),l=n?a(n).amount:null;return{kind:"apple_cash",app:t,amount:e??l,label:r,summary:n,state:null}}if(e.bundle_id.includes("FindMyMessagesApp")){let e,r=n??s??null;return{kind:"location",app:t,amount:null,label:r,summary:n,state:r?(e=r.toLowerCase()).includes("stopped")?"stopped":e.includes("request")?"requested":e.includes("started sharing")?"started":e.includes("shared")||e.includes("sharing")?"shared":null:null}}return{kind:"app",app:t,amount:null,label:s||null,summary:n,state:null}}],264648);var s=e.i(647163);let l={started:"Started sharing location",stopped:"Stopped sharing location",shared:"Shared location",requested:"Requested location"};function i({muted:e}){return(0,t.jsxs)("div",{"aria-hidden":!0,className:(0,s.cn)("relative h-[76px] overflow-hidden bg-[#E7E2D6] dark:bg-[#23221F]",e&&"opacity-60 saturate-50"),children:[(0,t.jsx)("div",{className:"absolute -left-2 -top-3 h-12 w-16 rounded-lg bg-[#CFDCC0] dark:bg-[#2C332A]"}),(0,t.jsx)("div",{className:"absolute -bottom-4 -right-3 h-11 w-16 rounded-full bg-[#C4D6DE] dark:bg-[#26313A]"}),(0,t.jsx)("div",{className:"absolute inset-x-0 top-7 h-[5px] bg-[#FBFAF7] dark:bg-white/12"}),(0,t.jsx)("div",{className:"absolute inset-y-0 left-[58%] w-[5px] bg-[#FBFAF7] dark:bg-white/12"}),(0,t.jsx)("div",{className:"absolute inset-x-0 bottom-3 h-[3px] bg-[#FBFAF7]/80 dark:bg-white/8"}),(0,t.jsxs)("div",{className:"absolute left-[58%] top-7 -translate-x-1/2 -translate-y-1/2",children:[(0,t.jsx)("span",{className:"absolute -inset-[9px] rounded-full bg-[#2F7CF6]/18 dark:bg-[#4C93FF]/20"}),(0,t.jsx)("span",{className:"relative block h-[11px] w-[11px] rounded-full border-2 border-white bg-[#2F7CF6] shadow-sm dark:bg-[#4C93FF]"})]})]})}let o=(0,n.memo)(function({balloon:e,onColor:n=!1,className:r}){if("apple_cash"===e.kind)return(0,t.jsxs)("div",{className:(0,s.cn)("w-[196px] max-w-full rounded-2xl border border-[#3A3A3C] bg-[#1C1C1E] px-4 py-3","text-white dark:bg-[#2C2C2E]",r),children:[(0,t.jsx)("p",{className:"text-[11px] font-medium leading-none text-[#9A9A9E]",children:e.app}),e.amount?(0,t.jsx)("p",{className:"mt-2 text-[26px] font-semibold leading-none tracking-tight",children:e.amount}):(0,t.jsx)("p",{className:"mt-2 text-[15px] font-medium leading-snug",children:e.summary??e.a
1pp}),e.label&&(0,t.jsx)("p",{className:"mt-1.5 text-[11px] leading-none text-[#9A9A9E]",children:e.label})]});if("location"===e.kind){let n="stopped"===e.state,a=e.state?l[e.state]:e.summary??e.label??"Location";return(0,t.jsxs)("div",{className:(0,s.cn)("w-[196px] max-w-full overflow-hidden rounded-2xl border border-border/70 bg-card",r),children:[(0,t.jsx)(i,{muted:n}),(0,t.jsxs)("div",{className:"px-3 py-2",children:[(0,t.jsx)("p",{className:"text-[10px] font-medium leading-none text-muted-foreground",children:e.app}),(0,t.jsx)("p",{className:(0,s.cn)("mt-1 text-[13px] font-medium leading-snug text-foreground",n&&"text-muted-foreground"),children:a})]})]})}return(0,t.jsxs)("div",{className:r,children:[(0,t.jsx)("p",{className:(0,s.cn)("text-[10px] font-medium leading-snug",n?"text-white/70":"text-muted-foreground"),children:e.app}),(0,t.jsx)("p",{className:"mt-0.5 text-[13px] leading-relaxed",children:e.summary??e.label??e.app})]})});e.s(["MessageBalloon",0,o,"isBareBalloonKind",0,function(e){return e?.kind==="apple_cash"||e?.kind==="location"}],713152)},800126,564138,e=>{"use strict";var t=e.i(271645);let n="inbox:refresh",r=new Map,a=null,s=!1;function l(e){for(let t of e.subs)if(function(e){if(!e||!e.isConnected||"u"<typeof document||"visible"!==document.visibilityState||0===e.getClientRects().length)return!1;let t=e.checkVisibility;if(t&&!t.call(e,{visibilityProperty:!0})||e.closest("[data-behind-card],[inert]"))return!1;let n=e.getBoundingClientRect();return n.bottom>0&&n.right>0&&n.top<window.innerHeight&&n.left<window.innerWidth}(t.el.current))return!0;return!1}function i(e){if(e.running){e.rerun=!0;return}e.running=!0,e.rerun=!1,e.lastRunAt=Date.now(),Promise.allSettled([...e.subs].map(e=>Promise.resolve().then(e.refresh))).then(()=>{e.running=!1,e.rerun&&e.subs.size>0&&(l(e)?i(e):e.lastRunAt=0)})}function o(){if("u"<typeof document||"visible"!==document.visibilityState)return;let e=Date.now();for(let t of r.values())!t.running&&(0===t.lastRunAt||!(e-t.lastRunAt<t.intervalMs))&&l(t)&&i(t)}function d(){for(let e of r.values())l(e)?i(e):e.lastRunAt=0}function c(){"visible"===document.visibilityState&&o()}let u=new Map;e.s(["fetchJsonShared",0,function(e){let t=Date.now(),n=u.get(e);if(n&&t-n.at<250)return n.promise;let r=fetch(e).then(e=>e.ok?e.json():null).finally(()=>{u.get(e)?.promise===r&&u.delete(e)});return u.set(e,{at:t,promise:r}),r},"useConversationPoll",0,function(e,l,i,u=5e3){let m=(0,t.useRef)(i);(0,t.useEffect)(()=>{m.current=i}),(0,t.useEffect)(()=>{if(!e)return;let t={el:l,refresh:()=>m.current()},i=r.get(e);return i||(i={subs:new Set,intervalMs:u,lastRunAt:Date.now(),running:!1,rerun:!1},r.set(e,i)),i.intervalMs=Math.min(i.intervalMs,u),i.subs.add(t),a||(a=setInterval(o,1e3)),s||(s=!0,window.addEventListener(n,d),document.addEventListener("visibilitychange",c)),()=>{let l=r.get(e);l&&(l.subs.delete(t),0===l.subs.size&&r.delete(e),!(r.size>0)&&(a&&(clearInterval(a),a=null),s&&(s=!1,window.removeEventListener(n,d),document.removeEventListener("visibilitychange",c))))}},[e,l,u])}],800126);var m=e.i(843476),h=e.i(611423),p=e.i(647163);let f=new Map,x=new Map,g=[],b=0,v=!1;function y(){v||(v=!0,j())}function j(){if(!v)return void setTimeout(y,300);for(;b<2&&g.length>0;){let e=g.shift();b+=1,e()}}let w="w-full overflow-hidden",N="h-[132px] w-full rounded-t-2xl",k="px-3 pt-2",C=(0,t.memo)(function({url:e,data:n,onColor:r=!1,className:a}){let[s,l]=(0,t.useState)(!1),i=function(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return""}}(e)||n.siteName,o=!!n.image&&!s;return(0,m.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),title:e,className:(0,p.cn)(w,"block transition-opacity duration-150 hover:opacity-90",a),children:[o&&(0,m.jsx)("img",{src:n.image,alt:"",loading:"lazy",onError:()=>l(!0),className:(0,p.cn)(N,"block bg-muted object-cover")}),(0,m.jsxs)("div",{className:k,children:[n.title&&(0,m.jsx)("p",{className:(0,p.cn)("line-clamp-2 text-[12px] font-medium leading-snug",r?"text-white":"text-foreground"),children:n.title}),i&&(0,m.jsx)("p",{className:(0,p.cn)("truncate text-[10px] leading-snug",!r&&"text-muted-foreground",n.title&&"mt-0.5"),style:r?{color:"rgba(255, 255, 255, 0.8)"}:void 0,children:i})]})]})});e.s(["LinkPreviewSkeleton",0,function({className:e}){return(0,m.jsxs)("div",{className:(0,p.cn)(w,e),"aria-hidden":!0,
1children:[(0,m.jsx)(h.Skeleton,{className:(0,p.cn)(N,"rounded-b-none")}),(0,m.jsxs)("div",{className:(0,p.cn)(k,"space-y-1.5"),children:[(0,m.jsx)(h.Skeleton,{className:"h-3 w-3/4 rounded-sm"}),(0,m.jsx)(h.Skeleton,{className:"h-2.5 w-1/3 rounded-sm"})]})]})},"MessageLinkPreview",0,C,"useLinkPreview",0,function(e){let[n,r]=(0,t.useState)(()=>e&&f.has(e)?{data:f.get(e)??null,loading:!1}:{data:null,loading:!!e});return(0,t.useEffect)(()=>{if(!e)return void r({data:null,loading:!1});if(f.has(e))return void r({data:f.get(e)??null,loading:!1});let t=!0;return r({data:null,loading:!0}),(function(e){var t;let n=x.get(e);if(n)return n;let r=(t=()=>fetch(`/api/og-preview?url=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(t=>{let n=t&&(t.title||t.image)?t:null;return f.set(e,n),n}).catch(()=>(f.set(e,null),null)),new Promise((e,n)=>{g.push(()=>{t().then(e,n).finally(()=>{b-=1,j()})}),j()})).finally(()=>{x.delete(e)});return x.set(e,r),r})(e).then(e=>{t&&r({data:e,loading:!1})}),()=>{t=!1}},[e]),n}],564138)}]);

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.